Receive the electrical signal from the network card to the application layer to get the data

Do not consider the optimization technology of zero copy

The overall process should be like this

  1. The network card receives the electrical signal, converts it into information, and transmits it to the network card cache
细节见书,《网络是怎样连接的》 ,6.2节对于网卡接收数据的描述
  1. The network card interrupts the cpu, and the cpu calls the network card driver to read data into the kernel. The corresponding data structure is input_pkt_queue.
    See the link blog

  2. When the operating system has been running in the interrupt context, that is, it has been in the kernel state, each layer of the protocol stack may copy the lower layer data to its own space, or it may just operate the pointer. I prefer the second one, of course, ip fragmentation reorganization inevitably requires copy data.

  3. Data is copied from the kernel to user space.

In general, there are two copies in total, which occurred in the network card cache --> kernel, kernel to user space.

Data transfer process when considering zero-copy technology

The DMA used from the network card to the kernel is gone from the kernel to the user. It uses shared memory, so it is called zero copy.
See linked blog

Guess you like

Origin blog.csdn.net/qq_41634872/article/details/109957816