3
votes

I'm currently using Twisted 10.1 to receive and parse UDP packets, but the standard implementation of reactor.listenUDP() only gives me access to the packet data, and I need to get the packet length from the UDP headers.

I've tried out Twisted's pairudp.py example, but it fails with an "ImportError: No module named eunuchs.tuntap". Doing an apt-cache search for python-eunuchs comes up with nothing, and looking at Ubuntu's package search, I can see that python-eunuchs hasn't been a part of Ubuntu since Dapper, circa 2006.

In any case, the Twisted Pair project itself is listed on it's twistedmatrix.com page as unmaintained, so I would be quite hesitant to start a project using any of it's libraries.

Can anyone provide me with pointers or even a (working?) example on how I can do this using Twisted 10.1 / 10.2?

Update

As Glyph pointed out, I'm trying to solve a problem in a complex manner that can be solved simply. Since I can get the length of the packet data using len(data), and since the length of a UDP packet header is 8 bytes, totalSizeOfUdpPacket = 8 + len(data).

*facepalm*

1
Why isn't len(data) adequate? - Glyph
Post your self-answer below, since it's probably worth keeping this around for anyone else. - detly
This is not a contradiction of the answer given, but I wanted to point out that I recently removed the eunuchs dependency. Twisted Pair now has no extra dependencies (beyond those Twisted has overall). twisted.pair.tuntap now also has pretty good test coverage and even a little bit of documentation. - Jean-Paul Calderone

1 Answers

2
votes

As Glyph pointed out, you're trying to solve a problem in a complex manner that can be solved simply. Since you can get the length of the packet data using len(data), and since the length of a UDP packet header is 8 bytes, totalSizeOfUdpPacket = 8 + len(data).