290 likes | 413 Views
TCP. Lecture 13 November 13, 2000. TCP Background. Transmission Control Protocol (TCP) TCP provides much of the functionality that IP lacks: reliable service. TCP Service. TCP provides the following functionality Connection Orientated Point-to-Point Communication Complete Reliability
E N D
TCP Lecture 13 November 13, 2000
TCP Background • Transmission Control Protocol (TCP) • TCP provides much of the functionality that IP lacks: reliable service
TCP Service • TCP provides the following functionality • Connection Orientated • Point-to-Point Communication • Complete Reliability • Full Duplex Communication • Streaming • Reliable Connection Startup • Graceful Connection Shutdown
Connection Orientated • A new connection must be created on both the sender and receiver before communication may begin.
Point-to-Point Communication • With P-T-P Communication, a clear start and end point exist. • Data is more secure; people should not be able to modify the data between the two points.
Complete Reliability • TCP guarantees that the exact data sent will be received in proper order, without loss, at the destination. • UDP, on the other hand, makes no such guarantee.
Full Duplex Communication • TCP allows for data to flow from the sender to the receiver, and from the receiver to the sender. • Either side can transmit at any time, or at the same time. • TCP can buffer data to ensure a constant flow.
Stream Interface • “Streaming” is where an application sends a constant flow of data. • No guarantee is made that the data received is of the same size. (Think about MTU).
Reliable Connection Startup • New connections must exist on both the sender and receiver before transmission begins. • Both sender and receiver must agree to use the new connection. • This eliminates errant packets from previous transmissions.
Graceful Communication Shutdown • Either the sender or the receiver can shutdown the connection. • TCP guarantees that all data is transmitted before shutting down the connection.
End-to-End Service • TCP is said to be end-to-end. • TCP provides the end-to-end connectivity between an application on the sender and an application on the receiver. • The connections between the two machines are virtual; the are implemented in software. • TCP data is encapsulated in an IP packet and transmitted.
Reliability • Two major areas of concern • Unreliable delivery of the underlying medium • Messages can be lost, delayed, delivered out of order, etc. • If a second connection is opened between machines, how does the receiver determine if the messages are for the first or the second connection? • Hardware reboot • If two machines are communicating, and one reboots, the other computer still sees an open connection. • How does the computer that rebooted handle messages from the time before the reboot?
Determining Retransmission Delay • Consider the two examples • LAN communication • Low delay • High throughput • IDEAL: low retransmission delay • Satellite communication • High delay • Low throughput • IDEAL: high retransmission delay
Retransmission (cont.) • Because TCP is was designed to work efficiently in multiple environments, a static retransmission delay was not effective. • Adaptive retransmission was the workaround. • TCP estimates round-trip delay based on the time it takes for the message to be sent, plus the time to receive the ACK. • The retransmission delay then becomes a linear combination of the mean round-trip delay and the variance.
Retransmission (cont.) • In general, adaptive retransmission sets the actual retransmission delay to be slightly longer than the actual round-trip estimate.
TCP & Windows, Buffers • TCP uses a similar scheme to the “sliding window” that was discussed earlier. • Buffer – total amount of memory allocated for the individual transmission. • Window – amount of data to send in one message. • Window Advertisement – amount of buffer remaining on the receiver’s side.
TCP Windowing (cont.) • If the receiving application can read data as fast as it arrives (or faster), it will send a window advertisement that is positive. • If the receiving application cannot read data as fast as it arrives, eventually the buffer will fill and the receiving application will send a zero window advertisement! Sending application will stop transmission until a nonzero window advertisement is received.
Handshaking (cont.) • The handshaking process used to create a connection is referred to the synchronization segment (SYN). • The process used to close a connection is referred to the finalize segment (FIN).
Congestion Control • TCP contains built-in congestion control. • As transmissions reach a busy node, they have an increased chance of having their TTL expiring! • If all transmissions into a busy node timeout, imagine if all senders kept resending the messages! This is called congestion collapse.
Congestion Control (cont.) • When TCP resends a message, it does so in the following manner: • If the message is the first in the retransmission, it will send a single message window, and wait for an ACK. • If the ACK is received w/o loss, it will double the amount of data to send (2 windows) • The increase continues until TCP is sending half of the advertised window, at which point it will slow itself down.
TCP Segment Header • Source Port (16 bits) • Destination Port (16 bits) • Sequence Number (32 bits): used to combine improperly received segments • Acknowledgement Number (32 bits): the value of the next ACK the sender is expecting to receive • Data Offset (HLEN) (4 bits): the number of 32 bit words in the header • Reserved (6 bits)
TCP Segment Header (cont.) • Control Bits (6 bits): (from left to right) • URG: Urgent Pointer field significant • ACK: Acknowledgement field significant • PSH: Push function • RST: Reset the connection • SYN: Synchronize sequence numbers • FIN: No more data from sender • Window (16 bits): The number of bytes the sender of this segment is willing to accept
TCP Segment Header (cont.) • Checksum (16 bits): the 16 bit one’s compliment of the one’s complement sum of all 16 bit words in the header and text (payload). • Urgent Pointer (16 bits): current value of the urgent pointer as an offset from the sequence number of this segment. • Options (variable): multiples of 8 bits.