From: Janus Varmarken Date: Thu, 26 Jul 2018 22:34:36 +0000 (-0700) Subject: Main.java: re-add counting of statistics using TcpConversationUtils X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d47fb3a17b0f426eec5382bfe1abb2c444c0cdcc;p=pingpong.git Main.java: re-add counting of statistics using TcpConversationUtils --- diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java index 76134dc..0ddae8d 100644 --- a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java +++ b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java @@ -1,5 +1,6 @@ package edu.uci.iotproject; +import edu.uci.iotproject.analysis.TcpConversationUtils; import edu.uci.iotproject.analysis.TriggerTrafficExtractor; import edu.uci.iotproject.io.TriggerTimesFileReader; import org.pcap4j.core.*; @@ -49,6 +50,24 @@ public class Main { }, dnsMap, tcpReassembler); outputter.flush(); outputter.close(); + + // Extract all conversations present in the filtered trace. + List allConversations = tcpReassembler.getTcpConversations(); + // Group conversations by hostname. + Map> convsByHostname = TcpConversationUtils.groupConversationsByHostname(allConversations, dnsMap); + System.out.println("Grouped conversations by hostname."); + // For each hostname, count the frequencies of packet lengths exchanged with that hostname. + final Map> pktLenFreqsByHostname = new HashMap<>(); + convsByHostname.forEach((host, convs) -> pktLenFreqsByHostname.put(host, TcpConversationUtils.countPacketLengthFrequencies(convs))); + System.out.println("Counted frequencies of packet lengths exchanged with each hostname."); + // For each hostname, count the frequencies of packet sequences (i.e., count how many conversations exchange a + // sequence of packets of some specific lengths). + final Map> pktSeqFreqsByHostname = new HashMap<>(); + convsByHostname.forEach((host, convs) -> pktSeqFreqsByHostname.put(host, TcpConversationUtils.countPacketSequenceFrequencies(convs))); + System.out.println("Counted frequencies of packet sequences exchanged with each hostname."); + + + // ------------------------------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------------------------------- }