Checking in new files and new entries for Blossom sprinkler.
authorrtrimana <rtrimana@uci.edu>
Fri, 11 Jan 2019 02:08:04 +0000 (18:08 -0800)
committerrtrimana <rtrimana@uci.edu>
Fri, 11 Jan 2019 02:08:04 +0000 (18:08 -0800)
Code/Projects/SmartPlugDetector/.idea/encodings.xml [new file with mode: 0644]
Code/Projects/SmartPlugDetector/.idea/modules/SmartPlugDetector_main.iml
Code/Projects/SmartPlugDetector/.idea/modules/SmartPlugDetector_test.iml
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/TcpReassembler.java
Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/detection/SignatureDetector.java
automation/browser.sh
python_ml/validate-detection.py

diff --git a/Code/Projects/SmartPlugDetector/.idea/encodings.xml b/Code/Projects/SmartPlugDetector/.idea/encodings.xml
new file mode 100644 (file)
index 0000000..15a15b2
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" addBOMForNewFiles="with NO BOM" />
+</project>
\ No newline at end of file
index 9353a45..15e9a30 100644 (file)
@@ -5,7 +5,6 @@
     <exclude-output />
     <content url="file://$MODULE_DIR$/../../src/main">
       <sourceFolder url="file://$MODULE_DIR$/../../src/main/java" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/../../src/main/resources" type="java-resource" />
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
index d10f1b0..d8e4114 100644 (file)
@@ -5,7 +5,6 @@
     <exclude-output />
     <content url="file://$MODULE_DIR$/../../src/test">
       <sourceFolder url="file://$MODULE_DIR$/../../src/test/java" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/../../src/test/resources" type="java-test-resource" />
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
index 530bbd1..5b9a54e 100644 (file)
@@ -127,11 +127,11 @@ public class Main {
 //        final String triggerTimesFile = path + "/2018-07/wemoinsight/wemo-insight-july-31-2018.timestamps";
 //        final String deviceIp = "192.168.1.135";
         // TODO: EXPERIMENT - November 21, 2018
-        final String inputPcapFile = path + "/experimental_result/standalone/wemo-insight-plug/wlan1/wemo-insight-plug.wlan1.local.pcap";
-        final String outputPcapFile = path + "/experimental_result/standalone/wemo-insight-plug/wlan1/wemo-insight-plug-processed.pcap";
-        final String triggerTimesFile = path + "/experimental_result/standalone/wemo-insight-plug/timestamps/wemo-insight-plug-nov-21-2018.timestamps";
-//        final String deviceIp = "192.168.1.145"; // .246 == phone; .135 == WeMo Insight
-        final String deviceIp = "192.168.1.246"; // .246 == phone; .135 == WeMo Insight
+//        final String inputPcapFile = path + "/experimental_result/standalone/wemo-insight-plug/wlan1/wemo-insight-plug.wlan1.local.pcap";
+//        final String outputPcapFile = path + "/experimental_result/standalone/wemo-insight-plug/wlan1/wemo-insight-plug-processed.pcap";
+//        final String triggerTimesFile = path + "/experimental_result/standalone/wemo-insight-plug/timestamps/wemo-insight-plug-nov-21-2018.timestamps";
+////        final String deviceIp = "192.168.1.145"; // .246 == phone; .135 == WeMo Insight
+//        final String deviceIp = "192.168.1.246"; // .246 == phone; .135 == WeMo Insight
 
         // 6) TP-Link Bulb August 1 experiment
 //        final String inputPcapFile = path + "/2018-08/tplink-bulb/tplinkbulb.wlan1.local.pcap";
@@ -228,11 +228,16 @@ public class Main {
 //        final String outputPcapFile = path + "/2018-08/blossom/blossom-processed.pcap";
 //        final String triggerTimesFile = path + "/2018-08/blossom/blossom-aug-13-2018.timestamps";
 //        final String deviceIp = "192.168.1.229"; // .246 == phone; .229 == sprinkler
-        // 2 November
+//        // 2 November
 //        final String inputPcapFile = path + "/2018-10/blossom-sprinkler/blossom-sprinkler.wlan1.local.pcap";
 //        final String outputPcapFile = path + "/2018-10/blossom-sprinkler/blossom-sprinkler-processed.pcap";
 //        final String triggerTimesFile = path + "/2018-10/blossom-sprinkler/blossom-sprinkler-nov-2-2018.timestamps";
 //        final String deviceIp = "192.168.1.229"; // .246 == phone; .229 == sprinkler
+        // January 9
+        final String inputPcapFile = path + "/experimental_result/standalone/blossom-sprinkler/wlan1/blossom-sprinkler.wlan1.local.pcap";
+        final String outputPcapFile = path + "/experimental_result/standalone/blossom-sprinkler/wlan1/blossom-sprinkler-processed.pcap";
+        final String triggerTimesFile = path + "/experimental_result/standalone/blossom-sprinkler/timestamps/blossom-sprinkler-standalone-jan-9-2018.timestamps";
+        final String deviceIp = "192.168.1.246"; // .246 == phone; .229 == sprinkler
 
 //        // 13) DLink siren August 14 experiment
 //        final String inputPcapFile = path + "/2018-08/dlink-siren/dlink-siren.wlan1.local.pcap";
@@ -348,26 +353,96 @@ public class Main {
          * sequence identifiers as we do not care about hostnames and sequences during clustering.
          * We can simply use the UserAction->List<Conversation> map to generate ON/OFF groupings of conversations.
          */
-        /*
-        // Contains all ON events: hostname -> sequence identifier -> list of conversations with that sequence
-        Map<String, Map<String, List<Conversation>>> ons = new HashMap<>();
-        // Contains all OFF events: hostname -> sequence identifier -> list of conversations with that sequence
-        Map<String, Map<String, List<Conversation>>> offs = new HashMap<>();
-        userActionsToConvsByHostname.forEach((ua, hostnameToConvs) -> {
-            Map<String, Map<String, List<Conversation>>> outer = ua.getType() == Type.TOGGLE_ON ? ons : offs;
-            hostnameToConvs.forEach((host, convs) -> {
-                Map<String, List<Conversation>> seqsToConvs = TcpConversationUtils.
-                        groupConversationsByPacketSequence(convs, verbose);
-                outer.merge(host, seqsToConvs, (oldMap, newMap) -> {
-                    newMap.forEach((sequence, cs) -> oldMap.merge(sequence, cs, (list1, list2) -> {
-                        list1.addAll(list2);
-                        return list1;
-                    }));
-                    return oldMap;
-                });
-            });
-        });
-        */
+
+//        // Contains all ON events: hostname -> sequence identifier -> list of conversations with that sequence
+//        Map<String, Map<String, List<Conversation>>> ons = new HashMap<>();
+//        // Contains all OFF events: hostname -> sequence identifier -> list of conversations with that sequence
+//        Map<String, Map<String, List<Conversation>>> offs = new HashMap<>();
+//        userActionsToConvsByHostname.forEach((ua, hostnameToConvs) -> {
+//            Map<String, Map<String, List<Conversation>>> outer = ua.getType() == Type.TOGGLE_ON ? ons : offs;
+//            hostnameToConvs.forEach((host, convs) -> {
+//                Map<String, List<Conversation>> seqsToConvs = TcpConversationUtils.
+//                        groupConversationsByPacketSequence(convs, verbose);
+//                outer.merge(host, seqsToConvs, (oldMap, newMap) -> {
+//                    newMap.forEach((sequence, cs) -> oldMap.merge(sequence, cs, (list1, list2) -> {
+//                        list1.addAll(list2);
+//                        return list1;
+//                    }));
+//                    return oldMap;
+//                });
+//            });
+//        });
+//
+//        System.out.println("==== ON ====");
+//        // Print out all the pairs into a file for ON events
+//        File fileOnEvents = new File(onPairsPath);
+//        PrintWriter pwOn = null;
+//        try {
+//            pwOn = new PrintWriter(fileOnEvents);
+//        } catch(Exception ex) {
+//            ex.printStackTrace();
+//        }
+//        for(Map.Entry<String, Map<String, List<Conversation>>> entry : ons.entrySet()) {
+//            Map<String, List<Conversation>> seqsToConvs = entry.getValue();
+//            for(Map.Entry<String, List<Conversation>> entryConv : seqsToConvs.entrySet()) {
+//                List<Conversation> listConv = entryConv.getValue();
+//                // Just get the first Conversation because all Conversations in this group
+//                // should have the same pairs of Application Data.
+//                for(Conversation conv : listConv) {
+//                    // Process only if it is a TLS packet
+//                    if (conv.isTls()) {
+//                        List<PcapPacketPair> tlsAppDataList = TcpConversationUtils.extractTlsAppDataPacketPairs(conv);
+//                        for(PcapPacketPair pair: tlsAppDataList) {
+//                            System.out.println(PrintUtils.toCsv(pair, dnsMap));
+//                            pwOn.println(PrintUtils.toCsv(pair, dnsMap));
+//                        }
+//                    } else { // Non-TLS conversations
+//                        List<PcapPacketPair> packetList = TcpConversationUtils.extractPacketPairs(conv);
+//                        for(PcapPacketPair pair: packetList) {
+//                            System.out.println(PrintUtils.toCsv(pair, dnsMap));
+//                            pwOn.println(PrintUtils.toCsv(pair, dnsMap));
+//                        }
+//                    }
+//                }
+//            }
+//        }
+//        pwOn.close();
+//
+//        System.out.println("==== OFF ====");
+//        // Print out all the pairs into a file for ON events
+//        File fileOffEvents = new File(offPairsPath);
+//        PrintWriter pwOff = null;
+//        try {
+//            pwOff = new PrintWriter(fileOffEvents);
+//        } catch(Exception ex) {
+//            ex.printStackTrace();
+//        }
+//        for(Map.Entry<String, Map<String, List<Conversation>>> entry : offs.entrySet()) {
+//            Map<String, List<Conversation>> seqsToConvs = entry.getValue();
+//            for(Map.Entry<String, List<Conversation>> entryConv : seqsToConvs.entrySet()) {
+//                List<Conversation> listConv = entryConv.getValue();
+//                // Just get the first Conversation because all Conversations in this group
+//                // should have the same pairs of Application Data.
+//                for(Conversation conv : listConv) {
+//                    // Process only if it is a TLS packet
+//                    if (conv.isTls()) {
+//                        List<PcapPacketPair> tlsAppDataList = TcpConversationUtils.extractTlsAppDataPacketPairs(conv);
+//                        for(PcapPacketPair pair: tlsAppDataList) {
+//                            System.out.println(PrintUtils.toCsv(pair, dnsMap));
+//                            pwOff.println(PrintUtils.toCsv(pair, dnsMap));
+//                        }
+//                    } else { // Non-TLS conversations
+//                        List<PcapPacketPair> packetList = TcpConversationUtils.extractPacketPairs(conv);
+//                        for (PcapPacketPair pair : packetList) {
+//                            System.out.println(PrintUtils.toCsv(pair, dnsMap));
+//                            pwOff.println(PrintUtils.toCsv(pair, dnsMap));
+//                        }
+//                    }
+//                }
+//            }
+//        }
+//        pwOff.close();
+
 
         // ================================================ CLUSTERING ================================================
         // Note: no need to use the more convoluted on/off maps; can simply use the UserAction->List<Conversation> map
@@ -398,10 +473,12 @@ public class Main {
         Stream.concat(Stream.of(onPairs), Stream.of(offPairs)).flatMap(List::stream).forEach(p -> p.setDnsMap(dnsMap));
         // Perform clustering on conversation logged as part of all ON events.
         DBSCANClusterer<PcapPacketPair> onClusterer = new DBSCANClusterer<>(10.0, 45);
+        //DBSCANClusterer<PcapPacketPair> onClusterer = new DBSCANClusterer<>(7.0, 45);
         //DBSCANClusterer<PcapPacketPair> onClusterer = new DBSCANClusterer<>(10.0, 10);
         List<Cluster<PcapPacketPair>> onClusters = onClusterer.cluster(onPairs);
         // Perform clustering on conversation logged as part of all OFF events.
         DBSCANClusterer<PcapPacketPair> offClusterer = new DBSCANClusterer<>(10.0, 45);
+        //DBSCANClusterer<PcapPacketPair> offClusterer = new DBSCANClusterer<>(7.0, 45);
         //DBSCANClusterer<PcapPacketPair> offClusterer = new DBSCANClusterer<>(10.0, 10);
         List<Cluster<PcapPacketPair>> offClusters = offClusterer.cluster(offPairs);
         // Sort the conversations as reference
@@ -426,6 +503,12 @@ public class Main {
         // TODO: Merging test
         ppListOfListListOn = PcapPacketUtils.mergeSignatures(ppListOfListListOn, sortedAllConversation);
         ppListOfListListOn = PcapPacketUtils.sortSignatures(ppListOfListListOn);
+        // TODO: Need to remove sequence numbers 0,1 for Blossom phone side since it is not a good signature!
+        PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 0);
+        PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 1);
+        // TODO: Need to remove sequence numbers 0 for Blossom device side since it is not a good signature!
+        //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 0);
+        //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 0);
         // TODO: Need to remove sequence number 2 for ST plug since it is not a good signature!
         //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOn, 2);
         // TODO: Need to remove sequence number 0 for Arlo Camera since it is not a good signature!
@@ -461,6 +544,9 @@ public class Main {
         // TODO: Merging test
         ppListOfListListOff = PcapPacketUtils.mergeSignatures(ppListOfListListOff, sortedAllConversation);
         //ppListOfListListOff = PcapPacketUtils.sortSignatures(ppListOfListListOff);
+        // TODO: Need to remove sequence numbers 0,2 for Blossom device side since it is not a good signature!
+        //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOff, 0);
+        //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOff, 2);
         // TODO: Need to remove sequence number 1 for Nest Thermostat since it is not a good signature!
         //PcapPacketUtils.removeSequenceFromSignature(ppListOfListListOff, 1);
         // TODO: Need to remove sequence number 0 for Arlo Camera since it is not a good signature!
@@ -481,77 +567,6 @@ public class Main {
         System.out.println("========================================");
         // ============================================================================================================
 
-        /*
-        System.out.println("==== ON ====");
-        // Print out all the pairs into a file for ON events
-        File fileOnEvents = new File(onPairsPath);
-        PrintWriter pwOn = null;
-        try {
-            pwOn = new PrintWriter(fileOnEvents);
-        } catch(Exception ex) {
-            ex.printStackTrace();
-        }
-        for(Map.Entry<String, Map<String, List<Conversation>>> entry : ons.entrySet()) {
-            Map<String, List<Conversation>> seqsToConvs = entry.getValue();
-            for(Map.Entry<String, List<Conversation>> entryConv : seqsToConvs.entrySet()) {
-                List<Conversation> listConv = entryConv.getValue();
-                // Just get the first Conversation because all Conversations in this group
-                // should have the same pairs of Application Data.
-                for(Conversation conv : listConv) {
-                    // Process only if it is a TLS packet
-                    if (conv.isTls()) {
-                        List<PcapPacketPair> tlsAppDataList = TcpConversationUtils.extractTlsAppDataPacketPairs(conv);
-                        for(PcapPacketPair pair: tlsAppDataList) {
-                            System.out.println(PrintUtils.toCsv(pair, dnsMap));
-                            pwOn.println(PrintUtils.toCsv(pair, dnsMap));
-                        }
-                    } else { // Non-TLS conversations
-                        List<PcapPacketPair> packetList = TcpConversationUtils.extractPacketPairs(conv);
-                        for(PcapPacketPair pair: packetList) {
-                            System.out.println(PrintUtils.toCsv(pair, dnsMap));
-                            pwOn.println(PrintUtils.toCsv(pair, dnsMap));
-                        }
-                    }
-                }
-            }
-        }
-        pwOn.close();
-
-        System.out.println("==== OFF ====");
-        // Print out all the pairs into a file for ON events
-        File fileOffEvents = new File(offPairsPath);
-        PrintWriter pwOff = null;
-        try {
-            pwOff = new PrintWriter(fileOffEvents);
-        } catch(Exception ex) {
-            ex.printStackTrace();
-        }
-        for(Map.Entry<String, Map<String, List<Conversation>>> entry : offs.entrySet()) {
-            Map<String, List<Conversation>> seqsToConvs = entry.getValue();
-            for(Map.Entry<String, List<Conversation>> entryConv : seqsToConvs.entrySet()) {
-                List<Conversation> listConv = entryConv.getValue();
-                // Just get the first Conversation because all Conversations in this group
-                // should have the same pairs of Application Data.
-                for(Conversation conv : listConv) {
-                    // Process only if it is a TLS packet
-                    if (conv.isTls()) {
-                        List<PcapPacketPair> tlsAppDataList = TcpConversationUtils.extractTlsAppDataPacketPairs(conv);
-                        for(PcapPacketPair pair: tlsAppDataList) {
-                            System.out.println(PrintUtils.toCsv(pair, dnsMap));
-                            pwOff.println(PrintUtils.toCsv(pair, dnsMap));
-                        }
-                    } else { // Non-TLS conversations
-                        List<PcapPacketPair> packetList = TcpConversationUtils.extractPacketPairs(conv);
-                        for (PcapPacketPair pair : packetList) {
-                            System.out.println(PrintUtils.toCsv(pair, dnsMap));
-                            pwOff.println(PrintUtils.toCsv(pair, dnsMap));
-                        }
-                    }
-                }
-            }
-        }
-        pwOff.close();
-        */
 
 //        // ================================================================================================
 //        // <<< Some work-in-progress/explorative code that extracts a "representative" sequence >>>
index f97ef47..72f0c1c 100644 (file)
@@ -2,8 +2,7 @@ package edu.uci.iotproject;
 
 import org.pcap4j.core.PacketListener;
 import org.pcap4j.core.PcapPacket;
-import org.pcap4j.packet.IpV4Packet;
-import org.pcap4j.packet.TcpPacket;
+import org.pcap4j.packet.*;
 
 import java.util.*;
 
@@ -42,11 +41,21 @@ public class TcpReassembler implements PacketListener {
     public void gotPacket(PcapPacket pcapPacket) {
         IpV4Packet ipPacket = pcapPacket.get(IpV4Packet.class);
         TcpPacket tcpPacket = pcapPacket.get(TcpPacket.class);
+
         if (ipPacket == null || tcpPacket == null) {
             return;
         }
         // ... TODO?
         processPacket(pcapPacket);
+//        Class clazz = pcapPacket.getClass();
+//        RadiotapPacket radiotapPacket = pcapPacket.get(RadiotapPacket.class);
+//        Dot11ManagementPacket dot11ManagementPacket = pcapPacket.get(Dot11ManagementPacket.class);
+//        if (dot11ManagementPacket != null) {
+//            return;
+//        }
+//        if (radiotapPacket != null) {
+//            processRadiotapPacket(pcapPacket);
+//        }
     }
 
     /**
@@ -61,6 +70,19 @@ public class TcpReassembler implements PacketListener {
         return combined;
     }
 
+    private void processRadiotapPacket(PcapPacket pcapPacket) {
+        RadiotapPacket radiotapPacket = pcapPacket.get(RadiotapPacket.class);
+
+        RadiotapPacket.RadiotapHeader header = radiotapPacket.getHeader();
+        short length = header.getLength();
+        ArrayList<RadiotapPacket.RadiotapData> radiotapData = header.getDataFields();
+        // TODO: We can handle this 802.11 QoS data by creating our own class
+        // TODO: We only need to handle the first few bytes for source, destination, receiver, and transmitter
+        // TODO: addresses
+        Packet dataPacket = radiotapPacket.getPayload();
+        int dataLength = dataPacket.length();
+    }
+
     private void processPacket(PcapPacket pcapPacket) {
         TcpPacket tcpPacket = pcapPacket.get(TcpPacket.class);
         // Handle client connection initiation attempts.
@@ -151,8 +173,8 @@ public class TcpReassembler implements PacketListener {
         if (!conv.isRetransmission(srvSynPacket) && !conv.addSynPacket(srvSynPacket)) {
             // For safety/debugging: if NOT a retransmission and add fails,
             // something has gone terribly wrong/invariant is broken.
-            throw new AssertionError("Attempt to add SYN ACK packet that was NOT a retransmission failed." +
-                    Conversation.class.getSimpleName() + " invariant broken.");
+//            throw new AssertionError("Attempt to add SYN ACK packet that was NOT a retransmission failed." +
+//                    Conversation.class.getSimpleName() + " invariant broken.");
         }
     }
 
index 7becdd0..fb3e67e 100644 (file)
@@ -29,17 +29,17 @@ public class SignatureDetector implements PacketListener, ClusterMatcher.Cluster
 
     // Test client
     public static void main(String[] args) throws PcapNativeException, NotOpenException {
-        if (args.length < 3) {
-            String errMsg = String.format("Usage: %s inputPcapFile onSignatureFile offSignatureFile",
-                    SignatureDetector.class.getSimpleName());
-            System.out.println(errMsg);
-            return;
-        }
-        final String inputPcapFile = args[0];
-        final String onSignatureFile = args[1];
-        final String offSignatureFile = args[2];
-
-//        String path = "/scratch/July-2018"; // Rahmadi
+//        if (args.length < 3) {
+//            String errMsg = String.format("Usage: %s inputPcapFile onSignatureFile offSignatureFile",
+//                    SignatureDetector.class.getSimpleName());
+//            System.out.println(errMsg);
+//            return;
+//        }
+//        final String inputPcapFile = args[0];
+//        final String onSignatureFile = args[1];
+//        final String offSignatureFile = args[2];
+
+        String path = "/scratch/July-2018"; // Rahmadi
 //        String path = "/Users/varmarken/temp/UCI IoT Project/experiments"; // Janus
 //        String path = "/home/jvarmark/iot_project/datasets"; // Hera (server)
 //        String path = "/raid/varmarken/iot_project/datasets"; // Zeus (server)
@@ -84,15 +84,24 @@ public class SignatureDetector implements PacketListener, ClusterMatcher.Cluster
 //        final String offSignatureFile = path + "/2018-07/dlink/offSignature-DLink-Plug-phone.sig";
 
         // TODO: The following are negative tests against the PCAP file from UNSW
-//                final String inputPcapFile = path + "/UNSW/16-09-28.pcap"; // TODO: Seems to be broken!
-//                final String inputPcapFile = path + "/UNSW/16-10-02.pcap"; // TODO: Seems to be broken!
-//                final String inputPcapFile = path + "/UNSW/16-10-03.pcap"; // TODO: Seems to be broken!
-//                final String inputPcapFile = path + "/UNSW/16-10-04.pcap"; // TODO: Seems to be broken!
-//                final String inputPcapFile = path + "/UNSW/16-10-07.pcap"; // TODO: Seems to be broken!
-//                final String inputPcapFile = path + "/UNSW/16-10-08.pcap"; // TODO: Seems to be broken!
-//                final String inputPcapFile = path + "/UNSW/16-10-09.pcap"; // TODO: Seems to be broken!
-//                final String inputPcapFile = path + "/UNSW/16-10-10.pcap"; // TODO: Seems to be broken!
-//                final String inputPcapFile = path + "/UNSW/16-10-11.pcap"; // TODO: Seems to be broken!
+//        final String inputPcapFile = path + "/UNSW/16-10-04.pcap"; // TODO: Seems to be broken! Zero-payload!
+//        final String inputPcapFile = path + "/UNSW/16-10-12.pcap";
+
+//        final String inputPcapFile = path + "/UNSW/16-09-28.pcap"; // TODO: Seems to be broken! Zero-payload!
+//        final String inputPcapFile = path + "/UNSW/16-10-02.pcap"; // TODO: Seems to be broken!
+//        final String inputPcapFile = path + "/UNSW/16-10-03.pcap"; // TODO: Seems to be broken!
+//        final String inputPcapFile = path + "/UNSW/16-10-04-a.pcap"; // TODO: Seems to be broken! Zero-payload!
+//        final String inputPcapFile = path + "/UNSW/16-10-04-b.pcap"; // TODO: Seems to be broken! Zero-payload!
+//        final String inputPcapFile = path + "/UNSW/16-10-07.pcap"; // TODO: Seems to be broken!
+//        final String inputPcapFile = path + "/UNSW/16-10-08.pcap"; // TODO: Seems to be broken!
+//        final String inputPcapFile = path + "/UNSW/16-10-09.pcap"; // TODO: Seems to be broken!
+//        final String inputPcapFile = path + "/UNSW/16-10-10.pcap"; // TODO: Seems to be broken!
+//        final String inputPcapFile = path + "/UNSW/16-10-11.pcap"; // TODO: Seems to be broken!
+        // TODO: The following one is very long!!! - Split into smaller files!
+//        final String inputPcapFile = path + "/UNSW/16-10-12-a.pcap";
+//        final String inputPcapFile = path + "/UNSW/16-10-12-b.pcap";
+//        final String inputPcapFile = path + "/UNSW/16-10-12-c.pcap";
+//        final String inputPcapFile = path + "/UNSW/16-10-12-d.pcap";
 
 //        final String inputPcapFile = path + "/UNSW/16-09-23.pcap";
 //        final String inputPcapFile = path + "/UNSW/16-09-24.pcap";
@@ -105,9 +114,6 @@ public class SignatureDetector implements PacketListener, ClusterMatcher.Cluster
         // Negative test: dataset from UNB
 //        final String inputPcapFile = path + "/evaluation/negative-datasets/UNB/Monday-WorkingHours_one-local-endpoint.pcap";
 
-        // TODO: The following one is very long!!!
-//        final String inputPcapFile = path + "/UNSW/16-10-12.pcap";
-
         // TODO: The following are tests for signatures against training data
 
         // D-Link Plug experiment
@@ -128,8 +134,8 @@ public class SignatureDetector implements PacketListener, ClusterMatcher.Cluster
 //        final String onSignatureFile = path + "/experimental_result/standalone/dlink-plug/signatures/dlink-plug-onSignature-device-side.sig";
 //        final String offSignatureFile = path + "/experimental_result/standalone/dlink-plug/signatures/dlink-plug-offSignature-device-side.sig";
         // D-Link Plug PHONE signatures
-        //final String onSignatureFile = path + "/experimental_result/standalone/dlink-plug/signatures/dlink-plug-onSignature-phone-side.sig";
-        //final String offSignatureFile = path + "/experimental_result/standalone/dlink-plug/signatures/dlink-plug-offSignature-phone-side.sig";
+//        final String onSignatureFile = path + "/experimental_result/standalone/dlink-plug/signatures/dlink-plug-onSignature-phone-side.sig";
+//        final String offSignatureFile = path + "/experimental_result/standalone/dlink-plug/signatures/dlink-plug-offSignature-phone-side.sig";
 
         // TODO: EXPERIMENT - November 9, 2018
         // D-Link Siren experiment
@@ -147,10 +153,12 @@ public class SignatureDetector implements PacketListener, ClusterMatcher.Cluster
 //        final String offSignatureFile = path + "/training/signatures/dlink-siren/dlink-siren-offSignature-phone-side.sig";
 
         // TP-Link Plug experiment
-        //final String inputPcapFile = path + "/training/tplink-plug/wlan1/tplink-plug.wlan1.local.pcap";
-        // TP-Link Plug DEVICE signatures
-        //final String onSignatureFile = path + "/training/tplink-plug/signatures/tplink-plug-onSignature-device-side.sig";
-        //final String offSignatureFile = path + "/training/tplink-plug/signatures/tplink-plug-offSignature-device-side.sig";
+////        final String inputPcapFile = path + "/training/tplink-plug/wlan1/tplink-plug.wlan1.local.pcap";
+////        final String inputPcapFile = path + "/experimental_result/wifi-Sniffer/tests2/airtool_2019-01-04_11.08.45.AM.pcap";
+//        final String inputPcapFile = path + "/experimental_result/wifi-Sniffer/tests2/command-frames-only.pcap";
+//        // TP-Link Plug DEVICE signatures
+//        final String onSignatureFile = path + "/training/tplink-plug/signatures/tplink-plug-onSignature-device-side.sig";
+//        final String offSignatureFile = path + "/training/tplink-plug/signatures/tplink-plug-offSignature-device-side.sig";
         // TODO: EXPERIMENT - November 8, 2018
         // TP-Link Plug experiment
 //        final String inputPcapFile = path + "/experimental_result/standalone/tplink-plug/wlan1/tplink-plug.wlan1.local.pcap";
@@ -208,6 +216,18 @@ public class SignatureDetector implements PacketListener, ClusterMatcher.Cluster
 //        final String onSignatureFile = path + "/training/signatures/st-plug/st-plug-onSignature-phone-side.sig";
 //        final String offSignatureFile = path + "/training/signatures/st-plug/st-plug-offSignature-phone-side.sig";
 
+        // TODO: EXPERIMENT - January 9, 2018
+        // Blossom Sprinkler experiment
+//        final String inputPcapFile = path + "/experimental_result/standalone/blossom-sprinkler/wlan1/blossom-sprinkler.wlan1.local.pcap";
+//        final String inputPcapFile = path + "/experimental_result/smarthome/blossom-sprinkler/eth0/blossom-sprinkler.eth0.detection.pcap";
+        final String inputPcapFile = path + "/experimental_result/smarthome/blossom-sprinkler/wlan1/blossom-sprinkler.wlan1.detection.pcap";
+        // Blossom Sprinkler DEVICE signatures
+//        final String onSignatureFile = path + "/experimental_result/standalone/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-device-side.sig";
+//        final String offSignatureFile = path + "/experimental_result/standalone/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-device-side.sig";
+        // Blossom Sprinkler PHONE signatures
+        final String onSignatureFile = path + "/experimental_result/standalone/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-phone-side.sig";
+        final String offSignatureFile = path + "/experimental_result/standalone/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-phone-side.sig";
+
         // LiFX Bulb experiment
 //        final String inputPcapFile = path + "/training/lifx-bulb/wlan1/lifx-bulb.wlan1.local.pcap";
 //        // LiFX Bulb DEVICE signatures
@@ -217,15 +237,13 @@ public class SignatureDetector implements PacketListener, ClusterMatcher.Cluster
 //        final String onSignatureFile = path + "/training/lifx-bulb/signatures/lifx-bulb-onSignature-phone-side.sig";
 //        final String offSignatureFile = path + "/training/lifx-bulb/signatures/lifx-bulb-offSignature-phone-side.sig";
 
-
-        /*
         // Blossom Sprinkler experiment
-        //final String inputPcapFile = path + "/training/blossom-sprinkler/wlan1/blossom-sprinkler.wlan1.local.pcap";
-        final String inputPcapFile = path + "/training/blossom-sprinkler/eth0/blossom-sprinkler.eth0.local.pcap";
-        // Blossom Sprinkler DEVICE signatures
-        final String onSignatureFile = path + "/training/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-device-side.sig";
-        final String offSignatureFile = path + "/training/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-device-side.sig";
-        */
+//        //final String inputPcapFile = path + "/training/blossom-sprinkler/wlan1/blossom-sprinkler.wlan1.local.pcap";
+//        final String inputPcapFile = path + "/2018-08/blossom/blossom.wlan1.local.pcap";
+//        //final String inputPcapFile = path + "/training/blossom-sprinkler/eth0/blossom-sprinkler.eth0.local.pcap";
+//        // Blossom Sprinkler DEVICE signatures
+//        final String onSignatureFile = path + "/training/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-device-side.sig";
+//        final String offSignatureFile = path + "/training/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-device-side.sig";
 
         // Nest Thermostat experiment
 //        final String inputPcapFile = path + "/training/nest-thermostat/wlan1/nest-thermostat.wlan1.local.pcap";
@@ -254,6 +272,7 @@ public class SignatureDetector implements PacketListener, ClusterMatcher.Cluster
         */
 
 
+
         // TP-Link Bulb experiment
 //        final String inputPcapFile = path + "/training/tplink-bulb/wlan1/tplink-bulb.wlan1.local.pcap";
 //        // TP-Link Bulb PHONE signatures
index 4d334ef..7d089a1 100755 (executable)
@@ -27,12 +27,15 @@ while true
 do
        # Choose a website randomly
        #RAND=$[( $RANDOM % $RAN_END ) + $RAN_STA]
-       RAND=$[`jot -r 1 $BRO_RAN_STA $BRO_RAN_END`]
+       #RAND=$[`jot -r 1 $BRO_RAN_STA $BRO_RAN_END`]
+       RAND=$[`shuf -i $BRO_RAN_STA-$BRO_RAN_END -n 1`]
        echo "${WEBSITE[$RAND]}"
        curl ${WEBSITE[$RAND]}
        
        # Sleep with random delay time  
-       RAND=$[`jot -r 1 $SLP_RAN_STA $SLP_RAN_END`]
+       #RAND=$[`jot -r 1 $SLP_RAN_STA $SLP_RAN_END`]
+       #RAND=$[( $RANDOM % $RAN_END ) + $RAN_STA]
+       RAND=$[`shuf -i $SLP_RAN_STA-$SLP_RAN_END -n 1`]
        echo "Delay: $RAND seconds"
        sleep $[$RAND]s
 
index 8025aff..9ddde6c 100644 (file)
@@ -88,9 +88,19 @@ path = "/scratch/July-2018/experimental_result/smarthome/"
 #device = "wemo-insight-plug/self-test"
 #fileExperiment = "wemo-insight-plug-nov-21-2018.timestamps"
 #fileDetection = "phone-side-detection"
-device = "wemo-insight-plug/timestamps"
-fileExperiment = "wemo-insight-plug-smarthome-nov-22-2018.timestamps"
-fileDetection = "wemo-insight-plug-smarthome-nov-22-2018.phone.wlan1.detections"
+#device = "wemo-insight-plug/timestamps"
+#fileExperiment = "wemo-insight-plug-smarthome-nov-22-2018.timestamps"
+#fileDetection = "wemo-insight-plug-smarthome-nov-22-2018.phone.wlan1.detections"
+
+# Blossom sprinkler
+device = "blossom-sprinkler/self-test"
+fileExperiment = "blossom-sprinkler-standalone-jan-9-2019.timestamps"
+#fileDetection = "phone-side-detection"
+#fileDetection = "device-side-detection"
+device = "blossom-sprinkler/timestamps"
+fileExperiment = "blossom-sprinkler-smarthome-jan-10-2019.timestamps"
+fileDetection = "blossom-sprinkler-smarthome-jan-10-2019.device.wlan1.detections"
+#fileDetection = "blossom-sprinkler-smarthome-jan-10-2019.phone.wlan1.detections"
 
 TIME_WINDOW = 15 # detection/signature window of 15 seconds
 #NEG_TIME_WINDOW = -15 # detection/signature window of 15 seconds