static int Main()
        {
            StaticConfiguration.Initialize();
            StaticConfiguration.Start();

            FakeDhcpServer fakeDhcpServer = new FakeDhcpServer();
            DebugAdapter   adapter        = new DebugAdapter(fakeDhcpServer);

            Console.WriteLine("Created Debug Adapter {0}",
                              adapter.HardwareAddress);
            Core.Instance().RegisterAdapter(adapter, 64);

            DhcpClient dc = new DhcpClient(adapter);

            dc.Start();

            while (fakeDhcpServer.State == FakeDhcpServer.ServerState.Running)
            {
                Thread.Sleep(TimeSpan.FromSeconds(1));
            }
            dc.Stop();

            Console.WriteLine("Removing Adapter.");
            Core.Instance().DeregisterAdapter(adapter);

            StaticConfiguration.Stop();

            if (fakeDhcpServer.State == FakeDhcpServer.ServerState.Failed)
            {
                return(1);
            }
            return(0);
        }
Esempio n. 2
0
        private DbClient()
        {
            const string connectionString = "mongodb://127.0.0.1:27017";

            try
            {
                StaticConfiguration.Initialize();
                _logger = LogManager.GetLogger("TestToolboxLog");
                var client = new MongoClient(connectionString);
                Database                = client.GetDatabase("ATA");
                TestDatabase            = client.GetDatabase("ATAActivitySimulator");
                DataProfileCollection   = Database.GetCollection <BsonDocument>("DataProfile");
                UniqueEntitieCollection = Database.GetCollection <BsonDocument>("UniqueEntity");
                SystemProfileCollection = Database.GetCollection <BsonDocument>("SystemProfile");
                GatewayIdsCollection    = new List <ObjectId>(0);
                GatewayIdsCollection    = FilterGwIds();
                CreateActivityCollectionsOnTestDb();
            }
            catch (Exception dbException)
            {
                _logger.Error(dbException);
            }
        }
Esempio n. 3
0
        static void Main()
        {
            StaticConfiguration.Initialize();
            StaticConfiguration.Start();

            LoopbackAdapter loopback = new LoopbackAdapter();

            Console.WriteLine("Created Loopback Adapter {0}",
                              loopback.HardwareAddress);
            Core.Instance().RegisterAdapter(loopback, 64);

            IPModule ip = Core.Instance().GetProtocolByName("IP") as
                          IPModule;

            Console.WriteLine("Binding address to adapter");

            IPv4 ifAddress = IPv4.Parse("192.168.0.100");
            IPv4 ifNetmask = IPv4.Parse("255.255.255.0");
            IPv4 gwAddress = IPv4.Parse("192.168.0.1");

            ip.HostConfiguration.Bindings.Add(
                loopback,
                new InterfaceIPConfiguration(ifAddress, ifNetmask, gwAddress)
                );

            const int nInstances = 8;
            const int maxPackets = 10000;
            ushort    basePort   = 10000;

            Receiver[] receivers = new Receiver[nInstances];
            Sender[]   senders   = new Sender[nInstances];

            for (int i = 0; i < nInstances; i++)
            {
                ushort rPort = (ushort)(basePort + 2 * i);
                ushort sPort = (ushort)(basePort + 2 * i + 1);
                receivers[i] = new Receiver(ifAddress, rPort, maxPackets);
                senders[i]   = new Sender(ifAddress, sPort, ifAddress, rPort,
                                          maxPackets);
            }

            bool done = false;

            while (done == false)
            {
                Thread.CurrentThread.Join(TimeSpan.FromSeconds(1));
                done = true;
                for (int i = 0; i < nInstances; i++)
                {
                    if (receivers[i].ThreadState != ThreadState.Stopped ||
                        senders[i].ThreadState != ThreadState.Stopped)
                    {
                        done = false;
                        break;
                    }
                }
            }

            Console.WriteLine("Removing Adapter.");
            Core.Instance().DeregisterAdapter(loopback);

            StaticConfiguration.Stop();
        }