Computer Networks and Internets 5 e By Douglas
Computer Networks and Internets, 5 e By Douglas E. Comer Lecture Power. Points By Lami Kaya, LKaya@ieee. org Modified by S. Jane Fritz, 2010 © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 1
Chapter 26 TCP: Reliable Transport Service © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 2
Topics Covered n n n n 26. 1 26. 2 26. 3 26. 4 26. 5 26. 6 26. 7 Introduction The Transmission Control Protocol The Service TCP Provides to Applications End-to-End Service and Virtual Connections Techniques That Transport Protocols Use Techniques to Avoid Congestion The Art of Protocol Design © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 3
Topics Covered n 26. 8 Techniques Used in TCP to Handle Packet Loss 26. 9 Adaptive Retransmission 26. 10 Comparison of Retransmission Times 26. 11 Buffers, Flow Control, and Windows 26. 12 TCP's Three-Way Handshake 26. 13 TCP Congestion Control n 26. 14 TCP Segment Format n n n © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 4
26. 1 Introduction n This chapter n n considers transport protocols in general examines TCP n n the major transport protocol used in the Internet explains how the TCP protocol provides reliable delivery reviews the service that TCP provides to applications examines the techniques TCP uses to achieve reliability © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 5
26. 2 The Transmission Control Protocol n A programmer assumes n the data will arrive correctly n n n OS guarantees that data will be delivered reliably Protocol software must provide the following: n n or the OS will inform the application that an error has occurred Guarantee prompt and reliable communication Data be delivered in exactly the same order that it was sent There be no loss or duplication In the TCP/IP suite, the Transmission Control Protocol (TCP) provides reliable transport service © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 6
26. 3 The Service TCP Provides to Applications n n n The service offered by TCP has the following features: Connection Orientation n an application must first request a connection to a destination Point-to-Point Communication n each TCP connection has exactly two endpoints Complete Reliability n TCP guarantees that the data sent across a connection will be delivered completely and in order Full Duplex Communication n allows data to flow in either direction © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 7
26. 3 The Service TCP Provides to Applications n n n Stream Interface n it does not group data into records or messages Reliable Connection Startup n an application sends a continuous sequence of octets n TCP allows two applications to reliably start communication Graceful Connection Shutdown n TCP insures that both sides have agreed to shut down the connection © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 8
26. 4 End-to-End Service and Virtual Connections n TCP is classified as an end-to-end protocol n n The connections in TCP are called virtual connections n n it provides communication between an application on one computer to an application on another computer because connections are achieved in software TCP software modules on two machines exchange messages to achieve the illusion of a connection © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 9
26. 4 End-to-End Service and Virtual Connections n n TCP software modules on two machines exchange messages to achieve the illusion of a connection TCP uses IP to carry messages n n IP treats each TCP message as data to be transferred Figure 26. 1 illustrates how TCP views the Internet n TCP software is needed at each end of a virtual connection n but not on intermediate routers © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 10
26. 4 End-to-End Service and Virtual Connections © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 11
26. 5 Techniques That Transport Protocols Use n n n An end-to-end transport protocol must be carefully designed to achieve efficient and reliable transfer The major problems/issues to be considered, such as Unreliable Communication n Messages sent across the Internet n n They can be lost, duplicated, corrupted, delayed, or delivered out of order End System Reboot n either of the two end systems might crash and reboot © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 12
26. 5 Techniques That Transport Protocols Use n n Heterogeneous End Systems n A sender can generate data so fast that it overruns a slow receiver Congestion in the Internet n If senders aggressively transmit data n intermediate switches and routers can become overrun © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 13
26. 5 Techniques That Transport Protocols Use n There are techniques that communication systems use to overcome some of the problems n For example, to compensate for bits that are changed during transmission n a protocol might include parity bits a checksum or a cyclic redundancy check (CRC) © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 14
26. 5 Techniques That Transport Protocols Use n Transport protocols do more than detect errors n n Transport protocols use a variety of tools n n they employ techniques that can repair or circumvent problems to handle some of the most complicated communication problems The next sections discuss basic mechanisms © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 15
26. 5 Techniques That Transport Protocols Use 26. 5. 1 Sequencing Handle Duplicates and Out-of-Order Delivery n n To handle duplicate packets and out-of-order deliveries transport protocols use sequencing The sender attaches a sequence number to each packet The receiver stores both the sequence number of the last packet received in order as well as a list of additional packets that arrived out of order The receiver examines the sequence number n to determine how the packet should be handled © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 16
26. 5 Techniques That Transport Protocols Use 26. 5. 1 Sequencing Handle Duplicates and Out-of-Order Delivery n n n If the packet is the next one expected (i. e. , has arrived in order) n the protocol software delivers the packet to the next highest layer n the protocol checks its list to see whether additional packets can also be delivered If the packet has arrived out of order the protocol software adds the packet to the list If the packet has already been delivered or the sequence number matches one of the packets waiting on the list the software discards the new copy © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 17
26. 5 Techniques That Transport Protocols Use 26. 5. 1 Sequencing Handle Duplicates and Out-of-Order Delivery n To handle packet loss n n Whenever a frame arrives intact n n n transport protocols use positive acknowledgement (ACK) with retransmission the receiver sends a small ACK message that reports successful reception Sender ensures that each packet is transferred successfully Whenever it sends a packet the sender starts a timer © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 18
26. 5 Techniques That Transport Protocols Use 26. 5. 1 Sequencing Handle Duplicates and Out-of-Order Delivery n n If an acknowledgement arrives before the timer expires the software cancels the timer If the timer expires before an acknowledgement arrives n n the protocol sends another copy of the packet and starts the timer again Sending a second copy is known as retransmitting n n retransmission cannot succeed if a hardware failure has permanently disconnected the network or if the receiving computer has crashed there is a bound for the maximum number of retransmissions n if bound exceeded, the destination will be declared unreachable © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 19
26. 5 Techniques That Transport Protocols Use 26. 5. 3 Techniques Avoid Replay n n Extraordinarily long delays can lead to replay errors For example, consider the following sequence of events n Assume two computers agree to communicate at 1 PM n One computer sends a sequence of 10 packets to the other n A hardware problem causes packet 3 to be delayed n n n Assume routes change to avoid the hardware problem Protocol software on the sending computer retransmits packet 3 and sends the remaining packets without error At 1: 05 PM the two computers agree to communicate again © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 20
26. 5 Techniques That Transport Protocols Use 26. 5. 3 Techniques Avoid Replay After the second packet arrives, the delayed copy of packet 3 arrives from the earlier conversation n Packet 3 arrives from the second conversation A packet from an earlier conversation might be accepted and the correct packet discarded as a duplicate n n © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 21
26. 5 Techniques That Transport Protocols Use 26. 5. 3 Techniques Avoid Replay n n Replay errors can also occur with control packets Consider a situation in which two application programs form a TCP connection, communicate, close the connection, and then form a new connection n The message of closing the connection might be duplicated and one copy might be delayed long enough for the second connection to be established © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 22
26. 5 Techniques That Transport Protocols Use 26. 5. 3 Techniques Avoid Replay n n A protocol should be designed so that the duplicate message will not cause the second connection to be closed To prevent replays, protocols mark each session with a unique ID n (e. g. , the time the session was established), and require the unique ID to be present in each packet The protocol discards any arriving packet that contains an incorrect ID An ID must not be reused until a reasonable time has passed © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 23
26. 5 Techniques That Transport Protocols Use 26. 5. 4 Flow Control Prevents Data Overrun n Techniques are available to prevent a fast computer from sending so much data to overrun a slower receiver n n Flow control techniques are employed to handle the problem The simplest form of flow control is a stop-and-go n n n a sender waits after transmitting each packet when the receiver is ready for another packet, the receiver sends a control message, usually a form of ACK stop-and-go protocols result in extremely low throughput © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 24
26. 5 Techniques That Transport Protocols Use 26. 5. 4 Flow Control Prevents Data Overrun n Another flow control technique known as sliding window n The sender and receiver use a fixed window size n n n which is the maximum amount of data that can be sent before an acknowledgement arrives The sender retains a copy in case retransmission is needed The receiver must have preallocated buffer space © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 25
26. 5 Techniques That Transport Protocols Use 26. 5. 4 Flow Control Prevents Data Overrun n If a packet arrives in sequence n the receiver n n n passes the packet to the receiving application and transmits an ACK to the sender When an ACK arrives n the sender n n discards its copy of the ACKed packet and transmits the next packet © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 26
26. 5 Techniques That Transport Protocols Use 26. 5. 4 Flow Control Prevents Data Overrun n n Figure 26. 2 illustrates sliding window mechanism Sliding window can increase throughput dramatically n n compare the sequence of transmissions with a stop-and-go scheme and a sliding window scheme Figure 26. 3 contains a comparison for a 4 -packet transmission in either case © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 27
26. 5 Techniques That Transport Protocols Use 26. 5. 4 Flow Control Prevents Data Overrun © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 28
26. 5 Techniques That Transport Protocols Use 26. 5. 4 Flow Control Prevents Data Overrun © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 29
26. 5 Techniques That Transport Protocols Use 26. 5. 4 Flow Control Prevents Data Overrun n To understand the significance of sliding window n imagine an extended communication that involves many packets n For such networks, a sliding window protocol can increase performance substantially. The potential improvement is: where n n n Tw is the throughput that can be achieved with a sliding window protocol Tg is the throughput that can be achieved with a stop-and-go protocol W is the window size © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 30
26. 5 Techniques That Transport Protocols Use 26. 5. 4 Flow Control Prevents Data Overrun n Throughput cannot be increased arbitrarily, by just increasing the window size n The bandwidth of the underlying network imposes an upper bound; bits cannot be sent faster than the hardware can carry them n The equation can be rewritten ( B is the underlying bandwidth): © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 31
26. 6 Techniques to Avoid Congestion n n How easily can congestion occur? Consider case in Figure 26. 4 (below) © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 32
26. 6 Techniques to Avoid Congestion n n Assume each connection in Figure 26. 4 operates at 1 Gbps Consider what happens if both computers attached to switch 1 attempt to send data to a computer attached to switch 2 n n n Switch 1 receives data at an aggregate rate of 2 Gbps, but can only forward 1 Gbps to switch 2 This situation is known as congestion Congestion results in delay © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 33
26. 6 Techniques to Avoid Congestion n If congestion persists n n Retransmission can be used to recover lost packets n n the switch will run out of memory and begin discarding packets But retransmission sends more packets into the network If the situation persists, network can become unusable n this condition is known as congestion collapse © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 34
26. 6 Techniques to Avoid Congestion n n In the Internet, congestion usually occurs in routers Transport protocols attempt to avoid congestion collapse n by monitoring the network and reacting quickly once congestion starts © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 35
26. 6 Techniques to Avoid Congestion n n There are two basic approaches: Arrange for intermediate systems (i. e. , routers) to inform a sender when congestion occurs n n n implemented either by having routers send a special message to the source of packets when congestion occurs or by having routers set a bit in the header of each packet that experiences delay caused by congestion Use increased delay or packet loss as an estimate of congestion n Implemented by the computer that receives the packet including information in the ACK to inform the original sender © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 36
26. 6 Techniques to Avoid Congestion n Using delay and loss to estimate congestion is reasonable in the Internet because: n n Modern network hardware works well Most delay and loss results from congestion, not hardware failures © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 37
26. 6 Techniques to Avoid Congestion n The appropriate response to congestion n n Reducing the rate at which packets are being transmitted Sliding window protocols can achieve the effect of reducing the rate by temporarily reducing the window size © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 38
26. 7 The Art of Protocol Design n n Techniques needed to solve specific problems are well-known, but protocol design is nontrivial, because: First, protocol details must be chosen carefully n n n Small design errors can result in incorrect operation, unnecessary packets, or delays For example, if sequence numbers are used, each packet must contain a sequence number in the packet header The field must be large enough so sequence numbers are not reused frequently, but small enough to avoid wasting unnecessary bandwidth © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 39
26. 7 The Art of Protocol Design n Second, protocols can interact in an unexpected way n For example, consider the interaction between flow control and congestion control mechanisms © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 40
26. 7 The Art of Protocol Design n n A sliding window scheme uses more of the network bandwidth to improve throughput A congestion control mechanism does the opposite n It reduces the number of packets being inserted to prevent the network from collapsing © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 41
26. 7 The Art of Protocol Design n Computer system reboot poses another serious challenge to transport protocol design n Imagine a situation where two applications n n establish a connection begin sending data, and then the computer receiving data reboots software on the rebooted computer has no knowledge of a connection protocol software on the sending computer considers the connection valid © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 42
26. 7 The Art of Protocol Design n If a protocol is not designed carefully n a duplicate packet can cause a computer to incorrectly create a connection and begin receiving data in midstream © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 43
26. 8 Techniques Used in TCP to Handle Packet Loss n How does TCP achieve reliability? n n n The answer is complex because TCP uses a variety of schemes that are combined in novel ways TCP uses retransmission to compensate for packet loss TCP provides data flow in both directions n n both sides of a communication participate in retransmission when TCP receives data, it sends an ACK back to the sender © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 44
26. 8 Techniques Used in TCP to Handle Packet Loss n Whenever it sends data n n TCP starts a timer, and retransmits the data if the timer expires TCP retransmission operates as Figure 26. 5 illustrates © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 45
26. 8 Techniques Used in TCP to Handle Packet Loss © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 46
26. 8 Techniques Used in TCP to Handle Packet Loss n TCP's retransmission is the key to its success n n n because it handles communication across an arbitrary path TCP must be ready to retransmit any message that is lost How long should TCP wait before retransmitting? n n ACKs from a computer on a LAN are expected to arrive within a few ms but a satellite connection requires hundreds of ms © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 47
26. 8 Techniques Used in TCP to Handle Packet Loss n On one hand n n waiting too long for such an ACK leaves the network idle and does not maximize throughput On the other hand n retransmitting quickly does not work well on a satellite connection n because the unnecessary traffic consumes network bandwidth and lowers throughput © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 48
26. 8 Techniques Used in TCP to Handle Packet Loss n n TCP faces a difficult challenge: Bursts of datagrams can cause congestion n n which causes transmission delays along a given path to change rapidly The total time required to send a message and receive an ACK can increase © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 49
26. 9 Adaptive Retransmission n Before TCP was invented n n n transport protocols used a fixed value for retransmission delay the protocol designer or network manager chose a value that was large enough for the expected delay TCP designers realized that a fixed timeout would not operate well for the Internet n n Thus, they chose to make TCP's retransmission adaptive TCP monitors current delay on each connection n It adapts (changes) the retransmission timer accordingly © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 50
26. 9 Adaptive Retransmission n n How can TCP monitor Internet delays? TCP cannot know the exact delays n n n TCP estimates round-trip delay for each active connection by measuring the time needed to receive a response TCP records the time at which the message was sent When a response arrives n TCP subtracts the time the message was sent from the current time to produce a new estimate of the round-trip delay for that connection © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 51
26. 9 Adaptive Retransmission n As it sends data packets and receives ACKs n n TCP generates a sequence of round-trip estimates It uses a statistical function to produce a weighted average TCP keeps an estimate of the variance It uses a linear combination of the estimated mean and variance to compute estimated time © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 52
26. 9 Adaptive Retransmission n n TCP adaptive retransmission works well: Using the variance helps TCP react quickly n n when delay increases following a burst of packets Using a weighted average helps TCP reset the retransmission timer n if the delay returns to a lower value after a temporary burst © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 53
26. 9 Adaptive Retransmission n When the delay remains constant n n TCP adjusts the retransmission timeout to a value that is slightly longer than the mean round-trip delay When delays start to vary n TCP adjusts the retransmission timeout to a value greater than the mean to accommodate peaks © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 54
26. 10 Comparison of Retransmission Times n How does adaptive retransmission help TCP to maximize throughput on each connection? n n consider a case of packet loss on two connections that have different round-trip delays Figure 26. 6 illustrates traffic on such two connections n TCP sets the retransmission timeout to be slightly longer than the mean round-trip delay © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 55
26. 10 Comparison of Retransmission Times n If the delay is large n n If the delay is small n n TCP uses a large retransmission timeout TCP uses a small timeout The goal is to wait long enough to determine that a packet was lost n without waiting longer than necessary © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 56
26. 10 Comparison of Retransmission Times © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 57
26. 11 Buffers, Flow Control, and Windows n n TCP uses a window mechanism to control the flow of data Unlike the simplistic packet-based window scheme described above n n a TCP window is measured in bytes When a connection is established n each end of the connection allocates a buffer n to hold incoming data and sends the size of the buffer to the other end © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 58
26. 11 Buffers, Flow Control, and Windows n As data arrives n n receiving TCP sends ACKs, which specify the remaining buffer size Window to refer to the buffer space available at any time n n a notification that specifies the size of the window is known as a window advertisement a receiver sends a window advertisement with each ACK © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 59
26. 11 Buffers, Flow Control, and Windows n If the receiver can read data as quickly as it arrives n n If the sender operates faster than the receiver n n n a receiver will send a positive window advertisement along with each ACK incoming data will eventually fill the receiver's buffer causing the receiver to advertise a zero (0) window A sender that receives a zero window advertisement n must stop sending n n until the receiver again advertises a positive window Figure 26. 7 illustrates window advertisements © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 60
26. 11 Buffers, Flow Control, and Windows © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 61
26. 12 TCP's Three-Way Handshake n To establish or terminate connections reliably n TCP uses a 3 -way handshake n n in which three messages are exchanged During the 3 -way handshake to start a connection n each side sends a control message that specifies an initial buffer size (for flow control) and a sequence number © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 62
26. 12 TCP's Three-Way Handshake n TCP's 3 -way exchange is necessary and sufficient to ensure unambiguous agreement n n despite packet loss, duplication, delay, and replay events The handshake insures that TCP will not open or close a connection until both ends have agreed © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 63
26. 12 TCP's Three-Way Handshake n n Term synchronization segment (SYN segment) to describe the control messages used in a 3 -way handshake to create a connection Term FIN segment (short for finish segment) to describe control messages used in a 3 -way handshake to close a connection © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 64
26. 12 TCP's Three-Way Handshake n n Figure 26. 8 illustrates the 3 -way handshake to create a connection A key aspect of the 3 -way handshake is the selection of sequence numbers n TCP requires each end to generate a random 32 -bit sequence number that becomes the initial sequence © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 65
26. 12 TCP's Three-Way Handshake Connection Establishment © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 66
26. 12 TCP's Three-Way Handshake n If an application attempts to establish a new TCP connection after a computer reboots n n n TCP chooses a new random number The probability of selecting a random value that matches the sequence used on a previous connection is low So TCP avoids replay problems n The sequence numbers on the new connection will differ from the sequence numbers used on the old connection © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 67
26. 12 TCP's Three-Way Handshake n n The 3 -way handshake uses FIN segments to close n An ACK is sent in each direction along with a FIN to guarantee that all data has arrived before the connection is terminated Figure 26. 9 illustrates the exchange © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 68
26. 12 TCP's Three-Way Handshake Connection Termination © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 69
26. 13 TCP Congestion Control n n n One of the most interesting aspects of TCP is a mechanism for congestion control In the Internet, delay or packet loss is more likely to be caused by congestion than a hardware failure Retransmission can exacerbate the problem of congestion n n by injecting additional copies of a packet To avoid congestion collapse n n TCP uses changes in delay as a measure of congestion It responds to congestion by reducing the rate at which it retransmits data © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 70
26. 13 TCP Congestion Control n Although we think of reducing the rate of transmission n n TCP does not compute a data rate Instead, TCP bases transmission on buffer size n That is, the receiver advertises a window size, and the sender can transmit data to fill the receiver's window before an ACK is received © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 71
26. 13 TCP Congestion Control n To control the data rate n n By temporarily reducing the window size n n TCP imposes a restriction on the window size the sending TCP effectively reduces the data rate TCP can achieve a reduction in data rate n by temporarily reducing the window size © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 72
26. 13 TCP Congestion Control n In the extreme case where loss occurs n n TCP temporarily reduces the window to one-half of its current value TCP uses a special congestion control mechanism when starting a new connection or when a message is lost n instead of transmitting enough data to fill the receiver's buffer n TCP begins by sending a single message containing data © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 73
26. 13 TCP Congestion Control n If an acknowledgement arrives without additional loss n n If both acknowledgements arrive n n TCP doubles the amount of data being sent and sends two additional messages TCP sends four messages, and so on The exponential increase continues n until TCP is sending half of the receiver's advertised window © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 74
26. 13 TCP Congestion Control n When one-half of the original window size is reached n TCP slows the rate of increase and increases the window size linearly n n n as long as congestion does not occur The approach is known as slow start TCP's congestion control mechanisms respond well to increases in traffic n By backing off quickly, TCP is able to alleviate congestion © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 75
26. 14 TCP Segment Format n TCP uses a single format for all messages n n including messages that carry data, those that carry ACKs, and messages that are part of the 3 -way handshake used to create or terminate a connection (SYN and FIN) TCP uses the term segment to refer to a message Figure 26. 10 illustrates the TCP segment format A TCP connection contains two streams of data n one flowing in each direction © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 76
26. 14 TCP Segment Format n If the applications at each end are sending data simultaneously n n n TCP can send a single segment that carries outgoing data The ACK for incoming data, and a window advertisement that specifies the amount of additional buffer space available for incoming data Some of the fields in the segment refer to the data stream traveling in the forward direction n while other fields refer to the data stream traveling in the reverse direction © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 77
26. 14 TCP Segment Format © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 78
26. 14 TCP Segment Format n ACKNOWLEDGEMENT NUMBER n n specifies the sequence number of the data that is expected next WINDOW n specifies how much additional buffer space is available beyond the ACKed data n n The ACK always refers to the first position for which data is missing If segments arrive out of order, a receiving TCP generates the same ACK multiple times until the missing data arrives © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 79
26. 14 TCP Segment Format n SEQUENCE NUMBER n n Refers to outgoing data, it gives the sequence number of the first byte of data being carried in the segment A receiver uses the sequence number to reorder segments that arrive out of order and to compute an acknowledgement number © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 80
26. 14 TCP Segment Format n DESTINATION PORT n n SOURCE PORT n n identifies which application program on the receiving computer should receive the data identifies the application program that sent the data CHECKSUM n contains a checksum that covers the TCP segment header and the data © 2009 Pearson Education Inc. , Upper Saddle River, NJ. All rights reserved. 81
- Slides: 81