porpoise_paul has asked for the wisdom of the Perl Monks concerning the following question:

I've written the sub below in order to return the signal level of wireless clients.

open TCPDUMP, "tcpdump -e -i $interface ether src $dst_hw_addr|" or di +e "Can't open tcpdump.\n"; sub get_rssi { my $rssi = undef; while (!defined $rssi) { my $line = readline(TCPDUMP); if ( $line =~ m#(?<sig_level>-\d{1,3})dB signal.*QoS#ig ) { $rssi = $+{sig_level}; } } $rssi; }

The sub works fine except that perl seems to be playing a constant game of catchup with tcpdump. I have the sub running in a loop and it will freeze the loop for about 7 sec and then execute 6 loops in quick succession before freezing again. Since the purpose of the code is to output a tone based on the signal level, the freezing makes the tone useless.

I'm pretty new to perl and any help would be greatly appreciated. I thought about getting into the Net::Pcap mod, but using the file handle to open tcpdump just seemed so much simpler.

Thanks for any input

Replies are listed 'Best First'.
Re: online tcpdump filter
by gmargo (Hermit) on Dec 04, 2009 at 21:05 UTC