doc: add a gnuplot file to show the smart gateway cost calculation
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 30 Jan 2014 13:32:22 +0000 (14:32 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 30 Jan 2014 13:56:49 +0000 (14:56 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
doc/SmartGateway/.gitignore [new file with mode: 0644]
doc/SmartGateway/SmartGatewayCost.gnuplot [new file with mode: 0644]
doc/SmartGateway/watchAndPlot.bash [new file with mode: 0755]

diff --git a/doc/SmartGateway/.gitignore b/doc/SmartGateway/.gitignore
new file mode 100644 (file)
index 0000000..d8c3b27
--- /dev/null
@@ -0,0 +1 @@
+/*.svg
diff --git a/doc/SmartGateway/SmartGatewayCost.gnuplot b/doc/SmartGateway/SmartGatewayCost.gnuplot
new file mode 100644 (file)
index 0000000..5168c0d
--- /dev/null
@@ -0,0 +1,42 @@
+sizex=1920
+sizey=1080
+
+set terminal svg dynamic enhanced fname 'Helvetica' fsize 16 mousing name "SmartGatewayCost" butt solid size sizex,sizey
+set output 'SmartGatewayCost.svg'
+
+set grid xtics lt 0 lw 1 lc rgb "#bbbbbb"
+set grid ytics lt 0 lw 1 lc rgb "#bbbbbb"
+set grid ztics lt 0 lw 1 lc rgb "#bbbbbb"
+
+set dummy x,y
+set isosamples 100, 100
+
+
+set title "Smart Gateway Cost (Symmetric Link)" 
+
+#                     WexitU   WexitD   Wetx
+# path_cost_weight =  ------ + ------ + ---- * path_cost
+#                     exitUm   exitDm   Detx
+
+WexitU=1.0
+WexitD=1.0
+Wetx=1.0
+Detx=4096.0
+
+set xlabel "Uplink / Downlink (Mbps)" 
+xlow=0.0
+xhigh=1.0
+set xlabel  offset character 0, 0, 0 font "Helvetica" textcolor lt -1 norotate
+set xrange [ xlow : xhigh ] noreverse nowriteback
+
+set ylabel "Path Cost ( = ETX * 1024 )"
+ylow=1000.0
+yhigh=10000.0
+set ylabel  offset character 0, 0, 0 font "Helvetica" textcolor lt -1 rotate by -270
+set yrange [ ylow : yhigh ] noreverse nowriteback
+
+
+set zlabel "Costs" 
+set zlabel  offset character -2, 0, 0 font "" textcolor lt -1 norotate
+
+splot (WexitU/x)+(WexitD/x)+((Wetx/Detx)*y)
diff --git a/doc/SmartGateway/watchAndPlot.bash b/doc/SmartGateway/watchAndPlot.bash
new file mode 100755 (executable)
index 0000000..da05038
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+set -e
+set -u
+
+ifsOld="$IFS"
+IFS=$'\n'
+gnuplotfiles=( $(ls -1 *.gnuplot | sort) )
+IFS="$ifsOld"
+gnuplotfilestimes=()
+
+# init time stamps
+declare -i index=0
+while [[ $index -lt ${#gnuplotfiles[*]} ]]; do
+  gnuplotfilestimes[$index]=1
+  index+=1
+done
+
+
+declare -i tim=0
+while true; do
+  index=0
+  while [[ $index -lt ${#gnuplotfiles[*]} ]]; do
+    tim=$(stat -c "%Y" "${gnuplotfiles[index]}")
+    if [[ $tim -ne ${gnuplotfilestimes[index]} ]]; then
+      gnuplot "${gnuplotfiles[index]}"
+      gnuplotfilestimes[$index]=$tim
+    fi
+    index+=1
+  done
+  sleep 1
+done