Recently I was diagnosing problems with missing multicast data for some system. Multicast send UDP packets from single source to many registered subscribers. IPTV is using this feature to stream video for example. For unicast (1-1) transmissions you can use netcat or telnet but what tool can test multicast data?
The answer was located pretty quickly: socat tool can register to multicast sources and pipe output to many destinations (stdout for example). Let's give a sample first:
socat UDP4-RECVFROM:9875,ip-add-membership=22.214.171.124:0.0.0.0,fork -\ | grep -a '^s='
Values to change:
- 126.96.36.199: sample multicast IP address
- 9875: sample multicast port
- ^s=: string to be located in multicast data (in my case data protocol is textual)
- UDP4-RECVFROM: receive IPv4 UDP packets
- ip-add-membership: multicast requires registering of packets receiver
- 0.0.0.0: accept multicast on any client interface (you can specify here your client network address here as well)
- grep -a: sometimes you need just subset of incoming data, in my case textual data was mixed with binary (-a parameter for grep)