Download presentation
Presentation is loading. Please wait.
Published byNigel Evans Modified over 6 years ago
1
Computer Networks and Internets, 5e By Douglas E. Comer
Lecture PowerPoints By Lami Kaya, Modified by S. Jane Fritz, 2010 © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 1 1
2
Chapter 26 TCP: Reliable Transport Service
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 2 2
3
Topics Covered 26.1 Introduction
26.2 The Transmission Control Protocol 26.3 The Service TCP Provides to Applications 26.4 End-to-End Service and Virtual Connections 26.5 Techniques That Transport Protocols Use 26.6 Techniques to Avoid Congestion 26.7 The Art of Protocol Design © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 3 3
4
Topics Covered 26.8 Techniques Used in TCP to Handle Packet Loss
26.9 Adaptive Retransmission Comparison of Retransmission Times Buffers, Flow Control, and Windows TCP's Three-Way Handshake TCP Congestion Control TCP Segment Format © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 4 4
5
26.1 Introduction This chapter
considers transport protocols in general examines TCP 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 5
6
26.2 The Transmission Control Protocol
A programmer assumes the data will arrive correctly or the OS will inform the application that an error has occurred OS guarantees that data will be delivered reliably Protocol software must provide the following: 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 6
7
26.3 The Service TCP Provides to Applications
The service offered by TCP has the following features: Connection Orientation an application must first request a connection to a destination Point-to-Point Communication each TCP connection has exactly two endpoints Complete Reliability TCP guarantees that the data sent across a connection will be delivered completely and in order Full Duplex Communication allows data to flow in either direction © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 7 7
8
26.3 The Service TCP Provides to Applications
Stream Interface it does not group data into records or messages Reliable Connection Startup an application sends a continuous sequence of octets TCP allows two applications to reliably start communication Graceful Connection Shutdown TCP insures that both sides have agreed to shut down the connection © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 8 8
9
26.4 End-to-End Service and Virtual Connections
TCP is classified as an end-to-end protocol it provides communication between an application on one computer to an application on another computer The connections in TCP are called virtual connections 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 9
10
26.4 End-to-End Service and Virtual Connections
TCP software modules on two machines exchange messages to achieve the illusion of a connection TCP uses IP to carry messages IP treats each TCP message as data to be transferred Figure 26.1 illustrates how TCP views the Internet TCP software is needed at each end of a virtual connection but not on intermediate routers © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 10 10
11
26.4 End-to-End Service and Virtual Connections
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 11 11
12
Transport Protocols Use
26.5 Techniques That Transport Protocols Use 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 Messages sent across the Internet They can be lost, duplicated, corrupted, delayed, or delivered out of order End System Reboot either of the two end systems might crash and reboot © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 12 12
13
Transport Protocols Use
26.5 Techniques That Transport Protocols Use Heterogeneous End Systems A sender can generate data so fast that it overruns a slow receiver Congestion in the Internet If senders aggressively transmit data intermediate switches and routers can become overrun © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 13 13
14
26.5 Techniques That Transport Protocols Use
There are techniques that communication systems use to overcome some of the problems For example, to compensate for bits that are changed during transmission 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 14
15
26.5 Techniques That Transport Protocols Use
Transport protocols do more than detect errors they employ techniques that can repair or circumvent problems Transport protocols use a variety of tools 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 15
16
26. 5 Techniques That Transport Protocols Use 26. 5
26.5 Techniques That Transport Protocols Use Sequencing Handle Duplicates and Out-of-Order Delivery 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 to determine how the packet should be handled © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 16 16
17
26. 5 Techniques That Transport Protocols Use 26. 5
26.5 Techniques That Transport Protocols Use Sequencing Handle Duplicates and Out-of-Order Delivery If the packet is the next one expected (i.e., has arrived in order) the protocol software delivers the packet to the next highest layer 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 17
18
Whenever a frame arrives intact
26.5 Techniques That Transport Protocols Use Sequencing Handle Duplicates and Out-of-Order Delivery To handle packet loss transport protocols use positive acknowledgement (ACK) with retransmission Whenever a frame arrives intact 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 18
19
26. 5 Techniques That Transport Protocols Use 26. 5
26.5 Techniques That Transport Protocols Use Sequencing Handle Duplicates and Out-of-Order Delivery If an acknowledgement arrives before the timer expires the software cancels the timer If the timer expires before an acknowledgement arrives the protocol sends another copy of the packet and starts the timer again Sending a second copy is known as retransmitting 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 if bound exceeded, the destination will be declared unreachable © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 19 19
20
26. 5 Techniques That Transport Protocols Use 26. 5
26.5 Techniques That Transport Protocols Use Techniques Avoid Replay Extraordinarily long delays can lead to replay errors For example, consider the following sequence of events Assume two computers agree to communicate at 1 PM One computer sends a sequence of 10 packets to the other A hardware problem causes packet 3 to be delayed 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 20
21
26. 5 Techniques That Transport Protocols Use 26. 5
26.5 Techniques That Transport Protocols Use Techniques Avoid Replay After the second packet arrives, the delayed copy of packet 3 arrives from the earlier conversation Packet 3 arrives from the second conversation A packet from an earlier conversation might be accepted and the correct packet discarded as a duplicate © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 21 21
22
26. 5 Techniques That Transport Protocols Use 26. 5
26.5 Techniques That Transport Protocols Use Techniques Avoid Replay 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 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 22
23
26. 5 Techniques That Transport Protocols Use 26. 5
26.5 Techniques That Transport Protocols Use Techniques Avoid Replay 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 (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 23
24
26. 5 Techniques That Transport Protocols Use 26. 5
26.5 Techniques That Transport Protocols Use Flow Control Prevents Data Overrun Techniques are available to prevent a fast computer from sending so much data to overrun a slower receiver Flow control techniques are employed to handle the problem The simplest form of flow control is a stop-and-go 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 24
25
26. 5 Techniques That Transport Protocols Use 26. 5
26.5 Techniques That Transport Protocols Use Flow Control Prevents Data Overrun Another flow control technique known as sliding window The sender and receiver use a fixed window size 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 25
26
If a packet arrives in sequence
26.5 Techniques That Transport Protocols Use Flow Control Prevents Data Overrun If a packet arrives in sequence the receiver passes the packet to the receiving application and transmits an ACK to the sender When an ACK arrives the sender 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
27
Sliding window can increase throughput dramatically
26.5 Techniques That Transport Protocols Use Flow Control Prevents Data Overrun Figure 26.2 illustrates sliding window mechanism Sliding window can increase throughput dramatically 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 27
28
26.5 Techniques That Transport
Protocols Use Flow Control Prevents Data Overrun © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 28 28
29
26.5 Techniques That Transport
Protocols Use Flow Control Prevents Data Overrun © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 29 29
30
26. 5 Techniques That Transport Protocols Use 26. 5
26.5 Techniques That Transport Protocols Use Flow Control Prevents Data Overrun To understand the significance of sliding window imagine an extended communication that involves many packets For such networks, a sliding window protocol can increase performance substantially. The potential improvement is: where 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 30
31
26. 5 Techniques That Transport Protocols Use 26. 5
26.5 Techniques That Transport Protocols Use Flow Control Prevents Data Overrun Throughput cannot be increased arbitrarily, by just increasing the window size The bandwidth of the underlying network imposes an upper bound; bits cannot be sent faster than the hardware can carry them The equation can be rewritten (B is the underlying bandwidth): © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 31 31
32
26.6 Techniques to Avoid Congestion
How easily can congestion occur? Consider case in Figure 26.4 (below) © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 32 32
33
26.6 Techniques to Avoid Congestion
Assume each connection in Figure 26.4 operates at 1 Gbps Consider what happens if both computers attached to switch1 attempt to send data to a computer attached to switch2 Switch1 receives data at an aggregate rate of 2 Gbps, but can only forward 1 Gbps to switch2 This situation is known as congestion Congestion results in delay © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 33 33
34
26.6 Techniques to Avoid Congestion
If congestion persists the switch will run out of memory and begin discarding packets Retransmission can be used to recover lost packets But retransmission sends more packets into the network If the situation persists, network can become unusable this condition is known as congestion collapse © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 34 34
35
26.6 Techniques to Avoid Congestion
In the Internet, congestion usually occurs in routers Transport protocols attempt to avoid congestion collapse by monitoring the network and reacting quickly once congestion starts © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 35 35
36
26.6 Techniques to Avoid Congestion
There are two basic approaches: Arrange for intermediate systems (i.e., routers) to inform a sender when congestion occurs 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 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 36
37
26.6 Techniques to Avoid Congestion
Using delay and loss to estimate congestion is reasonable in the Internet because: 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 37
38
26.6 Techniques to Avoid Congestion
The appropriate response to congestion 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 38
39
26.7 The Art of Protocol Design
Techniques needed to solve specific problems are well-known, but protocol design is nontrivial, because: First, protocol details must be chosen carefully 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 39
40
26.7 The Art of Protocol Design
Second, protocols can interact in an unexpected way For example, consider the interaction between flow control and congestion control mechanisms © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 40 40
41
26.7 The Art of Protocol Design
A sliding window scheme uses more of the network bandwidth to improve throughput A congestion control mechanism does the opposite 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 41
42
26.7 The Art of Protocol Design
Computer system reboot poses another serious challenge to transport protocol design Imagine a situation where two applications 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 42
43
26.7 The Art of Protocol Design
If a protocol is not designed carefully 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 43
44
26.8 Techniques Used in TCP to Handle Packet Loss
How does TCP achieve reliability? 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 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 44
45
26.8 Techniques Used in TCP to Handle Packet Loss
Whenever it sends data 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 45
46
26.8 Techniques Used in TCP to Handle Packet Loss
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 46 46
47
26.8 Techniques Used in TCP to Handle Packet Loss
TCP's retransmission is the key to its success 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? 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 47
48
26.8 Techniques Used in TCP to Handle Packet Loss
On one hand waiting too long for such an ACK leaves the network idle and does not maximize throughput On the other hand retransmitting quickly does not work well on a satellite connection because the unnecessary traffic consumes network bandwidth and lowers throughput © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 48 48
49
26.8 Techniques Used in TCP to Handle Packet Loss
TCP faces a difficult challenge: Bursts of datagrams can cause congestion 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 49
50
26.9 Adaptive Retransmission
Before TCP was invented 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 Thus, they chose to make TCP's retransmission adaptive TCP monitors current delay on each connection It adapts (changes) the retransmission timer accordingly © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 50 50
51
26.9 Adaptive Retransmission
How can TCP monitor Internet delays? TCP cannot know the exact delays 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 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 51
52
26.9 Adaptive Retransmission
As it sends data packets and receives ACKs 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 52
53
26.9 Adaptive Retransmission
TCP adaptive retransmission works well: Using the variance helps TCP react quickly when delay increases following a burst of packets Using a weighted average helps TCP reset the retransmission timer if the delay returns to a lower value after a temporary burst © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 53 53
54
26.9 Adaptive Retransmission
When the delay remains constant TCP adjusts the retransmission timeout to a value that is slightly longer than the mean round-trip delay When delays start to vary 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 54
55
26.10 Comparison of Retransmission Times
How does adaptive retransmission help TCP to maximize throughput on each connection? consider a case of packet loss on two connections that have different round-trip delays Figure 26.6 illustrates traffic on such two connections 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 55
56
26.10 Comparison of Retransmission Times
If the delay is large TCP uses a large retransmission timeout If the delay is small TCP uses a small timeout The goal is to wait long enough to determine that a packet was lost without waiting longer than necessary © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 56 56
57
26.10 Comparison of Retransmission Times
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 57 57
58
26.11 Buffers, Flow Control, and Windows
TCP uses a window mechanism to control the flow of data Unlike the simplistic packet-based window scheme described above a TCP window is measured in bytes When a connection is established each end of the connection allocates a buffer 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 58
59
26.11 Buffers, Flow Control, and Windows
As data arrives receiving TCP sends ACKs, which specify the remaining buffer size Window to refer to the buffer space available at any time 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 59
60
26.11 Buffers, Flow Control, and Windows
If the receiver can read data as quickly as it arrives a receiver will send a positive window advertisement along with each ACK If the sender operates faster than the receiver 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 must stop sending 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 60
61
26.11 Buffers, Flow Control, and Windows
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 61 61
62
26.12 TCP's Three-Way Handshake
To establish or terminate connections reliably TCP uses a 3-way handshake in which three messages are exchanged During the 3-way handshake to start a connection 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 62
63
26.12 TCP's Three-Way Handshake
TCP's 3-way exchange is necessary and sufficient to ensure unambiguous agreement 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 63
64
26.12 TCP's Three-Way Handshake
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 64
65
26.12 TCP's Three-Way Handshake
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 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 65
66
26.12 TCP's Three-Way Handshake Connection Establishment
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 66 66
67
26.12 TCP's Three-Way Handshake
If an application attempts to establish a new TCP connection after a computer reboots 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 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 67
68
26.12 TCP's Three-Way Handshake
The 3-way handshake uses FIN segments to close 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 68
69
26.12 TCP's Three-Way Handshake Connection Termination
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 69 69
70
26.13 TCP Congestion Control
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 by injecting additional copies of a packet To avoid congestion collapse 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 70
71
26.13 TCP Congestion Control
Although we think of reducing the rate of transmission TCP does not compute a data rate Instead, TCP bases transmission on buffer size 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 71
72
26.13 TCP Congestion Control
To control the data rate TCP imposes a restriction on the window size By temporarily reducing the window size the sending TCP effectively reduces the data rate TCP can achieve a reduction in data rate by temporarily reducing the window size © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 72 72
73
26.13 TCP Congestion Control
In the extreme case where loss occurs 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 instead of transmitting enough data to fill the receiver's buffer TCP begins by sending a single message containing data © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 73 73
74
26.13 TCP Congestion Control
If an acknowledgement arrives without additional loss TCP doubles the amount of data being sent and sends two additional messages If both acknowledgements arrive TCP sends four messages, and so on The exponential increase continues until TCP is sending half of the receiver's advertised window © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 74 74
75
26.13 TCP Congestion Control
When one-half of the original window size is reached TCP slows the rate of increase and increases the window size linearly 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 By backing off quickly, TCP is able to alleviate congestion © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 75 75
76
26.14 TCP Segment Format TCP uses a single format for all messages
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 illustrates the TCP segment format A TCP connection contains two streams of data one flowing in each direction © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 76 76
77
TCP Segment Format If the applications at each end are sending data simultaneously 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 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 77
78
TCP Segment Format © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 78 78
79
26.14 TCP Segment Format ACKNOWLEDGEMENT NUMBER WINDOW
specifies the sequence number of the data that is expected next WINDOW specifies how much additional buffer space is available beyond the ACKed data 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 79
80
26.14 TCP Segment Format SEQUENCE NUMBER
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 80
81
26.14 TCP Segment Format DESTINATION PORT SOURCE PORT CHECKSUM
identifies which application program on the receiving computer should receive the data SOURCE PORT identifies the application program that sent the data CHECKSUM contains a checksum that covers the TCP segment header and the data © 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. 81 81
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.