The Network Layer is a vital component in the OSI and TCP/IP models that is responsible for packet routing, addressing, and managing the delivery of data across multiple networks. It ensures that data is sent from the source to the destination across different devices and networks. This chapter delves into important topics such as IPv4 addressing, routing protocols, and congestion control, which are fundamental for every computer science student. In this post, we will break down these concepts in an easy-to-understand format.
3.1 Network Layer Services – Packetizing, Routing and Forwarding, Other Services
The Network Layer provides key services for transmitting data across networks:
- Packetizing: The process of dividing data into smaller packets for efficient transmission. Each packet is individually addressed and transmitted through the network.
- Routing: Determines the best path for data packets to travel from the source to the destination. Routing involves algorithms and protocols to dynamically select the optimal route.
- Forwarding: The process of moving packets from one device to the next hop on the route. Forwarding is based on the destination IP address and involves checking routing tables.
Other important services include:
- Error handling: Ensuring the data is accurately delivered by detecting and handling transmission errors.
- Flow control: Managing the rate at which packets are sent to avoid network congestion.
3.2 Open and Closed Loop Congestion Control
Congestion Control is essential in managing the network’s load to ensure data transmission is not disrupted due to congestion:
- Open-Loop Congestion Control: Works without feedback from the network. It involves setting parameters such as the maximum transmission rate and ensuring that the sender does not overload the network.
- Closed-Loop Congestion Control: Involves dynamic adjustments based on feedback from the network. Routers detect congestion, and the sender is notified to reduce the sending rate to avoid further congestion.
3.3 IPv4 Addressing – Address Space, Classful Addressing, Subnetting, Supernetting, Classless Addressing, Network Address Resolution (NAT)
IPv4 addressing is fundamental for identifying devices on a network. Here are the key concepts:
- Address Space: The total number of possible IP addresses in IPv4 is 32 bits, providing over 4 billion unique addresses.
- Classful Addressing: The IPv4 address space is divided into five classes (A, B, C, D, and E) based on network size. Class A, B, and C are used for assigning addresses to hosts.

- Subnetting: The process of dividing an IP network into smaller subnetworks to improve efficiency and security. Subnetting allows network administrators to allocate addresses effectively within a network.
- Supernetting: The reverse process of subnetting, where multiple smaller networks are combined into a larger network.
- Classless Addressing (CIDR): A method that replaces classful addressing with variable-length subnet masks (VLSM), offering more flexibility and efficient use of IP address space.
Difference Between Classful Addressing and Classless Addressing
Parameter | Classful Addressing | Classless Addressing |
---|---|---|
Basics | In Classful addressing IP addresses are allocated according to the classes- A to E. | Classless addressing came to replace the classful addressing and to handle the issue of allocation of IP Address. |
Network ID and Host ID | The changes in the Network ID and Host ID depend on the class. | There is no such restriction of class in classless addressing. |
VLSM | It does not support the Variable Length Subnet Mask (VLSM). | It supports the Variable Length Subnet Mask (VLSM). |
Bandwidth | Classful addressing requires more bandwidth. As a result, it becomes slower and more expensive as compared to classless addressing. | It requires less bandwidth. Thus, fast and less expensive as compared to classful addressing. |
CIDR | It does not support Classless Inter-Domain Routing (CIDR). | It supports Classless Inter-Domain Routing (CIDR). |
Updates | Regular or periodic updates | Triggered Updates |
Troubleshooting and Problem detection | Troubleshooting and problem detection are easy than classless addressing because of the division of network, host and subnet parts in the address. | It is not as easy compared to classful addressing. |
Division of Address | NetworkHost Subnet | Host Subnet |
- Network Address Resolution (NAT): A technique used to map private IP addresses to public ones. NAT helps conserve IP addresses and improves security by hiding internal Addresses.
Q.State the class of following IP address 128.89.0.26
Step 1: Identify the First Octet
- The first octet is 128.
- The classification of IPv4 addresses is:
- Class A:
1 - 126
- Class B:
128 - 191
- Class C:
192 - 223
- Class A:
Step 2: Determine the Class
- Since 128 falls within 128 – 191, the IP address 128.89.0.26 belongs to Class B.
Final Answer:
✅ Class B IP Address.
Q. Find out class, net ID and host ID of following IP address 126.25.21.1
Step 1: Determine the Class
The class of an IPv4 address is determined by its first octet (the first number before the dot).
Class | First Octet Range | Network & Host Bits |
---|---|---|
Class A | 1 – 126 | Network (8 bits), Host (24 bits) |
Class B | 128 – 191 | Network (16 bits), Host (16 bits) |
Class C | 192 – 223 | Network (24 bits), Host (8 bits) |
- The first octet of 126.25.21.1 is 126.
- 126 falls within the range of Class A (1 – 126).
✅ So, the given IP address belongs to Class A.
Step 2: Identify the Network ID and Host ID
- In Class A, the first 8 bits (1st octet) represent the Network ID.
- The remaining 24 bits (last 3 octets) represent the Host ID.
Network ID | Host ID |
---|---|
126 | 25.21.1 |
Final Answer:
- Class: A
- Network ID: 126
- Host ID: 25.21.1
Q.Change the following IP V4 addresses from binary notation to dotted decimal notation 10000001 00001011 00001011 11101111
11000001 10000011 00011011 11111111
To convert the given binary IPv4 addresses to dotted decimal notation, follow these steps:
Steps to Convert:
- Split the binary IP into 4 octets (each 8 bits).
- Convert each octet from binary to decimal.
- Write the result in dotted decimal notation.
1st IP Address: 10000001 00001011 00001011 11101111
- 10000001 → 129
- 00001011 → 11
- 00001011 → 11
- 11101111 → 239
✅ Converted IP: 129.11.11.239
2nd IP Address: 11000001 10000011 00011011 11111111
- 11000001 → 193
- 10000011 → 131
- 00011011 → 27
- 11111111 → 255
✅ Converted IP: 193.131.27.255
Final Answer:
1️⃣ 10000001 00001011 00001011 11101111
→ 129.11.11.239
2️⃣ 11000001 10000011 00011011 11111111
→ 193.131.27.255
Binary to Decimal Conversion Table
This table helps quickly convert binary (8-bit) numbers to decimal values.
Binary | Decimal | Binary | Decimal | |
---|---|---|---|---|
00000000 | 0 | 10000000 | 128 | |
00000001 | 1 | 10000001 | 129 | |
00000010 | 2 | 10000010 | 130 | |
00000011 | 3 | 10000011 | 131 | |
00000100 | 4 | 10000100 | 132 | |
00000101 | 5 | 10000101 | 133 | |
00000110 | 6 | 10000110 | 134 | |
00000111 | 7 | 10000111 | 135 | |
00001000 | 8 | 10001000 | 136 | |
00001001 | 9 | 10001001 | 137 | |
00001010 | 10 | 10001010 | 138 | |
00001011 | 11 | 10001011 | 139 | |
00001100 | 12 | 10001100 | 140 | |
00001101 | 13 | 10001101 | 141 | |
00001110 | 14 | 10001110 | 142 | |
00001111 | 15 | 10001111 | 143 | |
00010000 | 16 | 10010000 | 144 | |
00010001 | 17 | 10010001 | 145 | |
00010010 | 18 | 10010010 | 146 | |
00010011 | 19 | 10010011 | 147 | |
00010100 | 20 | 10010100 | 148 | |
00010101 | 21 | 10010101 | 149 | |
00010110 | 22 | 10010110 | 150 | |
00010111 | 23 | 10010111 | 151 | |
00011000 | 24 | 10011000 | 152 | |
00011001 | 25 | 10011001 | 153 | |
00011010 | 26 | 10011010 | 154 | |
00011011 | 27 | 10011011 | 155 | |
00011100 | 28 | 10011100 | 156 | |
00011101 | 29 | 10011101 | 157 | |
00011110 | 30 | 10011110 | 158 | |
00011111 | 31 | 10011111 | 159 | |
00100000 | 32 | 10100000 | 160 | |
00110000 | 48 | 11000000 | 192 | |
01000000 | 64 | 11100000 | 224 | |
01100000 | 96 | 11111111 | 255 |
Quick Binary to Decimal Trick
Each binary digit represents a power of 2:
Binary Position | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|---|
Example: 10101100 | 128 | 0 | 32 | 0 | 8 | 4 | 0 | 0 |
Sum of 1
positions → 128 + 32 + 8 + 4 = 172
✅ Binary 10101100
= Decimal 172
Use this method to quickly convert any binary to decimal!
3.4 Forwarding of IP Packets – Based on Destination Address, Based on Label
- Destination Address-Based Forwarding: The most common method for forwarding IP packets. Routers use the destination IP address in the packet to determine where to forward it.
- Label-Based Forwarding: In this method, packets are forwarded based on labels (used in technologies like MPLS – Multi-Protocol Label Switching). This allows for more efficient routing as the labels simplify the decision-making process compared to using IP addresses.
3.5 Network Layer Protocols – Internet Protocol (IP), IPv4 Datagram Format, Fragmentation, Options
Internet Protocol (IP) is the most widely used network layer protocol for routing packets across the Internet. The key features of IP include:
- IPv4 Datagram Format: The format in which data is transmitted over the network, including fields like source address, destination address, time-to-live (TTL), header checksum, and more.
- Fragmentation: A process that breaks large data packets into smaller fragments to accommodate the maximum transmission unit (MTU) of the network. Routers handle fragmentation to ensure the data can be delivered.
- Options: Additional fields in the IP header that provide extra features like security, timestamps, and routing.
Q. What is the value of HLEN if the size of header is 40 bytes?
Calculating HLEN (Header Length) in IPv4
HLEN (Header Length) Field in an IPv4 header represents the size of the header in 32-bit words (each word = 4 bytes).
Formula to Calculate HLEN:
HLEN=Header Size in BytesWord Size (4 Bytes)\text{HLEN} = \frac{\text{Header Size in Bytes}}{\text{Word Size (4 Bytes)}}
Given:
- Header Size = 40 bytes
- Word Size = 4 bytes
HLEN=404=10\text{HLEN} = \frac{40}{4} = 10
Final Answer:
✅ HLEN = 10 (in decimal) or 0xA (in hexadecimal).
3.6 Mobile IP – Addressing, Agents, Three Phases
Mobile IP allows devices to maintain their IP address as they move across different networks:
- Addressing: Mobile IP ensures that mobile devices can keep the same IP address while moving from one network to another.
- Agents: Mobile IP uses two types of agents: the Home Agent and the Foreign Agent. The Home Agent keeps track of the mobile device’s location, while the Foreign Agent provides routing information to the mobile device when it’s in a foreign network.
- Three Phases:
- Agent Discovery: The mobile device discovers the available agents in the network.
- Registration: The mobile device registers its location with the Home Agent.
- Tunneling: When the mobile device is away from the home network, the Home Agent tunnels packets to the Foreign Agent, which then forwards them to the device.
3.7 Next Generation IP – IPv6 Address Representation, Address Space, Address Types, IPv6 Protocol, Packet Format, Extension Header, Difference Between IPv4 and IPv6
IPv6 is the successor to IPv4 and was designed to overcome the limitations of IPv4, such as the address shortage:
- IPv6 Address Representation: IPv6 addresses are written as 8 groups of four hexadecimal digits, separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334).
- Address Space: IPv6 uses 128-bit addresses, providing an enormous address space, far exceeding IPv4’s 32-bit address space.
- Address Types: IPv6 has three main types of addresses:
- Unicast: Refers to a single sender and a single receiver.
- Multicast: Refers to a single sender and multiple receivers.
- Anycast: Refers to a single sender and the nearest receiver from a group of receivers.
- IPv6 Protocol: IPv6 improves upon IPv4 by offering better security, simplified header structure, and better support for large-scale networks.
- Packet Format: The IPv6 packet header has been simplified compared to IPv4, with fixed-length fields for ease of processing.
- Extension Header: IPv6 allows additional headers to be added to the packet for special functions, such as routing, fragmentation, and security.
- Difference Between IPv4 and IPv6:
- IPv6 has a larger address space (128 bits vs. 32 bits in IPv4).
- IPv6 has a simplified header format for faster processing.
- IPv6 supports better security features (IPsec).
- IPv6 eliminates the need for NAT due to its vast address space.
3.8 Routing – General Idea, Algorithms – Distance Vector Routing, Link State Routing, Path-Vector Routing
Routing is the process of determining the path that data packets take from the source to the destination. Key routing algorithms include:
- Distance Vector Routing: Each router maintains a table of distances to all known destinations and periodically updates its neighbors. Example: RIP (Routing Information Protocol).
- Link State Routing: Routers have complete knowledge of the entire network and use algorithms like Dijkstra’s to determine the best path. Example: OSPF (Open Shortest Path First).
- Path-Vector Routing: A hybrid of distance vector and link state routing. BGP (Border Gateway Protocol) is an example of path-vector routing used for routing across the Internet.
Conclusion
Chapter 3 provides an in-depth exploration of the Network Layer, which plays a critical role in ensuring that data is routed, addressed, and delivered accurately across networks. From IPv4 addressing to routing algorithms and mobile IP, these concepts are foundational for any computer science student to understand how the Internet and networked devices communicate. Mastering the topics covered in this chapter will prepare you for more advanced studies in networking and data communication.