Net::F...Online2(3pm)

πŸ“¦
version 1.18 Β· 2 versions
  • 1.18 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.18 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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 the next method, an internal counter gets updated. That counter is basically keeping score of whether you've received zero data since timeoutOnNext seconds went by. When a timeout happens, timeout gets set to true. It's the module's little way of saying "girl, nothing is coming." 😭
  • timeout β€” When timeoutOnNext seconds has been reached, this variable is set to true, and never reset. Never ever. If you want it reset, go see timeoutReset, that's literally its whole thing. πŸ’€
  • snaplen β€” If you want to capture a different snaplen, set it to a number. Defaults to 1514. ⭐
  • 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 the start method. 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 to start has been done, false otherwise or if a call to stop has been done. Basically a vibe check for "are we capturing rn?" 🌸
  • keepTimestamp β€” Okay so sometimes, when frames are captured and saved to a .pcap file, 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 is 0. Set it manually to 1 if you need the original .pcap frames' timestamps. πŸ•°οΈ

πŸ’œ METHODS πŸ’œ

  • new
  • new (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; undef if none are awaiting. Every time this method is called, a comparison is done to see if no frame has been captured during timeoutOnNext number of seconds. If so, the timeout attribute is set to 1 to reflect the pending timeout. No cap. ⏳
  • store (Net::Frame::Simple object) β€” This method will store internally, sorted, the Net::Frame::Simple object passed as a single parameter. The getKey methods, implemented in various Net::Frame::Layer objects, will be used to efficiently retrieve frames (via the getKeyReverse method).

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 specified Net::Frame::Simple object. 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 the store method. Out they go. 🧹
  • timeoutReset β€” Reset the internal timeout state (the timeout attribute). 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 (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 πŸ¦‹βœ¨