Protocol Data Units at each layer in Computer Networks - Time & Space Complexity
When data travels through a network, it passes through several layers. Each layer adds or removes information in units called Protocol Data Units (PDUs).
We want to understand how the processing time grows as data moves through these layers.
Analyze the time complexity of processing PDUs through network layers.
// Simplified PDU processing through layers
function processData(data) {
let pdu = data;
pdu = applicationLayer(pdu); // Adds headers
pdu = transportLayer(pdu); // Adds headers
pdu = networkLayer(pdu); // Adds headers
pdu = dataLinkLayer(pdu); // Adds headers
return pdu;
}
This code shows data being wrapped with headers at each network layer to form PDUs.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Sequential processing through each network layer.
- How many times: Exactly once per layer, with a fixed number of layers.
The processing steps do not increase with the size of the data but depend on the fixed number of layers.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 bytes | 4 steps (one per layer) |
| 100 bytes | 4 steps (one per layer) |
| 1000 bytes | 4 steps (one per layer) |
Pattern observation: The number of steps stays the same regardless of data size.
Time Complexity: O(1)
This means processing time stays constant because the number of layers is fixed and does not grow with data size.
[X] Wrong: "Processing time grows with the size of the data because each layer adds headers."
[OK] Correct: Each layer processes the data once regardless of size; the number of layers is fixed, so time does not increase with data size.
Understanding fixed steps in layered processing helps you explain how network protocols handle data efficiently. This skill shows you can reason about system design and performance.
"What if the number of network layers increased dynamically with data size? How would the time complexity change?"
Practice
Solution
Step 1: Recall OSI model layers and their PDUs
The OSI model has seven layers. Each layer uses a specific PDU name. The Network layer is the third layer.Step 2: Identify the PDU for the Network layer
The Network layer uses the term 'Packet' for its PDU, which contains logical addressing information.Final Answer:
Packet -> Option CQuick Check:
Network layer PDU = Packet [OK]
- Confusing Frame (Data Link layer) with Packet
- Mixing Segment (Transport layer) with Packet
- Thinking Bit is a PDU name at any layer
Solution
Step 1: Identify the Transport layer in the OSI model
The Transport layer is the fourth layer and is responsible for end-to-end communication.Step 2: Recall the PDU name for the Transport layer
The Transport layer uses 'Segment' as its PDU name, which contains data with transport headers.Final Answer:
Segment -> Option DQuick Check:
Transport layer PDU = Segment [OK]
- Choosing Frame which belongs to Data Link layer
- Selecting Packet which belongs to Network layer
- Confusing Bit with a PDU name
Solution
Step 1: Identify PDUs for each layer in order
Transport layer uses Segment, Network layer uses Packet, Data Link layer uses Frame.Step 2: Arrange PDUs in the order data passes down
Data flows from Transport (Segment) -> Network (Packet) -> Data Link (Frame).Final Answer:
Segment -> Packet -> Frame -> Option BQuick Check:
Transport=Segment, Network=Packet, Data Link=Frame [OK]
- Mixing order of PDUs
- Confusing Packet and Segment
- Including Bit as a PDU in this sequence
Solution
Step 1: Identify the correct PDU for Data Link layer
The Data Link layer uses 'Frame' as its PDU, not 'Packet'.Step 2: Identify which layer uses 'Packet'
The Network layer uses 'Packet' as its PDU.Final Answer:
Packet is the PDU for the Network layer, not Data Link layer. -> Option AQuick Check:
Data Link = Frame, Network = Packet [OK]
- Confusing Packet with Frame
- Mixing up Network and Data Link layers
- Assuming Packet is a general PDU name
Solution
Step 1: Calculate total header size added by layers
Transport header = 20 bytes, Network header = 30 bytes, Data Link header = 14 bytes. Total headers = 20 + 30 + 14 = 64 bytes.Step 2: Add headers to original Application data size
Application data = 1000 bytes. Total Frame size = 1000 + 64 = 1064 bytes.Final Answer:
1064 bytes -> Option AQuick Check:
1000 + 20 + 30 + 14 = 1064 bytes [OK]
- Confusing bytes with bits
- Adding headers incorrectly
- Misreading units as kilobytes
Ready to prove it?
Pass the test and this pattern moves unknown
