|
|
The TCP/IP protocols enable communication between pairs of hosts, or ``peers'', on a network. The TCP/IP protocol structure can be conceptualized as a series of layers, or ``stack'', between an application and the network. Each protocol layer on one peer has a corresponding layer on the other peer. To the application, it appears that it has a virtual connection to an application running on another host. In reality, data is passed over the network in the physical form that the network can handle. Each layer is required, by design, to handle communications in a predetermined fashion. Each protocol formats communicated data and appends information to or removes information from the data. Then the protocol passes the data to a lower layer on the sending host or a higher layer on the receiving host, as illustrated in ``Sender/receiver interaction''.

Sender/receiver interaction
The interface between the application and the transport layers is termed a transport interface. Interfaces such as sockets and TLI/XTI eliminate the need for applications to know about the transport layer in detail. For more information about the programming interfaces to the transport layer, see Using network programming interfaces.
``Encapsulation/decapsulation of application data within a network stack'' shows how each layer adds (or removes) header information to data traveling away from (or toward) the application layer. The process of adding header information is termed ``encapsulation''; removing header information is termed ``decapsulation'' or ``unencapsulation''.

Encapsulation/decapsulation of application data within a network stack
Networking application programs send messages or streams of data to one of the Internet transport Layer protocols, either the User Datagram Protocol (UDP) or the Transmission Control Protocol (TCP). These protocols receive the data from the application, divide it into smaller pieces called TCPsegments or UDP packets, add a destination address, and then pass the packets down to the next protocol layer, the network layer.
The network layer encloses the packet in an Internet Protocol (IP) datagram, adds the datagram header, decides where to send the datagram (either directly to the destination system or indirectly via a router or gateway), and passes the datagram down to the data link layer.
The data link layer accepts IP datagrams, encapsulates them within frames that are specific to the network hardware such as Ethernet, Token-Ring or Fiber Distributed Data Interface (FDDI), and transmits these over the network.
Frames received by a host are processed through the protocol layers in the reverse order. Each layer strips off the corresponding header information, until the data ends up at the application layer. Frames are received by the data link layer which strips off the frame header and trailer, and sends the datagram up to the network layer. The network layer strips off the IP header and sends the packet up to the transport layer. The transport layer strips off the TCP or UDP header and sends the data up to the application.
As hosts on a network can send and receive information simultaneously, data may be traveling both up and down the layers of the networking stack at the same time.
``Networking stack support for the TCP/IP protocols'' illustrates the relationships between the various protocols that are supported within the stack.

Networking stack support for the TCP/IP protocols
This arrangement is termed a ``dual-stack'' as both IPv4 and IPv6 are supported; the path that data takes is determined by the IP header on incoming datagrams or by the IP address format used by applications in outgoing datagrams.
The following sections provide an overview of how each protocol layer handles messages: