Net::F...r::UDP(3pm)
π 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 spelledchecksum, 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:
rawpayloadnextLayer
π 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:
layercomputeLengthscomputeChecksumspackunpackencapsulategetLengthgetPayloadLengthprintdump
π 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 AND LICENSE π
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 ππβ¨
π¦ where this page comes from
- debian bookworm: libnet-frame-perl 1.21-2 Β· Artistic-1.0-Perl
- debian trixie: libnet-frame-perl 1.21-2 Β· Artistic-1.0-Perl
- ubuntu noble: libnet-frame-perl 1.21-2 Β· Artistic-1.0-Perl
- ubuntu resolute: libnet-frame-perl 1.21-2 Β· Artistic-1.0-Perl
- ubuntu stonking: libnet-frame-perl 1.21-2 Β· Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms