I'm trying to record an incoming UDP stream (stream the sense that it's a stream of consecutive datagrams).

I tried netcat but unfortunately multiple sources send data on the same port address and nc doesn't let you specify the source or the target multicast address.

Then I tried tcpdump -w - because tcpdump has rich filtering options, but it records the raw stream and I only need the actual data so I can process it like it were a stream. Unfortunately it records all the packet related info like source/destination or IP/UDP headers.

Is there a way to do this? I could write a small C program to do this but I prefer to use existing tools.


My first choose would be wireshark. If you must do it from a terminal you can also try ngrep, it gives a more readable output than tcpdump. You can probably filter out the header info with a simple bash script.



You can use wireshark. It can do what you want plus more.

wireshark is not useful if what you want is to receive the data in the stream and feed it to a program. In that case, I would have to say that you are using the wrong protocol. If I were in your place I would cheat.

Hopefully you are on Linux. In that case, make a firewall rewrite rule to send incoming UDP packets from the desired source that are sent to the proper port to another port where you can use netcat to record the data in the stream.

This question will help you start.

  • I want to feed a command line app with the stream... Aug 16 '11 at 19:25
  • firewall rule is an interesting idea, thx. I'll stick to the C program, as it's sounds more logic. Aug 16 '11 at 22:42

netsed or iptables + the libnetfilter_queue module or ngrep might do what you wish.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.