1 / 95

Chapter 12

Chapter 12. Transmission Control Protocol. Objectives. Upon completion you will be able to:. Be able to name and understand the services offered by TCP Understand TCP’s flow and error control and congestion control Be familiar with the fields in a TCP segment

Télécharger la présentation

Chapter 12

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. Chapter 12 TransmissionControl Protocol Objectives Upon completion you will be able to: • Be able to name and understand the services offered by TCP • Understand TCP’s flow and error control and congestion control • Be familiar with the fields in a TCP segment • Understand the phases in a connection-oriented connection • Understand the TCP transition state diagram • Be able to name and understand the timers used in TCP • Be familiar with the TCP options TCP/IP Protocol Suite

  2. Figure 12.1TCP/IP protocol suite TCP provides a set of services. What are those services? TCP/IP Protocol Suite

  3. TCP provides a process-to-process communication service using port numbers. Table 12.1 Well-known ports used by TCP TCP/IP Protocol Suite

  4. Figure 12.4TCP segments TCP provides a stream delivery service. It breaks up the data stream into segments of variable size. Each segment receives a header and is handed off to the IP layer. TCP/IP Protocol Suite

  5. Figure 12.4TCP services and features TCP can create a full-duplex service. Data can flow in both directions at the same time; buffers on each side hold the data to be transmitted and sent. TCP provides a connection-oriented service: the two TCPs establish a connection, data is exchanged, and the connection is terminated. TCP provides a reliable service. Furthermore, TCP has a number of features. All bytes transferred are numbered by TCP. The numbering starts with a random value. TCP/IP Protocol Suite

  6. Example 2 Suppose a TCP connection is transferring a file of 5000 bytes. The first byte is numbered 10001. What are the sequence numbers for each segment if data is sent in five segments, each carrying 1000 bytes? SolutionThe following shows the sequence number for each segment: Segment 1➡ Sequence Number: 10,001 (range: 10,001 to 11,000) Segment 2➡ Sequence Number: 11,001 (range: 11,001 to 12,000) Segment 3➡ Sequence Number: 12,001 (range: 12,001 to 13,000) Segment 4➡ Sequence Number: 13,001 (range: 13,001 to 14,000) Segment 5➡ Sequence Number: 14,001 (range: 14,001 to 15,000) TCP/IP Protocol Suite

  7. The value in the sequence number field of a segment defines the number of the first data byte containedin that segment. The value of the acknowledgment field in a segment defines the number of the next byte a party expects to receive. The acknowledgment number is cumulative. TCP/IP Protocol Suite

  8. Figure 12.4TCP services and features TCP also provides flow control, error control, and congestion control. We will examine each of these shortly. Before we do, let’s examine the TCP header a little more closely. The TCP packet is called a segment (but most people just call it a packet). TCP/IP Protocol Suite

  9. Figure 12.5TCP segment format (packets in TCP are called segments) Window size set by receiver with max = 65,535 bytes TCP/IP Protocol Suite

  10. Figure 12.6Control field More on these bits later. TCP/IP Protocol Suite

  11. Figure 12.7Pseudoheader added to the TCP datagram to calculate checksum TCP/IP Protocol Suite

  12. 12.4 A TCP CONNECTION TCP is connection-oriented. A connection-oriented transport protocol establishes a virtual path between the source and destination. All of the segments belonging to a message are then sent over this virtual path. A connection-oriented transmission requires three phases: connection establishment, data transfer, and connection termination. The topics discussed in this section include: Connection Establishment Data Transfer Connection Termination Connection Reset TCP/IP Protocol Suite

  13. Figure 12.9Connection establishment using three-way handshaking A server tells its TCP that it is ready to make a connection - this is called a passive open. rwnd is the receiver window size, as we will see later. + Note: SYN bit is set in first packet; 8000 chosen randomly Should this be 8001? TCP/IP Protocol Suite

  14. A SYN segment cannot carry data, but it consumes one sequence number. A SYN + ACK segment cannot carry data, but does consume onesequence number. An ACK segment, if carrying no data, consumes no sequence number. TCP/IP Protocol Suite

  15. SYN flooding attack is when a bad person floods a server with bogus SYN packets. The server spends a lot of time and resources replying to the SYN packets. To counter these attacks, some servers postpone resource allocation until the entire connection is set up using a cookie. TCP/IP Protocol Suite

  16. Figure 12.10Data transfer Notice how the ACK and SEQ # are piggybacked. Push flag means deliver the data to the receiver as soon as it is received (don’t put it in a buffer and hold until you have enough bytes for a complete segment). This feature is usually ignored. Can also send Urgent data by setting the Urg bit. This data is then processed immediately. For example, you want to send a Ctrl-C to stop. TCP/IP Protocol Suite

  17. Figure 12.11Connection termination using three-way handshaking A FIN segment consumes one sequence number if it does not carry data. So should third segment be seq: x+1? TCP/IP Protocol Suite

  18. Figure 12.12Half-close y-1 Client is finished, but Server is not yet finished. So Server ACKs the Client’s FIN, but does not signal its own FIN just yet. x+1 TCP/IP Protocol Suite

  19. Connection Reset • Using the Reset flag (RST), one can: • Deny a request for a connection • Abort a current connection • Terminate an idle connection TCP/IP Protocol Suite

  20. 12.5 STATE TRANSITION DIAGRAM To keep track of all the different events happening during connection establishment, connection termination, and data transfer, the TCP software is implemented as a finite state machine. . The topics discussed in this section include: Scenarios TCP/IP Protocol Suite

  21. Table 12.3 States for TCP TCP/IP Protocol Suite

  22. Figure 12.13State transition diagram TCP/IP Protocol Suite

  23. Figure 12.14Common scenario TCP/IP Protocol Suite

  24. Note: The common value for MSL is between 30 seconds and 1 minute. TCP/IP Protocol Suite

  25. Figure 12.15Three-way handshake TCP/IP Protocol Suite

  26. Figure 12.16Simultaneous open TCP/IP Protocol Suite

  27. Figure 12.17Simultaneous close TCP/IP Protocol Suite

  28. Figure 12.18Denying a connection TCP/IP Protocol Suite

  29. Figure 12.19Aborting a connection TCP/IP Protocol Suite

  30. 12.6 FLOW CONTROL Flow control regulates the amount of data a source can send before receiving an acknowledgment from the destination. TCP defines a window that is imposed on the buffer of data delivered from the application program. The topics discussed in this section include: Sliding Window Protocol Silly Window Syndrome TCP/IP Protocol Suite

  31. Figure 12.20Sliding window rwnd is the receiver window size; cwnd is the congestion window size TCP/IP Protocol Suite

  32. Note: A sliding window is used to make transmission more efficient as well as to control the flow of data so that the destination does not become overwhelmed with data. TCP’s sliding windows are byte oriented. TCP/IP Protocol Suite

  33. Example 3 What is the value of the receiver window (rwnd) for host A if the receiver, host B, has a buffer size of 5,000 bytes and 1,000 bytes of received and unprocessed data? SolutionThe value of rwnd = 5,000 − 1,000 = 4,000. Host B can receive only 4,000 bytes of data before overflowing its buffer. Host B advertises this value in its next segment to A. TCP/IP Protocol Suite

  34. Example 4 What is the size of the window for host A if the value of rwnd is 3,000 bytes and the value of cwnd is 3,500 bytes? SolutionThe size of the window is the smaller of rwnd and cwnd, which is 3,000 bytes. TCP/IP Protocol Suite

  35. Example 5 Figure 12.21 shows an unrealistic example of a sliding window. The sender has sent bytes up to 202. We assume that cwnd is 20 (in reality this value is thousands of bytes). The receiver has sent an acknowledgment number of 200 with an rwnd of 9 bytes (in reality this value is thousands of bytes). The size of the sender window is the minimum of rwnd and cwnd or 9 bytes. Bytes 200 to 202 are sent, but not yet acknowledged. Bytes 203 to 208 can be sent without worrying about acknowledgment. Bytes 209 and above cannot be sent. TCP/IP Protocol Suite

  36. Figure 12.21Example 5 Next, the server receives a packet with an acknowledgment value of 202 and an rwnd of 9. The host has already sent bytes 203, 204, and 205. The value of cwnd is still 20. Show the new window. TCP/IP Protocol Suite

  37. Figure 12.22Example 6 Next, the sender receives a packet with an acknowledgment value of 206 and an rwnd of 12. The host has not sent any new bytes. The value of cwnd is still 20. Show the new window. TCP/IP Protocol Suite

  38. Figure 12.23Example 7 Assume the sender has sent bytes 206 to 209. The sender’s window shrinks accordingly. Now the sender receives a packet with an acknowledgment value of 210 and an rwnd of 5. The value of cwnd is still 20. Show the new window. TCP/IP Protocol Suite

  39. Figure 12.24Example 8 TCP/IP Protocol Suite

  40. Example 9 How can the receiver avoid shrinking the window in the previous example? SolutionThe receiver needs to keep track of the last acknowledgment number and the last rwnd. If we add the acknowledgment number to rwnd we get the byte number following the right wall. If we want to prevent the right wall from moving to the left (shrinking), we must always have the following relationship. new ack + new rwnd ≥ last ack + last rwndornew rwnd ≥ (last ack + last rwnd) − new ack TCP/IP Protocol Suite

  41. To avoid shrinking the sender window, the receiver must wait until more space is available in its buffer. Window Shutdown While you shouldn’t shrink the window, you can send rwnd = 0 to close the window. Sender can still send a “probe” packet. TCP/IP Protocol Suite

  42. Note: Some points about TCP’s sliding windows: ❏ The size of the window is the lesser of rwnd and cwnd.❏The source does not have to send a full window’s worth of data.❏ The window can be opened or closed by the receiver, but should not be shrunk.❏ The destination can send an acknowledgment at any time as long as it does not result in a shrinking window.❏ The receiver can temporarily shut down the window; the sender, however, can always send a segment of one byte after the window is shut down. TCP/IP Protocol Suite

  43. Figure 12.24Silly Window Syndrome Silly Window Syndrome - What if TCP sends segments that are only 1 byte long? You would have 40 bytes of header, 1 byte of data, for a total of 41 bytes. Very wasteful! TCP should wait until it has more data before it sends a 1-byte segment. But how long should it wait to assemble data? Nagle’s Algorithm: 1. The sending TCP sends the first piece of data it receives from the sending application even if it is only 1 byte. 2. After sending the first segment, the sending TCP accumulates data in the output buffer and waits until either the receiving TCP sends an ack or until enough data has accumulated to fill a maximum-size segment. At this time, the sending TCP can send the segment. 3. Step 2 is repeated for the rest of the transmission. TCP/IP Protocol Suite

  44. Figure 12.24Silly Window Syndrome Silly Window Syndrome - What happens if the receiving TCP has a buffer size of 1000 bytes and the sending TCP has just sent 1000 bytes. The receiving buffer is now full so the receiver tells the sender to stop (window size = 0). The receiver now reads 1 byte of data, processes it, and sends a window size of 1 (because now there is one space in the input buffer). The sender gets the window size and sends 1 byte. This procedure continues. Clark’s Solution - Acknowledge receipt right away, but don’t change the window size until you have at least half the buffer space available. Or, delay the ack until there is a decent amount of buffer space available. TCP/IP Protocol Suite

  45. 12.7 ERROR CONTROL TCP provides reliability using error control, which detects corrupted, lost, out-of-order, and duplicated segments. Error control in TCP is achieved through the use of the checksum, acknowledgment, and time-out. The topics discussed in this section include: Checksum Acknowledgment Acknowledgment Type Retransmission Out-of-Order Segments Some Scenarios TCP/IP Protocol Suite

  46. TCP Error Control TCP supports basic error control. It uses a 16-bit arithmetic checksum, similar to the ones we have already seen. TCP uses the ACK message to confirm receipt of segments. There are a number of basic rules pertaining to ACKs: Rule 1: When one ends sends data, it must piggyback the ACK for any data received. (Example in just a moment) Rule 2: If a receiver has no data to send and a segment arrives, do not ACK it immediately. Wait until two segments arrive, then ACK. Or wait 500 ms after the first segment then ACK. TCP/IP Protocol Suite

  47. Figure 12.25Normal operation TCP/IP Protocol Suite

  48. TCP Error Control Rule 3: When a segment arrives with an expected sequence number and the previous in-order segment has not been ACKed, the receiver immediately sends an ACK. (Example on previous slide) Rule 4: When a segment arrives with a sequence number higher than expected, the receiver immediately sends an ACK announcing the sequence number it expected. This leads to fast retransmission, which we will see shortly. Rule 5: When a missing segment arrives, the receiver sends an ACK segment to announce the sequence number expected. This informs the receiver that segments reported missing have been received. (Example on next slide) Rule 6: If a duplicate segment arrives, receiver immediately sends an ACK. This solves some problems when an ACK itself is lost. (Example on next slide) TCP/IP Protocol Suite

  49. Figure 12.26Lost segment TCP/IP Protocol Suite

  50. TCP Error Control Furthermore, a retransmission will occur if the retransmission timer (RTO) expires, or three duplicate ACKs arrive in order. (For RTO example, see previous slide.) (For three ACKs, see next slide.) TCP/IP Protocol Suite

More Related