1 package edu.uci.iotproject;
3 import edu.uci.iotproject.analysis.TriggerTrafficExtractor;
4 import edu.uci.iotproject.io.TriggerTimesFileReader;
5 import org.pcap4j.core.*;
6 import org.pcap4j.packet.namednumber.DataLinkType;
8 import java.io.EOFException;
9 import java.net.UnknownHostException;
10 import java.time.Instant;
12 import java.util.concurrent.TimeoutException;
15 * This is a system that reads PCAP files to compare
16 * patterns of DNS hostnames, packet sequences, and packet
17 * lengths with training data to determine certain events
18 * or actions for smart home devices.
20 * @author Janus Varmarken
21 * @author Rahmadi Trimananda (rtrimana@uci.edu)
27 public static void main(String[] args) throws PcapNativeException, NotOpenException, EOFException, TimeoutException, UnknownHostException {
28 // -------- 07-19-2018 --------
29 TriggerTimesFileReader ttfr = new TriggerTimesFileReader();
30 // List<Instant> triggerTimes = ttfr.readTriggerTimes("/Users/varmarken/Downloads/tplink-feb-13-2018.timestamps", false);
31 List<Instant> triggerTimes = ttfr.readTriggerTimes("/Users/varmarken/temp/UCI IoT Project/June2018 experiments/tplink/tplink-june-14-2018-timestamps.txt", false);
32 // String pcapFile = "/Users/varmarken/Development/Repositories/UCI/NetworkingGroup/smart_home_traffic/Code/Projects/SmartPlugDetector/pcap/wlan1.local.dns.pcap";
33 String pcapFile = "/Users/varmarken/temp/UCI IoT Project/June2018 experiments/tplink/tplink.wlan1.local.pcap";
34 String tpLinkPlugIp = "192.168.1.159";
35 TriggerTrafficExtractor tte = new TriggerTrafficExtractor(pcapFile, triggerTimes, tpLinkPlugIp);
36 // final PcapDumper outputter = Pcaps.openDead(DataLinkType.EN10MB, 65536).dumpOpen("/Users/varmarken/temp/traces/output/tplink-filtered.pcap");
37 final PcapDumper outputter = Pcaps.openDead(DataLinkType.EN10MB, 65536).dumpOpen("/Users/varmarken/temp/UCI IoT Project/June2018 experiments/tplink/tplink-filtered.pcap");
38 DnsMap dnsMap = new DnsMap();
39 TcpReassembler tcpReassembler = new TcpReassembler();
40 tte.performExtraction(pkt -> {
43 } catch (NotOpenException e) {
46 }, dnsMap, tcpReassembler);
49 // ----------------------------
55 // TP-Link MAC 50:c7:bf:33:1f:09 and usually IP 192.168.1.159 (remember to verify per file)