Stepping up to Layer 3 of the OSI model, we arrive at the Network Layer.
Just as every house has a postal address, every device connected to a network has an IP address (Internet Protocol address). IP addresses are used to uniquely identify devices across networks and enable communication between them.
There are two main versions of IP in use:
- IPv4 (Internet Protocol version 4): These are 32-bit addresses, typically represented in a dotted decimal format like this:
192.168.1.1
. IPv4 addresses are becoming increasingly scarce, but they remain the most widely used type of IP address. - IPv6 (Internet Protocol version 6): These are 128-bit addresses, represented in a hexadecimal format like this:
2001:0db8:85a3:0000:0000:8a2e:0370:7334
. IPv6 addresses were designed to address the exhaustion of IPv4 addresses, offering a vastly larger address space.
Within IPv4, there's also the concept of public vs. private IP addresses:
- Public IP addresses: These are globally unique addresses that are directly accessible on the internet.
- Private IP addresses: These are reserved address ranges that are not directly accessible on the internet. They are used within private networks (like your home or office network) and require Network Address Translation (NAT) to communicate with the outside world.
Subnetting: Dividing the Network
Subnetting is the process of dividing a network into smaller subnetworks. This is done to improve network efficiency, security, and manageability. Subnetting uses a subnet mask to divide an IP address into a network portion and a host portion.
Routing: Finding the Best Path
The core function of the Network Layer is routing. Routers are devices that operate at the Network Layer and forward data packets between different networks based on their IP addresses.
Think of routers like postal sorting offices. When you send a letter, it doesn't go directly to the recipient's address. Instead, it goes through a series of sorting offices, each of which directs the letter closer to its destination. Routers do the same thing with data packets.
Routers use routing tables to determine the best path to forward a packet. A routing table contains a list of networks and the next hop (the next router) to reach each network.
There are many routing protocols that routers use to learn about network topology and update their routing tables. Some common ones include:
- RIP (Routing Information Protocol): A simple distance-vector routing protocol.
- OSPF (Open Shortest Path First): A link-state routing protocol that is widely used in larger networks.
- BGP (Border Gateway Protocol): The routing protocol used to exchange routing information between different autonomous systems on the internet.
The concept of routing is crucial for network security.
The IP Protocol: Encapsulating the Data
The IP protocol is the workhorse of the Network Layer. It defines how data is encapsulated into IP packets for transmission across networks.
An IP packet includes the following key information:
- Source IP address: The IP address of the sending device.
- Destination IP address: The IP address of the receiving device.
- TTL (Time to Live): A value that is decremented by each router that forwards the packet. When the TTL reaches zero, the packet is discarded to prevent routing loops.
- Protocol: A field that indicates the protocol used in the next layer (e.g., TCP or UDP).
Fragmentation: Breaking It Down
Sometimes, a packet is too large to be transmitted across a particular network link. In this case, the IP protocol uses a process called fragmentation to break the packet into smaller fragments, which can then be reassembled at the destination.
ICMP: Network Diagnostics
The Internet Control Message Protocol (ICMP) is a supporting protocol that is used for network diagnostics and error reporting. Two common ICMP-based tools are:
- Ping: Sends an ICMP echo request to a destination device and waits for a reply. Ping is used to test network connectivity.
- Traceroute: Sends a series of ICMP packets with increasing TTL values to map the path a packet takes to a destination. Traceroute is used to troubleshoot network routing problems.
Network Layer Security Threats
- IP Spoofing: Faking source IP addresses to bypass access controls, launch denial-of-service and achieve network access.
- Man-in-the-Middle (MITM) attacks: If routing protocols are compromised, an attacker can redirect network traffic to the attacker.
- Denial-of-Service (DoS) attacks: Flooding a network with traffic to overwhelm routers and other network devices.
The Heart of Internetworking
The Network Layer is a crucial layer that allows for communication across networks, enabling applications like the web, email, and more. It's a building block for the communication. With it, we can proceed with even higher levels. In the next section, we'll examine how the Transporting Layer (layer 4) will control the flow of the packets.
OSI Network Layer: IP Addresses, Routing & Protocols
Understand the OSI Network Layer (Layer 3)! Learn about IPv4/IPv6, routing, IP protocol, and ICMP.