430 likes | 518 Vues
Gain an understanding of TCP, UDP, and IP services, explain congestion control algorithms, and describe protocol details for reliable transfer over networks.
E N D
Chapter 2 TCP/IP Fundamentals
Objectives • Gain an understanding of the basic services provided by TCP, UDP and IP • Explain the congestion control algorithms employed by TCP • Describe protocol details of TCP needed to ensure reliable transfer over unreliable networks
Contents • TCP services and protocols
TCP Services • Connection-oriented • Streaming • Full-duplex • Reliable • End-to-end semantic
TCP Header Format • Fig. 2.1
TCP Header Format (Cont.) • Source Port (16 bits) • Destination Port (16 bits) • Sequence number (32 bits) • Ack number (32 bits) • Header Length (4 bits) • Reserved (6 bits)
TCP Header Format (Cont.) • Flags (6 bits) • Receiver window size (16 bits) • Checksum (16 bits) • Urgent Pointer (16 bits) • Options (variable) TCP Header is 20 bytes long (without options).
Encapsulation in IP • Fig. 2.2
Acknowledgement Mechanism • Cumulative ACK: • Confirmation that all bytes up to the ack mechanism have been received correctly. • Advantage: lost ACK are compensated for subsecuents ACKs. • ACK-only segment and Piggybacking: • In piggybacking the ACK travels in a data segment. • Advantage: Reduces traffic. • Delayed ACK • The receiver has the choice of either generating an ACK as soon as receive a package or delay it for a while (not more than 500ms). • Advantage: Reduce traffic (receive two segments and ACK one). • Disadvantage: May cause a timeout and retransmission at the sender. • Duplicate ACK: • If a segment get lost , but the following segments arrive safetly at the receiver, it is possible for the receiving TCP to receive data with a sequence number beyond the expected range. In that case, the receiving TCP: • buffers the incoming bytes and • Regenerate the ACK for the bytes received so far in sequence. • The sender: • Can receive the same duplicate ACK more than once. • The original TCP ingnores the dupllicate ACK
Retransmission Mechanism • Retransmission timer: • TCP maintains a timer for each segment sent. • The timer is set for a duration call the RTO (Retransmision time). • where • Setting a optimum value for the RTO is very significative from the performance point of view. • Granularity of RTO • Typically 1 sec. • Smaller value used in some implementations (e.g. Solaris)
Flow Control • Prevent buffer overflow at TCP receiver • Regulate sending rate at TCP sender • The sending TCP maintains a variable called AdvertisedWindow to keep track of the current window size. • Mechanism • Sliding window • (p37, Fig. 2.5)
Congestion Control • Prevent buffer overflow at routers • Regulate sending rate at TCP sender: • The sending TCP maintains a variable called CongestionWindow to keep track of the current window size. • The idea is to that somehow we could learn the available buffer space in the most congested (bottleneck) router in the end-to-end path of the TCP congestion, we could set the CongestionWindow and select the transmision window as the minimum of the AdvertisedWindow and the CongestedWindow. • The challenge is to how to learn the available buffer space in the network. Since routers do not work at TCP level, then TCP assumes network congestion whenever a retransmission timer expires.
Congestion Control • TCP reacts to network congestion using three Mechanism • Slow-Start: • Congestion Avoidance: • Additive Increase, Multiplicative Decrease (AIMD)
TCP Slow Start • Start with small window • Increased window by 1 each time ACK rcvd • Window increases exponentially
TCP Congestion Avoidance • Exponential increase may cause congestion • Force linear increase after a threshold: • When CongestionWindow’s reaches a threshold (ssthresh), the windows segment size increased by one (linear increase). • Linear increase avoids possible congestion
Congestion Control • Additive Increase, Multiplicative Decrease (AIMD): • Control ssthresh variable. • Everytime a timeout occurs ssthresh is set to half of the current value, down to a minimum of two segments.
TCP Congestion Control SW SA • Fw= FlowControl Window • Aw= Advertised Window • CW= Congestion Window • SA= Acknowledged Segments • SW= Segments waiting to be acknowledge Aw Fw
TCP Congestion Control ACK: { If (SA < S < SA + SW) { SA++; If (CW < ssthres) slowstart(); else congAvoid(); } elseif (S< SA) duplicateACK(); } T0: multiplicativeDecrease();
TCP Congestion Control duplAck () { doNothing; } slowStart () { X= (SA)2; If (X<=ssthres) CW=X; else CW= congAvoid(); AW=min(CW , FW); } congAvoid(){ CW ++; AW=min(CW , FW); } MultiplicativeDecrease () { A=CW/2; if (A<=2) ssthres=A; else ssthres=2; AW=CW=1; }
Ejemplo • Suponga: SA =10; SW=3; ST=5 FW=500; CW=100; ssthres=500; • Para S=11 ACK: { If (SA=10 < S=11 < SA + SW=10+3 ) { SA++=11; If (CW =100 < ssthres=500) slowstart(); else congAvoid(); } else if (S< SA) duplicateACK(); } T0: multiplicativeDecrease; slowStart () { X= (SA)2=121; if (X=121<= ssthres=121) CW = X; else CW= congAvoid(); AW=min(CW=121, FW=500)=121; }
Chapter 11 New TCP Standards And Flavors
Objectives • Compare the variations in congestion congestion control algorithms of different TCP flavors • Learn how network simulation can be used to compare the performance of different TCP flows
Contents • Fast retransmission and fast recovery • TCP NewReno • Selective Acknowledgement (SACK) • Forward Acknowledgement (FACK) • TCP Vegas • Performance comparison of TCP flavors
History (Wikipedia) 4.2 BSD (1983) 4.3 BSD (1986) 4.3 BSD-Tahoe (1988) Net/1 (1989) 4.3 BSD-Reno (1990) Net/2 (1991) 4.4 BSD (1993) BSD-Lite (1994)
Fast Retransmit And Fast Recovery
Fast Retransmit • Duplicate ACKs (dupacks) trigger retransmission • Avoid retransmission timeout • Actions performed by the sender upon receiving 3 dupacks: • Reduce ssthresh to half of cwnd • Reset cwnd to 1 segment • Retransmit the lost TCP segment • Implemented in TCP Tahoe
TCP Congestion Control cont=0; ACK: { If (SA < S < SA + SW) { SA++; If (CW < ssthres) slowstart(); else congAvoid(); } elseif (S< SA) duplicateACK(); } T0: multiplicativeDecrease();
TCP Congestion Control duplAck () { If (cont=3) retransmit(S_ACK + 1); ssthres=CW/2; CW=1; cont=0; } else cont++; } slowStart () { X= (SA)2; If (X<=ssthres) CW=X; else CW= congAvoid(); AW=min(CW , FW); } congAvoid(){ CW ++; AW=min(CW , FW); } MultiplicativeDecrease () { A=CW/2; if (A<=2) ssthres=A; else ssthres=2; AW=CW=1; }
Fast Recovery • Implemented in TCP Reno (1990) • Initially, implemente in Unix BSD, now is the most used TCP version. • Avoid to go to slow-start, when only a packet is lost. • Based on the fact that a duplicate ACK (dupack) indicates that a segment has left the network • Keep track of of the No. of dupacks received • Inflate cwnd by one segment for each dupack received • Come out of fast recovery when receives an ACK for the segment resulting in the duplicate ACKs • Timeout still occurs when there are multiple consecutive loss in a window
TCP Congestion Control cont=0; fr=F; ACK:{ If (SA < S < SA + SW) { SA++; If (CW < ssthres) slowstart(); else congAvoid(); } elseif (S< SA) duplicateACK(); } T0:{ multiplicativeDecrease(); cont=0; }
TCP Congestion Control duplAck () { If (cont>=3) OR (fr==T) fastRetransmit(); fr==T; num_of_duplAck++; } else { cont++; num_of_duplAck=0; } } fastRetransmit() { If (cont==3){ retransmit(S_ACK); ssthres=CW/2; CW=CW/2; } else { If (num_duplAck>=CW/2){ if (ACK dato nuevo){ fr=F; } else { retransmit(S_ACK); CW++; } } slowStart () { X= (SA)2; If (X<=ssthres) CW=X; else CW= congAvoid(); AW=min(CW , FW); } congAvoid(){ CW ++; AW=min(CW , FW); } MultiplicativeDecrease () { A=CW/2; if (A<=2) ssthres=A; else ssthres=2; AW=CW=1; }
TCP NewReno • Effects of timeout on throughput: • TCP cannot send data during timeout period • cwnd is reset to 1 segment • Avoid timeouts in the case of multiple consecutive losses • Upon receipt of a partial ACK: • Does not come out of fast recovery • Assume the segment immediately after the most recently ACKed segment has been lost • Retransmit the lost (assumed) segment
Selective Acknowledgment
TCP SACK • Avoid timeouts in the case of multiple consecutive losses • Inform the sender which segments have been received • The receiver uses TCP SACK blocks to indicate contiguous blocks of data successfully received • The sender infers (from the SACK blocks) which segments are missing (holes in Seq. No) • The sender retransmits missing segments without waiting for timeout
Forward Acknowledgment
Forward Acknowledgment (FACK) • Better recovery from multiple consecutive losses • Keep track of the correctly received data with the highest sequence number • TCP maintains 2 additional variables: • fack: represents the forward-most segment ACKed • retran_data: reflects the amount of outstanding retransmitted data • Estimate the amount of outstanding data during recovery
TCP Vegas • Fundamentally different from other TCP variants • Not wait for loss to trigger cwnd reduction • Estimate current throughput every RTT • Compare current throughput with the expected throughput • Linearly increase cwnd if diff < 2 • Linearly decrease cwnd if diff > 4 • Modified slow start • Find the correct window size without incurring a loss • Modified retransmission • Retransmit after one duplicate ACK (as opposed to 3 dupacks)
Comparing TCP Flavors
Performance Comparison of TCP Flavors • Network topology used (Fig. 11.3) • Compare performance of TCP variants against TCP Reno
Performance Comparison of TCP Flavors (Cont.) • Goodput • Table 11.2 • Round trip time • Table 11.3 • Time granularity • Table 11.4