我有几个PCAP
坏的文件Checksum
,为了修复这些文件,我正在使用这种方法:
private Packet FixBadChecksum(Packet packet)
{
try
{
EthernetLayer ethernet = (EthernetLayer)packet.Ethernet.ExtractLayer();
IpV4Layer ipV4Layer = (IpV4Layer)packet.Ethernet.IpV4.ExtractLayer();
DateTime packetTimestamp = packet.Timestamp;
TransportLayer transportlayer = (TransportLayer)packet.Ethernet.IpV4.Transport.ExtractLayer();
ILayer datagramLayer = (PayloadLayer)packet.Ethernet.IpV4.Payload.ExtractLayer();
ipV4Layer.HeaderChecksum = null;
if (transportlayer == null)
return PacketBuilder.Build(packetTimestamp, ethernet, ipV4Layer, datagramLayer);
else
{
transportlayer.Checksum = null;
ILayer payload = packet.Ethernet.IpV4.Transport.Payload.ExtractLayer();
return PacketBuilder.Build(packetTimestamp, ethernet, ipV4Layer, transportlayer, payload);
}
}
catch (Exception)
{
return packet;
}
}
现在例如,如果我的数据包是ICMP
在这个数据包(校验和错误)完成我的功能之后,它仍然是错误的Checksum
,所以我的问题是:我需要检查每个数据包协议还是有一个通用的方法来做到这一点?(目前我的功能可以正常工作TCP
,UDP
但是其他协议呢?)