Net::F...r::TCP(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::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:

  • raw
  • payload
  • nextLayer

See Net::Frame::Layer for more information πŸ’œ


πŸ’… METHODS πŸ’…

  • new
  • new (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 πŸ™ˆ
  • getKey
  • getKeyReverse β€” these two methods are basically used to increase the speed when using recv method from Net::Frame::Simple. usually, you write them when you need to write match method.
  • match (Net::Frame::Layer::TCP object) β€” this method is mostly used internally. you pass a Net::Frame::Layer::TCP layer 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.

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

⭐ CONSTANTS ⭐

load them like this:

use Net::Frame::Layer::TCP qw(:consts);
  • NF_TCP_FLAGS_FIN
  • NF_TCP_FLAGS_SYN
  • NF_TCP_FLAGS_RST
  • NF_TCP_FLAGS_PSH
  • NF_TCP_FLAGS_ACK
  • NF_TCP_FLAGS_URG
  • NF_TCP_FLAGS_ECE
  • NF_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 (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 πŸ’–βœ¨