Net::F...r::UDP(3pm)

πŸ“¦
version 1.21 Β· 2 versions
  • 1.21 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.21 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Net::Frame::Layer::UDP β€” the manual, but make it make sense πŸ’–

okay bestie, gather round, because today we're learning about Net::Frame::Layer::UDP, aka the User Datagram Protocol layer object from the Net::Frame::Layer family. this is from the User Contributed Perl Documentation, and yes it's giving very much "networking girlie who actually reads the RFCs" energy πŸŽ€


✨ NAME ✨

Net::Frame::Layer::UDP β€” the User Datagram Protocol layer object. that's it, that's the whole name, slay πŸ’…


🌸 SYNOPSIS 🌸

here's the vibe, copy-paste ready, no cap:

use Net::Frame::Layer::UDP qw(:consts);

# Build a layer
my $layer = Net::Frame::Layer::UDP->new(
   src      => getRandomHighPort(),
   dst      => 0,
   length   => 0,
   checksum => 0,
);
$layer->pack;

print 'RAW: '.$layer->dump."\n";

# Read a raw layer
my $layer = Net::Frame::Layer::UDP->new(raw = $raw);

print $layer->print."\n";
print 'PAYLOAD: '.unpack('H*', $layer->payload)."\n"
   if $layer->payload;

so first half is you building a layer and packing it and dumping the raw bytes, second half is you reading a raw layer back in and printing it plus its payload. literally the whole lifecycle, bestie. periodt ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

this module implements the encoding and decoding of the UDP layer. so it builds UDP and it parses UDP. both directions. it's a two-way icon πŸ‘‘

the RFC, for the girls who like primary sources:

ftp://ftp.rfc-editor.org/in-notes/rfc768.txt

and if you wanna know about the other attributes and methods that come along for the ride, go look at Net::Frame::Layer. it's the parent energy, iykyk πŸ’œ


πŸŽ€ ATTRIBUTES πŸŽ€

  • src, dst β€” source and destination ports. two ports, one layer, iconic behavior 🫢
  • length β€” the length in bytes of the datagram, including the layer 7 payload. so like, that's layer 4 + layer 7, math girlies rise πŸ’…
  • checksum β€” the checksum of the datagram. yes it's spelled checksum, no we don't talk about it 😭

🌈 inherited attributes

these ones you don't get from this module, you get them from the parent. go read Net::Frame::Layer for more info, fr fr:

  • raw
  • payload
  • nextLayer

πŸ’… METHODS πŸ’…

⭐ new

⭐ new (hash)

the object constructor, aka how you make the thing</b>. you can pass attributes in and they'll overwrite the default ones. want the default values? look at SYNOPSIS, bestie, they're all right there ✨

⭐ computeLengths

computes various lengths contained within this layer. just... the lengths. all of them. in here. do the math for me please 🧚

⭐ computeChecksums ({ type => PROTO, src => IP, dst => IP })

so to compute checksums of TCP, you gotta pass the protocol type (IPv4, IPv6), plus the source and destination IP addresses β€” IPv4 addresses for IPv4, IPv6 addresses for IPv6. match your energies, don't mix them πŸ’œ

⭐ getKey

⭐ getKeyReverse

these two methods are basically here to speed things up when you're using the recv method from Net::Frame::Simple. usually you write them when you need to write a match method. it's a performance thing, ngl πŸ”₯

⭐ match (Net::Frame::Layer::UDP object)

this one is mostly used internally. you hand it a Net::Frame::Layer::UDP layer as a parameter, and it returns true if this is a response corresponding for the request, or false if it's not. vibe check but for packets πŸ’€

🌈 inherited methods

these come from the parent. some of them may be overridden in this layer, and some others may not be meaningful in this layer at all. see Net::Frame::Layer for more, bestie:

  • layer
  • computeLengths
  • computeChecksums
  • pack
  • unpack
  • encapsulate
  • getLength
  • getPayloadLength
  • print
  • dump

πŸ’€ CONSTANTS πŸ’€

No constants here.

that's it. nothing. empty. the void. no constants, bestie, sorry 😭


πŸ“ SEE ALSO πŸ“

  • Net::Frame::Layer

πŸ‘‘ AUTHOR πŸ‘‘

Patrice <GomoR> Auffret


Copyright (c) 2006-2019, Patrice <GomoR> Auffret

You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.


real talk though: it's the Artistic license, so read LICENSE.Artistic in the source distribution archive before you go redistributing, okay? 🫢

and that's the whole page, bestie! this was perl v5.36.0, dated 2022-12-04, from the Net::Frame::Layer::UDP manual page. go forth and packet, you absolute main character πŸŒŸπŸ’–βœ¨