1 package edu.uci.iotproject;
3 import org.pcap4j.core.*;
5 import java.io.EOFException;
6 import java.net.UnknownHostException;
8 import java.util.concurrent.TimeoutException;
11 * This is a system that reads PCAP files to compare
12 * patterns of DNS hostnames, packet sequences, and packet
13 * lengths with training data to determine certain events
14 * or actions for smart home devices.
16 * @author Janus Varmarken
17 * @author Rahmadi Trimananda (rtrimana@uci.edu)
23 public static void main(String[] args) throws PcapNativeException, NotOpenException, EOFException, TimeoutException, UnknownHostException {
24 final String fileName = args.length > 0 ? args[0] : "/home/rtrimana/pcap_processing/smart_home_traffic/Code/Projects/SmartPlugDetector/pcap/wlan1.local.remote.dns.pcap";
25 final String trainingFileName = "./pcap/TP_LINK_LOCAL_ON_SUBSET.pcap";
26 //final String trainingFileName = "./pcap/TP_LINK_REMOTE_ON.pcap";
28 // ====== Debug code ======
30 PcapHandle trainingPcap;
32 handle = Pcaps.openOffline(fileName, PcapHandle.TimestampPrecision.NANO);
33 trainingPcap = Pcaps.openOffline(trainingFileName, PcapHandle.TimestampPrecision.NANO);
34 } catch (PcapNativeException pne) {
35 handle = Pcaps.openOffline(fileName);
36 trainingPcap = Pcaps.openOffline(trainingFileName);
39 // TODO: The followings are the way to extract multiple hostnames and their associated packet lengths lists
40 //List<String> list = new ArrayList<>();
41 //list.add("events.tplinkra.com");
42 //FlowPattern fp = new FlowPattern("TP_LINK_LOCAL_ON", list, trainingPcap);
43 //List<String> list2 = new ArrayList<>();
44 //list2.add("devs.tplinkcloud.com");
45 //list2.add("events.tplinkra.com");
46 //FlowPattern fp3 = new FlowPattern("TP_LINK_REMOTE_ON", list2, trainingPcap);
48 FlowPattern fp = new FlowPattern("TP_LINK_LOCAL_ON", "events.tplinkra.com", trainingPcap);
49 FlowPatternFinder fpf = new FlowPatternFinder(handle, fp);
52 // ========================