Пример #1
0
        static void Main(string[] args) {

			Application.Init();

            Network myNetwork = new Network();

			myNetwork.AddDevices(NetworkGenerator.GenerateDevices(State.MaxDevices));

			var plot = new CPlot();

			State.SetDelegate(plot.AddCountPackets);

			MainWindow window = new MainWindow(plot);

			Logger.SetLogger(window.GetListStore());

			window.SetDelegateStartStopFunction(Protocol.StartStopGenerateOutgoingTraffic);

			GLib.Timeout.Add(100, delegate {
				Protocol.RunIteration(myNetwork);	
				return true;
			});


			window.ShowAll();
		
			Application.Run();


			//NetworkGenerator.GenerateConnectedLinks(myNetwork.GetDevices());
            //myNetwork.GenerateGraphFile();

        }
Пример #2
0
		public static void RunIteration(Network pNetwork)
		{
			List<Device> pDevices = pNetwork.GetDevices();

			foreach(var device in pDevices) {

				if(mGenerateOutgoingTraffic) {
					device.AddRandomPacketForOutgoing();
				}
				device.HandlePackets();
			}

			foreach(var device in pDevices) {
				Queue<Packet> queue = device.GetOutgoingPackets();
				while(queue.Count > 0) {
					Packet p = queue.Dequeue();
					int id = p.GetNextDeviceId();
					TransportPacketTo(id, p, pDevices);
				}
			}

			State.AppendNetworkState(mIdRunIteration++, pDevices);
		}