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%2Flayer2%2FLayer2SignatureDetector.java;h=51883c0196fe1149a0337367dd9af9f16ad1b43f;hp=1980348a082a89c56f267b036bdd054e3ace15f1;hb=39172356d48f5cd574ef15ec276a33de9146155a;hpb=3b85a5fd4c595dab156727d95908adbc47b01d98;ds=sidebyside diff --git a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SignatureDetector.java b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SignatureDetector.java index 1980348..51883c0 100644 --- a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SignatureDetector.java +++ b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SignatureDetector.java @@ -178,8 +178,14 @@ public class Layer2SignatureDetector implements PacketListener, ClusterMatcherOb detectedEvents.stream().filter(ua -> ua.getType() == UserAction.Type.TOGGLE_ON).count(); String resultOff = "# Number of detected events of type " + UserAction.Type.TOGGLE_OFF + ": " + detectedEvents.stream().filter(ua -> ua.getType() == UserAction.Type.TOGGLE_OFF).count(); + String onMaxSkippedPackets = "# Number of skipped packets in ON signature " + + Integer.toString(onDetector.getMaxSkippedPackets()); + String offMaxSkippedPackets = "# Number of skipped packets in OFF signature " + + Integer.toString(offDetector.getMaxSkippedPackets()); PrintWriterUtils.println(resultOn, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); PrintWriterUtils.println(resultOff, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); + PrintWriterUtils.println(onMaxSkippedPackets, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); + PrintWriterUtils.println(offMaxSkippedPackets, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); // Flush output to results file and close it. resultsWriter.flush(); @@ -219,6 +225,8 @@ public class Layer2SignatureDetector implements PacketListener, ClusterMatcherOb private int mInclusionTimeMillis; + private int mMaxSkippedPackets; + public Layer2SignatureDetector(List>> searchedSignature, int signatureDuration, boolean isRangeBased, double eps) { this(searchedSignature, null, signatureDuration, isRangeBased, eps); } @@ -253,6 +261,11 @@ public class Layer2SignatureDetector implements PacketListener, ClusterMatcherOb mClusterMatchers.forEach(cm -> mFlowReassembler.addObserver(cm)); mInclusionTimeMillis = inclusionTimeMillis == 0 ? TriggerTrafficExtractor.INCLUSION_WINDOW_MILLIS : inclusionTimeMillis; + mMaxSkippedPackets = 0; + } + + public int getMaxSkippedPackets() { + return mMaxSkippedPackets; } @Override @@ -262,7 +275,11 @@ public class Layer2SignatureDetector implements PacketListener, ClusterMatcherOb } @Override - public void onMatch(AbstractClusterMatcher clusterMatcher, List match) { + public void onMatch(AbstractClusterMatcher clusterMatcher, List match, int maxSkippedPackets) { + // Update the number of skipped packets + if (mMaxSkippedPackets < maxSkippedPackets) { + mMaxSkippedPackets = maxSkippedPackets; + } // TODO: a cluster matcher found a match if (clusterMatcher instanceof Layer2ClusterMatcher) { // Add the match at the corresponding index