NetPacket::IP(3)
π NetPacket::IP π
okay bestie, so this is the manual page for NetPacket::IP(3) β that's the User Contributed Perl Documentation section, iykyk. She's a Perl module that assembles and disassembles IP (Internet Protocol) packets, and honestly? she's iconic for it. no cap. π
β¨ VERSION β¨
version 1.8.0 β that's the vibe check and she passed π
π SYNOPSIS π
here's the whole look, copy it exactly bestie:
use NetPacket::IP;
$ip_obj = NetPacket::IP->decode($raw_pkt);
$ip_pkt = NetPacket::IP->encode($ip_obj);
$ip_data = NetPacket::IP::strip($raw_pkt);
like, that's it. that's the whole entrance. main character energy fr fr π¦
π DESCRIPTION π
NetPacket::IP gives you a whole lil set of routines for assembling and disassembling packets using IP (Internet Protocol). she does the tedious bits so you don't have to, periodt.
π§ Methods
NetPacket::IP->decode([RAW PACKET])β decodes the raw packet data you hand her and hands back an object stuffed with instance data. and okay, listen: she will quite happily decode garbage input. like, no complaints, no side-eye. so it is 100% your responsibility as the programmer to make sure you're actually passing valid packet data in here. she trusts you. don't make it weird. πNetPacket::IP->encode()β returns an IP packet encoded with whatever instance data you specified. she infers the total length of the packet automatically from the payload length, and she also adjusts the checksum for you. self-sufficient queen π
πΈ Functions
NetPacket::IP::strip([RAW PACKET])β returns the encapsulated data (a.k.a. the payload) that's chillin' inside the IP packet. this data is suitable to be used as input for otherNetPacket::*modules, so it plays nice with the whole friend group π«Ά
this function is equivalent to creating an object using the decode() constructor and then returning the data field of that object. same result, less typing. slay.
π Instance data
the instance data on your NetPacket::IP object has these fields, and here's what each one is giving:
verβ the IP version number of this packet.hlenβ the IP header length of this packet.flagsβ the IP header flags for this packet.foffsetβ the IP fragment offset for this packet.tosβ the type-of-service for this IP packet.lenβ the length (including length of header) in bytes for this packet.idβ the identification (sequence) number for this IP packet.ttlβ the time-to-live value for this packet.protoβ the IP protocol number for this packet.cksumβ the IP checksum value for this packet.src_ipβ the source IP address for this packet in dotted-quad notation.dest_ipβ the destination IP address for this packet in dotted-quad notation.optionsβ any IP options for this packet.dataβ the encapsulated data (payload) for this IP packet.
π« Exports
defaultβ none. yeah. nothing. we start from scratch around here πexportableβIP_PROTO_IPIP_PROTO_ICMPIP_PROTO_IGMPIP_PROTO_IPIPIP_PROTO_TCPIP_PROTO_UDPIP_VERSION_IPv4tagsβ the following tags group together related exportable items::protosβIP_PROTO_IPIP_PROTO_ICMPIP_PROTO_IGMPIP_PROTO_IPIPIP_PROTO_TCPIP_PROTO_UDP:versionsβIP_VERSION_IPv4:stripβ imports the strip functionip_strip.:ALLβ all the above exportable items. the whole menu, bestie π½οΈ
π₯ EXAMPLE π₯
this script dumps IP frames by IP address and protocol straight to standard output. she ate:
#!/usr/bin/perl -w
use strict;
use Net::PcapUtils;
use NetPacket::Ethernet qw(:strip);
use NetPacket::IP;
sub process_pkt {
my ($user, $hdr, $pkt) = @_;
my $ip_obj = NetPacket::IP->decode(eth_strip($pkt));
print("$ip_obj->{src_ip}:$ip_obj->{dest_ip} $ip_obj->{proto}\n");
}
Net::PcapUtils::loop(\&process_pkt, FILTER => 'ip');
π TODO π
the to-do list, aka the "we'll get to it" list, lowkey real of her to admit:
- IP option decoding β currently stored in binary form.
- Assembly of received fragments.
π COPYRIGHT π
Copyright (c) 2001 Tim Potter and Stephanie Wehner.
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>
- Stephanie Wehner <atrak@itsx.com>
and that's the whole page, bestie!! π this lil doc ships with perl v5.42.0 and it's dated 2026-02-05 β go forth and decode responsibly, mwah πβ¨π¦
π¦ 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