Session 2 Network Layer
Session 2 Network Layer
2
22
Session Topics
• Position of Network Layer
• Duties of Network Layer
• Internetwork
• Network Layer in an Internetwork
• Datagram Approach
• IP Addressing
• Dotted-Decimal Notation
• Classful Addressing
• Finding the Address Class
• Netid and Hostid
• Subnetting
• Default Masks
• Subnet Mask
3
33
Position of Network Layer
4
44
Network Layer
5
55
Network Layer
7
7
Duties of Network Layer
9
99
Internetwork
10
10
Links in an Internetwork
11
11
Network Layer in an
Internetwork
12
12
Network Layer at the Source
13
13
Network Layer at a Router
14
14
Network Layer at the
Destination
15
15
Switching
16
16
Datagram Approach
17
17
Datagram Approach
18
18
18
IP Addressing
An IP address is a 32-bit
address.
The IP addresses are unique
and universal
An identifier for a computer or device on a TCP/IP
network. Networks using the TCP/IP protocol route
messages based on the IP address of the destination. The
format of an IP address is a 32-bit numeric address written
as four numbers separated by periods. Each number can be
zero to 255. 19
19
Dotted-Decimal Notation
20
20
Example
Change the following IP addresses from binary notation to
dotted-decimal notation.
a. 10000001 00001011 00001011 11101111
b. 11111001 10011011 11111011 00001111
21
21
Example
Change the following IP addresses from dotted-decimal notation to
binary notation.
a. 111.56.45.78
b. 75.45.34.78
22
22
Classful Addressing
In classful addressing, the
address space is divided into
five classes: A, B, C, D, and E.
23
23
Finding the Address Class
24
24
Example
Find the class of each address:
a. 00000001 00001011 00001011 11101111
b. 11110011 10011011 11111011 00001111
25
25
Finding Class in Decimal
Notation
26
26
27
28
Example
Find the class of each address:
a. 227.12.14.87
b. 252.5.15.111
c. 134.11.78.56
a. The first byte is 227 (between 224 and 239); the class is D.
b. The first byte is 252 (between 240 and 255); the class is E.
c. The first byte is 134 (between 128 and 191); the class is B.
29
29
Netid and Hostid
30
30
Blocks in Class A
31
31
Blocks in Class B
32
32
Blocks in Class C
33
33
Classful Addressing
• Millions of class A addresses are wasted.
• Many class B addresses are wasted.
• The number of addresses in class C is smaller than
the needs of most organizations.
34
34
34
Network Address
36
36
Example
37
37
Example
Given the network address 17.0.0.0, find the class.
38
38
Sample Internet
39
39
Network With Two Levels of Hierarchy
40
40
Network With Three Levels of Hierarchy
(subnetted)
41
41
Network Addresses With and Without Subnetting
42
42
Default Masks
In Dotted-
Class In Binary Using Slash
Decimal
45
45
Example
A router inside the organization receives the same packet with
destination address 190.240.33.91. Show how it finds the
subnetwork address to route the packet.
• Find:
47
47
47
• Given Data:
• IP Address: 154.16.52.16
• Subnet Mask: 255.255.240.0
48
48
Step 1: Number of Subnets Possible
The subnet mask in binary is:
255.255.240.0 = 11111111.11111111.11110000.00000000
The number of bits used for subnetting is the count of 1s in the subnet mask
minus the default subnet mask for Class B networks (154.x.x.x is Class B,
default mask is 255.255.0.0):
• Default mask bits = 16
• New mask bits = 20
Thus, 4 bits are used for subnetting.
The formula for the number of subnets is:
2^number of subnet bits= 2^4 = 16
Number of Subnets Possible: 16
49
49
Step 2: Number of Hosts per Subnet
• The number of host bits is the remaining bits in the subnet mask:
• Total bits = 32
• Subnet bits = 20
• Host bits = 32 - 20 = 12
• The formula for the number of hosts per subnet is:
52
52
Final Answers:
• Number of Subnets Possible: 16
• Number of Hosts Possible on Each Subnet: 4094
• Subnet This Address is On: 154.16.48.0
• Range of Addresses on That Subnet: 154.16.48.1 to 154.16.63.254
53
53
Sample problem 2
• IP address: 168.25.52.13 subnet mask: 255.255.230.0
• Find:
54
54
Given Data:
• IP Address: 168.25.52.13
• Subnet Mask: 255.255.230.0
55
55
Step 1: Number of Subnets Possible
• Convert the subnet mask to binary:
255.255.230.0 = 11111111.11111111.11100110.00000000
The number of 1s in the subnet mask represents the subnet bits.
• Subnet bits = 16 (Class B default mask) + 6 (extra bits) = 22.
The number of subnets possible is:
2^extra subnet bits= 2^6 = 64
Number of Subnets Possible: 64
56
56
Step 2: Number of Hosts per Subnet
• The number of host bits is the remaining bits after the subnet mask:
• Total bits = 32
• Subnet bits = 22
• Host bits = 32 - 22 = 10
• The formula for the number of hosts per subnet is:
2^number of host bits−2= 2^{10} - 2 = 1024 - 2 = 1022
• Number of Hosts Possible per Subnet: 1022
57
57
Step 3: Which Subnet This Address is On
• To determine the subnet ID, perform a bitwise AND operation between the IP address and
the subnet mask.
• Convert the IP and subnet mask to binary:
• IP: 168.25.52.13 → 10101000.00011001.00110100.00001101
• Subnet Mask: 255.255.230.0 → 11111111.11111111.11100110.00000000
• Perform the bitwise AND operation:
10101000.00011001.00110100.00001101
AND
11111111.11111111.11100110.00000000
= 10101000.00011001.00100100.00000000
• Convert back to decimal:
10101000.00011001.00100100.00000000 → 168.25.36.0
Subnet ID: 168.25.36.0
58
58
Step 4: Range of Addresses on the Subnet
• The range of addresses in the subnet includes:
First Usable Address: Subnet ID + 1 → 168.25.36.1
Last Usable Address: Subnet ID + Maximum Hosts →
168.25.36.0+1022=168.25.39.255
The broadcast address is 168.25.39.255, so the usable address range is:
• 168.25.36.1 to 168.25.39.254
59
59
Final Answers:
• Number of Subnets Possible: 64
• Number of Hosts Possible on Each Subnet: 1022
• Subnet This Address is On: 168.25.36.0
• Range of Addresses on That Subnet: 168.25.36.1 to 168.25.39.254
60
60
Summary
• The network layer is responsible for the source to destination delivery
of a packet across multiple network links
• http://www.joshgentry.com/networking/subnet.htm
• http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html
62
62
62