Reliable data transfer mechanisms in Computer Networks - Time & Space Complexity
When sending data over a network, reliable transfer ensures all pieces arrive correctly. Analyzing time complexity helps us see how the process scales as data size grows.
We want to know how the number of steps changes when more data is sent.
Analyze the time complexity of the following reliable data transfer process.
for each packet in data:
send(packet)
wait for acknowledgment
if acknowledgment lost or error:
resend(packet)
This code sends each packet and waits for confirmation before moving on, resending if needed.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Sending each packet and waiting for its acknowledgment.
- How many times: Once per packet, with possible repeats if errors occur.
As the number of packets increases, the total steps grow roughly in proportion to the number of packets sent and acknowledged.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | About 10 sends plus acknowledgments |
| 100 | About 100 sends plus acknowledgments |
| 1000 | About 1000 sends plus acknowledgments |
Pattern observation: The work grows steadily as more packets are sent, roughly one step per packet.
Time Complexity: O(n)
This means the time to complete reliable transfer grows linearly with the number of packets.
[X] Wrong: "Resending packets does not affect overall time much because errors are rare."
[OK] Correct: Even a few resends add extra steps, increasing total time. If errors happen often, time can grow more than expected.
Understanding how reliable transfer scales helps you explain network behavior clearly. This skill shows you can think about real-world systems and their efficiency.
"What if we send multiple packets before waiting for acknowledgments? How would the time complexity change?"
Practice
Solution
Step 1: Understand the goal of reliable data transfer
Reliable data transfer aims to make sure data sent from one point reaches the other point correctly and fully.Step 2: Compare options with this goal
Only To ensure data arrives complete and without errors matches this goal by focusing on completeness and error-free delivery.Final Answer:
To ensure data arrives complete and without errors -> Option BQuick Check:
Reliable data transfer = complete, error-free data [OK]
- Confusing reliability with speed
- Thinking encryption is part of reliability
- Assuming data size reduction is reliability
Solution
Step 1: Recall Stop-and-Wait protocol behavior
In Stop-and-Wait, the sender sends one packet and waits for an acknowledgment before sending the next.Step 2: Match this behavior to options
Sender waits for acknowledgment before sending next packet correctly describes this waiting for acknowledgment step.Final Answer:
Sender waits for acknowledgment before sending next packet -> Option AQuick Check:
Stop-and-Wait = wait for ACK before next send [OK]
- Thinking sender sends all packets at once
- Confusing receiver's role with sender's
- Assuming packets are sent randomly
Solution
Step 1: Understand Sliding Window with size 3
The sender can have up to 3 unacknowledged packets sent at once.Step 2: Analyze acknowledgment for packet 1
Receiving ACK for packet 1 means the window slides forward by one, freeing space to send one more packet. Since packets 2 and 3 are still unacknowledged, the sender can send packets 4 and 5 to fill the window.Final Answer:
Packets 4 and 5 -> Option AQuick Check:
Sliding window size 3 allows 3 unacknowledged packets; after ACK 1, packets 2 and 3 remain unacknowledged, so 2 new packets (4 and 5) can be sent [OK]
- Sending two packets after one ACK
- Resending already acknowledged packets
- Sending packets beyond window size
Solution
Step 1: Understand Stop-and-Wait behavior on lost ACKs
If acknowledgments are lost or delayed, the sender waits or resends the same packet repeatedly.Step 2: Evaluate options for no ACK received
The acknowledgment packets are lost or delayed correctly identifies lost or delayed ACKs as the cause; other options do not fit Stop-and-Wait protocol behavior.Final Answer:
The acknowledgment packets are lost or delayed -> Option CQuick Check:
No ACK = lost/delayed ACK packets [OK]
- Blaming sender speed in Stop-and-Wait
- Confusing window size with Stop-and-Wait
- Assuming receiver sends wrong ACKs
Solution
Step 1: Understand duplicate ACKs in Sliding Window
Duplicate ACKs usually indicate a lost packet after the acknowledged one.Step 2: Identify sender's response to duplicate ACKs
The sender should resend the next expected packet (packet 4) immediately to recover lost data.Step 3: Evaluate other options
Ignoring duplicates risks data loss; increasing window size or stopping sending are not correct immediate responses.Final Answer:
Resend packet 4 immediately to recover from possible loss -> Option DQuick Check:
Duplicate ACKs = resend missing packet [OK]
- Ignoring duplicate acknowledgments
- Changing window size unnecessarily
- Waiting for timeout instead of fast resend
Ready to prove it?
Pass the test and this pattern moves unknown
