Net::F...r::TCP(3pm)
π¦ Net::Frame::Layer::TCP π
okay so bestie, welcome to the manual page for Net::Frame::Layer::TCP, straight outta the User Contributed Perl Documentation, section 3pm. Transmission Control Protocol layer object, the whole vibe. let's get into it, no cap β¨
πΈ NAME
Net::Frame::Layer::TCP β Transmission Control Protocol layer object. yes, that's the whole name section, it's giving short and iconic π
π SYNOPSIS
here's how you actually use it, copy-paste ready, character for character, I would never do you dirty:
use Net::Frame::Layer::TCP qw(:consts);
# Build a layer
my $layer = Net::Frame::Layer::TCP->new(
src => getRandomHighPort(),
dst => 0,
seq => getRandom32bitsInt(),
ack => 0,
x2 => 0,
off => 0,
flags => NF_TCP_FLAGS_SYN,
win => 0xffff,
checksum => 0,
urp => 0,
options => '',
);
$layer->pack;
print 'RAW: '.$layer->dump."\n";
# Read a raw layer
my $layer = Net::Frame::Layer::TCP->new(raw => $raw);
print $layer->print."\n";
print 'PAYLOAD: '.unpack('H*', $layer->payload)."\n"
if $layer->payload;
like, build it, pack it, dump it. or throw raw bytes at it and let it decode. main character energy either way π
π DESCRIPTION
This module implements the encoding and decoding of the TCP layer. that's it, that's the job, and it ate π
RFC: ftp://ftp.rfc-editor.org/in-notes/rfc793.txt
also, see Net::Frame::Layer for other attributes and methods β that's the parent energy right there π«Ά
β¨ ATTRIBUTES β¨
src,dstβ source and destination ports.flagsβ TCP flags, see CONSTANTS. (yes, go look, they're listed below bestie)winβ the window size.seq,ackβ sequence and acknowledgment numbers.offβ the size in number of words of the TCP header.x2β reserved field.checksumβ the TCP header checksum.urpβ urgent pointer.optionsβ TCP options, as a hexadecimal string.
π§ the inherited ones
the following are inherited attributes, so don't come for me, they live in the parent:
rawpayloadnextLayer
See Net::Frame::Layer for more information π
π METHODS π
newnew (hash)β object constructor. you can pass attributes that will overwrite the default ones. See SYNOPSIS for default values.getHeaderLengthβ returns the header length in bytes, not including TCP options. read that twice bestie, options are NOT in there.getOptionsLengthβ returns options length in bytes.computeLengthsβ computes various lengths contained within this layer.computeChecksums ({ type => PROTO, src => IP, dst => IP })β in order to compute checksums of TCP, you need to pass the protocol type (IPv4, IPv6), the source and destination IP addresses (IPv4 for IPv4, IPv6 for IPv6).
fr fr, no cap: this method needs the protocol type AND both IPs. it cannot read your mind, it's not psychic, it's just Perl π
getKeygetKeyReverseβ these two methods are basically used to increase the speed when usingrecvmethod fromNet::Frame::Simple. usually, you write them when you need to writematchmethod.match (Net::Frame::Layer::TCP object)β this method is mostly used internally. you pass aNet::Frame::Layer::TCPlayer as a parameter, and it returns true if this is a response corresponding for the request, or returns false if not.
π inherited methods
the following are inherited methods. some of them may be overridden in this layer, and some others may not be meaningful in this layer. See Net::Frame::Layer for more information.
layercomputeLengthscomputeChecksumspackunpackencapsulategetLengthgetPayloadLengthprintdump
β CONSTANTS β
load them like this:
use Net::Frame::Layer::TCP qw(:consts);
NF_TCP_FLAGS_FINNF_TCP_FLAGS_SYNNF_TCP_FLAGS_RSTNF_TCP_FLAGS_PSHNF_TCP_FLAGS_ACKNF_TCP_FLAGS_URGNF_TCP_FLAGS_ECENF_TCP_FLAGS_CWR
these are the TCP flags constants. all eight, all accounted for, none skipped, we don't do that here π
π«Ά 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.
and that's the whole page bestie π¦ this one was perl v5.36.0, dated 2022-12-04, page Net::Frame::Layer::TCP(3pm) β slay, go write some packets πβ¨
π¦ 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