Browse Source

Updates Paper example

24h training
1h per anomaly
Adds value anomaly
Andreas T. Meyer-Berg 4 years ago
parent
commit
72eeb0cdaa

+ 3 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/ConnectionPerformance.java

@@ -113,7 +113,9 @@ public class ConnectionPerformance implements Connection {
 	
 	@Override
 	public Collection<Packet> encapsulatePackages(Collection<Packet> packets) {
-		packets.forEach(p->p.setLabel(label));
+		packets.forEach(p->{
+			p.setLabel((short) Math.max(label, p.getSource().getOwner().getLabel()));
+		});
 		return packets;
 	}
 

+ 21 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/SmartDevice.java

@@ -10,7 +10,12 @@ import java.util.List;
  * @author Andreas T. Meyer-Berg
  */
 public class SmartDevice {
-
+	
+	/**
+	 * Label
+	 */
+	protected short label = 0;
+	
 	/**
 	 * Name of the Device
 	 */
@@ -204,5 +209,20 @@ public class SmartDevice {
 	public void removePort(Port port) {
 		this.ports.remove(port);
 	}
+	
+	/**
+	 * @return label
+	 */
+	public short getLabel() {
+		return label;
+	}
+	
+	/**
+	 * Sets the label
+	 * @param label label to set
+	 */
+	public void setLabel(Short label) {
+		this.label = label;
+	}
 
 }

+ 41 - 16
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/menuBar/MenuBarNetworkExamples.java

@@ -659,18 +659,20 @@ public class MenuBarNetworkExamples extends JMenu{
 
 			System.out.println("Check 3: created Controller");//TODO
 			
+			long hour = 60 * 60 * 1000;
 			/*
-			 * Simulate 150000 ms (2 1/2 minutes)
+			 * Simulate 24 hours
 			 */
 			SimulationController sim = controller.getSimulationController();
 			sim.setStartTime(0);
 			sim.resetSimulation();
-			sim.setStepDuration(15000);
+			sim.setStepDuration(hour);
 			sim.setPrintPackets(false);
-			sim.setEndTime(150000);
+			sim.setEndTime(24*hour);
 
-			for(int i=0; i<10; i++)
-				sim.getSimulationManager().simulateTimeIntervall(15000*i, 15000);
+			
+			for(int i=0; i<24; i++)
+				sim.getSimulationManager().simulateTimeIntervall(i*hour, hour);
 
 			collectorKNN.setMode(true);
 			//collectorEM.setMode(true);
@@ -679,27 +681,50 @@ public class MenuBarNetworkExamples extends JMenu{
 			System.out.println("Check 4: Trained");//TODO
 			
 			/*
-			 * Simulate/Test 30000 without anomalies
+			 * Simulate/Test 1 hour without anomalies
 			 */
 
-			for(int i=10; i<12; i++)
-				sim.getSimulationManager().simulateTimeIntervall(15000*i, 15000);
+			for(int i=24; i<25; i++)
+				sim.getSimulationManager().simulateTimeIntervall(hour*i, hour);
 			System.out.println("Check 5: tested w/0 anomalies");//TODO
 			
 			/**
-			 * Insert anomaly & Simulate further packets
+			 * Value Anomaly 1h
 			 */
-			Connection ddos = anomalyController.openDDosCreationMenu(broker, new LinkedList<SmartDevice>(zigbee.getDevices()));
-			Connection dos = anomalyController.runDosAttack(kitchenLight, kitchenFridge);
+			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);
+			
+			System.out.println("DDoS:");
 			/**
-			 * Start Testing another 30000
+			 * 1 hour DDoS
 			 */
-			sim.setEndTime(210000);
+			Connection ddos = anomalyController.openDDosCreationMenu(broker, new LinkedList<SmartDevice>(zigbee.getDevices()));	
+			for(int i=26; i<27; i++)
+				sim.getSimulationManager().simulateTimeIntervall(hour*i, hour);
+			networkController.deleteConnection(ddos);
 			
+			System.out.println("DoS:");
+			/**
+			 * 1 hour DoS
+			 */
+			Connection dos = anomalyController.runDosAttack(kitchenLight, kitchenFridge);
+			for(int i=27; i<28; i++)
+				sim.getSimulationManager().simulateTimeIntervall(hour*i, hour);
+			networkController.addConnection(dos);
+
 
-			for(int i=12; i<14; i++)
-				sim.getSimulationManager().simulateTimeIntervall(15000*i, 15000);
-			
 
 			System.out.println("Check 6: Tested w anomalies");//TODO