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%2FLayer3ClusterMatcher.java;h=165cdb3e57f68de4319504a3fee4e15cd4efc34e;hp=6d8110046afa16d00f342d48adb48576b96b2e8e;hb=987ea910fed24a1f3f51ded41b6aa98c4e2618ae;hpb=4beef1e7632e815e9d7a821295e6c3967e5935bd diff --git a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3ClusterMatcher.java b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3ClusterMatcher.java index 6d81100..165cdb3 100644 --- a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3ClusterMatcher.java +++ b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3ClusterMatcher.java @@ -131,13 +131,9 @@ public class Layer3ClusterMatcher extends AbstractClusterMatcher implements Pack while ((match = findSubsequenceInSequence(lowerBound, upperBound, cPkts, mClusterMemberDirections, null)). isPresent()) { List matchSeq = match.get(); -// // Notify observers about the match. -// mObservers.forEach(o -> o.onMatch(Layer3ClusterMatcher.this, matchSeq)); - if (!matchSeq.get(matchSeq.size()-1).getTimestamp().isAfter(matchSeq.get(0).getTimestamp(). - plusMillis(mInclusionTimeMillis))) { - // Notify observers about the match. - mObservers.forEach(o -> o.onMatch(Layer3ClusterMatcher.this, matchSeq)); - } + // Notify observers about the match. + // Max number of skipped packets in layer 3 is 0 (no skipped packets) + mObservers.forEach(o -> o.onMatch(Layer3ClusterMatcher.this, matchSeq)); /* * Get the index in cPkts of the last packet in the sequence of packets that matches the searched * signature sequence. @@ -178,13 +174,9 @@ public class Layer3ClusterMatcher extends AbstractClusterMatcher implements Pack while ((match = findSubsequenceInSequence(signatureSequence, cPkts, mClusterMemberDirections, null)). isPresent()) { List matchSeq = match.get(); -// // Notify observers about the match. -// mObservers.forEach(o -> o.onMatch(Layer3ClusterMatcher.this, matchSeq)); - if (!matchSeq.get(matchSeq.size()-1).getTimestamp().isAfter(matchSeq.get(0).getTimestamp(). - plusMillis(mInclusionTimeMillis))) { - // Notify observers about the match. - mObservers.forEach(o -> o.onMatch(Layer3ClusterMatcher.this, matchSeq)); - } + // Notify observers about the match. + // Max number of skipped packets in layer 3 is 0 (no skipped packets) + mObservers.forEach(o -> o.onMatch(Layer3ClusterMatcher.this, matchSeq)); /* * Get the index in cPkts of the last packet in the sequence of packets that matches the searched * signature sequence. @@ -358,12 +350,16 @@ public class Layer3ClusterMatcher extends AbstractClusterMatcher implements Pack PcapPacket seqPkt = sequence.get(seqIdx); // We only have a match if packet lengths and directions match. // The packet lengths have to be in the range of [lowerBound - eps, upperBound+eps] - // TODO: Maybe we could do better here for the double to integer conversion? -// int epsLowerBound = lowBndPkt.length() - (int) mEps; -// int epsUpperBound = upBndPkt.length() + (int) mEps; - // TODO: TEMPORARILY REMOVE EPS BOUNDS + // We initialize the lower and upper bounds first int epsLowerBound = lowBndPkt.length(); int epsUpperBound = upBndPkt.length(); + // Do strict matching if the lower and upper bounds are the same length + // Do range matching with eps otherwise + if (epsLowerBound != epsUpperBound) { + // TODO: Maybe we could do better here for the double to integer conversion? + epsLowerBound = epsLowerBound - (int) mEps; + epsUpperBound = epsUpperBound + (int) mEps; + } if (epsLowerBound <= seqPkt.getOriginalLength() && seqPkt.getOriginalLength() <= epsUpperBound && subsequenceDirections[subseqIdx] == sequenceDirections[seqIdx]) {