[Twisted-Python] sniffing multicast traffic

Phil Mayers p.mayers at imperial.ac.uk
Wed Mar 10 07:03:18 EST 2010

On 10/03/10 10:35, Ben Barker wrote:
> Hello - I wonder if someone can help:
> We have some status info being sent by various machines using
> multicast addressed udp packets. I have been attempting to use twisted
> to write a python script that will passively monitor on the relevant
> port for any udp packets with the specified multicast address, which I
> can then parse the payloads of as required.
> I have been looking at the examples here:
> http://code.activestate.com/recipes/425975-simple-udp-multicast-client-server-using-twisted/
> But I seem to have trouble getting them to receive anything at all.

That's a little vague. Does "trouble" mean "it sometimes works" or 
"never works"?

> I have managed to use tshark to display the packets :
> tshark -i eth0  -x -l -f udp
> so I know the data is there (coming isn on address, port 901)

FYI, the group is usually not IGMP snooped, and is 
effectively therefore broadcast.

Conversely, groups outside this range require working IGMP querying / 
snooping and some help from (usually) a router, so this may be why you 
chose this range.

Broadly speaking, as long as the UDP socket is listening on the right 
port and you've called joingroup, you should be ok.

Can you post a complete example that isn't working for you?

When your code is running, have a look "/sbin/ip maddr" to ensure the 
group has been added to the socket listen filter.

More information about the Twisted-Python mailing list