General

Chapter 3 Transport Layer

Description
Chapter 3 Transport Layer All material copyright J.F Kurose and K.W. Ross, All Rights Reserved Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March
Categories
Published
of 79
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Transcript
Chapter 3 Transport Layer All material copyright J.F Kurose and K.W. Ross, All Rights Reserved Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 Transport Layer 3-1 Chapter 3: Transport Layer our goals: v understand principles behind transport layer services: multiplexing, demultiplexing reliable data transfer flow control congestion control v learn about Internet transport layer protocols: UDP: connectionless transport TCP: connection-oriented reliable transport TCP congestion control Transport Layer 3-2 Chapter 3 outline 3.1 transport-layer services 3.2 multiplexing and demultiplexing 3.3 connectionless transport: UDP 3.4 principles of reliable data transfer 3.5 connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 principles of congestion control 3.7 TCP congestion control Transport Layer 3-3 Transport services and protocols v provide logical communication between app processes running on different hosts v 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 v more than one transport protocol available to apps Internet: TCP and UDP application transport network data link physical application transport network data link physical Transport Layer 3-4 Transport vs. network layer v network layer: logical communication between hosts v transport layer: logical communication between processes relies on, enhances, network layer services household analogy: 12 kids in Ann s house sending letters to 12 kids in Bill s house: v hosts = houses v processes = kids v app messages = letters in envelopes v transport protocol = Ann and Bill who demux to inhouse siblings v network-layer protocol = postal service Transport Layer 3-5 Internet transport-layer protocols v reliable, in-order delivery (TCP) congestion control flow control connection setup v unreliable, unordered delivery: UDP no-frills extension of best-effort IP v services not available: delay guarantees bandwidth guarantees 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 network data link physical application transport network data link physical Transport Layer 3-6 Chapter 3 outline 3.1 transport-layer services 3.2 multiplexing and demultiplexing 3.3 connectionless transport: UDP 3.4 principles of reliable data transfer 3.5 connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 principles of congestion control 3.7 TCP congestion control Transport Layer 3-7 Multiplexing/demultiplexing multiplexing at sender: handle data from multiple sockets, add transport header (later used for demultiplexing) demultiplexing at receiver: use header info to deliver received segments to correct socket application application P3 transport network link P1 P2 transport network link physical application P4 transport network link socket process physical physical Transport Layer 3-8 How demultiplexing works v host receives IP datagrams each datagram has source IP address, destination IP address each datagram carries one transport-layer segment each segment has source, destination port number v host uses IP addresses & port numbers to direct segment to appropriate socket 32 bits source port # dest port # other header fields application data (payload) TCP/UDP segment format Transport Layer 3-9 Connectionless demultiplexing v recall: created socket has host-local port #: DatagramSocket mysocket1 = new DatagramSocket(12534); v recall: when creating datagram to send into UDP socket, must specify destination IP address destination port # v when host receives UDP segment: checks destination port # in segment directs UDP segment to socket with that port # IP datagrams with same dest. port #, but different source IP addresses and/ or source port numbers will be directed to same socket at dest Transport Layer 3-10 Connectionless demux: example DatagramSocket mysocket2 = new DatagramSocket (9157); application P3 transport network link physical DatagramSocket serversocket = new DatagramSocket (6428); application P1 transport network link physical DatagramSocket mysocket1 = new DatagramSocket (5775); application P4 transport network link physical source port: 6428 dest port: 9157 source port:? dest port:? source port: 9157 dest port: 6428 source port:? dest port:? Transport Layer 3-11 Connection-oriented demux v TCP socket identified by 4-tuple: source IP address source port number dest IP address dest port number v demux: receiver uses all four values to direct segment to appropriate socket v server host may support many simultaneous TCP sockets: each socket identified by its own 4-tuple v web servers have different sockets for each connecting client non-persistent HTTP will have different socket for each request Transport Layer 3-12 Connection-oriented demux: example application P3 transport network link physical P4 application P5 transport network link physical P6 server: IP address B application P2 P3 transport network link physical host: IP address A source IP,port: B,80 dest IP,port: A,9157 source IP,port: A,9157 dest IP, port: B,80 three segments, all destined to IP address: B, dest port: 80 are demultiplexed to different sockets source IP,port: C,5775 dest IP,port: B,80 source IP,port: C,9157 dest IP,port: B,80 host: IP address C Transport Layer 3-13 Connection-oriented demux: example threaded server application P3 transport network link physical application P4 transport network link physical server: IP address B application P2 P3 transport network link physical host: IP address A source IP,port: B,80 dest IP,port: A,9157 source IP,port: C,5775 dest IP,port: B,80 host: IP address 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 services 3.2 multiplexing and demultiplexing 3.3 connectionless transport: UDP 3.4 principles of reliable data transfer 3.5 connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 principles of congestion control 3.7 TCP congestion control Transport Layer 3-15 UDP: User Datagram Protocol [RFC 768] v no frills, bare bones Internet transport protocol v best effort service, UDP segments may be: lost delivered out-of-order to app v connectionless: no handshaking between UDP sender, receiver each UDP segment handled independently of others v UDP use: streaming multimedia apps (loss tolerant, rate sensitive) DNS SNMP v reliable transfer over UDP: add reliability at application layer application-specific error recovery! Transport Layer 3-16 UDP: segment header source port # dest port # length 32 bits application data (payload) checksum UDP segment format length, in bytes of UDP segment, including header why is there a UDP? v no connection establishment (which can add delay) v simple: no connection state at sender, receiver v small header size v 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: v treat segment contents, including header fields, as sequence of 16-bit integers v checksum: addition (one s complement sum) of segment contents v sender puts checksum value into UDP checksum field receiver: v compute checksum of received segment v check if computed checksum equals checksum field value: NO - error detected YES - no error detected. But maybe errors nonetheless? More later. Transport Layer 3-18 Checksum Calculation At the sender: At the receiver: Application Data (Payload) FBA4H Application Data (Payload) à SUM 1 st compliment: à CHECKSUM = FBAH à Source Port à Dest Port à Length à Checksum All 1 s No Error Transport Layer 3-19 Internet checksum: When CARRYOUT occurs example: add two 16-bit integers wraparound sum checksum Note: when adding numbers, a carryout from the most significant bit needs to be added to the result Transport Layer 3-20 Chapter 3 outline 3.1 transport-layer services 3.2 multiplexing and demultiplexing 3.3 connectionless transport: UDP 3.4 principles of reliable data transfer 3.5 connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 principles of congestion control 3.7 TCP congestion control Transport Layer 3-21 Principles of reliable data transfer v important in application, transport, link layers top-10 list of important networking topics! v characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Transport Layer 3-22 Principles of reliable data transfer v important in application, transport, link layers top-10 list of important networking topics! v characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Transport Layer 3-23 Principles of reliable data transfer v important in application, transport, link layers top-10 list of important networking topics! v characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Transport Layer 3-24 Reliable data transfer (rdt): v Incrementally develop the sender and receiver sides with reliable data transfer protocol (rdt) v rtd protocol version : Ø rdt1.0: reliable transfer over a reliable channel v underlying channel perfectly reliable no bit errors no loss of packets v no need to provide feedback to sender v no need for the rcv to ask sender to slow down sending rate Ø rdt2.0: channel with bit errors Ø rdt3.0: channels with errors and loss Transport Layer 3-25 rdt2.0: channel with bit errors v underlying channel may flip bits in packet checksum to detect bit errors v 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 v new mechanisms in rdt2.0 (beyond rdt1.0): error detection feedback: control msgs (ACK,NAK) from receiver to sender Transport Layer 3-26 rdt2.0 has a fatal flaw! what happens if ACK/ NAK corrupted? v sender doesn t know what happened at receiver! v can t just retransmit: possible duplicate handling duplicates: v sender retransmits current pkt if ACK/NAK corrupted v sender adds sequence number to each pkt v receiver discards (doesn t deliver up) duplicate pkt stop and wait sender sends one packet, then waits for receiver response Transport Layer 3-27 rdt3.0: channels with errors and loss new assumption: underlying channel can also lose packets (data, ACKs) checksum, seq. #, ACKs, retransmissions will be of help but not enough approach: sender waits reasonable amount of time for ACK v retransmits if no ACK received in this time v if pkt (or ACK) just delayed (not lost): retransmission will be duplicate, but seq. # s already handles this receiver must specify seq # of pkt being ACKed v requires countdown timer Transport Layer 3-28 rdt3.0 in action sender receiver sender receiver send pkt0 rcv ack0 send pkt1 rcv ack1 send pkt0 pkt0 ack0 pkt1 ack1 pkt0 ack0 (a) no loss rcv pkt0 send ack0 rcv pkt1 send ack1 rcv pkt0 send ack0 send pkt0 rcv ack0 send pkt1 timeout resend pkt1 rcv ack1 send pkt0 pkt0 ack0 pkt1 X loss pkt1 ack1 pkt0 ack0 rcv pkt0 send ack0 rcv pkt1 send ack1 rcv pkt0 send ack0 (b) packet loss Transport Layer 3-29 rdt3.0 in action sender send pkt0 rcv ack0 send pkt1 timeout resend pkt1 rcv ack1 send pkt0 pkt0 ack0 pkt1 ack1 X loss pkt1 ack1 pkt0 ack0 receiver rcv pkt0 send ack0 rcv pkt1 send ack1 rcv pkt1 (detect duplicate) send ack1 rcv pkt0 send ack0 sender send pkt0 rcv ack0 send pkt1 timeout resend pkt1 rcv ack1 send pkt0 rcv ack1 send pkt0 pkt0 ack0 pkt1 ack1 pkt1 pkt0 ack1 ack0 pkt0 ack0 receiver rcv pkt0 send ack0 rcv pkt1 send ack1 rcv pkt1 (detect duplicate) send ack1 rcv pkt0 send ack0 rcv pkt0 (detect duplicate) send ack0 (c) ACK loss (d) premature timeout/ delayed ACK Transport Layer 3-30 Performance of rdt3.0 v rdt3.0 is correct, but performance stinks v e.g.: 1 Gbps link, 15 ms prop. delay, 8000 bit packet: D trans = L R 8000 bits = 10 9 = 8 microsecs bits/sec U sender : utilization fraction of time sender busy sending U sender = L / R RTT + L / R = = Therefore, the throughput is 8Kb/30.008ms=267Kb/sec. If 1Kb pkt is transferred in every msec, the throughput is 33Kb/sec over 1 Gbps link. v network protocol limits use of physical resources! Transport Layer 3-31 rdt3.0: stop-and-wait operation first packet bit transmitted, t = 0 last packet bit transmitted, t = L / R sender receiver RTT first packet bit arrives last packet bit arrives, send ACK ACK arrives, send next packet, t = RTT + L / R U sender = L / R RTT + L / R = = Transport Layer 3-32 Pipelined protocols pipelining: sender allows multiple, in-flight, yetto-be-acknowledged pkts range of sequence numbers must be increased buffering at sender and/or receiver v two generic forms of pipelined protocols: go-back-n, selective repeat Transport Layer 3-33 Pipelining: increased utilization first packet bit transmitted, t = 0 last bit transmitted, t = L / R sender receiver RTT ACK arrives, send next packet, t = RTT + L / R first packet bit arrives last packet bit arrives, send ACK last bit of 2 nd packet arrives, send ACK last bit of 3 rd packet arrives, send ACK 3-packet pipelining increases utilization by a factor of 3! U sender = 3L / R RTT + L / R = = Transport Layer 3-34 Pipelined protocols: overview Go-back-N: v sender can have up to N unack ed packets in pipeline v receiver only sends cumulative ack doesn t ack packet if there s a gap v sender has timer for oldest unacked packet when timer expires, retransmit all unacked packets Selective Repeat: v sender can have up to N unack ed packets in pipeline v rcvr sends individual ack for each packet v sender maintains timer for each unacked packet when timer expires, retransmit only that unacked packet Transport Layer 3-35 Go-Back-N: sender v window size N and each k-bit has seq # in pkt header v window of up to N, consecutive unack ed pkts allowed v ACK(n): ACKs all pkts up to, including seq # n - cumulative ACK may receive duplicate ACKs (see receiver) v timer for oldest in-flight pkt v timeout(n): retransmit packet n and all higher seq # pkts in window Transport Layer 3-36 GBN in action sender window (N=4) sender send pkt0 send pkt1 send pkt2 send pkt3 (wait) rcv ack0, send pkt4 rcv ack1, send pkt5 ignore duplicate ACK pkt 2 timeout send pkt2 send pkt3 send pkt4 send pkt5 X loss receiver receive pkt0, send ack0 receive pkt1, send ack1 receive pkt3, discard, (re)send ack1 receive pkt4, discard, (re)send ack1 receive pkt5, discard, (re)send ack1 rcv pkt2, deliver, send ack2 rcv pkt3, deliver, send ack3 rcv pkt4, deliver, send ack4 rcv pkt5, deliver, send ack5 Transport Layer 3-37 Selective repeat v receiver individually acknowledges all correctly received pkts buffers pkts, as needed, for eventual in-order delivery to upper layer v sender only resends pkts for which ACK not received sender timer for each unacked pkt v sender window has N consecutive seq # s limits seq #s of sent, unacked pkts (up-to window size N Transport Layer 3-38 Selective repeat: sender, receiver windows Transport Layer 3-39 Selective repeat (how it works?) sender data from above: v if next available seq # in window, send pkt timeout(n): v resend pkt n, restart timer ACK(n) in [sendbase,sendbase+n]: v mark pkt n as received v if n smallest unacked pkt, advance window base to next unacked seq # receiver pkt n in [rcvbase, rcvbase+n-1] v send ACK(n) v out-of-order: buffer v in-order: deliver (also deliver buffered, in-order pkts), advance window to next not-yet-received pkt pkt n in [rcvbase-n,rcvbase-1] v ACK(n) otherwise: v ignore Transport Layer 3-40 Selective repeat in action sender window (N=4) sender send pkt0 send pkt1 send pkt2 send pkt3 (wait) rcv ack0, send pkt4 rcv ack1, send pkt5 record ack3 arrived pkt 2 timeout send pkt2 record ack4 arrived record ack5 arrived X loss receiver receive pkt0, send ack0 receive pkt1, send ack1 receive pkt3, buffer, send ack3 receive pkt4, buffer, send ack4 receive pkt5, buffer, send ack5 rcv pkt2; deliver pkt2, pkt3, pkt4, pkt5; send ack2 Q: what happens when ack2 arrives? Transport Layer 3-41 Chapter 3 outline 3.1 transport-layer services 3.2 multiplexing and demultiplexing 3.3 connectionless transport: UDP 3.4 principles of reliable data transfer 3.5 connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 principles of congestion control 3.7 TCP congestion control Transport Layer 3-42 TCP: Overview RFCs: 793,1122,1323, 2018, 2581 v point-to-point: one sender, one receiver v reliable, in-order byte steam: no message boundaries v pipelined: TCP congestion and flow control set window size v full duplex data: bi-directional data flow in same connection MSS: maximum segment size E.g. File size=500kb, MSS=1KB, so TCP construct 500 segments out of data stream. v connection-oriented: handshaking (exchange of control msgs) inits sender, receiver state before data exchange v flow controlled: sender will not overwhelm receiver Transport Layer 3-43 TCP segment structure URG: urgent data (generally not used) ACK: ACK # valid PSH: push data now (generally not used) RST, SYN, FIN: connection estab (setup, teardown commands) Internet checksum (as in UDP) 32 bits source port # dest port # head len sequence number acknowledgement number not used U A P R S F checksum receive window application data (variable length) Urg data pointer options (variable length) counting by bytes of data (not segments!) # bytes rcvr willing to accept Transport Layer 3-44 TCP seq. numbers, ACKs sequence numbers (seq #): byte stream number of first byte in segment s data acknowledgements (ACK): seq # of next byte expected from other side cumulative ACK Q: how receiver handles out-of-order segments A: TCP spec doesn t say, - up to implementor E.g. use GBN or SR method outgoing segment from sender source port # dest port # sequence number acknowledgement number rwnd checksum sent ACKed urg pointer window size N sender sequence number space sent, notyet usable not ACKed but not usable ( inflight ) yet sent incoming segment to sender source port # dest port # sequence number acknowledgement number A rwnd checksum urg pointer Transport Layer 3-45 TCP seq. numbers, ACKs Host A Host B User types C host ACKs receipt of echoed C Seq=42, ACK=79, data = C Seq=79, ACK=43, data = C Seq=43, ACK=80 host ACKs receipt of C, echoes back C simple telnet scenario Transport Layer 3-46 TCP round trip time, timeout Q: how to set TCP timeout value? v longer than RTT but RTT varies v too short: premature timeout, unnecessary retransmissions v too long: slow reaction to segment loss Q: how to estimate RTT? v SampleRTT: measured time from segment transmission until ACK receipt ignore retransmissions v SampleRTT will vary, want estimated RTT smoother average several recent measurements, not just current SampleRTT Transport Layer 3-47 Chapter 3 outline 3.1 transport-layer services 3.2 multiplexing and demultiplexing 3.3 connectionless transport: UDP 3.4 principles of reliable data transfer 3.5 connection-oriented transport: TCP segment structure reliable data transfer flow control connection management 3.6 principles of congestion control 3.7 TCP congestion control Transport Layer 3-48 TCP reliable data transfer (rdt) v TCP creates rdt service on top of IP s unreliable service by implementing: pipelined segments cumulative acks single retransmission timer (refer to timer for oldest in-flight pkt) let s initially consider simplified TCP sender: ignore duplicate
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks