🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

TCP segment structure 32 bits ACK: seq # of next expected byte; A bit: this is an ACK length (of TCP header) Internet checksum C, E: congestion notification TCP options RST, SYN, FIN: connection management source port # dest port # sequence number acknowledgement number head not len used C EUA...

TCP segment structure 32 bits ACK: seq # of next expected byte; A bit: this is an ACK length (of TCP header) Internet checksum C, E: congestion notification TCP options RST, SYN, FIN: connection management source port # dest port # sequence number acknowledgement number head not len used C EUAP R SF checksum segment seq #: counting bytes of data into bytestream (not segments!) receive window flow control: # bytes Urg data pointer receiver willing to accept options (variable length) application data (variable length) data sent by application into TCP socket Transport Layer: 3-4 TCP flow control  TCP receiver “advertises” free buffer space in rwnd field in TCP header • RcvBuffer size set via socket options (typical default is 4096 bytes) • many operating systems autoadjust RcvBuffer  sender limits amount of unACKed (“in-flight”) data to received rwnd  guarantees receive buffer will not overflow to application process RcvBuffer rwnd buffered data free buffer space TCP segment payloads TCP receiver-side buffering Transport Layer: 3-20 TCP flow control flow control: # bytes receiver willing to accept  TCP receiver “advertises” free buffer space in rwnd field in TCP header • RcvBuffer size set via socket options (typical default is 4096 bytes) • many operating systems autoadjust RcvBuffer receive window  sender limits amount of unACKed (“in-flight”) data to received rwnd  guarantees receive buffer will not overflow TCP segment format Transport Layer: 3-21 Agreeing to establish a connection 2-way handshake: Let’s talk ESTAB choose x ESTAB OK ESTAB req_conn(x) acc_conn(x) Q: will 2-way handshake always work in network?  variable delays  retransmitted messages (e.g. req_conn(x)) due to message loss  message reordering  can’t “see” other side ESTAB Transport Layer: 3-23 2-way handshake scenarios choose x req_conn(x) ESTAB acc_conn(x) ESTAB data(x+1) ACK(x+1) accept data(x+1) connection x completes No problem! Transport Layer: 3-24 2-way handshake scenarios choose x req_conn(x) ESTAB retransmit req_conn(x) acc_conn(x) ESTAB req_conn(x) client terminates connection x completes server forgets x ESTAB acc_conn(x) Problem: half open connection! (no client) Transport Layer: 3-25 2-way handshake scenarios choose x req_conn(x) ESTAB retransmit req_conn(x) ESTAB retransmit data(x+1) client terminates acc_conn(x) data(x+1) connection x completes accept data(x+1) server forgets x req_conn(x) ESTAB data(x+1) accept data(x+1) Problem: dup data accepted! TCP 3-way handshake Server state serverSocket = socket(AF_INET,SOCK_STREAM) serverSocket.bind((‘’,serverPort)) serverSocket.listen(1) connectionSocket, addr = serverSocket.accept() Client state clientSocket = socket(AF_INET, SOCK_STREAM) LISTEN LISTEN clientSocket.connect((serverName,serverPort)) choose init seq num, x send TCP SYN msg SYNSENT received SYNACK(x) indicates server is live; ESTAB send ACK for SYNACK; this segment may contain client-to-server data SYNbit=1, Seq=x choose init seq num, y send TCP SYNACK SYN RCVD msg, acking SYN SYNbit=1, Seq=y ACKbit=1; ACKnum=x+1 ACKbit=1, ACKnum=y+1 received ACK(y) indicates client is live ESTAB Transport Layer: 3-27 Closing a TCP connection  client, server each close their side of connection • send TCP segment with FIN bit = 1  respond to received FIN with ACK • on receiving FIN, ACK can be combined with own FIN  simultaneous FIN exchanges can be handled Transport Layer: 3-29 TCP congestion control: AIMD  approach: senders can increase sending rate until packet loss (congestion) occurs, then decrease sending rate on loss event Additive Increase Multiplicative Decrease increase sending rate by 1 maximum segment size every RTT until loss detected TCP sender Sending rate cut sending rate in half at each loss event AIMD sawtooth behavior: probing for bandwidth time Transport Layer: 3-45 TCP AIMD: more Multiplicative decrease detail: sending rate is  Cut in half on loss detected by triple duplicate ACK (TCP Reno)  Cut to 1 MSS (maximum segment size) when loss detected by timeout (TCP Tahoe) Why AIMD?  AIMD – a distributed, asynchronous algorithm – has been shown to: • optimize congested flow rates network wide! • have desirable stability properties Transport Layer: 3-46 TCP congestion control: details sender sequence number space cwnd last byte ACKed sent, but notyet ACKed (“in-flight”) available but not used last byte sent TCP sending behavior:  roughly: send cwnd bytes, wait RTT for ACKS, then send more bytes TCP rate ~ ~ cwnd bytes/sec RTT  TCP sender limits transmission: LastByteSent- LastByteAcked <  cwnd is dynamically adjusted in response to observed network congestion (implementing TCP congestion control) cwnd Transport Layer: 3-47 TCP slow start • initially cwnd = 1 MSS • double cwnd every RTT • done by incrementing cwnd for every ACK received  summary: initial rate is slow, but ramps up exponentially fast Host B RTT  when connection begins, increase rate exponentially until first loss event: Host A time Transport Layer: 3-48 TCP: from slow start to congestion avoidance Q: when should the exponential increase switch to linear? A: when cwnd gets to 1/2 of its value before timeout. X Implementation:  variable ssthresh  on loss event, ssthresh is set to 1/2 of cwnd just before loss event * Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/ Transport Layer: 3-49 Summary: TCP congestion control duplicate ACK dupACKcount++ L cwnd = 1 MSS ssthresh = 64 KB dupACKcount = 0 slow start timeout ssthresh = cwnd/2 cwnd = 1 MSS dupACKcount = 0 retransmit missing segment dupACKcount == 3 ssthresh= cwnd/2 cwnd = ssthresh + 3 retransmit missing segment New ACK! new ACK cwnd = cwnd + MSS (MSS/cwnd) dupACKcount = 0 transmit new segment(s), as allowed . new ACK cwnd = cwnd+MSS dupACKcount = 0 transmit new segment(s), as allowed cwnd > ssthresh L timeout ssthresh = cwnd/2 cwnd = 1 MSS dupACKcount = 0 retransmit missing segment timeout ssthresh = cwnd/2 cwnd = 1 dupACKcount = 0 retransmit missing segment fast recovery New ACK! congestion avoidance duplicate ACK dupACKcount++ New ACK! New ACK cwnd = ssthresh dupACKcount = 0 dupACKcount == 3 ssthresh= cwnd/2 cwnd = ssthresh + 3 retransmit missing segment duplicate ACK cwnd = cwnd + MSS transmit new segment(s), as allowed Transport Layer: 3-50 Closing a TCP connection client state server state ESTAB ESTAB clientSocket.close() FIN_WAIT_1 FIN_WAIT_2 can no longer send but can receive data FINbit=1, seq=x CLOSE_WAIT ACKbit=1; ACKnum=x+1 wait for server close FINbit=1, seq=y TIMED_WAIT timed wait for 2*max segment lifetime can still send data LAST_ACK can no longer send data ACKbit=1; ACKnum=y+1 CLOSED CLOSED Transport Layer: 3-73

Use Quizgecko on...
Browser
Browser