NetPacket::ARP(3)
π NetPacket::ARP π
okay so bestie, you know how when your computer's like "hey who has this IP address??" and someone's like "omg that's me, here's my MAC" β that whole little exchange? that's ARP, and this is the Perl module that lets you build those packets and take them apart. it's NetPacket::ARP, it lives in the User Contributed Perl Documentation section of your man pages, and honestly? it's giving packet-crafting main character energy. π
β¨ NAME β¨
NetPacket::ARP β Assemble and disassemble ARP (Address Resolution Protocol) packets.
πΈ VERSION πΈ
version 1.8.0
π¦ SYNOPSIS π¦
use NetPacket::ARP;
$tcp_obj = NetPacket::ARP->decode($raw_pkt);
$tcp_pkt = NetPacket::ARP->encode(params...); # Not implemented
ngl, yes, the variable names say tcp for an ARP module. that's just how it is in here. we don't fix it, we respect it. π
π DESCRIPTION π
NetPacket::ARP hands you a little toolkit for assembling and disassembling packets that use ARP (Address Resolution Protocol). that's the whole vibe. π«Ά
π§ Methods
NetPacket::ARP->decode([RAW PACKET])β Decode the raw packet data you give it and return an object stuffed with instance data. heads up bestie: this method will quite happily decode garbage input. like, it does not care. it will munch on literal nonsense and hand you back an object. so it is your responsibility as the programmer to make sure the packet data you pass in is actually valid. no cap.NetPacket::ARP->encode(param => value)β Return an ARP packet encoded with the instance data you specify. Not implemented. π (see the TODO section, she's aware)
π Functions
NetPacket::ARP::strip([RAW PACKET])β Return the encapsulated data (or payload) contained in the TCP packet. but here's the thing: no payload data is encapsulated in an ARP packet (it's only instance data), so this function returnsundef. iconic of it, honestly.
π Instance data
the instance data for the NetPacket::ARP object is made up of these fields:
htypeβ Hardware type.protoβ Protocol type.hlenβ Header length.plenβ Protocol length.opcodeβ One of the following constants:ARP_OPCODE_REQUESTARP_OPCODE_REPLYRARP_OPCODE_REQUESTRARP_OPCODE_REPLY
shaSource hardware address.spaSource protocol address.thaTarget hardware address.tpaTarget protocol address.
π Exports
- default β none
- exportable β none
- tags β the following tags group together related exportable items:
:ALLβ All the above exportable items.
β EXAMPLE β
Print out arp requests on the local network. periodt. π
#!/usr/bin/perl -w
use Net::PcapUtils;
use NetPacket::Ethernet qw(:types);
use NetPacket::ARP;
sub process_pkt {
my ($arg, $hdr, $pkt) = @_;
my $eth_obj = NetPacket::Ethernet->decode($pkt);
if ($eth_obj->{type} == ETH_TYPE_ARP) {
my $arp_obj = NetPacket::ARP->decode($eth_obj->{data}, $eth_obj);
print("source hw addr=$arp_obj->{sha}, " .
"dest hw addr=$arp_obj->{tha}\n");
}
}
Net::PcapUtils::loop(\&process_pkt);
π TODO π
the author's own to-do list, preserved in all her glory:
- Implement encode() function
- Does this work for protocols other than IP? Need to read RFC.
- Example is a bit silly
"Example is a bit silly" β me @ my entire life tbh. π
π COPYRIGHT π
Copyright (c) 2001 Tim Potter.
Copyright (c) 1995,1996,1997,1998,1999 ANU and CSIRO on behalf of the participants in the CRC for Advanced Computational Systems ('ACSys').
This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
π AUTHOR π
Tim Potter <tpot@samba.org>
and that's the whole page, bestie! this one's from perl v5.42.0, dated 2026-02-05, so go forth and decode some ARP packets responsibly (remember: valid input is your job, not the module's π«Άβ¨).
π¦ where this page comes from
- fedora 43: perl-NetPacket 1.8.0-1.fc43 Β· Artistic-2.0 AND (GPL-1.0-or-later OR Artistic-1.0-Perl)
- fedora 44: perl-NetPacket 1.8.0-1.fc44 Β· Artistic-2.0 AND (GPL-1.0-or-later OR Artistic-1.0-Perl)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms