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

Full Transcript

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

Chapter 3 Transport Layer A note on the use of these ppt slides: We’re making these slides freely available to all (faculty, students, readers). Computer They’re in PowerPoint form so you see the animations; and can add, modify, and delete slides (including this one) and slide content to suit your needs. Networking: A Top They obviously represent a lot of work on our part. In return for use, we only ask the following: Down Approach  If you use these slides (e.g., in a class) that you mention their source (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 Ross from (or perhaps identical to) our slides, and note our copyright of this material. Addison-Wesley March 2012 Thanks and enjoy! JFK/KWR All material copyright 1996-2013 J.F Kurose and K.W. Ross, All Rights Reserved Transport Layer 3-1 Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented services transport: TCP 3.2 multiplexing and  segment structure demultiplexing  reliable data transfer 3.3 connectionless  flow control transport: UDP  connection management 3.4 principles of reliable 3.6 principles of congestion data transfer control Transport Layer 3-2 Transport services and protocols application transport  provide logical communication network data link between app processes physical running on different hosts  transport protocols run in end systems  send side: breaks app messages into segments, passes to network layer  rcv side: reassembles application segments into messages, transport network passes to app layer data link physical  more than one transport protocol available to apps  Internet: TCP and UDP Transport Layer 3-3 Transport vs. network layer  network layer: logical household analogy: communication between hosts 12 kids in Ann’s house sending letters to 12 kids in Bill’s  transport layer: house: logical  hosts = houses communication  processes = kids between processes  app messages = letters in envelopes  relies on, enhances,  transport protocol = Ann network layer and Bill who demux to in- services house siblings  network-layer protocol = postal service Transport Layer 3-4 Internet transport-layer protocols application  reliable, in-order transport network delivery (TCP) data link physical network  congestion control network data link data link physical physical  flow control network data link  connection setup physical network  unreliable, unordered data link physical delivery: UDP network data link physical  no-frills extension of network data link application “best-effort” IP physical network data link transport network data link  services not available: physical physical  delay guarantees  bandwidth guarantees Transport Layer 3-5 Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented services transport: TCP 3.2 multiplexing and  segment structure demultiplexing  reliable data transfer 3.3 connectionless  flow control transport: UDP  connection management 3.4 principles of reliable 3.6 principles of congestion data transfer control 3.7 TCP congestion control Transport Layer 3-6 Multiplexing/demultiplexing multiplexing at sender: handle data from multiple demultiplexing at receiver: sockets, add transport header use header info to deliver (later used for demultiplexing) received segments to correct socket application application P1 P2 application socket P3 transport P4 process transport network transport network link network link physical link physical physical Transport Layer 3-7 How demultiplexing works  host receives IP datagrams 32 bits  each datagram has source IP source port # dest port # address, destination IP address other header fields  each datagram carries one transport-layer segment  each segment has source, application destination port number data  host uses IP addresses & (payload) port numbers to direct segment to appropriate TCP/UDP segment format socket Transport Layer 3-8 Connectionless demultiplexing  recall: created socket has  recall: when creating host-local port #: datagram to send into DatagramSocket mySocket1 UDP socket, must specify = new DatagramSocket(12534);  destination IP address  destination port #  when host receives UDP IP datagrams with same segment: dest. port #, but different  checks destination port # source IP addresses in segment and/or source port numbers will be directed  directs UDP segment to to same socket at dest socket with that port # Transport Layer 3-9 Connectionless demux: example DatagramSocket DatagramSocket serverSocket = new DatagramSocket DatagramSocket mySocket2 = new mySocket1 = new DatagramSocket (6428); DatagramSocket (9157); application (5775); application application P1 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-10 Connection-oriented demux  TCP socket identified  server host may support by 4-tuple: many simultaneous TCP  source IP address sockets:  source port number  each socket identified by  dest IP address its own 4-tuple  dest port number  web servers have  demux: receiver uses different sockets for all four values to direct each connecting client segment to appropriate  non-persistent HTTP will socket have different socket for each request Transport Layer 3-11 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: IP physical address B host: IP source IP,port: B,80 host: IP address A dest IP,port: A,9157 source IP,port: C,5775 address C dest IP,port: B,80 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-12 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: IP physical address B host: IP source IP,port: B,80 host: IP address A dest IP,port: A,9157 source IP,port: C,5775 address C dest IP,port: B,80 source IP,port: A,9157 dest IP, port: B,80 source IP,port: C,9157 dest IP,port: B,80 Transport Layer 3-13 Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented services transport: TCP 3.2 multiplexing and  segment structure demultiplexing  reliable data transfer 3.3 connectionless  flow control transport: UDP  connection management 3.4 principles of reliable 3.6 principles of congestion data transfer control Transport Layer 3-14 UDP: User Datagram Protocol [RFC 768]  “no frills,” “bare bones”  UDP use: Internet transport  streaming multimedia protocol apps (loss tolerant, rate  “best effort” service, sensitive) UDP segments may be:  DNS  lost  reliable transfer over  delivered out-of-order UDP: to app  add reliability at  connectionless: application layer  no handshaking  application-specific error between UDP sender, recovery! receiver  each UDP segment handled independently of others Transport Layer 3-15 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 can data 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-16 UDP checksum Goal: detect “errors” (e.g., flipped bits) in transmitted segment sender: receiver:  treat segment contents,  compute checksum of including header fields, received segment as sequence of 16-bit  check if computed integers checksum equals checksum  checksum: addition field value: (one’s complement sum) of segment  NO - error detected contents  YES - no error detected.  sender puts checksum But maybe errors value into UDP nonetheless? More later checksum field …. Transport Layer 3-17 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-18 Chapter 3 Transport Layer A note on the use of these ppt slides: We’re making these slides freely available to all (faculty, students, readers). Computer They’re in PowerPoint form so you see the animations; and can add, modify, and delete slides (including this one) and slide content to suit your needs. Networking: A Top They obviously represent a lot of work on our part. In return for use, we only ask the following: Down Approach  If you use these slides (e.g., in a class) that you mention their source (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 Ross from (or perhaps identical to) our slides, and note our copyright of this material. Addison-Wesley March 2012 Thanks and enjoy! JFK/KWR All material copyright 1996-2013 J.F Kurose and K.W. Ross, All Rights Reserved Transport Layer 3-1 Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented services transport: TCP 3.2 multiplexing and  segment structure demultiplexing  reliable data transfer 3.3 connectionless  flow control transport: UDP  connection management 3.4 principles of reliable 3.6 principles of congestion data transfer control 3.7 TCP congestion control Transport Layer 3-2 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-3 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-4 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-5 Reliable data transfer: getting started rdt_send(): called from above, deliver_data(): called by (e.g., by app.). Passed data to rdt to deliver data to upper deliver to receiver upper layer 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-6 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 determined 1 event by next event 2 actions Transport Layer 3-7 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-8 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 Howretransmits do humanspkt on receipt from recover of NAK“errors”  new mechanisms in rdt2.0 (beyond rdt1.0):  error detection during conversation?  receiver feedback: control msgs (ACK,NAK) rcvr- >sender Transport Layer 3-9 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-10 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 L call from sender below rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt,data) deliver_data(data) udt_send(ACK) Transport Layer 3-11 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 L call from below rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt,data) deliver_data(data) udt_send(ACK) Transport Layer 3-12 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 L call from below rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt,data) deliver_data(data) udt_send(ACK) Transport Layer 3-13 rdt2.0 has a fatal flaw! what happens if handling duplicates: ACK/NAK corrupted?  sender retransmits  sender doesn’t know current pkt if ACK/NAK what happened at corrupted receiver!  sender adds sequence  can’t just retransmit: number to each pkt possible duplicate  receiver discards (doesn’t deliver up) duplicate pkt stop and wait sender sends one packet, then waits for receiver response Transport Layer 3-14 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) L L 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-15 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) && (corrupt(rcvpkt) rdt_rcv(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-16 rdt2.1: discussion sender: receiver:  seq # added to pkt  must check if received  two seq. #’s (0,1) will packet is duplicate suffice. Why?  state indicates whether 0 or 1 is expected pkt  must check if received seq # ACK/NAK corrupted  note: receiver can not  twice as many states know if its last  state must ACK/NAK received “remember” whether OK at sender “expected” pkt should have seq # of 0 or 1 Transport Layer 3-17 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-18 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) || L 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-19 rdt3.0: channels with errors and loss new assumption: approach: sender waits underlying channel can “reasonable” amount of also lose packets time for ACK (data, ACKs)  retransmits if no ACK  checksum, seq. #, received in this time ACKs, retransmissions  if pkt (or ACK) just delayed (not lost): will be of help … but not enough  retransmission will be duplicate, but seq. #’s already handles this  receiver must specify seq # of pkt being ACKed  requires countdown timer Transport Layer 3-20 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 L L 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) L rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || sndpkt = make_pkt(1, data, checksum) isACK(rcvpkt,0) ) udt_send(sndpkt) start_timer L Transport Layer 3-21 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-22 rdt3.0 in action sender receiver sender receiver send pkt0 pkt0 send pkt0 pkt0 rcv pkt0 send ack0 rcv pkt0 ack0 send ack0 rcv ack0 ack0 send pkt1 pkt1 rcv ack0 rcv pkt1 send pkt1 pkt1 send ack1 rcv pkt1 ack1 ack1 send ack1 X loss timeout resend pkt1 pkt1 rcv pkt1 timeout resend pkt1 pkt1 rcv ack1 (detect duplicate) rcv pkt1 send pkt0 pkt0 send ack1 (detect duplicate) ack1 ack1 send ack1 rcv ack1 rcv pkt0 rcv ack1 send pkt0 ack0 send ack0 send pkt0 pkt0 pkt0 rcv pkt0 rcv pkt0 ack0 (detect duplicate) ack0 send ack0 send ack0 (c) ACK loss (d) premature timeout/ delayed ACK Transport Layer 3-23 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 = = 8 microsecs 109 bits/sec  U sender: utilization – fraction of time sender busy sending U L/R.008 sender = = = 0.00027 RTT + L / R 30.008  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-24 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-25 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-26 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-27 Pipelined protocols: overview Go-back-N: Selective Repeat:  sender can have up to  sender can have up to N N unacked packets in unack’ed packets in pipeline pipeline  receiver only sends  rcvr sends individual ack cumulative ack for each packet  doesn’t ack packet if there’s a gap  sender has timer for  sender maintains timer oldest unacked packet for each unacked packet  when timer expires,  when timer expires, retransmit all unacked retransmit only that packets unacked packet Transport Layer 3-28 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-29 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++ } L 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-30 GBN: receiver extended FSM default udt_send(sndpkt) rdt_rcv(rcvpkt) && notcurrupt(rcvpkt) L && 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-31 GBN in action sender window (N=4) sender receiver 012345678 send pkt0 012345678 send pkt1 012345678 send pkt2 receive pkt0, send ack0 012345678 send pkt3 Xloss receive pkt1, send ack1 (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-32 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-33 Selective repeat: sender, receiver windows Transport Layer 3-34 Selective repeat sender receiver data from above: pkt n in [rcvbase, rcvbase+N-1]  if next available seq # in  send ACK(n) window, send pkt  out-of-order: buffer timeout(n):  in-order: deliver (also  resend pkt n, restart deliver buffered, in-order timer pkts), advance window to next not-yet-received pkt ACK(n) in [sendbase,sendbase+N]:  mark pkt n as received pkt n in [rcvbase-N,rcvbase-1]  ACK(n)  if n smallest unACKed pkt, advance window base otherwise: to next unACKed seq #  ignore Transport Layer 3-35 Selective repeat in action sender window (N=4) sender receiver 012345678 send pkt0 012345678 send pkt1 012345678 send pkt2 receive pkt0, send ack0 012345678 send pkt3 Xloss receive pkt1, send ack1 (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-36 sender window receiver window Selective repeat: (after receipt) (after receipt) dilemma 0123012 pkt0 pkt1 0123012 0123012 pkt2 0123012 example: 0123012 0123012 pkt3 seq #’s: 0, 1, 2, 3 0123012  X 0123012  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 in 0123012 pkt0 (b) 0123012 pkt1 0123012 0123012 pkt2 0123012 X 0123012 Q: what relationship X between seq # size timeout retransmit pkt0 X and window size to 0123012 pkt0 will accept packet avoid problem in (b)? with seq number 0 (b) oops! Transport Layer 3-37 Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented services transport: TCP 3.2 multiplexing and  segment structure demultiplexing  reliable data transfer 3.3 connectionless  flow control transport: UDP  connection management 3.4 principles of reliable 3.6 principles of congestion data transfer control 3.7 TCP congestion control Transport Layer 3-38 TCP: Overview RFCs: 793,1122,1323, 2018, 2581  point-to-point:  full duplex data:  one sender, one receiver  bi-directional data flow  reliable, in-order byte in same connection steam:  MSS: maximum segment size  no “message boundaries”  connection-oriented:  pipelined:  handshaking (exchange 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-39 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-40 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 sent sent, not- usable not Q: how receiver handles ACKed yet ACKed but not usable out-of-order segments (“in- flight”) yet sent 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-41 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-42 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 timeout, unnecessary  SampleRTT will vary, want retransmissions estimated RTT “smoother”  average several recent  too long: slow reaction measurements, not just to segment loss current SampleRTT Transport Layer 3-43 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-44 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 estimated RTT “safety margin” Transport Layer 3-45 Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented services transport: TCP 3.2 multiplexing and  segment structure demultiplexing  reliable data transfer 3.3 connectionless  flow control transport: UDP  connection management 3.4 principles of reliable 3.6 principles of congestion data transfer control 3.7 TCP congestion control Transport Layer 3-46 TCP reliable data transfer  TCP creates rdt service on top of IP’s unreliable service  pipelined segments  cumulative acks let’s initially consider  single retransmission simplified TCP sender: timer  ignore duplicate acks  retransmissions  ignore flow control, triggered by: congestion control  timeout events  duplicate acks Transport Layer 3-47 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-48 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) L start timer NextSeqNum = InitialSeqNum wait SendBase = InitialSeqNum for event timeout retransmit not-yet-acked segment with smallest seq. # start timer ACK received, with ACK field value y if (y > SendBase) { SendBase = y if (there are currently not-yet-acked segments) start timer else stop timer } Transport Layer 3-49 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 timeout timeout 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-50 TCP: retransmission scenarios Host A Host B 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-51 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-52 TCP fast retransmit  time-out period often relatively long: TCP fast retransmit  long delay before if sender receives 3 resending lost packet ACKs for same data  detect lost segments (“triple (“triple duplicate duplicate ACKs”), ACKs”), via duplicate ACKs. resend unacked  sender often sends segment with smallest 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-53 TCP fast retransmit Host A Host B 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-54 Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented services transport: TCP 3.2 multiplexing and  segment structure demultiplexing  reliable data transfer 3.3 connectionless  flow control transport: UDP  connection management 3.4 principles of reliable 3.6 principles of congestion data transfer control 3.7 TCP congestion control Transport Layer 3-55 TCP flow control application application may process remove data from application TCP socket buffers …. TCP socket OS 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-56 TCP flow control  receiver “advertises” free buffer space by including to application process rwnd value in TCP header of receiver-to-sender segments RcvBuffer buffered data  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-57 Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented services transport: TCP 3.2 multiplexing and  segment structure demultiplexing  reliable data transfer 3.3 connectionless  flow control transport: UDP  connection management 3.4 principles of reliable 3.6 principles of congestion data transfer control 3.7 TCP congestion control Transport Layer 3-58 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: ESTAB connection state: ESTAB connection variables: connection Variables: seq # client-to-server seq # client-to-server server-to-client server-to-client rcvBuffer size rcvBuffer size at server,client at server,client network network Socket clientSocket = Socket connectionSocket = newSocket("hostname","port welcomeSocket.accept(); number"); Transport Layer 3-59 Agreeing to establish a connection 2-way handshake: Q: will 2-way handshake always work in network? Let’s talk ESTAB  variable delays OK ESTAB  retransmitted messages (e.g. req_conn(x)) due to message loss  message reordering choose x req_conn(x)  can’t “see” other side ESTAB acc_conn(x) ESTAB Transport Layer 3-60 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(x) req_conn(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 terminates forgets x terminates forgets x req_conn(x) ESTAB ESTAB data(x+1) accept half open connection! data(x+1) (no client!) Transport Layer 3-61 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-62 TCP 3-way handshake: FSM closed Socket connectionSocket = welcomeSocket.accept(); L Socket clientSocket = SYN(x) newSocket("hostname","port number"); SYNACK(seq=y,ACKnum=x+1) create new socket for SYN(seq=x) communication back to client listen SYN SYN rcvd sent SYNACK(seq=y,ACKnum=x+1) ESTAB ACK(ACKnum=y+1) ACK(ACKnum=y+1) L Transport Layer 3-63 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-64 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-65 Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented services transport: TCP 3.2 multiplexing and  segment structure demultiplexing  reliable data transfer 3.3 connectionless  flow control transport: UDP  connection management 3.4 principles of reliable 3.6 principles of congestion data transfer control 3.7 TCP congestion control Transport Layer 3-66 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-67 Causes/costs of congestion: scenario 1 original data: lin throughput: lout  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 lout lin R/2 lin R/2  maximum per-connection  large delays as arrival rate, lin, throughput: R/2 approaches capacity Transport Layer 3-68 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 : l‘in lin lin : original data lout l'in: original data, plus retransmitted data Host A finite shared output Host B link buffers Transport Layer 3-69 Causes/costs of congestion: scenario 2 R/2 idealization: perfect knowledge lout  sender sends only when router buffers available lin R/2 lin : original data lout copy l'in: original data, plus retransmitted data A free buffer space! finite shared output Host B link buffers Transport Layer 3-70 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 lin : original data lout copy l'in: original data, plus retransmitted data A no buffer space! Host B Transport Layer 3-71 Causes/costs of congestion: scenario 2 Idealization: known loss R/2 packets can be lost, dropped at router due when sending at R/2, some packets are lout to full buffers retransmissions but sender only resends if asymptotic goodput  is still R/2 (why?) packet known to be lost lin R/2 lin : original data lout l'in: original data, plus retransmitted data A free buffer space! Host B Transport Layer 3-72 Causes/costs of congestion: scenario 2 Realistic: duplicates R/2  packets can be lost, dropped at router due to full buffers when sending at R/2, some packets are lout  sender times out prematurely, retransmissions sending two copies, both of including duplicated that are delivered! which are delivered lin R/2 lin timeout copy l'in lout A free buffer space! Host B Transport Layer 3-73 Causes/costs of congestion: scenario 2 Realistic: duplicates R/2  packets can be lost, dropped at router due to full buffers when sending at R/2, some packets are lout  sender times out prematurely, retransmissions sending two copies, both of including duplicated that are delivered! which are delivered lin R/2 “costs” of congestion:  more work (retrans) for given “goodput”  unneeded retransmissions: link carries multiple copies of pkt  decreasing goodput Transport Layer 3-74 Causes/costs of congestion: scenario 3  four senders Q: what happens as lin and lin’ increase ?  multihop paths A: as red lin’ increases, all arriving  timeout/retransmit blue pkts at upper queue are dropped, blue throughput g 0 Host A lin : original data lout Host B l'in: original data, plus retransmitted data finite shared output link buffers Host D Host C Transport Layer 3-75 Causes/costs of congestion: scenario 3 C/2 lout lin’ C/2 another “cost” of congestion:  when packet dropped, any “upstream transmission capacity used for that packet was wasted! Transport Layer 3-76 Approaches towards congestion control two broad approaches towards congestion control: end-end congestion network-assisted control: congestion control:  no explicit feedback  routers provide from network feedback to end systems  congestion inferred  single bit indicating from end-system congestion (SNA, observed loss, delay DECbit, TCP/IP ECN,  approach taken by ATM) TCP  explicit rate for sender to send at Transport Layer 3-77 Case study: ATM ABR congestion control ABR: available bit rate: RM (resource management)  “elastic service” cells:  if sender’s path  sent by sender, interspersed “underloaded”: with data cells  sender should use  bits in RM cell set by switches available bandwidth (“network-assisted”)  if sender’s path  NI bit: no increase in rate congested: (mild congestion)  sender throttled to  CI bit: congestion minimum guaranteed indication rate  RM cells returned to sender by receiver, with bits intact Transport Layer 3-78 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-79 Chapter 3 outline 3.1 transport-layer 3.5 connection-oriented services transport: TCP 3.2 multiplexing and  segment structure demultiplexing  reliable data transfer 3.3 connectionless  flow control transport: UDP  connection management 3.4 principles of reliable 3.6 principles of congestion data transfer control 3.7 TCP congestion control Transport Layer 3-80 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 after loss additively increase window size … …. 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-81 TCP Congestion Control: details sender sequence number space cwnd TCP sending rate:  roughly: send cwnd bytes, wait RTT for last byte last byte ACKS, then send ACKed sent, not- yet ACKed sent more bytes (“in- flight”) cwnd  sender limits transmission: rate ~ ~ RTT bytes/sec LastByteSent- < cwnd LastByteAcked  cwnd is dynamic, function of perceived network congestion Transport Layer 3-82 TCP Slow Start Host A Host B  when connection begins, increase rate exponentially until first loss event: RTT  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 time Transport Layer 3-83 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-84 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-85 Summary: TCP Congestion Control New New ACK! ACK! new ACK duplicate ACK dupACKcount++ new ACK. cwnd = cwnd + MSS (MSS/cwnd) dupACKcount = 0 cwnd = cwnd+MSS transmit new segment(s), as allowed dupACKcount = 0 L transmit new segment(s), as allowed cwnd = 1 MSS ssthresh = 64 KB cwnd > ssthresh dupACKcount = 0 slow L 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 ACK! timeout ssthresh = cwnd/2 cwnd = 1 New ACK dupACKcount = 0 cwnd = ssthresh dupACKcount == 3 dupACKcount == 3 retransmit missing segment 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-86 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 bytes) is ¾ W  avg. thruput is 3/4W per RTT 3 W avg TCP thruput = bytes/sec 4 RTT W W/2 Transport Layer 3-87 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-88 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-89 Why is TCP 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 loss: decrease window by factor of 2 congestion avoidance: additive increase Connection 1 throughput R Transport Layer 3-90 Fairness (more) Fairness and UDP Fairness, parallel TCP  multimedia apps often connections do not use TCP  application can open  do not want rate multiple parallel throttled by congestion connections between two control hosts  instead use UDP:  web browsers do this  send audio/video at constant rate, tolerate  e.g., link of rate R with 9 packet loss existing connections:  new app asks for 1 TCP, gets rate R/10  new app asks for 11 TCPs, gets R/2 Transport Layer 3-91 Chapter 3: summary  principles behind transport layer services:  multiplexing, demultiplexing next:  leaving the  reliable data transfer network “edge”  flow control (application,  congestion control transport layers)  instantiation,  into the network implementation in the “core” Internet  UDP  TCP Transport Layer 3-92

Use Quizgecko on...
Browser
Browser