NetPacket(3)

πŸ’– NetPacket πŸ’–

okay so bestie, we're looking at NetPacket(3) β€” it lives in the User Contributed Perl Documentation section of the manual, and it is literally the mothership of a whole little family of packet modules. sit down, grab a boba, let's get into it πŸ§‹βœ¨


✨ VERSION ✨

version 1.8.0 β€” she's a 1.8.0 girly, periodt. πŸ‘‘


🌸 SYNOPSIS 🌸

# NetPacket is a base class only

and that's it. that's the whole synopsis. she contains multitudes but she is, herself, a base class only. main character energy with zero lines πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

NetPacket is the base class for a whole cluster of modules that do the decoding and encoding of network protocols. every single descendant module of NetPacket knows exactly how to encode and decode packets for whatever network protocol it implements. wanna know the deets for a specific protocol? go read that module's own docs, bestie β€” it's all protocol-specific up in there. πŸ“–

okay and here's the tea, and it's important: there is NO inheritance in the NetPacket:: cluster beyond the fact that each protocol module is a NetPacket. why, you ask? because forcing inheritance relationships (like, say, between the IP, UDP and TCP protocols) was seen to be too restrictive β€” it would make tunneling and other unusual situations genuinely difficult. so they said "not today, Satan" and kept it flat. no cap. 🚫🌳


πŸŽ€ WRITING YOUR OWN NetPacket:: MODULE πŸŽ€

okay so this is the part where they invite you to the group project!! you are encouraged to write your own additional NetPacket:: modules and to improve the existing ones. got suggestions? got changes? contact the maintainer of the module in question, they wanna hear from you. 🫢

the following sections are a list of suggestions and conventions for writing a NetPacket:: module. not rules, vibes.

πŸ’œ Naming Conventions πŸ’œ

when you're creating a module in the NetPacket:: namespace, it is suggested that you stick to a couple of conventions when naming packet contents. the goal here is a consistent namespace that makes NetPacket:: easier to use. (manifesting a clean namespace ✨)

content names are all lowercase, with underscores separating multiple words. and here are the recommended abbreviations:

  • Word β†’ Abbreviation
    • source β†’ src
    • destination β†’ dest
    • checksum β†’ cksum
    • identifier β†’ id
    • version β†’ ver
    • protocol β†’ proto

πŸ”₯ Required Methods πŸ”₯

encode(), decode(), strip()

that's the holy trinity right there. all three. no skipping πŸ™…

πŸ“ Required Fields πŸ“

every NetPacket:: object should have the following fields. like, every single one. it's giving non-negotiable.

  • _parent β€” a link to the parent NetPacket:: object in which this NetPacket:: object is encapsulated. this field is undefined if there is no parent object. (orphan energy, but make it a feature πŸ’€)
  • _frame β€” a copy of the raw data of the packet. the raw. the unfiltered. the unedited footage πŸ“Έ
  • data β€” this field should contain the data encapsulated in the packet (i.e. any headers or trailers stripped off), or undef if the packet contains no data. and okay, note this: in this sense, data means information not relevant to the particular protocol being decoded. for example? an ARP packet contains many header fields but no data. a UDP datagram, however, contains header fields and a payload. iykyk. πŸ’…

πŸ‘‘ SEE ALSO πŸ‘‘

Joel Knight has a patch for NetPacket for IPv6 support, available at http://www.packetmischief.ca/code/netpacket/. go get your IPv6 fix bestie 🌈


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.

okay so real talk, that last bit matters: no warranty, no implied merchantability, no fitness for a particular purpose. she is free and she is as-is. 🫠

🌟 AUTHORS 🌟

  • Tim Potter <tpot@samba.org>
  • Stephanie Wehner <atrak@itsx.com>
  • Yanick Champoux <yanick@cpan.org>

and that's the whole page, bestie!! πŸŽ‰ this one was rendered by perl v5.42.0, dated 2026-02-05, and it lives in the NetPacket(3) slot of the manual. slay, go decode some packets responsibly πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from