Handbooks / Computer Networks / Chapter 1
OSI and TCP/IP Models
7 pages · ~5 min✓ Reviewed
Start here. Next up: IP Addressing and Subnetting.
Layered Model Mental Map
1. What Layering Does
- Networking is split into stacked jobs, one per layer
- Each layer serves the layer above it
- Each layer talks to the same layer on the peer host
2. OSI: 7 Layers, Top to Bottom
- L7 Application
- L6 Presentation
- L5 Session
- L4 Transport
- L3 Network
- L2 Data Link
- L1 Physical
- Mnemonic: All People Seem To Need Data Processing
- Application, Presentation, Session, Transport, Network, Data Link, Physical
3. OSI vs TCP/IP
| OSI layers | TCP/IP layer |
|---|---|
| L5-L7 Session, Presentation, Application | Application |
| L4 Transport | Transport |
| L3 Network | Internet |
| L2 Data Link + L1 Physical | Link (Network Access) |
Which model is which
OSI = reference model for reasoning and troubleshooting. TCP/IP = what is actually implemented.
What Each OSI Layer Does
1. Upper Layers: L7-L5
- L7 Application: network services for apps; HTTP, DNS, SMTP
- L6 Presentation: encoding, encryption, compression; TLS, JPEG, ASCII/UTF-8
- L5 Session: opens, maintains, closes dialogues; checkpointing, RPC sessions
2. L4 Transport
- End-to-end delivery between processes, using ports
| TCP | UDP | |
|---|---|---|
| Reliable | yes | no |
| Ordered | yes | no |
| Flow control | yes | no |
3. Lower Layers: L3-L1
| Layer | Job | Scope |
|---|---|---|
| L3 Network | logical IP addressing, routing | between networks |
| L2 Data Link | MAC addressing, framing, FCS error detection | one link |
| L1 Physical | bits as signals: cable, fibre, radio | the medium |
Scope
L3 crosses networks; L2 stays within one link; L1 only carries bits.
PDUs and Encapsulation
1. PDU Names and Header Fields
| Layer | PDU | Header fields |
|---|---|---|
| L7-L5 | data / message | none to know |
| L4 | segment (TCP), datagram (UDP) | source/destination port |
| L3 | packet | source/destination IP, TTL |
| L2 | frame | source/destination MAC, EtherType |
| L1 | bits | signals only |
2. Encapsulation and De-encapsulation
- DataL7-L5
- + TCP headersegment
- + IP headerpacket
- + Eth header + FCSframe
- Sender encapsulates downward, each layer wraps the payload from above
- Receiver de-encapsulates upward: each layer strips and reads its own header, then hands the payload up
- Only Data Link adds a trailer (FCS); all other layers add headers only
Trailer
Only the frame has a trailer: the FCS at the end. Segments and packets have headers only.
3. Interview Point
- Which layer adds a trailer? Data Link only, the FCS.
- What does a receiver do with a frame? Each layer strips and reads its header, then passes the payload up.
- Segment vs datagram? Segment is TCP, datagram is UDP; both are L4.
- Which fields does L3 read? Source/destination IP and TTL.
Protocols and Addresses by Layer
1. Protocols per Layer
| Layer | Protocols |
|---|---|
| L7 | HTTP/HTTPS, DNS, SMTP, FTP, SSH, DHCP |
| L6 | TLS/SSL (L5-L6, not L7) |
| L4 | TCP reliable; UDP connectionless, low overhead |
| L3 | IP, ICMP (ping, traceroute), IPsec, OSPF, BGP |
| L2 | Ethernet, ARP (IP to MAC, "L2.5"), VLAN 802.1Q, PPP |
- TCP 3-way handshake: client SYN, server SYN-ACK, client ACK, then connected
- SYNclient
- SYN-ACKserver
- ACKclient
2. Addresses
| Layer | Address | Identifies |
|---|---|---|
| L4 | Port | the process |
| L3 | IP | host and network |
| L2 | MAC | NIC on the local link |
- MAC: rewritten at every hop
- IP: stays end to end
- NAT rewrites the IP at the boundary
3. TCP or UDP
- TCP: web, email, file transfer
- UDP: DNS lookups, VoIP, streaming, games
Common slips
TLS sits at L5-L6, not only L7. Ping is ICMP at L3, not TCP.
Devices, Hubs vs Switches vs Routers, Troubleshooting
1. Hub vs Switch vs Router
- Collision domain: devices whose frames can collide
- Broadcast domain: devices receiving an L2 broadcast
- Switch learns source MACs into the CAM table
- Switch forwards only to the destination port
| Hub (L1) | Switch (L2) | Router (L3) | |
|---|---|---|---|
| Forwards | every bit, all other ports | dest MAC | dest IP, routing table |
| Duplex | half | full | full |
| Collision domains | 1 shared | 1 per port | 1 per interface |
| Broadcast domains | 1 | 1 (unless VLANs) | 1 per interface |
| Joins | one segment | one network | different networks |
2. Smarter Boxes
- L3 switch routes between VLANs at hardware speed
- Firewall: stateful at L3/L4, application-aware up to L7
- Load balancer: L4 or L7
3. Troubleshoot Bottom-Up
- 1L1cable, link light
- 2L2ARP/MAC, VLAN
- 3L3ping, routes
- 4L4port, firewall
- 5L7app logs
- Routing is a router's job, not a switch's
pingis ICMP at L3, not a TCP test- TLS is not only L7: often placed at L5-L6
OSI and TCP/IP Cheat Sheet
1. Layer to PDU, address, protocol, device
| Layer | PDU | Address | Protocols | Device |
|---|---|---|---|---|
| L7/6/5 | data | — | HTTP, DNS, SMTP, SSH | firewall, load balancer |
| L4 | segment | port | TCP, UDP | firewall, load balancer |
| L3 | packet | IP | IP, ICMP | router |
| L2 | frame | MAC | Ethernet, ARP | switch, bridge |
| L1 | bits | — | — | hub, repeater |
- TCP/IP: L7-L5 = Application, L4 = Transport, L3 = Internet, L2-L1 = Link
- Firewalls and load balancers work from L4 up to L7
2. Collision and broadcast domains
| Device | Collision domains | Broadcast domains |
|---|---|---|
| Hub | 1 shared | 1 |
| Switch | 1 per port | 1 (unless VLANs) |
| Router | 1 per interface | 1 per interface |
Remember
A switch splits collision domains; only a router splits broadcast domains.
Check yourself
A host sends a packet through one router to a server on another network, with no NAT. Which of MAC, IP and port change?
- Only the MAC addresses change: each L2 header spans one link
- IP and port stay end to end
- TTL also drops by 1, but it was not one of the three
Ping to a server succeeds, but its website times out. Where do you look next?
- Ping is ICMP at L3, so IP and routing work
- Check L4 next: port 443 open, firewall rules
- Then L7: app logs
PC A sends a frame to PC B. Who else sees it on a hub, and on a switch?
- Hub: every other port, since it repeats all bits
- Switch: only B's port once it has learned B's MAC
- Unknown destination MAC: the switch floods it