110 likes | 358 Views
Chapter 24 Transport Control Protocol (TCP). Layer 4 protocol Responsible for reliable end-to-end transmission Provides illusion of reliable network to application programmers no need to worry that data will be lost, duplicated or delivered out of order
E N D
Chapter 24 Transport Control Protocol (TCP) • Layer 4 protocol • Responsible for reliable end-to-end transmission • Provides illusion of reliable network to application programmers • no need to worry that data will be lost, duplicated or delivered out of order • Sequence number used to reorder segments
Services offered by TCP to application programs • Connection-oriented service • application first requests a connection to a destination and then use the connection to transfer data. • 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 exactly as sent, with no data missing or out of order. • full duplex communication • data may flow in either direction at any time. TCP can buffer both outgoing and incoming data.
TCP services (cont.) • stream interface • TCP provides a stream interface in which an application sends a continuous sequence of bytes across a connection • TCP does not provide a notion of records. • reliable connection startup • when two applications create a connection, both must agree to the new connection • random 32 bit sequence numbers generated by sender & receiver at beginning of a connection to prevent interference from other connections.. • graceful connection shutdown • TCP guarantees to deliver all transmitted data reliably before closing a connection.
TCP Characteristics • end-to-end protocol (fig 24.1) • TCP provides a connection directly from an application on one computer to another application on a remote computer • Provides virtual connections • connections achieved in software • underlying hardware does not provide support for connections. • TCP software modules on the two machines exchange messages to achieve the illusions of a connection.
Reliability through Retransmission (fig 24.2) • When TCP sends data, the sender handles packet loss via a retransmission scheme where both sender and receiver participates • When TCP receives data, it sends an acknowledgement back to the sender. • Whenever TCP sends data, a timer is started. • Data is retransmitted if the timer expires before an acknowledgement arrives • If acknowledgement packet is lost, receiver may receive duplicate packet.
How long should TCP wait before retransmitting? • The delay required for data to reach a destination and an acknowledgement to return depends on traffic conditions in the internet as well as the distance to the destination. • TCP uses adaptive retransmission (fig 24.3) since its retransmission timer changes based on current network conditions and delays. • TCP monitors delays by calculating the round-trip time from the time a packet is sent until an acknowledgement of the packet is received. • Ideally, timer is set just long enough to determine that a packet was lost
Flow Control(fig 24.4) • handled via a window mechanism such as sliding window with changing window sizes • When a connection is established, each end of the connection allocates a buffer to hold incoming data, and sends the size of the buffer (window advertisement) to the other end. • As data arrives, the receiver sends the remaining buffer size (window size advertisement) along with the acknowledgement. • window size is always measured beyond (relative to) the data being acknowledged. • window size decreases whenever data fills the buffer and increases whenever the application reads data from the buffer.
Three-Way Handshake(fig 24.5) • used by TCP to guarantee that connections are established or terminated reliably by exchanging three messages • necessary and sufficient to ensure unambiguous agreement in spite of packet loss (causing retransmission) or duplication (due to retransmission) • synchronization (SYN) segment used to create a connection, • finish (FIN) segment used to close a connection
Congestion Control • packet loss or extremely long delays is more likely to be caused by congestion (routers dropping packets due to overflow of router buffers) than hardware failure. • Retransmission of packets by transport protocols can exacerbate the problem by injecting additional copies of a message, • TCP uses packet loss as a measure of congestion, and responds by reducing the rate at which it retransmit data (router sends source quench message when it drops an incoming packet).
Congestion Control • Used by TCP when a message is lost • Instead of retransmitting enough data to fill the receiver’s buffer window size, TCP starts by sending a single message containing data. • If the acknowledgement arrives, TCP doubles the amount of data being sent by sending two messages. • When acknowledgement arrives for these two, TCP sends four more, and so on. • TCP’s congestion control scheme helps alleviate congestion by backing off quickly. • By not adding retransmissions to a congested network, TCP’s congestion control scheme helps prevents congestion collapse.
TCP Segment (Message) Format(fig 24.6) • 16 bit source port identifies the application program that sent the data • 16 bit destination port identifies application program on the receiving computer. • 32-bit sequence number of outgoing data in message used by receiver to reorder out-of-order segments and to compute acknowledgement number • 32-bit acknowledgement number containing sequence number of data that has being received • 16 bit window specifies buffer space available for incoming data • 16 bit checksum • data