Packet Processing in a Network Stack

 < Day Day Up > 



Packets within the IP suite of protocols are known as PDUs, or Protocol Data Units. The layered architecture of the Internet protocols permits the conceptually simple process of creating and parsing packets. Consider the illustration in Figure 1.10.

click to expand
Figure 1.10: Example of PDU construction.

When data is transmitted through a network stack (we'll ignore the communication model for this example), the data passes through the layers of the stack. The application, operating in the Application layer, communicates with the network stack through the Sockets API. The Sockets API, using information provided by the application, determines the connection (the socket) for which the data is intended and passes it to the Transport layer. In the Transport layer, a transport header is constructed and the new packet is passed to the Network layer. The element passed through the stack layers is PDU-each layer changes the PDU in a way specific to the particular protocol. The Network layer adds its packet header and passes it to the Physical layer. After the Physical layer packet header is attached, the packet is 'put on the wire' and is on its way to the destination.

The process of creating the PDU is the process of encapsulation. Each layer performs a specific service based upon the particular protocols used in the PDU construction. Packet headers encapsulate the packet passed from the higher layers, changing both the type and purpose of the packet. The Physical layer packet header is used to transport the PDU on a physical medium. The Network layer packet header permits the packet to traverse the Internet from the source to destination host. The Transport layer packet header permits the packet data to be delivered to the specific application.

Consider now the example shown in Figure 1.11. In this example, we illustrate a packet arriving at a host and being delivered to the intended application. The process is now performed in reverse. As the packet is pushed up the layers of the network stack, the packet headers are removed from the PDU to make the relevant packet headers visible to the proper layer.

click to expand
Figure 1.11: Example of PDU parsing and delivering payload data to an application.

As the packet is received from the network, the packet header is inspected to determine how to route the packet up the stack. Recall that there may be multiple protocols operating within a given layer (TCP and UDP, for example, in the Transport layer). Each layer inspects the current packet header, identifies how to process the packet, removes the header for the current layer, and routes it up the stack to the necessary protocol. At the Transport layer, the data is queued for the given application (as identified by the protocol and port). The application may then extract the data using functions provided in the Sockets API.



 < Day Day Up > 



BSD Sockets Programming from a Multi-Language Perspective
Network Programming for Microsoft Windows , Second Edition (Microsoft Programming Series)
ISBN: 1584502681
EAN: 2147483647
Year: 2003
Pages: 225
Authors: Jim Ohlund

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net