我遵循本教程PcapDotNet/Pcap.Net。但我会尝试构建一个像这张图片以太网帧这样的数据包。
private static Packet BuildEthernetPacket()
{
EthernetLayer ethernetLayer =
new EthernetLayer
{
Destination = new MacAddress("00:00:00:00:00:00"),
Source = new MacAddress("11:11:11:11:11:11"),
EtherType = EthernetType.None, // I select NONE for no IPV4 or ARP and so one protocole ...
};
PayloadLayer payloadLayer =
new PayloadLayer
{
Data = new Datagram(Encoding.ASCII.GetBytes("Hello stackoverflow")),
};
// The probleme it's here but the code build :
PacketBuilder builder = new PacketBuilder(ethernetLayer, payloadLayer);
return builder.Build(DateTime.Now);
}
Visual Studio 社区检测到错误“无法从下一层自动确定以太类型(PcapDotNet.Packets.PayloadLayer)”和 PcapDotNet.Packets.dll 中的“System.ArgumentException”
但是如果我通过 EthernetType.IpV4 或 IpV6 更改 EthernetType.None或者 ARP 等等.. 没有问题,但我不想添加其他协议。
提前致谢。