From: rtrimana Date: Tue, 26 Mar 2019 21:53:02 +0000 (-0700) Subject: Fixing bug in SignatureGenerator: wrong signature duration calculation because of... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=pingpong.git;a=commitdiff_plain;h=dd0d2642de5bc58bb3f928a5fb8acae90dc7e502 Fixing bug in SignatureGenerator: wrong signature duration calculation because of not updating duration in the while-loop. --- 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