Core CS · Computer Networks
One impossible problem, split seven ways
Each layer solves one problem, uses only the service under it, and offers only its own service above. Learn which problem each layer owns and the rest of this module turns into a lookup.
Diagnose five real faults, one layer at a time →01 The idea
Why anyone split it into layers at all
Getting a browser in Hyderabad talking to a server in Frankfurt is not one problem. It is a voltage problem, a which-device-on-this-cable problem, a which-way-through-the-world problem and a which-program-is-this-for problem, all at once. Nobody has solved that as a single design. The OSI reference model, published by ISO, is the admission of it.
Calling a module a layer does not make it one. Two rules make it one, and everything else in this lesson follows from them.
Two arrows allowed, one forbidden. This is why TCP behaves identically over Ethernet, Wi-Fi and a modem link: it never learns which is underneath, because it is not allowed to ask.
02 Worked example
One GET request, on its way down to the wire
A browser on 10.0.0.1 asks a server on 203.0.113.9 for a page. The request line and its headers come to 100 bytes. That is the whole example, and the rest of the lesson reuses it, so hold on to the 100.
100 + 20 = 120, + 20 = 140, + 14 + 4 = 158. Fifty-eight of those 158 bytes are wrapper — just over a third of the wire is not the message. That ratio is the price of layering.
Sit with the transport row. TCP was handed 100 bytes and never found out they were HTTP. It handed 120 bytes down and never found out they would travel over Ethernet. Rule two and rule one, once each, inside a single step.
Notice which layers did nothing: a plain GET runs no session protocol and converts no representation, so layers 5 and 6 added no bytes. That is the honest state of the internet, not a gap in the example. On the far side the whole thing runs backwards, each layer stripping only the header its own peer added.
03 Mechanics
Seven layers, and what each one owns
Read it bottom up, from the wire to the user, because nothing above layer 1 works until layer 1 works. Each responsibility is deliberately one line. If your answer to “what does the network layer do” needs two, one of them belongs to a different layer.
The four layers with a PDU of their own are the four that put bytes on the wire. Layers 5 and 6 carry no header on a normal connection, which is why they look thin.
| Layer | Two real protocols or standards you can name |
|---|---|
| 1 · Physical | 1000BASE-T (IEEE 802.3ab), RS-232 |
| 2 · Data link | Ethernet (IEEE 802.3), PPP |
| 3 · Network | IP, ICMP |
| 4 · Transport | TCP, UDP |
| 5 · Session | NetBIOS session service, ONC RPC |
| 6 · Presentation | SSL/TLS, JPEG (with ASCII as the encoding half) |
| 7 · Application | HTTP, SMTP |
The PDU is the fastest way to name the layer. The trap is datagram, which is used at two layers: an IP datagram is the layer 3 packet, a UDP datagram is the layer 4 unit. TCP’s unit is a segment and only a segment. A router forwards packets; a switch forwards frames. Swapping those two costs the mark even when the explanation is right.
Layer 2 has two sublayers, and they get asked for by name. LLC (IEEE 802.2) on top records which network-layer protocol the frame carries. MAC below owns the 48-bit addressing and decides who may transmit — CSMA/CD on classic Ethernet, CSMA/CA on 802.11. In practice Ethernet II carries a 2-byte EtherType instead of an LLC header, so LLC is often not on the wire at all.
Only three header sizes are worth memorising. Section 02 already showed all three: Ethernet II is 14 bytes plus a 4-byte FCS, IPv4 is 20 without options, TCP is 20 without options. UDP is 8, and that is the entire header.
Layers 5 and 6 look thin because in practice they are. Neither has a header of its own on a normal internet connection. The jobs did not disappear — a browser keeps session state in a cookie, and TLS does the presentation job while running on top of TCP. That is exactly why TCP/IP folds them away.
TCP/IP came out of running code, and nobody built separate protocols for 5 and 6. Say the jobs moved into the application layer; never say they stopped mattering.
05 Cheat sheet
The nine they ask, and the trap inside each
Every row is something to glance at on the morning of an interview. The right-hand column is the version that loses the mark, and it is usually a small slip rather than a wrong idea.
| What they ask | The answer | The trap |
|---|---|---|
| The seven layers in order | 1 physical, 2 data link, 3 network, 4 transport, 5 session, 6 presentation, 7 application | numbering from the top |
| The PDU at each layer | bit, frame, packet, segment; only data at 5, 6 and 7 | a layer 3 unit called a segment |
| What makes a layer a layer | uses only the service below, offers only its own service above | Answering with what the layer does instead of the two rules. |
| Which layer has ports | transport; 16-bit, 0 to 65535 | saying network |
| Which layer has MAC addresses | data link, its MAC sublayer; 48 bits | Saying physical, because the address is burned into hardware. |
| The two data link sublayers | LLC (IEEE 802.2) above, MAC below | Naming one, or putting LLC below MAC. |
| The fixed header sizes | Ethernet II 14 + 4 FCS, IPv4 20, TCP 20, UDP 8 | quoting 20 without “no options” |
| What TCP/IP leaves out | session and presentation; their work sits in the application layer | Saying those jobs do not exist. |
| The mnemonics | Please Do Not Throw Sausage Pizza Away (1–7); All People Seem To Need Data Processing (7–1) | Reciting without naming the direction. |
06 Where & why
Where the seven numbers are a thing you type
The model describes no shipped stack, and yet its numbers turn up in product names and configuration syntax across the industry. Every one of them is really a statement about how far into the packet something is allowed to read.
Same frame, five devices, five stopping points. Every layer number you will ever type into a config is a choice about where to stop.
Capture the request from section 02 and the middle pane lists Frame, Ethernet II, IPv4, TCP, HTTP — layers 2, 3, 4 and 7, in the order they were wrapped. Layers with no header of their own get no block, which is the clearest evidence you will see that 5 and 6 are jobs rather than wrappers.
A standard access list matches only the source IP, because layer 3 is as deep as it may look. An extended list matches protocol, both addresses and both ports, because it opens the transport header too. Same device, same traffic; only the reading depth differs.
A Network Load Balancer works at layer 4: it forwards TCP on address and port and never opens the payload, which is why it carries any protocol at all. An Application Load Balancer works at layer 7 and parses HTTP, so it makes decisions the layer 4 one physically cannot.
ip link is layer 2: interfaces and MAC addresses. ip addr and ip route are layer 3. ss -tulpn is layer 4: which ports are open and which process owns each. No command spans two layers, because no layer keeps another’s state.
07 Interview questions
What they actually ask
OSI is almost always the opening question of a networking round: it takes ten seconds to ask and instantly separates a memorised list from an understood one. Expect to be pushed one level past the list every time.
What is the OSI model, and why seven layers instead of one design?
Name the seven layers in order, and tell me which one is layer 1.
What actually makes something a layer, rather than just a module?
What is a PDU, and what is it called at each layer?
What does the transport layer give you that the network layer does not?
The session layer and the transport layer both talk about connections. What separates them?
The data link layer has two sublayers. Name them and say what each owns.
What is encapsulation? Walk me down the stack.
Why does the TCP/IP model have no session or presentation layer?
Nobody implements OSI. So why am I being asked about it?
08 Practice problems
Six to reason through, not recall
Write down the two rules before anything else, and name the PDU you are holding before you name a layer. Reaching for a layer number first is how a correct fact gets attached to the wrong layer.