Net::F...Online2(3pm)
β¨ NAME β¨
Bestie, say hi to Net::Frame::Dump::Online2 β a tcpdump-like implementation, online mode and non-blocking. It lives in the User Contributed Perl Documentation section of the manual (that's the 3pm energy, iykyk), and it's here to grab packets off your network live while you do literally anything else. Non-blocking, so it's not gonna ghost you mid-loop. π
π SYNOPSIS π
Okay so here's the whole vibe, copy it exactly:
use Net::Frame::Dump::Online2;
#
# Simply create a Dump object
#
my $oDump = Net::Frame::Dump::Online2->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;
#
# Default parameters on creation
#
my $oDumpDefault = Net::Frame::Dump::Online2->new(
timeoutOnNext => 3,
timeout => 0,
promisc => 0,
snaplen => 1514,
file => '',
overwrite => 0,
);
Look at those defaults, they're giving very much "already handled, bestie." π
πΈ DESCRIPTION πΈ
This module implements a tcpdump-like program, for live capture from networks. That's it. That's the whole job. It sits there, watches your interface, and hands you frames. Iconic behaviour, honestly. π¦
π ATTRIBUTES π
π The ones this module adds
devβ The network interface to listen on. No default value. So yeah, you have to tell it where to look, it's not gonna guess. πtimeoutOnNextβ Every single time you call thenextmethod, an internal counter gets updated. That counter is basically keeping score of whether you've received zero data sincetimeoutOnNextseconds went by. When a timeout happens,timeoutgets set to true. It's the module's little way of saying "girl, nothing is coming." πtimeoutβ WhentimeoutOnNextseconds has been reached, this variable is set to true, and never reset. Never ever. If you want it reset, go seetimeoutReset, that's literally its whole thing. π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 you want it. Your choice, your business, no judgement. π
π§ The inherited attributes (they come from elsewhere but they still ate)
filterβ Pcap filter to use. Defaults to no filter. As in, everything comes through. Chaotic but valid. β¨firstLayerβ Stores information about the first layer type contained on the read frame. Heads up though: this attribute is filled only after a call to thestartmethod. So don't go looking for it before you've started, it's not there yet, it's getting ready. πisRunningβ Returns true if a call tostarthas been done, false otherwise or if a call tostophas been done. Basically a vibe check for "are we capturing rn?" πΈkeepTimestampβ Okay so sometimes, when frames are captured and saved to a.pcapfile, timestamps suck. Like, genuinely. You send a frame, you receive the reply, but your request appears to have been sent after the reply. Time is a lie. So to correct that, you can use Net::Frame::Dump's own timestamping system. The default is0. Set it manually to1if you need the original.pcapframes' timestamps. π°οΈ
π METHODS π
newnew (hash)
Object constructor. You can pass attributes that will overwrite the default ones. Peep the SYNOPSIS for the default values, they're all sitting right there looking cute. π«Ά
startβ When you want to start reading frames from the network, call this method. That's the green flag. Go. π’stopβ When you want to stop reading frames from the network, call this method. That's the red flag, but the healthy kind. π΄nextβ Returns the next captured frame;undefif none are awaiting. Every time this method is called, a comparison is done to see if no frame has been captured duringtimeoutOnNextnumber of seconds. If so, thetimeoutattribute is set to1to reflect the pending timeout. No cap. β³store (Net::Frame::Simple object)β This method will store internally, sorted, theNet::Frame::Simpleobject passed as a single parameter. ThegetKeymethods, implemented in variousNet::Frame::Layerobjects, will be used to efficiently retrieve frames (via thegetKeyReversemethod).
Basically, it's used to make the recv method (from Net::Frame::Simple) retrieve the reply frame for a request frame quickly. Speed. Efficiency. Main character energy. π
getFramesFor (Net::Frame::Simple object)β This will return an array of possible reply frames for the specifiedNet::Frame::Simpleobject. For example, reply frames for a UDP probe will be all the frames which have the same source port and destination port as the request. Matchy matchy. π―flushβ Will flush stored frames β the ones which have been stored via thestoremethod. Out they go. π§ΉtimeoutResetβ Reset the internal timeout state (thetimeoutattribute). Fresh start, clean slate, we love to see it. πgetStatsβ Tries to get packet statistics on an open descriptor. It returns a reference to a hash that has the following fields:ps_recv,ps_drop,ps_ifdrop. Receipts! π
π«Ά 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 the LICENSE.Artistic file in the source distribution archive.
and that's the whole page, bestie β this one shipped as perl v5.36.0, dated 2022-11-19, on the Net::F...Online2(3pm) page. go capture some packets, you got this π¦β¨
π¦ 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