Chapter 3: Network Layer – Study Notes for BSc Computer Science Students

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:

  1. 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.
  2. 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

ParameterClassful AddressingClassless Addressing
BasicsIn 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 IDThe changes in the Network ID and Host ID depend on the class.There is no such restriction of class in classless addressing.
VLSMIt does not support the Variable Length Subnet Mask (VLSM).It supports the Variable Length Subnet Mask (VLSM).
BandwidthClassful 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.
CIDRIt does not support Classless Inter-Domain Routing (CIDR).It supports Classless Inter-Domain Routing (CIDR).
UpdatesRegular or periodic updatesTriggered Updates
Troubleshooting and Problem detectionTroubleshooting 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 SubnetHost 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

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).

ClassFirst Octet RangeNetwork & Host Bits
Class A1 – 126Network (8 bits), Host (24 bits)
Class B128 – 191Network (16 bits), Host (16 bits)
Class C192 – 223Network (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 IDHost ID
12625.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:

  1. Split the binary IP into 4 octets (each 8 bits).
  2. Convert each octet from binary to decimal.
  3. Write the result in dotted decimal notation.

1st IP Address: 10000001 00001011 00001011 11101111

  • 10000001129
  • 0000101111
  • 0000101111
  • 11101111239

Converted IP: 129.11.11.239


2nd IP Address: 11000001 10000011 00011011 11111111

  • 11000001193
  • 10000011131
  • 0001101127
  • 11111111255

Converted IP: 193.131.27.255


Final Answer:

1️⃣ 10000001 00001011 00001011 11101111129.11.11.239
2️⃣ 11000001 10000011 00011011 11111111193.131.27.255

Binary to Decimal Conversion Table

This table helps quickly convert binary (8-bit) numbers to decimal values.

BinaryDecimalBinaryDecimal
00000000010000000128
00000001110000001129
00000010210000010130
00000011310000011131
00000100410000100132
00000101510000101133
00000110610000110134
00000111710000111135
00001000810001000136
00001001910001001137
000010101010001010138
000010111110001011139
000011001210001100140
000011011310001101141
000011101410001110142
000011111510001111143
000100001610010000144
000100011710010001145
000100101810010010146
000100111910010011147
000101002010010100148
000101012110010101149
000101102210010110150
000101112310010111151
000110002410011000152
000110012510011001153
000110102610011010154
000110112710011011155
000111002810011100156
000111012910011101157
000111103010011110158
000111113110011111159
001000003210100000160
001100004811000000192
010000006411100000224
011000009611111111255

Quick Binary to Decimal Trick

Each binary digit represents a power of 2:

Binary Position1286432168421
Example: 1010110012803208400

Sum of 1 positions128 + 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:
    1. Agent Discovery: The mobile device discovers the available agents in the network.
    2. Registration: The mobile device registers its location with the Home Agent.
    3. 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:

  1. Distance Vector Routing: Each router maintains a table of distances to all known destinations and periodically updates its neighbors. Example: RIP (Routing Information Protocol).
  2. 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).
  3. 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.

Scroll to Top