[NETFRAME] Net::Packet::Dump / Net::Frame::Dump::Online - Concurrent Simultaneous Capture Limit?

Darien Kindlund darien at kindlund.com
Thu Jun 11 16:32:08 CEST 2009


On a related note, it seems that Net::Frame::Dump::Online->stop()
seems to indirectly trigger any END {} blocks within the parent
process.  Let me explain by example:

#!/usr/bin/perl -w

use strict;
use warnings;

use Data::Dumper;
use Net::Frame::Dump::Online;
use Net::Frame::Simple;

our $dump = undef;


# Instantiate object
$dump = Net::Frame::Dump::Online->new(
    dev           => 'eth0',
    file          => 'live.pcap',
    filter        => 'tcp port 22',
    promisc       => 1,
    snaplen       => 65535,
    keepTimestamp => 1,
    unlinkOnStop  => 1,
    overwrite     => 1,
);

END {
    print "END CALLED!\n";
    print "XXX: " . Dumper($dump->isSon()) . "\n";
    if (defined($dump) && $dump->isFather()) {
        print "REALLY DYING!\n";
    }
}

# Start capture
print "Starting...\n";
print Dumper($dump) . "\n";
$dump->start;
print Dumper($dump) . "\n";

while (1) {
    if (my $frame = $dump->next) {
        $frame = Net::Frame::Simple->newFromDump($frame);
        print $frame->print . "\n";
        #print Dumper($frame) . "\n";
        last;
    }
}

# Cleanup
print "Stopping...\n";
$dump->stop;
print Dumper($dump) . "\n";

print "Flushing...\n";
$dump->flush;
print Dumper($dump) . "\n";

-------

If you run the following code, you'll see that the "END CALLED!"
message appears after the $dump->stop call (which is unexpected) as
well as at the end of the script (which is expected).  I was thinking
about using the isFather and isSon functions to distinguish which
process we're in; however, it seems that these functions report back
the same information in both END calls (which is odd).  Any thoughts?

-- Darien


More information about the netframe mailing list