+ // TODO: Merging test
+ ppListOfListListOn = PcapPacketUtils.mergeSignatures(ppListOfListListOn, sortedAllConversation);
+ ppListOfListListOn = PcapPacketUtils.sortSignatures(ppListOfListListOn);
+ // 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!
+ //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 0);
+ // TODO: Need to remove sequence number 0 for TP-Link plug since it is not a good signature!
+ // TODO: This sequence actually belongs to the local communication between the plug and the phone
+ //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 0);
+ PcapPacketUtils.printSignatures(ppListOfListListOn);
+ //count = 0;
+ /*for (List<List<PcapPacket>> ll : ppListOfListListOn) {
+ PrintUtils.serializeClustersIntoFile("./onSignature" + ++count + ".sig", ll);
+ ppListOfListReadOn.add(PrintUtils.deserializeClustersFromFile("./onSignature" + count + ".sig"));
+ }*/
+ PrintUtils.serializeSignatureIntoFile("./onSignature.sig", ppListOfListListOn);
+ ppListOfListReadOn = PrintUtils.deserializeSignatureFromFile("./onSignature.sig");
+
+ System.out.println("========================================");
+ System.out.println(" Clustering results for OFF ");
+ System.out.println(" Number of clusters: " + offClusters.size());
+ count = 0;
+ List<List<List<PcapPacket>>> ppListOfListReadOff = new ArrayList<>();
+ List<List<List<PcapPacket>>> ppListOfListListOff = new ArrayList<>();
+ for (Cluster<PcapPacketPair> c : offClusters) {
+ System.out.println(String.format("<<< Cluster #%03d (%06d points) >>>", ++count, c.getPoints().size()));
+ System.out.print(PrintUtils.toSummaryString(c));
+ if(c.getPoints().size() > 45 && c.getPoints().size() < 55) {
+ //if(c.getPoints().size() > 25) {
+ // Print to file
+ List<List<PcapPacket>> ppListOfList = PcapPacketUtils.clusterToListOfPcapPackets(c);
+ ppListOfListListOff.add(ppListOfList);
+ }
+ }
+ // TODO: Merging test
+ ppListOfListListOff = PcapPacketUtils.mergeSignatures(ppListOfListListOff, sortedAllConversation);
+ //ppListOfListListOff = PcapPacketUtils.sortSignatures(ppListOfListListOff);
+ // 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!
+ //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOff, 1);
+ // TODO: Need to remove sequence number 2 for ST plug since it is not a good signature!
+ //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOff, 2);
+ // TODO: Need to remove sequence number 0 for TP-Link plug since it is not a good signature!
+ // TODO: This sequence actually belongs to the local communication between the plug and the phone
+ //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOff, 0);
+ PcapPacketUtils.printSignatures(ppListOfListListOff);
+ //count = 0;
+ /*for (List<List<PcapPacket>> ll : ppListOfListListOff) {
+ PrintUtils.serializeClustersIntoFile("./offSignature" + ++count + ".sig", ll);
+ ppListOfListReadOff.add(PrintUtils.deserializeClustersFromFile("./offSignature" + count + ".sig"));
+ }*/
+ PrintUtils.serializeSignatureIntoFile("./offSignature.sig", ppListOfListListOff);
+ ppListOfListReadOff = PrintUtils.deserializeSignatureFromFile("./offSignature.sig");
+ System.out.println("========================================");
+ // ============================================================================================================
+
+ /*
+ System.out.println("==== ON ====");