Ver Fonte

Adds create example network menuitem

Andreas T. Meyer-Berg há 5 anos atrás
pai
commit
8193f0b9ad

+ 5 - 307
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/Main.java

@@ -1,30 +1,7 @@
 package de.tu_darmstadt.tk.SmartHomeNetworkSim;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map.Entry;
-
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SimulationController;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPerformance;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPrecision;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Model;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Packet;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PacketCollector;
-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.protocols.MQTT_protocol;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleLink;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.CountingMetric;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.Manipulation_RandomMove;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleProtocol;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.MainFrame;
 
 /**
@@ -36,304 +13,25 @@ public class Main {
 	/**
 	 * Model of the smart home
 	 */
-	static Model m;
+	static Model model;
 	
 	/**
 	 * Visualization of the smart home network
 	 */
-	static MainFrame v;
+	static MainFrame view;
 	
 	/**
 	 * Controller of the program 
 	 */
 	static Controller controller;
 	
-	/**
-	 * Controller for editing the network
-	 */
-	static NetworkController c;
-	
-	/**
-	 * Controller for configuration of the program
-	 */
-	static SettingsController conf;
-	/**
-	 * SimulationController for running the simulation
-	 */
-	static SimulationController sim;
-	
 	/**
 	 * Starts the program
 	 * @param args will be ignored
 	 */
 	public static void main(String[] args) {
-		m = new Model();
-		controller = new Controller(m);
-		c = controller.getNetworkController();
-		conf = controller.getSettingsController();
-		sim = controller.getSimulationController();
-	    //initializeTest();
-	    initializeMQTTTest();
-	    //initializeUserStudy();
-		//initializePerformanceTest();
-		//Test packetCapture
-	    //sim.getPacketCaptureController().addPacketCollector(new PacketCollector(new SimplePacketSniffer()));
-	    v = new MainFrame(controller);
-	    /*
-	    for(int i=0; i<10; i++)
-	    	m.getSim().simulateTimeIntervall(0+50*i, 50);
-	    */
-	    //testPackageCollection();
-	    
-	}
-	
-	@SuppressWarnings("unused")
-	private static void initializePerformanceTest(){
-		SmartDevice tic = new SmartDevice("Tic");
-		tic.setX(100);
-		tic.setY(100);
-		SmartDevice toc = new SmartDevice("Toc");
-		toc.setX(100);
-		toc.setY(250);
-		c.addSmartDevice(tic);
-		c.addSmartDevice(toc);
-		
-		Link l = new PrecisionLink("Channel");
-		c.addLink(l);
-		c.addLinkToDevice(l, tic);
-		c.addLinkToDevice(l, toc);
-
-		Port ticP = new Port(tic, (short)2, 200, (short)0, 0, (short)0);
-		Port tocP = new Port(toc, (short)3, 200, (short)0, -100, (short)0);
-		tic.addPort(ticP);
-		toc.addPort(tocP);
-		
-		Connection con = new ConnectionPrecision(l, new SimpleProtocol());
-		c.addConnection(con);
-		c.addConnectionToLink(con, l);
-		c.addDeviceToConnectionAndProtocol(ticP, con, 0);
-		c.addDeviceToConnectionAndProtocol(tocP, con, 1);
-		
-		sim.setStepDuration(100000000);
-		sim.setEndTime(1000000000);
-	}
-	
-	/**
-	 * Initializes a basic test Network, which contains a few SmartDevices, one Link and one Connection
-	 */
-	@SuppressWarnings("unused")
-	private static void initializeUserStudy(){
-		/**
-		 * Preset one SmartDevice
-		 */
-		SmartDevice A = new SmartDevice("Homestation");
-		A.setX(200);
-		A.setY(200);
-		c.addSmartDevice(A);
-		/**
-		 * Packagecollector, which is registered at the Device
-		 */
-		PacketCollector collector = new PacketCollector(new CountingMetric());
-		sim.getPacketCaptureController().addPacketCollector(collector);
-		sim.getPacketCaptureController().addDeviceToCollector(collector, A);
-		sim.setPrintPackets(true);
+		model = new Model();
+		controller = new Controller(model);
+	    view = new MainFrame(controller);
 	}
-	
-	/**
-	 * Test package collectors
-	 */
-	@SuppressWarnings("unused")
-	private static void testPackageCollection() {
-		sim.addAlgorithm(new Manipulation_RandomMove(), controller);
-	    PacketCollector collector = new PacketCollector();
-	    sim.getSimulationManager().getPacketCollectionManager().addPacketCollector(collector);
-	    
-	    System.out.println("Collector 0-500 - nothing collected:");
-	    sim.getSimulationManager().simulateTimeIntervall(0, 500);
-	    HashMap<Link, LinkedList<Packet>> map = collector.getPackets();
-	    for(Entry<Link, LinkedList<Packet>> e:map.entrySet()){
-	    	System.out.println("Link: "+e.getKey().getName());
-	    	for(Packet p : e.getValue())
-	    		System.out.println(p.getTextualRepresentation());
-	    }
-	    
-	    System.out.println("");
-	    System.out.println("");
-	    Iterator<SmartDevice> it = c.getSmartDevices().iterator();
-	    it.next();
-	    
-	    SmartDevice d = it.next();
-	    collector.addDevice(d);
-	    SmartDevice f = it.next();
-	    collector.addDevice(f);
-	    System.out.println("Collector 500-1000 - "+d.getName()+" & "+f.getName()+" collected:");
-	    sim.getSimulationManager().simulateTimeIntervall(500, 500);
-	    map = collector.getPackets();
-	    for(Entry<Link, LinkedList<Packet>> e:map.entrySet()){
-	    	System.out.println("Link: "+e.getKey().getName());
-	    	for(Packet p : e.getValue())
-	    		System.out.println(p.getTextualRepresentation());
-	    }
-
-	    System.out.println("");
-	    System.out.println("");
-	    
-	    Link l = c.getLinks().iterator().next();
-	    collector.addLink(l);
-	    System.out.println("Collector 2000-3000 - "+l+" collected:");
-	    sim.getSimulationManager().simulateTimeIntervall(1000, 500);
-	    map = collector.getPackets();
-	    for(Entry<Link, LinkedList<Packet>> e:map.entrySet()){
-	    	System.out.println("Link: "+e.getKey().getName());
-	    	for(Packet p : e.getValue())
-	    		System.out.println(p.getTextualRepresentation());
-	    }
-	    sim.resetSimulation();
-	}
-	
-	/**
-	 * Initializes a basic test Network, which contains a few SmartDevices, one Link and one Connection
-	 */
-	@SuppressWarnings("unused")
-	private static void initializeTest(){
-		SmartDevice A = null, B = null, C = null;
-		for(int i = 0; i<5; i++){
-			A = new SmartDevice("SmartTV"+i);		
-			A.setX((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-			A.setY((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-			B = new SmartDevice("SmartDoor"+i);
-			B.setX((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-			B.setY((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-			C = new SmartDevice("SmartLight"+i);
-			C.setX((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-			C.setY((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-		
-			c.addSmartDevice(A);
-			c.addSmartDevice(B);
-			c.addSmartDevice(C);
-		}
-		
-		Link link = new SimpleLink("SimpleWifi");
-		link.addDevice(A);
-		link.addDevice(B);
-		link.addDevice(C);
-		A.addLink(link);
-		B.addLink(link);
-		C.addLink(link);
-		
-		Port a = new Port(A, (short) 1);
-		a.setLastTrigger(0);
-		a.setTriggerInterval(68);
-		a.setStatus(Port.SENDING);
-		A.addPort(a);
-		Port b = new Port(B, (short) 2);
-		b.setTriggerInterval(102);
-		b.setStatus(Port.SENDING);
-		B.addPort(b);
-		
-		Connection s = new ConnectionPerformance(link, new SimpleProtocol(a, b));
-		s.setPacketLossProbability(0.01);//1% Packet loss probability
-		a.setConnection(s);
-		b.setConnection(s);
-		s.addSmartDevice(a);
-		s.addSmartDevice(b);
-		m.addConnectionNetwork(link);
-		link.addConnection(s);
-		m.addConnection(s);
-	}
-	
-	/**
-	 * Initializes a basic test Network, which contains a few SmartDevices, one Link and one Connection
-	 */
-	//@SuppressWarnings("unused")
-	private static void initializeMQTTTest(){
-		Link link = new SimpleLink("WIFI");
-		
-		SmartDevice broker = new SmartDevice("MQTT-Broker");
-		broker.setX((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-		broker.setY((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-		c.addSmartDevice(broker);
-		
-		Port brokerPort = new Port(broker, (short) 0);
-		brokerPort.setLastTrigger(0);
-		brokerPort.setTriggerInterval(987);
-		brokerPort.setStatus(Port.OPEN);		
-		broker.addPort(brokerPort);
-		
-		link.addDevice(broker);
-		broker.addLink(link);
-		
-		Protocol protocol = new MQTT_protocol(brokerPort);
-		
-		Connection con = new ConnectionPrecision(link, protocol);
-		con.setPacketLossProbability(0.01);//1% Packet loss probability
-		con.addSmartDevice(brokerPort);
-		brokerPort.setConnection(con);
-		con.setStatus(Connection.ACTIVE);
-		c.addLink(link);
-		link.addConnection(con);
-		c.addConnection(con);
-		
-		SmartDevice A = null, B = null, C = null;
-		Port aP,bP,cP;
-		for(int i = 0; i<3; i++){
-			A = new SmartDevice("SmartTV"+i+"(Sub)");		
-			A.setX((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-			A.setY((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-			link.addDevice(A);
-			A.addLink(link);
-			
-			aP = new Port(A,((short) (3*i+1)));
-			aP.setLastTrigger(0);
-			aP.setTriggerInterval(100+(int)(Math.random()*900));
-			aP.setJitter((short) (Math.random()*50));
-			aP.setStatus(Port.SENDING);
-			aP.setConnection(con);
-			protocol.addDeviceOfRole(aP, 3);
-			con.addSmartDevice(aP);
-			A.addPort(aP);
-			
-			c.addSmartDevice(A);
-			
-			
-			
-			B = new SmartDevice("SmartDoor"+i+"(Pub)");
-			B.setX((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-			B.setY((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-			link.addDevice(B);
-			B.addLink(link);
-			
-			bP = new Port(B,((short) (3*i+2)));
-			bP.setLastTrigger(0);
-			bP.setTriggerInterval(10+(int)(Math.random()*190));
-			bP.setJitter((short) (Math.random()*50));
-			bP.setStatus(Port.SENDING);
-			bP.setConnection(con);
-			protocol.addDeviceOfRole(bP, 2);
-			con.addSmartDevice(bP);
-			B.addPort(bP);
-			
-			c.addSmartDevice(B);
-			
-			C = new SmartDevice("SmartLight"+i+"(Pub,Sub)");
-			C.setX((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-			C.setY((int)(Math.random()*conf.getWidth()-2*conf.getDeviceVisualizationRadius())+conf.getDeviceVisualizationRadius());
-			link.addDevice(C);
-			C.addLink(link);
-			
-			cP = new Port(C,((short) (3*i+1)));
-			cP.setLastTrigger(0);
-			cP.setTriggerInterval(50+(int)(Math.random()*450));
-			cP.setJitter((short) (Math.random()*50));
-			cP.setStatus(Port.SENDING);
-			cP.setConnection(con);
-			protocol.addDeviceOfRole(cP, 1);
-			con.addSmartDevice(cP);
-			C.addPort(cP);
-			
-			c.addSmartDevice(C);
-
-		}
-	}
-
 }

+ 9 - 0
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/MenuBar.java

@@ -16,6 +16,7 @@ import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups.ConnectionCreationDial
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups.EditAlgorithmsPopUp;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups.EditCollectorsPopUp;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups.LinkCreationDialog;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups.MenuBarNetworkExamples;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups.NetworkTreeWindow;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups.SettingsPopUp;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups.SimulationConfigurator;
@@ -62,6 +63,8 @@ public class MenuBar extends JMenuBar {
 	 * JMenu for help with the program
 	 */
 	private JMenu mnHelp;
+	
+	private JMenu mnExamples;
 
 	/**
 	 * Serial Version
@@ -163,6 +166,12 @@ public class MenuBar extends JMenuBar {
 					this.getParent());
 			});
 		mnCreate.add(mntmCreateConnectionOfSelected);
+		
+		// Create example network option
+		mnExamples = new MenuBarNetworkExamples(controller);
+		mnCreate.add(mnExamples);
+		
+		
 	}
 
 	/**

+ 356 - 0
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/popups/MenuBarNetworkExamples.java

@@ -0,0 +1,356 @@
+package de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map.Entry;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SimulationController;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPerformance;
+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.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.protocols.MQTT_protocol;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.CountingMetric;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.Manipulation_RandomMove;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleLink;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleProtocol;
+
+public class MenuBarNetworkExamples extends JMenu{
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Controller controller
+	 */
+	private Controller controller;
+	
+	/**
+	 * Controller for editing the network
+	 */
+	private NetworkController networkController;
+	
+	/**
+	 * Controller for configuration of the program
+	 */
+	private SettingsController settingsController;
+	
+	/**
+	 * SimulationController for running the simulation
+	 */
+	private SimulationController simulationController;
+
+	/**
+	 * Creates the JMenu for network examples in the MenuBar
+	 * @param controller controller to create examples
+	 */
+	public MenuBarNetworkExamples(Controller controller) {
+		super("Create example Network");
+		
+		this.controller = controller;
+		this.networkController = controller.getNetworkController();
+		this.settingsController = controller.getSettingsController();
+		this.simulationController = controller.getSimulationController();
+		
+		/**
+		 * MQTT example
+		 */
+		JMenuItem mnMQTT = new JMenuItem("MQTT Example");
+		mnMQTT.addActionListener(a->initializeMQTTTest());
+		this.add(mnMQTT);
+		
+		/**
+		 * Small Network Test
+		 */
+		JMenuItem mnTest = new JMenuItem("Network Example");
+		mnTest.addActionListener(a->initializeTest());
+		this.add(mnTest);
+		
+		/**
+		 * Performance Comparison Example
+		 */
+		JMenuItem mnPerformance = new JMenuItem("Performane Evaluation Preset");
+		mnPerformance.addActionListener(a->initializePerformanceTest());
+		this.add(mnPerformance);
+		
+		/**
+		 * User Study Preset
+		 */
+		JMenuItem mnUserStudy = new JMenuItem("User Study Preset");
+		mnUserStudy.addActionListener(a->initializeUserStudy());
+		this.add(mnUserStudy);
+		
+		/**
+		 * Packet Collection example
+		 */
+		JMenuItem mnPacketCollectionExmample = new JMenuItem("Packet Collection Example");
+		mnPacketCollectionExmample.addActionListener(a->testPackageCollection());
+		this.add(mnPacketCollectionExmample);
+	}
+	
+
+	private void initializePerformanceTest(){
+		SmartDevice tic = new SmartDevice("Tic");
+		tic.setX(100);
+		tic.setY(100);
+		SmartDevice toc = new SmartDevice("Toc");
+		toc.setX(100);
+		toc.setY(250);
+		networkController.addSmartDevice(tic);
+		networkController.addSmartDevice(toc);
+		
+		Link l = new PrecisionLink("Channel");
+		networkController.addLink(l);
+		networkController.addLinkToDevice(l, tic);
+		networkController.addLinkToDevice(l, toc);
+
+		Port ticP = new Port(tic, (short)2, 200, (short)0, 0, (short)0);
+		Port tocP = new Port(toc, (short)3, 200, (short)0, -100, (short)0);
+		tic.addPort(ticP);
+		toc.addPort(tocP);
+		
+		Connection con = new ConnectionPrecision(l, new SimpleProtocol());
+		networkController.addConnection(con);
+		networkController.addConnectionToLink(con, l);
+		networkController.addDeviceToConnectionAndProtocol(ticP, con, 0);
+		networkController.addDeviceToConnectionAndProtocol(tocP, con, 1);
+		
+		simulationController.setStepDuration(100000000);
+		simulationController.setEndTime(1000000000);
+		controller.notifyObservers();
+	}
+	
+	/**
+	 * Initializes a basic test Network, which contains a few SmartDevices, one Link and one Connection
+	 */
+	private void initializeUserStudy(){
+		/**
+		 * Preset one SmartDevice
+		 */
+		SmartDevice A = new SmartDevice("Homestation");
+		A.setX(200);
+		A.setY(200);
+		networkController.addSmartDevice(A);
+		/**
+		 * Packagecollector, which is registered at the Device
+		 */
+		PacketCollector collector = new PacketCollector(new CountingMetric());
+		simulationController.getPacketCaptureController().addPacketCollector(collector);
+		simulationController.getPacketCaptureController().addDeviceToCollector(collector, A);
+		simulationController.setPrintPackets(true);
+		controller.notifyObservers();
+	}
+	
+	/**
+	 * Test package collectors
+	 */
+	private void testPackageCollection() {
+		simulationController.addAlgorithm(new Manipulation_RandomMove(), controller);
+	    PacketCollector collector = new PacketCollector();
+	    simulationController.getSimulationManager().getPacketCollectionManager().addPacketCollector(collector);
+	    
+	    System.out.println("Collector 0-500 - nothing collected:");
+	    simulationController.getSimulationManager().simulateTimeIntervall(0, 500);
+	    HashMap<Link, LinkedList<Packet>> map = collector.getPackets();
+	    for(Entry<Link, LinkedList<Packet>> e:map.entrySet()){
+	    	System.out.println("Link: "+e.getKey().getName());
+	    	for(Packet p : e.getValue())
+	    		System.out.println(p.getTextualRepresentation());
+	    }
+	    
+	    System.out.println("");
+	    System.out.println("");
+	    Iterator<SmartDevice> it = networkController.getSmartDevices().iterator();
+	    it.next();
+	    
+	    SmartDevice d = it.next();
+	    collector.addDevice(d);
+	    SmartDevice f = it.next();
+	    collector.addDevice(f);
+	    System.out.println("Collector 500-1000 - "+d.getName()+" & "+f.getName()+" collected:");
+	    simulationController.getSimulationManager().simulateTimeIntervall(500, 500);
+	    map = collector.getPackets();
+	    for(Entry<Link, LinkedList<Packet>> e:map.entrySet()){
+	    	System.out.println("Link: "+e.getKey().getName());
+	    	for(Packet p : e.getValue())
+	    		System.out.println(p.getTextualRepresentation());
+	    }
+
+	    System.out.println("");
+	    System.out.println("");
+	    
+	    Link l = networkController.getLinks().iterator().next();
+	    collector.addLink(l);
+	    System.out.println("Collector 2000-3000 - "+l+" collected:");
+	    simulationController.getSimulationManager().simulateTimeIntervall(1000, 500);
+	    map = collector.getPackets();
+	    for(Entry<Link, LinkedList<Packet>> e:map.entrySet()){
+	    	System.out.println("Link: "+e.getKey().getName());
+	    	for(Packet p : e.getValue())
+	    		System.out.println(p.getTextualRepresentation());
+	    }
+	    simulationController.resetSimulation();
+		controller.notifyObservers();
+	}
+	
+	/**
+	 * Initializes a basic test Network, which contains a few SmartDevices, one Link and one Connection
+	 */
+	private void initializeTest(){
+		SmartDevice A = null, B = null, C = null;
+		for(int i = 0; i<5; i++){
+			A = new SmartDevice("SmartTV"+i);		
+			A.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+			A.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+			B = new SmartDevice("SmartDoor"+i);
+			B.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+			B.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+			C = new SmartDevice("SmartLight"+i);
+			C.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+			C.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+		
+			networkController.addSmartDevice(A);
+			networkController.addSmartDevice(B);
+			networkController.addSmartDevice(C);
+		}
+		
+		Link link = new SimpleLink("SimpleWifi");
+		link.addDevice(A);
+		link.addDevice(B);
+		link.addDevice(C);
+		A.addLink(link);
+		B.addLink(link);
+		C.addLink(link);
+		
+		Port a = new Port(A, (short) 1);
+		a.setLastTrigger(0);
+		a.setTriggerInterval(68);
+		a.setStatus(Port.SENDING);
+		A.addPort(a);
+		Port b = new Port(B, (short) 2);
+		b.setTriggerInterval(102);
+		b.setStatus(Port.SENDING);
+		B.addPort(b);
+		
+		Connection s = new ConnectionPerformance(link, new SimpleProtocol(a, b));
+		s.setPacketLossProbability(0.01);//1% Packet loss probability
+		a.setConnection(s);
+		b.setConnection(s);
+		s.addSmartDevice(a);
+		s.addSmartDevice(b);
+
+		link.addConnection(s);
+		
+		networkController.addLink(link);
+		networkController.addConnection(s);
+		controller.notifyObservers();
+	}
+	
+	/**
+	 * Initializes a basic test Network, which contains a few SmartDevices, one Link and one Connection
+	 */
+	private void initializeMQTTTest(){
+		Link link = new SimpleLink("WIFI");
+		
+		SmartDevice broker = new SmartDevice("MQTT-Broker");
+		broker.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+		broker.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+		networkController.addSmartDevice(broker);
+		
+		Port brokerPort = new Port(broker, (short) 0);
+		brokerPort.setLastTrigger(0);
+		brokerPort.setTriggerInterval(987);
+		brokerPort.setStatus(Port.OPEN);		
+		broker.addPort(brokerPort);
+		
+		link.addDevice(broker);
+		broker.addLink(link);
+		
+		Protocol protocol = new MQTT_protocol(brokerPort);
+		
+		Connection con = new ConnectionPrecision(link, protocol);
+		con.setPacketLossProbability(0.01);//1% Packet loss probability
+		con.addSmartDevice(brokerPort);
+		brokerPort.setConnection(con);
+		con.setStatus(Connection.ACTIVE);
+		networkController.addLink(link);
+		link.addConnection(con);
+		networkController.addConnection(con);
+		
+		SmartDevice A = null, B = null, C = null;
+		Port aP,bP,cP;
+		for(int i = 0; i<3; i++){
+			A = new SmartDevice("SmartTV"+i+"(Sub)");		
+			A.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+			A.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+			link.addDevice(A);
+			A.addLink(link);
+			
+			aP = new Port(A,((short) (3*i+1)));
+			aP.setLastTrigger(0);
+			aP.setTriggerInterval(100+(int)(Math.random()*900));
+			aP.setJitter((short) (Math.random()*50));
+			aP.setStatus(Port.SENDING);
+			aP.setConnection(con);
+			protocol.addDeviceOfRole(aP, 3);
+			con.addSmartDevice(aP);
+			A.addPort(aP);
+			
+			networkController.addSmartDevice(A);
+			
+			
+			
+			B = new SmartDevice("SmartDoor"+i+"(Pub)");
+			B.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+			B.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+			link.addDevice(B);
+			B.addLink(link);
+			
+			bP = new Port(B,((short) (3*i+2)));
+			bP.setLastTrigger(0);
+			bP.setTriggerInterval(10+(int)(Math.random()*190));
+			bP.setJitter((short) (Math.random()*50));
+			bP.setStatus(Port.SENDING);
+			bP.setConnection(con);
+			protocol.addDeviceOfRole(bP, 2);
+			con.addSmartDevice(bP);
+			B.addPort(bP);
+			
+			networkController.addSmartDevice(B);
+			
+			C = new SmartDevice("SmartLight"+i+"(Pub,Sub)");
+			C.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+			C.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
+			link.addDevice(C);
+			C.addLink(link);
+			
+			cP = new Port(C,((short) (3*i+1)));
+			cP.setLastTrigger(0);
+			cP.setTriggerInterval(50+(int)(Math.random()*450));
+			cP.setJitter((short) (Math.random()*50));
+			cP.setStatus(Port.SENDING);
+			cP.setConnection(con);
+			protocol.addDeviceOfRole(cP, 1);
+			con.addSmartDevice(cP);
+			C.addPort(cP);
+			
+			networkController.addSmartDevice(C);
+			controller.notifyObservers();
+		}
+	}
+}