[Twisted-Python] sniffing multicast traffic

Ben Barker ben at bbarker.co.uk
Wed Mar 10 08:03:46 EST 2010

>> 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"?

Sorry - yes, it was very vague! Never works. If I run wiresahrk I can
see udp packets addressed to, port 901, flying past, however
when I run my python script it does not appear to ever receive

The scritp I am running is almost identical to an exampel I found here:


>> I have managed to use tshark to display the packets :
>> tshark -i eth0  -x -l -f udp
> 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
	link  01:00:5e:00:00:04
	link  33:33:ff:7a:7e:4e
	link  01:00:5e:00:00:fb
	link  01:00:5e:00:00:01
	link  33:33:00:00:00:01
	inet6 ff02::1:ff7a:7e4e
	inet6 ff02::1

That's interesting.... eth1 is the wrong interface! In fact, it isn't
connected to anything at all. eth0 is the interface that should be
being used. I will try to swap them around, but presumably this is
something I can specify somwhere...

As I said, the code I am using is taken from the above link, but the
exact listing is given below:

from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
from twisted.application.internet import MulticastServer

class MulticastServerUDP(DatagramProtocol):
    def startProtocol(self):
        print 'Started Listening'
        # Join a specific multicast group, which is the IP we will respond to

    def datagramReceived(self, datagram, address):
            print "Server Received:" + repr(datagram)

reactor.listenMulticast(901, MulticastServerUDP())

> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list