Sending Packets

A finished packet is sent when a protocol-specific function of the network layer instructs the network access layer to process a packet defined by a socket buffer.

What must be noted when messages are sent from the computer? In addition to complete headers and the checksums required by the particular protocol and already generated by the higher instances, the route to be taken by the packet is of prime importance. (Even if the computer has only one network card, the kernel still has to distinguish between packets for external destinations and for the loopback link.)

Because this question can only be clarified by higher protocol instances (particularly if there is a choice of routes to the desired destination), the device driver assumes that the decision has already been made.

Before a packet can be sent to the next correct computer (normally not the same as the target computer because IP packets are usually sent via gateways unless there is a direct hardware connection), it is necessary to establish the hardware address of the receiving network card. This is a complicated process looked at more closely in Section 12.8.5. At this point, simply assume that the receiving MAC address is known. A further header for the network access layer is normally generated by protocol-specific functions.

dev_queue_xmit from net/core/dev.c is used to place the packet on the queue for outgoing packets. I ignore the implementation of the device-specific queue mechanism because it reveals little of interest on how the network layer functions. It is sufficient to know that the packet is sent a certain length of time after it has been placed on the wait queue. This is done by the adapter-specific hard_start_xmit function that is present as a function pointer in each net_device structure and is implemented by the hardware device drivers.

Continue reading here: Network Layer

Was this article helpful?

0 0