Layer 3: The Network Layer
Discover how IP addresses and routers move packets across networks, how routing decisions are made, and the difference between IPv4 and IPv6.
In this lesson, you will learn to:
- By the end of this lesson, learners will be able to explain how IP addressing and routing move packets across networks, describe the role of routers, and compare IPv4 and IPv6.
Layer 3: The Network Layer
This lesson focuses on the Network layer, where logical addressing and routing happen. Learners will understand IP addresses, packet forwarding, routers, and how data crosses multiple networks from source to destination.
Logical Addressing with IP
The Network layer is the third layer of the OSI model. Its job is to move packets from the source device to the destination device across multiple networks. While the Data Link layer below it handles communication on a local link, the Network layer handles logical addressing and routing from end to end.
The most important Network layer protocol is the Internet Protocol, or IP. IP gives every device a logical address called an IP address. Unlike a physical MAC address, which is tied to a network interface, an IP address is assigned logically and can change.
What an IP address looks like
An IPv4 address is written as four decimal numbers separated by dots. Each number is between 0 and 255.
Example: 192.168.1.10
An IPv6 address is longer, written as eight groups of hexadecimal digits separated by colons.
Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Logical addressing versus physical addressing
It is important to understand the difference between Layer 3 and Layer 2 addresses. A physical MAC address identifies a specific network interface on a local network. A logical IP address identifies a device within a larger internetwork. IP addresses are structured so routers can determine which network a device belongs to and forward packets toward that network.
The PDU at Layer 3
The Protocol Data Unit at the Network layer is called a packet. A packet contains the Network layer header, which includes the source IP address and destination IP address, plus the data from the Transport layer. Routers read the destination IP address to decide where to send the packet next.
Routers and Packet Forwarding
Routers are the primary devices that operate at the Network layer. A router connects two or more networks and forwards packets between them based on destination IP addresses. This process is called routing.
How a router forwards a packet
When a router receives a packet, it looks at the destination IP address. It then consults its routing table, which lists known networks and the best next hop for reaching each one. The router sends the packet out the appropriate interface toward the next router along the path. This continues hop by hop until the packet reaches its destination network.
What is a hop?
A hop is one router-to-router step. Each time a packet passes through a router, the hop count increases. Tools such as traceroute show the series of hops a packet takes across the internet. Seeing the hops helps network engineers understand the path and locate failures.
The difference between Layer 3 and Layer 2 forwarding
It is easy to confuse switches and routers. A switch typically forwards frames on a local network using MAC addresses at the Data Link layer. A router forwards packets between different networks using IP addresses at the Network layer.
- Switch: Layer 2, local forwarding with MAC addresses.
- Router: Layer 3, cross-network forwarding with IP addresses.
A simple home network often has both. A switch inside the home connects devices to each other, while a router connects the home network to the internet.
Why routing is needed
If all devices were on the same local network, routing would not be necessary. But the internet is a network of networks. Routing allows a packet from a laptop in one country to reach a server in another country by making many small forwarding decisions along the way. That is the central responsibility of the Network layer.
IPv4 and IPv6
The internet uses two versions of IP: IPv4 and IPv6. Both are Network layer protocols, but they are different enough that learners must understand both.
IPv4
IPv4 is the older and still very common version. An IPv4 address is 32 bits long. Written in dotted-decimal form, it looks like 192.168.1.10.
IPv4 provides about 4.3 billion unique addresses. That sounds like a lot, but the growth of the internet has exhausted the available public IPv4 space. Techniques such as Network Address Translation help many private devices share one public IPv4 address, but the fundamental limit remains.
IPv6
IPv6 was designed to solve the address exhaustion problem. An IPv6 address is 128 bits long, providing an enormous number of unique addresses. Written in hexadecimal groups separated by colons, it looks like 2001:0db8:85a3:0000:0000:8a2e:0370:7334.
IPv6 also introduces improvements in address autoconfiguration, simplified headers, and built-in support for modern features. However, IPv4 and IPv6 are not directly compatible without transition mechanisms.
Key differences
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address size | 32 bits | 128 bits |
| Format | Dotted decimal | Hexadecimal colon groups |
| Example | 192.168.1.10 | 2001:0db8:85a3::8a2e:0370:7334 |
| Address space | About 4.3 billion | Vastly larger |
| NAT needed | Often | Typically not |
Why this matters in security and networking
Many network tools and firewall rules still refer to IPv4 addresses. As IPv6 adoption grows, professionals need to recognize both formats and understand that a network may run both at once. A firewall rule written for IPv4 may not apply to IPv6 traffic. This is a common real-world oversight. Knowing the Network layer means understanding both address families and how they affect routing, access control, and troubleshooting.