Browse Source

Adds AnomalyDetectionController & Run Paper Example option

Andreas T. Meyer-Berg 4 years ago
parent
commit
691756ef1e

+ 2 - 1
examples/classifier/HierarchicalClustering.java

@@ -46,13 +46,14 @@ public class HierarchicalClustering extends BasicPacketClassifier {
 		/**
 		 * centroid instance
 		 */
+		/*
 		System.out.print(origin.getTextualRepresentation()+": ");
 		double[] posteriori = clusterer.distributionForInstance(instance);
 		for(int i = 0; i<posteriori.length; i++) {
 			System.out.print(posteriori[i]);
 			if(i<posteriori.length-1)
 				System.out.print(", ");
-		}
+		}*/
 		return 1;
 	}
 

+ 196 - 0
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/control/ExampleAnomalyController.java

@@ -0,0 +1,196 @@
+package de.tu_darmstadt.tk.SmartHomeNetworkSim.control;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPrecision;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PrecisionLink;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Protocol;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.distributionHandler.NormalDistributionHandler;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleProtocol;
+
+/**
+ * Controller, which allows the user to create a few example anomalies
+ * @author Andreas T. Meyer-Berg
+ *
+ */
+public class ExampleAnomalyController {
+
+	/**
+	 * Controller which is used to manipulates the network parts
+	 */
+	private Controller controller;
+	
+	/**
+	 * Initializes the Anomaly Controller
+	 * @param controller controller to be used
+	 */
+	public ExampleAnomalyController(Controller controller) {
+		this.controller = controller;
+	}
+
+	/**
+	 * Opens a DDosCreation Menu which targets the given Device
+	 * So far only a DDoS Attack is created
+	 * @param d Device which should be targeted
+	 * @return DDoS Connection, which was created 
+	 */
+	public Connection openDDosCreationMenu(SmartDevice d, List<SmartDevice> sources) {
+		/**
+		 * Port of the largest connected connection to disguise DDoS
+		 */
+		Port example = null;
+		for(Port p: d.getPorts()) {
+			if(example == null || example.getConnection() == null || example.getConnection().getProtocol()==null) {
+				example = p;
+			} else {
+				if(p.getConnection() == null || p.getConnection().getProtocol() == null) {
+					continue;
+				} else if(p.getConnection().getParticipants().size()>example.getConnection().getParticipants().size()){
+					example = p;
+				}
+			}
+		}
+		if(example == null || example.getConnection() == null || example.getConnection().getProtocol()==null)
+			example = null;
+		/**
+		 * Role of the target device
+		 */
+		int targetRole = 1;
+		if(example != null) {
+			targetRole = example.getConnection().getProtocol().getRoleOfDevice(example);
+			if(targetRole == -1)
+				targetRole = 1;
+		}
+		/**
+		 * Attack Interval per device
+		 */
+		long attackInterval = 1;
+		if(example!=null) {
+			int numDevices = 0;
+			for(Port exP:example.getConnection().getParticipants()) {
+				attackInterval+=exP.getTriggerInterval();
+				numDevices++;
+			}
+			attackInterval /= numDevices == 0 ? 1 : numDevices;
+			/**
+			 * Frequency Less or equal
+			 */
+			attackInterval /= 4.0;
+		}
+		
+		/**
+		 * Link of the DDoS attack
+		 */
+		Link link = null;
+		if(example !=null)
+			link = example.getConnection().getLink();
+		if(link == null) {
+			if(d.getLinks().isEmpty()) {
+				System.out.println("WARNING: Could not create DDos, as Device "+d.getName()+" is not connected to any Link");
+				return null;
+			}
+			link = d.getLinks().get(0);
+		}
+		NetworkController networkController = controller.getNetworkController();
+		Connection ddosConnection = new ConnectionPrecision();
+		ddosConnection.setLabel((short)1);
+		ddosConnection.setName("DDOS against "+d.getName());
+		networkController.addConnectionToLink(ddosConnection, link);
+		try {
+			@SuppressWarnings("unchecked")
+			Class<Protocol> exampleProtocol = (Class<Protocol>) example.getConnection().getProtocol().getClass();
+			ddosConnection.setProtocol(exampleProtocol.newInstance());	
+		} catch (Exception e) {
+			ddosConnection.setProtocol(new SimpleProtocol());			
+		}
+		LinkedList<SmartDevice> devices = new LinkedList<SmartDevice>(sources);
+		devices.retainAll(link.getDevices());
+		
+		
+		Port pTarget = new Port(d, (short)80, 1000L);
+		pTarget.setStatus(Port.OPEN);
+		if(!networkController.addDeviceToConnectionAndProtocol(pTarget, ddosConnection, targetRole)) {
+			System.out.println("WARNING: Could not add DDoS Target to role "+targetRole);
+		}
+			
+		for(SmartDevice src: devices) {
+			if(src==d)continue;
+			Port pSource = new Port(src, (short)80, 1L);
+			pSource.setTriggerHandler(new NormalDistributionHandler(attackInterval, attackInterval*0.05));
+			pSource.setStatus(Port.SENDING);
+			// Ten tries of assigning random role
+			for(int i=0; i<10;i++) {
+				int sourceRole = (int) Math.floor(Math.random()*ddosConnection.getProtocol().getNumberOfRoles());
+				if(sourceRole==targetRole)
+					continue;
+				if(networkController.addDeviceToConnectionAndProtocol(pSource, ddosConnection, sourceRole)) 
+					break;
+			}
+		}
+		networkController.addConnection(ddosConnection);
+		
+		controller.notifyObservers();
+		return ddosConnection;
+	}
+	
+	/**
+	 * Crash Device, which wont send packets any longer
+	 * @param d Device to be crashed
+	 */
+	public void crashDevice(SmartDevice d) {
+		for(Port p:d.getPorts()) {
+			p.setStatus(Port.CLOSED);
+		}
+		controller.notifyObservers();
+	}
+
+	/**
+	 * Inserts DOS attack into the network
+	 * @param source source of the attack
+	 * @param target destination of the attack
+	 * @return DDoS Connection, which was created
+	 */
+	public Connection runDosAttack(SmartDevice source, SmartDevice target) {
+		NetworkController networkController = controller.getNetworkController();
+		Connection dosConnection = new ConnectionPrecision();
+		dosConnection.setLabel((short)1);
+		dosConnection.setName("DOS: "+source.getName()+"-"+target.getName());
+		networkController.addConnectionToLink(dosConnection, getCommonLink(source, target));
+		dosConnection.setProtocol(new SimpleProtocol());
+		Port pSource = new Port(source, (short)80, 1L);
+		pSource.setStatus(Port.SENDING);
+		networkController.addDeviceToConnectionAndProtocol(pSource, dosConnection, 0);
+		Port pTarget = new Port(target, (short)80, 1000L);
+		pTarget.setStatus(Port.OPEN);
+		networkController.addDeviceToConnectionAndProtocol(pSource, dosConnection, 0);
+		networkController.addDeviceToConnectionAndProtocol(pTarget, dosConnection, 1);
+		networkController.addConnection(dosConnection);
+		controller.notifyObservers();
+		return dosConnection;
+	}
+	
+	/**
+	 * Returns a common Link of the given devices
+	 * @param a
+	 * @param b
+	 * @return Link, both devices are connected to
+	 */
+	private Link getCommonLink(SmartDevice a, SmartDevice b) {
+		LinkedList<Link> l = new LinkedList<Link>(a.getLinks());
+		l.addAll(b.getLinks());
+		if(l.isEmpty()) {
+			NetworkController net = controller.getNetworkController();
+			Link newLink = new PrecisionLink("Direct Link: " + a.getName()+"-"+b.getName());
+			net.addLinkToDevice(newLink, a);
+			net.addLinkToDevice(newLink, b);
+			net.addLink(newLink);
+			return newLink;
+		}else
+			return l.getFirst();
+	}
+}

+ 13 - 0
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/control/NetworkController.java

@@ -38,6 +38,10 @@ public class NetworkController {
 	 * Packet Capture Controller
 	 */
 	private PacketCaptureController captureController;
+	/**
+	 * ExampleAnomalyController
+	 */
+	private ExampleAnomalyController anomalyController;
 	/**
 	 * Creates a new NetworkController, which may manipulate the given model and use the controller
 	 * @param model Model which can be manipulated
@@ -48,6 +52,7 @@ public class NetworkController {
 		this.controller = controller;
 		networkTreeSettings = controller.getSettingsController().getNetworkTreeSettingsController();
 		captureController = controller.getSimulationController().getPacketCaptureController();
+		anomalyController = new ExampleAnomalyController(controller);
 	}
 
 	/**
@@ -771,4 +776,12 @@ public class NetworkController {
 			return newDevice;
 		}
 	}
+
+	/**
+	 * Returns the AnomalyController, which can be used to insert anomalies into the network model
+	 * @return Anomaly Controller
+	 */
+	public ExampleAnomalyController getAnomalyController() {
+		return anomalyController;
+	}
 }

+ 10 - 159
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/menuBar/MenuBarInsertAnomalies.java

@@ -9,6 +9,7 @@ import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.ExampleAnomalyController;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPrecision;
@@ -59,6 +60,11 @@ public class MenuBarInsertAnomalies extends JMenu implements Observer {
 	 */
 	private JMenu mnValueAnomaly;
 	
+	/**
+	 * Anomaly Controller
+	 */
+	private ExampleAnomalyController anomController;
+	
 	/**
 	 * Create a new MenuBar for anomaly insertion
 	 * @param controller main Controller of the framework
@@ -66,6 +72,7 @@ public class MenuBarInsertAnomalies extends JMenu implements Observer {
 	public MenuBarInsertAnomalies(Controller controller) {
 		super("Insert Example Anomaly");
 		this.controller = controller;
+		this.anomController = controller.getNetworkController().getAnomalyController();
 		initialize();
 		this.update(null, null);
 		this.controller.addObserver(this);
@@ -97,7 +104,7 @@ public class MenuBarInsertAnomalies extends JMenu implements Observer {
 			 * DDos Target Menu Item, which opens a DDosCreation Menu
 			 */
 			JMenuItem mntmDDosTarget = new JMenuItem("Destination: "+d.getName());
-			mntmDDosTarget.addActionListener(a->openDDosCreationMenu(d, (List<SmartDevice>)controller.getNetworkController().getVisibleSmartDevices()));
+			mntmDDosTarget.addActionListener(a->anomController.openDDosCreationMenu(d, (List<SmartDevice>)controller.getNetworkController().getVisibleSmartDevices()));
 			mnDDos.add(mntmDDosTarget);
 			/**
 			 * Dos creation menus
@@ -106,7 +113,7 @@ public class MenuBarInsertAnomalies extends JMenu implements Observer {
 			for(SmartDevice t: controller.getNetworkController().getVisibleSmartDevices()){
 				if(d==t)continue;
 				JMenuItem mntmDosTarget = new JMenuItem("Destination: " +t.getName());
-				mntmDosTarget.addActionListener(a->runDosAttack(d,t));
+				mntmDosTarget.addActionListener(a->anomController.runDosAttack(d,t));
 				mntmDosSource.add(mntmDosTarget);
 			}
 			mnDos.add(mntmDosSource);
@@ -114,7 +121,7 @@ public class MenuBarInsertAnomalies extends JMenu implements Observer {
 			 * Menus to crash a device
 			 */
 			JMenuItem crashDevice = new JMenuItem(d.getName());
-			crashDevice.addActionListener(a->crashDevice(d));
+			crashDevice.addActionListener(a->anomController.crashDevice(d));
 			mnCrash.add(crashDevice);
 			/**
 			 * Value Anomalies menus
@@ -142,160 +149,4 @@ public class MenuBarInsertAnomalies extends JMenu implements Observer {
 		mnValueAnomaly.setEnabled(mnValueAnomaly.getMenuComponentCount()!=0);
 	}
 
-	/**
-	 * Opens a DDosCreation Menu which targets the given Device
-	 * So far only a DDoS Attack is created
-	 * @param d Device which should be targeted
-	 */
-	private void openDDosCreationMenu(SmartDevice d, List<SmartDevice> sources) {
-		/**
-		 * Port of the largest connected connection to disguise DDoS
-		 */
-		Port example = null;
-		for(Port p: d.getPorts()) {
-			if(example == null || example.getConnection() == null || example.getConnection().getProtocol()==null) {
-				example = p;
-			} else {
-				if(p.getConnection() == null || p.getConnection().getProtocol() == null) {
-					continue;
-				} else if(p.getConnection().getParticipants().size()>example.getConnection().getParticipants().size()){
-					example = p;
-				}
-			}
-		}
-		if(example == null || example.getConnection() == null || example.getConnection().getProtocol()==null)
-			example = null;
-		/**
-		 * Role of the target device
-		 */
-		int targetRole = 1;
-		if(example != null) {
-			targetRole = example.getConnection().getProtocol().getRoleOfDevice(example);
-			if(targetRole == -1)
-				targetRole = 1;
-		}
-		/**
-		 * Attack Interval per device
-		 */
-		long attackInterval = 1;
-		if(example!=null) {
-			int numDevices = 0;
-			for(Port exP:example.getConnection().getParticipants()) {
-				attackInterval+=exP.getTriggerInterval();
-				numDevices++;
-			}
-			attackInterval /= numDevices == 0 ? 1 : numDevices;
-			/**
-			 * Frequency Less or equal
-			 */
-			attackInterval /= 4.0;
-		}
-		
-		/**
-		 * Link of the DDoS attack
-		 */
-		Link link = null;
-		if(example !=null)
-			link = example.getConnection().getLink();
-		if(link == null) {
-			if(d.getLinks().isEmpty()) {
-				System.out.println("WARNING: Could not create DDos, as Device "+d.getName()+" is not connected to any Link");
-				return;
-			}
-			link = d.getLinks().get(0);
-		}
-		NetworkController networkController = controller.getNetworkController();
-		Connection ddosConnection = new ConnectionPrecision();
-		ddosConnection.setLabel((short)1);
-		ddosConnection.setName("DDOS against "+d.getName());
-		networkController.addConnectionToLink(ddosConnection, link);
-		try {
-			@SuppressWarnings("unchecked")
-			Class<Protocol> exampleProtocol = (Class<Protocol>) example.getConnection().getProtocol().getClass();
-			ddosConnection.setProtocol(exampleProtocol.newInstance());	
-		} catch (Exception e) {
-			ddosConnection.setProtocol(new SimpleProtocol());			
-		}
-		LinkedList<SmartDevice> devices = new LinkedList<SmartDevice>(sources);
-		devices.retainAll(link.getDevices());
-		
-		
-		Port pTarget = new Port(d, (short)80, 1000L);
-		pTarget.setStatus(Port.OPEN);
-		if(!networkController.addDeviceToConnectionAndProtocol(pTarget, ddosConnection, targetRole)) {
-			System.out.println("WARNING: Could not add DDoS Target to role "+targetRole);
-		}
-			
-		for(SmartDevice src: devices) {
-			if(src==d)continue;
-			Port pSource = new Port(src, (short)80, 1L);
-			pSource.setTriggerHandler(new NormalDistributionHandler(attackInterval, attackInterval*0.05));
-			pSource.setStatus(Port.SENDING);
-			// Ten tries of assigning random role
-			for(int i=0; i<10;i++) {
-				int sourceRole = (int) Math.floor(Math.random()*ddosConnection.getProtocol().getNumberOfRoles());
-				if(sourceRole==targetRole)
-					continue;
-				if(networkController.addDeviceToConnectionAndProtocol(pSource, ddosConnection, sourceRole)) 
-					break;
-			}
-		}
-		networkController.addConnection(ddosConnection);
-		
-		controller.notifyObservers();
-	}
-	
-	/**
-	 * Crash Device, which wont send packets any longer
-	 * @param d Device to be crashed
-	 */
-	private void crashDevice(SmartDevice d) {
-		for(Port p:d.getPorts()) {
-			p.setStatus(Port.CLOSED);
-		}
-		controller.notifyObservers();
-	}
-
-	/**
-	 * Inserts DOS attack into the network
-	 * @param source
-	 * @param target
-	 */
-	private void runDosAttack(SmartDevice source, SmartDevice target) {
-		NetworkController networkController = controller.getNetworkController();
-		Connection dosConnection = new ConnectionPrecision();
-		dosConnection.setLabel((short)1);
-		dosConnection.setName("DOS: "+source.getName()+"-"+target.getName());
-		networkController.addConnectionToLink(dosConnection, getCommonLink(source, target));
-		dosConnection.setProtocol(new SimpleProtocol());
-		Port pSource = new Port(source, (short)80, 1L);
-		pSource.setStatus(Port.SENDING);
-		networkController.addDeviceToConnectionAndProtocol(pSource, dosConnection, 0);
-		Port pTarget = new Port(target, (short)80, 1000L);
-		pTarget.setStatus(Port.OPEN);
-		networkController.addDeviceToConnectionAndProtocol(pSource, dosConnection, 0);
-		networkController.addDeviceToConnectionAndProtocol(pTarget, dosConnection, 1);
-		networkController.addConnection(dosConnection);
-		controller.notifyObservers();
-	}
-	
-	/**
-	 * Returns a common Link of the given devices
-	 * @param a
-	 * @param b
-	 * @return
-	 */
-	private Link getCommonLink(SmartDevice a, SmartDevice b) {
-		LinkedList<Link> l = new LinkedList<Link>(a.getLinks());
-		l.addAll(b.getLinks());
-		if(l.isEmpty()) {
-			NetworkController net = controller.getNetworkController();
-			Link newLink = new PrecisionLink("Direct Link: " + a.getName()+"-"+b.getName());
-			net.addLinkToDevice(newLink, a);
-			net.addLinkToDevice(newLink, b);
-			net.addLink(newLink);
-			return newLink;
-		}else
-			return l.getFirst();
-	}
 }

+ 126 - 4
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/menuBar/MenuBarNetworkExamples.java

@@ -1,5 +1,6 @@
 package de.tu_darmstadt.tk.SmartHomeNetworkSim.view.menuBar;
 
+import java.io.File;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -9,7 +10,10 @@ import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.ExampleAnomalyController;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.ImportController;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.PacketCaptureController;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SimulationController;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
@@ -18,6 +22,7 @@ import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPrecision;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Packet;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PacketCollector;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PacketSniffer;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PrecisionLink;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Protocol;
@@ -50,6 +55,11 @@ public class MenuBarNetworkExamples extends JMenu{
 	 */
 	private NetworkController networkController;
 	
+	/**
+	 * Controller to insert anomalies
+	 */
+	private ExampleAnomalyController anomalyController;
+	
 	/**
 	 * Controller for configuration of the program
 	 */
@@ -69,6 +79,7 @@ public class MenuBarNetworkExamples extends JMenu{
 		
 		this.controller = controller;
 		this.networkController = controller.getNetworkController();
+		this.anomalyController = networkController.getAnomalyController();
 		this.settingsController = controller.getSettingsController();
 		this.simulationController = controller.getSimulationController();
 		
@@ -111,10 +122,16 @@ public class MenuBarNetworkExamples extends JMenu{
 		 * Paper example
 		 */
 		JMenuItem mnPaperExample = new JMenuItem("Paper Example");
-		mnPaperExample.addActionListener(a->createPaperExample());
+		mnPaperExample.addActionListener(a->createPaperExample(false));
 		this.add(mnPaperExample);
+		
+		/**
+		 * Paper example + run
+		 */
+		JMenuItem mnRunPaperExample = new JMenuItem("Run Paper Example");
+		mnRunPaperExample.addActionListener(a->createPaperExample(true));
+		this.add(mnRunPaperExample);
 	}
-	
 
 	private void initializePerformanceTest(){
 		SmartDevice tic = new SmartDevice("Tic");
@@ -408,7 +425,19 @@ public class MenuBarNetworkExamples extends JMenu{
 		}
 	}
 	
-	public void createPaperExample(){
+	/**
+	 * Creates the paper toy example, also simulates it, if run = true
+	 * @param run
+	 */
+	@SuppressWarnings("unchecked")
+	public void createPaperExample(boolean run){
+		/**
+		 * Reset network, etc.
+		 */
+		if(run) {
+			controller.getSimulationController().resetSimulation();
+			controller.getNetworkController().deleteNetworkModel();
+		}
 		/*
 		 * Main networking devices 
 		 */
@@ -581,10 +610,103 @@ public class MenuBarNetworkExamples extends JMenu{
 		pBedroomInfo.setTriggerHandler(new NormalDistributionHandler(15000, 500));
 		pBedroomInfo.setLastTrigger(-666L);
 		networkController.addDeviceToConnectionAndProtocol(pBedroomInfo, mqtt,1);
-		
 		/* 
 		 * Update visualization 
 		 */
 		controller.notifyObservers();
+		
+		/**
+		 * Run only if run == true
+		 */
+		if(!run)return;
+		try {
+			System.out.println("Check 1");//TODO
+			/**
+			 * Instances of the packet Sniffers
+			 */
+			PacketSniffer snifferEM = null, snifferKNN = null, snifferHC = null;
+			/*
+			 * Import Example PacketSniffer algorithms
+			 */
+			Class<? extends PacketSniffer> em = (Class<? extends PacketSniffer>) ImportController.importJavaClass(new File("examples/classifier/EMClustering.java"));
+			snifferEM = em.newInstance();
+			Class<? extends PacketSniffer> knn = (Class<? extends PacketSniffer>) ImportController.importJavaClass(new File("examples/classifier/KMeansClustering.java"));
+			snifferKNN = knn.newInstance();
+			Class<? extends PacketSniffer> hc = (Class<? extends PacketSniffer>) ImportController.importJavaClass(new File("examples/classifier/HierarchicalClustering.java"));
+			snifferHC = hc.newInstance();
+
+			System.out.println("Check 2: Imported");//TODO
+			/*
+			 * Create collectors
+			 */
+			PacketCollector collectorKNN = new PacketCollector(snifferKNN);
+			PacketCollector collectorEM = new PacketCollector(snifferEM);
+			PacketCollector collectorHC = new PacketCollector(snifferHC);
+			
+			/*
+			 * Capture both links on all collectors
+			 */
+			PacketCaptureController captureController = controller.getSimulationController().getPacketCaptureController();
+			captureController.addLinkToCollector(collectorEM, zigbee);
+			captureController.addLinkToCollector(collectorEM, wifi);
+			captureController.addLinkToCollector(collectorKNN, zigbee);
+			captureController.addLinkToCollector(collectorKNN, wifi);
+			captureController.addLinkToCollector(collectorHC, zigbee);
+			captureController.addLinkToCollector(collectorHC, wifi);
+			captureController.addPacketCollector(collectorKNN);
+			captureController.addPacketCollector(collectorEM);
+			captureController.addPacketCollector(collectorHC);
+
+			System.out.println("Check 3: created Controller");//TODO
+			
+			/*
+			 * Simulate 150000 ms (2 1/2 minutes)
+			 */
+			SimulationController sim = controller.getSimulationController();
+			sim.setStartTime(0);
+			sim.resetSimulation();
+			sim.setStepDuration(15000);
+			sim.setPrintPackets(false);
+			sim.setEndTime(150000);
+
+			for(int i=0; i<10; i++)
+				sim.getSimulationManager().simulateTimeIntervall(15000*i, 15000);
+
+			collectorKNN.setMode(true);
+			collectorEM.setMode(true);
+			collectorHC.setMode(true);
+			
+			System.out.println("Check 4: Trained");//TODO
+			
+			/*
+			 * Simulate/Test 30000 without anomalies
+			 */
+
+			for(int i=10; i<12; i++)
+				sim.getSimulationManager().simulateTimeIntervall(15000*i, 15000);
+			System.out.println("Check 5: tested w/0 anomalies");//TODO
+			
+			/**
+			 * Insert anomaly & Simulate further packets
+			 */
+			Connection ddos = anomalyController.openDDosCreationMenu(zigBeeRouter, new LinkedList<SmartDevice>(zigbee.getDevices()));
+			Connection dos = anomalyController.runDosAttack(kitchenLight, kitchenFridge);
+			/**
+			 * Start Testing another 30000
+			 */
+			sim.setEndTime(210000);
+			
+
+			for(int i=12; i<14; i++)
+				sim.getSimulationManager().simulateTimeIntervall(15000*i, 15000);
+			
+
+			System.out.println("Check 6: Tested w anomalies");//TODO
+			
+			System.out.println("Testing completed");
+		} catch(Exception e) {
+			System.out.println("WARNING: Testing failed: ");
+			e.printStackTrace();
+		}
 	}
 }