Reliable Data Transfer
RDT(reliable data transfer)
- Capabilities
- Error detection
- Receive feedback(ACK)
- Retransmission(RDT based on retransmission is also called ARQ(automatically repeat request))
Stop-and-wait
Let’s build a reliable data transfer protocol! 🌟
-
RDT2.0 🌟
- Sending process
- Receive data from upper layer
- Make a packet
- Send the packet
- Waiting
- Receive ACK
- Exit waiting
- Receive NAK
- Resend
- Keep waiting
- Receive ACK
- Next
- Receiving process
- Receive the packet
- Checking
- Corrupt
- Send NAK
- Exit checking
- Not corrupt
- Extract data
- Deliver data to next layer
- Send ACK
- Exit checking
- Corrupt
- Next
- Problems
- Corrupt ACK/NAK
- Error
- Lost
- Corrupt ACK/NAK
- 3 ways to solve the problems
- Sender asking
- Receiver have no idea whether it is a new packet or request for repeating
- checksum
- Not solving “lost” problem
- Resending when NAK/corrupt ACK
- Receiver have no idea sender have received ACK or not. Then it’s hard for receiver to find out the new packet is the previous one or the new one.
- Sender asking
- final method
- Resending (3rd method)
- SN(sequence number) for packets
- 1-bit number(SN mod 2 can achieve)
- Introduce RDT2.1
- Sending process
-
RDT2.1 🌟
- Sender
- Receive data from upper layer
- Make a packet(+ SN mod 2)
- Send the packet
- Waiting
- Receive ACK
- Exit waiting
- Receive NAK/corrupt packet
- Resend
- Keep waiting
- Receive ACK
- Next (SN+1)
- Receiver
- Receive the packet
- Checking
- Waiting for 1(SN mod 2=1)
- Corrupt
- Send NAK
- Keep waiting
- Receive 0(duplicate one)
- Send ACK
- Keep waiting
- Receive 1
- Extract and deliver
- Send ACK
- Exit waiting
- Corrupt
- Waiting for 0(SN mod 2=0)
- Corrupt
- Send NAK
- Keep waiting
- Receive 1(duplicate one)
- Send ACK
- Keep waiting
- Receive 0
- Extract and deliver
- Send ACK
- Exit waiting
- Corrupt
- Waiting for 1(SN mod 2=1)
- Next(waiting +1)
- Sender
-
RDT2.2 🌟
- What’s new
- No more NAK
- SN in ACK
- Sender
- Receive data from upper layer
- Make a packet(+ SN mod 2)
- Send the packet
- Waiting
- Waiting for ACK 0(having sent the packet(SN mod 2=0))
- Receive ACK 0
- Exit waiting
- Receive ACK 1/corrupt ACK
- Resend
- Keep waiting
- Receive ACK 0
- Waiting for ACK 1(having sent the packet(SN mod 2=1))
- Receive ACK 1
- Exit waiting
- Receive ACK 0/corrupt ACK
- Resend
- Keep waiting
- Receive ACK 1
- Waiting for ACK 0(having sent the packet(SN mod 2=0))
- Next (SN+1)
- Receiver
- Receive the packet
- Checking
- Waiting for 1(SN mod 2=1)
- Corrupt /Receive 0(duplicate one)
- Send ACK 0
- Keep waiting
- Receive 1
- Extract and deliver
- Send ACK 1
- Exit waiting
- Corrupt /Receive 0(duplicate one)
- Waiting for 0(SN mod 2=0)
- Corrupt /Receive 1(duplicate one)
- Send ACK 1
- Keep waiting
- Receive 0
- Extract and deliver
- Send ACK 0
- Exit waiting
- Corrupt /Receive 1(duplicate one)
- Waiting for 1(SN mod 2=1)
- Next(waiting +1)
- What’s new
-
RDT3.0(alternating-bit protocol) 🌟
- What’s new
- Deal with the lossy channel, which is common
- Introduce cutdown timer
- Start the timer for each packet
- Timer interrupt
- Stop the timer
- Sender
- Receive data from upper layer
- Make a packet(+ SN mod 2)
- Send the packet
- Start the timer
- Waiting
- Waiting for ACK 0(having sent the packet(SN mod 2=0))
- Receive ACK 0
- Stop the timer
- Exit waiting
- Receive ACK 1/corrupt ACK
- None
- Timeout
- Resend
- Restart the timer
- Keep waiting
- Receive ACK 0
- Waiting for ACK 1(having sent the packet(SN mod 2=1))
- Receive ACK 1
- Stop the timer
- Exit waiting
- Receive ACK 0/corrupt ACK
- None
- Timeout
- Resend
- Restart the timer
- Keep waiting
- Receive ACK 1
- Waiting for ACK 0(having sent the packet(SN mod 2=0))
- Next (SN+1)
- Receiver
- The same as RDT2.2
- What’s new
A reliable data transfer protocol(3.0) has been created! 🌟
- New problems
- How to achieve high efficiency?
- Pipelining
- How to achieve high efficiency?
- Consequences for RDT
- Unique SN
- Both sides have buffer
- Error control
- GBN
- Selective repeat
GBN(Go-Back-N)
- Base: The oldest unacknowledged packet
- Nextseqnum: The next packet to be sent
- Window size(N): used for flow control
- SN issues: As the number of bits in header is fixed(eg. k, (32 bits)TCP), SN need do modular arithmetic()
1 | //sender |
- Why discard all packets after the unacknowledged one?
- Sender will resend, so they will not be lost
- Simplify the receiver buffer
- Why
-
- It’s obvious that there must be mixing the previous one with the new one
-
-
SR(selective repeat)
- What’s new
- Compare to GBN
- Solving the problem that when a large number of packets are in the channel, GBN becomes time-consuming
- Avoid unnecessary retransmissions
- Compare to GBN
- Sender
- Receive data from upper layer
- The same as GBN
- Timeout
- Now each packet has its own logical timer
- Only send the one packet when its timer expires
- ACK received
- The same as GBN
- Receive data from upper layer
- Receiver
- Packets with SN in rcv window(rcv_base ~ rcd_base+N-1) is correctly received
- Not received previously
- buffered
- SN == rcv_base
- Rcv_base one and all previously buffered & consecutively numbered packets are all passed to the next layer
- Window moves forward by the number of packets delivered
- Send ACK
- Not received previously
- Packets with SN in [rcv_base-N, rcv_base-1] –ensure the window of send slides
- Send ACK
- Not buffered
- Other packets
- Ignore them
- Packets with SN in rcv window(rcv_base ~ rcd_base+N-1) is correctly received
- SR delima with too-large window size
🌟 How to solve
-
- equivalent to
- w is the window size
- Why?
- We must make sure the sum of w of both sides less than or equal to , then all previous ones with SN can be distinguished. We cannot recognize a previous one as a new one
We have built amazing RDT protocols! Now, let’s see what’s new in RDT of TCP.
RDT in TCP
- Point 1: Practically, timer requires considerable overhead
- Try to follow one-timer retransmission
- Point 2: Use cumulative acknowledgements
- The acknowledgment number that receiver puts in its segment is the sequence number of the next byte receiver is expecting from sender.
1 | /*Not C just pseudocode*/ |
- 3 scenarios to learn RDT in TCP visually
- Fast retransmission
- If the TCP sender receives three duplicate ACKs for the same data, it takes this as an indication that the segment following the segment that has been ACKed three times has been lost
- Retransmitting the missing segment before that segment’s timer expires
- How to classify RDT in TCP
- A hybrid of GBN and SR protocols
Here is a Leaning Note.
Most of the content references “Computer Network A Top-Down Approach(James Kurose, Keith Ross)”
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 LeeZ's blog!
评论
ValineWaline