- 论坛徽章:
- 0
|
回复 2# nswcfd
您好,
1、支持tso等特性的网卡会做一些组包操作,使得我__netif_receive_skb 拿到的包大于MTU 1500 值。
我关闭了tso、gso、gro、tx、rx 选项全部关闭后,就不会组包超过1500 ,如果rx和tx不关闭的话,还是会超过1500.
2、__netif_receive_skb 代码
struct iphdr*iph ;
skb_tail = skb_tail_pointer(skb);
mac_header = skb_mac_header(skb);
network_header = skb_network_header(skb);
if (ntohs(((struct ethhdr*)mac_header)->h_proto) == ETH_P_8021Q){
if (ntohs(((struct vlan_ethhdr*)mac_header)->h_vlan_encapsulated_proto) != ETH_P_IP ){
//不是ip数据包
goto pass ;
}
//IP包头
iph=(struct iphdr *)(network_header+4);
} else {
if (ntohs(((struct ethhdr*)mac_header)->h_proto) != ETH_P_IP){
//不是ip数据包
goto pass ;
}
//IP包头
iph=(struct iphdr *)network_header;
}
iph ----> 拿到的iph 减去 ip头和tcp 头,剩下就是包的内容。
如果连续多个包,第一个包里面的内容是正确的,后面的就会存在包错位、或者包不全的现象。
例如下面:
*****************time[1433142699851]-item.count[5]-head_node[5dfbf520]********************
POST /XMLReceiver HTTP/1.1 -------------> 第一个包是正常
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 1442
Host: 132.194.38.234:12026
Connection: Keep-Alive
node[5dfbf520],head_node[5dfbf520]==>seq[2809258566],ack[3413947443],next_seq[2809258733],offset[0],
np==>seq[2809258566],ack[3413947443],next_seq[2809258733],datasize[167]
xmST /XMLReceiver HTTP/1.1 ---------------------->第二个包的前两个字符为xm,后面的内容为第一个包的内容。
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 1442
Host: 132.194.38.234:12026
Connection: Keep-Alive |
|