http://qs321.pair.com?node_id=296375

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to create an ARP network packet. Has anyone ever attempted to do this that could possibly point me in the right direction?

Replies are listed 'Best First'.
Re: Creating an ARP Packet
by athomason (Curate) on Oct 03, 2003 at 21:05 UTC
    If you need to use Perl, you'll probably get farthest by using the module hooks into libpcap, which implements raw socket functionality on *NIX and Windows. (A previous discussion of raw sockets in Perl is here).

    Glancing at CPAN, there's NetPacket::ARP, but apparently encoding isn't implemented. Still, it shouldn't be too hard to finish that yourself since the meat of the decoder is in a fairly self-documenting call to unpack, which I imagine could be inverted fairly easily. Once you have the encoded packet, one or more of NetPacket::Ethernet, Net::PcapUtils, and Net::RawIP should help you get it on the wire.

Re: Creating an ARP Packet
by hardburn (Abbot) on Oct 03, 2003 at 20:15 UTC

    Read RFC 826, then search Google for how to create a raw Ethernet packet. I don't know of any modules to help with this.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated