0% found this document useful (0 votes)
55 views

Network Layer: Sanjaya Kumar Jena

The document discusses various topics related to the network layer in computer networking: 1. The network layer is responsible for delivering packets from the source host to the destination host. It handles logical addressing, routing, and source-to-destination delivery of packets. 2. IPv4 addresses are 32-bit addresses that uniquely identify devices on the Internet. They can be represented in dotted-decimal or binary notation. 3. Network addresses define the network and have all host bits set to zero. They are the starting address of each block and cannot be assigned to hosts.

Uploaded by

Josh Rigs
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Network Layer: Sanjaya Kumar Jena

The document discusses various topics related to the network layer in computer networking: 1. The network layer is responsible for delivering packets from the source host to the destination host. It handles logical addressing, routing, and source-to-destination delivery of packets. 2. IPv4 addresses are 32-bit addresses that uniquely identify devices on the Internet. They can be represented in dotted-decimal or binary notation. 3. Network addresses define the network and have all host bits set to zero. They are the starting address of each block and cannot be assigned to hosts.

Uploaded by

Josh Rigs
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

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

Logical addressing (IP addressing)


Routing

UNP
Packet Format

UNP
IPv4 ADDRESSES

An IPv4 address is a 32-bit address that uniquely and universally


defines the connection of a device (for example, a computer or a
router) to the Internet.

UNP
Dotted-decimal notation and binary notation for
an IPv4 address

UNP
Example

Change the following IPv4 addresses from binary notation


to dotted-decimal notation.

UNP
Finding the classes in binary and dotted-decimal
notation

UNP
Example

Find the class of each address.


1 00000001 00001011 00001011 11101111
2 11000001 10000011 00011011 11111111
3 14.23.120.8
4 252.5.15.111

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

It is a 32-bit address that define the network itself.


All host bits are zero
The network address define the network to the rest of the Internet. A router can route a
packet based on the network address.
The network 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 network address.
UNP
Example

Given the address 23.56.7.91, find the network address.


Given the address 132.6.17.85, find the network address.
Given the network address 17.0.0.0, find the class.

A network address is different from a netid. A network ad-


dress has both netid and hostid, with 0s for the hostid.

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

Class In Binary In Dotted Using


Decimal slash
Class A 11111111 00000000 00000000 00000000 255.0.0.0 /8
Class B 11111111 11111111 00000000 00000000 255.255.0.0 /16
Class C 11111111 11111111 11111111 00000000 255.255.255.0 /24

UNP
Subnet mask

It is a 32 bit binary number that masks an IP address and


divides the IP address into network number and host
number.
Netid Subnetid Hostid
All 1s All 1s All 0s
It is used to idenify network address of an IP address by
performing a bitwise AND operation on the mask.
It is required to find the interface to forward the packet for
the desired network or the node.
Network mask helps to know which portion of the address
identifies the network and which portion identifies the host.
UNP
use of Subnet mask: An example

A class A IP address and mask given as 8.20.15.1 and 255.0.0.0.


Find the network address using mask.
Answer
IP address bitwise AND Mask = Network address
8.20.15.1 bitwise AND 255.0.0.0 = 8.0.0.0

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

How to send the packet from one host to other.


Unicast: One-to-one
Broadcast:Host to all other host
1 Limited broadcast (Local network broadcast):
Host to all other host in the same network
Netid Subnetid Hostid
All 1s All 1s All 1s
2 Directed broadcast (Distant network broadcast):
Host to all other host in the other network
Netid Subnetid Hostid
Specific Specific All 1s

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.

(a) 128.96.39.10 (c) 128.96.40.151 (e) 192.4.153.90


(b) 128.96.40.12 (d) 192.4.153.17
Network address Subnet mask Interface
128.96.39.0 255.255.255.128 0
128.96.39.128 255.255.255.128 1
128.96.40.0 255.255.255.128 R2
192.4.153.0 255.255.255.192 R3
default —- R4

Table 1 : Routing table


UNP
Note

If multiple network addresses match, then use the interface with


maximum 1s in the network mask. It is called longest prefix
match.

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.

(a) 128.96.171.92 (c) 128.96.163.151 (e) 128.96.165.121


(b) 128.96.167.151 (d) 128.96.169.192
Network address Subnet mask Interface
128.96.170.0 255.255.254.0 0
128.96.168.0 255.255.254.0 1
128.96.166.0 255.255.254.0 R2
128.96.164.0 255.255.252.0 R3
default —- R4

Table 2 : Routing table


UNP
Variable Length Subnet Masking(VLSM)
Consider a Class C IP 200.1.2.0. Design 3 subnets each of
IPs 128, 64 and 64 respectively. Find the range of address,
subnetwork address, and subnet mask.
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.194
Network address subnet mask Interface
200.1.2.0 255.255.255.128 a
200.1.2.128 255.255.255.192 b
200.1.2.192 255.255.255.192 c
0.0.0.0 0.0.0.0.0 e (default entry)
UNP
Practice Question
A network on the Internet has a classful subnet mask of
255.255.240.0. What is the maximum number of hosts it
can handle?
Suppose that instead of using 16 bits for the network part
of a class B address originally, 20 bits had been used. How
many class B networks would there have been?
Mask in classful address is given as 255.192.0.0. Find out
the number of Hosts, and subnet present.
What is a mask in IPv4 addressing? What is a default mask
in IPv4 addressing?
What is the network address in a block of addresses? How
can we find the network address if one of the addresses in a
block is given?
UNP
Classless IP Addressing or CIDR Representation

Blockid Hostid

CIDR(classless Inter Domain Routing) representation or class-


less representation- x.y.z.t/ n
n- number of bits in blockid or networkid

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

1 The addresses in a block must be contiguous, one after an-


other.
2 The number of addresses in a block must be a power of 2
(1, 2, 4, 8, ... ).
3 The first address must be evenly divisible by the number of
addresses in the 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?

Let HostID for a block is 7 bits.

Let BlockID(NetID) for that block is 25 bits.

Say, any one IP address of that block is 205.10.22.65, So

CIDR representation of that block is 205.10.22.65/ 25

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

Let a CIDR block is given as 205.16.37.39/28. Find the entire


block.
First address: 205.16.37.32
Last address: 205.16.37.47
We can test whether it is a valid CIDR block or not by applying
the rules discussed earlier.

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

A mask is a 32-bit number in which the n leftmost bits are


1s and the 32 - n rightmost bits are 0s.
However, in classless addressing the mask for a block can
take any value from 0 to 32.
It is very convenient to give just the value of n preceded by
a slash (CIDR notation).

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.

An ISP is granted a block of addresses starting with 190.100.0.0/16


(65,536 addresses). The ISP needs to distribute these addresses to three
groups of customers as follows:
a. The first group has 64 customers; each needs 256 addresses.
b. The second group has 128 customers; each needs 128 addresses.
c. The third group has 128 customers; each needs 64 addresses.
Design the subblocks and find out how many addresses are still avail-
able after these allocations.
An address space has a total of 1024 addresses. How many bits are
needed to represent an address?
UNP
Practice Question-1
An ISP is granted a block of addresses starting with 120.60.4.0/22. The
ISP wants to distribute these blocks to 100 organizations with each or-
ganization receiving just eight addresses. Design the subblocks and give
the slash notation for each subblock. Find out how many addresses are
still available after these allocations.

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

You might also like