Adding EPS value back into the range.
authorrtrimana <rtrimana@uci.edu>
Fri, 15 Mar 2019 23:15:47 +0000 (16:15 -0700)
committerrtrimana <rtrimana@uci.edu>
Fri, 15 Mar 2019 23:15:47 +0000 (16:15 -0700)
Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2RangeMatcher.java
Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3ClusterMatcher.java

index 00cde34..eb3b34e 100644 (file)
@@ -72,11 +72,11 @@ public class Layer2RangeMatcher extends Layer2AbstractMatcher {
         PcapPacket expectedLowerBound = mLowerBound.get(mMatchedPackets.size());
         PcapPacket expectedUpperBound = mUpperBound.get(mMatchedPackets.size());
         // 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){
+        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 (expectedLowerBound.getOriginalLength() <= packet.getOriginalLength() &&
+//                packet.getOriginalLength() <= expectedUpperBound.getOriginalLength()){
             // 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
index 6d81100..d4b2a32 100644 (file)
@@ -131,7 +131,7 @@ public class Layer3ClusterMatcher extends AbstractClusterMatcher implements Pack
             while ((match = findSubsequenceInSequence(lowerBound, upperBound, cPkts, mClusterMemberDirections, null)).
                     isPresent()) {
                 List<PcapPacket> matchSeq = match.get();
-//                // Notify observers about the match.
+                // 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))) {
@@ -178,7 +178,7 @@ public class Layer3ClusterMatcher extends AbstractClusterMatcher implements Pack
                 while ((match = findSubsequenceInSequence(signatureSequence, cPkts, mClusterMemberDirections, null)).
                         isPresent()) {
                     List<PcapPacket> matchSeq = match.get();
-//                    // Notify observers about the match.
+                    // 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))) {
@@ -359,11 +359,11 @@ public class Layer3ClusterMatcher extends AbstractClusterMatcher implements Pack
             // 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;
+            int epsLowerBound = lowBndPkt.length() - (int) mEps;
+            int epsUpperBound = upBndPkt.length() + (int) mEps;
             // TODO: TEMPORARILY REMOVE EPS BOUNDS
-            int epsLowerBound = lowBndPkt.length();
-            int epsUpperBound = upBndPkt.length();
+//            int epsLowerBound = lowBndPkt.length();
+//            int epsUpperBound = upBndPkt.length();
             if (epsLowerBound <= seqPkt.getOriginalLength() &&
                     seqPkt.getOriginalLength() <= epsUpperBound &&
                     subsequenceDirections[subseqIdx] == sequenceDirections[seqIdx]) {