Data encapsulations

When an application such as telnet wants to send data, the data is sent to the TCP module at the transport layer and TCP then assigns a number to the local and remote telnet session, allowing TCP to determine the session where the data is to be delivered. IP either receives or delivers data to the UDP or TCP module, depending on the type of application.


Finally, an ethernet frame contains an identifier that identifies the network layer protocol it received the data from or the network layer protocol to which it should deliver the data.


To illustrate the interaction between the different layers in the OSI model, we will follow the flow of data from one host to another (see Figure 1-3). Assume we are running a telnet session between two hosts. User data is generated at the application layer and is then passed down the protocol stack to the TCP module in the transport layer. The TCP layer uses an identifier for the session, which is contained in the TCP header, and passes the TCP segment to the IP module at the network layer. IP then tags the packet as a TCP or UDP packet. When the packet is received at the data link layer, an ethernet frame is constructed with an ethernet header and trailer. The header, among other things, contains a field tagging the frame as one that carries the IP data. Finally, the frame is passed to the physical layer for transmission onto the network media.


When the ethernet frame is received by the remote host, the data link ethernet module strips off the ethernet header and trailer after determining that this frame carries IP data and passes the data to the IP module in the network layer. IP determines if the packet is a TCP or UDP packet and passes it to the appropriate module at the transport layer. Finally, TCP extracts the user data and sends it to the proper user process.