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?"