Only taking signatures in the range of trigger+/-5; pad with null if the second eleme...
authorrtrimana <rtrimana@uci.edu>
Wed, 19 Sep 2018 18:12:04 +0000 (11:12 -0700)
committerrtrimana <rtrimana@uci.edu>
Wed, 19 Sep 2018 18:12:04 +0000 (11:12 -0700)
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/util/PcapPacketUtils.java

index 78676e8..d909be8 100644 (file)
@@ -49,10 +49,10 @@ public class Main {
         final String offPairsPath = "/scratch/July-2018/off.txt";
 
         // 1) D-Link July 26 experiment
-        final String inputPcapFile = path + "/2018-07/dlink/dlink.wlan1.local.pcap";
-        final String outputPcapFile = path + "/2018-07/dlink/dlink-processed.pcap";
-        final String triggerTimesFile = path + "/2018-07/dlink/dlink-july-26-2018.timestamps";
-        final String deviceIp = "192.168.1.246"; // .246 == phone; .199 == dlink plug?
+//        final String inputPcapFile = path + "/2018-07/dlink/dlink.wlan1.local.pcap";
+//        final String outputPcapFile = path + "/2018-07/dlink/dlink-processed.pcap";
+//        final String triggerTimesFile = path + "/2018-07/dlink/dlink-july-26-2018.timestamps";
+//        final String deviceIp = "192.168.1.246"; // .246 == phone; .199 == dlink plug?
 
         // 2) TP-Link July 25 experiment
 //        final String inputPcapFile = path + "/2018-07/tplink/tplink.wlan1.local.pcap";
@@ -93,10 +93,10 @@ public class Main {
 //        final String deviceIp = "192.168.1.140"; // .246 == phone; .140 == TP-Link bulb
 
         // 7) Kwikset Doorlock August 6 experiment
-//        final String inputPcapFile = path + "/2018-08/kwikset-doorlock/kwikset-doorlock.wlan1.local.pcap";
-//        final String outputPcapFile = path + "/2018-08/kwikset-doorlock/kwikset-doorlock-processed.pcap";
-//        final String triggerTimesFile = path + "/2018-08/kwikset-doorlock/kwikset-doorlock-aug-6-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-08/kwikset-doorlock/kwikset-doorlock.wlan1.local.pcap";
+        final String outputPcapFile = path + "/2018-08/kwikset-doorlock/kwikset-doorlock-processed.pcap";
+        final String triggerTimesFile = path + "/2018-08/kwikset-doorlock/kwikset-doorlock-aug-6-2018.timestamps";
+        final String deviceIp = "192.168.1.246"; // .246 == phone; .142 == SmartThings Hub (note: use eth0 capture for this!)
 
         // September 12, 2018 - includes both wlan1 and eth1 interfaces
         //final String inputPcapFile = path + "/2018-08/kwikset-doorlock/kwikset3.wlan1.local.pcap";
@@ -283,11 +283,13 @@ public class Main {
         for (Cluster<PcapPacketPair> c : onClusters) {
             System.out.println(String.format("<<< Cluster #%02d (%03d points) >>>", ++count, c.getPoints().size()));
             System.out.print(PrintUtils.toSummaryString(c));
-            // Print to file
-            List<List<PcapPacket>> ppListOfList = PcapPacketUtils.clusterToListOfPcapPackets(c);
-            PrintUtils.serializeClustersIntoFile("./onSignature" + count + ".sig", ppListOfList);
-            ppListOfListReadOn =
-                    PrintUtils.serializeClustersFromFile("./onSignature" + count + ".sig");
+            if(c.getPoints().size() > 45 && c.getPoints().size() < 55) {
+                // Print to file
+                List<List<PcapPacket>> ppListOfList = PcapPacketUtils.clusterToListOfPcapPackets(c);
+                PrintUtils.serializeClustersIntoFile("./onSignature" + count + ".sig", ppListOfList);
+                ppListOfListReadOn =
+                        PrintUtils.serializeClustersFromFile("./onSignature" + count + ".sig");
+            }
         }
         System.out.println("========================================");
         System.out.println("       Clustering results for OFF       ");
@@ -297,11 +299,13 @@ public class Main {
         for (Cluster<PcapPacketPair> c : offClusters) {
             System.out.println(String.format("<<< Cluster #%03d (%06d points) >>>", ++count, c.getPoints().size()));
             System.out.print(PrintUtils.toSummaryString(c));
-            // Print to file
-            List<List<PcapPacket>> ppListOfList = PcapPacketUtils.clusterToListOfPcapPackets(c);
-            PrintUtils.serializeClustersIntoFile("./offSignature" + count + ".sig", ppListOfList);
-            ppListOfListReadOff =
-                    PrintUtils.serializeClustersFromFile("./offSignature" + count + ".sig");
+            if(c.getPoints().size() > 45 && c.getPoints().size() < 55) {
+                // Print to file
+                List<List<PcapPacket>> ppListOfList = PcapPacketUtils.clusterToListOfPcapPackets(c);
+                PrintUtils.serializeClustersIntoFile("./offSignature" + count + ".sig", ppListOfList);
+                ppListOfListReadOff =
+                        PrintUtils.serializeClustersFromFile("./offSignature" + count + ".sig");
+            }
         }
         System.out.println("========================================");
         // ============================================================================================================
index 167f054..932c492 100644 (file)
@@ -95,11 +95,13 @@ public final class PcapPacketUtils {
             // Create a list of PcapPacket objects (list of two members)
             List<PcapPacket> ppList = new ArrayList<>();
             ppList.add(ppp.getFirst());
-            ppList.add(ppp.getSecond().get());
+            if(ppp.getSecond().isPresent())
+                ppList.add(ppp.getSecond().get());
+            else
+                ppList.add(null);
             // Create a list of list of PcapPacket objects
             ppListOfList.add(ppList);
         }
-
         return ppListOfList;
     }