Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer

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.

share|improve this answer
I want to feed a command line app with the stream... – Karoly Horvath 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. – Karoly Horvath Aug 16 '11 at 22:42

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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