Site home page
(news and notices)

Get alerts when Linktionary is updated

Book updates and addendums

Get info about the Encyclopedia of Networking and Telecommunicatons, 3rd edition (2001)

Download the electronic version of the Encyclopedia of Networking, 2nd edition (1996). It's free!

Contribute to this site

Electronic licensing info



TCP (Transmission Control Protocol)

Related Entries    Web Links    New/Updated Information

Search Linktionary (powered by FreeFind)

Note: Many topics at this site are reduced versions of the text in "The Encyclopedia of Networking and Telecommunications." Search results will not be as extensive as a search of the book's CD-ROM.

TCP is a subset of the Internet protocol suite, which is often called TCP/IP, although the acronym TCP/IP refers to only two of the many protocols in the Internet protocol suite. Still, most people refer to the Internet protocols as TCP/IP and that style is retained here. For a description of the entire suite, refer to "Internet Protocol Suite."

The Internet Protocol suite consists of a set of protocols that provide a variety of networking services as shown in Figure T-1. TCP and UDP (User Datagram Protocol) are transport layer components that provide the connection point through which applications access network services. TCP and UDP use IP, which is a lower-layer best effort delivery service. IP encapsulates TCP and UDP information in datagrams and delivers the information across router-connected internetworks. See "IP (Internet Protocol)" and "UDP (User Datagram Protocol)."

TCP is a connection-oriented protocol that provides the flow controls and reliable data delivery services listed next. These services run in the host computers at either end of a connection, not in the network itself. Therefore, TCP is a protocol for managing end-to-end connections, as shown in Figure T-2. Since end-to-end connections may exist across a series of point-to-point connections, they are often called virtual circuits.

  • Connections    Two computers set up a connection to exchange data. The systems synchronize with one another to manage packet flows and adapt to congestion in the network.

  • Full-duplex operation    A TCP connection is a pair of virtual circuits (one in each direction). Only the two end systems can use the connection.

  • Error checking    A checksum technique is used to verify that packets are not corrupted.

  • Sequencing    Packets are numbered so that the destination can reorder packets and determine if a packet is missing.

  • Acknowledgements    Upon receipt of one or more packets, the receiver returns an acknowledgement (called an "ACK") to the sender indicating that it received the packets. If packets are not ACKed, the sender may retransmit the packets (or terminate the connection if it thinks the receiver has crashed).

  • Flow control    If the sender is overflowing the receiver by transmitting too quickly, the receiver drops packets. Failed ACKs alert the sender to slow down or stop sending.

  • Packet recovery services    The receiver can request retransmission of a packet. Also, if packet receipt is not ACKed, the sender will resend the packets.

Reliable data delivery services are critical for applications such as file transfers, database services, transaction processing, and other mission-critical applications in which every packet must be delivered-guaranteed. See "Reliable Data Delivery Services" for a general overview of reliable services.

While TCP provides these reliable services, it depends on IP to delivery packets. IP is often referred to as an unreliable or best effort service. While it seems odd to build a network that is unreliable, the original Internet architects wanted to remove as many services from the network itself to support fast packet delivery rather than reliability. Routers do not keep track of packets or do anything to ensure delivery. They just forward packets.

The assumption was that end systems would be relatively smart devices with memory and processors. The end devices could handle all the reliability functions rather than the network. This was actually a radical approach at the time, but the implications have been profound. It meant that end systems would become the focus of application development for the Internet, not the network.

In contrast, the telephone network implements an architecture in which end devices (phones) are dumb and the network is supposedly "smart." The only problem with this model is that you can't run applications on your phone that take advantage of the network. In fact, you are totally dependent on the phone company to deploy new applications (call waiting and caller ID are examples). Compared to the Internet, the phone system is a dinosaur. Consider that the user interface for the Web is a full-color graphical browser, while the interface for the telephone network is a 12-key pad!

While end-systems provide TCP's reliability functions, not all applications need them. For example, there is no need to recover lost packets in a live video stream. By the time they are recovered, the viewer has will have already seen the barely visible glitch caused by the missing packet. These applications just need speed. So UDP was created to provide an application interface to the network for real-time applications that don't need TCP's extra services. UDP provides a very simple port connection between applications and IP.

The topic "Reliable Data Delivery Services" has a subsection called "Partial Reliable Services" that describes several Internet protocols that provide some but not all of TCP's reliable services but more than what UDP provides. An example is RTP (Real-time Transport Protocol), a multimedia delivery protocol that provides what is called a "partial ordered service." RTP sequentially numbers packets and adds timing information for services that might need to reconstruct the original packet sequence.

See "Internet" for more information about the structure of the Internet and a history of its development. TCP is described in RFC 793 (Transmission Control Protocol, September 1981). Related documents with revisions and updates are listed on the related entries page. Also see RFC 1180 (A TCP/IP Tutorial, January 1991).

TCP Features

An end-to-end connection actually extends up through the TCP layer to the application that is using the network services. Note the ports in Figure T-1. The most common applications such as HTTP (Web services) and FTP (File Transfer Protocol) use ports that are "well known," so clients can connect to them to access a particular service without having to query on what port that service is running. For example, Web browsers automatically connect with port 80, FTP uses port 21, and Gopher use port 70.

A typical session involves sending packets from a source IP address and port to a destination IP address and port. The combination port and IP address is called a socket. You can think of a socket as the end of a connection. If a connection is like a circuit or wire, then the socket is the end of that wire, much like a telephone exists at the end of a voice circuit. Packets flow across networks between sockets. These packet flows can be identified by an IP address/port number combination.

TCP Segment Properties

A TCP segment is the packet of information that TCP uses to exchange data with its peers (TCP running on other hosts). The segment is what gets encapsulated into an IP datagram and transmitted across the network. See "Network Architecture" for a description of how information is exchanged between protocol layers.

Segments have a 20-byte header and a variable-length Data field. The fields of the TCP segment are described here and pictured in Figure T-3. Keep in mind that either station may send a segment that contains just header information and no data to provide the other system with session control information, such as an acknowledgment that a segment was received.

  • Source and Destination Ports    Contains the port numbers of the sockets at the source and destination sides of the connection.

  • Sequence Number    This field contains a sequential number for the receiver, which is a sequential number that identifies the data in the segment and where it belongs in the stream of data that has already been sent. The receiver can use the sequence number to reorder packets that have arrived out of order or to determine that a segment is missing. This field is used by the sliding-window algorithm.

  • Acknowledgment Number    This field is used by the receiver to indicate to the sender in a return message that it has received a previously sent packet. The number in this field is actually the sequence number for the next segment that the receiver expects. That number is calculated by incrementing the value in the Sequence Number field. This field is used by the sliding-window algorithm. Refer to "Flow-Control Mechanisms" for a description.

  • TCP Header Length    Specifies the length of the header.

  • Codes    This field is reserved.

  • URG (urgent)    This bit is set to 1 if there is information in the Urgent Pointer field of the header.

  • ACK (acknowledgment)    If ACK is set to 1, it indicates that the segment is part of an ongoing conversation and the number in the Acknowledgment Number field is valid. If this flag is set to 0 and SYN is set to 1, the segment is a request to establish a connection.

  • PSH (push)    A bit set by the sender to request that the receiver send data directly to the application and not buffer it.

  • RST (reset)    When set, the connection is invalid for a number of reasons and must be reset.

  • SYN (synchronize)    Used in conjunction with ACK to request a connection or accept a connection. SYN=1 and ACK=0 indicates a connection request. SYN=1 and ACK=1 indicates a connection accepted. SYN=0 and ACK=1 is an acknowledgment of the acknowledgment.

  • FIN (finish)    When set, this bit indicates that the connection should be terminated.

  • Sliding Window Size    Indicates how much space is available in the receiver's buffers. The field is used by the receiver to inform the sender that it needs to speed up or slow down its transmissions. If the receiver wants the sender to stop transmitting altogether, it can return a segment with 0 in this field.

  • Checksum    Provides an error-checking value to ensure the integrity of the segment.

  • Urgent Pointer    This field can be used by the sender to indicate a location in the data where some urgent data is located.

  • Options    A variable set aside for special options.

  • Data    A variable-length field that holds the messages or data from applications.

These many different fields are used to set up and control connections, as well as to provide the reliability services that guarantee data delivery. The next section provides some insight into how these features are used.

A Typical TCP Session

Assume a client needs to connect with a server. First, the client must contact the server and request a connection. After the connection is established, various control parameters for the connection are negotiated. After data transmission begins, a sliding window flow-control scheme is used to manage data transfer.

A connection is established via a three-way handshake, as described next. This handshake helps define the start of a new TCP connection, and prevents a host from being confused by duplicate packets generated by a previous connection that arrives late.

  1. Host A (the sender) sends a TCP segment to host B with the SYN flag set to 1 and the ACK flag set to 0.

  2. Host B returns a segment to host A in which both the SYN and ACK flags are set to 1.

  3. Host A can now acknowledge to host B that it received its ACK. It sends a segment in which ACK=1 and SYN=0.

Included these steps is a negotiation of an initial sequence number for the client and for the server (each uses its own sequence number scheme). Host A sends its starting number to host B and host B acknowledges that number by incrementing it and returning the number to host A. The same process is used to negotiate host B's starting sequence number.

After data is transmitted, the session is terminated. Host A sends a FIN=1 to host B. Host B then responds with ACK=1 and FIN=1 and host A responds to that with ACK=1.

TCP uses a keep-alive feature to keep connections open and manage connections. Keep-alive verifies that the computer at the other end of a connection is still available.

A single host can set up multiple connections over the TCP/IP network at any time. This is called multiplexing. If multiple applications or network processes are running, each may set up a connection to a different computer. For example, you can simultaneously open multiple Web browsers and connect with multiple sites.

TCP uses flow controls, sliding windows, and various other mechanisms to manage sessions. These are discussed further under the following headings:

  • "Connection Establishment"

  • "Flow-Control Mechanisms"

  • "Congestion Control Mechanism"

The topic congestion control discusses techniques that TCP uses to control congestion. Specifically, TCP relies on dropped packets as a signal that the receiver or network is overloaded! Much work has gone into improving this technique.

A number of IETF Working Groups are developing extensions to TCP or working on updates. Refer to the IETF Web site (listed on the related entries page) and see the Transport Area section.

Copyright (c) 2001 Tom Sheldon and Big Sur Multimedia.
All rights reserved under Pan American and International copyright conventions.