From: Janus Varmarken Date: Sun, 29 Apr 2018 07:49:12 +0000 (-0700) Subject: Filter out retransmissions when reconstructing TCP flows. Now able to detect all... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=384a838085fb80075c9da1cecef542ff31ff9f43;p=pingpong.git Filter out retransmissions when reconstructing TCP flows. Now able to detect all local ON events in wlan1.local.dns.pcap. --- diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/FlowPatternFinder.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/FlowPatternFinder.java index c8f8fe2..8c7d41e 100644 --- a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/FlowPatternFinder.java +++ b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/FlowPatternFinder.java @@ -69,7 +69,13 @@ public class FlowPatternFinder { listWrappedPacket.add(packet); // Create new conversation entry, or append packet to existing. connections.merge(conversation, listWrappedPacket, (v1, v2) -> { - v1.addAll(v2); + // TODO: in theory, this is insufficient to detect retransmissions due to TCP seq.no. rollover. + // TODO: bad for performance, O(n) for each packet added to flow (n being length of the flow). + boolean retransmission = v1.stream().anyMatch(p -> p.get(TcpPacket.class).getHeader().getSequenceNumber() == v2.get(0).get(TcpPacket.class).getHeader().getSequenceNumber()); + if (!retransmission) { + // Do not add if retransmission -> avoid duplicate packets in flow + v1.addAll(v2); + } return v1; }); }