# iwspy eth0 + 00:02:2D:22:2B:AE # # iwspy eth0 eth0 Statistics collected: 00:02:2D:22:2B:AE : Quality:31/92 Signal level:-66 dBm Noise level:-97 dBm (updated) # # cat iwspying.sh
while true do iwspy eth0 sleep 2 done |grep Signal # # # sh iwspying.sh 00:02:2D:22:2B:AE : Quality:28/92 Signal level:-67 dBm Noise level:-95 dBm (updated) 00:02:2D:22:2B:AE : Quality:29/92 Signal level:-66 dBm Noise level:-95 dBm (updated) 00:02:2D:22:2B:AE : Quality:30/92 Signal level:-67 dBm Noise level:-97 dBm (updated) 00:02:2D:22:2B:AE : Quality:27/92 Signal level:-67 dBm Noise level:-94 dBm (updated) 00:02:2D:22:2B:AE : Quality:30/92 Signal level:-66 dBm Noise level:-96 dBm (updated) 00:02:2D:22:2B:AE : Quality:24/92 Signal level:-70 dBm Noise level:-94 dBm (updated) 00:02:2D:22:2B:AE : Quality:29/92 Signal level:-68 dBm Noise level:-97 dBm (updated) 00:02:2D:22:2B:AE : Quality:27/92 Signal level:-67 dBm Noise level:-94 dBm (updated)Ensuite, j'extrais ce qui m'intéresse avec un petit script Perl :
#!/usr/bin/perl
# 00:05:5D:F2:D9:CA : Quality:23/92 Signal level:-74 dBm Noise level:-97 dBm (updated)
while ($line = <STDIN>)
{
if ($line =~ /level:(-[0-9]+).*level:(-[0-9]+)/)
{
print "$1 $2\n";
}
}
Et enfin, je crée le graphe avec 'gnuplot'
:
gnuplot <<END set title "iwspy for DLink (00:05:5D:F2:D9:CA)" set yrange [-120:-50] set ylabel "dBm" set xlabel "Sample" set term png # set output 'dlink-strength.png' plot 'dlink' using :1 title "DLink Signal", 'dlink' using :2 title "Noise" set title "iwspy for Avaya (00:02:2D:22:2B:AE)" set output 'avaya-strength.png' plot 'avaya' using :1 title "Avaya Signal", 'avaya' using :2 title "Noise" ENDBref, on est presque prêt pour tester/comparer de nouvelles antennes... :-)
------------------ File vu.pl ---------------------------
#!/usr/bin/perl
$scale="0....+....10...+....20...+....30...+....40...+....50...+....60...+....70...+....";
while (1)
{
`ping -c1 $ARGV[0]`;
open STATS, "</proc/net/wireless" or die "boum!";
while ($line = <STATS>)
{ # eth0: 0000 22. 191. 169. 0 0 0
if ($line =~ / ([0-9]+)/)
{
printf("%s*\n", substr($scale, 0, $1));
}
}
close STATS;
}
-------------------
Qui donne ceci :
# iwspy eth0 + 00:02:2D:22:2B:AE # vu.pl 192.168.1.1 0....+....10...+....20...+.* 0....+....10...+....20...* 0....+....10...+....20...* 0....+....10...+....20...* 0....+....10...+....20...* 0....+....10...+....20..* 0....+....10...+....20..* 0....+....10...+....20...+* 0....+....10...+....20...+* 0....+....10...+....20...+.* 0....+....10...+....20...+.* 0....+....10...+....20..* 0....+....10...+....20* 0....+....10...+....* 0....+....10...+..* 0....+....10.* 0....+....10.* 0....+....* 0....+.* <- je met ma main pour empêcher les ondes d'entrer/sortir ;-) 0....+..* 0....+...* 0....+....* 0....+....10* 0....+....10..* 0....+....10...* ^C # -------------------
!!! je ne suis pas très sûr du 'zéro'...(+/-1)
!!! le "$line =~ / ([0-9]+)/" est un peu 'ad-hoc' (Quick &
Dirty)
(i.e. "le premier nombre précédé de deux espaces")
!!! le 'boum!' et le manque total de tests aussi...
!!! lire 'dBm' me rassurait avec iwspy. Est-ce psychologique?
;-)
Philippe Teuwen propose une version améliorée dans
un mail à [lln-wave]