|
@@ -443,7 +443,7 @@ public class MenuBarNetworkExamples extends JMenu{
|
|
|
*/
|
|
|
SmartDevice router = networkController.createSmartDevice("Wifi-Router", 500, 100, 50);
|
|
|
SmartDevice zigBeeRouter = networkController.createSmartDevice("ZigBee-Router", 500, 300, 50);
|
|
|
- SmartDevice broker = networkController.createSmartDevice("Broker", 500, 500, 50);
|
|
|
+ SmartDevice broker = networkController.createSmartDevice("SmartHub", 500, 500, 50);
|
|
|
|
|
|
/*
|
|
|
* Links/Networks
|
|
@@ -540,8 +540,8 @@ public class MenuBarNetworkExamples extends JMenu{
|
|
|
kitchenFridge.setFSinfoName("home/kitchen/fridgeTemp");
|
|
|
networkController.addLinkToDevice(zigbee, kitchenFridge);
|
|
|
networkController.moveSmartDevice(kitchenFridge, 100, 600, 50);
|
|
|
- kitchenFridge.setFSmin(-4.0f);
|
|
|
- kitchenFridge.setFSmax(12.0f);
|
|
|
+ kitchenFridge.setFSmin(-6.0f);
|
|
|
+ kitchenFridge.setFSmax(-4.0f);
|
|
|
networkController.addSmartDevice(kitchenFridge);
|
|
|
Port pKitchenFridge = new Port(kitchenFridge, (short)1883, 15000);
|
|
|
pKitchenFridge.setStatus(Port.SENDING);
|
|
@@ -659,6 +659,8 @@ public class MenuBarNetworkExamples extends JMenu{
|
|
|
|
|
|
System.out.println("Check 3: created Controller");//TODO
|
|
|
|
|
|
+ long currentTime = System.currentTimeMillis();
|
|
|
+
|
|
|
long hour = 60 * 60 * 1000;
|
|
|
/*
|
|
|
* Simulate 24 hours
|
|
@@ -670,63 +672,90 @@ public class MenuBarNetworkExamples extends JMenu{
|
|
|
sim.setPrintPackets(false);
|
|
|
sim.setEndTime(24*hour);
|
|
|
|
|
|
-
|
|
|
+ kitchenFridge.setFSmin(-6f);
|
|
|
+ kitchenFridge.setFSmax(-4f);
|
|
|
+ kitchenFridge.setFSval(-5f);
|
|
|
+ System.out.println("Training:");//TODO
|
|
|
for(int i=0; i<24; i++)
|
|
|
sim.getSimulationManager().simulateTimeIntervall(i*hour, hour);
|
|
|
-
|
|
|
+
|
|
|
+ long new_time = System.currentTimeMillis();
|
|
|
+ long elapsed_time = new_time-currentTime;
|
|
|
+ System.out.println("Training data generation: "+elapsed_time+"ms");
|
|
|
+ currentTime = new_time;
|
|
|
+
|
|
|
collectorKNN.setMode(true);
|
|
|
//collectorEM.setMode(true);
|
|
|
//collectorHC.setMode(true);
|
|
|
+ new_time = System.currentTimeMillis();
|
|
|
+ elapsed_time = new_time-currentTime;
|
|
|
+ System.out.println("Training of algorithm: "+elapsed_time+"ms");
|
|
|
+ currentTime = new_time;
|
|
|
+
|
|
|
|
|
|
- System.out.println("Check 4: Trained");//TODO
|
|
|
|
|
|
/*
|
|
|
* Simulate/Test 1 hour without anomalies
|
|
|
*/
|
|
|
|
|
|
+ System.out.println("Test w/0 anomalies:");//TODO
|
|
|
for(int i=24; i<25; i++)
|
|
|
sim.getSimulationManager().simulateTimeIntervall(hour*i, hour);
|
|
|
- System.out.println("Check 5: tested w/0 anomalies");//TODO
|
|
|
|
|
|
- /**
|
|
|
- * Value Anomaly 1h
|
|
|
- */
|
|
|
- System.out.println("Value Anomalies:");
|
|
|
- float min = kitchenFridge.getFSmin();
|
|
|
- float max = kitchenFridge.getFSmax();
|
|
|
- float val = kitchenFridge.getFSval();
|
|
|
- kitchenFridge.setFSmin(18);
|
|
|
- kitchenFridge.setFSval(18);
|
|
|
- kitchenFridge.setFSmax(30);
|
|
|
- kitchenFridge.setLabel((short)1);
|
|
|
- for(int i=25; i<26; i++)
|
|
|
- sim.getSimulationManager().simulateTimeIntervall(hour*i, hour);
|
|
|
- kitchenFridge.setFSmin(min);
|
|
|
- kitchenFridge.setFSmax(max);
|
|
|
- kitchenFridge.setFSval(val);
|
|
|
- kitchenFridge.setLabel((short)0);
|
|
|
+ new_time = System.currentTimeMillis();
|
|
|
+ elapsed_time = new_time-currentTime;
|
|
|
+ System.out.println("Training data generation: "+elapsed_time+"ms");
|
|
|
+ currentTime = new_time;
|
|
|
|
|
|
System.out.println("DDoS:");
|
|
|
/**
|
|
|
* 1 hour DDoS
|
|
|
*/
|
|
|
Connection ddos = anomalyController.openDDosCreationMenu(broker, new LinkedList<SmartDevice>(zigbee.getDevices()));
|
|
|
- for(int i=26; i<27; i++)
|
|
|
+ for(int i=25; i<26; i++)
|
|
|
sim.getSimulationManager().simulateTimeIntervall(hour*i, hour);
|
|
|
networkController.deleteConnection(ddos);
|
|
|
|
|
|
+ new_time = System.currentTimeMillis();
|
|
|
+ elapsed_time = new_time-currentTime;
|
|
|
+ System.out.println("DDoS generation & classification: "+elapsed_time+"ms");
|
|
|
+ currentTime = new_time;
|
|
|
+
|
|
|
System.out.println("DoS:");
|
|
|
/**
|
|
|
* 1 hour DoS
|
|
|
*/
|
|
|
Connection dos = anomalyController.runDosAttack(kitchenLight, kitchenFridge);
|
|
|
+ for(int i=26; i<27; i++)
|
|
|
+ sim.getSimulationManager().simulateTimeIntervall(hour*i, hour);
|
|
|
+ networkController.deleteConnection(dos);
|
|
|
+
|
|
|
+ new_time = System.currentTimeMillis();
|
|
|
+ elapsed_time = new_time-currentTime;
|
|
|
+ System.out.println("DoS generation & classification: "+elapsed_time+"ms");
|
|
|
+ currentTime = new_time;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Value Anomaly 1h
|
|
|
+ */
|
|
|
+ System.out.println("Value Anomalies:");
|
|
|
+ float min = kitchenFridge.getFSmin();
|
|
|
+ float max = kitchenFridge.getFSmax();
|
|
|
+ float val = kitchenFridge.getFSval();
|
|
|
+ kitchenFridge.setFSmin(18);
|
|
|
+ kitchenFridge.setFSval(18.5f);
|
|
|
+ kitchenFridge.setFSmax(24);
|
|
|
+ kitchenFridge.setLabel((short)1);
|
|
|
for(int i=27; i<28; i++)
|
|
|
sim.getSimulationManager().simulateTimeIntervall(hour*i, hour);
|
|
|
- networkController.addConnection(dos);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- System.out.println("Check 6: Tested w anomalies");//TODO
|
|
|
+ kitchenFridge.setFSmin(min);
|
|
|
+ kitchenFridge.setFSmax(max);
|
|
|
+ kitchenFridge.setFSval(val);
|
|
|
+ kitchenFridge.setLabel((short)0);
|
|
|
+
|
|
|
+ elapsed_time = new_time-currentTime;
|
|
|
+ System.out.println("Anomaly generation & classification: "+elapsed_time+"ms");
|
|
|
+ currentTime = new_time;
|
|
|
|
|
|
System.out.println("Testing completed");
|
|
|
} catch(Exception e) {
|