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.


In reply to Re: How to check the UDP checksum of an IO::Socket::INET packet by VinsWorldcom
in thread How to check the UDP checksum of an IO::Socket::INET packet by dantheman1210

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.