Network communication is complex. Reference models divide it into layers, each with a clear job, so that it can be designed and understood step by step.
Why Layers?
Layering breaks the task of communication into smaller parts. Each layer provides services to the layer above and uses the services of the layer below. A layer on one machine talks to the peer layer on another machine using a protocol. Layering makes networks modular (one layer can change without affecting others), easier to standardise and to troubleshoot, and lets equipment from different vendors interoperate.
Definition: OSI model. The Open Systems Interconnection reference model, developed by the ISO, which divides network communication into seven layers, each with defined functions and services.
The Seven Layers
The OSI model was developed by the International Organization for Standardization (ISO) in 1984. From bottom to top: 1. Physical layer: transmits raw bits over the medium; defines cables, connectors, voltages, signalling and data rates. 2. Data link layer: transfers frames between neighbouring nodes; handles framing, MAC addressing, error detection and flow control. 3. Network layer: moves packets from source to destination across networks; handles logical (IP) addressing and routing. 4. Transport layer: provides end-to-end delivery between processes; handles segmentation, port numbers, reliability, flow control and congestion control (TCP, UDP). 5. Session layer: establishes, manages and ends sessions (dialogues), with synchronisation and checkpoints. 6. Presentation layer: deals with the format of data: translation (character codes), encryption and compression. 7. Application layer: provides network services to user applications, such as web browsing, email and file transfer (HTTP, SMTP, FTP, DNS).
Encapsulation
As data goes down the layers at the sender, each layer adds its own header (and the data link layer adds a trailer): this is encapsulation. The data unit is called a segment at the transport layer, a packet at the network layer, a frame at the data link layer, and bits at the physical layer. At the receiver, each layer removes its header as the data goes up, which is decapsulation. A common way to remember the layers from top to bottom is "All People Seem To Need Data Processing".
Table 1.2: OSI layers
| No. | Layer | Data unit | Example |
|---|---|---|---|
| 7 | Application | Data | HTTP, FTP, DNS |
| 6 | Presentation | Data | TLS, JPEG, ASCII |
| 5 | Session | Data | RPC, session control |
| 4 | Transport | Segment | TCP, UDP |
| 3 | Network | Packet | IP, ICMP |
| 2 | Data link | Frame | Ethernet, Wi-Fi |
| 1 | Physical | Bits | Cables, radio |
Example 1.2: Which layer?
Problem: Name the OSI layer responsible for (a) choosing the path through routers, (b) detecting a corrupted frame, (c) encrypting data, (d) putting bits on a fibre cable, (e) delivering data to the right application with a port number.
Solution:
- Path selection is routing: network layer.
- Frame error detection: data link layer.
- Encryption: presentation layer.
- Bits on the medium: physical layer.
- Ports and process-to-process delivery: transport layer.
Result: (a) 3, (b) 2, (c) 6, (d) 1, (e) 4.
layers = ["Application", "Presentation", "Session", "Transport",
"Network", "Data link", "Physical"]
hdr = {"Transport": "TCP|", "Network": "IP|", "Data link": "ETH|"}
data = "Hello"
for L in layers:
if L in hdr:
data = hdr[L] + data
if L == "Data link":
data += "|FCS"
print(f"{L:<13} {data}")
Output
Application Hello
Presentation Hello
Session Hello
Transport TCP|Hello
Network IP|TCP|Hello
Data link ETH|IP|TCP|Hello|FCS
Physical ETH|IP|TCP|Hello|FCS
Common mistakes
- Mixing up the order of the layers. Remember: Physical, Data link, Network, Transport, Session, Presentation, Application.
- Placing routing in the data link layer. Routing is a network-layer function.
- Thinking that the OSI model is a protocol. It is a reference model.
Key takeaways
- OSI has seven layers, defined by the ISO.
- Each layer serves the one above and uses the one below.
- Data units: bits, frames, packets, segments.
- Headers are added on the way down (encapsulation) and removed on the way up.
Practice questions
- How many layers does the OSI model have?
- Which layer handles routing?
- What is encapsulation?
Answers to the practice questions
- Seven.
- The network layer.
- Adding a header (and trailer) to data at each layer as it moves down the stack.
Sources
- Official BCA syllabus Computer Networks, course code 26BCA404DS02, Unit I
