r4894 - developers/werner/wlan/freeze
werner at docs.openmoko.org
werner at docs.openmoko.org
Thu Jan 22 22:24:02 CET 2009
Author: werner
Date: 2009-01-22 22:23:59 +0100 (Thu, 22 Jan 2009)
New Revision: 4894
Added:
developers/werner/wlan/freeze/r2ch.py
developers/werner/wlan/freeze/r3ch-plot
Modified:
developers/werner/wlan/freeze/README
Log:
New tools to mine the data for the channels involved.
Modified: developers/werner/wlan/freeze/README
===================================================================
--- developers/werner/wlan/freeze/README 2009-01-22 02:49:42 UTC (rev 4893)
+++ developers/werner/wlan/freeze/README 2009-01-22 21:23:59 UTC (rev 4894)
@@ -116,3 +116,31 @@
- Chains can be sorted by frequency with:
./r1.pl log | ./r2.pl | sort | uniq -c | sort -rn
+
+- r2ch.py counts the number outcome of a channel change as a function of
+ the channels involved.
+
+ ./r1.pl log | ./r2ch.py
+
+ Show for each channel we depart from, channel we enter, and distance of
+ the change the following numbers:
+
+ - channel number or distance
+ - total number of associations
+ - associations to the correct channel
+ - associations to the channel we departed from
+ - associations to a different channel
+ - number of times communication could not be reestablished
+
+ The option -p changes the last four numbers to percents of associations.
+
+- r3ch.plot plots the output of r2ch.py into a PNG file:
+
+ ./r1.pl log | ./r2ch.py -p | ./r3ch-plot DIST
+
+ plots the distribution by association type as a function of the hopping
+ distance. The other results are accessed with the keys FROM and TO.
+
+ By default, the PNG file is displayed with ImageMagick and then discarded.
+ With the option -f, it is written to a file with the name <key>.png or,
+ if the input comes from a file, <name>-<key>.png
Added: developers/werner/wlan/freeze/r2ch.py
===================================================================
--- developers/werner/wlan/freeze/r2ch.py (rev 0)
+++ developers/werner/wlan/freeze/r2ch.py 2009-01-22 21:23:59 UTC (rev 4894)
@@ -0,0 +1,92 @@
+#!/usr/bin/python
+#
+# r2ch.py - reductor #2, channel statistics
+#
+# This reductor takes a normalized session log and extracts statistics on how
+# hopping success relates to old and new channel.
+#
+
+
+from sys import argv, stdin
+
+
+percent = False
+
+
+def stat(frm, to, type):
+ out[frm-1][type] += 1
+ into[to-1][type] += 1
+ if frm > to:
+ dist = frm-to
+ else:
+ dist = to-frm
+ delta[dist][type] += 1
+
+
+def report(v):
+ s = v["ASSOC"]+v["LATE"]+v["WRONG"]
+ if s == 0:
+ print 0, 0, 0, 0
+ return
+ print s,
+ if percent:
+ d = s/100.0
+ else:
+ d = 1
+ print v["ASSOC"]/d, v["LATE"]/d, v["WRONG"]/d, v["TROUBLE"]/d, v["CRASH"]
+
+
+optind = 1
+if len(argv) > 1 and argv[1] == "-p":
+ percent = True
+ optind += 1
+
+into = []
+out = []
+delta = []
+for n in range(0, 11):
+ into.append({})
+ out.append({})
+ delta.append({})
+ for t in ("ASSOC", "LATE", "WRONG", "TROUBLE", "CRASH"):
+ into[n][t] = 0
+ out[n][t] = 0
+ delta[n][t] = 0
+
+if len(argv) > optind:
+ f = open(argv[optind], "r")
+else:
+ f = stdin
+while True:
+ line = f.readline()
+ if line == "":
+ break
+ a = line.split()
+ if a[0] != "STATE":
+ continue
+ if a[1] == "RESET":
+ hop = None
+ hop2 = None
+ elif a[1] == "ROUND":
+ hop = None
+ hop2 = None
+ elif a[1] == "HOP":
+ hop = (int(a[2]), int(a[4]))
+ hop2 = (int(a[2]), int(a[4]))
+ elif a[1] == "ASSOC" or a[1] == "LATE" or a[1] == "WRONG":
+ if hop is not None:
+ stat(hop[0], hop[1], a[1])
+ hop = None
+ elif a[1] == "TROUBLE" or a[1] == "CRASH":
+ if hop2 is not None:
+ stat(hop2[0], hop2[1], a[1])
+
+for n in range(0, 11):
+ print "FROM", n+1,
+ report(out[n])
+for n in range(0, 11):
+ print "TO", n+1,
+ report(into[n])
+for n in range(1, 10):
+ print "DIST", n,
+ report(delta[n])
Property changes on: developers/werner/wlan/freeze/r2ch.py
___________________________________________________________________
Name: svn:executable
+ *
Added: developers/werner/wlan/freeze/r3ch-plot
===================================================================
--- developers/werner/wlan/freeze/r3ch-plot (rev 0)
+++ developers/werner/wlan/freeze/r3ch-plot 2009-01-22 21:23:59 UTC (rev 4894)
@@ -0,0 +1,22 @@
+#!/bin/sh
+if [ "$1" = -f ]; then
+ shift
+ if [ -z "$2" ]; then
+ out="set output \"$1.png\""
+ else
+ out="set output \"`basename $2`-$1.png\""
+ fi
+else
+ out='set output "| display png:-"'
+fi
+gnuplot <<EOF
+set terminal png
+$out
+set style data linespoints
+set title "$1"
+plot "<sed '/^$1 /s///p;d' $2" using 1:3 lw 2 title "assoc", \
+ "<sed '/^$1 /s///p;d' $2" using 1:4 lw 2 title "late", \
+ "<sed '/^$1 /s///p;d' $2" using 1:5 lw 2 title "wrong", \
+ "<sed '/^$1 /s///p;d' $2" using 1:6 lw 2 title "trouble", \
+ "<sed '/^$1 /s///p;d' $2" using 1:7 lw 2 title "crash"
+EOF
More information about the commitlog
mailing list