【发布时间】:2018-12-13 01:08:03
【问题描述】:
我尝试发送以太网类型为 0x0101 的原始数据包,但它似乎无法正常工作,如果我使用以太网类型 0x1000,它可以正常工作。 基本上我打开一个原始套接字:
int sd = socket(AF_PACKET, SOCK_RAW | SOCK_CLOEXEC, htons(0x0101));
int r = sendmsg(sd, msgSend, 0);
根据iana以太网类型0101-01FF是实验性的,所以据我所知可以用于实验。
如果我使用 0x0101 tcpdump 显示:
00:00:01.001914 aa:00:00:2e:00:02 > 08:00:27:0b:ed:84, 802.3, length 257: LLC, dsap Null (0x00) Individual, ssap Null (0x00) Command, ctrl 0x0000: Information, send s0
0x0000: 0000 0000 efbe adde aaaa db00 0000 0000 ................
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0030: 0000
当我使用 0x1000 时显示:
00:00:00.439876 aa:00:00:2e:00:02 > 08:00:27:0b:ed:84, ethertype Trail (0x1000), length 64:
0x0000: 0000 0000 efbe adde aaaa db00 0000 0000 ................
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0030: 0000
我错过了什么?
【问题讨论】:
标签: c linux sockets raw-ethernet