Main.java: cleanup - leave only code for extracting traffic generated by a device...
authorJanus Varmarken <varmarken@gmail.com>
Thu, 26 Jul 2018 22:02:09 +0000 (15:02 -0700)
committerJanus Varmarken <varmarken@gmail.com>
Thu, 26 Jul 2018 22:02:09 +0000 (15:02 -0700)
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java

index 940b8a48a4995f1967c00ee6e9f9d9d726fe5bd1..76134dc7654a256f720b612929a1c00835393d48 100644 (file)
@@ -25,16 +25,19 @@ public class Main {
 
 
     public static void main(String[] args) throws PcapNativeException, NotOpenException, EOFException, TimeoutException, UnknownHostException {
-        // -------- 07-19-2018 --------
+        // -------------------------------------------------------------------------------------------------------------
+        // ------------ # Code for extracting traffic generated by a device within x seconds of a trigger # ------------
+        // Paths to input and output files (consider supplying these as arguments instead)
+        final String inputPcapFile = "/Users/varmarken/temp/UCI IoT Project/June2018 experiments/tplink/tplink.wlan1.local.pcap";
+        final String outputPcapFile = "/Users/varmarken/temp/UCI IoT Project/June2018 experiments/tplink/tplink-filtered.pcap";
+        final String triggerTimesFile = "/Users/varmarken/temp/UCI IoT Project/June2018 experiments/tplink/tplink-june-14-2018-timestamps.txt";
+        // IP of the device for which traffic is to be extracted
+        final String deviceIp = "192.168.1.159";
+
         TriggerTimesFileReader ttfr = new TriggerTimesFileReader();
-//        List<Instant> triggerTimes = ttfr.readTriggerTimes("/Users/varmarken/Downloads/tplink-feb-13-2018.timestamps", false);
-        List<Instant> triggerTimes = ttfr.readTriggerTimes("/Users/varmarken/temp/UCI IoT Project/June2018 experiments/tplink/tplink-june-14-2018-timestamps.txt", false);
-//        String pcapFile = "/Users/varmarken/Development/Repositories/UCI/NetworkingGroup/smart_home_traffic/Code/Projects/SmartPlugDetector/pcap/wlan1.local.dns.pcap";
-        String pcapFile = "/Users/varmarken/temp/UCI IoT Project/June2018 experiments/tplink/tplink.wlan1.local.pcap";
-        String tpLinkPlugIp = "192.168.1.159";
-        TriggerTrafficExtractor tte = new TriggerTrafficExtractor(pcapFile, triggerTimes, tpLinkPlugIp);
-//        final PcapDumper outputter = Pcaps.openDead(DataLinkType.EN10MB, 65536).dumpOpen("/Users/varmarken/temp/traces/output/tplink-filtered.pcap");
-        final PcapDumper outputter = Pcaps.openDead(DataLinkType.EN10MB, 65536).dumpOpen("/Users/varmarken/temp/UCI IoT Project/June2018 experiments/tplink/tplink-filtered.pcap");
+        List<Instant> triggerTimes = ttfr.readTriggerTimes(triggerTimesFile, false);
+        TriggerTrafficExtractor tte = new TriggerTrafficExtractor(inputPcapFile, triggerTimes, deviceIp);
+        final PcapDumper outputter = Pcaps.openDead(DataLinkType.EN10MB, 65536).dumpOpen(outputPcapFile);
         DnsMap dnsMap = new DnsMap();
         TcpReassembler tcpReassembler = new TcpReassembler();
         tte.performExtraction(pkt -> {
@@ -46,7 +49,8 @@ public class Main {
         }, dnsMap, tcpReassembler);
         outputter.flush();
         outputter.close();
-        // ----------------------------
+        // -------------------------------------------------------------------------------------------------------------
+        // -------------------------------------------------------------------------------------------------------------
     }
 
 }