Computer Networking: A Top-Down Approach PDF

Summary

This document is chapter 3 of a computer networking textbook. It covers the transport layer and its services (e.g. multiplexing and demultiplexing, reliable data transfer, flow control, congestion control). It details the Transport Layer 3 in Computer Networking.

Full Transcript

Chapter 3 Transport Layer A note on the use of these ppt slides: Computer We’re making these slides freely available to all (faculty, students, readers). They’re in PowerPoint form so you see the animations; and can...

Chapter 3 Transport Layer A note on the use of these ppt slides: Computer We’re making these slides freely available to all (faculty, students, readers). They’re in PowerPoint form so you see the animations; and can add, modify, Networking: A and delete slides (including this one) and slide content to suit your needs. They obviously represent a lot of work on our part. In return for use, we only Top Down ask the following:  If you use these slides (e.g., in a class) that you mention their source Approach (after all, we’d like people to use our book!) 6th edition  If you post any slides on a www site, that you note that they are adapted Jim Kurose, Keith from (or perhaps identical to) our slides, and note our copyright of this material. Ross Addison-Wesley Thanks and enjoy! JFK/KWR March 2012 All material copyright 1996-2013 J.F Kurose and K.W. Ross, All Rights Reserved Transport Layer 3-1 Chapter 3: Transport Layer our goals:  understand  learn about Internet principles behind transport layer transport layer protocols: services:  UDP: connectionless  multiplexing, transport demultiplexing  TCP: connection-  reliable data oriented reliable transfer transport  flow control  TCP congestion  congestion control control Transport Layer 3-2 Chapter 3 outline 3.1 transport-layer 3.5 connection- services oriented transport: 3.2 multiplexing TCP and  segment structure demultiplexing  reliable data transfer  flow control 3.3 connectionless  connection transport: UDP management 3.4 principles of 3.6 principles of reliable data congestion control transfer 3.7 TCP congestion control Transport Layer 3-3 Transport services and protocols applicatio n  provide logical transport communication between network data link app processes running on physical different hosts lo gi ca  transport protocols run in enl end systems d- en  send side: breaks app d tr messages into a ns segments, passes to po network layer rt  rcv side: reassembles applicatio n segments into transport network messages, passes to data link physical app layer  more than one transport protocol available to apps  Internet: TCP and UDP Transport Layer 3-4 Transport vs. network layer  network layer: household analogy: logical communication 12 kids in Ann’s house sending letters to 12 between hosts kids in Bill’s house:  transport layer:  hosts = houses logical  processes = kids communication  app messages = letters in envelopes between  transport protocol = processes Ann and Bill who  relies on, demux to in-house enhances, siblings network layer  network-layer services protocol = postal service Transport Layer 3-5 Internet transport-layer protocols applicatio  reliable, in-order n transport delivery (TCP) network data link  congestion control physical network lo network data link gi data link physical  flow control ca physical network l en  connection setup data link d- physical en  unreliable, unordered network d data link tr delivery: UDP a physical ns network po  no-frills extension of data link r physical t network “best-effort” IP data link physical applicatio network n  services not data link physical transport network available: data link physical  delay guarantees  bandwidth guarantees Transport Layer 3-6 Chapter 3 outline 3.1 transport-layer 3.5 connection- services oriented transport: 3.2 multiplexing TCP and  segment structure demultiplexing  reliable data transfer  flow control 3.3 connectionless  connection transport: UDP management 3.4 principles of 3.6 principles of reliable data congestion control transfer 3.7 TCP congestion control Transport Layer 3-7 Multiplexing/ demultiplexing multiplexing at sender: handle data from demultiplexing at receiver: multiple use header info to deliver sockets, add transport received segments to corre header (later used for socket demultiplexing) application application P1 P2 application socket P3 transport P4 process transport network transport network link network link physical link physical physical Transport Layer 3-8 How demultiplexing works  host receives IP datagrams 32 bits  each datagram has source IP address, destination IP source port # dest port # address  each datagram carries one transport-layer segment  each segment has source, other header fields destination port number  host uses IP addresses & port numbers to direct segment to application appropriate socket data (payload) TCP/UDP segment format Transport Layer 3-9 Connectionless demultiplexing  recall: created socket  recall: when creating has host-local port #: datagram to send DatagramSocket mySocket1 into UDP socket, must = new DatagramSocket(12534); specify  destination IP address  destination port #  when host receives IP datagrams with UDP segment: same dest. port #,  checks destination but different source port # in segment IP addresses and/or  directs UDP segment source port numbers to socket with that will be directed to port # same socket at dest Transport Layer 3-10 Connectionless demux: example DatagramSocket serverSocket = new DatagramSocket DatagramSocket (6428); DatagramSocket mySocket2 = new mySocket1 = new DatagramSocket DatagramSocket (9157); application (5775); application P1 application P3 P4 transport transport transport network network link network link physical link physical physical source port: 6428 source port: ? dest port: 9157 dest port: ? source port: 9157 source port: ? dest port: 6428 dest port: ? Transport Layer 3-11 Connection-oriented demux  TCP socket  server host may identified by 4- support many tuple: simultaneous TCP  source IP address sockets:  each socket identified  source port number by its own 4-tuple  dest IP address  web servers have  dest port number different sockets for  demux: receiver each connecting uses all four values client  non-persistent HTTP to direct segment will have different to appropriate socket for each socket request Transport Layer 3-12 Connection-oriented demux: example application application P4 P5 P6 application P3 P2 P3 transport transport transport network network link network link physical link physical server: physical IP address B host: IP source IP,port: B,80 host: IP address dest IP,port: A,9157 source IP,port: C,5775 address A dest IP,port: B,80 C source IP,port: A,9157 dest IP, port: B,80 source IP,port: C,9157 dest IP,port: B,80 three segments, all destined to IP address: B, dest port: 80 are demultiplexed to different sockets Transport Layer 3-13 Connection-oriented demux: example threaded server application application application P4 P3 P2 P3 transport transport transport network network link network link physical link physical server: physical IP address B host: IP source IP,port: B,80 host: IP address dest IP,port: A,9157 source IP,port: C,5775 address A dest IP,port: B,80 C source IP,port: A,9157 dest IP, port: B,80 source IP,port: C,9157 dest IP,port: B,80 Transport Layer 3-14 Chapter 3 outline 3.1 transport-layer 3.5 connection- services oriented transport: 3.2 multiplexing TCP and  segment structure demultiplexing  reliable data transfer  flow control 3.3 connectionless  connection transport: UDP management 3.4 principles of 3.6 principles of reliable data congestion control transfer 3.7 TCP congestion control Transport Layer 3-15 UDP: User Datagram Protocol [RFC 768]  “no frills,” “bare bones”  UDP use: Internet transport protocol  streaming  “best effort” service, multimedia apps UDP segments may be: (loss tolerant, rate  lost sensitive)  delivered out-of-  DNS order to app  connectionless:  SNMP  no handshaking  reliable transfer between UDP sender, receiver over UDP:  each UDP segment  add reliability at handled application layer independently of others  application-specific error recovery! Transport Layer 3-16 UDP: segment header length, in bytes of 32 bits UDP segment, source port # dest port # including header length checksum why is there a UDP?  no connection application establishment (which data can add delay) (payload)  simple: no connection state at sender, receiver  small header size UDP segment format  no congestion control: UDP can blast away as fast as desired Transport Layer 3-17 UDP checksum Goal: detect “errors” (e.g., flipped bits) in transmitted segment sender: receiver:  treat segment  compute checksum of contents, including received segment header fields, as  check if computed sequence of 16-bit checksum equals integers checksum field value:  checksum: addition  NO - error detected (one’s complement sum) of segment  YES - no error contents detected. But maybe  sender puts checksum errors nonetheless? value into UDP More later …. checksum field Transport Layer 3-18 Internet checksum: example example: add two 16-bit integers 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 Note: when adding numbers, a carryout from the most significant bit needs to be added to the result Transport Layer 3-19 Chapter 3 outline 3.1 transport-layer 3.5 connection- services oriented transport: 3.2 multiplexing TCP and  segment structure demultiplexing  reliable data transfer  flow control 3.3 connectionless  connection transport: UDP management 3.4 principles of 3.6 principles of reliable data congestion control transfer 3.7 TCP congestion control Transport Layer 3-20 Principles of reliable data transfer  important in application, transport, link layers  top-10 list of important networking topics!  characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Transport Layer 3-21 Principles of reliable data transfer  important in application, transport, link layers  top-10 list of important networking topics!  characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Transport Layer 3-22 Principles of reliable data transfer  important in application, transport, link layers  top-10 list of important networking topics!  characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Transport Layer 3-23 Reliable data transfer: getting started rdt_send(): called from above, deliver_data(): called (e.g., by app.). Passed data to by rdt to deliver data to deliver to receiver upper layer upper send receive side side udt_send(): called by rdt, rdt_rcv(): called when packet to transfer packet over arrives on rcv-side of channel unreliable channel to receiver Transport Layer 3-24 Reliable data transfer: getting started we’ll:  incrementally develop sender, receiver sides of reliable data transfer protocol (rdt)  consider only unidirectional data transfer  but control info will flow on both directions!  use finite state machines (FSM) to specify sender, receiver event causing state transition actions taken on state transition state: when in this “state” next state state state uniquely 1 event determined by 2 actions next event Transport Layer 3-25 rdt1.0: reliable transfer over a reliable channel  underlying channel perfectly reliable  no bit errors  no loss of packets  separate FSMs for sender, receiver:  sender sends data into underlying channel  receiver reads data from underlying channel Wait for rdt_send(data) Wait for rdt_rcv(packet) call from call from extract (packet,data) above packet = make_pkt(data) below deliver_data(data) udt_send(packet) sender receiver Transport Layer 3-26 rdt2.0: channel with bit errors  underlying channel may flip bits in packet  checksum to detect bit errors  the question: how to recover from errors:  acknowledgements (ACKs): receiver explicitly tells sender that pkt received OK  negative acknowledgements (NAKs): receiver explicitly tells sender that pkt had errors  sender retransmits pkt on receipt of NAK How do humans recover from “errors”  new mechanisms in rdt2.0 (beyond rdt1.0): during conversation?  error detection  receiver feedback: control msgs (ACK,NAK) rcvr->sender Transport Layer 3-27 rdt2.0: channel with bit errors  underlying channel may flip bits in packet  checksum to detect bit errors  the question: how to recover from errors:  acknowledgements (ACKs): receiver explicitly tells sender that pkt received OK  negative acknowledgements (NAKs): receiver explicitly tells sender that pkt had errors  sender retransmits pkt on receipt of NAK  new mechanisms in rdt2.0 (beyond rdt1.0):  error detection  feedback: control msgs (ACK,NAK) from receiver to sender Transport Layer 3-28 rdt2.0: FSM specification rdt_send(data) sndpkt = make_pkt(data, checksum) receiver udt_send(sndpkt) rdt_rcv(rcvpkt) && isNAK(rcvpkt) Wait for Wait for rdt_rcv(rcvpkt) && call from ACK or udt_send(sndpkt) corrupt(rcvpkt) above NAK udt_send(NAK) rdt_rcv(rcvpkt) && isACK(rcvpkt) Wait for  call from below sender rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt,data) deliver_data(data) udt_send(ACK) Transport Layer 3-29 rdt2.0: operation with no errors rdt_send(data) snkpkt = make_pkt(data, checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && isNAK(rcvpkt) Wait for Wait for rdt_rcv(rcvpkt) && call from ACK or udt_send(sndpkt) corrupt(rcvpkt) above NAK udt_send(NAK) rdt_rcv(rcvpkt) && isACK(rcvpkt) Wait for  call from below rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt,data) deliver_data(data) udt_send(ACK) Transport Layer 3-30 rdt2.0: error scenario rdt_send(data) snkpkt = make_pkt(data, checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && isNAK(rcvpkt) Wait for Wait for rdt_rcv(rcvpkt) && call from ACK or udt_send(sndpkt) corrupt(rcvpkt) above NAK udt_send(NAK) rdt_rcv(rcvpkt) && isACK(rcvpkt) Wait for  call from below rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt,data) deliver_data(data) udt_send(ACK) Transport Layer 3-31 rdt2.0 has a fatal flaw! what happens if handling duplicates: ACK/NAK  sender retransmits current pkt if ACK/NAK corrupted? corrupted  sender doesn’t know  sender adds sequence what happened at number to each pkt receiver!  receiver discards (doesn’t deliver up)  can’t just retransmit: duplicate pkt possible duplicate stop and wait sender sends one packet, then waits for receiver response Transport Layer 3-32 rdt2.1: sender, handles garbled ACK/NAKs rdt_send(data) sndpkt = make_pkt(0, data, checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || Wait for Wait for ACK or isNAK(rcvpkt) ) call 0 from NAK 0 udt_send(sndpkt) above rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) rdt_rcv(rcvpkt) && isACK(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt)   Wait for Wait for ACK or call 1 from rdt_rcv(rcvpkt) && NAK 1 above ( corrupt(rcvpkt) || isNAK(rcvpkt) ) rdt_send(data) udt_send(sndpkt) sndpkt = make_pkt(1, data, checksum) udt_send(sndpkt) Transport Layer 3-33 rdt2.1: receiver, handles garbled ACK/NAKs rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq0(rcvpkt) extract(rcvpkt,data) deliver_data(data) sndpkt = make_pkt(ACK, chksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && rdt_rcv(rcvpkt) && (corrupt(rcvpkt) (corrupt(rcvpkt) sndpkt = make_pkt(NAK, chksum) sndpkt = make_pkt(NAK, chksum) udt_send(sndpkt) udt_send(sndpkt) Wait for Wait for rdt_rcv(rcvpkt) && 0 from 1 from rdt_rcv(rcvpkt) && not corrupt(rcvpkt) && below below not corrupt(rcvpkt) && has_seq1(rcvpkt) has_seq0(rcvpkt) sndpkt = make_pkt(ACK, chksum) sndpkt = make_pkt(ACK, chksum) udt_send(sndpkt) udt_send(sndpkt) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq1(rcvpkt) extract(rcvpkt,data) deliver_data(data) sndpkt = make_pkt(ACK, chksum) udt_send(sndpkt) Transport Layer 3-34 rdt2.1: discussion sender: receiver:  seq # added to pkt  must check if  two seq. #’s (0,1) received packet is will suffice. Why? duplicate  must check if  state indicates received ACK/NAK corrupted whether 0 or 1 is  twice as many expected pkt seq # states  state must  note: receiver can “remember” not know if its last whether “expected” ACK/NAK received pkt should have seq # of 0 or 1 OK at sender Transport Layer 3-35 rdt2.2: a NAK-free protocol  same functionality as rdt2.1, using ACKs only  instead of NAK, receiver sends ACK for last pkt received OK  receiver must explicitly include seq # of pkt being ACKed  duplicate ACK at sender results in same action as NAK: retransmit current pkt Transport Layer 3-36 rdt2.2: sender, receiver fragments rdt_send(data) sndpkt = make_pkt(0, data, checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || Wait for Wait for ACK isACK(rcvpkt,1) ) call 0 from above 0 udt_send(sndpkt) sender FSM fragment rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) rdt_rcv(rcvpkt) && && isACK(rcvpkt,0) (corrupt(rcvpkt) ||  has_seq1(rcvpkt)) Wait for receiver FSM 0 from udt_send(sndpkt) below fragment rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq1(rcvpkt) extract(rcvpkt,data) deliver_data(data) sndpkt = make_pkt(ACK1, chksum) udt_send(sndpkt) Transport Layer 3-37 rdt3.0: channels with errors and loss new assumption: approach: sender waits underlying “reasonable” amount channel can also of time for ACK lose packets  retransmits if no ACK received in this time (data, ACKs)  if pkt (or ACK) just  checksum, seq. #, delayed (not lost): ACKs,  retransmission will be retransmissions duplicate, but seq. #’s will be of help … already handles this but not enough  receiver must specify seq # of pkt being ACKed  requires countdown timer Transport Layer 3-38 rdt3.0 sender rdt_send(data) rdt_rcv(rcvpkt) && sndpkt = make_pkt(0, data, checksum) ( corrupt(rcvpkt) || udt_send(sndpkt) isACK(rcvpkt,1) ) rdt_rcv(rcvpkt) start_timer   Wait for Wait for timeout call 0from ACK0 udt_send(sndpkt) above start_timer rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) rdt_rcv(rcvpkt) && isACK(rcvpkt,1) && notcorrupt(rcvpkt) stop_timer && isACK(rcvpkt,0) stop_timer Wait Wait for timeout for call 1 from udt_send(sndpkt) ACK1 above start_timer rdt_rcv(rcvpkt) rdt_send(data)  rdt_rcv(rcvpkt) && sndpkt = make_pkt(1, data, checksum) ( corrupt(rcvpkt) || udt_send(sndpkt) isACK(rcvpkt,0) ) start_timer  Transport Layer 3-39 rdt3.0 in action sender receiver sender receiver send pkt0 pkt0 send pkt0 pkt0 rcv pkt0 rcv pkt0 ack0 send ack0 ack0 send ack0 rcv ack0 rcv ack0 send pkt1 pkt1 send pkt1 pkt1 rcv pkt1 X ack1 send ack1 loss rcv ack1 send pkt0 pkt0 rcv pkt0 timeout ack0 send ack0 resend pkt1 pkt1 rcv pkt1 ack1 send ack1 rcv ack1 send pkt0 pkt0 (a) no loss rcv pkt0 ack0 send ack0 (b) packet loss Transport Layer 3-40 rdt3.0 in action sender receiver sender receiver send pkt0 pkt0 send pkt0 pkt0 rcv pkt0 ack0 send ack0 rcv pkt0 send ack0 rcv ack0 ack0 send pkt1 pkt1 rcv ack0 rcv pkt1 send pkt1 pkt1 rcv pkt1 send ack1 ack1 ack1 send ack1 X loss timeout resend pkt1 pkt1 timeout rcv pkt1 resend pkt1 pkt1 rcv ack1 pkt0 (detect duplicate) rcv pkt1 send pkt0 send ack1 ack1 (detect duplicate) ack1 send ack1 rcv ack1 rcv pkt0 rcv ack1 ack0 send ack0 pkt0 send pkt0 pkt0 send pkt0 rcv pkt0 rcv pkt0 ack0 (detect duplicate) ack0 send ack0 send ack0 (c) ACK loss (d) premature timeout/ delayed ACK Transport Layer 3-41 Performance of rdt3.0  rdt3.0 is correct, but performance stinks  e.g.: 1 Gbps link, 15 ms prop. delay, 8000 bit packet: L 8000 bits Dtrans = R = 9 = 8 microsecs 10 bits/sec  U sender: utilization – fraction of time sender busy sending L/R.008 U = 0.00027 sender = = 30.008 RTT + L / R  if RTT=30 msec, 1KB pkt every 30 msec: 33kB/sec thruput over 1 Gbps link  network protocol limits use of physical resources! Transport Layer 3-42 rdt3.0: stop-and-wait operation sender receiver first packet bit transmitted, t = 0 last packet bit transmitted, t = L / R first packet bit arrives RTT last packet bit arrives, send ACK ACK arrives, send next packet, t = RTT + L / R U L/R.008 sender = = = 0.00027 RTT + L / R 30.008 Transport Layer 3-43 Pipelined protocols pipelining: sender allows multiple, “in- flight”, yet-to-be-acknowledged pkts  range of sequence numbers must be increased  buffering at sender and/or receiver  two generic forms of pipelined protocols: go-Back-N, selective repeat Transport Layer 3-44 Pipelining: increased utilization sender receiver first packet bit transmitted, t = 0 last bit transmitted, t = L / R first packet bit arrives RTT last packet bit arrives, send ACK last bit of 2nd packet arrives, send ACK last bit of 3rd packet arrives, send ACK ACK arrives, send next packet, t = RTT + L / R 3-packet pipelining increases utilization by a factor of 3! U 3L / R.0024 sender = = = 0.00081 RTT + L / R 30.008 Transport Layer 3-45 Pipelined protocols: overview Go-back-N: Selective Repeat:  sender can have up  sender can have up to to N unacked N unack’ed packets in packets in pipeline pipeline  receiver only sends  rcvr sends individual cumulative ack ack for each packet  doesn’t ack packet if there’s a gap  sender has timer  sender maintains for oldest unacked timer for each packet unacked packet  when timer expires,  when timer expires, retransmit only that retransmit all unacked packet unacked packets Transport Layer 3-46 Go-Back-N: sender  k-bit seq # in pkt header  “window” of up to N, consecutive unack’ed pkts allowed  ACK(n): ACKs all pkts up to, including seq # n - “cumulative ACK”  may receive duplicate ACKs (see receiver)  timer for oldest in-flight pkt  timeout(n): retransmit packet n and all higher seq # pkts in window Transport Layer 3-47 GBN: sender extended FSM rdt_send(data) if (nextseqnum < base+N) { sndpkt[nextseqnum] = make_pkt(nextseqnum,data,chksum) udt_send(sndpkt[nextseqnum]) if (base == nextseqnum) start_timer nextseqnum++ }  else refuse_data(data) base=1 nextseqnum=1 timeout start_timer Wait udt_send(sndpkt[base]) rdt_rcv(rcvpkt) udt_send(sndpkt[base+1]) && corrupt(rcvpkt) … udt_send(sndpkt[nextseqnum- 1]) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) base = getacknum(rcvpkt)+1 If (base == nextseqnum) stop_timer else start_timer Transport Layer 3-48 GBN: receiver extended FSM default udt_send(sndpkt) rdt_rcv(rcvpkt) && notcurrupt(rcvpkt)  && hasseqnum(rcvpkt,expectedseqnum) expectedseqnum=1 Wait extract(rcvpkt,data) sndpkt = deliver_data(data) make_pkt(expectedseqnum,ACK,chksum) sndpkt = make_pkt(expectedseqnum,ACK,chksum) udt_send(sndpkt) expectedseqnum++ ACK-only: always send ACK for correctly- received pkt with highest in-order seq #  may generate duplicate ACKs  need only remember expectedseqnum  out-of-order pkt:  discard (don’t buffer): no receiver buffering!  re-ACK pkt with highest in-order seq # Transport Layer 3-49 GBN in action sender window (N=4) sender receiver 012345678 send pkt0 012345678 send pkt1 send pkt2 receive pkt0, send ack0 012345678 send pkt3 Xloss receive pkt1, send ack1 012345678 (wait) receive pkt3, discard, 012345678 rcv ack0, send pkt4 (re)send ack1 012345678 rcv ack1, send pkt5 receive pkt4, discard, (re)send ack1 ignore duplicate ACK receive pkt5, discard, (re)send ack1 pkt 2 timeout 012345678 send pkt2 012345678 send pkt3 012345678 send pkt4 rcv pkt2, deliver, send ack2 012345678 send pkt5 rcv pkt3, deliver, send ack3 rcv pkt4, deliver, send ack4 rcv pkt5, deliver, send ack5 Transport Layer 3-50 Selective repeat  receiver individually acknowledges all correctly received pkts  buffers pkts, as needed, for eventual in- order delivery to upper layer  sender only resends pkts for which ACK not received  sender timer for each unACKed pkt  sender window  N consecutive seq #’s  limits seq #s of sent, unACKed pkts Transport Layer 3-51 Selective repeat: sender, receiver windows Transport Layer 3-52 Selective repeat sender receiver data from above: pkt n in [rcvbase,  if next available seq # rcvbase+N-1] in window, send pkt  send ACK(n) timeout(n):  out-of-order: buffer  resend pkt n, restart  in-order: deliver (also timer deliver buffered, in- ACK(n) in order pkts), advance [sendbase,sendbase+N]: window to next not-  mark pkt n as received yet-received pkt  if n smallest unACKed pkt n in [rcvbase- pkt, advance window N,rcvbase-1] base to next unACKed  ACK(n) seq # otherwise:  ignore Transport Layer 3-53 Selective repeat in action sender window (N=4) sender receiver 012345678 send pkt0 012345678 send pkt1 send pkt2 receive pkt0, send ack0 012345678 send pkt3 Xloss receive pkt1, send ack1 012345678 (wait) receive pkt3, buffer, 012345678 rcv ack0, send pkt4 send ack3 012345678 rcv ack1, send pkt5 receive pkt4, buffer, send ack4 record ack3 arrived receive pkt5, buffer, send ack5 pkt 2 timeout 012345678 send pkt2 012345678 record ack4 arrived 012345678 rcv pkt2; deliver pkt2, record ack5 arrived 012345678 pkt3, pkt4, pkt5; send ack2 Q: what happens when ack2 arrives? Transport Layer 3-54 sender window receiver window Selective repeat: (after receipt) (after receipt) dilemma 0123012 pkt0 pkt1 0123012 0123012 0123012 pkt2 0123012 example: 0123012 0123012 pkt3  seq #’s: 0, 1, 2, 3 0123012 X  window size=3 pkt0 will accept packet with seq number 0 (a) no problem  receiver sees no difference in two receiver can’t see sender side. scenarios! receiver behavior identical in both cases! something’s (very) wrong!  duplicate data accepted as new 0123012 pkt0 in (b) 0123012 pkt1 0123012 0123012 pkt2 0123012 X 0123012 Q: what relationship X between seq # timeout retransmit pkt0 X size and window 0123012 pkt0 will accept packet size to avoid (b) oops! with seq number 0 problem in (b)? Transport Layer 3-55 Chapter 3 outline 3.1 transport-layer 3.5 connection- services oriented transport: 3.2 multiplexing TCP and  segment structure demultiplexing  reliable data transfer  flow control 3.3 connectionless  connection transport: UDP management 3.4 principles of 3.6 principles of reliable data congestion control transfer 3.7 TCP congestion control Transport Layer 3-56 TCP: Overview RFCs: 793,1122,1323, 2018, 2581  point-to-point:  full duplex data:  one sender, one  bi-directional data flow in same connection receiver  MSS: maximum  reliable, in-order segment size byte steam:  connection-oriented:  no “message  handshaking boundaries” (exchange of control msgs) inits sender,  pipelined: receiver state before  TCP congestion and data exchange flow control set  flow controlled: window size  sender will not overwhelm receiver Transport Layer 3-57 TCP segment structure 32 bits URG: urgent data counting (generally not used) source port # dest port # by bytes sequence number of data ACK: ACK # valid acknowledgement number (not segments!) head not PSH: push data now len used UAP R S F receive window (generally not used) # bytes checksum Urg data pointer rcvr willing RST, SYN, FIN: to accept options (variable length) connection estab (setup, teardown commands) application Internet data checksum (variable length) (as in UDP) Transport Layer 3-58 TCP seq. numbers, ACKs outgoing segment from sender sequence numbers: source port # dest port # sequence number  byte stream “number” acknowledgement number of first byte in rwnd segment’s data checksum urg pointer window size acknowledgements: N  seq # of next byte expected from other side sender sequence number space  cumulative ACK sent sent, not- usable not Q: how receiver handles ACKed yet but not usable ACKed yet sent out-of-order segments (“in-flight  A: TCP spec doesn’t ”) incoming segment to sender say, - up to source port # dest port # sequence number implementor acknowledgement number A rwnd checksum urg pointer Transport Layer 3-59 TCP seq. numbers, ACKs 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-60 TCP round trip time, timeout Q: how to set TCP Q: how to estimate timeout value? RTT?  longer than RTT  SampleRTT: measured time from segment  but RTT varies transmission until ACK  too short: receipt premature  ignore timeout, retransmissions unnecessary  SampleRTT will vary, want estimated RTT retransmissions “smoother”  too long: slow  average several reaction to recent measurements, not just current segment loss SampleRTT Transport Layer 3-61 TCP round trip time, timeout EstimatedRTT = (1- )*EstimatedRTT + *SampleRTT  exponential weighted moving average  influence of past sample decreases exponentially fast RTT: gaia.cs.umass.edu to fantasia.eurecom.fr  typical value:  = 0.125 350 RTT: gaia.cs.umass.edu to fantasia.eurecom.fr 300 (milliseconds) RTT 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 SampleRTT Estimated RTT Transport Layer 3-62 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 estimated RTT “safety margin” Transport Layer 3-63 Chapter 3 outline 3.1 transport-layer 3.5 connection- services oriented transport: 3.2 multiplexing TCP and  segment structure demultiplexing  reliable data transfer  flow control 3.3 connectionless  connection transport: UDP management 3.4 principles of 3.6 principles of reliable data congestion control transfer 3.7 TCP congestion control Transport Layer 3-64 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  single sender:  ignore duplicate acks retransmission timer  ignore flow control,  retransmissions congestion control triggered by:  timeout events  duplicate acks Transport Layer 3-65 TCP sender events: data rcvd from app: timeout:  create segment  retransmit segment with seq # that caused timeout  seq # is byte-  restart timer stream number of first data byte in ack rcvd: segment  if ack acknowledges  start timer if not previously unacked already running segments  think of timer as for  update what is oldest unacked known to be ACKed segment  start timer if there  expiration interval: are still unacked TimeOutInterval segments Transport Layer 3-66 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 NextSeqNum = InitialSeqNum wait SendBase = InitialSeqNum for event timeout retransmit not-yet-acked segment with smallest seq. # ACK received, with ACK field value y start timer if (y > SendBase) { SendBase = y if (there are currently not-yet-acked segments) start timer else stop timer } Transport Layer 3-67 TCP: retransmission scenarios Host A Host B Host A Host B SendBase=92 Seq=92, 8 bytes of data Seq=92, 8 bytes of data Seq=100, 20 bytes of data timeo timeo ACK=100 ut ut 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-68 TCP: retransmission scenarios Host A Host B Seq=92, 8 bytes of data Seq=100, 20 bytes of data ACK=100 timeo X ut ACK=120 Seq=120, 15 bytes of data cumulative ACK Transport Layer 3-69 TCP ACK generation [RFC 1122, RFC 2581] event at receiver TCP receiver action arrival of in-order segment with delayed ACK. Wait up to 500ms expected seq #. All data up to for next segment. If no next segment, expected seq # already ACKed send ACK arrival of in-order segment with immediately send single cumulative expected seq #. One other ACK, ACKing both in-order segments segment has ACK pending arrival of out-of-order segment immediately send duplicate ACK, higher-than-expect seq. #. indicating seq. # of next expected byte Gap detected arrival of segment that immediate send ACK, provided that partially or completely fills gap segment starts at lower end of gap Transport Layer 3-70 TCP fast retransmit  time-out period often relatively TCP fast retransmit long: if sender receives  long delay before resending lost packet 3 ACKs for same  detect lost data duplicate (“triple segments via ACKs”), (“triple duplicate duplicate ACKs. ACKs”), resend  sender often sends unacked segment many segments with smallest seq back-to-back #  if segment is lost, there will likely be  likely that unacked many duplicate ACKs. segment lost, so don’t wait for timeout Transport Layer 3-71 TCP fast retransmit Host A Host B Seq=92, 8 bytes of data Seq=100, 20 bytes of data X ACK=100 timeo ACK=100 ut ACK=100 ACK=100 Seq=100, 20 bytes of data fast retransmit after sender receipt of triple duplicate ACK Transport Layer 3-72 Chapter 3 outline 3.1 transport-layer 3.5 connection- services oriented transport: 3.2 multiplexing TCP and  segment structure demultiplexing  reliable data transfer  flow control 3.3 connectionless  connection transport: UDP management 3.4 principles of 3.6 principles of reliable data congestion control transfer 3.7 TCP congestion control Transport Layer 3-73 TCP flow control application application may process remove data from application TCP socket buffers …. TCP socket OS receiver buffers … slower than TCP receiver is TCP delivering code (sender is sending) IP flow control code receiver controls sender, so sender won’t overflow receiver’s buffer by from sender transmitting too much, receiver protocol stack too fast Transport Layer 3-74 TCP flow control  receiver “advertises” free buffer space by to application process including rwnd value in TCP header of receiver- to-sender segments RcvBuffer buffered data  RcvBuffer size set via socket options (typical rwnd free buffer space default is 4096 bytes)  many operating systems autoadjust RcvBuffer TCP segment payloads  sender limits amount of unacked (“in-flight”) data to receiver’s rwnd receiver-side buffering value  guarantees receive buffer will not overflow Transport Layer 3-75 Chapter 3 outline 3.1 transport-layer 3.5 connection- services oriented transport: 3.2 multiplexing TCP and  segment structure demultiplexing  reliable data transfer  flow control 3.3 connectionless  connection transport: UDP management 3.4 principles of 3.6 principles of reliable data congestion control transfer 3.7 TCP congestion control Transport Layer 3-76 Connection Management before exchanging data, sender/receiver “handshake”:  agree to establish connection (each knowing the other willing to establish connection)  agree on connection parameters application application connection state: connection state: ESTAB ESTAB connection variables: connection Variables: seq # client-to- seq # client-to- server server server-to-client server-to- rcvBuffer size client network at server,client network rcvBuffer size at server,client Socket clientSocket = Socket connectionSocket = newSocket("hostname","port welcomeSocket.accept(); number"); Transport Layer 3-77 Agreeing to establish a connection 2-way handshake: Q: will 2-way handshake always work in network?  variable delays Let’s talk ESTAB  retransmitted messages OK (e.g. req_conn(x)) due to ESTAB message loss  message reordering  can’t “see” other side choose x req_conn(x) ESTAB acc_conn(x) ESTAB Transport Layer 3-78 Agreeing to establish a connection 2-way handshake failure scenarios: choose x choose x req_conn(x) req_conn(x) ESTAB ESTAB retransmit acc_conn(x) retransmit acc_conn(x) req_conn( req_conn( x) x) ESTAB ESTAB data(x+1) accept req_conn(x) retransmit data(x+1 data(x+1) ) connection connection client x completes server x completes server client terminat forgets x terminat forgets x es req_conn(x) es ESTAB ESTAB data(x+1) accept half open connection! data(x+1 (no client!) ) Transport Layer 3-79 TCP 3-way handshake client state server state LISTEN LISTEN choose init seq num, x send TCP SYN msg SYNSENT SYNbit=1, Seq=x choose init seq num, y send TCP SYNACK msg, acking SYN SYN RCVD SYNbit=1, Seq=y ACKbit=1; ACKnum=x+1 received SYNACK(x) ESTAB indicates server is live; send ACK for SYNACK; this segment may contain ACKbit=1, ACKnum=y+1 client-to-server data received ACK(y) indicates client is live ESTAB Transport Layer 3-80 TCP 3-way handshake: FSM closed Socket connectionSocket = welcomeSocket.accept();  Socket clientSocket = SYN(x) newSocket("hostname","port number"); SYNACK(seq=y,ACKnum=x+1) create new socket for listen SYN(seq=x) communication back to client SYN SYN rcvd sent SYNACK(seq=y,ACKnum=x+1) ESTAB ACK(ACKnum=y+1) ACK(ACKnum=y+1)  Transport Layer 3-81 TCP: closing a 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-82 TCP: closing a connection client state server state ESTAB ESTAB clientSocket.close() FIN_WAIT_1 can no longer FINbit=1, seq=x send but can receive data CLOSE_WAIT ACKbit=1; ACKnum=x+1 can still FIN_WAIT_2 wait for server send data close LAST_ACK FINbit=1, seq=y TIMED_WAIT can no longer send data ACKbit=1; ACKnum=y+1 timed wait for 2*max CLOSED segment lifetime CLOSED Transport Layer 3-83 Chapter 3 outline 3.1 transport-layer 3.5 connection- services oriented transport: 3.2 multiplexing TCP and  segment structure demultiplexing  reliable data transfer  flow control 3.3 connectionless  connection transport: UDP management 3.4 principles of 3.6 principles of reliable data congestion control transfer 3.7 TCP congestion control Transport Layer 3-84 Principles of congestion control congestion:  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 3-85 Causes/costs of congestion: scenario 1 original data: in throughput:out  two senders, two receivers Host A  one router, infinite unlimited shared buffers output link buffers  output link capacity: R  no retransmission Host B R/2 delay out in R/2 in R/2  maximum per-  large delays as arrival connection throughput: rate, in, approaches R/2 capacity Transport Layer 3-86 Causes/costs of congestion: scenario 2  one router, finite buffers  sender retransmission of timed-out packet  application-layer input = application-layer output:in = out  transport-layer input includes retransmissions :in in ‘ in : original data 'in: original data, plus out retransmitted data Host A finite shared output Host B link buffers Transport Layer 3-87 Causes/costs of congestion: scenario 2 R/2 idealization: perfect knowledge out  sender sends only when router buffers available in R/2 in : original data copy 'in: original data, plus out retransmitted data A free buffer space! finite shared output Host B link buffers Transport Layer 3-88 Causes/costs of congestion: scenario 2 Idealization: known loss packets can be lost, dropped at router due to full buffers  sender only resends if packet known to be lost in : original data copy out 'in: original data, plus retransmitted data A no buffer space! Host B Transport Layer 3-89 Causes/costs of congestion: scenario 2 Idealization: known R/2 loss packets can be lost, dropped at router when sending at R/2, due to full buffers some packets are out  sender only resends if retransmissions but packet known to be asymptotic goodput lost is still R/2 (why?) in R/2 in : original data out 'in: original data, plus retransmitted data A free buffer space! Host B Transport Layer 3-90 Causes/costs of congestion: scenario 2 Realistic: duplicates R/2  packets can be lost, when sending at R/2, dropped at router due some packets are to full buffers out retransmissions including duplicated  sender times out that are delivered! prematurely, sending in R/2 two copies, both of which are delivered in copy timeout out 'in A free buffer space! Host B Transport Layer 3-91 Causes/costs of congestion: scenario 2 Realistic: duplicates R/2  packets can be lost, when sending at R/2, dropped at router due some packets are to full buffers out retransmissions including duplicated  sender times out that are delivered! prematurely, sending in R/2 two copies, both of which are delivered “costs” of congestion:  more work (retrans) for given “goodput”  unneeded retransmissions: link carries multiple copies of pkt  decreasing goodput Transport Layer 3-92 Causes/costs of congestion: scenario 3  four senders Q: what happens as in  multihop paths and in’ increase ? A: as red in’ increases, all  timeout/retransmit arriving blue pkts at upper queue are dropped, blue Host A in : original throughput data out 0 Host B 'in: original data, plus retransmitted data finite shared output link buffers Host D Host C Transport Layer 3-93 Causes/costs of congestion: scenario 3 C/2 out in C/2 ’ another “cost” of congestion:  when packet dropped, any “upstream transmission capacity used for that packet was wasted! Transport Layer 3-94 Approaches towards congestion control two broad approaches towards congestion control: end-end network-assisted congestion congestion control: control:  no explicit  routers provide feedback from feedback to end network systems  congestion inferred  single bit from end-system indicating observed loss, congestion (SNA, delay DECbit, TCP/IP  approach taken by ECN, ATM) TCP  explicit rate for sender to send at Transport Layer 3-95 Case study: ATM ABR congestion control ABR: available bit RM (resource rate: management) cells:  sent by sender, interspersed  “elastic service” with data cells  if sender’s path  bits in RM cell set by “underloaded”: switches (“network-  sender should assisted”)  NI bit: no increase in rate use available (mild congestion) bandwidth  CI bit: congestion  if sender’s path indication congested:  RM cells returned to sender  sender throttled by receiver, with bits intact to minimum guaranteed rate Transport Layer 3-96 Case study: ATM ABR congestion control RM cell data cell  two-byte ER (explicit rate) field in RM cell  congested switch may lower ER value in cell  senders’ send rate thus max supportable rate on path  EFCI bit in data cells: set to 1 in congested switch  if data cell preceding RM cell has EFCI set, receiver sets CI bit in returned RM cell Transport Layer 3-97 Chapter 3 outline 3.1 transport-layer 3.5 connection- services oriented transport: 3.2 multiplexing TCP and  segment structure demultiplexing  reliable data transfer  flow control 3.3 connectionless  connection transport: UDP management 3.4 principles of 3.6 principles of reliable data congestion control transfer 3.7 TCP congestion control Transport Layer 3-98 TCP congestion control: additive increase multiplicative decrease  approach: sender increases 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 additively increase window size … after loss …. until loss occurs (then cut window in half) congestion window size cwnd: TCP sender AIMD saw tooth behavior: probing for bandwidth time Transport Layer 3-99 TCP Congestion Control: details sender sequence number space cwnd TCP sending rate:  roughly: send cwnd bytes, wait last byte last byte RTT for ACKS, ACKed sent, not- sent yet then send more ACKed (“in-flight bytes cwnd  sender limits ”) transmission: rate ~ ~ RTT bytes/sec LastByteSent- < cwnd LastByteAcked  cwnd is dynamic, function of perceived network congestion Transport Layer 3-100 TCP Slow Start Host A Host B  when connection begins, increase rate exponentially until one s e gm ent first loss event: RTT  initially cwnd = 1 MSS two segm en ts  double cwnd every RTT  done by incrementing cwnd for every ACK four segm ents received  summary: initial rate is slow but ramps up exponentially fast time Transport Layer 3-101 TCP: detecting, reacting to loss  loss indicated by timeout:  cwnd set to 1 MSS;  window then grows exponentially (as in slow start) to threshold, then grows linearly  loss indicated by 3 duplicate ACKs: TCP RENO  dup ACKs indicate network capable of delivering some segments  cwnd is cut in half window then grows linearly  TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks) Transport Layer 3-102 TCP: switching from slow start to CA 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 Transport Layer 3-103 Summary: TCP Congestion Control New New ACK! duplicate ACK dupACKcount++ ACK! new ACK new ACK. cwnd = cwnd + MSS (MSS/cwnd) dupACKcount = 0 cwnd = cwnd+MSS transmit new segment(s), as allowed dupACKcount = 0  transmit new segment(s), as allowed cwnd = 1 MSS ssthresh = 64 KB cwnd > ssthresh dupACKcount = 0 slow  congestion start timeout avoidance ssthresh = cwnd/2 cwnd = 1 MSS duplicate ACK timeout dupACKcount = 0 dupACKcount++ ssthresh = cwnd/2 retransmit missing segment cwnd = 1 MSS dupACKcount = 0 retransmit missing segment New timeout ACK! ssthresh = cwnd/2 cwnd = 1 New ACK dupACKcount = 0 retransmit missing segment cwnd = ssthresh dupACKcount == 3 dupACKcount == 3 dupACKcount = 0 ssthresh= cwnd/2 ssthresh= cwnd/2 cwnd = ssthresh + 3 cwnd = ssthresh + 3 retransmit missing segment retransmit missing segment fast recovery duplicate ACK cwnd = cwnd + MSS transmit new segment(s), as allowed Transport Layer 3-104 TCP throughput  avg. TCP thruput as function of window size, RTT?  ignore slow start, assume always data to send  W: window size (measured in bytes) where loss occurs  avg. window size (# in-flight 3 W bytes) is ¾ W avg TCP thruput = bytes/sec  avg. thruput is 3/4W per 4 RTT RTT W W/2 Transport Layer 3-105 TCP Futures: TCP over “long, fat pipes”  example: 1500 byte segments, 100ms RTT, want 10 Gbps throughput  requires W = 83,333 in-flight segments  throughput in terms of segment loss probability, L [Mathis 1997]: 1.22. MSS TCP throughput = RTT L ➜ to achieve 10 Gbps throughput, need a loss rate of L = 2·10-10 – a very small loss rate!  new versions of TCP for high-speed Transport Layer 3-106 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 3-107 Why is TCP fair? two competing sessions:  additive increase gives slope of 1, as throughout increases  multiplicative decrease decreases throughput R proportionally equal bandwidth share Connection 2 throughput loss: decrease window by factor of 2 congestion avoidance: additive increase loss: decrease window by factor of 2 congestion avoidance: additive increase Connection 1 throughput R Transport Layer 3-108 Fairness (more) Fairness and UDP Fairness, parallel TCP  multimedia apps connections  application can open often do not use TCP multiple parallel  do not want rate connections between throttled by two hosts congestion control  web browsers do this  instead use UDP:  e.g., link of rate R with 9  send audio/video existing connections: at constant rate,  new app asks for 1 TCP, gets tolerate packet rate R/10  new app asks for 11 TCPs, gets loss R/2 Transport Layer 3-109 Chapter 3: summary  principles behind transport layer services:  multiplexing, demultiplexing next:  reliable data transfer  leaving the  flow control network “edge”  congestion control (application,  instantiation, transport layers) implementation in the  into the network Internet  UDP “core”  TCP Transport Layer 3-110

Use Quizgecko on...
Browser
Browser