Project for CS305: Reliable Data Transfer.
This project is based on the existing UDP socket to achieve a reliable data transmission protocol, and with a packet loss rate of 10%, the rate reaches 60%. This project mainly builds a finite state machine, defines the different states of the socket, simulates the TCP protocol to achieve three-way handshake, four waved hands, and retransmission mechanism; at the same time, set the timeout time by estimating the round-trip time of the data packet, and modify the sliding window size To achieve congestion control;
- Process
-
Process
-
CWDN
- Slow Start:
- cwdn = 1 (Time out)
- cwdn = cwdn * 2
- Congestion Avoidance:
- cwdn = cwdn + 1
- Slow Start:
-
Fast Retransmit
-
Timeout Interval
- Receive payload:
- TimeoutInterval = EstimatedRTT + 4 * DevRTT
- EstimatedRTT = (1 - α) * EstimatedRTT + α * SampleRTT
- DevRTT = (1 - β) * DevRTT + β * |SampleRTT – EstimatedRTT|
- Time out
- Doubling the Timeout Interval
- Receive payload:
-
-
Flow chart
-
Pseudocode
-
When Timeout:
ssthresh = cwnd / 2 cwnd = 1 dupACKcount = 0 RESEND
-
When duplicate ACK:
dupACKcount++ if dupACKcount = 3 : ssthresh = cwnd/2 Resend missing segment
-
When new ACK:
if cwdn < ssthresh: cwnd += 1 else if ACKcount = cwnd: cwnd += 1 ACKcount = 0 else: ACKcount += 1
-
-
Log
- In send function, we will add a special payload at the end of the data. When recv function receives this payload, it represents the end of the received data. Causes data from two consecutive send functions not to be received by a single recv functions
- The data sending and receiving mode we adopted is between GBN and SR, with buffer at both receiving end and sending end. And accumulative ACK is adopted to make fast retransmission more effective.