1 / 21

CENG415 – Communication Networks

CENG415 – Communication Networks. Lectures 9 TCP – Concept - flow control & connection management. Transport layer. We will cover Transport-layer services Multiplexing and demultiplexing Connectionless transport: UDP Principles of reliable data transfer

drago
Download Presentation

CENG415 – Communication Networks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CENG415 – Communication Networks Lectures 9 TCP – Concept - flow control & connection management

  2. Transport layer We will cover • Transport-layer services • Multiplexing and demultiplexing • Connectionless transport: UDP • Principles of reliable data transfer • Connection-oriented transport: TCP • segment structure • reliable data transfer • flow control • connection management • Principles of congestion control • TCP congestion control

  3. TCP overview • RFCs: 793, 1122, 1323, 2018, 2581 • point-to-point: one sender, one receiver • reliable, in-order byte steam: no “message boundaries” • pipelined: TCP congestion and flow control set window size • send & receive buffers • full duplex data: bi-directional data flow in same connection • MSS: maximum segment size • connection-oriented: handshaking (exchange of control msgs) init’s sender, receiver state before data exchange • flow controlled: • sender will not overwhelm receiver

  4. 32 bits source port # dest port # sequence number acknowledgement number head len not used Receive window U A P R S F checksum Urg data pnter Options (variable length) application data (variable length) TCP segment structure URG: urgent data (generally not used) counting by bytes of data (not segments!) ACK: ACK # valid PSH: push data now (generally not used) # bytes rcvr willing to accept RST, SYN, FIN: connection estab (setup, teardown commands) Internet checksum (as in UDP)

  5. time TCP sequence number and ACK Host B Host A User Types ‘C’ Seq. #’s: • byte stream “number” of first byte in segment’s data ACKs: • seq # of next byte expected from other side • cumulative ACK Q: how receiver handles out-of-order segments • A: TCP specification doesn’t say • up to the designer Seq=42, ACK=79, data = ‘C’ host ACKs receipt of ‘C’, echoes back ‘C’ Seq=79, ACK=43, data = ‘C’ Seq=43, ACK=80 simple telnet scenario

  6. TCP round trip Setting TCP timeout value • Should be longer than RTT • if too short: premature timeout and unnecessary retransmissions • if too long: low reaction to segment loss • RTT Varies ! • RTT estimation SampleRTT: measured time from segment transmission until ACK receipt • ignore measurement if packet was retransmitted. • SampleRTT: will vary, we want the estimated RTT “smoother” • average several recent measurements

  7. TCP round trip EstimatedRTT = (1- )*EstimatedRTT + *SampleRTT EstimatedRTT[new] = (1-)* EstimatedRTT[old] + *SampleRTT[new] • Exponential weighted moving average • influence of past sample decreases exponentially fast • typical value:  = 0.125

  8. TCP round trip Setting the retransmission timeout, RTO: • use EstimatedRTT plus “safety margin” • larger variation in EstimatedRTT -> larger safety margin • use a running average, DevRTT, to estimate how much SampleRTT deviates from EstimatedRTT: DevRTT[new] = (1-)* DevRTT[old] +  * |SampleRTT[new]-EstimatedRTT[old]| • (typically,  = 0.25) Note the absolute bars,|...| • Then set a new timeout interval, RTO: • Timeout Interval: RTO = EstimatedRTT + 4 * DevRTT

  9. TCP reliable data transfer • TCP creates rdt service on top of IP’s unreliable service • Pipelined segments • Cumulative acks • TCP uses single retransmission timer • Retransmissions are triggered by: • timeout events • duplicate acks • Initially consider simplified TCP sender: • ignore duplicate acks • ignore flow control, congestion control

  10. TCP sender events data received from app: • Create segment with seq # • seq # is byte-stream number of first data byte in segment • start RTO timer if not already running (think of timer as for oldest unacknowledged segment) • timeout: • retransmit segment that caused timeout • RTO -> 2*RTO temporarily • CongWin = 1 MSS (maximum segment size, e.g. 1420 bytes) • restart RTO timer • Ack rcvd: • If acknowledges previously unacknowledged segments • update what is known to be acknowledged • CongWin =CongWin + MSS • RTO -> original value • start RTO timer if there are outstanding segments

  11. Host A Host B Seq=92, 8 bytes data ACK=100 Seq=92 timeout timeout X loss Seq=92, 8 bytes data ACK=100 time time lost ACK scenario TCP retransmission scenario Host A Host B Seq=92, 8 bytes data Seq=100, 20 bytes data ACK=100 ACK=120 Seq=92, 8 bytes data Sendbase = 100 SendBase = 120 ACK=120 Seq=92 timeout SendBase = 100 SendBase = 120 premature timeout

  12. Host A Host B Seq=92, 8 bytes data ACK=100 timeout Seq=100, 20 bytes data X loss ACK=120 time Cumulative ACK scenario TCP retransmission scenario Sender Buffer 92 100 120 + CongWin + RcvrWin SendBase SendBase = 120 + CongWin + RcvrWin’ SendBase Sender can not send bytes beyond either window

  13. TCP ACK generation

  14. Fast retransmission • 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 4 ACKs for the same data (3 dups), it supposes that segment after Acknowledged data was lost: • fast retransmit:resend segment before timer expires • When resent packet is Acknowledged before a timeout, go to Fast Recovery Mode: • - Halve Sender-Window, "CongWin" • - Increase CongWin by 1 MSS per CongWin bytes sent and Acknowledged .

  15. Fast Retransmit (after 3 duplicate ACKs) (not CongWin limited) Sequence Number (kBytes) Retransmission Retransmission Retransmission.

  16. TCP Flow Control ← byte no. • receive side of TCP connection has a receive buffer: • application process may be slow at reading from buffer • Flow control: sender won’t overflow receiver’s buffer by transmitting too fast • Every TCP header sent by the receiver contains the value of the receiver's Window. This decreases as the incoming data buffer fills up.

  17. TCP Flow Control Last Byte ACKed Last Byte In Buffer ← byte no. LastByteInBuffer – LastByteACKed = spare room in buffer • Receiver advertises spare room by including value of RcvWindow in every segment (TCP header) • Sender limits data to RcvWindow + ACK • guarantees receive buffer doesn’t overflow

  18. TCP connection management TCP sender, receiver establish “connection” before exchanging data segments • initialize TCP variables: • seq. #s, buffers, flow control info (e.g. RcvWindow) • Three way handshake: • client host sends TCP SYN segment to server (client initiate the connection) • specifies initial seq # • TCP option sends client’s MSS (max segment size, usually 1420 bytes) • no data • server host receives SYN (servercontacted by client ) • replies with SYN-ACK segment • server allocates buffers • specifies server initial seq. # • TCP option sends server’s MSS • client receives SYN-ACK • replies with ACK segment • normally has no data

  19. client server close FIN ACK close FIN ACK timed wait closed TCP connection management Closing a connection: client closes socket. Client end system sends TCP FIN control segment to server Server receives FIN, replies with ACK. Closes connection, sends FIN. Or, Host sends a packet with the RES (reset) flag bit set. frequent between Web servers and browsers

  20. TCP connection management TCP client lifecycle

  21. TCP connection management TCP server lifecycle

More Related