Malformed / unified PCAP files

This problem came out as part of a discussion in the user's group (https://groups.google.com/u/1/g/ns-3-users/c/fAduyyjeG4o)

A call to the below function (or the IPv6 one) will create a malformed PCAP file if the same prefix is forced (explicitFilename == true) on different interfaces:

PcapHelperForIpv4::EnablePcapIpv4(std::string prefix,
                                  Ptr<Ipv4> ipv4,
                                  uint32_t interface,
                                  bool explicitFilename)

The problem is that each interface will open the same file and will initialize it, resulting in writing overlaps and repeated initialization sequences.

An ideal solution would:

  • Catch a repeated filename in the simulation (and issue an assert), and
  • Enable the creation of per-node PCAP files (even at NetDevice level).

The second goal is more complex but it's not impossible, and would be similar to Wireshark capturing traffic on all the interfaces.

Note: the second point is mitigated by using mergecap (an application installed alongside Wireshark)

Edited by Tommaso Pecorella