OSI model interview questions, with answers
The OSI model is the vocabulary of networking interviews: nearly every question about a protocol or a device starts with which layer it belongs to. Interviewers expect you to name the layers in order and, more importantly, to say what each one does and which real protocols and devices live there.
The answers below cover the seven layers, how OSI relates to the TCP/IP model, devices by layer, the transport layer's job, port numbers and the presentation layer. Then take the free Computer Networks diagnostic — ten questions across every networking topic in the bank — to see which of these you can explain but not yet apply.
The questions, with answers
1.What are the seven layers of the OSI model?
In short: Physical, data link, network, transport, session, presentation and application, from the wire up to the program.
From the bottom: the physical layer transmits raw bits over a medium such as copper, fibre or radio. The data link layer moves frames between directly connected nodes, with MAC addressing and error detection. The network layer delivers packets across networks, choosing routes. The transport layer delivers data between processes end to end, with ports and, for TCP, reliability. The session layer manages dialogues between applications, the presentation layer handles data formats, encoding, encryption and compression, and the application layer provides network services to programs, such as HTTP, SMTP and DNS.
2.What is the difference between the OSI model and the TCP/IP model?
In short: OSI is a seven-layer reference model; TCP/IP is the four-layer model the internet's protocols were actually built around.
The OSI model was designed by ISO as a general reference with seven cleanly separated layers, before protocols were written for it, and its own protocol suite never caught on. The TCP/IP model grew out of the protocols that run the internet and has four layers: application, transport, internet and link. OSI remains the standard vocabulary, so people say layer 2 switch or layer 7 load balancer, while TCP/IP describes what is actually deployed. Real protocols do not always fit the OSI layers neatly; TLS, for example, sits between transport and application.
3.Which network devices work at which OSI layer?
In short: Hubs and repeaters at layer 1, switches and bridges at layer 2, routers at layer 3, and gateways and proxies up to layer 7.
A repeater or hub works at the physical layer: it regenerates and repeats signals without understanding them. A bridge or switch works at the data link layer, forwarding frames by MAC address. A router works at the network layer, forwarding packets between networks by IP address. Layer 3 switches combine switching and routing. Devices that inspect ports, such as some firewalls and layer 4 load balancers, work at the transport layer, and application gateways, proxies and layer 7 load balancers understand application protocols such as HTTP. A device's layer tells you which header it reads.
4.What does the transport layer do?
In short: It delivers data between processes on two hosts, using port numbers, and with TCP adds reliability, ordering, flow and congestion control.
The network layer gets packets to the right host; the transport layer gets data to the right process on that host, using port numbers to multiplex many conversations over one IP address. TCP adds a reliable, ordered byte stream with connection setup, acknowledgements, retransmission, flow control and congestion control. UDP adds only ports and a checksum, leaving everything else to the application. The transport layer is also where segmentation happens: large application data is split into segments sized for the network, and reassembled at the other end.
5.What is a port number, and what are well-known ports?
In short: A 16-bit number identifying a process or service on a host; ports 0 to 1023 are reserved for standard services.
An IP address identifies a host, and a port number, from 0 to 65535, identifies a particular service or connection on it, so one host can run a web server, a mail server and many client connections at once. Ports 0 to 1023 are well-known ports assigned to standard services, such as 22 for SSH, 25 for SMTP, 80 for HTTP and 443 for HTTPS, and binding to them usually needs administrator rights. Registered ports run up to 49151, and the rest are ephemeral ports that the operating system assigns to the client side of connections.
6.What does the presentation layer do?
In short: It translates data between the application's format and the network's: character encoding, serialisation, encryption and compression.
The presentation layer makes sure data sent by one system can be understood by another: it handles character encodings such as ASCII and UTF-8, serialisation formats and data representation such as byte order, compression, and encryption and decryption. In OSI terms it is the layer that turns application data structures into a standard transfer syntax. In practice, these jobs are done by applications and libraries, for example JSON serialisation in an API client, gzip compression in HTTP, and TLS encryption.
How the diagnostic asks it
One question from the Computer Networks bank, exactly as a sitting would show it. The bank has 4 on osi & tcp/ip models and 30 across Computer Networks.
What is the protocol data unit of TCP at the transport layer called?
- 1A frame
- 2A packet
- 3A bit stream
- 4A segmentcorrect
Each layer wraps the data it receives in its own header and names the result differently. TCP's unit is a segment (UDP's is usually called a datagram). The network layer's unit, an IP header plus a segment, is a packet. The data link layer's unit, with a header and a trailer such as Ethernet's, is a frame, and the physical layer sends bits. Using the right name signals which layer, and so which header and which device, you mean.
Measure it
Reading answers tells you what’s true. A diagnostic tells you what you get wrong.
10 Computer Networks questions across its topics, easy to hard, about fifteen minutes. You get a readiness figure with the arithmetic shown, the topics you missed named, and a practice set sized for today. Free: 1 diagnostic a month and 15 problems a day. No card.