Completing flow for time series graph generation
authorrtrimana <rtrimana@uci.edu>
Tue, 7 Nov 2017 22:26:17 +0000 (14:26 -0800)
committerrtrimana <rtrimana@uci.edu>
Tue, 7 Nov 2017 22:26:17 +0000 (14:26 -0800)
README.md
parser/parse_packet_frequency.py
plot_scripts/plot_graph [new file with mode: 0644]
run_scripts/ts_analysis_run.sh [new file with mode: 0755]
ts_analysis_run.sh [deleted file]

index 5a93e6a50cde0bdcbf85fe9269abbbf9f935bac8..52a18c1fafb96d5399cb398a5157155abc258f88 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,4 +1,17 @@
 # smart_home_traffic
 # smart_home_traffic
-This repository will be used to store scripts for analyzing smart home traffic.
+Some useful information:
+
+1) This repository will be used to store scripts for analyzing smart home traffic.
+
+2) Please run the Python scripts from the top level directory (smart_home_traffic) where this README.md is located, NOT from inside the subdirectory.
+
+3) Please run automation scripts from inside the folder, i.e. run_scripts.
+
+4) Please run graph plotting scripts from inside the folder, i.e. plot_scripts.
+
+    - Go into plot_scripts directory
+    
+    - Run 'gnuplot'
+    
+    - Run 'load "plot_graph"'
 
 
-Please run the scripts from the top level directory (smart_home_traffic) where this README.md is located, NOT from inside the subdirectory.
index afd5b1c9d0b7bc6895c060e8f969f2e223207270..9520298a28aed1ae925655656380561220732108 100644 (file)
@@ -39,6 +39,9 @@ def save_to_file(tbl_header, dictionary, filename_out):
         #f.write(str(key) + ", " + str(dictionary[key]) + "\n")
         # Space separated
         f.write(str(key) + " " + str(dictionary[key]) + "\n")
         #f.write(str(key) + ", " + str(dictionary[key]) + "\n")
         # Space separated
         f.write(str(key) + " " + str(dictionary[key]) + "\n")
+    # Write "0 0" if dictionary is empty
+    if not dictionary:
+        f.write("0 0");
 
     f.close()
     print "Writing output to file: ", filename_out
 
     f.close()
     print "Writing output to file: ", filename_out
diff --git a/plot_scripts/plot_graph b/plot_scripts/plot_graph
new file mode 100644 (file)
index 0000000..12f2065
--- /dev/null
@@ -0,0 +1,150 @@
+# Script to plot time series graphs for network traffic analysis
+#
+# by Rahmadi Trimananda (rahmadi.trimananda@uci.edu)
+# Programming Language Research Group @ University of California, Irvine
+# Fall 2017
+
+# ************ #
+# BASIC SETUP  #
+# ************ #
+#set terminal postscript landscape "Arial, 18"
+#set terminal postscript eps font 'Helvetica,20' enhanced color 
+set terminal pngcairo enhanced font 'Verdana,10'
+set autoscale
+unset key
+unset log
+unset label
+set xtics 600
+set ytics auto
+set xlabel "Packet Timestamp (hh:mm:ss)"
+set ylabel "Packet Frequency (pps)"
+set xdata time
+set timefmt "%H:%M:%S"
+#set xrange ["06:00:00":"10:00:00"]
+#set yrange [0:200]
+set xrange [:]
+set yrange [0:]
+
+# ***************** #
+# PER DEVICE SETUP  #
+# ***************** #
+# WeMo switch
+#set output 'wemo_switch.ps'
+#set output 'wemo_switch.eps'
+set output '../result/wemo_switch.png'
+set title "WeMo Switch Time Series Plot of Packets"
+plot "../result/wemo_switch.dat" using 1:2 with lines
+
+#set output 'wemo_switch2.ps'
+#plot "wemo_switch.dat" using 1:2
+
+# WeMo switch
+#set output '../result/wemo_switch.ps'
+#set output '../result/wemo_switch.eps'
+set output '../result/wemo_switch.png'
+set title "WeMo Switch"
+plot "../result/wemo_switch.dat" using 1:2 with lines
+
+# WeMo Insight
+#set output '../result/wemo_insight.eps'
+set output '../result/wemo_insight.png'
+set title "WeMo Insight"
+plot "../result/wemo_insight.dat" using 1:2 with lines
+
+# TP-Link switch
+#set output '../result/tplink_switch.eps'
+set output '../result/tplink_switch.png'
+set title "TP-Link Switch"
+plot "../result/tplink_switch.dat" using 1:2 with lines
+
+# D-Link switch
+#set output '../result/dlink_switch.eps'
+set output '../result/dlink_switch.png'
+set title "D-Link Switch"
+plot "../result/dlink_switch.dat" using 1:2 with lines
+
+# Amcrest camera
+#set output '../result/amcrest_camera.eps'
+set output '../result/amcrest_camera.png'
+set title "Amcrest Camera"
+plot "../result/amcrest_camera.dat" using 1:2 with lines
+
+# Netgear Arlo camera
+#set output '../result/netgear_arlo_camera.eps'
+set output '../result/netgear_arlo_camera.png'
+set title "Netgear Arlo Camera"
+plot "../result/netgear_arlo_camera.dat" using 1:2 with lines
+
+# LiFX light bulb
+#set output '../result/lifx_lightbulb_1.eps'
+set output '../result/lifx_lightbulb_1.png'
+set title "LiFX Light Bulb #1"
+plot "../result/lifx_lightbulb_1.dat" using 1:2 with lines
+
+# LiFX light bulb
+#set output '../result/lifx_lightbulb_2.eps'
+set output '../result/lifx_lightbulb_2.png'
+set title "LiFX Light Bulb #2"
+plot "../result/lifx_lightbulb_2.dat" using 1:2 with lines
+
+# Philips Hue
+#set output '../result/philips_hue.eps'
+set output '../result/philips_hue.png'
+set title "Philips Hue"
+plot "../result/philips_hue.dat" using 1:2 with lines
+
+# TP-Link Light Bulb
+#set output '../result/tplink_lightbulb.eps'
+set output '../result/tplink_lightbulb.png'
+set title "TP-Link Light Bulb"
+plot "../result/tplink_lightbulb.dat" using 1:2 with lines
+
+# Nxeco sprinkler
+#set output '../result/nxeco_sprinkler.eps'
+set output '../result/nxeco_sprinkler.png'
+set title "Nxeco Sprinkler"
+plot "../result/nxeco_sprinkler.dat" using 1:2 with lines
+
+# Blossom sprinkler
+#set output '../result/blossom_sprinkler.eps'
+set output '../result/blossom_sprinkler.png'
+set title "Blossom Sprinkler"
+plot "../result/blossom_sprinkler.dat" using 1:2 with lines
+
+# D-Link alarm
+#set output '../result/dlink_alarm.eps'
+set output '../result/dlink_alarm.png'
+set title "D-Link Alarm"
+plot "../result/dlink_alarm.dat" using 1:2 with lines
+
+# D-Link alarm
+#set output '../result/dlink_alarm.eps'
+set output '../result/dlink_alarm.png'
+set title "D-Link Alarm"
+plot "../result/dlink_alarm.dat" using 1:2 with lines
+
+# D-Link motion sensor
+#set output '../result/dlink_motion_sensor.eps'
+set output '../result/dlink_motion_sensor.png'
+set title "D-Link Motion Sensor"
+plot "../result/dlink_motion_sensor.dat" using 1:2 with lines
+
+# Nest Thermostat
+#set output '../result/nest_thermostat.eps'
+set output '../result/nest_thermostat.png'
+set title "Nest Thermostat"
+plot "../result/nest_thermostat.dat" using 1:2 with lines
+
+# Amazon Echo Dot
+#set output '../result/amazon_echo_dot.eps'
+set output '../result/amazon_echo_dot.png'
+set title "Amazon Ech Odit"
+plot "../result/amazon_echo_dot.dat" using 1:2 with lines
+
+# SmartThings hub
+#set output '../result/smartthings_hub.eps'
+set output '../result/smartthings_hub.png'
+set title "SmartThings Hub"
+plot "../result/smartthings_hub.dat" using 1:2 with lines
+
+
diff --git a/run_scripts/ts_analysis_run.sh b/run_scripts/ts_analysis_run.sh
new file mode 100755 (executable)
index 0000000..a1fc157
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# Check input arguments - we need 2 arguments
+if [ $# -ne 2 ]
+    then
+        echo "Usage: ts_analysis_run.sh <path-and-json-file, e.g./a/b/c/d.json> <path-to-output-file, e.g. result/>"
+        exit 1
+fi
+
+# Check result folder and create one if it does not exist yet
+[ -d $2 ] || mkdir $2
+
+# Run the analysis
+python ../parser/parse_packet_frequency.py $1 $2/wemo_switch.dat WeMo_Switch 94:10:3e:36:60:09
+python ../parser/parse_packet_frequency.py $1 $2/wemo_insight.dat WeMo_Insight 14:91:82:25:10:77
+python ../parser/parse_packet_frequency.py $1 $2/tplink_switch.dat TPLink_Switch 50:c7:bf:33:1f:09
+python ../parser/parse_packet_frequency.py $1 $2/dlink_switch.dat DLink_Switch 90:8d:78:e3:81:0c
+python ../parser/parse_packet_frequency.py $1 $2/amcrest_camera.dat Amcrest_Camera 3c:ef:8c:6f:79:5a
+python ../parser/parse_packet_frequency.py $1 $2/netgear_arlo_camera.dat Netgear_Arlo_Camera 40:5d:82:2f:50:2a
+python ../parser/parse_packet_frequency.py $1 $2/lifx_lightbulb_1.dat Lifx_LightBulb_1 d0:73:d5:12:8e:30
+python ../parser/parse_packet_frequency.py $1 $2/lifx_lightbulb_2.dat Lifx_LightBulb_2 d0:73:d5:02:41:da
+python ../parser/parse_packet_frequency.py $1 $2/philips_hue.dat Philips_Hue 00:17:88:69:ee:e4
+python ../parser/parse_packet_frequency.py $1 $2/tplink_lightbulb.dat TPLink_LightBulb 50:c7:bf:59:d5:84
+python ../parser/parse_packet_frequency.py $1 $2/nxeco_sprinkler.dat Nxeco_Sprinkler ac:cf:23:5a:9c:e2
+python ../parser/parse_packet_frequency.py $1 $2/blossom_sprinkler.dat Blossom_Sprinkler e4:95:6e:b0:20:39
+python ../parser/parse_packet_frequency.py $1 $2/dlink_alarm.dat DLink_Alarm c4:12:f5:de:38:20
+python ../parser/parse_packet_frequency.py $1 $2/dlink_motion_sensor.dat DLink_Motion_Sensor c4:12:f5:e3:dc:17
+python ../parser/parse_packet_frequency.py $1 $2/nest_thermostat.dat Nest_Thermostat 18:b4:30:bf:34:7e
+python ../parser/parse_packet_frequency.py $1 $2/amazon_echo_dot.dat Amazon_Echo_Dot 68:37:e9:d2:26:0d
+python ../parser/parse_packet_frequency.py $1 $2/smartthings_hub.dat SmartThings_Hub d0:52:a8:a3:60:0f
+
diff --git a/ts_analysis_run.sh b/ts_analysis_run.sh
deleted file mode 100755 (executable)
index 9cb9435..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-# Check input arguments - we need 2 arguments
-if [ $# -ne 2 ]
-    then
-        echo "Usage: ts_analysis_run.sh <path-and-json-file, e.g./a/b/c/d.json> <path-to-output-file, e.g. result/>"
-        exit 1
-fi
-
-# Check result folder and create one if it does not exist yet
-[ -d $2 ] || mkdir $2
-
-# Run the analysis
-python parser/parse_packet_frequency.py $1 $2/wemo_switch.dat WeMo_Switch 94:10:3e:36:60:09
-python parser/parse_packet_frequency.py $1 $2/wemo_insight.dat WeMo_Insight 14:91:82:25:10:77
-python parser/parse_packet_frequency.py $1 $2/tplink_switch.dat TPLink_Switch 50:c7:bf:33:1f:09
-python parser/parse_packet_frequency.py $1 $2/dlink_switch.dat DLink_Switch 90:8d:78:e3:81:0c
-python parser/parse_packet_frequency.py $1 $2/amcrest_camera.dat Amcrest_Camera 3c:ef:8c:6f:79:5a
-python parser/parse_packet_frequency.py $1 $2/netgear_arlo_camera.dat Netgear_Arlo_Camera 40:5d:82:2f:50:2a
-python parser/parse_packet_frequency.py $1 $2/lifx_lightbulb_1.dat Lifx_LightBulb_1 d0:73:d5:12:8e:30
-python parser/parse_packet_frequency.py $1 $2/lifx_lightbulb_2.dat Lifx_LightBulb_2 d0:73:d5:02:41:da
-python parser/parse_packet_frequency.py $1 $2/philips_hue.dat Philips_Hue 00:17:88:69:ee:e4
-python parser/parse_packet_frequency.py $1 $2/tplink_lightbulb.dat TPLink_LightBulb 50:c7:bf:59:d5:84
-python parser/parse_packet_frequency.py $1 $2/nxeco_sprinkler.dat Nxeco_Sprinkler ac:cf:23:5a:9c:e2
-python parser/parse_packet_frequency.py $1 $2/blossom_sprinkler.dat Blossom_Sprinkler e4:95:6e:b0:20:39
-python parser/parse_packet_frequency.py $1 $2/dlink_alarm.dat DLink_Alarm c4:12:f5:de:38:20
-python parser/parse_packet_frequency.py $1 $2/dlink_motion_sensor.dat DLink_Motion_Sensor c4:12:f5:e3:dc:17
-python parser/parse_packet_frequency.py $1 $2/nest_thermostat.dat Nest_Thermostat 18:b4:30:bf:34:7e
-python parser/parse_packet_frequency.py $1 $2/amazon_echo_dot.dat Amazon_Echo_Dot 68:37:e9:d2:26:0d
-python parser/parse_packet_frequency.py $1 $2/smartthings_hub.dat SmartThings_Hub d0:52:a8:a3:60:0f
-