Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented transport: TCP services • segment structure 3.2 multiplexing and demultiplexing • reliable data transfer • flow control 3.3 connectionless • connection management transport: UDP 3.6 principles of congestion 3.4 principles of reliable control 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 connection-oriented: boundaries ” • handshaking (exchange pipelined: of control msgs) inits • TCP congestion and sender, receiver state flow control set window before data exchange size flow controlled: • sender will not overwhelm receiver Transport Layer 3-2
TCP segment structure 32 bits URG: urgent data counting source port # dest port # (generally not used) by bytes sequence number of data ACK: ACK # (not segments!) acknowledgement number valid head not receive window U A P R S F PSH: push data now len used # bytes (generally not used) checksum Urg data pointer rcvr willing to accept RST, SYN, FIN: options (variable length) connection estab (setup, teardown commands) application data Internet (variable length) checksum (as in UDP) Transport Layer 3-3
TCP seq. numbers, ACKs outgoing segment from sender sequence numbers: source port # dest port # sequence number • byte stream “ number ” of acknowledgement number first byte in segment ’ s rwnd data checksum urg pointer window size acknowledgements: N • seq # of next byte expected from other side sender sequence number space • cumulative ACK Q: how receiver handles sent sent, not- usable not ACKed yet ACKed but not usable out-of-order segments ( “ in- yet sent flight ” ) • A: TCP spec doesn ’ t say, incoming segment to sender - up to implementor source port # dest port # sequence number acknowledgement number A rwnd checksum urg pointer Transport Layer 3-4
TCP seq. numbers, ACK s Host A Host B User types ‘ C ’ Seq= 42, ACK= 79, data = ‘ C ’ host ACKs receipt of ‘ C ’ , echoes Seq=79, ACK=43, data = ‘ C ’ back ‘ C ’ host ACKs receipt of echoed ‘ C ’ Seq=43, ACK=80 simple telnet scenario Transport Layer 3-5
TCP round trip time, timeout Q: how to set TCP Q: how to estimate RTT? timeout value? SampleRTT : measured time from segment longer than RTT transmission until ACK • but RTT varies receipt too short: premature • ignore retransmissions SampleRTT will vary, want timeout, unnecessary estimated RTT “ smoother ” retransmissions • average several recent too long: slow reaction measurements, not just to segment loss current SampleRTT Transport Layer 3-6
TCP round trip time, timeout EstimatedRTT = (1- α )*EstimatedRTT + α *SampleRTT exponential weighted moving average influence of past sample decreases exponentially fast typical value: α = 0.125 RTT: gaia.cs.umass.edu to fantasia.eurecom.fr 350 RTT: gaia.cs.umass.edu to fantasia.eurecom.fr RTT (milliseconds) 300 250 RTT (milliseconds) 200 sampleRTT 150 EstimatedRTT 100 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106 time (seconnds) time (seconds) Transport Layer 3-7 SampleRTT Estimated RTT
TCP round trip time, timeout timeout interval: EstimatedRTT plus “ safety margin ” • large variation in EstimatedRTT -> larger safety margin estimate SampleRTT deviation from EstimatedRTT: DevRTT = (1- β )*DevRTT + β *|SampleRTT-EstimatedRTT| (typically, β = 0.25) TimeoutInterval = EstimatedRTT + 4*DevRTT “ safety margin ” estimated RTT * Check out the online interactive exercises for more examples: h ttp://gaia.cs.umass.edu/kurose_ross/interactive/ Transport Layer 3-8
Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented transport: TCP services • segment structure 3.2 multiplexing and demultiplexing • reliable data transfer • flow control 3.3 connectionless • connection management transport: UDP 3.6 principles of congestion 3.4 principles of reliable control data transfer 3.7 TCP congestion control Transport Layer 3-9
TCP reliable data transfer TCP creates rdt service on top of IP ’ s unreliable service • pipelined segments let ’ s initially consider • cumulative acks simplified TCP sender: • single retransmission • ignore duplicate acks timer • ignore flow control, retransmissions congestion control triggered by: • timeout events • duplicate acks Transport Layer 3-10
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 ack acknowledges start timer if not previously unacked already running segments • think of timer as for • update what is known oldest unacked to be ACKed segment • start timer if there are • expiration interval: still unacked segments TimeOutInterval Transport Layer 3-11
TCP sender (simplified) data received from application above create segment, seq. # : NextSeqNum pass segment to IP (i.e., “ send ” ) NextSeqNum = NextSeqNum + length(data) if (timer currently not running) Λ start timer wait NextSeqNum = InitialSeqNum for SendBase = InitialSeqNum event timeout retransmit not-yet-acked segment with smallest seq. # start timer ACK received, with ACK field value y if (y > SendBase) { SendBase = y /* SendBase–1: last cumulatively ACKed byte */ if (there are currently not-yet-acked segments) start timer else stop timer } Transport Layer 3-12
TCP: retransmission scenarios Host B Host B Host A Host A SendBase= 92 Seq= 92, 8 bytes of data Seq= 92, 8 bytes of data timeout timeout Seq= 100, 20 bytes of data ACK=100 X ACK=100 ACK=120 Seq= 92, 8 bytes of data Seq= 92, 8 SendBase= 100 bytes of data SendBase= 120 ACK=100 ACK=120 SendBase= 120 lost ACK scenario premature timeout Transport Layer 3-13
TCP: retransmission scenarios Host B Host A Seq= 92, 8 bytes of data Seq= 100, 20 bytes of data timeout ACK=100 X ACK=120 Seq= 120, 15 bytes of data cumulative ACK Transport Layer 3-14
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 arrival of in-order segment with immediately send single cumulative ACK, ACKing both in-order segments expected seq #. One other segment has ACK pending immediately send duplicate ACK , arrival of out-of-order segment higher-than-expect seq. # . indicating seq. # of next expected byte 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-15
TCP fast retransmit time-out period often relatively long: TCP fast retransmit if sender receives 3 • long delay before ACKs for same data resending lost packet detect lost segments ( “ triple duplicate ACKs ” ), ( “ triple duplicate ACKs ” ), via duplicate ACKs. resend unacked segment with smallest • sender often sends many segments back- seq # to-back likely that unacked • if segment is lost, there segment lost, so don ’ t will likely be many wait for timeout duplicate ACKs. Transport Layer 3-16
TCP fast retransmit Host B Host A Seq= 92, 8 bytes of data Seq= 100, 20 bytes of data X ACK=100 timeout ACK=100 ACK=100 ACK=100 Seq= 100, 20 bytes of data fast retransmit after sender receipt of triple duplicate ACK Transport Layer 3-17
Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented transport: TCP services • segment structure 3.2 multiplexing and demultiplexing • reliable data transfer • flow control 3.3 connectionless • connection management transport: UDP 3.6 principles of congestion 3.4 principles of reliable control data transfer 3.7 TCP congestion control Transport Layer 3-18
TCP flow control application process application may remove data from application TCP socket buffers …. OS TCP socket receiver buffers … slower than TCP receiver is delivering (sender is sending) TCP code IP flow control code receiver controls sender, so sender won ’ t overflow receiver ’ s buffer by transmitting from sender too much, too fast receiver protocol stack Transport Layer 3-19
TCP flow control receiver “ advertises ” free buffer space by including to application process rwnd value in TCP header of receiver-to-sender segments buffered data RcvBuffer • RcvBuffer size set via socket options (typical default rwnd free buffer space is 4096 bytes) • many operating systems autoadjust RcvBuffer TCP segment payloads sender limits amount of unacked ( “ in-flight ” ) data to receiver-side buffering receiver ’ s rwnd value guarantees receive buffer will not overflow Transport Layer 3-20
Recommend
More recommend