c - 以太网头的长度一定是 14 吗?

标签 c networking ethernet

来自 here 的代码片段:

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
    ....

但是这张图片并没有说它一定是14:

alt text
(来源:lewis at www.dcs.gla.ac.uk)

我应该如何正确操作?

最佳答案

在 802.3 中,源地址和目的地址都是 48 位的 MAC 地址。 6+6+2=14

关于c - 以太网头的长度一定是 14 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2796944/

相关文章:

java - 启用 C 应用程序作为 Web 服务

c - 获取ARP数据包的大小

android - 在 Android 中查找本地网络地址 - 包括 IP 和 NetMask? (以太网不是 wifi)

linux-kernel - 我需要构建什么才能在内核级别直接访问以太网帧位?

c - VC2008 中的链接器是否存在路径中的空格问题?

c++ - OpenCL header 包含在 C++ 中的相对路径问题

c - 数组计数排序段错误

java - LAN 中不同计算机上的 JVM 与其他计算机进行通信的最快方式是什么?

linux - linux 如何提取我的 mac 地址以通过链接发送?

c# - 以太网端口上的 throttle 带宽