Infodoc ID |
|
Synopsis |
|
Date |
2195 |
|
Transmission Control Protocol (TCP) |
|
3 Apr 1996 |
The Transmission Control Protocol (TCP)[1] is intended for use as a highly
reliable host-to-host protocol in packet-switched computer communication
networks, and in interconnected systems of such networks.
The primary purpose of TCP is to provide a reliable, securable, and logical
circuit or connection service between pairs of processes. To provide this
service on top of a less reliable Internet communication system requires
facilities in the following areas:
Basic data
Transfer reliability
Flow control
Multiplexing connections
Precedence and security
This section describes the functions to be performed by the Transmission
Control Protocol, the program that implements it, and its interface to programs
or users that require its services.
The explanation below is divided into the following sections. Each
section is preceded with an outline of topics that apply to that
section. Some of the topics are explained in greater detail within
each section - these are noted by "see detail below"
1. Overview - Where TCP Fits In
2. TCP operation services
3. Connection and disconnection
4. Data transfer
5. Flow control ("Windowing" concept)
6. Multiplexing Connection ("Socket" concept)
7. Sequence number
8. Checksum
9. TCP header translation
10. Interfaces to other Protocols & Applications
11. TCP/UDP port value ranges
1. Overview - Where TCP Fits In
------------------------------------
Computer communication systems are playing an increasingly important role in
military, government, and civilian environments. This section focuses its
attention primarily on military computer communication requirements, especially
robustness in the presence of communication unreliability and availability in
the presence of congestion. Many of these problems are found in the civilian
and government sector as well.
As strategic and tactical computer communication networks are developed and
deployed, it is essential to provide means of interconnecting them and to
provide standard interprocess communication protocols that can support a broad
range of applications. In anticipation of the need for such standards, the
Deputy Undersecretary of Defense for Research and Engineering has declared the
Transmission Control Protocol (TCP) described herein to be a basisfor DoD-wide
interprocess communication protocol standardization.
TCP is a connection-oriented, end-to-end reliable protocol designed to fit into
a layered hierarchy of protocols that support multi-network applications. The
TCP provides for reliable interprocess communication between pairs of processes
in host computers attached to distinct but interconnected computer
communication
networks. Very few assumptions are made as to the reliability of the
communication protocols below the TCP layer. TCP assumes it can obtain a
simple,
potentially unreliable datagram service from the lower-level protocols. In
principle, the TCP should be able to operate above a wide spectrum of
communication systems ranging from hard-wired connections to packet-switched
orcircuit-switched networks.
TCP is based on concepts first described by Cerf and Kahn. The TCP fits into
a layered protocol architecture just above a basic Internet Protocol, which
provides a way for the TCP to send and receive variable-length segments of
information enclosed in internet datagram "envelopes". The Internet datagram
provides a means for addressing source and destination TCPs in different
networks. The Internet protocol also deals with any fragmentation or
reassembly
of the TCP segments required to achieve transport and delivery through multiple
networks and interconnecting gateways. The Internet protocol also carries
information on the precedence, security classification, and compartmentation of
the TCP segments, so this information can be communicated end-to-end across
multiple networks. The diagram below shows the protocol layering.
+---------------------+
| higher-level |
+---------------------+
| TCP |
+---------------------+
| internet protocol |
+---------------------+
|communication network|
+---------------------+
Much of this is written in the context of TCP implementations that are
co-resident with higher-level protocols in the host computer. Some computer
systems are connected to networks via front-end computers that house the TCP
and internet protocol layers, as well as network-specific software. The TCP
specification describes an interface to the higher-level protocols that appears
to be implementable even for the front-end case, as long as a suitable host-
to-front end protocol is implemented.
2. TCP operation services
------------------------------
Topics: Connection-oriented
Basic data transfer
Flow controlled (windows)
Multiplexing
Reliability see detail below
Security/precedence
Reliability
(Segment numbering, Positive acknowledgment, Error detection and recovery)
The TCP must recover data that is damaged, lost, duplicated, or delivered
out of order by the Internet communication system. This is achieved by
assigning a sequence number to each octet transmitted, and requiring a
positive acknowledgment (ACK) from the receiving TCP. If the ACK is not
received within a timeout interval, the data is retransmitted. At the
receiver, the sequence numbers are used to correctly order segments that may
be received out of order and to eliminate duplicates.
Damage is handled by adding a checksum to each segment transmitted, checking
itat the receiver, and discarding damaged segments.
As long as the TCPs continue to function properly and the Internet system does
not become completely partitioned, no transmission errors will affect the
correct delivery of data. TCP recovers from internet communication system
errors.
3. Connection and disconnection
------------------------------------
Topics: 3-way handshake
Simplex closing and abort
4. Data Transfer
---------------------
Topics: Data blocking and forwarding via intelligence
Fragmentation and reassembly
Push function see detail below
Push Function
The TCP is able to transfer a continuous stream of octets in each direction
between its users by packaging some number of octets into segments for
transmission through the Internet system. In general, the TCPs decide when
to block and forward data at their own convenience.
Sometimes users need to be sure that all the data submitted to the TCP has
been transmitted. For this purpose, a push function is defined. To assure
that data submitted to a TCP is actually transmitted, the sending user
ndicates that it should be pushed through to the receiving user. A push
causes the TCPs to promptly forward and deliver data up to that point to the
receiver. The exact push point might not be visible to the receiving user
and the push function does not supply a record boundary marker.
5. Flow control ("Windowing" concept)
------------------------------------------
TCP provides a means for the receiver to govern the amount of data sent by
the sender. This is achieved by returning a "window" with every ACK
indicating a range of acceptable sequence numbers beyond the last segment
successfully received. The window indicates an allowed number of octets
that the sender may transmit before receiving further permission.
6. Multiplexing Connections
--------------------------------
Sockets and Connections
To allow many processes within a single host to use TCP communication
facilities simultaneously, the TCP provides a set of addresses or ports
within each host.
Concatenated with the network and host addresses from the Internet
communication layer, this forms a socket. A pair of sockets uniquely
identifies each connection. That is, a socket may be simultaneously
used in multiple connections.
The binding of ports to processes is handled independently by each host.
However, it proves useful to attach frequently used processes (for example, a
"logger" or timesharing service) to fixed sockets that are made known to the
public. These services can then be accessed through the known addresses.
Establishing and learning the port addresses of other processes may involve
more dynamic mechanisms.
The reliability and flow control mechanisms described above require that TCPs
initialize and maintain certain status information for each data stream. The
combination of this information, including sockets, sequence numbers, and
window sizes, is called a connection. Each connection is uniquely specified
by a pair of sockets identifying its two sides.
Establishing a connection
When two processes wish to communicate, their TCPs must first establish a
connection (initialize the status information on each side). When their
communication is complete, the connection is terminated or closed to free the
resources for other uses.
Because connections must be established between unreliable hosts and over the
unreliable Internet communication system, a handshake mechanism with clock-
based sequence numbers is used to avoid erroneous initialization of
connections. The procedure used to establish a connection involves the
"Three-way handshake," which exchanges the initial sequence number and a
sync flag.
Outgoing data may be fragmented to current window size if the data is very
long.
Short data may be concatenated before the segment is sent.
Urgent indicator is sent to receiver to expedite receiver accepting some urgent
data by processing the queued-up ones first.
7. Sequence number
-----------------------
Every byte transmittedis assigned a sequence number.
The sequence number of the first byte of data in a segment is
transmitted in the header of that segment as the segment sequence number.
Sequence numbers of connecting systems are synchronized during connection
initialization. In this case, the sequence number is the initial sequence
number (ISN), and the first data byte is ISN+1.
Sequence number range is 2**32. An Initial Sequence Number generator selects
a new 32-bit ISN every time a new connection occurs.
8. Checksum
----------------
The checksum field is the 16-bit one's complement of the one's complement sum
of all 16-bit words in the header and text.
While computing the checksum, the checksum field itself is set to all zeros.
All odd octet words are padded with zeros.
To compute the checksum, TCP prepends a pseudo-header to the TCP datagram,
suffixes an octet of zeros to pad the datagram to an exact multiple of 16 bits,
and computes the checksum over the entire object. The octet used for
padding andthe pseudo-header are not transmitted with the TCP datagram,
nor are they included in the length.
TCP Pseudo Header:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source IP Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination IP Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Zero | Proto | TCP Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
9. TCP Header
------------------
TCP Header
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Acknowledgment Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Data |Reserved |U|A|P|R|S|F| Window |
|Offset | |R|C|S|S|Y|I| |
| | |G|K|H|T|N|N| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Checksum | Urgent Pointer |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Options |Padding|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|DATA |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Source Port:
The port number used by the calling TCP.
Destination Port:
The port number used by the sending TCP.
Sequence Number:
A 32-bit sequence number used to ensure correct arrival and sequencing of data.
This corresponds to a byte sequence number and is incremented according to the
number of bytes transmitted in each TCP datagram.
Acknowledgement Number:
A 32-bit sequence number used to indicate the next byte expected, and thereby
acknowledge all bytes in the data stream up to but not including that point.
Data Offset:
The number of 32-bit words in the TCP header. This indicates where the data
begins. The TCP header (even one including options) is an integral number of
32 bits long. Data Offset includes padding and options. The offset starts
from source port and ends at padding.
Flags:
Contains six flags, which control functions such as setup and close down of
a session, indication of expedited or urgent flow, immediate reset of a
connection, or the forcing of buffered data over the network.
Window:
The number of data octets beginning with the one indicated in the
acknowledgment
field that the sender of this segment is willing to accept.
Checksum:
The checksum field is the 16-bit one's complement of the one's complement sum
of all 16 bit words in the header and text. If a segment contains an odd
number of header and text octets to be checksummed, the last octet is padded
on the right with zeros to form a 16-bit word for checksum purposes. The pad
is not transmitted as part of the segment. While computing the checksum, the
checksum field itself is replaced with zeros.
Urgent Pointer:
This field communicates the current value of the urgent pointer as a positive
offset from the sequence number in the segment. The urgent pointer points to
the sequence number of the octet following the urgent data. This field is only
to be interpreted in segments with the URG control bit set.
Options:
Provides the capability to indicate special options, such as maximum TCP
segment
size that the host canreceive.
Data:
This is where the user data goes.
10. Interfaces to other Protocols & Applications
----------------------------------------------------
The TCP interfaces on one side to user or application processes, and on the
other side to a lower-level protocol such as Internet Protocol.
The interface between an application process and the TCP is illustrated in
reasonable detail. This interface consists of a set of calls much like the
calls an operating system provides to an application process for manipulating
files. For example, calls to open and close connections and to send and
receive data on established connections. It is also expected that the TCP
can asynchronously communicate with application programs. Although
considerable
freedom ispermitted to TCP implementors to design interfaces that are
appropriate to a particular operating system environment, a minimum
functionality is required at the TCP/user interface for any valid
implementation.
The interface between TCP and lower-level protocols is essentially unspecified
except that it is assumed a mechanism exists whereby the two levels can
asynchronously pass information to each other. Typically, one expects the
lower-level protocol to specify this interface. TCP is designed to workin a
very general environment of interconnected networks. The lower-level protocol
that is assumed throughout this section is the Internet Protocol.
11. TCP/UDP port value ranges
-------------------------
---------------------------------------------------------------
Port Values (decimal) Description
--------------------- -----------
0-63 Network Wide Standard Services
64-131 Host Specific Services
132-223 Reserved for future use
224-255 Any Experimental Services
256-1023 Reserved for future use
1024-65534 General use
---------------------------------------------------------------
References: RFC 790: Port or Socket Numbers.
-------------------------
[1] Postal, Jon, RFC793, Transmission Control Proto-
col; DARP Internet Program Protocol Specification, Sep-
tember 1981.
[2] Postal, Jon, RFC768, User Datagram Protocol,
1980.
SOLUTION SUMMARY:
Top
Sun Proprietary/Confidential: Internal Use Only
Feedback to SunSolve Team