Nichestack TCP/IP stack will also include the device drivers such as Ethernet, SLIP, PPP, PPPoE and Loopback. Each network interface will be associated with a network device structure.
This network structure contains the prepare function pointer. This prepare function will be called during the NicheStack initialization. There is another structure called NET structure which will contain all the device specific details. During the prepare function call, required parameters of the NET structure will be initialized. The NET structure also contains the function pointer to the driver specific routines and this will be assigned during this call.
Next step is the initialization of devices and during this step, the stack will check whether the interface associated with the driver is OK and if it is working fine then change the device MIB status to UP.
After the driver initialization, the driver can send the packets using the packet send function. The packet will be send in the same order, which is provided to the driver. Once the packet is send, the driver will frees the packet. If the driver is busy, then the data to send will be queued and later when the driver is available, it will send the data.
Above paragraph describes the packet sending process, next we can dig into the packet receiving process. When the data is received by the device driver, the data must be stored in either chained or contiguous packet. Then the packet is placed in the stacks receive queue(rcvdq) and send the signal to the main task which is waiting for the incoming data. The signal will unlock the main task and dequeue the data and send to the upper layers based on the type of packet.
If the application layer task need to avoid the overhead during sending and receiving, then the task should use another mechanism called TCP-Zero-Copy. This feature can be used to avoid the overhead of having the stack copy data between application-owned buffers and stack-owned buffers.
We can stop the device driver using the close function. This will frees the memory resources associated with a driver and also changes the network interface status to DOWN.
No comments:
Post a Comment