OSI and TCP/IP models, protocols, TCP vs UDP and packets: WACE Computer Science Unit 3
“Describe the OSI and TCP/IP models and the role of common protocols at each layer, compare TCP and UDP, and explain packet structure, encapsulation and how packets move between networks”
The OSI model has seven layers and the TCP/IP model four; protocols such as HTTP, TCP, IP and Ethernet each work at a particular layer. TCP gives reliable, ordered, connection-based delivery; UDP is faster and connectionless. Data is encapsulated with headers as it moves down the stack, routed across networks, and decapsulated at the destination.
Jump to a section
What this dot point is asking
Unit 3 includes network communications. You need to describe the layered models used to explain networking, know where key protocols operate, compare TCP and UDP, and explain how data is packaged and moved across networks.
The answer
The OSI and TCP/IP models
| OSI layer | TCP/IP layer | Role | Examples |
|---|---|---|---|
| 7 Application | Application | Services for applications | HTTP/HTTPS, DNS, SMTP, FTP |
| 6 Presentation | Application | Data format, encryption, compression | TLS, JPEG |
| 5 Session | Application | Managing sessions | Session setup and teardown |
| 4 Transport | Transport | End-to-end delivery, ports | TCP, UDP |
| 3 Network | Internet | Logical addressing, routing | IP, ICMP |
| 2 Data link | Network access | Physical addressing, frames, error detection | Ethernet, Wi-Fi (802.11), MAC addresses |
| 1 Physical | Network access | Bits on the medium | Cables, radio signals |
Layered models let different technologies work together: each layer only needs to understand the layers next to it.
TCP and UDP
- TCP: connection-oriented (three-way handshake: SYN, SYN-ACK, ACK), reliable, ordered, acknowledgements and retransmission, flow control. Used for web pages, email, file transfer.
- UDP: connectionless, no acknowledgements, low overhead and delay. Used for streaming, voice and video calls, online games, DNS queries.
Packets and encapsulation
A packet has a header (addresses, sequence numbers, protocol information, time to live), a payload (the data) and often a trailer (error checking, at the frame level). As data moves down the stack each layer encapsulates it by adding its header; at the destination each layer removes its header (decapsulation).
Routers forward packets between networks using destination IP addresses; switches forward frames within a network using MAC addresses.
Sending an email with a large attachment:
- The email client uses SMTP (application layer).
- TCP breaks the message into numbered segments and ensures they all arrive (transport).
- IP addresses each packet to the mail server (internet).
- Frames carry the packets over Wi-Fi and Ethernet links (network access).
- If a packet is lost, TCP retransmits it, so the attachment arrives intact.
- Mixing up OSI and TCP/IP layer names
- Know both and how they map.
- Saying UDP is "unreliable" as if it is bad
- It is a deliberate trade-off for speed.
- Confusing MAC and IP addresses
- MAC is physical (layer 2); IP is logical (layer 3).
Practice questions
Original practice questions graded from foundation to exam level, each with a full worked solution. Try them before revealing the solution.
foundation4 marksMatch each protocol to its TCP/IP layer: HTTPS, TCP, IP, Ethernet.Show worked solution →
- HTTPS: application layer.
- TCP: transport layer.
- IP: internet layer.
- Ethernet: network access (link) layer.
Marking guide: 1 mark each.
core4 marksCompare TCP and UDP and recommend one for (a) downloading a software update and (b) an online multiplayer game's position updates.Show worked solution →
TCP establishes a connection, numbers segments, acknowledges receipt and retransmits lost data, so delivery is reliable and in order but slower. UDP sends datagrams without a connection or acknowledgements, so it is faster with less overhead but packets may be lost or arrive out of order.
(a) TCP, because every byte of the update must arrive correctly.
(b) UDP, because new position updates quickly replace old ones; waiting to resend a lost update would cause lag.
Marking guide: 2 marks for the comparison, 1 mark for each justified recommendation.
exam6 marksDescribe what happens to a web request as it moves from a browser down the TCP/IP stack on a laptop, across the network, and up the stack on a web server.Show worked solution →
- Application: the browser creates an HTTP request (inside TLS for HTTPS).
- Transport: TCP splits it into segments and adds headers with source and destination ports (for example port 443) and sequence numbers.
- Internet: IP adds a header with source and destination IP addresses, creating packets.
- Network access: Ethernet or Wi-Fi adds a frame header with MAC addresses and a trailer with an error check, then transmits bits.
- Across the network: routers read IP headers to forward packets hop by hop towards the server's network; frames are rebuilt on each link.
- At the server: each layer removes its header (decapsulation): the frame is checked, the IP packet is delivered, TCP reassembles segments in order and acknowledges them, and the web server application receives the HTTP request.
Marking guide: 1 mark per correctly described stage (up to 6).
core4 marksExplain two advantages of describing networks with a layered model such as the OSI model. Then distinguish between a MAC address and an IP address, naming the OSI layer at which each is used.Show worked solution →
Advantages of layering (any two):
- Each layer only needs to understand the layers next to it, so different technologies (for example Wi-Fi and Ethernet) can work together with the same higher-layer protocols.
- A layer can be changed or improved (for example a faster physical medium) without redesigning the other layers.
- It gives a common framework for designing protocols and for troubleshooting a problem one layer at a time.
MAC versus IP. A MAC address is a physical address of a network interface, used at layer 2 (data link) to deliver frames within a local network; switches forward frames using it. An IP address is a logical address used at layer 3 (network) to identify a host across networks; routers use it to forward packets between networks.
Marking guide: 1 mark per advantage (2); 1 mark for MAC address with layer 2; 1 mark for IP address with layer 3.
exam5 marksA student uploads a large assignment file to a school portal using TCP. Describe how TCP sets up the connection, and explain how TCP makes sure the whole file arrives correctly and in order even if one segment is lost on the way.Show worked solution →
Connection set-up (three-way handshake). The student's computer sends a SYN to the server; the server replies with a SYN-ACK; the computer replies with an ACK. The connection is now established and both sides have agreed starting sequence numbers.
Reliable, ordered delivery.
- TCP splits the file into segments, each with a sequence number in its header.
- The receiver sends acknowledgements for data it receives.
- If a segment is lost, no acknowledgement for it arrives, so the sender retransmits it.
- The receiver uses the sequence numbers to reorder segments that arrive out of order and reassemble the file exactly, before passing it to the application.
- Flow control stops the sender overwhelming the receiver.
Marking guide: 1 mark for the SYN, SYN-ACK, ACK sequence; 1 mark for sequence numbers; 1 mark for acknowledgements; 1 mark for retransmission of the lost segment; 1 mark for reordering and reassembly.
exam15 marksA high school streams its weekly assembly live to families' devices and runs a portal where students download notes and submit work. (a) Show how the seven layers of the OSI model map onto the four layers of the TCP/IP model. (4 marks) (b) Recommend a transport protocol for the live assembly stream and for downloading notes from the portal, justifying each choice. (4 marks) (c) Describe the three parts of a packet or frame and give two items of information found in a header. (3 marks) (d) A request from a classroom computer travels to the portal server, which is hosted off site. Explain the roles of the classroom switch and of the routers along the path. (4 marks)Show worked solution →
(a)
| OSI layers | TCP/IP layer |
|---|---|
| 7 Application, 6 Presentation, 5 Session | Application |
| 4 Transport | Transport |
| 3 Network | Internet |
| 2 Data link, 1 Physical | Network access (link) |
(b)
- Live stream: UDP. It is connectionless with low overhead and delay. A lost packet causes at most a brief glitch, whereas waiting to retransmit it (as TCP would) would make the live video pause and fall behind.
- Downloading notes: TCP. Every byte of the file must arrive correctly and in order, so TCP's acknowledgements, retransmission and ordering are worth the small extra delay.
(c) A header carries control information; the payload is the data being carried; a trailer (at the frame level) holds error-checking information. Header items (any two): source and destination IP addresses, source and destination port numbers, sequence numbers, protocol information, time to live.
(d) The switch receives the frame from the classroom computer and forwards it, using MAC addresses, to the port leading to the school's router (the default gateway), keeping local traffic within the network. Each router reads the destination IP address in the packet header and forwards the packet towards the portal server's network, hop by hop. At each link the packet is carried in a new frame with that link's MAC addresses, while the IP source and destination addresses stay the same (except that the school's edge router uses NAT to replace the computer's private source address with the school's public address). The server's router delivers it to the server, where the layers decapsulate it.
Marking guide: (a) 1 mark for the application mapping, 1 each for transport, internet and network access rows; (b) 1 mark per correct protocol, 1 mark per justification; (c) 1 mark for header, payload and trailer, 1 mark per header item (2); (d) 1 mark for the switch using MAC addresses, 1 mark for routers using destination IP addresses, 1 mark for hop-by-hop forwarding, 1 mark for new frames on each link with IP addresses unchanged. Total 15.
exam17 marksA customer uses a small online shop's app to place an order. The app looks up the shop's domain name, sends the order securely over HTTPS, and the shop's server then emails an order confirmation. (a) Identify four protocols involved in this process, stating the TCP/IP layer of each and its role. (4 marks) (b) DNS lookups usually use UDP. Explain why UDP suits this task. (2 marks) (c) Explain how the order request is encapsulated as it moves down the TCP/IP stack on the customer's phone. (4 marks) (d) The packets pass through several routers. Explain which header information stays the same across the journey and which is replaced at each hop, and why. (4 marks) (e) TLS is placed in the presentation layer of the OSI model but in the application layer of the TCP/IP model. Explain why the models differ in this way. (3 marks)Show worked solution →
(a) Any four, with layer and role:
- DNS (application): resolves the shop's domain name to an IP address.
- HTTPS (application): carries the order request, protected by TLS.
- SMTP (application): sends the confirmation email.
- TCP (transport): reliable, ordered delivery of the order and email, using ports.
- UDP (transport): carries the DNS query.
- IP (internet): logical addressing and routing of packets.
- Ethernet or Wi-Fi (network access): frames and physical addresses on each link.
(b) A DNS query and its reply are small, often fitting in a single datagram. UDP is connectionless, so there is no handshake and very little overhead, making the lookup fast. If a query is lost, the resolver can simply send it again.
(c)
- Application: the app creates the HTTP request containing the order, encrypted with TLS.
- Transport: TCP adds a header with source and destination ports (443 for HTTPS) and sequence numbers, forming segments.
- Internet: IP adds a header with the phone's and server's IP addresses (and time to live), forming packets.
- Network access: Wi-Fi adds a frame header with physical addresses and a trailer for error checking, then transmits bits.
(d) The IP header's source and destination addresses stay the same, because they identify the phone and the server end to end and routers use the destination to choose the next hop (the exception is a NAT router, such as a home router, which replaces a private source address with its public address). The frame header and trailer are replaced at each hop, because physical (MAC) addresses only have meaning on one link; each router removes the old frame and builds a new one for the next link. The time to live field is reduced at each router so a packet caught in a loop is eventually discarded.
(e) The OSI model is a more detailed reference model that separates presentation (data format, encryption, compression) and session (managing sessions) from the application layer. The TCP/IP model was built around the internet protocols actually used and combines OSI layers 5, 6 and 7 into one application layer. So TLS, which encrypts data, fits OSI's presentation layer but simply sits in TCP/IP's application layer.
Marking guide: (a) 1 mark per protocol with correct layer and role (4); (b) 1 mark for small messages and no handshake, 1 mark for low overhead or easy resending; (c) 1 mark per layer correctly described (4); (d) 1 mark for IP addresses unchanged, 1 mark for why, 1 mark for frames rebuilt per hop with reason, 1 mark for time to live; (e) 1 mark for OSI separating presentation and session, 1 mark for TCP/IP combining layers 5 to 7, 1 mark for applying this to TLS. Total 17.