我正在使用 pcap.net 更改数据包并重建输出 pcap 文件。但在这部分我有错误。谁能说,我该如何解决?
if (packet.Ethernet.IpV4.Protocol == IpV4Protocol.Tcp)
{
PayloadLayer Payload = null;
if ((packet.Ethernet.IpV4.Tcp.Payload != null) && (packet.Ethernet.IpV4.Tcp.Payload.Length >= 0))
{
Payload = (PayloadLayer)packet.Ethernet.IpV4.Tcp.Payload.ExtractLayer(); //extract the data
tmpPacket = PacketBuilder.Build(packetTimestamp, ethernet, ipV4Layer, tcpLayer, Payload);
}
else
{
tmpPacket = PacketBuilder.Build(packetTimestamp, ethernet, ipV4Layer, tcpLayer);
}
}
这是我的错误:对象引用未设置为对象的实例。(对于 ipv4Layer)
以及错误的详细信息: Length = 'ipV4Layer.Length' 引发了“System.NullReferenceException”类型的异常