Download presentation
Presentation is loading. Please wait.
1
CS4470 Computer Networking Protocols
12/1/2018 CS Computer Networking Protocols 16. TCP 3 Huiping Guo Department of Computer Science California State University, Los Angeles
2
Outline TCP reliable data transfer TCP timeout value 16. TCP 3 CS4470
12/1/2018 Outline TCP reliable data transfer TCP timeout value 16. TCP CS4470
3
TCP reliable data transfer
TCP creates reliable data transfer service on top of IP’s unreliable service Use sliding window Limit the number of bytes that can be sent Cumulative acks TCP uses single timer When the timer expires, only retransmits the oldest segment 16. TCP CS4470
4
TCP reliable data transfer
Retransmissions are triggered by: timeout events duplicate acks Initially consider simplified TCP sender: ignore duplicate acks ignore flow control, congestion control 16. TCP CS4470
5
TCP sender (simplified)
NextSeqNum = InitialSeqNum SendBase = InitialSeqNum loop (forever) { switch(event) event: data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running) start timer pass segment to IP NextSeqNum = NextSeqNum + length(data) event: timer timeout retransmit not-yet-acknowledged segment with smallest sequence number event: ACK received, with ACK field value of y if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) } } /* end of loop forever */ TCP sender (simplified) Comment: SendBase-1: last cumulatively ack’ed byte Example: SendBase-1 = 71; y= 73, so the rcvr wants 73+ ; y > SendBase, so that new data is acked 16. TCP CS4470
6
TCP retransmission scenarios
Host A Host B Seq=92, 8 bytes data loss ACK=100 X timeout Seq=100, 20 bytes data ACK=120 SendBase = 120 time Cumulative ACK scenario 16. TCP CS4470
7
TCP: retransmission scenarios
12/1/2018 TCP: retransmission scenarios Host A Seq=92, 8 bytes data ACK=100 loss timeout lost ACK scenario Host B X time Host A Host B Seq=92 timeout Seq=92, 8 bytes data Seq=100, 20 bytes data ACK=100 Sendbase = 100 SendBase = 120 ACK=120 Seq=92, 8 bytes data ACK=120 SendBase = 120 Seq=92 timeout SendBase = 100 premature timeout time 16. TCP CS4470
8
Fast Retransmit Time-out period often relatively long:
long delay before resending lost packet Detect lost segments via duplicate ACKs. Sender often sends many segments back-to-back If segment is lost, there will likely be many duplicate ACKs. If sender receives 3 duplicate(4 identical) ACKs for the same data, it supposes that segment was lost: fast retransmit: resend segment before timer expires 16. TCP CS4470
9
Fast retransmit algorithm:
event: ACK received, with ACK field value of y if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) start timer } else { increment count of dup ACKs received for y if (count of dup ACKs received for y = 3) { resend segment with sequence number y a duplicate ACK for already ACKed segment fast retransmit 16. TCP CS4470
10
Fast retransmit example
Host A Host B Seq=92, 8 bytes data Seg=100, 10 bytes Seg=110 Seg=120 ACK=100 Seg=130 ACK=100 Seq92 timeout ACK=100 ACK=100 Seq=100, 10bytes Fast retransmit time 16. TCP CS4470
11
TCP ACK generation [RFC 1122, RFC 2581]
Event at Receiver Arrival of in-order segment with expected seq #. All data up to expected seq # already ACKed expected seq #. One other segment has ACK pending Arrival of out-of-order segment higher-than-expect seq. # . Gap detected Arrival of segment that partially or completely fills gap TCP Receiver action Delayed ACK. Wait up to 500ms for next segment. If no next segment, send ACK Immediately send single cumulative ACK, ACKing both in-order segments Immediately send duplicate ACK, indicating seq. # of next expected byte Immediate send ACK, provided that segment starts at lower end of gap 16. TCP CS4470
12
Example: normal operation
16. TCP CS4470
13
Example: Lost segment 16. TCP CS4470
14
Example: fast retransmission
16. TCP CS4470
15
Example: Lost acknowledgment
16. TCP CS4470
16
Example: Lost acknowledgment corrected by resending a segment
16. TCP CS4470
17
TCP Round Trip Time and Timeout
TCP uses timeout/retransmit mechanism to recover from lost segments Set TCP timeout value? longer than RTT how much longer? too short: premature timeout unnecessary retransmissions too long: slow reaction to segment loss TCP has an algorithm to compute the timeout value 16. TCP CS4470
18
Timeout value Measured RTT, RTTM
The time required for the segment to reach the destination and be acknowledged The ack may include other segments Several segments may be acked together In TCP, only one RTT measurement can be in progress at any time If an RTT measurement is started, no other measurement starts until the value of this RTT is finalized. 16. TCP CS4470
19
Timeout value Smoothed RTT To calculate RTTS
RTTM changes for round trip. The fluctuation is so high in today’s Inernet that it cannot be used for retransmission time-out purposes A smoothed RTT, called RTTS, is a weighted average of RTTM and the previous RTTS To calculate RTTS Original: no value After first measurement: RTTS = RTTM After any other measurement: RTTS = (1-α)*RTTS+ α * RTTM The value of α is implementation dependent, but it’s usually set to 1/8 16. TCP CS4470
20
Timeout value RTT deviation, RTTD To calculate RTTD
It’s based on RTTS and RTTM To calculate RTTD Original: no value After first measurement: RTTD = RTTM/2 After any other measurement: RTTD = (1-β)*RTTD+ β *| RTTS - RTTM| The value of β is also implementation dependent, but it’s usually set to 1/4 16. TCP CS4470
21
Timeout value Retransmission Timeout (RTO) To calculate RTO
RTO is based on RTTS and RTTD To calculate RTO Original: intial value After any measurement: RTO = RTTS + 4*RTTD 16. TCP CS4470
22
Example 16. TCP CS4470
23
Example When the SYN segment is sent, there is no value for RTTM, RTTS, or RTTD When the SYN+ACK segment arrives, RTTM is measured to 1.5s The following shows the values of these variables RTTM = 1.5 RTTS = 1.5 RTTD = 1.5/2 = 0.75 RTO = * 0.75 = 4.5 16. TCP CS4470
24
Example When the 1st segment is sent, a new RTT measurement starts. Note: Sender doesn’t start an RTT measurement when it sends the ACK segment No RTT measurement starts for the 2nd segment because a measurement is already in progress Though the last ACK acks two data segments, its arrival finalize the value of RTTM for the first segment The following shows the values of these variables RTTM = 2.5 RTTS = 7/8(1.5) + 1/7(2.5) = 1.625 RTTD = ¾ (0.75) + ¼ |1.625 – 2.5| = 0.78 RTO = * 0.78 = 4.74 16. TCP CS4470
25
Timeout value (cont.) TCP does not consider the RTT of a retransmitted segment in its calculation of a new RTO. When a segment is retransmitted, the current RTO value is doubled. 16. TCP CS4470
26
Example 16. TCP CS4470
27
Example(cont.) The first segment in the figure is sent, but lost.
The RTO timer expires after 4.74 seconds. The segment is retransmitted and the timer is set to 9.48, twice the previous value of RTO. This time an ACK is received before the time-out. We wait until we send a new segment and receive the ACK for it before recalculating the RTO 16. TCP CS4470
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.