Any small program to receive multicast packets on specified UDP port?

I'd like to debug some multicast issues, and I hope to have some small programs/utilities to display incoming multicast packets.

From the sending machine(A), I use Richard Stevens's sock program(provided with his TCP/IP Illustrated book Vol1) to send multicast packets(source port=dest port=7000), like this:

sock -u -b 7000 7000

On the receiving machine(B), I can capture the very sent packet with Wireshark, however, the same sock command running on B does not report receiving anything.

Then, what program should I use on B to see incoming multicast packets, aside from Wireshark which is overkill.

Linux and Windows programs are both welcome.

Here's a python script that will print the incoming data;

# Multicast client
# Adapted from:

import socket

ANY = "" 

# Create a UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)

# Allow multiple sockets to use the same PORT number

# Bind to the port that we know will receive multicast data

# Tell the kernel that we want to add ourselves to a multicast group
# The address for the multicast group is the third param
status = sock.setsockopt(socket.IPPROTO_IP,
socket.inet_aton(MCAST_ADDR) + socket.inet_aton(ANY))

# setblocking(0) is equiv to settimeout(0.0) which means we poll the socket.
# But this will raise an error if recv() or send() can't immediately find or send data. 

while 1:
        data, addr = sock.recvfrom(1024)
    except socket.error as e:
        print "From: ", addr
        print "Data: ", data

Multicast UDP Tutorial - Tutorials, It allows relatively small packets of data (up to 512 bytes always, and often x.x.x IP range, which is available for organization-specific use within a single local area network. The other parameter is the UDP port number (1-65535). to UDP multicast and prints the value in any packet received in a loop. Hello, I have a LAN and a Wireless LAN on my computer. I try to send and receive UDP-Multicast packets. Sending works well, even on all netwrok devices, after inserting this..

You can use netcat (nc) to do that:

netcat -vv -l -p 1234 -u

This means netcat is verbosely listening on port 1234 of the localhost in UDP mode.

The Linux socket and network programming on multicasting client , Working program examples if any compiled using gcc, tested using the public IPs , run on An application program can send or receive multicast datagrams by using the IP_ADD_MEMBERSHIP: Joins the multicast group specified. Initialize a sockaddr_in structure with the destination group IP address and port number. It's not an IP multicast. You'll have to find out what it is and indeed whether it is an instance of the packets you're trying to receive before any progress can be made. I find it hard to believe that the server uses Ethernet multicast rather than IP multicast. – Marquis of Lorne May 28 '14 at 22:48

I've written a multicast testing application back in the day.

You can check it out here:

Understanding IP Multicasting, -IP multicasting allows a host to send a single packet to thousands of hosts across On a small home or office network any host can send and receive multicast datagrams. Protocol) uses multicast address on UDP port 1900. Someone mentioned Comcast could be blocking the traffic. If you bind to the wildcard address you will be able to receive unicast packets on your multicast port. Binding to your multicast address will prevent this and ensure you only get multicast packets on that port. EDIT: Fixed the code based on above comment, binding to multicast address, stored in 'group', as opposed to INADDR_ANY to receive only

On Windows, I found these utilities quite handy for debugging udp (on both ends)

Multicast-HOWTO, UDP supports a lot more paradigms, but if you are sending UDP packets and there is your radio to hear a program that is transmitted at some specific frequency, group, but remain bound to the port you were receiving the multicast traffic on, Just one is generated -by the host that chose the smaller timeout-, and that is� Another option, the one I investigate here, is to use multicast UDP. It works! Without going into too much detail, UDP, the User Datagram Protocol, is one of the low-level TCP/IP protocols. It allows relatively small packets of data (up to 512 bytes always, and often up to 8 Kbytes, sometimes larger) to be sent between devices.

This is the first hit when I searched for capturing multicast packets using netcat, and I found out that tcpdump does a job better. Just making a note for any one else hitting this post.

To install:

sudo apt install tcpdump

To run:

tcpdump -c 8 -n -i eth0 portrange 1234-1239

looks like there may be a Windows port too, but I didn't try it:

Using Multicast, To send a multicast datagram, specify an IP multicast address in the range and sites can be subdivided into smaller administrative units as a local matter. An application can choose an initial TTL other than the ones previously listed. In this case, all sockets that are bound to the port receive every incoming multicast UDP� On a small home or office network any host can send and receive multicast datagrams. Note: multicast uses UDP and are sent through switches and hubs. To receive a multicast message a host must be configured to receive on that multicast address. All hosts that are configured to receive packets on a particular address are part of a multicast group.

Using Multicast (Network Interface Guide), To send a multicast datagram, specify an IP multicast address in the range Before a host can receive IP multicast datagrams, it must become a member of Incoming multicast packets are accepted by the kernel IP layer if any socket UDP datagram destined to the shared port is delivered to all sockets bound to the port. We have multicast TV streams, which we can use through our second network interface and we want to use ffmpeg to encode the video. We have “Multicast Group:port” for every stream, which is like “IP:PORT” and in our case the port is always the same 5000. Here are the steps you need to do if you want to receive these streams.

UdpCommunication, The mreq packing is based on some code that I found, that does not work. On my computer, at least. Sending to multicast groups is just fine; Here's some functional text: 5 """send(data[, port[, addr]]) - multicasts a UDP datagram. This, despite specifying the local IP address of the appropriate� But you would do well to use different multicast IP addresses for different application because switches will distribute multicast packets according to the IP address (regardless of port). So if you have two applications that use the same IP address but different ports, a machine that is interested in either application will have to listen to

UDPTunnel 1.1 - Columbia CS, UDPTunnel is a small program which can tunnel UDP packets bi-directionally over a All specified port numbers in this case must be even. Multicast is used for one-to-many broadcast. In a multicast configuration the Encoder/Gateway sends the UDP stream to a multicast group, such as: VLC then connects to this group on a specified port and plays the stream (s). Click on the text input box labeled Please Enter a Network URL

  • I happen to know Python. You snippet works great on Windows XP and Linux(openSUSE 11.3), exept that it consumes 100% CPU core.
  • The 100% CPU usage is due to sock.setblocking(0), you may wish to do a blocking read with a small timeout using sock.settimeout(0.1) or similar instead
  • This is a dead link now - is there an updated location for it?
  • The author's page is here and he has an email address listed (so I suppose he can be contacted), but his links to the above tool there is the same dead one.
  • How can this work, as there is no way it can know what multicast group to sub\scribe to?