For a project I am working on we have a data source which generates a stream of data as UDP packets on 100 GbE Ethernet link.
The engineers I am working with can capture this stream and write the full stream as a pcap file.
I would like to strip all network headers and create a new file with just the UDP datagramme payload. I realise I can write some C or python to do this using the Pcap libraries, but I would prefer to use an existing tool such as tshark. Particularly if this gives the option of (optional) packet filtering such as UDP port etc.
I have been looking for solutions with google and reading man page but could not find any solution.
I do NOT want the data converted to hex - I want the binary data of the payload retained.
Does anyone have any suggestions?
What do you think about this command?
This command looks for incoming UDP packets, extracts the UDP payload from them, sends them to the
xxdcommand for hex to raw byte conversion and saves the raw bytes into a file as they come in.-iSpecifies what interface you want to capture packets from.-YSpecifies how to filter packets. In my example, filter out packets where the UDP port equals 67 or 68. List of filters can be found here: https://www.wireshark.org/docs/dfref/-TSpecifies where we are going to look (e.i. fields), in our case we want to look into theudp.payloadfield-eSpecifies the field to read (e.i.udp.payloadfield)This will output all the UDP payloads into hex.
We can convert the hex into raw bytes by piping the output into
xxd.-rwill convert hex to binary-pwill output the binary continuouslyThen finally we save the raw bytes into a file:
> raw_payloads.bin