1.04k likes | 1.18k Views
Chapter 3 Transport Layer. Computer Networking: A Top Down Approach 4 th edition. Jim Kurose, Keith Ross Addison-Wesley, July 2007. Our goals: understand principles behind transport layer services: Multiplexing, demultiplexing reliable data transfer flow control congestion control.
E N D
Chapter 3Transport Layer Computer Networking: A Top Down Approach 4th edition. Jim Kurose, Keith RossAddison-Wesley, July 2007. Transport Layer
Our goals: understand principles behind transport layer services: Multiplexing, demultiplexing reliable data transfer flow control congestion control learn about transport layer protocols in the Internet: UDP: connectionless transport TCP: connection-oriented transport TCP congestion control Chapter 3: Transport Layer Transport Layer
3.1 Transport-layer services 3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4 Principles of reliable data transfer 3.5 Connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 Principles of congestion control 3.7 TCP congestion control Chapter 3 outline Transport Layer
provide logical communication between app processes running on different hosts transport protocols run in end systems send side: breaks app messages into segments, passes to network layer rcv side: reassembles segments into messages, passes to app layer more than one transport protocol available to apps Internet: TCP and UDP application transport network data link physical application transport network data link physical logical end-end transport Transport services and protocols Transport Layer
reliable, in-order delivery to app: TCP congestion control flow control connection setup unreliable, unordered delivery to app: UDP no-frills extension of “best-effort” IP services not available: delay guarantees bandwidth guarantees application transport network data link physical application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical logical end-end transport Internet transport-layer protocols Transport Layer
3.1 Transport-layer services 3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4 Principles of reliable data transfer 3.5 Connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 Principles of congestion control 3.7 TCP congestion control Chapter 3 outline Transport Layer
Multiplexing at send host: Demultiplexing at rcv host: Multiplexing/demultiplexing delivering received segments to correct socket gathering data from multiple sockets, enveloping data with header (later used for demultiplexing) = socket = process application P4 application application P1 P2 P3 P1 transport transport transport network network network link link link physical physical physical host 3 host 2 host 1 Transport Layer
host receives IP datagrams each datagram has source, destination IP addresses each datagram carries 1 transport-layer segment each segment has source, destination port numbers host uses IP addresses & port numbers to direct segment to appropriate socket, process, application How demultiplexing works: General for TCP and UDP 32 bits source port # dest port # other header fields application data (message) TCP/UDP segment format Transport Layer
Create sockets with port numbers: DatagramSocket mySocket1 = new DatagramSocket(12534); DatagramSocket mySocket2 = new DatagramSocket(12535); UDP socket identified by two-tuple: (dest IP address, dest port number) When host receives UDP segment: checks destination port number in segment directs UDP segment to socket with that port number IP datagrams with different source IP addresses and/or source port numbers directed to same socket Connectionless demultiplexing Transport Layer
P3 P2 P1 P1 SP: 9157 client IP: A DP: 6428 Client IP:B server IP: C SP: 5775 SP: 6428 SP: 6428 DP: 6428 DP: 9157 DP: 5775 Connectionless demux (cont) DatagramSocket serverSocket = new DatagramSocket(6428); SP provides “return address” Transport Layer
TCP socket identified by 4-tuple: source IP address source port number dest IP address dest port number recv host uses all four values to direct segment to appropriate socket Server host may support many simultaneous TCP sockets: each socket identified by its own 4-tuple Web servers have different sockets for each connecting client non-persistent HTTP will have different socket for each request Connection-oriented demux Transport Layer
SP: 9157 SP: 5775 P1 P1 P2 P4 P3 P6 P5 client IP: A DP: 80 DP: 80 Connection-oriented demux (cont) S-IP: B D-IP:C SP: 9157 DP: 80 Client IP:B server IP: C S-IP: A S-IP: B D-IP:C D-IP:C Transport Layer
3.1 Transport-layer services 3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4 Principles of reliable data transfer 3.5 Connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 Principles of congestion control 3.7 TCP congestion control Chapter 3 outline Transport Layer
“no frills,” “bare bones” transport protocol “best effort” service, UDP segments may be: lost delivered out of order to app connectionless: no handshaking between UDP sender, receiver each UDP segment handled independently Why is there a UDP? no connection establishment (which can add delay) simple: no connection state at sender, receiver small segment header no congestion control: UDP can blast away as fast as desired (more later on interaction with TCP!) UDP: User Datagram Protocol [RFC 768] Transport Layer
often used for streaming multimedia apps loss tolerant rate sensitive other UDP uses DNS SNMP (net mgmt) reliable transfer over UDP: add reliability at app layer application-specific error recovery! used for multicast, broadcast in addition to unicast (point-point) UDP: more 32 bits source port # dest port # Length, in bytes of UDP segment, including header checksum length Application data (message) UDP segment format Transport Layer
3.1 Transport-layer services 3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4 Principles of reliable data transfer 3.5 Connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 Principles of congestion control 3.7 TCP congestion control Chapter 3 outline Transport Layer
important in app., transport, link layers top-10 list of important networking topics! characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Principles of Reliable data transfer Transport Layer
important in app., transport, link layers top-10 list of important networking topics! characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Principles of Reliable data transfer Transport Layer
important in app., transport, link layers top-10 list of important networking topics! characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Principles of Reliable data transfer Transport Layer
rdt_send():called from above, (e.g., by app.). Passed data to deliver to receiver upper layer deliver_data():called by rdt to deliver data to upper udt_send():called by rdt, to transfer packet over unreliable channel to receiver rdt_rcv():called when packet arrives on rcv-side of channel Reliable data transfer: getting started send side receive side Transport Layer
Flow Control • End-to-end flow and Congestion control study is complicated by: • Heterogeneous resources (links, switches, applications) • Different delays due to network dynamics • Effects of background traffic • We start with a simple case: hop-by-hop flow control Transport Layer
Hop-by-hop flow control • Approaches/techniques for hop-by-hop flow control • Stop-and-wait • sliding window • Go back N • Selective reject Transport Layer
underlying channel perfectly reliable no bit errors, no loss of packets stop and wait Stop-and-wait: reliable transfer over a reliable channel Sender sends one packet, then waits for receiver response Transport Layer
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 for: error detection receiver feedback: control msgs (ACK,NAK) rcvr->sender channel with bit errors Transport Layer
What happens if ACK/NAK corrupted? sender doesn’t know what happened at receiver! can’t just retransmit: possible duplicate Handling duplicates: sender retransmits current pkt if ACK/NAK garbled sender adds sequence number to each pkt receiver discards (doesn’t deliver up) duplicate pkt Stop-and-wait: Corrupt ACK/NACK Transport Layer
Sender: seq # added to pkt two seq. #’s (0,1) will suffice. Why? must check if received ACK/NAK corrupted Receiver: must check if received packet is duplicate state indicates whether 0 or 1 is expected pkt seq # note: receiver can not know if its last ACK/NAK received OK at sender discussion Transport Layer
New assumption: underlying channel can also lose packets (data or ACKs) checksum, seq. #, ACKs, retransmissions will be of help, but not enough Approach: sender waits “reasonable” amount of time for ACK retransmits if no ACK received in this time if pkt (or ACK) just delayed (not lost): retransmission will be duplicate, but use of seq. #’s already handles this receiver must specify seq # of pkt being ACKed requires countdown timer channels with errors and loss Transport Layer
Stop-and-wait operation Summary • Stop and wait: • sender awaits for ACK to send another frame • sender uses a timer to re-transmit if no ACKs • if ACK is lost: • A sends frame, B’s ACK gets lost • A times out & re-transmits the frame, B receives duplicates • Sequence numbers are added (frame0,1 ACK0,1) • timeout: should be related to round trip time estimates • if too small unnecessary re-transmission • if too large long delays Transport Layer
Stop-and-wait with lost packet/frame Transport Layer
Stop and wait performance • utilization – fraction of time sender busy sending • ideal case (error free) • u=Tframe/(Tframe+2Tprop)=1/(1+2a), a=Tprop/Tframe Transport Layer
example: 1 Gbps link, 15 ms e-e prop. delay, 1KB packet: Performance of stop-and-wait L (packet length in bits) 8kb/pkt T = = = 8 microsec transmit R (transmission rate, bps) 10**9 b/sec • U sender: utilization – fraction of time sender busy sending • 1KB pkt every 30 msec -> 33kB/sec thruput over 1 Gbps link • network protocol limits use of physical resources! Transport Layer
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 Transport Layer
consider losses • assume Timeout ~ 2 Tprop • on average need Nx attempts to get the frame through • p is the probability of frame being in error • Pr[k attempts are made before the frame is transmitted correctly]=pk-1.(1-p) • Nx=kPr[k]=1/(1-p) • u=Tframe/[Nx.(Tframe+2.Tprop)]=1/Nx(1+2a) =[1-p]/(1+2a) • stop and wait is a conservative approach to flow control but is wasteful Transport Layer
Sliding window techniques • TCP is a variant of sliding window • Includes selective reject and Go back N • Allows for outstanding packets without ack • More complex than stop and wait • Need to buffer un-ack’ed packets • Terminology: RR ready to rcv (like ack), REJ reject, SREJ selective reject Transport Layer
Go back N: • Receiver sends RRi to ack all frames up to i-1 (cumulative acks) • REJi to reject frame i & sender has to retransmit frame i and all subsequent frames Transport Layer
Error scenario: • - Error in frame • 1. B receives a frame in error after frame i, B sends REJi+1, A re-transmits i+1 and on • 2. Frame i was lost, A sends i+1, B gets i+1, B sends REJi • 3. Frame i was lost, A does not send frames, A times out and sends RR with P bit set to ask B to ack last received frame, B sends RRi, A re-transmits i. Transport Layer
Error in RR • if A receives a subsequent RR (cumulative ack)o.k. • otherwise similar to 3 above • Error in REJ: similar to 3 above Transport Layer
Selective Reject: • only the frames for which –ve ack was sent are re-transmitted • more efficient than Go back N, but also more complex • needs re-ordering at the receiver Transport Layer
performance: • selective reject: • error-free case: • if the window is w such that the pipe is fullu=100% • otherwise u=w/(1+2a) • in case of error: • if w fills the pipe u=1-p • otherwise u=w(1-p)/(1+2a) Transport Layer
TCP congestion control • transmission control protocol (TCP) is a transport layer protocol for TCP/IP suite • provides congestion control and reliability • header format: • source and destination ports • sequence number • ack number: indicates next octet to be received Transport Layer
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 Pipelined protocols Transport Layer
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 Increase utilization by a factor of 3! Transport Layer
Sender: k-bit seq # in pkt header “window” of up to N, consecutive unack’ed pkts allowed Go-Back-N • ACK(n): ACKs all pkts up to, including seq # n - “cumulative ACK” • may receive duplicate ACKs (see receiver) • timer for each in-flight pkt • timeout(n): retransmit pkt n and all higher seq # pkts in window Transport Layer
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 # GBN: receiver extended FSM default udt_send(sndpkt) rdt_rcv(rcvpkt) && notcurrupt(rcvpkt) && hasseqnum(rcvpkt,expectedseqnum) L Wait extract(rcvpkt,data) deliver_data(data) sndpkt = make_pkt(expectedseqnum,ACK,chksum) udt_send(sndpkt) expectedseqnum++ expectedseqnum=1 sndpkt = make_pkt(expectedseqnum,ACK,chksum) Transport Layer
GBN inaction Transport Layer
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 again limits seq #s of sent, unACKed pkts Selective Repeat Transport Layer
Selective repeat: sender, receiver windows Transport Layer