Presentation is loading. Please wait.

Presentation is loading. Please wait.

Transport Layer: UDP, TCP

Similar presentations


Presentation on theme: "Transport Layer: UDP, TCP"— Presentation transcript:

1 Transport Layer: UDP, TCP

2 Internet Transport Protocols
TCP Connection-oriented setup required between client and server Reliable transport Flow control Won’t overwhelm receiver Congestion control Won’t overwhelm network Does not provide Timing and throughput guarantees, security UDP Unreliable data transfer Does not provide Connection setup, reliability, flow control, congestion control, timing and throughput guarantee, or security Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo

3 Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo
UDP Services User Datagram Protocol Service OSI Transport Layer Provides a thin layer over IP 16-bit port space (distinct from TCP ports) allows multiple recipients on a single host Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo

4 Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo
UDP Services Unit of Transfer Datagram (variable length packet) Packet boundaries are preserved when receiving data (a read operation yields packet payload as it was originally sent. Unreliable No guaranteed delivery Drops packets silently Unordered No guarantee of maintained order of delivery Unlimited Transmission No flow control Postal Mail Unreliable Not necessarily in-order Letters sent independently Must address each reply Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo

5 Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo
UDP Packet structure Quiz: by locking at UDP packet structure, can you guess what services are provided by UDP? bits 0-15 16-31 32 64 Source port Destination port Length Checksum Data Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo

6 Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo
UDP Packet structure UDP provides application multiplexing (via port numbers) integrity verification (via checksum) of the header and payload packets are sent individually and error checked only if they arrive if any kind of transmission reliability is needed, it must be implemented at application level bits 0-15 16-31 32 64 Source port Destination port Length Checksum Data Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo

7 Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo
When should I use UDP? Why should I use UDP? After all, TCP is a “better” algorithm! Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo

8 Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo
When should I use UDP? Why should I use UDP? After all, TCP is a “better” algorithm! Reliability of TCP comes with some costs… TCP needs 3 packets to set up a connection UDP header has 8 bytes instead of 20 (like TCP header) UDP is a better choice for interactive (soft real-time) voice and video traffic (like Skype). During real-time streaming, it is better to occasionally lose few packets (slight QoS degradation) rather than introducing large delays if lost packets are retransmitted. Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo

9 Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo
TCP Connections Transmission Control Protocol (TCP) Service TCP is a protocol running on OSI Transport Layer Service Model Byte stream (interpreted by application); packet boundaries cannot be distinguished by application 16-bit port space allows multiple connections on a single host Connection-oriented Set up connection before communicating Tear down connection when done Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo

10 Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo
TCP Service Reliable Data Transfer Guaranteed delivery Exactly once Sequenced Data Transfer In-order delivery Regulated Data Flow Monitors network and adjusts transmission appropriately Data Transmission Full-Duplex byte stream Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo

11 TCP Connection Establishment
3-Way Handshake Sequence Numbers J,K Message Types Synchronize (SYN) Acknowledge (ACK) Passive Open Server listens for connection from client Active Open Client initiates connection to server Passive open Active open Client Server Time flows down listen Synchronize SYN J acknowledge ACK J+1 SYN K, ACK K+1 Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo

12 TCP Connection Termination
Active close Either client or server can initiate connection teardown (4-way handshake) Message Types Finished (FIN) Acknowledge (ACK) 3-way handshake is also possible. The sequence is FIN J, ACK J+1 & FIN K (as single packet), ACK K+1 Client Server Time flows down Passive close Finished FIN J ACK J+1 FIN K ACK K+1 Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo

13 TCP Reliable transmission
TCP uses a sequence number to identify each byte of data. When establishing a connection, the 3-way handshake allows remote hosts to exchange and ACK an initial sequence number (ISN). Exploiting sequence numbers, data can be reconstructed in order, regardless of fragmentation, lack of ordering, or packet loss Sequence number is incremented for each payload byte that is sent. Receiver uses cumulative acknowledgment For example, if host A sends 10 bytes with sequence numbers 100 to 109, then the receiver transmits ACK 110 since next expected byte should have sequence number 110 Copyright ©: Nahrstedt, Angrave, Abdelzaher, Kravets, Gupta, Caccamo

14 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher
TCP Segment Format TCP segments have a 20 byte header with >= 0 bytes of data. Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher

15 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher
TCP header fields Port number A port number identifies the endpoint of a connection A pair <IP address, port number> identifies one endpoint of a connection Two pairs <client IP address, client port number> and <server IP address, server port number> identify a TCP connection Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher

16 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher
TCP header fields Sequence Number (SeqNo): Sequence number is 32 bits long. Each sequence number identifies a byte in the byte stream Initial Sequence Number (ISN) of a connection is set during connection establishment Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher

17 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher
TCP header fields Acknowledgement Number (AckNo): Acknowledgements are piggybacked A host uses the AckNo field to send acknowledgements. (If AckNo has a valid value, then the “ACK flag” is set) The AckNo contains the next SeqNo that a host (receiver) expects to receive Example: The acknowledgement for a segment with sequence numbers is AckNo=1501 Copyright Jorg Liebeherr 98, Modified with permission, Abdelzaher


Download ppt "Transport Layer: UDP, TCP"

Similar presentations


Ads by Google