Network | Sk_buff

Source: Internet
Author: User

The SK_BUFF structure is probably the most important data structure in Linux Network Code, which represents the packet header information that is received or sent. It is defined in and contains a number of member variables for use by subsystems in the network code.
This structure is used by different network layers (Mac or other two-layer link protocol, three-layer IP, four-layer TCP or UDP, etc.), and the member variables change as the structure passes from one layer to another. L4 adds a L4 header to the L3 before it is passed to the L2, and a L3 header is added to the L3 before it is delivered. Adding headers is more efficient than copying data between different layers.
Since adding data to the head of the buffer means modifying pointers to buffers, this is a complex operation, so the kernel provides a function skb_reserve.
Each layer in the protocol stack before passing the buffer, the first thing is to call Skb_reserve in the buffer head to the protocol header to reserve a certain amount of space.
The Skb_reserve is also used by the device driver to align the packets received to the packet header. If the buffer is passed to the upper layer protocol, the old protocol layer header information is useless. For example, L2 's head is only useful when the network driver deals with L2 protocols, and L3 does not care about its information. However, the kernel does not remove the L2 head from the buffer, but instead points the payload pointer to the L3 's head, which saves CPU time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.