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 -> {
}, dnsMap, tcpReassembler);
outputter.flush();
outputter.close();
- // ----------------------------
+ // -------------------------------------------------------------------------------------------------------------
+ // -------------------------------------------------------------------------------------------------------------
}
}