C SC 481.20 Lecture 7: Principles of Reliable Transport
major resource: Computer Networking (4th Edition),
Kurose and Ross, Addison Wesley, 2008
[ previous
| schedule
| next ]
Simplest protocol for reliable delivery
- Simple protocol: assumes reliable channel and fast receiver (textbook "rdt1.0")
- Sender: when application supplies data, put into packets and send
- Receiver: when packet arrives, pass data up to application layer.
Stop-and-wait protocols for reliable delivery
- This family of protocols drops assumption that receiver infinitely fast.
- Sender must avoid flooding slow receiver. Must implement flow control.
- Several variations follow
Stop-and-wait with reliable channel
- (no textbook equivalent)
- Sender: when application supplies data, send data packet and wait for ACK (acknowledgement) packet to arrive. After ACK arrives, send next packet.
- Receiver: when data packet arrives, send ACK packet to sender. Pass data up to application layer as appropriate.
Stop-and-wait with corrupt channel
- unreliable channel which can corrupt bits (but not lose them) and slow receiver
- textbook rdt2.0, rdt2.1, rdt2.2
- The following protocol (rdt2.0) will work in almost all cases
- Sender: when application supplies data, send data packet and wait for ACK or NAK (negative acknowledgement) packet to arrive. If ACK, send next packet. If NAK, resend same packet.
- Receiver: when data packet arrives, check for error. If none, send ACK packet to sender else send NAK packet. Pass data up to application layer as appropriate.
- When will this not work? (hint: errors are not exclusive to data packets)
- Problem: what if ACK/NAK is corrupted? See rdt2.1
- Solution: Add sequence number to data packet. 0 or 1 will do.
- Sender: toggle sequence number before sending new data packet.
- Receiver: If arriving packet has same sequence number as last one, it is duplicate soACK it (since sender didn’t know it was received) then discard it.
- Total solution requires all the functionality listed above for sender and receiver.
- Sender: when application supplies data, toggle sequence number, send data packet and wait for ACK or NAK packet to arrive. If ACK, send next packet. If NAK or garbled, resend same packet.
- Receiver: when data packet arrives, check for garbled. If garbled, send NAK packet to sender. If duplicate, send ACK then discard data. If correct packet, send ACK packet. Pass data up to application layer as appropriate.
- Textbook rdt2.2 uses ACK with sequence number and no NAK. TCP uses a variation on this.
- Receiver always responds with ACK containing sequence number of last correct packet.
- Sender must recognize when ACK really means NAK!
Stop-and-wait with lossy channel
- textbook rdt3.0
- unreliable channel which can corrupt bits and lose packets and maybe slow receiver
- Given version 2.1 or 2.2, you need only add timer to sender.
Consider performance of all stop-and-wait protocols
- Propagation delay is major factor
- Recall this is not the same as transmission delay
- Propagation is how long it takes bit to physically move from A to B
- Round trip propagation determines how long until sender receives ACK! It is idle all this time.
Sliding window protocols for reliable delivery
- Improve performance by providing pipelining
- Two flavors are:
- Go-Back-N (retransmit all packets since last confirmed ACK)
- Selective Repeat (retransmit only packets w/o confirmed ACK)
- TCP sliding window protocol is combo of these two.
Go-Back-N
- Sender has window (range) of packet “slots”:
- packets transmitted but no ACK received yet
- packets slots usable but no data received yet from app layer
- Sender window has length N.
- If sender window full, new data from app layer is “rejected”
(may use semaphore as in producer-consumer problem to prevent)
- Requires sequence number
- Textbook uses only ACKs (can also define using ACK/NAK)
- ACKs cumulative (one ACK can cover more than one packet)
- Textbook receiver accepts only in-order packets (window size 1).
- Can also implement to accept out-of-order packets (window size > 1)
- Sender action:
- Transmit data packets until:
- ACK received –or-
- Timer times out –or-
- window full –or-
- waiting for data from app layer
- When ACK x received
- slide window’s “left edge” to slot x+1
- slide window’s “right edge” by similar amount to keep size N
- (re)start timer unless window is now empty
- When timer times out
- Resend all packets in the window!
- Receiver action:
- If received packet is non-corrupt and in-order
- deliver data to app layer
- ACK with sequence number of that packet
- else (corrupt or out-of-order)
- ACK with sequence number of last accepted packet
- NOTE: It appears that ACK covers only one packet instead of being cumulative. But suppose:
- sender sends seq# 0,1,2,3
- receiver sends ACK 0,1,2,3
- receiver’s ACK 0, ACK 1, and ACK 2 are lost
- sender will get ACK 3 first and acknowledge all four.
- Consider performance:
- pipelined, so much better than stop-and-wait
- due to corrupted/lost ACKs, correctly transmitted packets may be retransmitted
Selective Repeat
- Address performance issue: Go-Back-N can result in many correct data packets being retransmitted.
- Receiver buffers out-of-order packets, so now has window
- ACKs are individual (not cumulative)
- Each packet has individual timer
- Sender action:
- Transmit until… (same as Go-Back-N).
- When ACK x received,
- If ACK duplicate or outside window, ignore. Otherwise……
- Delete timer for slot x
- Mark slot x as ACKed
- If all slots less than x are ACKed (e.g. slot x is “left edge”),
- slide “left edge” of window to first unACKed slot
- slide “right edge” of window by same amount
- send packets that come into window as a result of slide.
- When slot times out, resend that packet only.
- Receiver Action:
- When packet x received and x is within receiver window,
- Send ACK x.
- If duplicate, ignore. Otherwise…….
- Store data in buffer slot x.
- If all slots less than x have been delivered to app layer,
- Slide “left edge” of window to first undelivered slot y.
- Slide “right edge” of window by same amount.
- Deliver buffer slots x through y-1 to app layer.
- When packet x is received and x is “behind” current window,
- Otherwise, ignore the packet.
Example to illustrate two things about Selective Repeat
Example: (window size N = 4)
- Sender sends 0, 1, 2 and 3.
- Receiver ACKs 0, 1, 2, and 3. And slides left edge up to slot 4.
- ACK 0 is lost.
- Sender gets ACK 1, 2 and 3. Cannot slide left edge; no ACK 0.
- Sender slot 0 times out and resends.
- Receiver gets duplicate slot 0. What should it do? Slot 0 is now behind its window.
Illustrates that sender and receiver windows need not coincide.
Illustrates that range of sequence numbers must be at least twice the window size.
Suppose:
- sequence numbers range from 0 to N-1 (01230123…).
- After step 2, what is receiver’s left edge? Slot 0. Right edge? Slot 3.
- At step 6, receiver gets packet for slot 0. It thinks “slot 0 within window”, which is wrong!
Suppose:
- sequence numbers range from 0 to 2N-2 (01234560123456…).
- After step 2, what is receiver’s left edge? Slot 4. Right edge? Slot 0.
- At step 6, receiver gets packet for slot 0. It thinks “slot 0 within window”, which is wrong!
Suppose:
- sequence numbers range from 0 to 2N-1 (0123456701234567…).
- After step 2, what is receiver’s left edge? Slot 4. Right edge? Slot 7.
- At step 6, receiver gets packet for slot 0. It thinks “slot 0 behind window”, which is right!
[ C
SC 481 | Peter
Sanderson | Math Sciences server
| Math Sciences home page
| Otterbein ]
Last updated:
Peter Sanderson (PSanderson@otterbein.edu)