Temporary fix for router's IP as client for WAN trace and paths for new tests for...
authorrtrimana <rtrimana@uci.edu>
Fri, 2 Nov 2018 23:05:14 +0000 (16:05 -0700)
committerrtrimana <rtrimana@uci.edu>
Fri, 2 Nov 2018 23:05:14 +0000 (16:05 -0700)
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Conversation.java
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/TcpReassembler.java
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/detection/SignatureDetector.java
python_ml/validate-detection.py

index a998c17..490dc4f 100644 (file)
@@ -484,7 +484,7 @@ public class Conversation {
          * 08/31/18: Added unconvetional TLS ports used by WeMo plugs and LiFX bulb.
          * 09/20/18: Moved hardcoded ports to other class to allow other classes to query the set of TLS ports.
          */
-        return TcpConversationUtils.isTlsPort(mServerPort) || TcpConversationUtils.isTlsPort(mClientPort);
+        return TcpConversationUtils.isTlsPort(mServerPort);
     }
 
     /**
index 4d0ead2..598cc99 100644 (file)
@@ -84,16 +84,16 @@ public class Main {
 //        final String triggerTimesFile = path + "/2018-07/stplug/smartthings-july-25-2018.timestamps";
 //        final String deviceIp = "192.168.1.246"; // .246 == phone; .142 == SmartThings Hub (note: use eth0 capture for this!)
         // October 18
-        final String inputPcapFile = path + "/2018-10/st-plug/st-plug.wlan1.local.pcap";
-        final String outputPcapFile = path + "/2018-10/st-plug/st-plug-processed.pcap";
-        final String triggerTimesFile = path + "/2018-10/st-plug/st-plug-oct-18-2018.timestamps";
-        final String deviceIp = "192.168.1.246"; // .246 == phone; .142 == SmartThings Hub (note: use eth0 capture for this!)
+//        final String inputPcapFile = path + "/2018-10/st-plug/st-plug.wlan1.local.pcap";
+//        final String outputPcapFile = path + "/2018-10/st-plug/st-plug-processed.pcap";
+//        final String triggerTimesFile = path + "/2018-10/st-plug/st-plug-oct-18-2018.timestamps";
+//        final String deviceIp = "192.168.1.246"; // .246 == phone; .142 == SmartThings Hub (note: use eth0 capture for this!)
 
         // 4) Wemo July 30 experiment
 //        final String inputPcapFile = path + "/2018-07/wemo/wemo.wlan1.local.pcap";
 //        final String outputPcapFile = path + "/2018-07/wemo/wemo-processed.pcap";
 //        final String triggerTimesFile = path + "/2018-07/wemo/wemo-july-30-2018.timestamps";
-//        final String deviceIp = "192.168.1.145";
+//        final String deviceIp = "192.168.1.145";  // .246 == phone; .145 == WeMo
 
         // 5) Wemo Insight July 31 experiment
 //        final String inputPcapFile = path + "/2018-07/wemoinsight/wemoinsight.wlan1.local.pcap";
@@ -105,7 +105,7 @@ public class Main {
 //        final String inputPcapFile = path + "/2018-08/tplink-bulb/tplinkbulb.wlan1.local.pcap";
 //        final String outputPcapFile = path + "/2018-08/tplink-bulb/tplinkbulb-processed.pcap";
 //        final String triggerTimesFile = path + "/2018-08/tplink-bulb/tplink-bulb-aug-3-2018.timestamps";
-//        final String deviceIp = "192.168.1.140"; // .246 == phone; .140 == TP-Link bulb
+//        final String deviceIp = "192.168.1.246"; // .246 == phone; .140 == TP-Link bulb
 
         // 7) Kwikset Doorlock August 6 experiment
 //        final String inputPcapFile = path + "/2018-08/kwikset-doorlock/kwikset-doorlock.data.wlan1.pcap";
@@ -128,16 +128,26 @@ public class Main {
 //        final String triggerTimesFile = path + "/2018-08/hue-bulb/hue-bulb-aug-7-2018.timestamps";
 //        final String deviceIp = "192.168.1.246";
         // October 30 experiment
-//        final String inputPcapFile = path + "/2018-10/hue-bulb/hue-bulb.eth1.local.pcap";
+//        final String inputPcapFile = path + "/2018-10/hue-bulb/hue-bulb.wlan1.local.pcap";
 //        final String outputPcapFile = path + "/2018-10/hue-bulb/hue-bulb-processed.pcap";
 //        final String triggerTimesFile = path + "/2018-10/hue-bulb/hue-bulb-oct-30-2018.timestamps";
-//        final String deviceIp = "192.168.1.100"; // .246 == phone; .100 == Hue hub
+//        final String deviceIp = "192.168.1.246"; // .246 == phone; .100 == Hue hub
 
         // 9) Lifx Bulb August 8 experiment
 //        final String inputPcapFile = path + "/2018-08/lifx-bulb/lifx-bulb.wlan1.local.pcap";
 //        final String outputPcapFile = path + "/2018-08/lifx-bulb/lifx-bulb-processed.pcap";
 //        final String triggerTimesFile = path + "/2018-08/lifx-bulb/lifx-bulb-aug-8-2018.timestamps";
 //        final String deviceIp = "192.168.1.246"; // .246 == phone; .231 == Lifx
+        // October 18
+//        final String inputPcapFile = path + "/2018-10/lifx-bulb/lifx-bulb.wlan1.local.pcap";
+//        final String outputPcapFile = path + "/2018-10/lifx-bulb/lifx-bulb-processed.pcap";
+//        final String triggerTimesFile = path + "/2018-10/lifx-bulb/lifx-bulb-oct-18-2018.timestamps";
+//        final String deviceIp = "192.168.1.231"; // .246 == phone; .231 == Lifx
+        // November 1
+        final String inputPcapFile = path + "/2018-10/lifx-bulb/lifx-bulb.wlan1.local.pcap";
+        final String outputPcapFile = path + "/2018-10/lifx-bulb/lifx-bulb-processed.pcap";
+        final String triggerTimesFile = path + "/2018-10/lifx-bulb/lifx-bulb-nov-1-2018.timestamps";
+        final String deviceIp = "192.168.1.231"; // .246 == phone; .231 == Lifx
 
         // 10) Amcrest Camera August 9 experiment
 //        final String inputPcapFile = path + "/2018-08/amcrest-camera/amcrest-camera.wlan1.local.pcap";
index 70c096a..8c91c82 100644 (file)
@@ -227,7 +227,8 @@ public class TcpReassembler implements PacketListener {
                 // We can check if the IP prefix matches a local IP when handling traffic observed inside the local
                 // network, but that obviously won't be a useful strategy for an observer at the WAN port.
                 String srcIp = pcapPacket.get(IpV4Packet.class).getHeader().getSrcAddr().getHostAddress();
-                boolean clientIsSrc = srcIp.startsWith("10.0.1.") || srcIp.startsWith("192.168.1.");
+                // TODO: REPLACE THE ROUTER'S IP WITH A PARAMETER!!!
+                boolean clientIsSrc = srcIp.startsWith("10.0.1.") || srcIp.startsWith("192.168.1.") || srcIp.equals("128.195.205.105");
                 conv = Conversation.fromPcapPacket(pcapPacket, clientIsSrc);
             }
             mOpenConversations.put(conv, conv);
index f67a832..d21e6d1 100644 (file)
@@ -46,10 +46,10 @@ public class SignatureDetector implements PacketListener, ClusterMatcher.Cluster
 
         // Kwikset Doorlock Sep 12 experiment
 //        final String inputPcapFile = path + "/evaluation/kwikset-doorlock/kwikset-doorlock.data.wlan1.pcap";
-//        //final String inputPcapFile = path + "/evaluation/kwikset-doorlock/kwikset-doorlock.data.eth0.pcap";
-////        // Kwikset Doorlock PHONE signatures
-//        final String onSignatureFile = path + "/2018-08/kwikset-doorlock/onSignature-Kwikset-Doorlock-phone-new.sig";
-//        final String offSignatureFile = path + "/2018-08/kwikset-doorlock/offSignature-Kwikset-Doorlock-phone-new.sig";
+        final String inputPcapFile = path + "/evaluation/kwikset-doorlock/kwikset-doorlock.data.eth0.pcap";
+//        // Kwikset Doorlock PHONE signatures
+        final String onSignatureFile = path + "/2018-08/kwikset-doorlock/onSignature-Kwikset-Doorlock-phone-new.sig";
+        final String offSignatureFile = path + "/2018-08/kwikset-doorlock/offSignature-Kwikset-Doorlock-phone-new.sig";
 
         // D-Link Plug experiment
         //final String inputPcapFile = path + "/evaluation/dlink/dlink-plug.data.wlan1.pcap";
@@ -64,6 +64,7 @@ public class SignatureDetector implements PacketListener, ClusterMatcher.Cluster
 
 
         // TODO: The following are tests for signatures against training data
+
         /*
         // D-Link Plug experiment
         final String inputPcapFile = path + "/training/dlink-plug/wlan1/dlink-plug.wlan1.local.pcap";
@@ -90,10 +91,10 @@ public class SignatureDetector implements PacketListener, ClusterMatcher.Cluster
 //        final String offSignatureFile = path + "/training/arlo-camera/signatures/arlo-camera-offSignature-phone-side.sig";
 
         // Amazon Alexa experiment
-        final String inputPcapFile = path + "/training/amazon-alexa/wlan1/alexa2.wlan1.local.pcap";
-        // TP-Link Plug DEVICE signatures
-        final String onSignatureFile = path + "/training/amazon-alexa/signatures/amazon-alexa-onSignature-device-side.sig";
-        final String offSignatureFile = path + "/training/amazon-alexa/signatures/amazon-alexa-offSignature-device-side.sig";
+//        final String inputPcapFile = path + "/training/amazon-alexa/wlan1/alexa2.wlan1.local.pcap";
+//        // TP-Link Plug DEVICE signatures
+//        final String onSignatureFile = path + "/training/amazon-alexa/signatures/amazon-alexa-onSignature-device-side.sig";
+//        final String offSignatureFile = path + "/training/amazon-alexa/signatures/amazon-alexa-offSignature-device-side.sig";
 
         // SmartThings Plug experiment
 //        final String inputPcapFile = path + "/training/st-plug/wlan1/st-plug.wlan1.local.pcap";
@@ -105,6 +106,68 @@ public class SignatureDetector implements PacketListener, ClusterMatcher.Cluster
 //        final String offSignatureFile = path + "/training/st-plug/signatures/st-plug-offSignature-phone-side.sig";
 
 
+        // LiFX Bulb experiment
+//        final String inputPcapFile = path + "/training/lifx-bulb/wlan1/lifx-bulb.wlan1.local.pcap";
+//        // LiFX Bulb DEVICE signatures
+//        final String onSignatureFile = path + "/training/lifx-bulb/signatures/lifx-bulb-onSignature-device-side.sig";
+//        final String offSignatureFile = path + "/training/lifx-bulb/signatures/lifx-bulb-offSignature-device-side.sig";
+        // LiFX Bulb PHONE signatures
+//        final String onSignatureFile = path + "/training/lifx-bulb/signatures/lifx-bulb-onSignature-phone-side.sig";
+//        final String offSignatureFile = path + "/training/lifx-bulb/signatures/lifx-bulb-offSignature-phone-side.sig";
+
+
+        /*
+        // Blossom Sprinkler experiment
+        final String inputPcapFile = path + "/training/blossom-sprinkler/wlan1/blossom-sprinkler.wlan1.local.pcap";
+        // Blossom Sprinkler DEVICE signatures
+        final String onSignatureFile = path + "/training/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-device-side.sig";
+        final String offSignatureFile = path + "/training/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-device-side.sig";
+        */
+
+
+        /*
+        // Nest Thermostat experiment
+        final String inputPcapFile = path + "/training/nest-thermostat/wlan1/nest-thermostat.wlan1.local.pcap";
+        // Nest Thermostat DEVICE signatures
+//        final String onSignatureFile = path + "/training/nest-thermostat/signatures/nest-thermostat-onSignature-device-side.sig";
+//        final String offSignatureFile = path + "/training/nest-thermostat/signatures/nest-thermostat-offSignature-device-side.sig";
+        // Nest Thermostat PHONE signatures
+        final String onSignatureFile = path + "/training/nest-thermostat/signatures/nest-thermostat-onSignature-phone-side.sig";
+        final String offSignatureFile = path + "/training/nest-thermostat/signatures/nest-thermostat-offSignature-phone-side.sig";
+        */
+
+        /*
+        // Hue Bulb experiment
+        final String inputPcapFile = path + "/training/hue-bulb/wlan1/hue-bulb.wlan1.local.pcap";
+        // Hue Bulb PHONE signatures
+        final String onSignatureFile = path + "/training/hue-bulb/signatures/hue-bulb-onSignature-phone-side.sig";
+        final String offSignatureFile = path + "/training/hue-bulb/signatures/hue-bulb-offSignature-phone-side.sig";
+        */
+
+        /*
+        // TP-Link Bulb experiment
+        final String inputPcapFile = path + "/training/tplink-bulb/wlan1/tplink-bulb.wlan1.local.pcap";
+        // TP-Link Bulb PHONE signatures
+        final String onSignatureFile = path + "/training/tplink-bulb/signatures/tplink-bulb-onSignature-phone-side.sig";
+        final String offSignatureFile = path + "/training/tplink-bulb/signatures/tplink-bulb-offSignature-phone-side.sig";
+        */
+
+        /*
+        // WeMo Plug experiment
+        final String inputPcapFile = path + "/training/wemo-plug/wlan1/wemo-plug.wlan1.local.pcap";
+        // WeMo Plug PHONE signatures
+        final String onSignatureFile = path + "/training/wemo-plug/signatures/wemo-plug-onSignature-device-side.sig";
+        final String offSignatureFile = path + "/training/wemo-plug/signatures/wemo-plug-offSignature-device-side.sig";
+        */
+
+        /*
+        // WeMo Insight Plug experiment
+        final String inputPcapFile = path + "/training/wemo-insight-plug/wlan1/wemo-insight-plug.wlan1.local.pcap";
+        // WeMo Insight Plug PHONE signatures
+        final String onSignatureFile = path + "/training/wemo-insight-plug/signatures/wemo-insight-plug-onSignature-device-side.sig";
+        final String offSignatureFile = path + "/training/wemo-insight-plug/signatures/wemo-insight-plug-offSignature-device-side.sig";
+        */
+
         /*
         // Kwikset Doorlock Sep 12 experiment
         final String inputPcapFile = path + "/2018-08/kwikset-doorlock/kwikset3.wlan1.local.pcap";
index 0a63761..c4335eb 100644 (file)
@@ -7,11 +7,31 @@ path = "/scratch/July-2018/training/"
 #fileExperiment = "dlink-plug-oct-17-2018.timestamps"
 #fileDetection = "detection-on-training-device-side"
 #fileDetection = "detection-on-training-phone-side"
-# TP-Link plug
-device = "arlo-camera/self-test"
-fileExperiment = "arlo-camera-aug-10-2018.timestamps"
-fileDetection = "detection-on-training-phone-side"
+# Arlo camera
+#device = "arlo-camera/self-test"
+#fileExperiment = "arlo-camera-aug-10-2018.timestamps"
 #fileDetection = "detection-on-training-phone-side"
+# Blossom sprinkler
+#device = "blossom-sprinkler/self-test"
+#fileExperiment = "blossom-sprinkler-aug-13-2018.timestamps"
+#fileDetection = "detection-on-training-device-side"
+# Nest thermostat
+#device = "nest-thermostat/self-test"
+#fileExperiment = "nest-aug-15-2018.timestamps"
+#fileDetection = "detection-on-training-phone-side"
+# Hue bulb
+#device = "hue-bulb/self-test"
+#fileExperiment = "hue-bulb-aug-7-2018.timestamps"
+#fileDetection = "detection-on-training-phone-side"
+# TPLink bulb
+#device = "tplink-bulb/self-test"
+#fileExperiment = "tplink-bulb-aug-3-2018.timestamps"
+#fileDetection = "detection-on-training-phone-side"
+# WeMo Insight Plug
+device = "wemo-insight-plug/self-test"
+fileExperiment = "wemo-insight-july-31-2018.timestamps"
+fileDetection = "detection-on-training-device-side"
+
 TIME_WINDOW = 15 # detection/signature window of 15 seconds
 #NEG_TIME_WINDOW = -15 # detection/signature window of 15 seconds
 
@@ -51,6 +71,7 @@ while i < maxTimestamps:
        # The following happens when we could detect less triggers than the experiment
        if (delta1.seconds > TIME_WINDOW and delta2.seconds > TIME_WINDOW):
                print("Missing trigger at line: " + str(i) + ", t_experiment: " + str(tsE) + " and t_detection: " + str(tsD))
+               #print(str(tsD))
                i = i + 1
        # The following should not happen (we have more detected triggers than the experiment)
        #elif (delta.seconds < NEG_TIME_WINDOW):