1 / 59

UTP and TCP

UTP and TCP. Transport Protocols, UDP and TCP, Protocol Port Numbers. Transport Protocol. Separate layer of protocol stack Conceptually between Application IP. Terminology. IP Provides computer-to-computer communication Source and destination addresses are computers

marli
Download Presentation

UTP and TCP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UTP and TCP Transport Protocols, UDP and TCP, Protocol Port Numbers

  2. Transport Protocol • Separate layer of protocol stack • Conceptually between • Application • IP Spring 2005

  3. Terminology • IP • Provides computer-to-computer communication • Source and destination addresses are computers • Called machine-to-machine • Transport Protocols • Provide application-to-application communication • Need extended addressing mechanism to identify applications • Called end-to-end Spring 2005

  4. Transport Protocol Functionality • Identify sending and receiving applications • Optionally provide • Reliability • Flow control • Congestion control • Note: not all transport protocols provide above facilities Spring 2005

  5. Two Transport Protocols Available • Transmission Control Protocol (TCP) • User Datagram Protocol (UDP) • Major differences • Interface to applications • Functionality Spring 2005

  6. User Datagram Protocol (UDP) • Provides unreliable transfer • Requires minimal • Overhead • Computation • Communication • Best for LAN applications Spring 2005

  7. UDP Details • Connectionless service paradigm • Message-oriented interface • Each message encapsulated in IP datagram • UDP header identifies • Sending application • Receiving application Spring 2005

  8. Identifying An Application • Cannot extend IP address • No unused bits • Cannot use OS-dependent quantity • Process ID • Task number • Job name • Must work on all computer systems Spring 2005

  9. Applications Applications Ports: Ports: 23 80 104 7 80 16 TCP TCP IP IP Identifying an Application (continued) • Invent new abstraction • Used only with TCP/IP • Identifies sender and receiver unambiguously • Technique • Each application assigned unique integer • Called protocol port number Spring 2005

  10. Protocol Ports • Server • Follows standard • Always uses same port number • Uses lower port numbers • Client • Obtains unused port from protocol software • Uses higher port numbers Spring 2005

  11. Protocol Port Example • Domain name server application is assigned port 53 • Application using DNS obtains port 28900 • UDP datagram sent from application to DNS server has • Source port number 28900 • Destination port number 53 • When DNS server replied, DP datagram hs • Source port number 53 • Destination port number 28900 Spring 2005

  12. Transmission Control Protocol (TCP) • Major transport protocol used in Internet • Heavily used • Completely reliable transfer Spring 2005

  13. TCP Features • Connection-oriented service • Point-to-point • Full-duplex communication • Stream interface • Stream divided into segments for transmission • Each segment encapsulated in IP datagram • Uses protocol ports to identify applications Spring 2005

  14. TCP Feature Summary TCP provides a completely reliable (no data duplication or loss), connection-oriented, full-duplex stream transport service that allows two application programs to form a connection, send data in either direction, and then terminate the connection. Spring 2005

  15. Relationship Between TCP And Other Protocols • TCP on one computer uses IP to communicate with TCP on another computer Spring 2005

  16. Apparent Contradiction • IP offers best-effort (unreliable) delivery • TCP uses IP • TCP provides completely reliable transfer • How is this possible? Spring 2005

  17. Achieving Reliability • Reliable connection startup • Reliable data transmission • Graceful connection shutdown Spring 2005

  18. TCP Segment Format • All TCP segments have same format • Data • Acknowledgment • SYN (startup) • FIN (shutdown) • Segment divided into two parts • Header • Payload area (zero or more bytes of data) Spring 2005

  19. TCP Segment Format (continued) • Header contains • Protocol port numbers to identify • Sending application • Receiving application • Bits to specify items such as • SYN • FIN • ACK • Fields for window advertisement, acknowledgment, etc. Spring 2005

  20. Illustration of TCP Segment • Sequence number specifies where in stream data belongs • Few segments contain options Spring 2005

  21. Startup and Shutdown • Connection startup • Must be reliable • Connection shutdown • Must be graceful • Difficult Spring 2005

  22. Why Startup/Shutdown Difficult • Segments can be • Lost • Duplicated • Delayed • Delivered out of order • Either side can crash • Either side can reboot • Need to avoid duplicate “shutdown” message from affecting later connection Spring 2005

  23. TCP’s Startup/Shutdown Solution • Uses three-message exchange • Known as 3-way handshake • Necessary and sufficient for • Unambiguous, reliable startup • Unambiguous, graceful shutdown • SYN used for startup • FIN used for shutdown Spring 2005

  24. Illustration of 3-Way Handshake This picture is copied from somewhere SYN (SeqNo = x) SYN (SeqNo = y, AckNo = x + 1 ) (SeqNo = x+1, AckNo = y + 1 ) Spring 2005

  25. S 1031880193:1031880193(0) win 16384 <mss 1460, ...> delayed duplicate packet. S 15322112354:15322112354(0) win 16384 <mss 1460, ...> S 172488586:172488586(0) win 8760 <mss 1460> 2-Way Handshake Problem A B This picture is copied from somewhere Will be discarded as a duplicate SYN When A initiates the data transfer (starting with SeqNo=15322112355), B will reject all data. Spring 2005

  26. Reliable Data Transmission • Positive acknowledgment • Receiver returns short message when data arrives • Called acknowledgment • Retransmission • Sender starts timer whenever message is transmitted • If timer expires before acknowledgment arrives, sender retransmits message Spring 2005

  27. Illustration of Retransmission • TCP delays transmission of ACKs for up to 200ms • The hope is to have data ready in that time frame. Then, the ACK can be piggybacked with a data segment. • Delayed ACKs explain why the ACK and the “echo of character” are sent in the same segment. Spring 2005

  28. How Long Should TCP WaitBefore Retransmitting? • Time for acknowledgment to arrive depends on • Distance to destination • Current traffic conditions • Multiple connections can be open simultaneously • Traffic conditions change rapidly Spring 2005

  29. Important Point The delay required for data to reach a destination and an acknowledgment to return depends on traffic in the internet as well as the distance to the destination. Because it allows multiple application programs to communication with multiple destinations concurrently, TCP must handle a variety of delays that can change rapidly Spring 2005

  30. Solving the Retransmission Problem • Keep estimate of round trip time on each connection • Use current estimate to set retransmission timer • Known as adaptive retransmission • Key to TCP’s success Spring 2005

  31. Illustration of Adaptive Retransmssion • Timeout depends on current round-trip estimate Spring 2005

  32. TCP Flow Control • Sliding Window Protocol performed at the “byte” level • Receiver • Advertises available buffer space • Called window • Sender • Can send up to entire window before ack arrives This picture is copied from somewhere Spring 2005

  33. Window Advertisement • Each acknowledgment carries new window information • Called window advertisement • Can be zero (called closed window) • Interpretation: I have received up through X, and can take Y more octets Spring 2005

  34. Illustration of “Window Closes” • Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): This picture is copied from somewhere Spring 2005

  35. Illustration of “Window Opens” • Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): This picture is copied from somewhere • A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). Spring 2005

  36. Illustration of “Window Shrinks” • Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): This picture is copied from somewhere • Shrinking a window should not be used Spring 2005

  37. Window Management in TCP • The receiver is returning two parameters to the sender • The interpretation is: • I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 • Receiver can acknowledge data without opening the window • Receiver can change the window size without acknowledging data Spring 2005

  38. Sliding Window: Example This picture is copied from somewhere Spring 2005

  39. TCP Congestion Control

  40. TCP Congestion Control • TCP has a mechanism for congestion control. The mechanism is implemented at the sender • The sender has two parameters: • Congestion Window (cwnd) • Slow-start threshhold Value (ssthresh) Initial value is the advertised window size • Congestion control works in two modes: • slow start (cwnd < ssthresh) • congestion avoidance (cwnd >= ssthresh Spring 2005

  41. Slow Start • Initial value:Set cwnd = 1 • Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) • The receiver sends an acknowledgement (ACK) for each packet • Note: Generally, a TCP receiver sends an ACK for every other segment. • Each time an ACK is received by the sender, the congestion window is increased by 1 segment: Set cwnd = cwnd + 1 • If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. • Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. • Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential Spring 2005

  42. Slow Start Example • The congestion window size grows very rapidly • For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed • TCP slows down the increase of cwnd when cwnd > ssthresh This picture is copied from somewhere Spring 2005

  43. Congestion Avoidance • Congestion avoidance phase is started if cwnd has reached the slow-start threshold value • If cwnd >= ssthresh then each time an ACK is received, increment cwnd as follows: • cwnd = cwnd + 1/ [cwnd] where [cwnd] is the largest integer smaller than cwnd • So cwnd is increased by one only if all cwnd segments have been acknowledged. Spring 2005

  44. Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 ssthresh This picture is copied from somewhere Cwnd (in segments) Roundtrip times Spring 2005

  45. Responses to Congestion • TCP assumes there is congestion if it detects a packet loss • A TCP sender can detect lost packets via: • Timeout of a retransmission timer • Receipt of a duplicate ACK • TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: • Set ssthresh=cwnd / 2 • Reset cwnd = 1 • and slow-start is entered Spring 2005

  46. Summary of TCP congestion control Initially: cwnd = 1; ssthresh = advertised window size; New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd; Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2; cwnd = 1;

  47. Slow Start / Congestion Avoidance • A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) with TCP Tahoe: This picture is copied from somewhere Spring 2005

  48. Flavors of TCP Congestion Control • TCP Tahoe (1988, FreeBSD 4.3 Tahoe) • Slow Start • Congestion Avoidance • Fast Retransmit • TCP Reno (1990, FreeBSD 4.3 Reno) • Fast Recovery • New Reno (1996) • SACK (1996) • RED (Floyd and Jacobson 1993) Spring 2005

  49. Acknowledgments in TCP • Receiver sends ACK to sender • ACK is used for flow control, error control, and congestion control • ACK number sent is the next sequence number expected • Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) • Why? • ACKs are not delayed when packets are received out of sequence • Why? Lostsegment Spring 2005

  50. Acknowledgments in TCP • Receiver sends ACK to sender • ACK is used for flow control, error control, and congestion control • ACK number sent is the next sequence number expected • Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) • Why? • ACKs are not delayed when packets are received out of sequence • Why? Out-of-order arrivals Spring 2005

More Related