320 likes | 500 Views
1DT066 Distributed Information Systems Chapter 3 Transport Layer. p rinciples of transport services Internet transport layer protocols: UDP: connectionless transport TCP: connection-oriented reliable transport. Our Goals: Transport Layer.
E N D
1DT066Distributed Information SystemsChapter 3 Transport Layer
principles of transport services Internet transport layer protocols: UDP: connectionless transport TCP: connection-oriented reliable transport Our Goals: Transport Layer TransportLayer
3.1 Internet transport-layer services: UDP & TCP 3.3 connectionless transport: UDP 3.4 principles of reliable data transfer 3.5 connection-oriented transport: TCP segment structure sequence number / ACK retransmission flow control connection establishment Chapter 3, Transport, Outline TransportLayer
unreliable, unordered delivery: UDP no-frills extension of “best-effort” IP reliable, in-order delivery (TCP) congestion control flow control connection setup 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 network data link physical logical end-end transport Internet transport-layer protocols pp 211-217 TransportLayer
TCP vs. UDP pp 224-230
“no frills,”“bare bones” Internet transport protocol each UDP packet (segment) handled independently of others “best effort” service, UDP segments may be: lost delivered out-of-order to app connectionless: no handshaking between UDP sender, receiver UDP: User Datagram Protocol [RFC 768] • UDP is used by: • streaming multimedia apps (loss tolerant, but time sensitive) • name look-up services (e.g. the Domain Name Service protocol) Why? • apps that adds reliability (e.g. remote procedure calls) • apps that use specific error recovery (e.g. TV broadcast). pp 224-230 TransportLayer
no connection establishment before sending data (which adds delay) simple: no connection state at sender, receiver that has to be maintained. no flow control: UDP can blast away segments as fast as desired without waiting for a receiver OK. Why is there a UDP pp 244- TransportLayer
UDP: segment(data packet) header 32 bits source port # dest port # Header checksum length To detect if there are bit errors in the header & data sections Application data (Payload) length, in bytes of UDP segment, including header UDP segment format pp 224-230 TransportLayer
important in application, transport, link layers top-10 list of important networking topics! characteristics of unreliable channel will determine the complexity of a reliable data transfer protocol (rdt) Principles of reliable data transfer pp 230-233 TransportLayer
characteristics of unreliable channel will determine the complexity of a reliable data transfer protocol (rdt) important in application, transport, link layers top-10 list of important networking topics! Principles of reliable data transfer pp 224-230 TransportLayer
characteristics of unreliable channel will determine the complexity of a reliable data transfer protocol (rdt) important in application, transport, link layers top-10 list of important networking topics! Principles of reliable data transfer pp 224-230 TransportLayer
pkt0 pkt0 ack0 ack0 pkt1 pkt1 pkt1 X loss ack1 ack1 pkt0 pkt0 timeout resend pkt1 ack0 ack0 Example of a Reliable Data Transfer Protocol: Packet Loss receiver receiver sender sender send pkt0 send pkt0 rcv pkt0 rcv pkt0 send ack0 send ack0 rcv ack0 rcv ack0 send pkt1 send pkt1 rcv pkt1 send ack1 rcv ack1 send pkt0 rcv pkt0 send ack0 rcv pkt1 send ack1 rcv ack1 send pkt0 rcv pkt0 (a) no loss send ack0 (b) packet loss pp 238-241 TransportLayer
Example of a Reliable Data Transfer Protocol: Ack loss pkt0 pkt0 pkt0 ack0 ack0 pkt1 pkt1 pkt1 pkt1 ack1 ack1 ack1 X loss pkt0 timeout resend pkt1 timeout resend pkt1 send ack1 ack0 ack0 rcv ack1 ack0 send pkt0 pkt0 rcv pkt0 rcv pkt0 send ack0 (detect duplicate) send ack0 rcv ack1 send pkt0 ack1 receiver sender receiver sender send pkt0 rcv pkt0 send pkt0 send ack0 rcv pkt0 rcv ack0 send ack0 send pkt1 rcv ack0 rcv pkt1 send pkt1 send ack1 rcv pkt1 send ack1 rcv pkt1 (detect duplicate) rcv pkt1 (detect duplicate) send ack1 rcv ack1 send pkt0 rcv pkt0 send ack0 (d) premature timeout/ delayed ACK (c) ACK loss pp 238-241 TransportLayer
stop-and-wait operation sender receiver first packet bit transmitted, t = 0 last packet bit transmitted, t = L / R first packet bit arrives Round Trip Time=RTT last packet bit arrives, send ACK ACK arrives, send next packet, t = RTT + L / R pp 241-244 TransportLayer
pipelining: sender allows multiple, “in-flight”, yet-to-be-acknowledged packets 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 pp 244- TransportLayer
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! pp 241-244 TransportLayer
Go-back-N: sender can have up to N un-acked packets in pipeline Receiver sends a cumulative ack Doesn’t ack packet if there’s a gap sender has timer for oldest un-acked packet when timer expires, retransmit all un-acked packets Selective Repeat: sender can have up to N unack’ed packets in pipeline receiver sends individual ack for each packet sender maintains timer for each un-acked packet when timer expires, retransmit only that unacked packet Pipelined protocols: overview pp 244-251 TransportLayer
k-bit seq # in pkt header “window” of up to N, consecutive unack’ed pkts allowed Go-Back-N: sender • ACK(n): ACKs all pkts up to, including seq # n - “cumulative ACK” • may receive duplicate ACKs (see next slide) • timer for oldest in-flight pkt • timeout(n): retransmit packet n and all higher seq # pkts in window pp 244-251 TransportLayer
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 GBN in action sender receiver sender window (N=4) send pkt0 send pkt1 send pkt2 send pkt3 (wait) receive pkt0, send ack0 receive pkt1, send ack1 receive pkt3, discard, (re)send ack1 X loss rcv ack0, send pkt4 rcv ack1, send pkt5 0 1 2 3 4 5 6 7 8 receive pkt4, discard, (re)send ack1 ignore duplicate ACK receive pkt5, discard, (re)send ack1 pkt 2 timeout send pkt2 send pkt3 send pkt4 send pkt5 rcv pkt2, deliver, send ack2 rcv pkt3, deliver, send ack3 rcv pkt4, deliver, send ack4 rcv pkt5, deliver, send ack5 pp 244-251 TransportLayer
full duplex data: bi-directional data flow in same connection MSS: maximum segment size connection-oriented: handshaking (exchange of control msgs) inits sender, receiver state before data exchange flow controlled: sender will not overwhelm receiver point-to-point: one sender, one receiver reliable, in-order byte steam: no “message boundaries” pipelined: TCP congestion and flow control set window size TCP: Overview RFCs: 793,1122,1323, 2018, 2581 pp 256-259 TransportLayer
TCP segment structure 32 bits URG: urgent data (generally not used) counting by bytes of data (not segments!) source port # dest port # sequence number ACK bit set: ACK seq. novalid acknowledgement number head len not used receive window U A P R S F PSH: push data now (generally not used) # bytes receiver willing to accept checksum Urg data pointer RST, SYN, FIN: connection establishment bits(setup, teardown commands) options (variable length) application data (variable length) Checksum (to detect erros) pp 259-261 TransportLayer
sequence numbers: byte stream “number” of first byte in segment’s data acknowledgements: 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 outgoing segment from sender source port # source port # dest port # dest port # incoming segment to sender sequence number sequence number acknowledgement number acknowledgement number rwnd rwnd checksum checksum urg pointer urg pointer A TCP seq. numbers, ACKs window size N • sender sequence number space sent ACKed usable but not yet sent sent, not-yet ACKed (“in-flight”) not usable pp 261-262 TransportLayer
TCP seq. numbers, ACKs Host B Host A User types ‘C’ Seq=42, ACK=79, data = ‘C’ host ACKs receipt of ‘C’, echoes back ‘C’ Seq=79, ACK=43, data = ‘C’ host ACKs receipt of echoed ‘C’ Seq=43, ACK=80 simple telnet scenario pp 261-262 TransportLayer
Seq=100, 20 bytes of data ACK=120 ACK=100 TCP: retransmission scenarios Host B Host B Host A Host A SendBase=92 Seq=92, 8 bytes of data Seq=92, 8 bytes of data timeout timeout ACK=100 X Seq=92, 8 bytes of data Seq=92, 8 bytes of data SendBase=100 SendBase=120 ACK=100 ACK=120 SendBase=120 lost ACK scenario premature timeout pp 268-272 TransportLayer
Seq=100, 20 bytes of data timeout ACK=100 ACK=120 TCP: retransmission scenarios Host B Host A Seq=92, 8 bytes of data X Seq=120, 15 bytes of data cumulative ACK TransportLayer
flow control application OS receiver controls sender, so sender won’t overflow receive’s buffer by transmitting too much, too fast TCP socket receiver buffers TCP flow control application process application may remove data from TCP socket buffers …. … slower than TCP receiver is delivering (sender is sending) TCP code IP code from sender receiver protocol stack pp 276-278 TransportLayer
receiver “advertises” free buffer space by including rwnd value in TCP header of receiver-to-sender segments RcvBuffer size set via socket options (typical default is 4096 bytes) many operating systems autoadjust RcvBuffer sender limits amount of unacked (“in-flight”) data to receiver’s rwnd value guarantees receive buffer will not overflow buffered data free buffer space TCP flow control to application process RcvBuffer rwnd TCP segment payloads receiver-side buffering pp 276-278 TransportLayer
TCP sliding window http://histrory.visualland.net/view.php?path=content/TCP/Simu/sm_1_Reliable_Transmit.show&type=show http://histrory.visualland.net/tcp_swnd.html TransportLayer
Q: will 2-way handshake always work in network? when variable delays retransmitted messages (e.g. req_conn(x)) due to message loss? message reordering can’t “see” other side Agreeing to establish a connection 2-way handshake: Let’s talk ESTAB OK ESTAB choose x req_conn(x) ESTAB acc_conn(x) ESTAB pp 278-282 TransportLayer
choose x choose x req_conn(x) req_conn(x) ESTAB ESTAB retransmit req_conn(x) retransmit req_conn(x) acc_conn(x) req_conn(x) acc_conn(x) ESTAB ESTAB data(x+1) accept data(x+1) retransmit data(x+1) connection x completes connection x completes client terminates server forgets x server forgets x client terminates req_conn(x) ESTAB ESTAB data(x+1) accept data(x+1) half open connection! (no client!) Agreeing to establish a connection 2-way handshake failure scenarios: pp 278-282 TransportLayer
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) indicates server is live; send ACK for SYNACK; this segment may contain client-to-server data ESTAB ACKbit=1, ACKnum=y+1 received ACK(y) indicates client is live TCP 3-way handshake ESTAB pp 278-282 TransportLayer
clientSocket.close() FINbit=1, seq=x FIN_WAIT_1 can no longer send but can receive data CLOSE_WAIT ACKbit=1; ACKnum=x+1 can still send data FIN_WAIT_2 wait for server close LAST_ACK FINbit=1, seq=y can no longer send data TIMED_WAIT ACKbit=1; ACKnum=y+1 timed wait for 2*max segment lifetime CLOSED CLOSED TCP: closing a connection client state server state ESTAB ESTAB TransportLayer