Network Layer: Sanjaya Kumar Jena
Network Layer: Sanjaya Kumar Jena
UNP
Introductiom
Responsibilities: It is responsible for the delivery of individual
packets from the source host to the destination host (i.e. End to
end delivery).
Source-to-destination delivery :Network Layer
UNP
Other Issues
UNP
Packet Format
UNP
IPv4 ADDRESSES
UNP
Dotted-decimal notation and binary notation for
an IPv4 address
UNP
Example
UNP
Finding the classes in binary and dotted-decimal
notation
UNP
Example
UNP
Netid(NID) and Hostid (HID)
In classful addressing, an IP address in class A, B, or C is di-
vided into netid and hostid. These parts are of varying lengths,
depending on the class of the address.
Netid Hostid # bits reserved # Networks/blocks
Class A 1 byte 3 byte 1 bit 27
Class B 2 byte 2 byte 2 bits 214
Class C 3 byte 1 byte 3 bits 221
UNP
Number of blocks and block size in classful IPv4
addressing
UNP
Network Address
UNP
Sample internet
UNP
A network with two levels of hierarchy
Netid Hostid
UNP
A network with three levels of hierarchy
Netid Subnetid Hostid
UNP
Addresses in a network with and without
subnetting
UNP
Default mask
UNP
Subnet mask
UNP
Subnetwork Address
Netid Subnetid Hostid
Specific Specific All 0s
It is a 32-bit address that define the subnetwork itself.
All host bits are zero
The subnetwork address define the network to the rest of
the Internet. A router can route a packet onto the network
based on the subnetwork address.
The subnetwork address is the first address in the block.
It can not be assigned to any host.
The class of the address can be determined from the given
subnetwork address.
UNP
Casting
UNP
Special IP addresses
UNP
Subnet, Subnet Masking, & Routing
Design 4 subnets for the given class C IP 200.1.2.0. Find
the network address for each subnet and subnet mask of the
network.
Let us consider a routing table is given below. Find the
interface on which the packet will move with the destination
address 200.1.2.22
Network address subnet mask Interface
200.1.2.0 255.255.255.192 a
200.1.2.64 255.255.255.192 b
200.1.2.128 255.255.255.192 c
200.1.2.192 255.255.255.192 d
0.0.0.0 0.0.0.0.0 e (default entry)
UNP
Example
Suppose a router has build up the routing table shown in the table-2. The
router can deliver packet directly over the interface 0 and 1 or it can forward
packet to routers R2 , R3 , and R4 . Describe what the router does with the
packet addressed to each of the following destinations.
UNP
Example
Suppose a router has build up the routing table shown in the table-2. The
router can deliver packet directly over the interface 0 and 1 or it can forward
packet to routers R2 , R3 , and R4 . Describe what the router does with the
packet addressed to each of the following destinations.
Blockid Hostid
Example: 20.10.50.120 / 20
Networkid=20 bits
Hostid=32-20=12
Total number of IP addresses=232−n
UNP
Rules for forming CIDR Block
UNP
Example
Test Whether the given addresses is a CIDR block or not.
100.1.2.32
100.1.2.33
..
.
100.1.2.47
Solution
Rules
IP addresses are contiguous- Yes
Number of addresses power of 2- Yes
First IP address is evenly divisible by 16- Yes
So, It is a valid CIDR block
UNP
Practice
Test Whether the given addresses is a CIDR block or not.
1 100.1.2.32
100.1.2.33
..
.
100.1.2.47
2 205.16.37.32
205.16.37.33
..
.
205.16.37.47
3 150.10.20.64
150.10.20.65
..
.
150.10.20.127
UNP
HOW to represent CIDR block?
UNP
Derivation of entire block from the given CIDR
representation
Let a CIDR block is given as 205.16.37.39/28. Find the entire
block.
Derivation: The first address in the block
n=28 bits, BlockId=n= 28 bits, HostId=32-n= 32-28 = 4 bits
The first address in the block can be found by setting the rightmost 32
- n bits to 0s.
The first address in the block can be found by setting the rightmost 32
- 28 bits to 0s.
The binary representation of the given address is 11001101 00010000
00100101 00100111
Setting 32 - 28 rightmost bits to 0, we get 11001101 0001000
00100101 0010000 or 205.16.37.32.
UNP
Derivation of entire block from the given CIDR
representation contd...
Let a CIDR block is given as 205.16.37.39/28. Find the entire
block.
Derivation: The last address in the block
n=28 bits, BlockId=n= 28 bits, HostId=32-n= 32-28 = 4 bits
The first address in the block can be found by setting the rightmost 32
- n bits to 1s.
The first address in the block can be found by setting the rightmost 32
- 28 bits to 1s.
The binary representation of the given address is 11001101 00010000
00100101 00100111
Setting 32 - 28 rightmost bits to 1, we get 11001101 00010000
00100101 00101111 or 205.16.37.47.
UNP
Entire Block
UNP
Practice
Given the CIDR block, find the first address and last address, and
total number of addresses
1 20.10.30.35/ 27
2 100.0.2.35/ 28
3 100.1.2.35/ 20
4 205.16.37.39/ 28
5 In a block of addresses, we know the IP address of one
host is 25.34.12.56/16. What are the first address and the
last address in this block?
6 In a block of addresses, we know the IP address of one
host is 182.44.82.16/26. What are the first address and the
last address in this block?
UNP
Masking in CIDR
Example- Mask
/26 or 11111111 11111111 11111111 11000000
/27 or 11111111 11111111 11111111 11100000
/18 or 11111111 11111111 11000000 00000000
UNP
Network Address in CIDR
It is a 32-bit address that define the network itself.
As like classful, Blockid Hostid
Specific All 0s
All host bits are zero. It can not be assigned to any host.
The first address is called the network address and defines
the organization network. It defines the organization itself
to the rest of the world.
The first address is the one that is used by routers to direct
the message sent to the organization from the outside.
Example: for mask 205.16.37.39/28 (i.e 11001101 00010000
00100101 00100111/28), the network address is 11001101
00010000 00100101 0010 0000 , or 205.16.37.32
UNP
Sunbetting in CIDR
An organization that is granted a large block of addresses
may want to create clusters of networks (called subnets) and
divide the addresses between the different subnets.
The rest of the world still sees the organization as one en-
tity; however, internally there are several subnets.
All messages are sent to the router address that connects the
organization to the rest of the Internet; the router routes the
message to the appropriate subnets.
The organization, however, needs to create small subblocks
of addresses, each assigned to specific subnets.
The organization has its own mask; each subnet must also
have its own.
UNP
Example Subnetting in CIDR
Asssume a CIDR block is given as 20.30.40.10/25. Divide the
block in two subblocks, and find the first address, last address,
subnet mask of each block.
Subnetting
Block id= 25 bits, host id=32-25=7 bits, total addresses
= 27 = 128 to be divided into two blocks
Block 1: 20.30.40.0 0 000000 · · · 20.30.40.0 0 111111
20.30.40.0 · · · 20.30.40.63
CIDR representation of block 1= 20.30.40.1/26
Block 2: 20.30.40.0 1 000000 · · · 20.30.40.0 1 111111
20.30.40.64 · · · 20.30.40.127
CIDR representation of block 2= 20.30.40.66/26
UNP
Example Subnetting in CIDR
Asssume a CIDR block is given as 20.30.40.10/25. Divide the block in 4
subblocks, and find the first address, last address, subnet mask of each block.
Subnetting
Block id= 25 bits, host id=32-25=7 bits, total addresses = 27 = 128 to be
divided into four blocks
Block 1: 20.30.40.0 00 00000 · · · 20.30.40.0 00 11111
20.30.40.0 · · · 20.30.40.31
CIDR representation of block 1= 20.30.40.1/27
Block 2: 20.30.40.0 01 00000 · · · 20.30.40.0 01 11111
20.30.40.32 · · · 20.30.40.63
CIDR representation of block 2= 20.30.40.1/27
Block 3: 20.30.40.0 10 00000 · · · 20.30.40.0 10 11111
20.30.40.64 · · · 20.30.40.95
CIDR representation of block 3= 20.30.40.64/27
Block 4: 20.30.40.0 11 00000 · · · 20.30.40.0 11 11111
20.30.40.96 · · · 20.30.40.127
UNP
Practice Question
suppose an organization is given the block 17.12.40.0/26, which con-
tains 64 addresses. The organization has three offices and needs to di-
vide the addresses into three subblocks of 32, 16, and 16 addresses.
Find the first address, last address , and sunet mask of each block.
Find the netid and the hostid of the following classful IP addresses.
a. 114.34.2.8
b. 132.56.8.6
c. 208.34.54.12
Find the mask of the block, if the CIDR block is represented as 12.36.56.1/27
A large number of consecutive IP addresses are available starting at
198.16.0.0. Suppose that four organizations, A, B, C, and D, request
4000, 2000, 4000, and 8000 addresses, respectively, and in that order.
For each of these, give the first IP address assigned, the last IP address
assigned, and the mask in the w.x.y.z/s notation.
UNP