A set of scripts for producing plots from the output of the sky-collect program

This commit is contained in:
adamdunkels 2007-11-28 16:56:37 +00:00
parent 1b659316b7
commit 8d96443a3b
5 changed files with 282 additions and 0 deletions

View file

@ -0,0 +1,68 @@
#!/usr/bin/perl
while(<>) {
if(/^(\d+) (\d+) (\d+) \d+ \d+ \d+ \d+ \d+ \d+ (\d+) \d+ \d+ (\d+) (\d+) (\d+) (\d+) (\d+) /) {
$node{$2}{$1} = $_;
$lpm{$2} = $5;
$cpu{$2} = $6;
$rx{$2} = $7;
$tx{$2} = $8;
$rled{$2} = $9;
$lasttime{$2} = $1;
if($lastparent{$2} != $4) {
$parent{$2}{$1} = $4;
}
$lastparent{$2} = $4;
if($lastseqno{$2} == $3) {
$dup{$2}{$1} = 1;
}
if(defined $lastseqno{$2} &&
$3 != ($lastseqno{$2} + 1 % 256)) {
$lost{$2}{$1} = 1;
}
$lastseqno{$2} = $3;
if($firsttime{$2} == 0) {
$firsttime{$2} = $1;
}
}
}
open(F, "> power");
close(F);
foreach $n (sort {$a <=> $b} keys %node) {
# print "$n ";
open(F, "> data-$n");
foreach $k (sort keys %{$node{$n}}) {
print F $node{$n}{$k};
}
close(F);
open(F, "> dup-data-$n");
foreach $k (sort keys %{$node{$n}}) {
if($dup{$n}{$k} == 1) {
print F "$k $dup{$n}{$k}\n";
}
}
close(F);
open(F, "> lost-data-$n");
foreach $k (sort keys %{$node{$n}}) {
if($lost{$n}{$k} == 1) {
print F "$k $lost{$n}{$k}\n";
}
}
close(F);
open(F, "> parent-data-$n");
foreach $k (sort keys %{$node{$n}}) {
if($parent{$n}{$k} != 0) {
print F "$k $parent{$n}{$k}\n";
}
}
close(F);
open(F, ">> power");
print F ($lasttime{$n} - $firsttime{$n}) . " $n $lpm{$n} $cpu{$n} $rx{$n} $tx{$n} $rled{$n}\n";
close(F);
# print "\n";
}

View file

@ -0,0 +1,26 @@
#!/bin/sh
rm -f data-*
rm -f *.eps
./extract < $1
echo "Drawing graphs. Don't worry about messages about 'no valid points'."
for f in `echo data-*`
do
echo $f
cp $f data
cp lost-$f lost
cp dup-$f dup
cp parent-$f parent
gnuplot plot-all
for p in `echo plot-*.eps`
do
mv $p $f-$p
done
done
gnuplot plot-power
./stats < $1

View file

@ -0,0 +1,122 @@
set terminal postscript eps color font "Helvetica" 16
set xlabel "Time"
set xdata time
set timefmt "%s"
#set datafile separator " "
#set boxwidth 0.15
set style fill pattern 1
set style data lines
set key top left Left #width -3
set output "plot-battery.eps"
set ylabel "Battery level"
plot [:] [0:] \
'data' using 1:($9/4096 * 1.5) title "Battery level"
set output "plot-energy.eps"
set ylabel "Energy (mJ)"
plot 'data' using 1:\
((0.0545 * $13 + 1.8 * $14 + 20.0 * $15 + 17.7 * $16 + 4.6 * $17) / 4096) \
title "Red LED" with filledcurves x1, \
'data' using 1:\
((0.0545 * $13 + 1.8 * $14 + 20.0 * $15 + 17.7 * $16) / 4096) \
title "Radio TX" with filledcurves x1, \
'data' using 1:\
((0.0545 * $13 + 1.8 * $14 + 20.0 * $15) / 4096) \
title "Radio listen" with filledcurves x1, \
'data' using 1:\
((0.0545 * $13 + 1.8 * $14) / 4096) \
title "CPU active" with filledcurves x1, \
'data' using 1:\
((0.0545 * $13) / 4096) \
title "CPU LPM" with filledcurves x1
set output "plot-temperature.eps"
set ylabel "Temperature (degrees Celcius)"
plot [:] [-10:30] \
'data' using 1:(-39.60 + 0.01*$7) title "Temperature"
set output "plot-humidity.eps"
set ylabel "Humidity"
plot [:] [0:100] \
'data' using 1:(-4 + 0.0405*$8 - 2.8e-6*($8*$8)) title "Humidity"
set output "plot-sensors.eps"
set ylabel "Sensed value"
plot [:] [-10:200] \
'data' using 1:(0.625 * 1000000 * 0.5 * $5/4096 / 100000 * 1000) title "Light 1", \
'data' using 1:(0.769 * 100000 * 2.5 * $6/4096 / 100000 * 1000) title "Light 2", \
'data' using 1:(-39.60 + 0.01*$7) title "Temperature", \
'data' using 1:(-4 + 0.0405*$8 - 2.8e-6*($8*$8)) title "Humidity"
set output "plot-light.eps"
set ylabel "Light"
plot [:] [0:] \
'data' using 1:(0.625 * 1000000 * 0.5 * $5/4096 / 100000 * 1000) title "Light 1", \
'data' using 1:(0.769 * 100000 * 2.5 * $6/4096 / 100000 * 1000) title "Light 2"
set output "plot-ll-errors.eps"
set ylabel "Errors per packet"
plot [:] [0:1] \
'data' using 1:($31 / $33) title "contentiondrop per tx", \
'data' using 1:($32 / $33) title "sendingdrop per tx", \
'data' using 1:($27 / $34) title "toolong per rx",\
'data' using 1:($28 / $34)title "tooshort per rx",\
'data' using 1:($29 / $34) title "badsynch per rx",\
'data' using 1:($30 / $34) title "badcrc per rx"
set output "plot-parent.eps"
set ylabel "Node ID"
plot [:] [0:100] \
'data' using 1:10 title "Best parent" with points
set output "plot-rtmetric.eps"
set ylabel "Routing metric"
plot [:] [0:] \
'data' using 1:(($11 + $12) / 16) title "Routing metric" with steps, \
'data' using 1:(($11) / 16) title "ETX to best neighbor" with steps, \
'data' using 1:(($12) / 16) title "Rtmetric for best neighbor" with steps, \
'lost' using 1:($2 * 0.5) title "Lost packet" with points
set output "plot-rtx-stats.eps"
set ylabel "Ratio"
plot \
'data' using 1:($20 / $18) title "reliabletx per tx",\
'data' using 1:($21 / $19) title "reliablerx per rx",\
'data' using 1:($22 / $20) title "rexmit per rtx",\
'data' using 1:($23 / $21) title "acktx per rrx",\
'data' using 1:($24 / $21) title "noacktx per rrx",\
'data' using 1:($25 / $20) title "timedout per rtx",\
'data' using 1:($26 / $20) title "badackrx per rtx"
set output "plot-seqno.eps"
set ylabel "Sequence number"
plot [:] [0:256] \
'data' using 1:3 title "Sequence number" with steps, \
'lost' using 1:($2 * 128) title "Lost" with points, \
'dup' using 1:($2 * 64) title "Duplicate" with points, \
'parent' using 1:2 title "Best parent" with points
set output "plot-hops.eps"
set ylabel "Hops"
plot [:] [-1:5] \
'data' using 1:4 title "Hops" with steps

View file

@ -0,0 +1,25 @@
set terminal postscript eps monochrome font "Helvetica" 16
set output "plot-power.eps"
set title "Average power consumption per node"
set xlabel "Node number"
set ylabel "Power (mW)"
set boxwidth 0.5
set style fill pattern
#set key top left Left width -5
plot [:] [0:] \
'power' using \
2:((0.0545 * $3 + 1.8 * $4 + 20.0 * $5 + 17.7 * $6 + 4.6 * $7) / 4096) * 3 / $1 \
with boxes title "Red LED", \
'power' using \
2:((0.0545 * $3 + 1.8 * $4 + 20.0 * $5 + 17.7 * $6) / 4096) * 3 / $1 \
with boxes title "Radio transmit", \
'power' using \
2:((0.0545 * $3 + 1.8 * $4 + 20.0 * $5) / 4096) * 3 / $1 \
with boxes title "CPU low-power mode", \
'power' using \
2:((1.8 * $4 + 20.0 * $5) / 4096) * 3 / $1 \
with boxes title "CPU active mode", \
'power' using \
2:((20.0 * $5) / 4096) * 3 / $1 \
with boxes title "Radio reception"

View file

@ -0,0 +1,41 @@
#!/usr/bin/perl
while(<>) {
if(/^(\d+) (\d+) (\d+) (\d+)/) {
$time = $1;
if($last_time{$2} != 0 &&
$time - $last_time{$2} > $max_timediff{$2}) {
$max_timediff{$2} = $time - $last_time{$2};
$max_timediff_time{$2} = $time;
}
$last_time{$2} = $time;
$seqno = $3;
if(! defined $first_seqno{$2}) {
$first_seqno{$2} = $seqno;
}
if($seqno < $last_seqno{$2}) {
$seqno_add{$2} += $last_seqno{$2} + 1;
}
if($last_seqno{$2} == $seqno) {
$dup{$2}++;
}
$last_seqno{$2} = $seqno;
$hops{$2} += $4;
$num{$2}++;
}
}
foreach $n (sort {$a <=> $b} keys %hops) {
print "Node $n packets " . ($num{$n} - $dup{$n}) .
" duplicates $dup{$n} dropped " .
((1 + $last_seqno{$n} + $seqno_add{$n} - $first_seqno{$n}) - ($num{$n} - $dup{$n}));
print " ratio ";
printf "%.2f", ($num{$n} - $dup{$n}) / (1 + $last_seqno{$n} + $seqno_add{$n} - $first_seqno{$n});
# print " max timediff " . $max_timediff{$n}/20;
print "\n";
}