Search code examples
network-programmingcsvpcap

Convert .csv file to .pcap file


I have a csv file with all the fields that is related to IP network such as source and destination IP address, port number, protocol, timestamp, etc. Can I know if it is possible to convert the csv file to a formal PCAP file? Thanks for advice.


Solution

  • Can I know if it is possible to convert the csv file to a formal PCAP file?

    If it also had the payload of the IP datagrams, you could write a program to do so.

    If it only has IP header information, you could also write a program to do so; you'd use the IP total length field (you say "all the fields", so I'm assuming you mean all the fields from the IP header, including the total length) to specify the on-the-wire packet length in the pcap packet header, and you'd give the "captured length" field in the pcap packet header a value equal to the length of the IP header. Reading that packet would give error indications in many network analyzers - for example, Wireshark would report "Packet size limited during capture" errors - but if you don't have the full packet data, there's nothing you can do about that.