OSI and TCP/IP reference models
Clear, exam-focused notes on the OSI seven-layer model and the TCP/IP reference model: definitions, layer functions, mapping, encapsulation, formulas, worked examples and exam pointers.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Networking engineers use the OSI and TCP/IP reference models as blueprints to design, debug and document networks. These models separate functions into layers so engineers can implement, test and replace parts (protocols, hardware, software) without reworking the whole system.
Key ideas
Start from first principles: when two processes on different machines communicate, the data must be prepared, sent across a medium, delivered to the right host, and finally delivered to the right process. Layering divides these tasks into simpler groups.
Layering (definition): a design method that groups related communication functions in separate levels called layers, where each layer provides services to the layer above and uses services from the layer below.
Protocol (definition): a set of rules defining format, order of messages and actions taken when messages are sent and received.
Service (definition): the behaviour a layer provides to the layer above, described in terms of primitives (e.g., request, indication, response, confirm) without exposing how it is implemented.
Encapsulation (definition): the process of adding control information (headers and sometimes trailers) at each layer when sending data; the reverse process at the receiver is decapsulation.
OSI model: Exactly seven layers. State and define each (write these in your answer and draw them as seven stacked boxes, top = Application):
- Application layer — provides network services to end-user applications (e.g., file transfer, email). Does not mean the program itself but its network interface.
- Presentation layer — translates, encrypts/decrypts and formats data (e.g., character encoding, compression, encryption).
- Session layer — establishes, manages and terminates sessions or dialogues between applications (e.g., full-duplex, half-duplex control, sync points).
- Transport layer — provides end-to-end communication services (e.g., reliability, flow control, segmentation). PDUs at this layer are often called segments (TCP) or datagrams (UDP).
- Network layer — routes packets across possibly multiple networks; handles logical addressing and forwarding. PDU: packet.
- Data Link layer — organizes bits into frames, provides physical addressing (MAC), error detection and possibly correction; two sublayers often named Logical Link Control (LLC) and Media Access Control (MAC).
- Physical layer — transmits raw bit stream across the physical medium: voltage levels, timing, connectors, cable specifications.
For exams: draw a vertical stack of 7 boxes labelled and beside each write 1–2 short responsibilities. Also remember the standard OSI layer numbering: Layer 1 = Physical, 2 = Data Link, 3 = Network, 4 = Transport, 5 = Session, 6 = Presentation, 7 = Application.
TCP/IP model: Four (or sometimes five) layers with common names and responsibilities (draw 4 boxes top-down):
- Application layer — merges OSI Application, Presentation and Session responsibilities. Contains protocols like HTTP, SMTP, FTP, DNS.
- Transport layer — end-to-end transport (TCP, UDP).
- Internet layer — logical addressing and routing (IPv4, IPv6, ICMP; ARP operates at the boundary with the Link layer and is commonly grouped with Link/Network Access).
- Link layer (Network Access) — combines OSI Data Link and Physical: frames and physical transmission (Ethernet, Wi-Fi).
Mapping between models: explain how OSI 7 maps to TCP/IP 4 (Application->Application, Presentation+Session->Application, Transport->Transport, Network->Internet, Data Link+Physical->Link). In exam answers provide a small table or diagram: left column OSI, right column TCP/IP, draw arrows.
PDU names and examples: at Application layer: message; Transport: segment (TCP) or datagram (UDP); Network: packet; Data link: frame; Physical: bits.
Responsibilities and design decisions: state assumptions that each layer trusts the layer below and hides implementation. Note that real stacks violate strict layering for performance; layering is a conceptual tool.
Where each model is used: OSI is pedagogic and useful to discuss functions; TCP/IP is the practical, deployed suite used on the Internet.
Describe a diagram to draw for encapsulation: Draw a left column showing sender layers top->bottom, right column receiver bottom->top. Between sender layers show data with headers added: e.g., [Application data] -> Transport header + [Application data] = segment -> Network header + segment = packet -> Link header+trailer + packet = frame -> transmitted bits. Label each header (name and typical fields: source/destination ports at transport, source/destination IP at network, source/destination MAC at link, trailer: FCS at link).
Formulas
Overhead_bytes = total_transmitted_bytes - application_data_bytes
- Overhead_bytes: header+trailer bytes added by lower layers; unit: bytes. Use when computing extra bytes sent for headers.
Overhead_percent = (Overhead_bytes / total_transmitted_bytes) * 100
- Overhead_percent: fraction of total transmission used by control information; unit: %.
Total_transmitted_bytes = application_data_bytes + sum(all_headers_and_trailers) — unless otherwise stated, assume minimum header sizes: IPv4 20 B, IPv6 40 B, TCP 20 B, UDP 8 B, Ethernet II header 14 B, Ethernet FCS 4 B; add 4 B if 802.1Q VLAN is present.
- When summing headers from Transport, Network, Link layers.
MTU_effective = MTU_link - (network_header_bytes + transport_header_bytes) — for TCP this maximum application data per segment is called MSS; a common default on Ethernet for IPv4/TCP is 1460 B (1500 − 20 − 20).
- MTU_effective: maximum application data bytes that can be placed in one packet without fragmentation; unit: bytes; applies when calculating fragmentation at IP layer given link MTU.
If you compute transmission time given bandwidth B and total bytes S:
Transmission_time = (S * 8) / B (serialization time only; does not include propagation, processing or queuing delays).
- S: total bytes; B: bandwidth in bits per second; Transmission_time: seconds.
Worked examples
Encapsulation overhead calculation (numerical): Problem: An application wants to send 1200 bytes of data. Headers: TCP 20 B, IPv4 20 B, Ethernet II header 14 B and FCS trailer 4 B. Compute total bytes transmitted, overhead percent, and whether fragmentation occurs if Ethernet MTU is 1500 bytes. Steps:
application = 1200 Btransport_header = 20 B(TCP without options)network_header = 20 B(IPv4 without options)link_header = 14 B,link_trailer = 4 Btotal = 1200 + 20 + 20 + 14 + 4 = 1258 B(show sum)overhead = 1258 - 1200 = 58 Boverhead_percent = (58 / 1258) * 100 = 4.61%→ 4.61%- Check MTU: Ethernet MTU (payload) is 1500 B, our network packet (IPv4 packet size = transport header + application + network header = 20 + 1200 + 20 = 1240 B) < 1500, so no fragmentation. Final answers: total 1258 B transmitted, overhead 58 B (4.61%), no fragmentation.
Encapsulation and PDU names (theory trace): Problem: Trace an HTTP GET from process A on Host X to a web server on Host Y over IP/Ethernet. Show PDU names and one key field added at each layer. Steps:
- Application: HTTP message "GET /index.html" — PDU: message; no headers added by HTTP for this exercise.
- Transport: TCP adds source port and destination port (PDU: segment).
- Network: IP adds source IP and destination IP (PDU: packet).
- Link: Ethernet adds source MAC, destination MAC, and FCS trailer (PDU: frame).
- Physical: bits are signalled on medium. On receive, layers remove headers in reverse order and deliver the HTTP request to the server application.
Model answer (exam long question): "Compare OSI and TCP/IP models" (short model answer):
- State both models and layer counts; describe main differences: OSI has 7 conceptual layers and clean separation of presentation/session; TCP/IP has 4 practical layers combining these. OSI is a reference for teaching; TCP/IP is the implemented suite. Mention mapping and PDUs. Explain that OSI strictly separates services, interfaces and protocols as definitions, while TCP/IP grew from protocols and then was fitted into layers. Conclude: both useful; for exams give a small mapping diagram and list three functional differences.
Common mistakes
- Mixing up PDU names (e.g., calling a frame a packet) — write the layer name beside the PDU in your answer.
- Forgetting Transport header size assumptions (always state "without options" if using 20 B for TCP).
- Saying Ethernet header includes FCS as part of header — clarify FCS is a trailer.
- Not showing units or failing to carry units through calculations for bytes vs bits.
For your exam
Types of questions:
- Definitions and short notes: define layering, encapsulation, PDU names, list OSI layers and functions.
- Compare and contrast: OSI vs TCP/IP with mapping diagram.
- Diagram questions: draw the OSI stack and draw encapsulation/decapsulation flow with headers/trailers labelled.
- Numerical: calculate overhead, check fragmentation using MTU, compute transmission time using bandwidth.
- Theory/model answer: explain why layering is useful and give practical limitations.
What full-marks answers must include:
- Clear definitions for each bold term asked.
- Diagrams where required, labelled precisely (draw boxes for layers, arrows for flow, and show which header/trailer is added at each step).
- For calculations: show formulas used, substitute numbers with units, give final answer with correct unit and a short interpretation.
- When comparing models: include layer mapping, main functional differences, and an example protocol placed in correct layer.
Quick check
- How many layers are in the OSI model and what is the name of the third layer from the bottom?
- At which layer does IP operate and what is the PDU name at that layer?
- If an application sends 2000 B and headers are TCP 20 B, IP 20 B and Link 18 B total, what is total transmitted bytes and overhead percent (to two decimals)?
Answers: 1) Seven layers; third from bottom = Network layer. 2) IP operates at the Network (Internet) layer; PDU name = packet (or datagram). 3) total = 2000+20+20+18 = 2058 B; overhead = (58/2058)*100 = 2.82% (approx).
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?