Net::F...Online(3pm)
π Net::Frame::Dump::Online β¨
hiii bestie π«Ά so this is the manual page for Net::Frame::Dump::Online β it lives in the perl docs, section 3pm, under "User Contributed Perl Documentation" (yes that's the whole vibe of the manual name, iykyk). Anyway. Snacks out, brain on, let's go π
πΈ NAME
Net::Frame::Dump::Online β a tcpdump-like implementation, online mode. that's the whole name. iconic of it honestly β¨
π¦ SYNOPSIS
okay so first up, the absolute simplest thing you can do β just make a Dump object and let it cook:
use Net::Frame::Dump::Online;
#
# Simply create a Dump object
#
my $oDump = Net::Frame::Dump::Online->new(
dev => 'eth0',
);
$oDump->start;
# Gather frames
while (1) {
if (my $f = $oDump->next) {
my $raw = $f->{raw};
my $firstLayerType = $f->{firstLayer};
my $timestamp = $f->{timestamp};
}
}
$oDump->stop;
and then there's the on-event loop era, if you'd rather have a callback do the work instead of a while (1) staring at you π:
#
# Create a Dump object, using on-event loop
#
sub callOnRecv {
my ($h, $data) = @_;
print "Data: $data\n";
my $oSimple = Net::Frame::Simple->newFromDump($h);
print $oSimple->print."\n";
}
my $oDumpEvent = Net::Frame::Dump::Online->new(
dev => 'eth0',
onRecv => \&callOnRecv,
onRecvCount => 1,
onRecvData => 'test',
);
# Will block here, until $onRecvCount packets read, or a stop() call has
# been performed.
$oDumpEvent->start;
and here are all the default parameters you get when you create one, laid out exactly as the module does it, no cap π:
#
# Default parameters on creation
#
my $oDumpDefault = Net::Frame::Dump::Online->new(
dev => undef,
timeoutOnNext => 3,
timeout => 0,
promisc => 0,
unlinkOnStop => 1,
file => "netframe-tmp-$$.$int.pcap",
filter => '',
overwrite => 0,
isRunning => 0,
keepTimestamp => 0,
onRecvCount => -1,
frames => [],
);
π DESCRIPTION
this module implements a tcpdump-like program, for live capture from networks. like, actually live. from the wire. it's giving main character energy fr fr π₯
π ATTRIBUTES
devβ the network interface you want to listen on. There is no default value. you gotta say it, bestie.timeoutOnNextβ every single time you call thenextmethod, an internal counter gets updated. that counter is basically telling you "hey, you haven't received any data intimeoutOnNextseconds." and when a timeout does happen,timeoutgets set to true. β°timeoutβ whentimeoutOnNextseconds has been reached, this variable gets set to true, and it never resets. if you want it reset, go look attimeoutReset. periodt.snaplenβ if you want to capture a different snaplen, set it to a number. Defaults to1514. πpromiscβ by default, the interface is not put into promiscuous mode. set this parameter to true if that's what you want. live your truth πunlinkOnStopβ when you call thestopmethod, the generated.pcapfile gets removed β unless you set this parameter to a false value. ποΈonRecvβ if you put a reference to a sub in here, it will be called every time a packet is received on the interface. go check the SYNOPSIS for an example of how that looks. πonRecvDataβ this parameter stores extra data that gets passed along to theonRecvcallback.onRecvCountβ by default it's set to read packets that reach your network interface forever. set it to a positive value and it'll only readonRecvCountframes. π
β¨ the following are inherited attributes β¨
fileβ name of the generated.pcapfile. peek at the SYNOPSIS for the default name.filterβ the pcap filter to use. Defaults to no filter at all.overwriteβ overwrites a.pcapfile that already exists. Defaults to not doing that.firstLayerβ stores info about the first layer type contained in a read frame. this attribute only gets filled after you call thestartmethod.isRunningβ returns true if a call tostarthas happened, false otherwise β or if a call tostophas happened.keepTimestampβ sometimes, when frames get captured and saved to a.pcapfile, the timestamps suck π like, you send a frame, you receive the reply, but your request appears to have been sent after the reply. wild. so to fix that, you can useNet::Frame::Dump's own timestamping system. the default is0. set it manually to1if you need the original.pcapframe timestamps.
π METHODS
newnew (hash)β the object constructor. you can pass attributes in and they'll overwrite the defaults. check the SYNOPSIS for the default values. πstartβ call this method when you want to start reading frames from the network. πstopβ call this method when you want to stop reading frames from the network. πnextβ returns the next captured frame;undefif nothing's waiting. every time you call this method, a comparison happens to see if no frame has been captured duringtimeoutOnNextnumber of seconds. if that's the case, thetimeoutattribute is set to1to reflect the pending timeout. πstore (Net::Frame::Simple object)β this method stores theNet::Frame::Simpleobject you pass as a single parameter internally, sorted. thegetKeymethods, which are implemented in variousNet::Frame::Layerobjects, get used to efficiently retrieve frames (via thegetKeyReversemethod).
basically, it's used to make the recv method (from Net::Frame::Simple) quickly retrieve the reply frame for a request frame. β‘
getFramesFor (Net::Frame::Simple object)β this returns an array of possible reply frames for theNet::Frame::Simpleobject you specified. for example, reply frames for a UDP probe will be all the frames that have the same source port and destination port as the request. π―flushβ flushes stored frames β the ones that got stored via thestoremethod. π§ΉtimeoutResetβ resets the internal timeout state (thetimeoutattribute). β»οΈgetStatsβ tries to get packet statistics on an open descriptor. returns a reference to a hash that has the following fields:ps_recv,ps_drop,ps_ifdrop. πisFatherisSonβ these methods tell you whether your current process is, respectively, the father or the son process of theNet::Frame::Dump::Onlineobject. family drama, but make it fork π§¬
π¦ SEE ALSO
Net::Frame::Dump
π AUTHOR
Patrice <GomoR> Auffret
β COPYRIGHT AND LICENSE
Copyright (c) 2006-2020, Patrice <GomoR> Auffret
You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.
okay that's the whole page bestie, you ate it π this was Net::Frame::Dump::Online(3pm) as documented by the User Contributed Perl Documentation, running under perl v5.36.0 and dated 2022-11-19 β go capture some frames, mwah π«Άβ¨π
π¦ where this page comes from
- debian bookworm: libnet-frame-dump-perl 1.18-2 Β· Artistic-1.0-Perl
- debian trixie: libnet-frame-dump-perl 1.18-2 Β· Artistic-1.0-Perl
- ubuntu noble: libnet-frame-dump-perl 1.18-2 Β· Artistic-1.0-Perl
- ubuntu resolute: libnet-frame-dump-perl 1.18-2 Β· Artistic-1.0-Perl
- ubuntu stonking: libnet-frame-dump-perl 1.18-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