3

I have what sounds like the simplest possible use case, and yet nothing is satisfactory.

I have a multi-homed host and I would like to listen to multicasts on eth1, and shove all the payload (NOT including UDP packet headers, just the payload) into a file. Here are some things I've already tried,

  • socat. This sounds like it would be the perfect tool, but I have no idea what syntax to use and all the examples I find are for much more complicated use cases. I can't really make heads or tails of the examples I see. If anyone knows, how could I get socat to do this? Feel free to call me an idiot for not figuring it out.
  • vlc. Occasionally drops packets, which is not acceptable. I need it to run for a long time without a single packet dropped. I see this occasional drop on many vlc versions on multiple platforms and I simply don't trust it.
  • wireshark. This does work and never drops packets like vlc (even when run side-by-side at the same time), but I don't actually need a packet dump, just the payload. I can after-the-fact use wireshark to write all the payload to a file using the "follow UDP stream" feature, but it takes a lot of time and it prevents me from saving the payload in realtime. Plus it seems to be only possible in the wireshark gui. My workflow would be much easier without some GUI.
  • netcat. Sounded like the right tool, but doesn't do jack shit when it comes to receiving multicast. No idea how to debug, or if it just doesn't work with multicast. Alongside, I am running nemesis to force igmp joins and I can see with tcpdump that this works. Please suggest if I am missing something stupid.
  • nc6. same result as netcat.

2 Answers 2

4
socat -u UDP4-RECV:6666,ip-add-membership=224.1.0.1:0.0.0.0 CREATE:test.out

Perhaps not optimal, but should work.

1
  • The above answer by NuclearDog looks PERFECT, have a nice day.
    – snacky
    Apr 2, 2013 at 1:56
0

You can use ffmpeg, multicat, tsudpreceive and tsp:

ffmpeg -i udp://<multicast_ip>:<port_number> -c copy -f mpegts test.ts

Keep in mind that ffmpeg would drop the NULL PID but it will copy all other PIDs to the test.ts file.

Another option is to use multicat:

multicat -u -U @<multicast_ip>:<port_number> test.ts

By default, mutlticat is expecting an RTP stream as an input and that is why you need to define -u and -U to tell that the source and destination are not containing RTP headers.

You can install the Opencaster and use tsudpreceive:

tsudpreceive <multicast_ip> <port_number> > test.ts

You can also try to do it with TSDuck and tsp:

tsp -rtrue -I ip <multicast_ip>:<port_number> --buffer-size-mb 50 -O file test.ts

rtrue is telling tsp to use real-time processing
-I ip - defines that the input is IP stream
--buffer-size-mb specifies the buffer size in megabytes, the default is 16MB, so this is just optional parameter
-O file defines the type of the output to file.

You can define the duration of the recordings in FFmpeg by passing -t <seconds>. You can do the same for multicat, but this time you need to define the duration in 27MHz units, meaning that if you want to have 30 seconds recording you need to pass: -d 810000000 (27E+6 * 30 = 81E+7). For the rest of the options, you can use timeout --foreground 30 as a prefix to the commands and this will cut the recordings at precisely 30 seconds.

Most likely you would be able to do the same using gstreamer, cvlc and so on, but I am not familiar with their syntax.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .