X-Git-Url: http://plrg.eecs.uci.edu/git/?p=pingpong.git;a=blobdiff_plain;f=Code%2FProjects%2FPacketLevelSignatureExtractor%2Fsrc%2Fmain%2Fjava%2Fedu%2Fuci%2Fiotproject%2Fdetection%2Flayer3%2FLayer3SignatureDetector.java;h=03e4bd1cb242531bd6a4858eaba01a2de4b054b5;hp=b11fef88e9086d3354d446a48dae5b39ec86d8bf;hb=987ea910fed24a1f3f51ded41b6aa98c4e2618ae;hpb=da522d853c482a182fb7032251fd936caee6f317;ds=inline diff --git a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3SignatureDetector.java b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3SignatureDetector.java index b11fef8..03e4bd1 100644 --- a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3SignatureDetector.java +++ b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3SignatureDetector.java @@ -47,7 +47,11 @@ public class Layer3SignatureDetector implements PacketListener, ClusterMatcherOb public static void main(String[] args) throws PcapNativeException, NotOpenException, IOException { if (args.length < 8) { - String errMsg = String.format("Usage: %s inputPcapFile onAnalysisFile offAnalysisFile onSignatureFile offSignatureFile resultsFile" + + String errMsg = String.format("SPECTO version 1.0\n" + + "Copyright (C) 2018-2019 Janus Varmarken and Rahmadi Trimananda.\n" + + "University of California, Irvine.\n" + + "All rights reserved.\n\n" + + "Usage: %s inputPcapFile onAnalysisFile offAnalysisFile onSignatureFile offSignatureFile resultsFile" + "\n inputPcapFile: the target of the detection" + "\n onAnalysisFile: the file that contains the ON clusters analysis" + "\n offAnalysisFile: the file that contains the OFF clusters analysis" + @@ -66,7 +70,11 @@ public class Layer3SignatureDetector implements PacketListener, ClusterMatcherOb final String onSignatureFile = args[3]; final String offSignatureFile = args[4]; final String resultsFile = args[5]; - final int signatureDuration = Integer.parseInt(args[6]); + // TODO: THIS IS TEMPORARILY SET TO DEFAULT SIGNATURE DURATION + // TODO: WE DO NOT WANT TO BE TOO STRICT AT THIS POINT SINCE LAYER 3 ALREADY APPLIES BACK-TO-BACK REQUIREMENT + // TODO: FOR PACKETS IN A SIGNATURE +// final int signatureDuration = Integer.parseInt(args[6]); + final int signatureDuration = TriggerTrafficExtractor.INCLUSION_WINDOW_MILLIS; final double eps = Double.parseDouble(args[7]); // Prepare file outputter. @@ -173,9 +181,9 @@ public class Layer3SignatureDetector implements PacketListener, ClusterMatcherOb // Output the detected events detectedEvents.forEach(outputter); - String resultOn = "Number of detected events of type " + UserAction.Type.TOGGLE_ON + ": " + + String resultOn = "# Number of detected events of type " + UserAction.Type.TOGGLE_ON + ": " + detectedEvents.stream().filter(ua -> ua.getType() == UserAction.Type.TOGGLE_ON).count(); - String resultOff = "Number of detected events of type " + UserAction.Type.TOGGLE_OFF + ": " + + String resultOff = "# Number of detected events of type " + UserAction.Type.TOGGLE_OFF + ": " + detectedEvents.stream().filter(ua -> ua.getType() == UserAction.Type.TOGGLE_OFF).count(); PrintWriterUtils.println(resultOn, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); PrintWriterUtils.println(resultOff, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);