Chinaunix首页 | 论坛 | 博客
  • 博客访问: 96795
  • 博文数量: 41
  • 博客积分: 991
  • 博客等级: 准尉
  • 技术积分: 420
  • 用 户 组: 普通用户
  • 注册时间: 2011-05-11 19:59
文章分类

全部博文(41)

文章存档

2012年(18)

2011年(23)

分类: LINUX

2011-06-12 09:30:36

1.The Socket Buffer: sk_buff Structure
      sk_buff  representing the headers for data that has been received or is about to be transmitted.

     (1)Layout
     (2)General
     (3)Feature-specific
     (4)Management functions

   Layout
       This structure is used by several different network layers (MAC or another link protocol
       on the L2 layer, IP on  L3, TCP or UDP on L4), and various fields of the structure change
       as it is passed from one layer to another. L4 appends a header before passing it to L3,
       which in turn puts on its own header before passing it to L2.

       one of the first things done by each protocol, as the buffer passes
       down through layers, is to call skb_reserve to reserve space for the protocol's header.

       When the buffer passes up through the network layers, each header from the old layer
       is no longer of interest. The L2 header,
       for instance, is used only by the device drivers that handle the L2 protocol,
       so it is of no interest to L3. Instead of removing the L2 header from the buffer,
       the pointer to the beginning of the payload is moved ahead to the beginning of the L3 header,
       which requires fewer CPU cycles.

       总:当sk_buff 从上层(layer)移动到下层时,调用skb_reserve 为相应header储备空间;
              当sk_buff 从下层(layer)移动到上层时,相应的header仅对对应的层有用,所以当
              往上一层移时,下一层的header可以丢弃,但是,仅移动指向header的指针比丢弃header
              需要的CPU cycles 更少。

    General
        The function then completes the layer n processing and, before passing the packet to
        the layern 1  handler, updates skb->data to make it point to the end of the layern
        header, which is the beginning of the layer n 1 header.

        unsigned short protocol
             each protocol has its own function handler for the processing of incoming packets,
             this field is used by the driver to inform the layer above it what handler to use.
             Each driver calls netif_rx to invoke the handler for the upper network layer,
             so the protocol field must be initialized before that function is invoked.

    Feature-Specific Fields

    Management functions
     skb_reserve  skb_push  skb_put  skb_pull
   these functions does not really move anything into or within the data buffer; it simply updates the relevant   pointer

 2. net_device structure

       Configuration
       Statistics
       Device status
       List management
       Traffic management
       Feature specific
       Generic
       Function pointers (or VFT)



  




阅读(1312) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~