Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 3335: Computer Networks Chapter 3 Transport Layer

Similar presentations


Presentation on theme: "CSCI 3335: Computer Networks Chapter 3 Transport Layer"— Presentation transcript:

1 CSCI 3335: Computer Networks Chapter 3 Transport Layer
Vamsi Paruchuri University of Central Arkansas Some of the material is adapted from J.F Kurose and K.W. Ross

2 Chapter 3 outline 3.1 Transport-layer services
3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4 Principles of reliable data transfer 3.5 Connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 Principles of congestion control 3.7 TCP congestion control Transport Layer

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) inits sender, receiver state before data exchange flow controlled: sender will not overwhelm receiver Transport Layer

4 TCP segment structure source port # dest port # application data
32 bits application data (variable length) sequence number acknowledgement number Receive window Urg data pnter checksum F S R P A U head len not used Options (variable length) 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) Transport Layer

5 TCP segment structure - Quiz
source port # dest port # 32 bits application data (variable length) sequence number acknowledgement number Receive window Urg data pnter checksum F S R P A U head len not used Options (variable length) What is the significance of each field What is TCP Header size What is max Receiver Window Size? Is it large enough? Which field should be larger “Seq#” or “Receive window”? Why? What is the maximum # options? Which flags are set in first message in connection set up? Second message? Third message? Why are initial Seq # set randomly? Flags: SYN, FIN, RESET, PUSH, URG, ACK Transport Layer

6 TCP Header: Flags (6 bits)
Connection establishment/termination SYN – establish; sequence number field contains valid initial sequence number FIN - terminate RESET - abort connection because one side received something unexpected PUSH - sender invoked push to send URG – indicated urgent pointer field is valid; special data - record boundary ACK - indicates Acknowledgement field is valid 3: Transport Layer

7 TCP Header: ACK flag ACK flag – if on then acknowledgement field valid
Once connection established no reason to turn off Acknowledgment field is always in header so acknowledgements are free to send along with data 3: Transport Layer

8 TCP Header: PUSH Intention: use to indicate not to leave the data in a TCP buffer waiting for more data before it is sent Receiver is supposed to interpret as deliver to application immediately; most TCP/IP implementations don’t delay delivery in the first place though 3: Transport Layer

9 TCP Header: Header Length
source port # dest port # 32 bits application data (variable length) sequence number acknowledgement number Receive window Urg data pnter checksum F S R P A U head len not used Options (variable length) Header Length (4 bits) needed because options field make header variable length Expressed in number of 32 bit words = 4 bytes 4 bits field => 4 bytes*24 = 60 bytes; 20 bytes of required header gives 40 bytes possible of options Recall UDP header was 8 bytes 3: Transport Layer

10 Implications of Field Length
32 bits for sequence number (and acknowledgement); 16 bits for advertised window size Implication for maximum window size? Window size <= ½ SequenceNumberSpace Requirement easily satisfied because receiver advertised window field is 16 bits 232 >> 2* 216 Even if increase possible advertised window to 231 that would still be ok 3: Transport Layer

11 Implications of Field Length (cont)
Advertised Window is 16 bit field => maximum window is 64 KB Is this enough to fill the pipeline? Not always Pipeline = delay*BW product 100 ms roundtrip and 100 Mbps => 1.19 MB 3: Transport Layer

12 TCP Header: Common Options
Options used to extend and test TCP Each option is: 1 byte of option kind 1 byte of option length Examples window scale factor: if don’t want to be limited to 216 bytes in receiver advertised window timestamp option: if 32 bit sequence number space will wrap in MSL; add 32 bit timestamp to distinguish between two segments with the same sequence number Maximum Segment Size can be set in SYN packets 3: Transport Layer

13 TCP Connection Management
Three way handshake: Step 1: client end system sends TCP SYN control segment to server specifies initial seq # Step 2: server end system receives SYN, replies with SYNACK control segment ACKs received SYN allocates buffers specifies server-> receiver initial seq. # Step 3: client acknowledges servers initial seq. # Recall: TCP sender, receiver establish “connection” before exchanging data segments initialize TCP variables: seq. #s buffers, flow control info (e.g. RcvWindow) client: connection initiator Socket clientSocket = new Socket("hostname","port number"); server: contacted by client Socket connectionSocket = welcomeSocket.accept(); 3: Transport Layer

14 Three-Way Handshake Active participant (client) Passive participant
(server) SYN, SequenceNum = x SYN + ACK, SequenceNum = y , ACK, Acknowledgment = + 1 Acknowledgment = SequenceNum = x+1 3: Transport Layer

15 Connection Establishment
Both data channels opened at once Three-way handshake used to agree on a set of parameters for this communication channel Initial sequence number for both sides (random) Receiver advertised window size for both sides Optionally, Maximum Segment Size (MSS) for each side; if not specified MSS of 536 bytes is assumed to fit into 576 byte datagram 3: Transport Layer

16 Initial Sequence Numbers
Chosen at random in the sequence number space? Well not really randomly; intention of RFC is for initial sequence numbers to change over time 32 bit counter incrementing every 4 microseconds Vary initial sequence number to avoid packets that are delayed in network from being delivered later and interpreted as a part of a newly established connection (to avoid reincarnations) 3: Transport Layer

17 simple telnet scenario
TCP seq. #’s and ACKs 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 spec doesn’t say, - up to implementor Host A Host B User types ‘C’ Seq=42, ACK=79, data = ‘C’ host ACKs receipt of ‘C’, echoes back ‘C’ Seq=79, ACK=43, data = ‘C’ host ACKs receipt of echoed ‘C’ Seq=43, ACK=80 time simple telnet scenario Transport Layer

18 Connection Termination
Each side of the bi-directional connection may be closed independently 4 messages: FIN message and ACK of that FIN in each direction Each side closes the data channel it can send on One side can be closed and data can continue to flow in the other direction, but not usually FINs consume sequence numbers like SYNs 3: Transport Layer

19 TCP Connection Management (cont.)
Closing a connection: client closes socket: clientSocket.close(); Step 1: client end system sends TCP FIN control segment to server Step 2: server receives FIN, replies with ACK. Closes connection, sends FIN. client FIN server ACK close closed timed wait 3: Transport Layer

20 Chapter 3 outline 3.1 Transport-layer services
3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4 Principles of reliable data transfer 3.5 Connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 Principles of congestion control 3.7 TCP congestion control Transport Layer

21 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 Transport Layer

22 TCP Quiz -2 What are “Cumulative Acks”?
What is advantage of having short time outs? What is advantage of having long time outs? Describe the method(s) TCP uses to detect packet losses. What is Fast Retransmit? Transport Layer

23 TCP sender events: data rcvd from app: Create segment with seq #
seq # is byte-stream number of first data byte in segment start timer if not already running (think of timer as for oldest unacked segment) expiration interval: TimeOutInterval timeout: retransmit segment that caused timeout restart timer Ack rcvd: If acknowledges previously unacked segments update what is known to be acked start timer if there are outstanding segments Transport Layer

24 TCP sender (simplified)
NextSeqNum = InitialSeqNum SendBase = InitialSeqNum loop (forever) { switch(event) event: data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running) start timer pass segment to IP NextSeqNum = NextSeqNum + length(data) event: timer timeout retransmit not-yet-acknowledged segment with smallest sequence number event: ACK received, with ACK field value of y if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) } } /* end of loop forever */ TCP sender (simplified) Comment: SendBase-1: last cumulatively acked byte Example: SendBase-1 = 71; y= 73, so the rcvr wants 73+ ; y > SendBase, so that new data is acked Transport Layer

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

26 TCP retransmission scenarios (more)
Host A Seq=92, 8 bytes data ACK=100 loss timeout Cumulative ACK scenario Host B X Seq=100, 20 bytes data ACK=120 time SendBase = 120 Transport Layer

27 TCP Round Trip Time and Timeout
Q: how to set TCP timeout value? longer than RTT but RTT varies too short: premature timeout unnecessary retransmissions too long: slow reaction to segment loss Q: how to estimate RTT? SampleRTT: measured time from segment transmission until ACK receipt ignore retransmissions SampleRTT will vary, want estimated RTT “smoother” average several recent measurements, not just current SampleRTT Transport Layer

28 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

29 Example RTT estimation:
Transport Layer

30 Fast Retransmit 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 3 ACKs for the same data, it supposes that segment after ACKed data was lost: fast retransmit: resend segment before timer expires Transport Layer

31 X time Figure 3.37 Resending a segment after triple duplicate ACK
Host A Host B Seq=92, 8 bytes data Seq=100, 20 bytes data X Seq=120, 20 bytes data ACK=100 Seq=140, 20 bytes data Seq=160, 20 bytes data ACK=100 ACK=100 ACK=100 timeout resend 2nd segment: Seq=100, 20 bytes data ACK=180 time Figure 3.37 Resending a segment after triple duplicate ACK Transport Layer

32 Chapter 3 outline 3.1 Transport-layer services
3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4 Principles of reliable data transfer 3.5 Connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 Principles of congestion control 3.7 TCP congestion control Transport Layer

33 TCP Flow Control flow control
sender won’t overflow receiver’s buffer by transmitting too much, too fast flow control receive side of TCP connection has a receive buffer: speed-matching service: matching the send rate to the receiving app’s drain rate app process may be slow at reading from buffer Transport Layer

34 TCP Flow control: how it works
rcvr advertises spare room by including value of RcvWindow in segments sender limits unACKed data to RcvWindow guarantees receive buffer doesn’t overflow (suppose TCP receiver discards out-of-order segments) spare room in buffer = RcvWindow = RcvBuffer-[LastByteRcvd - LastByteRead] Transport Layer

35 Chapter 3 outline 3.1 Transport-layer services
3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4 Principles of reliable data transfer 3.5 Connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 Principles of congestion control 3.7 TCP congestion control Transport Layer

36 TCP Connection Management
Three way handshake: Step 1: client host sends TCP SYN segment to server specifies initial seq # no data Step 2: server host receives SYN, replies with SYNACK segment server allocates buffers specifies server initial seq. # Step 3: client receives SYNACK, replies with ACK segment, which may contain data Recall: TCP sender, receiver establish “connection” before exchanging data segments initialize TCP variables: seq. #s buffers, flow control info (e.g. RcvWindow) client: connection initiator Socket clientSocket = new Socket("hostname","port number"); server: contacted by client Socket connectionSocket = welcomeSocket.accept(); Transport Layer

37 TCP Connection Management (cont.)
Closing a connection: client closes socket: clientSocket.close(); Step 1: client end system sends TCP FIN control segment to server Step 2: server receives FIN, replies with ACK. Closes connection, sends FIN. client FIN server ACK close closed timed wait Transport Layer

38 TCP Connection Management (cont.)
Step 3: client receives FIN, replies with ACK. Enters “timed wait” - will respond with ACK to received FINs Step 4: server, receives ACK. Connection closed. client server closing FIN ACK closing FIN ACK timed wait closed closed Transport Layer

39 TCP Connection Management (cont)
TCP server lifecycle TCP client lifecycle Transport Layer

40 Quiz Why does TCP use time outs?
How does timeout impact the performance of TCP? What are pros and cons for short (long) timeouts? How is RTT estimated by TCP? What is need for "flow control" in TCP? Describe "flow control" mechanism. What is the primary cause of congestion? Mention 3 costs of congestion. What is difference between flow and congestion control. Transport Layer

41 Chapter 3 outline 3.1 Transport-layer services
3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4 Principles of reliable data transfer 3.5 Connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 Principles of congestion control 3.7 TCP congestion control Transport Layer

42 Principles of Congestion Control
informally: “too many sources sending too much data too fast for network to handle” different from flow control! manifestations: lost packets (buffer overflow at routers) long delays (queueing in router buffers) a top-10 problem! Transport Layer

43 Causes/costs of congestion: scenario 1
unlimited shared output link buffers Host A lin : original data Host B lout two senders, two receivers one router, infinite buffers no retransmission lout lin : original data large delays when congested maximum achievable throughput Transport Layer

44 Causes/costs of congestion: scenario 2
one router, finite buffers sender retransmission of timed-out packet application-layer input = application-layer output: lin = lout transport-layer input includes retransmissions : lin lin lin : original data lout l'in: original data, plus retransmitted data Host B Host A finite shared output link buffers Transport Layer

45 Congestion scenario 2a: ideal case
lin lout sender sends only when router buffers available lin : original data lout copy l'in: original data, plus retransmitted data Host B free buffer space! Host A finite shared output link buffers Transport Layer

46 Congestion scenario 2b: known loss
packets may get dropped at router due to full buffers sometimes lost sender only resends if packet known to be lost (admittedly idealized) lin : original data lout copy l'in: original data, plus retransmitted data Host B no buffer space! Host A Transport Layer

47 Congestion scenario 2b: known loss
packets may get dropped at router due to full buffers sometimes not lost sender only resends if packet known to be lost (admittedly idealized) R/2 when sending at R/2, some packets are retransmissions but asymptotic goodput is still R/2 lout lin R/2 lin : original data lout l'in: original data, plus retransmitted data Host B free buffer space! Host A Transport Layer

48 Congestion scenario 2c: duplicates
packets may get dropped at router due to full buffers sender times out prematurely, sending two copies, both of which are delivered R/4 lin lout timeout lin lout copy l'in Host B free buffer space! Host A Transport Layer

49 Congestion scenario 2c: duplicates
packets may get dropped at router due to full buffers sender times out prematurely, sending two copies, both of which are delivered R/4 lin lout “costs” of congestion: more work (retrans) for given “goodput” unneeded retransmissions: link carries multiple copies of pkt decreasing goodput Transport Layer

50 Causes/costs of congestion: scenario 3
four senders multihop paths timeout/retransmit l in Q: what happens as and increase ? l in Host A lout lin : original data l'in : original data, plus retransmitted data finite shared output link buffers Host B Transport Layer

51 Causes/costs of congestion: scenario 3
Host A lout Host B another “cost” of congestion: when packet dropped, any “upstream transmission capacity used for that packet was wasted! Transport Layer

52 Approaches towards congestion control
Two broad approaches towards congestion control: end-end congestion control: no explicit feedback from network congestion inferred from end-system observed loss, delay approach taken by TCP network-assisted congestion control: routers provide feedback to end systems single bit indicating congestion (SNA, DECbit, TCP/IP ECN, ATM) explicit rate sender should send at Transport Layer

53 Chapter 3 outline 3.1 Transport-layer services
3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4 Principles of reliable data transfer 3.5 Connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 Principles of congestion control 3.7 TCP congestion control Transport Layer

54 TCP congestion control: additive increase, multiplicative decrease
approach: increase transmission rate (window size), probing for usable bandwidth, until loss occurs additive increase: increase cwnd by 1 MSS every RTT until loss detected multiplicative decrease: cut cwnd in half after loss time cwnd: congestion window size saw tooth behavior: probing for bandwidth Transport Layer

55 TCP Congestion Control: details
How does sender perceive congestion? loss event = timeout or 3 duplicate acks TCP sender reduces rate (cwnd) after loss event three mechanisms: AIMD slow start conservative after timeout events sender limits transmission: LastByteSent-LastByteAcked  cwnd roughly, cwnd is dynamic, function of perceived network congestion rate = cwnd RTT Bytes/sec Transport Layer

56 TCP Slow Start when connection begins, increase rate exponentially until first loss event: 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 A Host B one segment RTT two segments four segments time Transport Layer

57 Refinement: inferring loss
after 3 dup ACKs: cwnd is cut in half window then grows linearly but after timeout event: cwnd instead set to 1 MSS; window then grows exponentially to a threshold, then grows linearly 3 dup ACKs indicates network capable of delivering some segments timeout indicates a “more alarming” congestion scenario Philosophy: Transport Layer

58 Can you identify different phases?
Refinement Q: when should the exponential increase switch to linear? A: when cwnd gets to 1/2 of its value before timeout. Implementation: variable ssthresh on loss event, ssthresh is set to 1/2 of cwnd just before loss event Can you identify different phases? Transport Layer

59 Connection Timeline 3: Transport Layer

60 Summary: TCP Congestion Control
New ACK! congestion avoidance cwnd = cwnd + MSS (MSS/cwnd) dupACKcount = 0 transmit new segment(s), as allowed new ACK . dupACKcount++ duplicate ACK slow start timeout ssthresh = cwnd/2 cwnd = 1 MSS dupACKcount = 0 retransmit missing segment cwnd = cwnd+MSS transmit new segment(s), as allowed new ACK dupACKcount++ duplicate ACK L ssthresh = 64 KB L cwnd > ssthresh timeout ssthresh = cwnd/2 cwnd = 1 MSS dupACKcount = 0 retransmit missing segment ssthresh= cwnd/2 cwnd = ssthresh + 3 retransmit missing segment dupACKcount == 3 timeout ssthresh = cwnd/2 cwnd = 1 dupACKcount = 0 cwnd = ssthresh dupACKcount = 0 New ACK ssthresh= cwnd/2 cwnd = ssthresh + 3 retransmit missing segment dupACKcount == 3 fast recovery cwnd = cwnd + MSS transmit new segment(s), as allowed duplicate ACK Transport Layer

61 TCP throughput what’s the average throughout of TCP as a function of window size and RTT? ignore slow start let W be the window size when loss occurs. when window is W, throughput is W/RTT just after loss, window drops to W/2, throughput to W/2RTT. average throughout: .75 W/RTT Transport Layer

62 TCP Futures: TCP over “long, fat pipes”
example: 1500 byte segments, 100ms RTT, want 10 Gbps throughput requires window size W = 83,333 in-flight segments throughput in terms of loss rate: ➜ L = 2· Wow – a very small loss rate! new versions of TCP for high-speed Transport Layer

63 TCP Fairness fairness goal: if K TCP sessions share same bottleneck link of bandwidth R, each should have average rate of R/K TCP connection 1 bottleneck router capacity R TCP connection 2 Transport Layer

64 TCP is fair two competing sessions:
additive increase gives slope of 1, as throughout increases multiplicative decrease decreases throughput proportionally R equal bandwidth share loss: decrease window by factor of 2 congestion avoidance: additive increase Connection 2 throughput loss: decrease window by factor of 2 congestion avoidance: additive increase Connection 1 throughput R Transport Layer

65 Fairness (more) Fairness and parallel TCP connections Fairness and UDP
nothing prevents app from opening parallel connections between 2 hosts. web browsers do this example: link of rate R supporting 9 connections; new app asks for 1 TCP, gets rate R/10 new app asks for 11 TCPs, gets R/2 ! Fairness and UDP multimedia apps often do not use TCP do not want rate throttled by congestion control instead use UDP: pump audio/video at constant rate, tolerate packet loss Transport Layer

66 Chapter 3: Summary principles behind transport layer services:
multiplexing, demultiplexing reliable data transfer flow control congestion control instantiation and implementation in the Internet UDP TCP Next: leaving the network “edge” (application, transport layers) into the network “core” Transport Layer

67 Netstat netstat –a –n Shows open connections in various states
Example: Active Connections Proto LocalAddr ForeignAddr State TCP : :0 LISTENING TCP : :80 CLOSE_WAIT TCP : :22 ESTABLISHED UDP :1070 *:*

68 Quiz What are three primary mechanisms of TCP Congestion Control
What are the two TCP loss events How many packets are transmitted in the first 4 RTT durations after a TCP connection is established. Transport Layer

69 Quiz (cont) Transport Layer


Download ppt "CSCI 3335: Computer Networks Chapter 3 Transport Layer"

Similar presentations


Ads by Google