Testing and fixing YourThings scripts for negative experiments.
[pingpong.git] / Code / Projects / PacketLevelSignatureExtractor / execute_layer2_yourthings_all_detection.sh
1 #!/bin/bash
2
3 # Arg1 should point to the folder with YourThings traces (PCAP files w/o any expected events).
4 # There are 3 overlap devices:
5 # 1) Belkin WeMo switch: https://yourthings.info/devices/belkin_switch.html
6 # 2) Roomba iRobot 690: https://yourthings.info/devices/roomba.html
7 # 3) TP-Link Bulb LB130: https://yourthings.info/devices/tplink_bulb.html
8 YT_TRACES_DIR=$1
9
10 # Arg2 should point to the base directory  for signature files (i.e., /some/local/path/experimental_result/standalone)
11 SIGNATURES_BASE_DIR=$2
12 readonly SIGNATURES_BASE_DIR
13
14 # Arg3 should point to base directory where the detection results for the UNSW trace are to be output.
15 # Subfolders will be created for each individual pcap file in YT_TRACES_DIR.
16 OUTPUT_DIR=$3
17 readonly OUTPUT_DIR
18
19 #set -x # echo invoked commands to std out
20
21 # Download and untar the public data set https://yourthings.info/data/
22 # Then everything should be untarred/unzipped into /.../2018/
23 # YT_TRACES_DIR path should be something like /.../2018/
24 # Then there are subfolders inside 2018/ such as 2018/03/20/
25 for SUBFOLDER1 in $YT_TRACES_DIR/*; do
26         for SUBFOLDER2 in $SUBFOLDER1/*; do
27                 for PCAP_FILE in $SUBFOLDER2/*; do
28             # skip non pcap files
29             [ -e "$PCAP_FILE" ] || continue
30             # make an output sub dir in the base output dir that is the filename minus extension
31             OUTPUT_SUB_DIR=$(basename "$PCAP_FILE" .pcap)
32             ./execute_layer2_unb_all_detection.sh $PCAP_FILE $SIGNATURES_BASE_DIR $OUTPUT_DIR/$OUTPUT_SUB_DIR
33                 done
34         done
35 done