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

Network layer

The document provides an overview of the Network Layer in computer networks, detailing its role in moving data packets between networks, routing, and packetizing. It explains key services such as error control, flow control, and congestion control, along with IPv4 addressing and classful addressing schemes. Additionally, it describes the characteristics and usage of different IP address classes (A, B, C, D, and E).

Uploaded by

divyadarakha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Network layer

The document provides an overview of the Network Layer in computer networks, detailing its role in moving data packets between networks, routing, and packetizing. It explains key services such as error control, flow control, and congestion control, along with IPv4 addressing and classful addressing schemes. Additionally, it describes the characteristics and usage of different IP address classes (A, B, C, D, and E).

Uploaded by

divyadarakha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 76

Network Layer

BY TRUPTI SISODE.
What is the Network Layer?

 The network layer is a part of the communication process in computer networks.


Its main job is to move data packets between different networks.
 It helps route these packets from the sender to the receiver across multiple paths
and networks.
 Network-to-network connections enable the Internet to function. These
connections happen at the “network layer,” which sends data packets between
different networks.
 In the 7-layer OSI model, the network layer is layer 3. The Internet Protocol (IP)
is a key protocol used at this layer, along with other protocols for routing, testing,
and encryption.
Features of Network Layer

 The main responsibility of the Network layer is to carry the data packets from
the source to the destination without changing or using them.
 If the packets are too large for delivery, they are fragmented i.e., broken down
into smaller packets.
 It decides the route to be taken by the packets to travel from the source to the
destination among the multiple routes available in a network (also called
routing).
 The source and destination addresses are added to the data packets inside the
network layer.
Services Offered by Network Layer
 1. Packetizing
Packetizing is the process of putting data into a packet at the source and
taking it out of the packet at the destination.
• At the Source: The source puts a header with the source and destination
addresses onto the data, then sends the packet to the next layer.
• At the Destination: The destination receives the packet, removes the
header, and sends the data to the appropriate place.
• Routers: They don’t change the addresses in the packet. They only handle
the packet if it needs to be split into smaller pieces.
1. Packetizing
2. Routing

 Routing is the process of directing data packets from one place to another across a network.
 Example
 Imagine sending a letter from your home to a friend’s house in a different city. Here’s how routing works:
1. Starting Point (Your Home):
1. You write the letter and address it with your friend’s location.

2. Route Taken:
1. The letter is sent to a post office, then to several intermediate locations (like other post offices or sorting centers), each of which figur
2. es out the next destination based on the address.

3. Destination (Friend’s House):


1. Finally, the letter arrives at your friend’s house, where it’s delivered.
 In Short: Routing determines the best path for data to travel across a network from the sender to the receiver, ensuring it
reaches the correct destination efficiently.
Routing
Forwarding

 Forwarding in the network layer is the process of moving data packets from one network device to another along
the path to their final destination.
 Simple Example
 Think of forwarding as a delivery service:
1. Receiving Device (Router): A router receives a packet of data.
2. Checking Destination: The router looks at the packet’s destination address.
3. Sending to Next Device: Based on the address, the router forwards the packet to the next device or router on the
path to the destination.
4. Continuing the Journey: The packet continues to be forwarded from router to router until it reaches its destination.
 In Short: Forwarding is the action of directing data packets to their next hop or device based on their destination
address, helping them travel through the network.
Forwarding
Other Services Expected from Network Layer
 Error Control
• Purpose: Detects and manages errors that occur during data transmission.
• How: Uses techniques like checksums or acknowledgments to identify corrupted or lost packets and request
retransmission if needed.
 2. Flow Control
• Purpose: Ensures that data is sent at a rate that the receiving device can handle.
• How: Adjusts the rate of data transmission based on the receiver’s ability to process and store incoming
packets, preventing data overload.
 3. Congestion Control
• Purpose: Prevents network congestion by managing the amount of data entering the network.
• How: Monitors network traffic and adjusts the data flow to avoid excessive load that could slow down or
block the network.
IPv4 addressing

 The IPv4 address is a 32-bit number that uniquely identifies a network interface on a
machine. An IPv4 address is typically written in decimal digits, formatted as four 8-bit
fields that are separated by periods.

1. Address Format:

 32-bit Address: An IPv4 address consists of 32 bits. This is divided into four 8-
bit octets. Each octet is represented as a decimal number ranging from 0 to
255.
•Example: 192.168.1.1
Binary Representation: The address can also be represented in binary format,
such as 11000000.10101000.00000001.00000001
Address space

 The address space of IPv4 is 32 bits, which means it can provide approximately
2³² or about 4.3 billion unique addresses. This limitation has led to the adoption
of IPv6, which uses 128 bits and can provide a vastly larger address space.

 The address space of IPv4 is 2^32 or


4,294,967,296
Notations

 Binary Notation In binary notation, the IPv4 address is displayed as 32 bits. Each octet is
often referred to as a byte. So it is common to hear an IPv4 address referred to as a 32-bit
address or a 4-byte address. The following is an example of an IPv4 address in binary
notation:
 01110101 10010101 00011101 00000010
 Dotted-Decimal Notation To make the IPv4 address more compact and easier to read,
Internet addresses are usually written in decimal form with a decimal point (dot)
separating the bytes.
 The following is the dotted decimal notation of the above address: 117.149.29.2
binary notation to dotted-decimal notation

Example
Change the following IPv4 addresses from binary notation to dotted-
decimal notation.

a. 10000001 00001011 00001011 11101111


b. 11000001 10000011 00011011 11111111

Solution We replace each group of 8 bits with its equivalent decimal


number (see Appendix B) and add dots for separation.
a. 129.11.11.239
b. 193.131.27.255
dotted-decimal notation to binary notation.
Find the error
Classful addressing

 Classful addressing is an old method used in IP networking to divide the IP address space
into distinct classes, each catering to different network sizes. This method was part of
IPv4 and helped in allocating IP addresses based on the size of the network.
 In classful addressing, the address space is divided into five classes: A, B, C, D, and E.
•1. 00001000 00101000 00001111 11000011 → Class A (first bit 0)
•2. 10101100 00010000 00001101 00101011 → Class B (first 2 bits 10)
•3. 23.45.67.89 → Class A (first byte 23)
•4. 240.100.200.250 → Class E (first byte 240)
Finding the classes in binary and dotted-decimal notation
Class A

Class A is one of the classes in the IPv4 addressing scheme, used in early network design for IP
addressing.
1. Range of IP Addresses
•First Octet Range: 1.0.0.0 to 126.0.0.0
•Complete Address Range: 1.0.0.0 to 126.255.255.255
•Default Subnet Mask: 255.0.0.0 (or /8 in CIDR notation)

2. Structure
•First Octet (Network Part): The first 8 bits (1st octet) are designated as the network identifier.
•Remaining Octets (Host Part): The remaining 24 bits (2nd, 3rd, and 4th octets) are used for host
identification.
Example:
•An IP address like 10.1.2.3 would belong to the 10.0.0.0 network, with 1.2.3 as the host
identifier.
3. Number of Networks and Hosts
•Number of Networks: 128 (2^7, as the first bit is fixed as 0)
•Number of Hosts per Network: 16,777,214 (2^24 - 2, since two addresses are reserved—network and
broadcast)

4. Special Addresses
•0.0.0.0: Used to represent a default route or an unknown network.
•127.0.0.0 to 127.255.255.255: Reserved for loopback testing (localhost).

5. Usage
•Class A addresses are typically assigned to large organizations or Internet Service Providers (ISPs) with a
large number of hosts on their network.
•Due to their large size, they are less commonly used today for public networks but may be utilized in
private networks.

6. Private IP Address Range


•The range 10.0.0.0 to 10.255.255.255 is reserved for private networks and cannot be routed on the
public Internet.

Example of Class A Address Breakdown


Given an IP address 10.1.2.3:
•Network Address: 10.0.0.0
•Broadcast Address: 10.255.255.255
•Valid Host Range: 10.0.0.1 to 10.255.255.254
Class B

 Class B is one of the classes in the original IPv4 addressing scheme, designed to accommodate
medium to large-sized networks.
1. Range of IP Addresses
•First Octet Range: 128.0.0.0 to 191.255.0.0
•Complete Address Range: 128.0.0.0 to 191.255.255.255
•Default Subnet Mask: 255.255.0.0 (or /16 in CIDR notation)

2. Structure
•First Two Octets (Network Part): The first 16 bits (1st and 2nd octets) are designated as the network
identifier.
•Last Two Octets (Host Part): The remaining 16 bits (3rd and 4th octets) are used for host
identification.
Host Address
Example:
•An IP address like 172.16.50.100 would belong to the 172.16.0.0 network, with 50.100 as the host
identifier.
Network Address
Number of Networks and Hosts
•Number of Networks: 16,384 (2^14, as the first two bits are fixed as 10)
•Number of Hosts per Network: 65,534 (2^16 - 2, since two addresses are reserved—
network and broadcast)

4. Special Addresses
•Network Address: The first address in a given network, used to identify the network itself.
For example, 172.16.0.0 in the 172.16.0.0/16 network.
•Broadcast Address: The last address in a given network, used to send data to all hosts in
the network. For example, 172.16.255.255 in the 172.16.0.0/16 network.

5. Usage
•Class B addresses were intended for medium to large-sized organizations or universities
with a sizable number of hosts.
•These addresses offer a balance between the number of networks and the number of hosts
per network.

6. Private IP Address Range :


The range 172.16.0.0 to 172.31.255.255 is reserved for private networks and cannot be
routed on the public Internet. This is a 20-bit block of addresses (172.16.0.0/12), providing a
large number of addresses for private use.
Class C

 Class C is one of the classes in the IPv4 addressing scheme, designed for small-sized
networks.
1. Range of IP Addresses
•First Octet Range: 192.0.0.0 to 223.255.255.255
•Complete Address Range: 192.0.0.0 to 223.255.255.255
•Default Subnet Mask: 255.255.255.0 (or /24 in CIDR notation)

2. Structure
•First Three Octets (Network Part): The first 24 bits (1st, 2nd, and 3rd octets) are designated as
the network identifier.
•Last Octet (Host Part): The remaining 8 bits (4th octet) are used for host identification.
Example:
•An IP address like 192.168.1.10 would belong to the 192.168.1.0 network, with 10 as the host
identifier.
3. Number of Networks and Hosts
•Number of Networks: 2,097,152 (2^21, as the first three bits are fixed as 110)
•Number of Hosts per Network: 254 (2^8 - 2, since two addresses are reserved—network
and broadcast)

4. Special Addresses
•Network Address: The first address in a given network, used to identify the network itself.
For example, 192.168.1.0 in the 192.168.1.0/24 network.
•Broadcast Address: The last address in a given network, used to send data to all hosts in
the network. For example, 192.168.1.255 in the 192.168.1.0/24 network.

5. Usage
•Class C addresses are primarily intended for small-sized networks, such as small
businesses or home networks.
•Because of the limited number of hosts per network, they are ideal for environments where
fewer than 254 devices are needed.

6. Private IP Address Range


•The range 192.168.0.0 to 192.168.255.255 is reserved for private networks and cannot be
routed on the public Internet. This is a 16-bit block of addresses (192.168.0.0/16), providing a
large number of smaller networks for private use.
Class D
Class D IP addresses are used for multicasting, a method of sending data to a group of destinations simultaneously.
Unlike Classes A, B, and C, which are used for unicast (one-to-one communication), Class D addresses do not
identify individual hosts. Instead, they identify groups of hosts known as multicast groups.
1. Range of IP Addresses
•First Octet Range: 224.0.0.0 to 239.255.255.255
•Complete Address Range: 224.0.0.0 to 239.255.255.255
•Default Subnet Mask: Class D addresses do not have a subnet mask because they are not intended for standard
host-based networking.

2. Structure
•First Four Bits (1110): The first four bits of a Class D address are fixed as 1110, which determines that the
address is within the multicast range.
•Remaining 28 Bits: The remaining 28 bits identify the specific multicast group.
Example:
•An IP address like 224.0.1.1 is a multicast address, with the specific group identified by the remaining 28 bits.

•Class D addresses are reserved for multicast groups, not for individual hosts or networks.
•They allow efficient data distribution to multiple recipients simultaneously, making them ideal for applications like live
streaming, online gaming, and real-time data feeds.
•Class D addresses span the range 224.0.0.0 to 239.255.255.255 and are managed differently from the traditional
unicast addresses in Classes A, B, and C.
Class E

❑ Class E IP addresses are reserved for experimental purposes and are not used in regular network
operations.
❑ The address range 240.0.0.0 to 255.255.255.255 is not available for public or private network
assignments.
❑ These addresses are generally ignored by networking devices and protocols, except for specific
research and experimental use cases.

1. Range of IP Addresses
•First Octet Range: 240.0.0.0 to 255.255.255.255
•Complete Address Range: 240.0.0.0 to 255.255.255.255

2. Structure
•First Four Bits (1111): The first four bits of a Class E address are fixed as 1111, which places the
address within the reserved range.
•Remaining 28 Bits: The remaining 28 bits could theoretically be used for network and host
identification, but Class E addresses are not defined for use in standard networking.
Subnetting

• What is Subnetting?
• Subnetting is the process of dividing a large network into smaller sub-networks
(subnets).
• Helps in better network management, security, and IP address utilization.
• Benefits of Subnetting:
• Improved Security: Different subnets can have different security settings.
• Better Organization: Helps in organizing large networks into manageable
sections.
• Efficient IP Usage: Reduces the waste of IP addresses.
Example 1 Network:

• Network Address: 192.168.1.0


• Subnet Mask: 255.255.255.0 (/24)
• Goal: Divide this network into 4 subnets.
Determine the Subnets

•Number of Subnets Required: 4

•Borrowing Bits:
•We need to borrow bits from the host portion to create subnets.

•How Many Bits to Borrow? : 2 bits


•Why? 2^2 = 4 (this gives us 4 subnets)
•Formula : 2^n

•From the 8 host bits, we borrow the first 2 bits, leaving 6 bits for hosts.
Subnet Addresses in Binary:
•Subnet 1: •Subnet 3:
•Binary: • Binary:
11000000.10101000.00000001.00000000 11000000.10101000.00000001.10000000
•Range: • Range:
11000000.10101000.00000001.00000000 to
11000000.10101000.00000001.10000000 to
11000000.10101000.00000001.00111111
•Decimal: 192.168.1.0 to 192.168.1.63 11000000.10101000.00000001.10111111
•Decimal: 192.168.1.128 to 192.168.1.191
•Subnet 2:
•Binary: •Subnet 4:
11000000.10101000.00000001.01000000 •Binary:
Range: 11000000.10101000.00000001.11000000
11000000.10101000.00000001.01000000 to •Range:
11000000.10101000.00000001.01111111
11000000.10101000.00000001.11000000 to
•Decimal: 192.168.1.64 to 192.168.1.127
11000000.10101000.00000001.11111111
•Decimal: 192.168.1.192 to 192.168.1.255
Example 2 Network:

•Network Address: 192.168.1.0


•Subnet Mask: /24 (which is 255.255.255.0 in
decimal)
•Binary Representation of the Subnet Mask:
•11111111.11111111.11111111.00000000
•The first 24 bits are for the network, and the last 8
bits are for hosts.
Decide How Many Subnets You Need

•Number of Subnets: 2
•How Many Bits to Borrow:
•Since you need 2 subnets, you borrow 1 bit from the
host portion.
•2^1 = 2 (this gives you the number of subnets).
Calculate the Subnet Addresses

Since you borrowed 1 bit, you can create 2 subnets. Here's how they look:
1.Subnet 1:
•Network Address: 192.168.1.0
•Binary Representation: 11000000.10101000.00000001.00000000
•Range of Usable IP Addresses: 192.168.1.1 to 192.168.1.126
•Broadcast Address: 192.168.1.127

2.Subnet 2:
•Network Address: 192.168.1.128
•Binary Representation: 11000000.10101000.00000001.10000000
•Range of Usable IP Addresses: 192.168.1.129 to 192.168.1.254
•Broadcast Address: 192.168.1.255
To divide a Class B network (e.g., 172.16.0.0/16) into 4 subnets, follow
these steps:

•Determine the New Subnet Mask:


•To create 4 subnets, you need 2 additional bits (because 22=42^2 = 422=4).
•The original subnet mask for a Class B network is /16.
•New subnet mask: /18 (because 16 + 2 = 18)

•Calculate the Subnet Size:


•Each subnet will have 2^(32−18)=2^14=16,384
•{2^(32 - 18)} = 2^{14} = 16,384 , 2^(32−18)=2^14=16,384 addresses.

•Determine the Subnet Ranges:


•The network 172.16.0.0 with a /18 mask creates subnets as follows:
1.Subnet 1:
1. Network Address: 172.16.0.0
2. Broadcast Address: 172.16.63.255
3. Usable IP Range: 172.16.0.1 to 172.16.63.254
2.Subnet 2:
1. Network Address: 172.16.64.0
2. Broadcast Address: 172.16.127.255
3. Usable IP Range: 172.16.64.1 to 172.16.127.254
3.Subnet 3:
1. Network Address: 172.16.128.0
2. Broadcast Address: 172.16.191.255
3. Usable IP Range: 172.16.128.1 to 172.16.191.254
4.Subnet 4:
1. Network Address: 172.16.192.0
2. Broadcast Address: 172.16.255.255
3. Usable IP Range: 172.16.192.1 to 172.16.255.254
In this setup, each subnet has 16,384 addresses, with 16,382 usable IPs in
each subnet.
Super netting in Network Layer

 Supernetting is the opposite of Subnetting. In subnetting, a single big network is divided into
multiple smaller subnetworks. In Supernetting, multiple networks are combined into a bigger
network termed a Supernetwork or Supernet.
 If you have Class C addresses and want to supernet them, the goal is to combine multiple
smaller Class C networks into a larger network.
 Step 1: Identify the Class C Networks to Combine
Suppose you have the following Class C networks:
• 192.168.1.0/24
• 192.168.2.0/24
• 192.168.3.0/24
• 192.168.4.0/24
Step 2: Convert Network Addresses to Binary
Convert the network addresses to binary format to see the common bits:
•192.168.1.0: 11000000.10101000.00000001.00000000
•192.168.2.0: 11000000.10101000.00000010.00000000
•192.168.3.0: 11000000.10101000.00000011.00000000
•192.168.4.0: 11000000.10101000.00000100.00000000

Step 3: Determine the Common Prefix


Look for the common bits in the binary representation. In this example:
•192.168.1.0 to 192.168.3.0 share the first 22 bits: 11000000.10101000.000000

Step 4: Determine the New Subnet Mask


Since the first 22 bits are common, the new subnet mask would be /22.

Step 5: Create the Supernet Address:


The new supernet address would be 192.168.0.0/22. This covers the IP address range from
192.168.0.0 to 192.168.3.255.
Step 6: Verification
The /22 subnet mask means:
•The first 22 bits are network bits (common across all combined networks).
•The remaining 10 bits are for host addresses within the combined supernet.

Summary
By supernetting, you've combined multiple Class C networks into a single network:
•Original Networks: 192.168.1.0/24, 192.168.2.0/24, 192.168.3.0/24,
192.168.4.0/24
•Supernet: 192.168.0.0/22
Classless Addressing

 Classless addressing, as used in Classless Inter-Domain Routing (CIDR), offers several


advantages over the traditional classful addressing system.
 Classless Inter-Domain Routing (CIDR): CIDR is a method for allocating IP addresses
that replaces the older system based on address classes. In CIDR, an IP address is followed
by a slash (/) and a number (e.g., 192.168.1.0/24). This number indicates how many bits are
used for the network portion of the address.
Address blocks:

 Address blocks refer to a range or group of IP addresses that are allocated to


a network or an organization.

CIDR Notation:
•Address blocks are often represented using CIDR (Classless Inter-Domain Routing)
notation, which includes an IP address followed by a slash (/) and a prefix length
(e.g., 192.168.1.0/24).

Size of Address Blocks:


•The size of the address block is determined by the prefix length. For example:
•192.168.1.0/24 represents 256 IP addresses (from 192.168.1.0 to
192.168.1.255).
•192.168.1.0/26 represents 64 IP addresses (from 192.168.1.0 to 192.168.1.63).
Address Blocks Rules:

1. The Address Block Must Be Contiguous:


•Explanation: All IP addresses in the block must be sequential, without any gaps.
•Example: If you have an address block starting at 192.168.1.0/29, the block includes IP addresses 192.168.1.0
to 192.168.1.7. These 8 addresses are contiguous.

2. The Number of Addresses Must Be a Power of 2:


•Explanation: The size of the address block must be a power of 2 (e.g., 2, 4, 8, 16, 32, 64, etc.).
•Example: An address block of size 8 would include IP addresses such as 192.168.1.0/29 (which has 8 addresses:
192.168.1.0 to 192.168.1.7).

3. The First Address in the Block Must Be Divisible by the Number of Addresses:
•Explanation: The starting IP address in the block should be divisible by the total number of addresses in that
block.
•Example: For an address block with 8 addresses (/29), the block starts at 192.168.1.0. Since 8 is the number of
addresses, the first address (192.168.1.0) must be divisible by 8 (which it is, as 192.168.1.0 is 0 in binary, and 0 ÷
8 = 0).
All Rules Example:

Example :

•Address Block: 192.168.1.0/28


•Number of Addresses: 16 (2^4 = 16)
•Contiguous Addresses: 192.168.1.0 to 192.168.1.15
•Divisibility: The first address (192.168.1.0) is divisible
by 16 (in binary: 192.168.1.0 is 0, and 0 ÷ 16 = 0).
Subnet mask:

Instead of using default masks like 255.0.0.0 (Class A) or 255.255.255.0 (Class C), CIDR uses a notation
like 192.168.1.0/24 where /24 indicates the number of bits used for the network portion.

In classless addressing (CIDR), the subnet mask:


•Definition: Shows how many bits of an IP address are used for the network part and how many are for
hosts.
•Format: Expressed as IP address/prefix length (e.g., 192.168.1.0/24).
•Prefix Length: Number after the slash (e.g., /24) indicates how many bits are used for the network. For
/24, the first 24 bits are for the network.

The format of mask is: a.b.c.d/n


Here /n defines the mask.
To write the mask in binary notation it will contain ‘ n ’ zeros(0’s) followed by (32-n) 1’s.
Example
Q. To find the
i. subnet mask for the IP address 205.16.37.39/28
ii. Find first address of the block
iii. Find last address of the block
iv. Number of addresses in the block

ANS:
i. Subnet mask
•CIDR Notation: /28
•This means the first 28 bits are used for the network portion.
 A /28 subnet mask means 28 bits are set to 1.
11111111.11111111.11111111.11110000

•Split the binary mask into four octets and convert each to decimal:
•11111111 = 255
•11111111 = 255
•11111111 = 255
•11110000 = 240
So, the subnet mask in decimal notation is: 255.255.255.240
ii. Find first address of the block
•Convert the last octet of the IP address to binary: 39 in decimal is 00100111 in binary.
•00100111 (39 in binary) becomes 00100000 (32 in binary) ,when the last 4 bits are set to 0. (32-n)bits to 0
•So, the network address for the IP block is 205.16.37.32.
•The first address or network address for the 205.16.37.39/28 subnet is 205.16.37.32. This address represents
the beginning of the subnet block.
•Another method is perform (AND Operation) with IP address and mask

•iii. Find last address of the block


• Setting last address of block is obtained by setting rightmost 32-n bits to 1.
• 205.16.37.32 = 11001101 00010000 00100101 00100000
• Setting last 4 bits to 1 , we get , 11001101 00010000 00100101 00101111 = 205.16.37.47
•Another method is perform (OR Operation) with IP address and Complement of mask

iv. Number of addresses in the block:


• The range of addresses = 2^32-28 = 2^4 = 16 Addresses.
• Range from 205.16.37.32 to 205.16.37.47
Network Address Translation

 Network Address Translation (NAT) is a method used by routers to allow multiple


devices on a private network (like a home or office network) to access the internet using a
single public IP address. It works by modifying the IP addresses in the packets as they
pass through the router, translating between the private IP addresses of the local network
and the public IP address used on the internet.
 Why is NAT Needed?
• Limited IPv4 Addresses: The IPv4 address space is limited, and NAT helps by
allowing many devices to share a single public IP address.
• Security: NAT hides the internal IP addresses of devices from external
networks, adding a layer of security.
IPv4 Datagram Header
IPV4 header format

 An IPv4 datagram is a packet of data that is used in the IPv4 protocol to transmit information across networks. It consists o f
a header and a payload.
• Header:
• Version (4 bits): Indicates the IP version, which is 4 for IPv4.
• Header Length (IHL) (4 bits): Specifies the length of the header in 32-bit words.
• It is a 4-bit field, meaning it can represent values from 0 to 15.
• Since the IHL field is 4 bits long, the minimum value it can represent is 5 (for a header without options), and the
maximum is 15 (for a header with maximum options).
• The standard IPv4 header is 20 bytes long. Since each 32-bit word is 4 bytes(Scaling Factor), the minimum IHL value
is 20 bytes / 4 bytes = 5.
• The maximum IHL value is 15, which means the header can be 15 words * 4 bytes = 60 bytes long.
3.Type of service: Low Delay, High Throughput, Reliability (8 bits)
Voice calls (VoIP) and video calls require quick, reliable data transmission to ensure clear communication. The TOS field
in the IPv4 header can prioritize these packets, reducing delays and ensuring smooth audio and video quality.

4.Total Length: Length of header + Data (16 bits), which has a minimum value 20 bytes and the maximum is 65,535
bytes.
•Field Size: The Total Length field is 16 bits long.
•Maximum Value: In binary, a 16-bit field can represent values from 0000000000000000 (0) to 1111111111111111
(65535).
•Total Length = Header Length + Payload Size Header Length: This varies depending on whether there are additional
options included. The minimum header length is 20 bytes (IHL = 5).
•Payload Size: The actual data being transmitted, which can vary in size.

5. Identification: Unique Packet Id for identifying the group of fragments of a single IP datagram (16 bits)
6. Flags: 3 flags of 1 bit each : reserved bit (must be zero), do not fragment flag, more fragments flag (same order)
7. Fragment Offset: Represents the number of Data Bytes ahead of the particular fragment in the particular Datagram.
Specified in terms of number of 8 bytes, which has the maximum value of 65,528 bytes.
8.Time to live: TTL is a value in an IP packet that controls how long the packet can stay in the
network before it’s discarded.

Imagine a bus ticket with an expiration time:

•TTL Value: 5 hours (initially set)


Scenario:
1.Hour 1: You board the bus with 5 hours left.
2.Hour 2: At the first stop, 4 hours are left on the ticket.
3.Hour 3: At the next stop, 3 hours are left.
4.Hour 4: At another stop, 2 hours are left.
If the Ticket Expiry Time Hits Zero:
•Hour 6: The ticket expires. If you haven’t reached your destination, you can’t use it anymore and need a
new one.
Summary:
TTL is like the expiration time on a bus ticket. It keeps track of how long data can stay in the network. If
it expires, the data is discarded to avoid going in circles forever.
9. Protocol:
The Protocol field in the IPv4 header is an 8-bit value that specifies which higher-level protocol should handle the
data within the packet.
•Purpose: It tells the receiving device which protocol (like TCP, UDP, or ICMP) should process the packet's data.
•Values: Each protocol has a specific number. For example:
•6: TCP (Transmission Control Protocol)
•17: UDP (User Datagram Protocol)
•1: ICMP (Internet Control Message Protocol)

10. Header Checksum: 16 bits header checksum for checking errors in the datagram header.
How It Works:
1.Calculation: The sender calculates the checksum value based on the header content.
2.Verification: The receiver recalculates the checksum to check for errors. If the calculated checksum matches the
one in the header, the header is considered intact. If not, the packet is likely corrupted and discarded.

11. Source IP address: 32 bits IP address of the sender


12. Destination IP address: 32 bits IP address of the receiver
13. Option: Optional information such as source route, record route. Used by the Network administrator to
check whether a path is working or not. Due to the presence of options, the size of the datagram header
can be of variable length (20 bytes to 60 bytes).
Fragmentation
Maximum
Transmission
Unit
What is Fragmentation?
IPv4 datagrams have a size limit, but sometimes, the path between the sender and receiver has a smaller Maximum
Transmission Unit (MTU) — the largest size of a packet that can be transmitted over a network link. When a datagram is too
large for the network, it is fragmented into smaller pieces (fragments), each of which can be transmitted individually.

How Fragmentation Works:


1.Original Datagram: A large datagram is created by the sender with all the necessary information (source, destination, data,
etc.).
2.MTU Check: The datagram passes through routers. If a router detects that the datagram size is larger than the MTU of the
next link, fragmentation occurs.
3.Splitting the Datagram: The router divides the datagram into smaller fragments, each with its own header. The data is
divided in such a way that all fragments except the last one have a size that is a multiple of 8 bytes (due to the offset field
requirement).
4.Fragment Headers: Each fragment has a unique header that includes:
1. Identification field: All fragments of the original datagram share the same ID, helping the receiver to identify which
fragments belong together.
2. Fragment offset: Indicates the position of the fragment’s data within the original datagram.
3. More Fragments flag (MF): This flag tells whether more fragments follow (if set to 1, more fragments are coming; if
set to 0, it's the last fragment).
5.Reassembly: The receiver collects all the fragments using the ID and offsets and reassembles them in the correct order to
form the original datagram.
•DF (Don't Fragment): This is a flag in the IPv4 header.
•When the DF flag is set to 1, it tells the network not to fragment the packet. If a packet with
this flag is too large for the network, the router will drop it and send an error message back to
the sender (ICMP "Fragmentation Needed" message).
•When DF is 0, fragmentation is allowed.

•MF (More Fragments): This is another flag in the IPv4 header.


•When MF is set to 1, it indicates that there are more fragments to follow, meaning this
packet is part of a series of fragments.
•When MF is 0, it means this is the last fragment.

•Res (Reserved): This is a Reserved bit in the IPv4 header.


•The Res field is not used in typical communications and is set to 0 by default. It’s reserved
for future use or specific network protocols that may need it. It doesn't currently serve a
function in IPv4 standard implementations.
Example

A packet has arrived with an M bit value of 1 and a


fragmentation offset value of 0. Is this the first fragment,
the last fragment, or a middle fragment?

Solution
Because the M bit is 1, it is either the first fragment or a
middle one. Because the offset value is 0, it is the first
fragment.
Example

A packet has arrived in which the offset value is 100. What


is the number of the first byte? Do we know the number of
the last byte?

Solution
To find the number of the first byte, we multiply the offset
value by 8. This means that the first byte number is 800. We
cannot determine the number of the last byte unless we
know the length.
Example

A packet has arrived in which the offset value is 100, the


value of HLEN is 5, and the value of the total length field is
100. What are the numbers of the first byte and the last
byte?
Solution
The first byte number is 100 × 8 = 800. The total length is
100 bytes, and the header length is 20 bytes (5 × 4), which
means that there are 80 bytes in this datagram. If the first
byte number is 800, the last byte number must be 879.
•If the first byte is at position 800 and you have 80 bytes of data, you count as follows: The first
byte is 800.
•The second byte is 801.
•The third byte is 802.
•…
•The 80th (last) byte is 879.
IPv6

The network layer protocol in the TCP/IP protocol suite is currently IPv4. Although
IPv4 is well designed , data communication has evolved since the inception of
IPv4 in the 1970s. IPv4 has some deficiencies that make it unsuitable for the fast-
growing Internet.
IPv6 datagram header and payload

• Base Header in IPv6 refers to the fixed 40-byte header that appears at the start of every IPv6 packet. This header is
simpler and more efficient compared to the IPv4 header, with fewer fields and fixed size, making processing faster.
• Extension Headers: Optional headers used for additional features like routing, fragmentation, security (e.g.,
Authentication Header, Encapsulation Security Payload), and options.
• Upper Layer Protocol Data: This is the actual data from the upper-layer protocols (like TCP, UDP) or
applications. The size of the payload is defined in the Payload Length field in the header.
Format of an IPv6 datagram
•Version (4 bits):
•Identifies the IP version. For IPv6, this value is always 6.
PRI stands for Primary Rate Interface. It's a type of phone line used by businesses to handle many calls at the
same time.
It has multiple channels: 23 for voice or data (in North America) or 30 (in Europe).
These channels allow companies to make or receive many phone calls simultaneously over a single line.

•Flow Label (20 bits):Used for identifying flows of packets that require special handling, such as real-time traffic
(e.g., voice or video streams). It helps route packets belonging to the same flow efficiently.

•Payload Length (16 bits): Specifies the size of the data in the payload, excluding the base header. It can hold
values from 0 to 65,535 bytes. If the payload is larger than 64 KB, a separate jumbo payload extension can be
used.

•Next Header (8 bits):Identifies the type of header that immediately follows the IPv6 base header. It could
point to a higher-layer protocol like TCP/UDP or an IPv6 extension header (such as Routing, Fragmentation, or
Authentication headers).

•Hop Limit (8 bits):Similar to the Time to Live (TTL) field in IPv4. It specifies the maximum number of hops
the packet can take before being discarded. Each router that forwards the packet decreases this value by one.
When it reaches zero, the packet is discarded.
Comparison between IPv4 and IPv6 packet headers
Extension header types
TRANSITION FROM IPv4 TO IPv6

• Because of the huge number of systems on the Internet,


the transition from IPv4 to IPv6 cannot happen
suddenly.
• It takes a considerable amount of time before every
system in the Internet can move from IPv4 to IPv6.
• The transition must be smooth to prevent any problems
between IPv4 and IPv6 systems.
Three transition strategies
Dual stack

•Both old (IPv4) and new (IPv6) systems work together on the same network.
•Your device can talk to both IPv4 and IPv6 systems without a problem.
Tunneling strategy

•Imagine sending a letter in an envelope through a post office that only handles old-style letters (IPv4).
•The new letter (IPv6) is placed inside an old-style envelope (IPv4) so it can go through, and at the end,
it’s taken out.
Header translation strategy

• Think of it as a translator between people who speak different languages.


• Translation involves converting IPv6 packets into IPv4 packets (and vice versa) so that IPv6-
only devices can communicate with IPv4-only devices.

You might also like