Selective Repeat Protocol Simulation
Selective Repeat uses a receiver window so out-of-order packets are kept, not thrown away. Only the packet that was truly lost needs to be sent again.
Interactive simulation
- base
- 0
- next_seq
- 0
- rcv_base
- 0
- Timer
- idle
- Speed
- 1x
Sender (window of 4)
Receiver (window of 4 packets (buffers out-of-order))
Legend
- Inside window, ready
- Sent, waiting for ACK
- Retransmitted
- Acknowledged / delivered
- Buffered out of order (receiver)
- Packet in transit (click to select)
- ACK in transit (click to select)
- Selected (press Kill Selected)
- Destroyed in transit
Event log
How to use this simulation
- Press Send. The sender transmits up to 4 packets. Each one is acknowledged individually.
- Click a packet in transit or press Kill Packet. Notice later packets still arrive and turn indigo: they are buffered, not discarded.
- When the timer for the lost packet expires, only that packet is resent. Once it arrives, the receiver delivers the whole buffered run and both windows slide.
- Use Step, Slower, Faster and Reset to explore at your own pace. Try killing an ACK too.
1. Both sides have a window
The sender window works as in Go-Back-N. The receiver also has a window, starting at rcv_base, which is the lowest packet it has not yet delivered. Here both windows hold 4 packets.
2. Packets are acknowledged one by one
When a packet lands inside the receiver window, the receiver acknowledges that specific packet. If the packet is already delivered it is acknowledged again, because the earlier ACK may have been lost.
3. Out-of-order packets are buffered
If packet 2 is missing but 3 and 4 arrive, the receiver stores 3 and 4. They are not delivered to the application until the gap is filled, so data still arrives in order.
4. Each packet has its own timer
On timeout, the sender retransmits just that packet. When it arrives, the receiver delivers it together with everything buffered behind it, and rcv_base jumps forward.
5. The cost of efficiency
Selective Repeat wastes less bandwidth but needs receiver buffer memory, per-packet timers and a sequence number space at least twice the window size, so old and new packets cannot be confused.
Go-Back-N vs Selective Repeat
| Feature | Go-Back-N | Selective Repeat |
|---|---|---|
| Receiver window | 1 packet | Same size as sender window |
| Out-of-order packets | Discarded | Buffered |
| Acknowledgements | Cumulative | Individual |
| On a loss | Resend the whole window | Resend only the lost packet |
| Timers | One | One per packet |
| Receiver complexity | Low | Higher (buffer and reordering) |
Key takeaways
- Receiver window equals sender window, so out-of-order packets are buffered.
- Every packet gets its own ACK and its own timer.
- Only lost or unacknowledged packets are retransmitted.
- Data is still delivered to the application in order.
- It trades extra memory and complexity for better efficiency on lossy links.
Related topics
Go-Back-N
Simpler receiver, bigger retransmissions.
Stop-and-Wait
The simplest ARQ: one packet at a time.
Coming soonSliding Window
The general idea behind flow control.
Coming soonTCP Handshake
How a reliable connection starts.
Coming soonARQ Protocols
Automatic repeat request, compared.
Coming soon