Adding more new devices.
[pingpong.git] / Code / Projects / PacketLevelSignatureExtractor / src / main / java / edu / uci / iotproject / SignatureGenerator.java
index 50417e71bf3d222f75156dea895a3e454a1a5a2d..57e0a0e9ca2d4c5a07f6c49519d114837ddf16a2 100644 (file)
@@ -216,6 +216,8 @@ public class SignatureGenerator {
         int numberOfEventsPerType = triggerTimes.size() / 2;
         int lowerBound = numberOfEventsPerType - (int)(numberOfEventsPerType * 0.1);
         int upperBound = numberOfEventsPerType + (int)(numberOfEventsPerType * 0.1);
+        //int lowerBound = numberOfEventsPerType - (int)(numberOfEventsPerType * 0.5);
+        //int upperBound = numberOfEventsPerType + (int)(numberOfEventsPerType * 0.5);
         int minPts = lowerBound;
         DBSCANClusterer<PcapPacketPair> onClusterer = new DBSCANClusterer<>(eps, minPts);
         List<Cluster<PcapPacketPair>> onClusters = onClusterer.cluster(onPairs);
@@ -282,7 +284,7 @@ public class SignatureGenerator {
             }
             PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, sequenceToDelete);
         }
-        PrintWriterUtils.println("ON Sequences after removal: ", resultsWriter,
+        PrintWriterUtils.println("ON Sequences: ", resultsWriter,
                 DUPLICATE_OUTPUT_TO_STD_OUT);
         for(List<List<PcapPacket>> listOfList : ppListOfListListOn) {
             PrintWriterUtils.println(listOfList.get(0).get(0).length() + "...", resultsWriter,
@@ -303,7 +305,7 @@ public class SignatureGenerator {
             }
             PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOff, sequenceToDelete);
         }
-        PrintWriterUtils.println("OFF Sequences after removal: ", resultsWriter,
+        PrintWriterUtils.println("OFF Sequences: ", resultsWriter,
                 DUPLICATE_OUTPUT_TO_STD_OUT);
         for(List<List<PcapPacket>> listOfList : ppListOfListListOff) {
             PrintWriterUtils.println(listOfList.get(0).get(0).length() + "...", resultsWriter,
@@ -328,6 +330,9 @@ public class SignatureGenerator {
         PrintWriterUtils.println("========================================", resultsWriter,
                 DUPLICATE_OUTPUT_TO_STD_OUT);
         PcapPacketUtils.printSignatures(ppListOfListListOff, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
+        // Clean signatures from null elements
+        PcapPacketUtils.cleanSignature(ppListOfListListOn);
+        PcapPacketUtils.cleanSignature(ppListOfListListOff);
         // Printing signatures into files
         PrintUtils.serializeIntoFile(onSignatureFile, ppListOfListListOn);
         PrintUtils.serializeIntoFile(offSignatureFile, ppListOfListListOff);