* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download TCP and UDP
Survey
Document related concepts
Transcript
TCP/IP Transport Layer Protocols TCP/UDP © 2004, Cisco Systems, Inc. All rights reserved. 1 Objectives • Explain the role of Transport Layer protocols – TCP (Transport Control Protocol) – UDP (User Datagram Protocol) • Analyze the operation of TCP mechanisms that support – reliability – reassembly and – manage data loss. • Analyze the operation of UDP © 2004, Cisco Systems, Inc. All rights reserved. 2 Packet handling on the Internet © 2004, Cisco Systems, Inc. All rights reserved. 3 Transport Layer Role and Services •Transport layer prepares application data for transport over the network and •Processes data for use by applications •Assembles data received by network layer © 2004, Cisco Systems, Inc. All rights reserved. 4 Transport Protocols: TCP and UDP • Two Transport Layer Protocols in TCP/IP model –UDP: user datagram protocol – Connection-less protocol. –TCP: transmission control protocol Connection-oriented protocol. – Different applications use different transport protocols based on the nature of the application © 2004, Cisco Systems, Inc. All rights reserved. 5 TCP Connection setup – Three way handshake TCP offers reliable communication Connection setup stage precedes data transfer stage Three way handshake procedure: 1. Sender sends in a request to receiver to set up connection Send SYN SEQ = 100 2. Receiver accepts the connection request, if feasible. Acknowledges sender’s request 3. Sender acknowledges receiver confirmation Established SEQ 101, ACK 301 Once connection is setup, data transfer can take place © 2004, Cisco Systems, Inc. All rights reserved. Data Transfer 6 TCP Flow Control: How Fast to Send Data • Flow Control is necessary so that source does not transmit too fast for a receivertoo fast for given receiver • TCP Window size :Sender and Receiver agree at Session establishment stage about the size of data sent at a time Size of advertised window related to receiver’s buffer space. • Sender can send data up to receiver’s advertised window. • TCP window size can be increased/decreased during data transfer session © 2004, Cisco Systems, Inc. All rights reserved. Data Not Ready Buffer FULL Ready Process uses Data Data 7 TCP Basic Window: How many bytes of Data to send Window size 1 Byte Send 1 Receive 1 ACK 2 © 2004, Cisco Systems, Inc. All rights reserved. 8 TCP Basic Window –Window Size Negotiation ACK 3 Window size 2 Send 3 bytes ACK 5 Window size 2 Send 3 bytes Send 2 bytes © 2004, Cisco Systems, Inc. All rights reserved. 9 TCP Reliable Delivery • Reliable delivery offered by • Acknowledgements. • Timeouts and • Retransmissions. • Ordered delivery. •Sequence numbers. © 2004, Cisco Systems, Inc. All rights reserved. 10 TCP reliable delivery– Sequencing Data • Data generated by application is broken down into segments • Segments are assigned sequence numbers • Different segments may take different route to destination • Having taken different routes , segments arrive out of order • TCP uses sequence numbers to reconstruct the data stream with segments placed in the correct order © 2004, Cisco Systems, Inc. All rights reserved. 11 TCP Sequence and Acknowledgement © 2004, Cisco Systems, Inc. All rights reserved. 12 TCP Reliable delivery: Handling lost packets • Retransmission timer: When a data segment is sent, a timer is started. –If the segment is acknowledged before the timer expires, the timer is stopped and reset. –Otherwise, the segment is retransmitted (and the timer is reset and started again). © 2004, Cisco Systems, Inc. All rights reserved. 13 UDP: User Datagram Protocol • “no frills,” “bare bones” Internet transport protocol • “best effort” service, UDP segments may be: –lost –delivered out of order to application • connectionless: no handshaking between UDP sender, receiver each UDP segment handled independently of others © 2004, Cisco Systems, Inc. All rights reserved. 14 UDP Protocol •Different datagrams may take different route to destination •Datagrams may arrive out of order •Out of order datagrams are not ordered •Lost datagrams are not sent © 2004, Cisco Systems, Inc. All rights reserved. 15 Applications of UDP • Often used for streaming multimedia apps loss tolerant rate sensitive • reliable transfer over UDP: • Application is responsible for error recovery of lost data © 2004, Cisco Systems, Inc. All rights reserved. 16 Summary: TCP and UDP • TCP provides end-to-end communication. It takes care of reliable, error-free transfer of data, and in-sequence delivery • UDP has less overhead compared to TCP, but does not guarantee transfers TCP is preferred to transfer files UDP is preferred to transfer audio/video streams In real-time streaming, we cannot afford the delay consequent to packet retransmission • Both protocols support multiplexing, i.e. they allow several distinct streams of data between two hosts © 2004, Cisco Systems, Inc. All rights reserved. 17