Illuminatus has asked for the wisdom of the Perl Monks concerning the following question:
This seems to take quite a long time to complete. I was wondering if anyone else had seen this problem, and found a more efficient solutionwhile (1) { my $hdr; my $len = read $handle, $hdr, $PKT_HDR_LEN; die "read failed: $!\n" if not defined $len; return undef if $len == 0; $TotalPkts++; my @vals = unpack "LLLL", $hdr; $pkt{secs} = $vals[0]; $pkt{usecs} = $vals[1]; $pkt{stamp} = ($vals[0] * 1.0) + ($vals[1] / 1000000); $pkt{len} = $vals[3]; $len = read $handle, $data, $vals[2]; die "read failed: $!\n" if not defined $len; die "file truncated: $!\n" if $len < $vals[2]; my $ipdata = eth_strip($data); $ip = NetPacket::IP->decode($ipdata); if ($$ip{proto} == 47) { $is_ce = ($$ip{tos} & 3 == 3); $ipdata = NetPacket::IP::strip($ipdata); $ipdata = substr $ipdata, 4; my $gre = NetPacket::IP->decode($ipdata); next if $$gre{src_ip} ne $ip1 && $$gre{src_ip} ne $ip2; $ip = $gre; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: net::pcap performance
by broomduster (Priest) on Aug 02, 2008 at 00:06 UTC | |
|
Re: net::pcap performance
by GrandFather (Saint) on Aug 01, 2008 at 23:57 UTC | |
|
Re: net::pcap performance
by Khen1950fx (Canon) on Aug 01, 2008 at 23:50 UTC | |
by sandeepbharmoria (Beadle) on Aug 02, 2008 at 11:42 UTC |