SKB(socket buffer)是Linux网络代码中最根本的数据结构,收发数据包都是通过skb。
struct sk_buff {
/* These two members must be first. */
struct sk_buff *next;
struct sk_buff *prev;
//首要的这两个字段是为了实现链表操作,最近的版本没有了struct sk_buff_head *list;是否意味着packet都在同一个队列上??
ktime_t tstamp;
//记录时间戳,计算这个字段代价很大,所以必要的时候才设置;
struct sock *sk;
struct sock *sk;
//记录这个SKB关联的套接字,当在某一个套接字上收发一个packet时,与之相关的内存会得到分配
//(
socket packet buffer memory accounting??)
struct net_device *dev;
//具体的网络设备;
/* This is the control buffer. It is free to use for every
* layer. Please put your private variables there. If you
* want to keep them across layers you have to do a skb_clone()
* first. This is owned by whoever has the skb queued ATM.
*/
char cb[48] __aligned(8);
/* This is the control buffer. It is free to use for every
* layer. Please put your private variables there. If you
* want to keep them across layers you have to do a skb_clone()
* first. This is owned by whoever has the skb queued ATM.
*/
char cb[48] __aligned(8);
//SKB控制块,该透明存储区用来存每个packet的私有信息,如TCP可以用来放序列号和帧的重传状态;
unsigned long _skb_refdst;
#ifdef CONFIG_XFRM
struct sec_path *sp;
#endif
unsigned int len,
data_len;
unsigned long _skb_refdst;
#ifdef CONFIG_XFRM
struct sec_path *sp;
#endif
unsigned int len,
data_len;
//SKB是由一个线性缓冲区和可选的页缓存构成,len是packet的总长度,data_len是页缓存中字节长度;
//所以线性缓存中数据长度: skb->len - skb->data_len ,有函数 skb_headlen(skb)实现;
__u16 mac_len,