From dd0d2642de5bc58bb3f928a5fb8acae90dc7e502 Mon Sep 17 00:00:00 2001 From: rtrimana Date: Tue, 26 Mar 2019 14:53:02 -0700 Subject: [PATCH] Fixing bug in SignatureGenerator: wrong signature duration calculation because of not updating duration in the while-loop. --- .../java/edu/uci/iotproject/SignatureGenerator.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/SignatureGenerator.java b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/SignatureGenerator.java index ae8e806..3629e80 100644 --- a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/SignatureGenerator.java +++ b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/SignatureGenerator.java @@ -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(); + 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 - 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(); + 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 -- 2.34.1