Download presentation
Presentation is loading. Please wait.
Published byAlison Hudson Modified over 9 years ago
1
NET0183 Networks and Communications Lectures 26 and 27 TCP: a transport layer protocol 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks Lecture powerpoints from the recommended textbook are by Lami Kaya, LKaya@ieee.org. Lecture powerpoints are © 2009 Pearson Education Inc. Their content has sometimes been edited by Andy Brooks. transport layer protocol/samskiptareglur flutningslags
2
8/25/2009 NET0183 Networks and Communications by Dr Andy Brooks 2 The recommended textbook is Computer Networks and Internets by Douglas E. Comer http://www.coursesmart.com/0136066992/?a=1773944 www.pearson-books.com/student (for additional discounts and offers) http://www.coursesmart.com/0136066992/?a=1773944 www.pearson-books.com/student
3
8/25/2009 NET0183 Networks and Communications by Dr Andy Brooks 3 http://i.techrepublic.com.com/blogs/ip-encap.png Data Link Layer (OSI Model) Physical Layer (OSI Model)...just another protocol stack diagram
4
4 http://www.fatpipe.org/~mjb/Drawings/
5
TCP: a transport layer protocol Most Internet applications are built to use TCP. TCP is the major transport protocol. Hence the term “TCP/IP”. TCP provides a reliable transport service. 8/25/2009 NET0183 Networks and Communications by Dr Andy Brooks 5... you acknowledge you have received the package...
6
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.6 26.3 The Service TCP Provides to Applications 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 complete and in order. Full Duplex Communication. –A TCP connection allows data to flow in either direction at any time.
7
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.7 26.3 The Service TCP Provides to Applications Stream Interface. –An application sends a continuous sequence of octets. “Transmission Control Protocol (TCP) accepts data from a data stream, 'segments' it into chunks, and adds a TCP header creating a TCP segment. The TCP segment is then encapsulated into an IP packet.” TCP segment @ Wikipedia 22-Mar-10 Reliable Connection Startup. –TCP allows two applications to reliably start communication. Graceful Connection Shutdown. –TCP insures that both sides have agreed to shut down the connection after all the data has been delivered.
8
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.8 26.4 End-to-End Service and Virtual Connections TCP is classified as an end-to-end protocol. –TCP provides communication between an application on one computer to an application on another computer. The connections in TCP are called virtual connections because the connections are achieved in software. 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.
9
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.9 26.4 End-to-End Service and Virtual Connections Figure 26.1 Illustration of how TCP views the underlying Internet. see animation at http://www.netbook.cs.purdue.edu/ “A Packet Travelling Through Layers”http://www.netbook.cs.purdue.edu/
10
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.10 An end-to-end transport protocol must be carefully designed to achieve efficient and reliable transfer. Major problems include: Unreliable Communication –IP packets sent across the Internet can be lost, duplicated, corrupted, delayed, or delivered out of order. End System Reboot –Either of the two end systems might crash and reboot. 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. 26.5 Techniques That Transport Protocols Use
11
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.11 26.5 Techniques That Transport Protocols Use To check for bits that are changed during transmission, a protocol might include parity bits, a checksum, or a cyclic redundancy check (CRC). Transport protocols do more than detect errors, they employ techniques to repair or circumvent problems. The following sections discuss these techniques.
12
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.12 26.5 Techniques That Transport Protocols Use 26.5.1 Sequencing To 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 an incoming packet should be handled.
13
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.13 26.5 Techniques That Transport Protocols Use 26.5.1 Sequencing To 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 software 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 protocol software discards the duplicate. Andy asks: How often does this happen?
14
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.14 26.5 Techniques That Transport Protocols Use 26.5.2 Retransmission to Handle Lost Packets 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. The sender checks that each packet is transferred successfully. Whenever it sends a packet, the sender starts a timer. timer/tímamælir
15
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.15 26.5 Techniques That Transport Protocols Use 26.5.2 Retransmission to Handle Lost Packets If an acknowledgement arrives before the timer expires the protocol software cancels the timer. If the timer expires before an acknowledgement arrives the protocol software 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 the bound is exceeded, the destination will be declared unreachable. Andy asks: What is the maximum number of retransmissions?
16
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.16 26.5 Techniques That Transport Protocols Use 26.5.3 Techniques To 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. –After the second packet arrives, the delayed copy of packet 3 arrives from the earlier conversation. –Then packet 3 arrives from the second conversation. A packet from an earlier conversation might be accepted and the correct packet discarded as a duplicate.
17
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.17 26.5 Techniques That Transport Protocols Use 26.5.3 Techniques To Avoid Replay Replay errors can also occur with control packets. Consider when 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. 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.
18
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.18 26.5 Techniques That Transport Protocols Use 26.5.4 Flow Control To Prevent Data Overrun Flow control techniques are available to prevent a fast computer from sending too much data to a slower receiver. The simplest form of flow control is 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 in the form of an ACK –stop-and-go protocols result in low throughput Another flow control technique is 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.
19
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.19 26.5 Techniques That Transport Protocols Use 26.5.4 Flow Control To Prevent 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 Sliding window can increase throughput dramatically. Figure 26.3 contains a comparison for a 4-packet transmission using stop-and-go and sliding window. Figure 26.2 shows why the technique is called sliding window.
20
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.20 26.5 Techniques That Transport Protocols Use 26.5.4 Flow Control to Prevent Data Overrun Figure 26.3 Comparison of a transmission using (a) stop-and-go and (b) sliding window.
21
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.21 26.5 Techniques That Transport Protocols Use 26.5.4 Flow Control to Prevent Data Overrun Figure 26.2 An illustration of a sliding window in (a) initial, (b) intermediate, and (c) final positions. still unsent already acknowledged
22
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.22 26.5 Techniques That Transport Protocols Use 26.5.4 Flow Control to Prevent Data Overrun Imagine an extended communication that involves many packets. A sliding window protocol can increase performance substantially. The potential improvement is: where T w is the throughput that can be achieved with sliding window T g is the throughput that can be achieved with stop-and-go W is the window size Throughput cannot be increased arbitrarily by increasing the windo 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):
23
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.23 26.6 Techniques to Avoid Congestion How easily can congestion occur? Figure 26.4 Four hosts connected by two switches. 1 Gbps
24
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.24 26.6 Techniques to Avoid Congestion Assume each connection in Figure 26.4 operates at 1 Gbps. 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. 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 even more packets into the network! If the situation persists, the network can become unusable. –This condition is known as congestion collapse.
25
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.25 26.6 Techniques to Avoid Congestion Transport protocols attempt to avoid congestion collapse by monitoring the network and reacting quickly once congestion starts. 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 information is included in the ACK to inform the original sender
26
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.26 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 The appropriate response to congestion is to reduce 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. Andy asks: For which protocols does this actually happen?
27
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.27 26.7 The Art of Protocol Design Protocol design is nontrivial, because: First, protocol details must be chosen carefully. –Small design errors can result in incorrect operation. –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. Second, protocols can interact in unexpected ways. –A sliding window scheme uses more of the network bandwidth to improve throughput. –A congestion control mechanism does the opposite by reducing the number of packets being inserted to prevent the network from collapsing.
28
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.28 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
29
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.29 26.8 Techniques Used in TCP to Handle Packet Loss Figure 26.5 Illustration of TCP retransmission after a packet loss.
30
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.30 TCP's retransmission is the key to its success 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 On the 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 Bursts can increase congestion and vary delays at any time. “TCP faces a difficult challenge.” 26.8 Techniques Used in TCP to Handle Packet Loss
31
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.31 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 so they made TCP's retransmission adaptive. –TCP monitors current delay on each connection. It adapts (changes) the retransmission timer accordingly. But how can TCP monitor Internet delays?
32
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.32 26.9 Adaptive Retransmission TCP estimates round-trip delay for each active connection. 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. As it sends data packets and receives ACKs –TCP generates a sequence of round-trip estimates. –TCP calculates an average and standard deviation. When the round-trip delay remains constant: –TCP adjusts the retransmission timeout to a value that is slightly greater than the average round-trip delay. When round-trip delays start to vary: –TCP adjusts the retransmission timeout to a value greater than the average round-trip delay to accommodate the variation. Andy asks: what are the formulae actually used?
33
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.33 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 average round-trip delay. If the delay is large –TCP uses a large retransmission timeout If the delay is small –TCP uses a small retransmission timeout The goal is to wait long enough to determine that a packet was lost without waiting longer than necessary.
34
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.34 26.10 Comparison of Retransmission Times Figure 26.6 Timeout and retransmission on twp TCP connections that have different round-trip delays.
35
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.35 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 earlier, 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. As data arrives, receiving TCP sends ACKs, which specify the remaining buffer size. TCP uses the term Window to refer to the amount of buffer space available at any time. A receiver is said to send a window advertisement with each ACK.
36
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.36 26.11 Buffers, Flow Control, and Windows If the receiver can read data as quickly as it arrives, it 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.
37
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.37 26.11 Buffers, Flow Control, and Windows Figure 26.7 A sequence of messages that illustrates TCP flow for a maximum segment size of 1000 bytes.
38
The port numbers identify the applications. Window is the number of bytes (beyond the sequence number in the acknowledgement field) that the receiver is currently willing to receive. If the ACK flag (A) is set, the value of Acknowledgement Number is the next sequence number that the receiver is expecting (thus acknowledging receipt of all prior bytes). The Sequence Number is the sequence number of the first byte of data in the segment. 38 http://www.fatpipe.org/~mjb/Drawings/
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.