def main(): parser = argparse.ArgumentParser() parser.add_argument("-e", "--emultype", help="Emulation type") parser.add_argument("-t", "--time", help="Duration of the test") parser.add_argument("-i", "--infra", help="Infrastructure file") parser.add_argument("-s", "--service", help="Service file") parser.add_argument("-b", "--default_bwd", help="Default bandwidth limitation in the interface") args = parser.parse_args() if (args.default_bwd): infra.deploy_infrastructure(args.emultype, args.infra) net_rules.deploy_net_rules(args.emultype, args.infra, args.service) services.deploy_services(args.emultype, args.time, args.infra, args.service, args.default_bwd) else: args.default_bwd = float(0.0) infra.deploy_infrastructure(args.emultype, args.infra) net_rules.deploy_net_rules(args.emultype, args.infra, args.service) services.deploy_services(args.emultype, args.time, args.infra, args.service, args.default_bwd)
def deploy_second_phase_server(origin_bwd, duration, pktloss): for vcpu_count in range(10): vcpu = (vcpu_count + 1.0) / 10.0 print "\033[1m" + "Testing server with", vcpu, "vCPU for", origin_bwd, "Mbps" + "\033[0m" fileInfra = "benchmarker_Infra.json" infra.deploy_infrastructure(fileInfra, vcpu, 1) services.deploy_services(fileInfra, origin_bwd, duration, 2) file = "/home/expran/results/client{}_{}_server.txt".format( 2, origin_bwd) fileHandle = open(file, "r") lineList = fileHandle.readlines() fileHandle.close() your_text = lineList[-2].replace(" ", "") if (your_text.find('ServerReport:') != -1): your_text = lineList[-1].replace(" ", "") if (your_text.find("Gbits") > -1): bandwidth = your_text[your_text.find("Bytes") + 5:your_text.find("Gbits")] bandwidth = float(bandwidth) * 1000 elif (your_text.find("Kbits") > -1): bandwidth = your_text[your_text.find("Bytes") + 5:your_text.find("Kbits")] bandwidth = float(bandwidth) / 1000 elif (your_text.find("Mbits") > -1): bandwidth = your_text[your_text.find("Bytes") + 5:your_text.find("Mbits")] bandwidth = float(bandwidth) origin_bwd = float(origin_bwd) dropped = your_text[your_text.find("(") + 1:your_text.find("%)")] dropped = float(dropped) dropped = (((origin_bwd - bandwidth) + (bandwidth * (dropped / 100.0))) / origin_bwd) * 100 print "\033[1m" + "The percentage of packet loss for", vcpu, "vCPU was", dropped, "%" + "\033[0m" os.system("python destroy_emulation.py -u n -i benchmarker_Infra.json") if (dropped <= pktloss): print "\033[1m" + "So,", vcpu, "vCPU is enough for the server" + "\033[0m" break return vcpu
def deploy_second_phase_server_client(origin_bwd, duration, pktloss, vcpu_server, vcpu_client): fileInfra = "benchmarker_Infra.json" print "\033[1m" + "Testing with", vcpu_server, "vCPU for the server and", vcpu_client, "vCPU for the client. Throughput is", origin_bwd, "Mbps" + "\033[0m" infra.deploy_infrastructure(fileInfra, vcpu_server, vcpu_client) services.deploy_services(fileInfra, origin_bwd, duration, 4) file = "/home/expran/results/client{}.txt".format(4) fileHandle = open(file, "r") lineList = fileHandle.readlines() fileHandle.close() your_text = lineList[-2].replace(" ", "") if (your_text.find('ServerReport:') != -1): your_text = lineList[-1].replace(" ", "") if (your_text.find("Gbits") > -1): bandwidth = your_text[your_text.find("Bytes") + 5:your_text.find("Gbits")] bandwidth = float(bandwidth) * 1000 elif (your_text.find("Kbits") > -1): bandwidth = your_text[your_text.find("Bytes") + 5:your_text.find("Kbits")] bandwidth = float(bandwidth) / 1000 elif (your_text.find("Mbits") > -1): bandwidth = your_text[your_text.find("Bytes") + 5:your_text.find("Mbits")] bandwidth = float(bandwidth) origin_bwd = float(origin_bwd) dropped = your_text[your_text.find("(") + 1:your_text.find("%)")] dropped = float(dropped) dropped = (((origin_bwd - bandwidth) + (bandwidth * (dropped / 100.0))) / origin_bwd) * 100 os.system("python destroy_emulation.py -u n -i benchmarker_Infra.json") print "The percentage of packet loss with", vcpu_server, "vCPU for the server and", vcpu_client, "vCPU for the client was", dropped, "%" print "\033[1m" + "The recommendation of the benchmarker is: To achieve", pktloss, "%" + " of packet loss, you should use", vcpu_server, "vCPU for the server and", vcpu_client, "vCPU for the client. Throughput should be", origin_bwd, "Mbps." + "\033[0m" print "Benchmarker finished!"
def deploy_first_phase(origin_bwd, duration): fileInfra = "benchmarker_Infra.json" infra.deploy_infrastructure(fileInfra, 1, 1) services.deploy_services(fileInfra, origin_bwd, duration, 1) file = "/home/expran/results/client{}_{}.txt".format(1, origin_bwd) fileHandle = open(file, "r") lineList = fileHandle.readlines() fileHandle.close() your_text = lineList[-2].replace(" ", "") if (your_text.find('ServerReport:') != -1): your_text = lineList[-1].replace(" ", "") if (your_text.find("Gbits") > -1): bandwidth = your_text[your_text.find("Bytes") + 5:your_text.find("Gbits")] bandwidth = float(bandwidth) * 1000 elif (your_text.find("Kbits") > -1): bandwidth = your_text[your_text.find("Bytes") + 5:your_text.find("Kbits")] bandwidth = float(bandwidth) / 1000 elif (your_text.find("Mbits") > -1): bandwidth = your_text[your_text.find("Bytes") + 5:your_text.find("Mbits")] bandwidth = float(bandwidth) origin_bwd = float(origin_bwd) dropped = your_text[your_text.find("(") + 1:your_text.find("%)")] dropped = float(dropped) dropped = (((origin_bwd - bandwidth) + (bandwidth * (dropped / 100.0))) / origin_bwd) * 100 return dropped