Adding a parameter to easily change epsilon and cluster bounds.
authorrtrimana <rtrimana@uci.edu>
Sat, 4 Jan 2020 19:03:34 +0000 (11:03 -0800)
committerrtrimana <rtrimana@uci.edu>
Sat, 4 Jan 2020 19:03:34 +0000 (11:03 -0800)
Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/SignatureGenerator.java

index 15a79b78fc088b903eb45de445e23286498af302..ea3e39b41b49e24e00847d2c41481b5fc5d69917 100644 (file)
@@ -47,6 +47,10 @@ public class SignatureGenerator {
      * Directory for logging.
      */
     private static String LOG_DIRECTORY = "./";
+    /**
+     * Multiplier for cluster bounds.
+     */
+    private static float CLUSTER_BOUNDS_MULTIPLIER = 0.1f;
 
     public static void main(String[] args) throws PcapNativeException, NotOpenException, EOFException,
             TimeoutException, UnknownHostException, IOException {
@@ -214,10 +218,8 @@ public class SignatureGenerator {
         // Perform clustering on conversation logged as part of all ON events.
         // Calculate number of events per type (only ON/only OFF), which means half of the number of all timestamps.
         int numberOfEventsPerType = triggerTimes.size() / 2;
-//        int lowerBound = numberOfEventsPerType - (int)(numberOfEventsPerType * 0.1);
-//        int upperBound = numberOfEventsPerType + (int)(numberOfEventsPerType * 0.1);
-        int lowerBound = numberOfEventsPerType - (int)(numberOfEventsPerType * 0.2);
-        int upperBound = numberOfEventsPerType + (int)(numberOfEventsPerType * 0.2);
+        int lowerBound = numberOfEventsPerType - (int)(numberOfEventsPerType * CLUSTER_BOUNDS_MULTIPLIER);
+        int upperBound = numberOfEventsPerType + (int)(numberOfEventsPerType * CLUSTER_BOUNDS_MULTIPLIER);
         int minPts = lowerBound;
         DBSCANClusterer<PcapPacketPair> onClusterer = new DBSCANClusterer<>(eps, minPts);
         List<Cluster<PcapPacketPair>> onClusters = onClusterer.cluster(onPairs);