Exemplo n.º 1
0
    def runDistTestCase(self, testcase, met_calc):
        #create logdir
        if not os.path.isdir(testcase["testlogdir"]):
            os.makedirs(testcase["testlogdir"])
            os.makedirs(testcase["testoutputdir"])
        
        # Create docker command to run testcase: get all parameters
        bytesreq = testcase["bytesreq"]
        isquic = testcase["tcp_config"] == ""
        cmd = (
            "CURTIME=" + testcase["curtime"] + " "
            "SERVER_LOGS=" + testcase["testlogdir"] + " "
            "CLIENT_LOGS=" + testcase["testlogdir"] + " "
            "SCENARIO=\"" + testcase["scenario"] + "\" "
            "CLIENT=" + testcase["client"] + " "
            "SERVER=" + testcase["server"] + " "
            "BYTESREQ=" + bytesreq + " "
            "CLIENT_PARAMS=\"" + testcase["client_params"] + "\" "
            "SERVER_PARAMS=\"" + testcase["server_params"] + "\" "
            "CL_COMMIT=\"" + testcase['cl_commit'] + "\" "
            "SV_COMMIT=\"" + testcase['sv_commit'] + "\" "
        )
        # Check which simulator to run
        if testcase["sim"] == "qns":
            o_file = "/qns.out"
            cmd = cmd + "docker-compose -f ../quic-network-simulator/docker-compose.yml " + testcase["tcp_config"] + "up --abort-on-container-exit"
        else:
            o_file = "/min.out"
            cmd = cmd + "docker-compose -f ../containernet/docker-compose.yml up --abort-on-container-exit"
        print("Server: " + testcase["server"] + ". Client: " + testcase["client"] + ". Test case: " + testcase["scenario"] + ". Simulation: " + testcase["sim"])
        runsuccess = False
        while not runsuccess:
            try:
                r = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=90)
                output = r.stdout
            except subprocess.TimeoutExpired as ex:
                output = ex.stdout
                expired = True


            with open(testcase["testoutputdir"] + o_file, "w+") as outputfile:
                outputfile.write(output.decode('utf-8'))

            filemngr = FileManager()
            
            clpars = testcase["client_params"]
            clpars = clpars.replace("$CURTIME" , testcase["curtime"])
            clpars = clpars.replace("$BYTESREQ", bytesreq)
            svpars = testcase["server_params"]
            svpars = svpars.replace("$CURTIME" , testcase["curtime"])
            filemngr.addTestInfo(testcase["testlogdir"], testcase["scenario"], clpars, svpars, testcase["client"], testcase["server"], testcase["sim"])
            runsuccess = filemngr.pcaptojson(testcase["testlogdir"], testcase["sim"], met_calc, isquic, testcase["run"])
Exemplo n.º 2
0
    def _run_testcase(self, serverid: int, clientid: int, rootlogdir: str, rootoutputdir: str, curtime: str, scenario: dict, met_calc: MetricCalculator, isquic: bool, run: int):
        if isquic:
            servers = self._implementations['quic_servers']
            clients = self._implementations['quic_clients']
        else:
            servers = self._implementations['tcp_servers']
            clients = self._implementations['tcp_clients']

        clientname = clients[clientid]['name']
        servername = servers[serverid]['name']
        
        testlogdir = rootlogdir + servername + "/" + scenario['name'] + "/run" + str(run + 1)
        testoutputdir = rootoutputdir + servername + "/" + scenario['name'] + "/run" + str(run + 1)


        # create directories for logs and sim output
        if not os.path.isdir(testlogdir):
            os.makedirs(testlogdir)
            os.makedirs(testoutputdir)  

        # set up docker command to run test with NS-3: gather all parameters
        bytesreq = scenario["bytesreq"]
        logging.debug("Request: %s bytes", bytesreq)
        tcpqns_config = ""
        if not isquic:
            tcpqns_config = "-f ../quic-network-simulator/docker-compose.tcp.yml "
        qnscmd = (
            "CURTIME=" + curtime + " "
            "SERVER_LOGS=" + testlogdir + " "
            "CLIENT_LOGS=" + testlogdir + " "
            "SCENARIO=\"" + scenario["qns"] + "\" "
            "CLIENT=" + clientname + " "
            "SERVER=" + servername + " "
            "BYTESREQ=" + bytesreq + " "
            "CLIENT_PARAMS=\"" + clients[clientid]['clpars_qns'] + "\" "
            "SERVER_PARAMS=\"" + servers[serverid]['svpars_qns'] + "\" "
            "CL_COMMIT=\"" + clients[clientid]['clcommit'] + "\" "
            "SV_COMMIT=\"" + servers[serverid]['svcommit'] + "\" "
            "docker-compose -f ../quic-network-simulator/docker-compose.yml " + tcpqns_config + "up --abort-on-container-exit"
        )

        print("Server: " + servername + ". Client: " + clientname + ". Test case: " + scenario["qns"] + ". Simulation: QNS")
        runsuccess = False
        filemngr = FileManager()
        # keep running test if too many decryption errors are in pcap
        while not runsuccess:
            try:
                r = subprocess.run(qnscmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=90)
                output = r.stdout
            except subprocess.TimeoutExpired as ex:
                output = ex.stdout
                expired = True

            with open(testoutputdir + "/qns.out", "w+") as outputfile:
                outputfile.write(output.decode('utf-8'))

            filemngr = FileManager()
            
            # Parse test results
            clpars = clients[clientid]['clpars_qns']
            clpars = clpars.replace("$CURTIME" , curtime)
            clpars = clpars.replace("$BYTESREQ", bytesreq)
            svpars = servers[serverid]['svpars_qns']
            svpars = svpars.replace("$CURTIME" , curtime)
            filemngr.addTestInfo(testlogdir, scenario["qns"], clpars, svpars, clientname, servername, "QNS")
            runsuccess = filemngr.pcaptojson(testlogdir, "QNS", met_calc, isquic, run)

        # set up docker command to run test with Mininet: gather all parameters
        scenario_min = scenario["min"]
        if not isquic:
            scenario_min += " -k"
        mincmd = (
            "CURTIME=" + curtime + " "
            "SERVER_LOGS=" + testlogdir + " "
            "CLIENT_LOGS=" + testlogdir + " "
            "SCENARIO=\"" + scenario_min + "\" "
            "CLIENT=" + clientname + " "
            "SERVER=" + servername + " "
            "BYTESREQ=" + bytesreq + " "
            "CLIENT_PARAMS=\"" + clients[clientid]['clpars_min'] + "\" "
            "SERVER_PARAMS=\"" + servers[serverid]['svpars_min'] + "\" "
            "CL_COMMIT=\"" + clients[clientid]['clcommit'] + "\" "
            "SV_COMMIT=\"" + servers[serverid]['svcommit'] + "\" "
            "docker-compose -f ../containernet/docker-compose.yml up --abort-on-container-exit"
        )
        print("Server: " + servername + ". Client: " + clientname + ". Test case: " + scenario["min"] + ". Simulation: MININET")
        runsuccess = False
        while not runsuccess:
            try:
                r = subprocess.run(mincmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=90)
                output = r.stdout
            except subprocess.TimeoutExpired as ex:
                output = ex.stdout
                expired = True

            with open(testoutputdir + "/min.out", "w+") as outputfile:
                outputfile.write(output.decode('utf-8'))
            
            clpars = clients[clientid]['clpars_min']
            clpars = clpars.replace("$CURTIME" , curtime)
            clpars = clpars.replace("$BYTESREQ", bytesreq)
            svpars = servers[serverid]['svpars_min']
            svpars = svpars.replace("$CURTIME" , curtime)
            filemngr.addTestInfo(testlogdir, scenario["min"], clpars, svpars, clientname, servername, "MIN")
            runsuccess = filemngr.pcaptojson(testlogdir, "MIN", met_calc, isquic, run)