Chapter 3 outline � 3.1 Transport-layer � 3.5 Connection-oriented services transport: TCP � 3.2 Multiplexing and � segment structure demultiplexing � reliable data transfer � flow control � 3.3 Connectionless � connection management transport: UDP � 3.6 Principles of � 3.4 Principles of congestion control reliable data transfer � 3.7 TCP congestion control Transport Layer 3-1
TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 � point-to-point: � full duplex data: � one sender, one receiver � bi-directional data flow in same connection � reliable, in-order byte � MSS: maximum segment steam: size � no “message boundaries” � connection-oriented: � pipelined: � handshaking (exchange � TCP congestion and flow of control msgs) init’s control set window size sender, receiver state � send & receive buffers before data exchange � flow controlled: application application � sender will not writes data reads data socket socket overwhelm receiver door door TCP TCP send buffer receive buffer segment Transport Layer 3-2
TCP segment structure • upper left: wireshark display showing TCP header fields including an option, followed by the payload. • lower right: wireshark display of a TCP segment carrying an ACK but no payload. Transport Layer
TCP header, in detail ((c) Matt Baxter) Transport Layer
TCP seq. #’s and ACKs Seq. #’s: Host A Host B � byte stream User “number” of first Seq=42, ACK=79, data = ‘C’ types byte in segment’s ‘C’ data host ACKs receipt of ACKs: ‘C’, echoes Seq=79, ACK=43, data = ‘C’ � seq # of next byte back ‘C’ expected from other side host ACKs � cumulative ACK receipt Seq=43, ACK=80 of echoed Q: how receiver handles ‘C’ out-of-order segments � A: TCP spec doesn’t time say, - up to simple telnet scenario implementor Transport Layer 3-5
TCP Round Trip Time and Timeout Q: how to estimate RTT? Q: how to set TCP timeout value? � SampleRTT : measured time from segment transmission until ACK � longer than RTT receipt � but RTT varies � ignore retransmissions � too short: premature � SampleRTT will vary, want timeout estimated RTT “smoother” � unnecessary � average several recent retransmissions measurements, not just � too long: slow reaction current SampleRTT to segment loss Transport Layer 3-6
TCP Round Trip Time and Timeout EstimatedRTT = (1- α )*EstimatedRTT + α *SampleRTT � Exponential weighted moving average � influence of past sample decreases exponentially fast � typical value: α = 0.125 Transport Layer 3-7
Example RTT estimation: RTT: gaia.cs.umass.edu to fantasia.eurecom.fr 350 300 250 RTT (milliseconds) 200 150 100 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106 time (seconnds) SampleRTT Estimated RTT Transport Layer 3-8
TCP Round Trip Time and Timeout Setting the timeout � EstimtedRTT plus “safety margin” � large variation in EstimatedRTT -> larger safety margin � first estimate of how much SampleRTT deviates from EstimatedRTT: DevRTT = (1- β )*DevRTT + β *|SampleRTT-EstimatedRTT| (typically, β = 0.25) Then set timeout interval: TimeoutInterval = EstimatedRTT + 4*DevRTT Transport Layer 3-9
Chapter 3 outline � 3.1 Transport-layer � 3.5 Connection-oriented services transport: TCP � 3.2 Multiplexing and � segment structure demultiplexing � reliable data transfer � flow control � 3.3 Connectionless � connection management transport: UDP � 3.6 Principles of � 3.4 Principles of congestion control reliable data transfer � 3.7 TCP congestion control Transport Layer 3-10
TCP reliable data transfer � TCP creates rdt � Retransmissions are service on top of IP’s triggered by: unreliable service � timeout events � Pipelined segments � duplicate acks � Initially consider � Cumulative acks simplified TCP sender: � TCP uses single � ignore duplicate acks retransmission timer � ignore flow control, congestion control Transport Layer 3-11
TCP sender events: data rcvd from app: timeout: � Create segment with � retransmit segment seq # that caused timeout � seq # is byte-stream � restart timer number of first data Ack rcvd: byte in segment � If acknowledges � start timer if not previously unacked already running (think segments of timer as for oldest � update what is known to unacked segment) be acked � expiration interval: � start timer if there are outstanding segments TimeOutInterval Transport Layer 3-12
NextSeqNum = InitialSeqNum SendBase = InitialSeqNum TCP loop (forever) { sender switch(event) event: data received from application above (simplified) create TCP segment with sequence number NextSeqNum if (timer currently not running) start timer Comment: pass segment to IP NextSeqNum = NextSeqNum + length(data) • SendBase-1: last cumulatively event: timer timeout ack’ed byte retransmit not-yet-acknowledged segment with Example: smallest sequence number • SendBase-1 = 71; start timer y= 73, so the rcvr wants 73+ ; event: ACK received, with ACK field value of y y > SendBase, so if (y > SendBase) { SendBase = y that new data is if (there are currently not-yet-acknowledged segments) acked start timer } } /* end of loop forever */ Transport Layer 3-13
TCP: retransmission scenarios Host A Host B Host A Host B Seq=92, 8 bytes data Seq=92, 8 bytes data Seq=92 timeout S e q = 1 0 0 , 2 0 b y t e s timeout d a t a ACK=100 ACK=100 ACK=120 X loss Seq=92, 8 bytes data Seq=92, 8 bytes data Sendbase = 100 Seq=92 timeout SendBase = 120 ACK=120 0 0 1 = K C A SendBase SendBase = 100 = 120 premature timeout time time lost ACK scenario Transport Layer 3-14
TCP retransmission scenarios (more) Host A Host B Seq=92, 8 bytes data ACK=100 timeout Seq=100, 20 bytes data X loss 0 2 SendBase 1 = K C A = 120 time Cumulative ACK scenario Transport Layer 3-15
TCP ACK generation [RFC 1122, RFC 2581] TCP Receiver action Event at Receiver Delayed ACK. Wait up to 500ms Arrival of in-order segment with for next segment. If no next segment, expected seq #. All data up to expected seq # already ACKed send ACK Immediately send single cumulative Arrival of in-order segment with ACK, ACKing both in-order segments expected seq #. One other segment has ACK pending Immediately send duplicate ACK , Arrival of out-of-order segment indicating seq. # of next expected byte higher-than-expect seq. # . Gap detected Arrival of segment that Immediate send ACK, provided that segment starts at lower end of gap partially or completely fills gap Transport Layer 3-16
Fast Retransmit � Time-out period often � If sender receives 3 relatively long: ACKs for the same data, it supposes that � long delay before segment after ACKed resending lost packet data was lost: � Detect lost segments via duplicate ACKs. � fast retransmit: resend segment before timer � Sender often sends expires many segments back-to- back � If segment is lost, there will likely be many duplicate ACKs. Transport Layer 3-17
Host A Host B X timeout resend 2 nd segment time Figure 3.37 Resending a segment after triple duplicate ACK Transport Layer 3-18
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 fast retransmit already ACKed segment Transport Layer 3-19
Chapter 3 outline � 3.1 Transport-layer � 3.5 Connection-oriented services transport: TCP � 3.2 Multiplexing and � segment structure demultiplexing � reliable data transfer � flow control � 3.3 Connectionless � connection management transport: UDP � 3.6 Principles of � 3.4 Principles of congestion control reliable data transfer � 3.7 TCP congestion control Transport Layer 3-20
TCP Flow Control • receive side of TCP • The problem: sender connection has a receive might send segments buffer: faster than receiver can consume them – Receiving app. is slow at reading from TCP’s input buffer – this is an App-layer problem, but solved w/ help from Transport layer. • Flow control forces the sender to slow down its • speed-matching service: transmission rate matching the send rate to – sending app. blocks on calls to the receiving app’s drain its transport layer rate Transport Layer 3-21
TCP Flow control: how it works � Rcvr advertises spare room by including value of RcvWindow in segments � Sender limits unACKed (Suppose TCP receiver data to RcvWindow discards out-of-order � guarantees receive segments) buffer doesn’t overflow � spare room in buffer = RcvWindow = RcvBuffer-[LastByteRcvd - LastByteRead] Transport Layer 3-22
Chapter 3 outline � 3.1 Transport-layer � 3.5 Connection-oriented services transport: TCP � 3.2 Multiplexing and � segment structure demultiplexing � reliable data transfer � flow control � 3.3 Connectionless � connection management transport: UDP � 3.6 Principles of � 3.4 Principles of congestion control reliable data transfer � 3.7 TCP congestion control Transport Layer 3-23
Recommend
More recommend