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%2FLayer2RangeMatcher.java;h=5f92df785183a0eaa66f54a2308eed49737feca1;hp=eb3b34e8e5c90661afcf5fb973f8ed3b2df75892;hb=54f6c976c697bb5f132abb5a5e7b7f01e2b6e957;hpb=b5f2e4fdf476cdf07d649089900c3f7c4c7f0ccb diff --git a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2RangeMatcher.java b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2RangeMatcher.java index eb3b34e..5f92df7 100644 --- a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2RangeMatcher.java +++ b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2RangeMatcher.java @@ -71,12 +71,16 @@ public class Layer2RangeMatcher extends Layer2AbstractMatcher { // Get representative of the packet we expect to match next. PcapPacket expectedLowerBound = mLowerBound.get(mMatchedPackets.size()); PcapPacket expectedUpperBound = mUpperBound.get(mMatchedPackets.size()); + int lowerBound = expectedLowerBound.getOriginalLength(); + int upperBound = expectedUpperBound.getOriginalLength(); + // Do strict matching if the lower and upper bounds are the same length + // Do range matching with eps otherwise + if (lowerBound != upperBound) { + lowerBound = lowerBound - (int) mEps; + upperBound = upperBound + (int) mEps; + } // First verify if the received packet has the length we're looking for (the length should be within the range). - if (expectedLowerBound.getOriginalLength() - (int) mEps <= packet.getOriginalLength() && - packet.getOriginalLength() <= expectedUpperBound.getOriginalLength() + (int) mEps){ - // TODO: TEMPORARILY WITHOUT EPS -// if (expectedLowerBound.getOriginalLength() <= packet.getOriginalLength() && -// packet.getOriginalLength() <= expectedUpperBound.getOriginalLength()){ + if (lowerBound <= packet.getOriginalLength() && packet.getOriginalLength() <= upperBound){ // If this is the first packet, we only need to verify that its length is correct. Time constraints are // obviously satisfied as there are no previous packets. Furthermore, direction matches by definition as we // don't know the MAC of the device (or phone) in advance, so we can't enforce a rule saying "first packet @@ -94,13 +98,11 @@ public class Layer2RangeMatcher extends Layer2AbstractMatcher { 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? + // 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())) { 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))) { return false; @@ -125,6 +127,6 @@ public class Layer2RangeMatcher extends Layer2AbstractMatcher { } public List getTargetUpperBound() { - return mLowerBound; + return mUpperBound; } }