in reply to Parsing ERF (pcap-like) format files

Sounds like you figured it out already.

ERF (Endace Record Format) is a proprietary binary format for captured network packets. An ERF File is simply one or more records concatenated, with no file header. This makes it conceptually simpler than pcap files, which it is not directly compatible with.

The Wireshark package (including mergecap, editcap, capinfos, tshark, wireshark etc) has the ability to read ERF Files and dissect the records. This functionality is split between wiretap (wtap/erf.c) and a dissector (epan/dissectors/packet-erf.c).

Because of this, editcap/mergecap/tshark/wireshark can read in an ERF File and output any format they support writing into, defaulting to pcap. The DLT you get will depend on the tool settings.

There is a pcap DLT_ERF specifically for encapsulating ERF records. If you output this type you will have a pcap file of type DLT_ERF where the payload of each pcap 'packet' is a complete ERF record including the header. Alternatively you can use these tools to output a regular DLT format such as DLT_EN10MB for Ethernet.

If you are capturing live you can use the native APIs or libpcap. If you are using libpcap by default the ERF records are converted into regular pcap DLTs such as DLT_EN10MB. You can optionally specify DLT_ERF to retain all the extra metadata including the high precision timestamp. When Wireshark tools read a pcap file containing DLT_ERF they discard the pcap wrapper information and use the ERF header preferentially.

As mentioned libtrace can also be used to read ERF Files as well as pcap files with a common API.

  • Comment on Re: Parsing ERF (pcap-like) format files

Replies are listed 'Best First'.
Re^2: Parsing ERF (pcap-like) format files
by sblanton (Sexton) on Mar 28, 2011 at 14:32 UTC

    Thanks, that clarifies things. It turns out I've gone with capturing over a socket, not a device (which is on another machine), so again libpcap doesn't help. However, I just went byte by byte over the ERF header from the Wireshark gui and have constructed a Net::Format::Layer::ERF module that does the job.

    I keep looking for an excuse to do more projects in C, but can't justify it because Perl does the job with acceptable performance, is faster to implement and easier to maintain!