聘我网

新概念招聘3.0

Ethernet头是否一定是14字节?

vote up0vote downstar

代码片段(source):

void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data)
{
    ....
    /* retireve the position of the ip header */
    ih = (ip_header *) (pkt_data +
        14); //length of ethernet header
    ....

但这张图却显示并不一定:

alt text

这是怎么回事?

 

1 个答复

vote up0vote downcheck

现在用的Ethernet协议(802.3)中的MAC地址都是48位的了,历史上曾今的老版本是16位。

The MAC addresses used in 802.3 are always 48 bits long, although older versions of Ethernet used 16 bits.(source)

所以是6+6+2=14

另外其中的struct pcap_pkthdr *headercapture driver产生的,而不是协议头。

pkt_header is the header associated by the capture driver to the packet. It is NOT a protocol header.(source)

链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.