Tags:conceptosimodelnetworknetworklayer Status:🟩
OSI Model - Network Layer
Summary
The Network Layer is responsible for routing and forwarding data packets between devices across different networks. It handles logical addressing, packet fragmentation, and reassembly, ensuring data can travel from source to destination, whether within the same network (local) or across multiple networks (non-local). The primary protocol in this layer is the Internet Protocol (IP), which assigns unique addresses to devices and routes packets through various networks without guaranteeing delivery order or success.
Internet Protocols (IP)
The Internet Protocol (IP) is a fundamental protocol in networking responsible for moving data packets between devices across networks. It operates at the network layer, ensuring that messages can travel from one host to another, whether locally within a subnet or across different subnets.
Key Functionality: The main role of IP is to move packets of data from one location to another.
- Locally: Direct communication occurs within the same subnet, allowing devices to exchange data without intermediary routing.
- Non-local: When data needs to be sent outside the local subnet, it is routed through various networks to reach its destination.
Addressing: IP provides a method for identifying devices on a network.
- Host Identification: Each device (host) is assigned a unique IP address, allowing it to be recognized and communicated with.
- Subnetting: The use of Classless Inter-Domain Routing (CIDR) allows for efficient allocation of IP addresses, improving the organization of networks.
Connection-less, Unreliable, Datagram Protocol: IP operates without establishing a connection prior to data transmission, meaning there is no guarantee that packets will arrive in the same order they were sent, or that they will arrive at all.
Protocol on Top of the Link Layer: IP functions above the link layer, which is responsible for the physical transmission of data.
- Maximum Transmission Unit (MTU): The MTU defines the largest packet size that can be transmitted over a specific link without fragmentation.
- Fragmentation: If a packet exceeds the MTU, it may need to be fragmented into smaller pieces to ensure successful delivery.
IPv6 and IPv4
IPv4 and IPv6 are both protocols used for addressing and routing packets across networks, but they differ significantly in their design, capabilities, and addressing methods.
Protocol Support: Both IPv4 and IPv6 provide similar protocol support for network communication, ensuring that fundamental functionalities are maintained.
Application Support: While both protocols support applications, some older applications may require updates to work properly with IPv6.
Cross-Communication: Communication between IPv4 and IPv6 networks can be achieved through tunneling, allowing packets from one protocol to be encapsulated and sent over the other.
Addressing with IPv6: Each device in an IPv6 network typically has at least two addresses:
- Global Address: A unique address that allows direct access over the Internet.
- Link-Local Address: An address used for communication within the same local network.
Possibility of More Addresses: IPv6 can assign additional addresses to devices as needed, providing greater flexibility in addressing.
IPv4 vs. IPv6:
| Feature | IPv4 | IPv6 |
|---|---|---|
| Example Address | 192.0.2.1 | 2001:db8:dead:beef:cafe::1 |
| Internet Standard | 1982 | 2017 |
| Address Size | 32 bits | 128 bits |
| Number of Addresses | 4.3 billion (4.3 × 10^9) | 340 undecillion (3.4 × 10^38) |
| Fragmentation | At every hop | Only at the source |
| Features | Limited features | Extensive features |
IPv6 and IPv4 header
IPv4 at top and IPv6 at bottom

Subnet
A subnet, or “subnetwork,” is a smaller network within a larger one that enhances IP address management and network performance. Subnetting divides a larger network into manageable sections, improving organization and security of network traffic. A home network is a subnet since it operates a smaller network withing the larger internet, allowing devices like computers, phones and smart devices to communicate with each other.
Static and Variable Bits: In subnetting, the first x bits of the IP address remain fixed (static), while the remaining bits can vary to identify individual hosts within the subnet.
Subnet Example: For instance, in the address 192.0.2.130/26:
- The /26 indicates that the first 26 bits are used for the network portion, and the remaining 6 bits are available for host addresses.
Subnet Addresses: The range of valid addresses for this subnet spans from 192.0.2.128 to 192.0.2.191.
Subnet Size: This subnet can accommodate 64 hosts, as calculated by 2(32−26)=642^{(32 - 26)} = 642(32−26)=64.
Address Breakdown:
| Binary Form | Dot-Decimal Notation | |
|---|---|---|
| IP Address | 11000000.00000000.00000010.10000010 | 192.0.2.130 |
| Subnet Mask | 11111111.11111111.11111111.11000000 | 255.255.255.192 |
| Network Prefix | 11000000.00000000.00000010.10000000 | 192.0.2.128 |
| Host Part | 00000000.00000000.00000000.00000010 | 0.0.0.2 |
Home network example

- Desktop Address: 192.0.2.2
- Desktop Subnet: /24 = x.y.z.0 to x.y.z.255
- Desktop ↔ Laptop: Direct (Same subnet)
- Desktop/Laptop ↔ Webserver: Routed
Network Groups
In networking, traffic can be categorized based on how data is transmitted between devices.
Unicast: The most common type of network traffic, where data is sent from one sender to one specific receiver.
One-to-Many Communication: This method is more efficient than sending multiple unicast messages, as it allows a single message to reach multiple recipients simultaneously. Streaming video content to multiple viewers is a typical use case.
Multicast: Here the data is sent to a specific group of interested recipients (subscription group) rather than all devices on the network. Multicast Domain Name System (mDNS) enables devices to discover each other without a central server.
Broadcast: In broadcast communication, data is sent to all devices within a subnet. This method is typically used in IPv4 networks, where a single packet is transmitted to every device in the subnet.
Service Discovery: Both multicast and broadcast are commonly used for service discovery, allowing devices to locate services available on the network efficiently.
Network Address Translation (NAT)
Network Address Translation (NAT) is a technique primarily used in IPv4 networks to allow multiple devices to share a single public IP address. This method helps conserve IP addresses and enhances security by obscuring internal network structures.
- IP Address Sharing: NAT enables many hosts on a local network to use the same public IP address for Internet access, making it efficient in managing IP address allocations.
- Transparency for Hosts: Devices do not need to be aware of NAT; they operate as if they each have their own public IP addresses.
- Stateful Firewall Requirement: NAT requires a stateful firewall to keep track of active connections and manage the mapping between internal and external IP addresses
- Common Applications: NAT is widely used in home routers, company networks, and by Internet Service Providers (ISPs) through Carrier Grade NAT (CGNAT).
- Debugging Challenges: Troubleshooting can become complex, especially with multiple layers of NAT, as it complicates the tracing of connection paths.
IPv6
IPv6 is the next generation of the Internet Protocol, designed to address the limitations of IPv4. With the exhaustion of available IPv4 addresses, IPv6 provides a more sustainable and efficient solution for the growing number of devices connected to the Internet.
- Address Availability: IPv6 offers an enormous address space, providing enough unique IP addresses for every device, ensuring that the world won’t run out of addresses.
- NAT Limitations: Network Address Translation (NAT) was not intended to be a long-term solution for IP address scarcity. IPv6 eliminates the need for NAT by allowing direct device-to-device communication.
- Efficient Routing: IPv6 simplifies and improves routing efficiency, which can lead to faster data transmission across the network.
- Quality of Service (QoS): Built-in QoS features allow for prioritizing traffic, such as differentiating between real-time voice calls and file transfers. This ensures that critical applications receive the necessary bandwidth and low latency.
- Privacy Features: IPv6 includes privacy enhancements, such as temporary addresses that help protect user identity and location.
- Address Delegation: IPv6 supports automatic address configuration and delegation, allowing devices to self-assign addresses within the network without manual intervention.
- Enhanced Security: Security features are integrated into IPv6, providing better protection against common vulnerabilities and ensuring secure data transmission.
Internet Control Message Protocol (ICMP)
The Internet Control Message Protocol (ICMP) is a crucial network layer protocol used for diagnostic and error-reporting purposes. It operates on top of the Internet Protocol (IP) and is essential for both IPv4 and IPv6, though it plays a particularly vital role in IPv6.
- Commonly Known as the “Ping-Pong” Protocol: ICMP is often associated with the “ping” command, which tests connectivity between devices.
- Beyond Ping: ICMP provides several important functionalities, including:
- Timeouts: Notifications when a response takes too long.
- Destination Unreachable: Messages indicating that a packet cannot reach its destination.
- Fragmentation Notifications: Alerts for fragmentation needs in IPv4 and “Packet Too Big” messages in IPv6.
- Address Resolution: Used in IPv6 for resolving addresses.
- Network Layer Protocol: ICMP functions at the network layer, similar to IP, providing feedback about issues in the communication environment.
- Essential for IPv6: While ICMP is important for both protocols, it is crucial for the functionality of IPv6 networks.
- Debugging Tool: ICMP is an excellent tool for troubleshooting network issues and is required for traceroute operations, helping trace the path packets take through a network.
- Security Concerns: ICMP messages are often blocked in IPv4 networks for “security reasons,” which can hinder effective troubleshooting.