Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Notes › Computer Networks

OSI and TCP/IP Models

Networking is split into layers. Each layer does one job and only talks to the layers directly above and below it. This makes the system modular: Wi-Fi can be replaced by Ethernet without changing HTTP.

The OSI model (7 layers)

# Layer Job Protocols / examples Data unit Devices
7 Application services for user apps HTTP, HTTPS, FTP, SMTP, DNS, SSH data —
6 Presentation format, encryption, compression TLS/SSL, JPEG, UTF-8, gzip data —
5 Session open, manage and close sessions; checkpoints RPC, NetBIOS, session tokens data —
4 Transport process-to-process delivery, ports, reliability, flow control TCP, UDP segment (TCP) / datagram (UDP) firewall (L4), load balancer (L4)
3 Network logical (IP) addressing and routing across networks IP, ICMP, ARP*, OSPF, BGP packet router, L3 switch
2 Data Link node-to-node delivery on one link, MAC addresses, error detection Ethernet, Wi-Fi (802.11), PPP frame switch, bridge, NIC
1 Physical raw bits over the medium cables, fibre, radio, voltages bits hub, repeater, cables

*ARP sits between layers 2 and 3 (it maps IP → MAC).

Mnemonics

The TCP/IP model (what the internet actually uses)

TCP/IP layer OSI layers it covers Protocols
Application 7, 6, 5 HTTP, DNS, SMTP, FTP, TLS
Transport 4 TCP, UDP
Internet 3 IP, ICMP
Network Access (Link) 2, 1 Ethernet, Wi-Fi

(Some books split the last one into Data Link + Physical → a 5-layer model.)

OSI vs TCP/IP

OSI TCP/IP
Layers 7 4 (or 5)
Nature reference/teaching model practical model used on the internet
Developed protocols-independent, model first protocols first, model described later
Session & presentation separate layers folded into Application

Encapsulation — what happens when you send data

Each layer adds its own header (Data Link also adds a trailer) as data moves down on the sender; the receiver strips them going up.

Application   [ HTTP data ]
Transport     [ TCP hdr | HTTP data ]                       ← segment (ports 52314 → 443)
Network       [ IP hdr | TCP hdr | data ]                   ← packet (IPs)
Data Link     [ Eth hdr | IP hdr | TCP hdr | data | FCS ]   ← frame (MACs, checksum)
Physical      0101011010…                                   ← bits

Devices and layers

Device Layer Works with
Hub / repeater 1 bits — sends to every port
Switch 2 MAC addresses — sends only to the right port
Router 3 IP addresses — connects different networks
Gateway / proxy / L7 load balancer 7 full application data

See Network Devices and Common Ports.

Which layer is the problem? (troubleshooting)

Interview one-liners

More Computer Networks notes