Unit 6jfbvb
Unit 6jfbvb
Unit 6jfbvb
Network Layer
o The Network Layer is the third layer of the OSI model.
o It handles the service requests from the transport layer and further forwards
the service request to the data link layer.
o The network layer translates the logical addresses into physical addresses
o It determines the route from the source to the destination and also manages
the traffic problems such as switching, routing and controls the congestion
of data packets.
o The main role of the network layer is to move the packets from sending host
to the receiving host.
o Routing: When a packet reaches the router's input link, the router will move
the packets to the router's output link. For example, a packet from S1 to R1
must be forwarded to the next router on the path to S2.
o Logical Addressing: The data link layer implements the physical
addressing and network layer implements the logical addressing. Logical
addressing is also used to distinguish between source and destination system.
The network layer adds a header to the packet which includes the logical
addresses of both the sender and the receiver.
o Internetworking: This is the main role of the network layer that it provides
the logical connection between different types of networks.
o Fragmentation: The fragmentation is a process of breaking the packets into
the smallest individual data units that travel through different networks.
Address representation of
Address Representation of IPv6 is in hexadecimal
IPv4 is in decimal
Fragmentation performed
In IPv6 fragmentation is performed only by the
by Sender and forwarding
sender
routers
IPv4 IPv6
Classful Addressing
An IP address is an address having information about how to reach a specific host,
especially outside the LAN. An IP address is a 32-bit unique address having an
address space of 232.
Generally, there are two notations in which the IP address is written, dotted
decimal notation and hexadecimal notation.
Dotted Decimal Notation
Classful Addressing
The 32-bit IP address is divided into five sub-classes. These are:
Class A
Class B
Class C
Class D
Class E
Each of these classes has a valid range of IP addresses. Classes D and E are
reserved for multicast and experimental purposes respectively. The order of bits in
the first octet determines the classes of the IP
address. The IPv4 address is divided into two parts:
Network ID
Host ID
The class of IP address is used to determine the bits used for network ID and host
ID and the number of total networks and hosts possible in that particular class.
Each ISP or network administrator assigns an IP address to each device that is
connected to its network.
Classful Addressing
Class A
IP addresses belonging to class A are assigned to the networks that contain a large
number of hosts.
The network ID is 8 bits long.
The host ID is 24 bits long.
The higher-order bit of the first octet in class A is always set to 0. The remaining
7 bits in the first octet are used to determine network ID. The 24 bits of host ID are
used to determine the host in any network. The default subnet mask for Class A is
255.x.x.x. Therefore, class A has a total of:
2^24 – 2 = 16,777,214 host ID
IP addresses belonging to class A ranges from 1.0.0.0 – 126.255.255.255.
Class A
Class B
IP address belonging to class B is assigned to networks that range from medium-
sized to large-sized networks.
The network ID is 16 bits long.
The host ID is 16 bits long.
The higher-order bits of the first octet of IP addresses of class B are always set to
10. The remaining 14 bits are used to determine the network ID. The 16 bits of host
ID are used to determine the host in any network. The default subnet mask for class
B is 255.255.x.x. Class B has a total of:
2^14 = 16384 network address
2^16 – 2 = 65534 host address
IP addresses belonging to class B ranges from 128.0.0.0 – 191.255.255.255.
Class B
Class C
IP addresses belonging to class C are assigned to small-sized networks.
The network ID is 24 bits long.
The host ID is 8 bits long.
The higher-order bits of the first octet of IP addresses of class C is always set to
110. The remaining 21 bits are used to determine the network ID. The 8 bits of host
ID are used to determine the host in any network. The default subnet mask for class
C is 255.255.255.x. Class C has a total of:
2^21 = 2097152 network address
2^8 – 2 = 254 host address
IP addresses belonging to class C range from 192.0.0.0 – 223.255.255.255.
Class C
Class D
IP address belonging to class D is reserved for multi-casting. The higher-order bits
of the first octet of IP addresses belonging to class D is always set to 1110. The
remaining bits are for the address that interested hosts recognize.
Class D does not possess any subnet mask. IP addresses belonging to class D range
from 224.0.0.0 – 239.255.255.255.
Class D
Class E
IP addresses belonging to class E are reserved for experimental and research
purposes. IP addresses of class E range from 240.0.0.0 – 255.255.255.254. This
class doesn’t have any subnet mask. The higher-order bits of the first octet of class
E are always set to 1111.
Class E
Point-01:
Point-02:
For any given IP Address,
IP Address of its network is obtained by setting all its Host ID part bits to 0.
Point-03:
Point-04:
For any given IP Address, limited Broadcast Address is obtained by setting all its bits to 1.
For any network, its limited broadcast address is always 255.255.255.255
Pause
Point-05:
Class D IP Addresses are not divided into Net ID and Host ID parts.
Class E IP Addresses are not divided into Net ID and Host ID parts.
Problem-01:
1. 1.2.3.4
2. 10.15.20.60
3. 130.1.2.3
4. 150.0.150.150
5. 200.1.10.100
6. 220.15.1.10
7. 250.0.1.2
8. 300.1.2.3
Identify the Class, Network IP Address, Direct broadcast address and Limited broadcast address of each IP
Address.
Solution-
Part-A:
Part-B:
Part-C:
Part-E:
Part-F:
Part-G:
Part-H:
Problem-03:
A host with IP Address 200.100.1.1 wants to send a packet to all the hosts in the same network.
What will be-
1. Source IP Address
2. Destination IP Address
Solution-
Problem-04:
How many bits are allocated for Network ID and Host ID in 23.192.157.234 address?
Solution-
Solution: The first Octet of the given IP address exists in between the range of Class C (192 –
223). So, the given IP belongs to class C.
Solution: After checking the class of the given IP. A subnet mask can be found by putting all octet-bits
of network ID to “255” and Host bits to “0”. So, the Class C subnet mask is 255.255.255.0.
Solution: To find the network ID, Perform AND operation of the given IP with Subnet mask in
binary. It will provide the network ID where that particular IP exists. So, the network ID will
be 201.20.31.0.
Part 4: Find the First and Last IP address of the given Network IP.
Solution: We know that there are two IPs for each network, which are reserved. As the Network ID is
201.20.31.0. So, the first IP address will be 201.20.31.0, which is reserved for network identification.
The last IP address is 201.20.31.255, which is reserved for direct broadcasting.
Part 5: Find the first and Last Host ID of the given Network IP.
Solution: Due to the reservation of two Hosts, the Network ID is 201.20.31.0. So, the first host IP
address will be 201.20.31.1, and the Last host IP address will be 201.20.31.254.
Solution: Replacing all octets of IP address to 255 (decimal) is called Limited broadcast IP
addressing. So, Limited broadcast address = 255.255.255.255.
Part 7: Find the Direct broadcast IP addressing.
Solution: Replacing the Host-bits-octets to 255 of a given IP is called direct broadcast IP addressing.
So, direct broadcast IP addressing = 201.20.31.255.
IPv4 Datagram Header Numerical
Question: A datagram of 3000 bytes (20 bytes of IP header + 2980 bytes IP payload)
reached the router and must be forwarded to link with MTU (maximum transmission unit) of
500 bytes. How many fragments will be granted? Also, write MF, offset, and total length
values for all.
After the fragmentation of the datagram into fragments (packets), each fragment will carry the same
header size, which is the same as the original datagram. So, in this question, 20 bytes will be the
compulsory part of each fragment.
As the limit of a link is 500 bytes to transfer, in which 20 bytes is the header size. So, 480 bytes
of payload can transfer in each fragment.
The total number of fragments can be calculated by considering a ceiling value of the following
formula.
Total length is the combination of all fragmented payloads. Adding the payload of each fragment will
always equal the size of the original payload. As
Note: Header length will remain the same 20 bytes at the receiving end. So, 20+2980 bytes = 3000
bytes. It was the original datagram of 3000 bytes.
MF value may be 0 or 1.
When MF bit value is 0 then It tells to the receiver that the current datagram-fragment is the last
fragment and no more segment will appear of same datagram.
When MF bit value is 1 then it tells more fragments are still to come after this fragment.
Fragment Offset
It uses a scaling factor of 8. Fragment offset can be calculated by using the following formula
Fragment offset for a given fragmented IP datagram = Number of data (payload) bytes ahead of it / 8
At fragment F1, no byte has already been transferred. So fragment offset = 0/8 B = 0
At fragment F2, 480 bytes of F1 are already transferred. So fragment offset = 480/8 B = 60
At fragment F3, 480 bytes of F1 and F2 are already transferred. So fragment offset = 480*2/8 B =120
At fragment, F4, 480 bytes of F1, F2, and F3 are already transferred. So fragment offset = 480*3/8 B
=180
At fragment F5, 480 bytes of F1,F2,F3 and F4 is already transferred. So fragment offset = 480*4/8 B
=240
At fragment F6, 480 bytes of F1,F2,F3,F4 and F5 is already transferred. So fragment offset = 480*5/8 B
=300
At fragment F7, 480 bytes of F1,F2,F3,F4,F5 and F6 is already transferred. So fragment offset =
480*6/8 B =360