Fixing bug in SignatureGenerator: wrong signature duration calculation because of...
[pingpong.git] / Code / Projects / PacketLevelSignatureExtractor / src / main / java / edu / uci / iotproject / SignatureGenerator.java
index ae8e8063a09730e0f9f0a4815e25ff6b6947f927..3629e8086836ce5f8342c86341aff5a2268860ac 100644 (file)
@@ -375,15 +375,16 @@ public class SignatureGenerator {
                 while (duration > TriggerTrafficExtractor.INCLUSION_WINDOW_MILLIS && iterFirst.hasNext()) {
                     // that means we have to move to the next trigger
                     firstInst = (Instant) iterFirst.next();
                 while (duration > TriggerTrafficExtractor.INCLUSION_WINDOW_MILLIS && iterFirst.hasNext()) {
                     // that means we have to move to the next trigger
                     firstInst = (Instant) iterFirst.next();
+                    dur = Duration.between(firstInst, lastInst);
+                    duration = dur.toMillis();
                 }
                 }
-                dur = Duration.between(firstInst, lastInst);
-                duration = dur.toMillis();
             } else { // Below 0/Negative --- that means we have to move to the next signature
             } else { // Below 0/Negative --- that means we have to move to the next signature
-                while (duration < 0 && iterLast.hasNext()) { // that means we have to move to the next trigger
+                while (duration < 0 && iterLast.hasNext()) {
+                    // that means we have to move to the next trigger
                     lastInst = (Instant) iterLast.next();
                     lastInst = (Instant) iterLast.next();
+                    dur = Duration.between(firstInst, lastInst);
+                    duration = dur.toMillis();
                 }
                 }
-                dur = Duration.between(firstInst, lastInst);
-                duration = dur.toMillis();
             }
             PrintWriterUtils.println(duration, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
             // Update duration if this bigger than the max value and still less than the window inclusion time
             }
             PrintWriterUtils.println(duration, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
             // Update duration if this bigger than the max value and still less than the window inclusion time