The Network Layer (OSI Layer 3)
Layer 2 moves frames inside one local network. Layer 3 is what makes the Internet possible: it gives every host a logical address and lets a packet cross many different networks, one router at a time, to reach a machine on the other side of the planet.
Where Layer 3 sits
The OSI model separates communication into layers, each with one job. Below Layer 3, the data link layer (Layer 2) moves a frame across a single link — from one device to its neighbour. Above Layer 3, the transport layer (Layer 4) decides which application gets the data, using port numbers. Layer 3 sits in the middle and answers one question: which network, and which path through the networks, must this data travel to reach the destination host?
The protocol that does this work in TCP/IP is the Internet Protocol (IP). When we say “the network layer” in a modern course, we almost always mean IP — today, either IPv4 or IPv6. This week focuses on IPv4; IPv6 arrives in a later week.
The three jobs of Layer 3
Every function of the network layer reduces to three things:
- Logical addressing. Layer 3 gives every host a globally meaningful address (an IP address) that is independent of the hardware. Unlike a MAC address, which is burned into the NIC and only matters on one local link, an IP address is logical: it is assigned by configuration or DHCP, and it encodes which network the host belongs to. The network part is what routers use to make forwarding decisions.
- Path selection (routing). When a destination is on a different network, someone must decide which way to send the packet. Layer 3 devices build a routing table — a map of known networks and the next hop that reaches each one — and choose the best path for every packet.
- Moving packets between networks. Layer 2 can only deliver inside one network. Layer 3 is the layer whose entire reason for existing is to carry data from one network to another, a process called routing. Without Layer 3 there is no Internet, only millions of isolated LANs.
Connectionless and best-effort
IP is designed to be simple, fast, and scalable, and it accepts two important limitations to get there. First, IP is connectionless: there is no setup phase before data is sent. A host does not call ahead, agree on a path, or reserve capacity. It simply builds a packet, puts the destination IP in the header, and hands it to the network. Each packet is treated as an independent datagram, so two packets from the same conversation can take completely different routes and may even arrive out of order.
Second, IP is best-effort. IP makes no guarantee that a packet will arrive at all, nor that it will arrive on time, nor in the right order. If a router’s queue is full it drops packets; if a link fails it reroutes the survivors. IP does not detect, report, or repair loss — it is the unreliable postal service the rest of the stack is built on.
The packet and encapsulation
The Layer 3 PDU is the packet (also called an IP datagram). It is built by encapsulation: the transport layer hands down a segment, and IP adds its own header in front of it. The IP header carries the source and destination IP addresses, the time-to-live (TTL), protocol number, and other fields. The original segment becomes the packet’s payload and is never altered.
The packet is not ready for the wire yet. Layer 2 wraps the whole packet in an Ethernet frame, adding a header with source and destination MAC addresses and an FCS trailer. The packet becomes the payload of the frame. So the nesting, from outside in, is:
Frame [ ETH | Packet [ IP | Segment [ TCP | Data ] ] | FCS ]
At every router along the path, the frame is stripped off and discarded, but the packet survives unchanged — its IP addresses stay the same from source to destination. This is the key contrast with Layer 2: MAC addresses change at every hop, IP addresses do not.
Routers: the Layer 3 devices
A router is the hardware that performs Layer 3 forwarding. A router has multiple interfaces, each connected to a different network (each with its own IP subnet). When a packet arrives, the router removes the incoming Layer 2 frame, reads the destination IP address, looks it up in its routing table, and builds a brand-new frame for the next link.
The routing table can be populated in three ways: directly connected networks
(learned automatically when an interface comes up), static routes (entered by hand),
and dynamic routing protocols (routers exchanging information automatically —
OSPF and others, covered later). If the router has no specific route but a default route
(0.0.0.0/0), it sends the packet to that gateway; if it has no route at all, it drops the
packet.
A router joining two LANs
The clearest way to see Layer 3 at work is two local networks joined by one router. The left LAN
(192.168.1.0/24) and the right LAN (192.168.2.0/24) are separate networks. The
router sits in both: one interface has an address in each subnet.
The left hosts use the router interface on their subnet as their default gateway. To reach a host in the other LAN, a packet travels host → Switch 1 → Router → Switch 2 → host. The switch never looks at the IP header; only the router does.
Common pitfalls and key terms
Five mistakes account for most lost marks on the network layer.
- Calling a Layer 3 unit a “frame”. Layer 3 = packet; Layer 2 = frame.
- Saying IP guarantees delivery. It is best-effort; TCP at Layer 4 provides the guarantees.
- Thinking packets all take one path. IP is connectionless, so packets can take independent routes.
- Believing IP addresses change at each hop. MAC addresses change; IP addresses stay end to end.
- Confusing routing with switching. A switch forwards within a network (Layer 2); a router forwards between networks (Layer 3).
Key terms
| Term | Meaning |
|---|---|
| Network layer (Layer 3) | The OSI layer that provides logical addressing and path selection so packets travel between networks. |
| IP | Internet Protocol; the Layer 3 protocol that addresses and routes packets. |
| Packet | The Layer 3 PDU: an IP header wrapping a transport-layer segment. |
| Connectionless | No setup or agreed path before transmission; each packet is independent. |
| Best-effort | No guarantee of delivery, ordering, or timing; failures are not reported by IP. |
| Router | A Layer 3 device that forwards packets between networks using IP addresses. |
| Routing table | A map of known networks and the next hop/interface used to reach each one. |
| Default gateway | The router interface a host sends packets to when the destination is on a different network. |
Review
Check what you have learned with these review questions.
Sources & references
- Postel, J. RFC 791: Internet Protocol (1981), Section 1.4 (“Operation”) and Section 2.1 (the IP header). rfc-editor.org/rfc/rfc791.
- Braden, R. RFC 1122: Requirements for Internet Hosts — Communication Layers (1989), Section 1.3.3 (PDU terminology) and Section 3. rfc-editor.org/rfc/rfc1122.
- Socolofsky, T. & Kale, C. RFC 1180: A TCP/IP Tutorial (1991), Sections 2–4. rfc-editor.org/rfc/rfc1180.
- Cisco. CCNA (200-301) Exam Topics, Network Fundamentals (OSI model, Layer 3). cisco.com.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.