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%2FLayer2SequenceMatcher.java;h=49951f0ef050bc9479fa5a5e68d969f171bd7c4e;hp=a9d6241e59fc704363b2cbc7a9249183ea6ceae9;hb=39172356d48f5cd574ef15ec276a33de9146155a;hpb=3b85a5fd4c595dab156727d95908adbc47b01d98 diff --git a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SequenceMatcher.java b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SequenceMatcher.java index a9d6241..49951f0 100644 --- a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SequenceMatcher.java +++ b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SequenceMatcher.java @@ -24,6 +24,7 @@ public class Layer2SequenceMatcher extends Layer2AbstractMatcher { private int mInclusionTimeMillis; + /** * Create a {@code Layer2SequenceMatcher}. * @param sequence The sequence to match against (search for). @@ -90,22 +91,29 @@ public class Layer2SequenceMatcher extends Layer2AbstractMatcher { mPacketDirections[getMatchedPacketsCount()-1], packet); boolean expectedDirection = mPacketDirections[getMatchedPacketsCount()]; if (actualDirection != expectedDirection) { + mSkippedPackets++; return false; } // Next apply timing constraints: // 1: to be a match, the packet must have a later timestamp than any other packet currently matched // 2: does adding the packet cause the max allowed time between first packet and last packet to be exceeded? if (!packet.getTimestamp().isAfter(mMatchedPackets.get(getMatchedPacketsCount()-1).getTimestamp())) { + mSkippedPackets++; return false; } // if (packet.getTimestamp().isAfter(mMatchedPackets.get(0).getTimestamp(). // plusMillis(TriggerTrafficExtractor.INCLUSION_WINDOW_MILLIS))) { if (packet.getTimestamp().isAfter(mMatchedPackets.get(0).getTimestamp(). plusMillis(mInclusionTimeMillis))) { + mSkippedPackets++; return false; } // If we made it here, it means that this packet has the expected length, direction, and obeys the timing // constraints, so we store it and advance. + if (mMaxSkippedPackets < mSkippedPackets) { + mMaxSkippedPackets = mSkippedPackets; + mSkippedPackets = 0; + } mMatchedPackets.add(packet); if (mMatchedPackets.size() == mSequence.size()) { // TODO report (to observers?) that we are done?