CS138-lecture-20210311

UDP cont. #

image_2021-03-11-09-01-20 image_2021-03-11-09-01-54 image_2021-03-11-09-02-50 image_2021-03-11-09-03-06 image_2021-03-11-09-07-34

Principles of reliable data transfer #

image_2021-03-11-09-11-07 image_2021-03-11-09-12-50 image_2021-03-11-09-15-32 image_2021-03-11-09-17-24 image_2021-03-11-09-17-28

Expected features

  • No bit errors
  • No loss of data

Problems

  • Bit error
  • Data loss

Solutions

  1. Error detection (checksum)
  2. Data recovery

image_2021-03-11-09-21-00 image_2021-03-11-09-24-20

So how do we do recovery? We learn from human to human conversation, “pardon?” to recover data loss in the conversation.

Feedback: ACK for positive, NAK for negative.

So the receiver will send an ACK if the packet was received without loss, otherwise it’ll send NAK. Then, from the sender’s perspective it will move on to the next data transmission if ACK is received from receiver. Otherwise, (NAK from receiver) it will retransmit the last data until an ACK is received.

image_2021-03-11-09-37-13

So we have a new problem, what if ACK/NAK is corrupted on the way back?

The sender has no way to find out whether the current packet was successful or not. We can allow the sender to retransmit the data, but it can cause duplicates on the receiver’s side. To avoid and handle duplicates, the sender adds a sequence number to each packet, this way the receiver can discard duplicates.

image_2021-03-11-09-41-53

We have to stop and wait, each time we only transmit one single packet. If we’re only sending 1 packet at a time, when we wait until its successful each time we give it a sequence number, so we actually only need 2 different sequence numbers.

pkt 0… pkt 1… pkt 0… pkt 1… etc

image_2021-03-11-09-48-26

What if the ACK response is corrupted?

image_2021-03-11-09-50-06 image_2021-03-11-09-50-45 image_2021-03-11-09-51-34 image_2021-03-11-09-55-53

If the sender receives the same ACK for the same packet, then that must mean that the last packet was corrupted during transmission. Instead of sending NAK for the current packet, it is equivalent of sending the ACK for the last packet. This tells the sender that the current packet wasn’t successful, and the sender should retransmit.

image_2021-03-11-10-00-24

NAK 1 -> ACK 0;

NAK 0 -> ACK 1;

If the first packet has a problem, then simply no response shows that it had a problem.