Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

3 Answers 3

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.

http://ngrep.sourceforge.net/usage.html#http

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

 
discard

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.