A packet capture keeps headers and payloads together, even when a comparison needs only a few bytes. Wireshark on the Linux desktop can export a selected range of packet bytes to a raw binary file.

A field selected in Packet Details highlights its corresponding bytes in Packet Bytes. For an IPv4 length field, the highlighted bytes show how the number is stored in the packet, including any leading zeroes.

Exported bytes can contain private data such as cookies or credentials. Export only bytes you are authorized to handle and save the file in a private folder.

Steps to export packet bytes in Wireshark:

Start with a saved capture open in Wireshark's Default profile, with Packet Details, Packet Bytes, and the status bar visible. The Ubuntu example uses an IPv4 ping reply in ping-traffic.pcapng.

  1. Select the packet that contains the bytes you want from the packet list.

    The example uses frame 2, the ICMP reply from 192.0.2.20.

  2. Expand the protocol layer that contains the field in Packet Details.

    The example uses the Internet Protocol Version 4 row.

  3. Select the field whose bytes you want to export in Packet Details.

    The export option requires a field with actual bytes to highlight.

  4. Note the highlighted hex bytes in Packet Bytes and the byte count in the status bar.

    For Total Length, the example shows 00 54 at offset 0010 and 2 bytes in the status bar.

  5. Choose File > Export Packet Bytes….
  6. Type the full path for a new .bin file in Name, replacing any existing text.

    The example uses /home/reader/Documents/captures/ip-total-length.bin. A full path sets the destination even when the dialog opens in a different folder.

  7. Click Save to write the binary file.

    The dialog closes when the export finishes.

  8. Press Ctrl+Alt+T to open your default terminal.

    If GNOME Terminal asks Set GNOME Terminal as your default terminal?, you can leave that choice open and click the command prompt below it.

  9. Run od on the file you saved with its full path in single quotes.
    od -Ad -tx1 -v '/home/reader/Documents/captures/ip-total-length.bin'
  10. Confirm that the terminal shows the same hex bytes and byte count you noted.

    On each data line, the hex byte values follow the offset. The final decimal offset is the file size in bytes. For Total Length in frame 2, the file contains 00 54 and ends at 0000002.

Share this guide