in reply to How to check the UDP checksum of an IO::Socket::INET packet

I won't say it's impossible, but I don't *think* it can be done with IO::Socket::INET. The methods available will return peer address and port, but not specific fields in the IP or 'transport' (TCP / UDP) layer protocol.

It is certainly possible with something like Net::Pcap. But of course with that functionality comes complexity - you'll need to understand the structure of the entire frame / packet to get the right field and parse it into a meaningful number representing the checksum.

If you want to go that way for the receiver, you're looking at creating a simple packet capture ('sniffer') and there is an incredibly useful suite of Perl modules for crafting and dissecting frames / packets:

Net::Frame

Net::Frame::Simple

Net::Frame::Dump

As BrowserUK says above, packets with incorrect checksums aren't even sent. There is of course the possibility it gets mangled en-route - perhaps that's what you're trying to check for? Although even then, as the receiver passes this up the stack and the checksum fails to verify, I think the packet is discarded before being sent to the 'application' layer.

  • Comment on Re: How to check the UDP checksum of an IO::Socket::INET packet

Replies are listed 'Best First'.
Re^2: How to check the UDP checksum of an IO::Socket::INET packet
by dantheman1210 (Beadle) on Mar 14, 2012 at 17:13 UTC

    Well at least I wasn't totally missing something in IO::Socket::INET. :)

    I will look into the Net::Pcap and Net::Frame stuff to see what I can do with them.

    Thank you both for the assistance! I have no doubt that I will be back with some more painfully obvious questions.