Transport Layer: Part I Transport Layer Services connection-oriented vs. connectionless multiplexing and demultiplexing UDP: Connectionless Unreliable Service TCP: Connection-Oriented Reliable Service connection management: set-up and tear down reliable data transfer protocols (Part II) flow and congestion control (Part II) Readings: Chapter 3, Lecture Notes CSci4211: Transport Layer:Part I 1
Transport Services and Protocols • provide logical communication application between app processes transport network running on different hosts data link network physical data link • transport protocols run in network physical data link end systems physical network – send side: breaks app data link physical network messages into segments, data link physical passes to network layer network – rcv side: reassembles data link physical segments into messages, passes to app layer application transport • more than one transport network data link protocol available to apps physical – Internet: TCP and UDP CSci4211: Transport Layer:Part I 2
Transport vs. Application and Network Layer Household analogy: • application layer: application processes 12 kids sending letters to 12 kids and message exchange • processes = kids • network layer: logical • app messages = letters communication in envelopes between hosts • hosts = houses • transport layer: logical • transport protocol = communication support Ann and Bill for app processes • network-layer protocol – relies on, enhances, = postal service network layer services CSci4211: Transport Layer:Part I 3
End to End Issues • Transport services built on top of (potentially) unreliable network service – packets can be corrupted or lost – Packets can be delayed or arrive “ out of order ” • Do we detect and/or recover errors for apps? – Error Control & Reliable Data Transfer • Do we provide “ in-order ” delivery of packets? – Connection Management & Reliable Data Transfer • Potentially different capacity at destination, and potentially different network capacity – Flow and Congestion Control CSci4211: Transport Layer:Part I 4
Internet Transport Protocols TCP service: UDP service: • connection-oriented: setup • unreliable data transfer required between client, between sender and server receiver • reliable transport between • does not provide: sender and receiver connection setup, • flow control: sender won ’ t reliability, flow control, overwhelm receiver congestion control • congestion control: throttle sender when network overloaded Both provide logical communication between app processes running on different hosts! CSci4211: Transport Layer:Part I 5
Multiplexing/Demultiplexing Multiplexing at send host: Demultiplexing at rcv host: gathering data from multiple delivering received segments app processes, enveloping data to correct application process with header (later used for demultiplexing) = API ( “ socket ” ) = process P4 application P1 P2 P3 P1 application application transport transport transport network network network link link link physical physical physical host 3 host 2 host 1 CSci4211: Transport Layer:Part I 6
How De-multiplexing Works • host receives IP datagrams 32 bits – each datagram has source IP address, destination IP source port # dest port # address – each datagram carries 1 other header fields transport-layer segment – each segment has source, destination port number (recall: well-known port numbers for specific application applications) data • host uses IP addresses & port (message) numbers to direct segment to appropriate app process (identified by “ socket ’ ) TCP/UDP segment format CSci4211: Transport Layer:Part I 7
UDP: User Datagram Protocol [RFC 768] “ no frills, ” “ bare bones ” • Internet transport Why is there a UDP? protocol • no connection “ best effort ” service, UDP • establishment (which can segments may be: add delay) – lost • simple: no connection state – delivered out of order to at sender, receiver app • small segment header • connectionless: • no congestion control: UDP – no handshaking between can blast away as fast as UDP sender, receiver desired – each UDP segment handled independently of others CSci4211: Transport Layer:Part I 8
UDP (cont ’ d) • often used for 32 bits streaming multimedia apps source port # dest port # Length, in – loss tolerant bytes of UDP checksum length segment, – rate sensitive including • other UDP uses header – DNS – SNMP Application data • reliable transfer over (message) UDP: add reliability at application layer – application-specific UDP segment format error recovery! CSci4211: Transport Layer:Part I 9
UDP Checksum Goal: detect “ errors ” (e.g., flipped bits) in transmitted segment Sender: Receiver: • treat segment contents • compute checksum of as sequence of 16-bit received segment integers • check if computed checksum • checksum: addition (1 ’ s equals checksum field value: complement sum) of – NO - error detected segment contents – YES - no error detected. But • sender puts checksum maybe errors nonetheless? value into UDP checksum More later …. field CSci4211: Transport Layer:Part I 10
Checksum: Example (from book) 0110011001100000 arrange data segment in sequences of 0101010101010101 16-bit words binary addition, 1000111100001100 + with overflow wrapped around sum: 0100101011000010 checksum(1 ’ s complement): 1011010100111101 verify by adding: 1111111111111111 CSci4211: Transport Layer:Part I 11
TCP: Overview • full duplex data: • point-to-point: – bi-directional data flow in – one sender, one receiver same connection • reliable, in-order byte – MSS: maximum segment steam: size – no “ message boundaries ” • connection-oriented: • pipelined: – handshaking (exchange of control msgs) init ’ s sender, – TCP congestion and flow control receiver state before data set window size exchange • send & receive buffers • flow controlled: application application – sender will not overwhelm writes data reads data socket socket receiver door door TCP TCP send buffer receive buffer segment CSci4211: Transport Layer:Part I 12
TCP Segment Structure 32 bits counting source port # dest port # URG: urgent data by bytes sequence number (generally not used) of data (not segments!) acknowledgement number ACK: ACK # head not valid rcvr window size U A P R S F len used checksum ptr urgent data PSH: push data now # bytes (generally not used) rcvr willing Options (variable length) to accept RST, SYN, FIN: connection estab application (setup, teardown commands) data (variable length) Internet checksum (as in UDP) CSci4211: Transport Layer:Part I 13
TCP Seq. # ’ s and ACKs Host A Host B Seq. # ’ s: User byte stream types “ number ” of first ‘ C ’ host ACKs byte in segment ’ s receipt of data ‘ C ’ , echoes back ‘ C ’ ACKs: seq # of next byte host ACKs expected from receipt of echoed other side ‘ C ’ time red: A-to-B green: B-to-A simple telnet scenario CSci4211: Transport Layer:Part I 14
TCP: Error Scenarios Host A Host B Questions for you: • How to detect lost packets? X • How to “ recover ” lost timeout loss packets? • Potential consequence of retransmission? • How to detect duplicate packets? “ State ” maintained at • sender & receiver? time lost data scenario CSci4211: Transport Layer:Part I 15
TCP: Error Scenarios (cont ’ d) Host A Host B Host A Host B timeout timeout X loss time time lost ACK scenario duplicate packets CSci4211: Transport Layer:Part I 16
A Simple Reliable Data Transfer Protocol “ Stop & Wait ” Protocol (aka “ Alternate Bit ” Protocol) Receiver algorithm: ?? Sender algorithm: • Send Phase : send data segment (n bytes) w/ seq=x, buffer data segment, set timer • Wait Phase : wait for ack from receiver w/ ack= x+n – if received ack w/ ack=x+n, set x:=x+n, and go to sending phase with next data segment – if time out, resend data segment w/ seq=x. – if received ack w/ ack != x+n, ignore (or resend data segment w/ seq=x) CSci4211: Transport Layer:Part I 17
SRDTP: Finite State Machine event : state action Receiver FSM? : transition Sender FSM Upper layer: send data (n bytes) make data sgt, seq = x, set timer pass data sgt to lower layer ? receive Ack w/ ack != x+n ? Wait Send no op, or resend data sgt phase phase time out resend data sgt receive Ack w/ ack = x+n x: = x+n, stop timer info ( “ state ” ) maintained at sender: phase it is in ( send , or wait ), ack expected, data sgt sent (seq #), timer CSci4211: Transport Layer:Part I 18
Recommend
More recommend