Exemplo n.º 1
0
        public AutoTesterServer(string[] args)
        {
            scenariosFileName = args[0];
            string localAddr = args[1];
            int localPort = int.Parse(args[2]);

            tcpClients = new List<TcpClient>();
            scenarios = new TestingScenarios();

            // Create the TCP server
            IPEndPoint localEP = new IPEndPoint(IPAddress.Parse(localAddr), localPort);
            tcpServer = new TcpListener(localEP);
            tcpServer.Start();
            tcpServer.BeginAcceptTcpClient(new AsyncCallback(AcceptTCPClient), null);

            // Build the session
            ProcessArgs(args, 3, localAddr);
        }
Exemplo n.º 2
0
        private void ProcessArgs(string[] args, int startFrom, string localAddr)
        {
            string simulationType = "interval";
            string[] browsers = { "chrome", "firefox" };
            string[] connections = { "websocket", "securewebsocket", "webrtc - reliable", "webrtc - unreliable", "unity - reliable", "unity - unreliable" };
            int[] clients = { 1 };
            int[] duration = { 10 };
            int[] pps = { 10 };
            int[] payloadSize = { 100 };
            int[] packetCount = { 10000 };
            int sessions = 5;
            bool enableWireshark = false;

            if (args.Length > startFrom)
            {
                int i = startFrom;
                do
                {
                    if (args[i] == "--wireshark")
                    {
                        enableWireshark = true;
                        ++i;
                    }
                    else if (args[i] == "--type")
                    {
                        ++i;
                        simulationType = args[i];
                        ++i;

                    }
                    else if (args[i] == "--browsers")
                    {
                        ++i;

                        List<string> browserList = new List<string>();

                        while ((i < args.Length) && !args[i].StartsWith("--"))
                        {
                            browserList.Add(args[i]);
                            ++i;
                        }

                        browsers = browserList.ToArray();
                    }
                    else if (args[i] == "--connections")
                    {
                        ++i;

                        List<string> connectionList = new List<string>();

                        while ((i < args.Length) && !args[i].StartsWith("--"))
                        {
                            string arg = args[i];
                            if (arg.Contains("-"))
                            {
                                arg = arg.Replace("-", " - ");
                            }

                            connectionList.Add(arg);
                            ++i;
                        }

                        connections = connectionList.ToArray();
                    }
                    else if (args[i] == "--clients")
                    {
                        ++i;

                        List<int> clientList = new List<int>();

                        while ((i < args.Length) && !args[i].StartsWith("--"))
                        {
                            clientList.Add(int.Parse(args[i]));
                            ++i;
                        }

                        clients = clientList.ToArray();
                    }
                    else if (args[i] == "--duration")
                    {
                        ++i;

                        List<int> durationList = new List<int>();

                        while ((i < args.Length) && !args[i].StartsWith("--"))
                        {
                            durationList.Add(int.Parse(args[i]));
                            ++i;
                        }

                        duration = durationList.ToArray();
                    }
                    else if (args[i] == "--pps")
                    {
                        ++i;

                        List<int> ppsList = new List<int>();

                        while ((i < args.Length) && !args[i].StartsWith("--"))
                        {
                            ppsList.Add(int.Parse(args[i]));
                            ++i;
                        }

                        pps = ppsList.ToArray();
                    }
                    else if (args[i] == "--payload")
                    {
                        ++i;

                        List<int> payloadList = new List<int>();

                        while ((i < args.Length) && !args[i].StartsWith("--"))
                        {
                            payloadList.Add(int.Parse(args[i]));
                            ++i;
                        }

                        payloadSize = payloadList.ToArray();
                    }
                    else if (args[i] == "--packets")
                    {
                        ++i;

                        List<int> packetCountList = new List<int>();

                        while ((i < args.Length) && !args[i].StartsWith("--"))
                        {
                            packetCountList.Add(int.Parse(args[i]));
                            ++i;
                        }

                        packetCount = packetCountList.ToArray();
                    }
                    else if (args[i] == "--sessions")
                    {
                        ++i;
                        sessions = int.Parse(args[i]);
                        ++i;
                    }
                    else
                    {
                        Console.WriteLine("Unknown command argument: " + args[i]);
                        ++i;
                    }

                } while (i < args.Length);
            }

            scenarios = new TestingScenarios();
            scenarios.connectionInfo = new ServerSettings();
            scenarios.sessions = new List<SessionDescription>();

            scenarios.connectionInfo.ipAddr = localAddr;
            scenarios.connectionInfo.port = "8080";

            // Sessions
            for (int i = 0; i < sessions; ++i)
            {
                // browsers
                for (int j = 0; j < browsers.Length; ++j)
                {
                    // connections
                    for (int k = 0; k < connections.Length; ++k)
                    {

                        // When dealing with an interval simulation, then only apply the client, pps and payloadsize parameters
                        if (simulationType == "interval")
                        {
                            // clients
                            for (int l = 0; l < clients.Length; ++l)
                            {
                                scenarios.sessions.Add(new SessionDescription(simulationType, browsers[j], connections[k], clients[l], duration[0], pps[0], payloadSize[0], packetCount[0], i + 1, enableWireshark));
                            }

                            // pps - Start from 1 because clients already tested first scenario
                            for (int l = 1; l < pps.Length; ++l)
                            {
                                scenarios.sessions.Add(new SessionDescription(simulationType, browsers[j], connections[k], clients[0], duration[0], pps[l], payloadSize[0], packetCount[0], i + 1, enableWireshark));
                            }

                            // payloadsize - Start from 1 because clients already tested first scenario
                            for (int l = 1; l < payloadSize.Length; ++l)
                            {
                                scenarios.sessions.Add(new SessionDescription(simulationType, browsers[j], connections[k], clients[0], duration[0], pps[0], payloadSize[l], packetCount[0], i + 1, enableWireshark));
                            }
                        }
                        else if (simulationType == "pingpong")
                        {
                            // packet count
                            for (int l = 0; l < packetCount.Length; ++l)
                            {
                                scenarios.sessions.Add(new SessionDescription(simulationType, browsers[j], connections[k], clients[0], duration[0], pps[0], payloadSize[0], packetCount[l], i + 1, enableWireshark));
                            }

                            // payloadsize - Start from 1 because packet count already tested first scenario
                            for (int l = 1; l < payloadSize.Length; ++l)
                            {
                                scenarios.sessions.Add(new SessionDescription(simulationType, browsers[j], connections[k], clients[0], duration[0], pps[0], payloadSize[l], packetCount[0], i + 1, enableWireshark));
                            }
                        }

                    }
                }
            }

            string scenariosStr = JsonConvert.SerializeObject(scenarios, Formatting.Indented);
            File.WriteAllText(scenariosFileName, scenariosStr);
        }