Merge branch 'master' of https://github.uci.edu/rtrimana/smart_home_traffic
authorrtrimana <rtrimana@uci.edu>
Mon, 14 Jan 2019 18:03:15 +0000 (10:03 -0800)
committerrtrimana <rtrimana@uci.edu>
Mon, 14 Jan 2019 18:03:15 +0000 (10:03 -0800)
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/detection/layer3/Layer3ClusterMatcher.java
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/detection/layer3/SignatureDetector.java
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/util/PcapPacketUtils.java

index a7e9a6c7b64e9f13e8fdeca43c6b51f18773d05c..81eb3b0b9a96c833ae2db2870a4cca21316938da 100644 (file)
@@ -230,10 +230,11 @@ public class Main {
 //        final String outputPcapFile = path + "/2018-10/blossom-sprinkler/blossom-sprinkler-processed.pcap";
 //        final String triggerTimesFile = path + "/2018-10/blossom-sprinkler/blossom-sprinkler-nov-2-2018.timestamps";
 //        final String deviceIp = "192.168.1.229"; // .246 == phone; .229 == sprinkler
-        // January 9
+        // January 9, 11
         final String inputPcapFile = path + "/experimental_result/standalone/blossom-sprinkler/wlan1/blossom-sprinkler.wlan1.local.pcap";
         final String outputPcapFile = path + "/experimental_result/standalone/blossom-sprinkler/wlan1/blossom-sprinkler-processed.pcap";
-        final String triggerTimesFile = path + "/experimental_result/standalone/blossom-sprinkler/timestamps/blossom-sprinkler-standalone-jan-9-2018.timestamps";
+        final String triggerTimesFile = path + "/experimental_result/standalone/blossom-sprinkler/timestamps/blossom-sprinkler-standalone-jan-9-2019.timestamps";
+//        final String triggerTimesFile = path + "/experimental_result/standalone/blossom-sprinkler/timestamps/blossom-sprinkler-standalone-jan-11-2019.timestamps";
         final String deviceIp = "192.168.1.246"; // .246 == phone; .229 == sprinkler
 
 //        // 13) DLink siren August 14 experiment
@@ -504,8 +505,8 @@ public class Main {
         PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 0);
         PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 1);
         // TODO: Need to remove sequence numbers 0 for Blossom device side since it is not a good signature!
-        //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 0);
-        //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 0);
+//        PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 0);
+//        PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 0);
         // TODO: Need to remove sequence number 2 for ST plug since it is not a good signature!
         //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 2);
         // TODO: Need to remove sequence number 0 for Arlo Camera since it is not a good signature!
@@ -540,10 +541,10 @@ public class Main {
         }
         // TODO: Merging test
         ppListOfListListOff = PcapPacketUtils.mergeSignatures(ppListOfListListOff, sortedAllConversation);
-        //ppListOfListListOff = PcapPacketUtils.sortSignatures(ppListOfListListOff);
+        ppListOfListListOff = PcapPacketUtils.sortSignatures(ppListOfListListOff);
         // TODO: Need to remove sequence numbers 0,2 for Blossom device side since it is not a good signature!
-        //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOff, 0);
-        //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOff, 2);
+//        PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOff, 0);
+//        PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOff, 0);
         // TODO: Need to remove sequence number 1 for Nest Thermostat since it is not a good signature!
         //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOff, 1);
         // TODO: Need to remove sequence number 0 for Arlo Camera since it is not a good signature!
index b5e30772d3f79893f10ee134786b6fd8e09e9d0e..f0e3bb63b03343aba86f8757b244956f1718bbdc 100644 (file)
@@ -327,7 +327,7 @@ public class Layer3ClusterMatcher extends AbstractClusterMatcher implements Pack
             } else if (isDstIpLocal(pkt) || getDestinationIp(pkt).equals(routerWanIp)) {
                 directions[i] = Conversation.Direction.SERVER_TO_CLIENT;
             } else {
-                throw new IllegalArgumentException("no local IP or router WAN port IP found, can't detect direction");
+                //throw new IllegalArgumentException("no local IP or router WAN port IP found, can't detect direction");
             }
         }
         return directions;
index ad4710612e0e382c824c22a54a663d8bb8e06038..c1a5a9c0c2939f66c9b4bb1608796fcb841a722a 100644 (file)
@@ -217,14 +217,14 @@ public class SignatureDetector implements PacketListener, Layer3ClusterMatcher.C
         // TODO: EXPERIMENT - January 9, 2018
         // Blossom Sprinkler experiment
 //        final String inputPcapFile = path + "/experimental_result/standalone/blossom-sprinkler/wlan1/blossom-sprinkler.wlan1.local.pcap";
-//        final String inputPcapFile = path + "/experimental_result/smarthome/blossom-sprinkler/eth0/blossom-sprinkler.eth0.detection.pcap";
-        final String inputPcapFile = path + "/experimental_result/smarthome/blossom-sprinkler/wlan1/blossom-sprinkler.wlan1.detection.pcap";
+        final String inputPcapFile = path + "/experimental_result/smarthome/blossom-sprinkler/eth0/blossom-sprinkler.eth0.detection.pcap";
+//        final String inputPcapFile = path + "/experimental_result/smarthome/blossom-sprinkler/wlan1/blossom-sprinkler.wlan1.detection.pcap";
         // Blossom Sprinkler DEVICE signatures
-//        final String onSignatureFile = path + "/experimental_result/standalone/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-device-side.sig";
-//        final String offSignatureFile = path + "/experimental_result/standalone/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-device-side.sig";
+        final String onSignatureFile = path + "/experimental_result/standalone/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-device-side.sig";
+        final String offSignatureFile = path + "/experimental_result/standalone/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-device-side.sig";
         // Blossom Sprinkler PHONE signatures
-        final String onSignatureFile = path + "/experimental_result/standalone/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-phone-side.sig";
-        final String offSignatureFile = path + "/experimental_result/standalone/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-phone-side.sig";
+//        final String onSignatureFile = path + "/experimental_result/standalone/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-phone-side.sig";
+//        final String offSignatureFile = path + "/experimental_result/standalone/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-phone-side.sig";
 
         // LiFX Bulb experiment
 //        final String inputPcapFile = path + "/training/lifx-bulb/wlan1/lifx-bulb.wlan1.local.pcap";
@@ -361,11 +361,11 @@ public class SignatureDetector implements PacketListener, Layer3ClusterMatcher.C
         List<List<List<PcapPacket>>> offSignature = PrintUtils.deserializeSignatureFromFile(offSignatureFile);
 
         // LAN
-        SignatureDetector onDetector = new SignatureDetector(onSignature, null);
-        SignatureDetector offDetector = new SignatureDetector(offSignature, null);
+//        SignatureDetector onDetector = new SignatureDetector(onSignature, null);
+//        SignatureDetector offDetector = new SignatureDetector(offSignature, null);
         // WAN
-//        SignatureDetector onDetector = new SignatureDetector(onSignature, "128.195.205.105");
-//        SignatureDetector offDetector = new SignatureDetector(offSignature, "128.195.205.105");
+        SignatureDetector onDetector = new SignatureDetector(onSignature, "128.195.205.105");
+        SignatureDetector offDetector = new SignatureDetector(offSignature, "128.195.205.105");
 
         final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).
                 withLocale(Locale.US).withZone(ZoneId.of("America/Los_Angeles"));
index f07072abe8d9daf8ddd9a9bd2ce40e022ed5ee79..cee09fed8c1c78ddc19459470864b01571f6fd93 100644 (file)
@@ -318,9 +318,9 @@ public final class PcapPacketUtils {
     public static List<List<List<PcapPacket>>> sortSignatures(List<List<List<PcapPacket>>> signatures) {
         // TODO: This is the simplest solution!!! Might not cover all corner cases.
         // TODO: Sort the list of lists based on the first packet's timestamps!
-        //Collections.sort(signatures, (p1, p2) -> {
-        //    return p1.get(0).get(0).getTimestamp().compareTo(p2.get(0).get(0).getTimestamp());
-        //});
+//        Collections.sort(signatures, (p1, p2) -> {
+//            return p1.get(0).get(0).getTimestamp().compareTo(p2.get(0).get(0).getTimestamp());
+//        });
         // TODO: The following is a more complete solution that covers corner cases.
         // Sort the list of lists based on one-to-one comparison between timestamps of signatures on both lists.
         // This also takes into account the fact that the number of signatures in the two lists could be different.