From: Janus Varmarken Date: Tue, 24 Jul 2018 21:41:16 +0000 (-0700) Subject: PcapHandleReader: count and print (to std.err) the number of packets that appear... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0990ea745f5e7976cf71a75e971ce78c98ae9a4a;p=pingpong.git PcapHandleReader: count and print (to std.err) the number of packets that appear out of order --- diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/io/PcapHandleReader.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/io/PcapHandleReader.java index 2c387f3..e01f712 100644 --- a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/io/PcapHandleReader.java +++ b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/io/PcapHandleReader.java @@ -43,12 +43,13 @@ public class PcapHandleReader { * @throws TimeoutException if packets are being read from a live capture and the timeout expired. */ public void readFromHandle() throws PcapNativeException, NotOpenException, TimeoutException { + int outOfOrderPackets = 0; try { PcapPacket prevPacket = null; PcapPacket packet; while ((packet = mHandle.getNextPacketEx()) != null) { if (prevPacket != null && packet.getTimestamp().isBefore(prevPacket.getTimestamp())) { - System.out.println("Out-of-order (in terms of timestamp) packet detected"); + outOfOrderPackets++; /* // Fail early if assumption doesn't hold. mHandle.close(); @@ -67,6 +68,11 @@ public class PcapHandleReader { // Reached end of file. All good. System.out.println(String.format("%s: finished reading pcap file", getClass().getSimpleName())); } + if (outOfOrderPackets > 0) { + System.err.println( + String.format("[[[ %s: %d packets appeared out of order (with regards to their timestamps) ]]]", + getClass().getSimpleName(), outOfOrderPackets)); + } mHandle.close(); }