def benchmark(self, index, lcore, num_pthreads, size_list): """ Just Test IPv4 Throughput for selected parameters. """ Bps = dict() Pps = dict() Pct = dict() if int(lcore[0]) == 1: core_mask = dts.create_mask(self.dut.get_core_list(lcore, socket=self.ports_socket)) else: core_mask = dts.create_mask(self.dut.get_core_list(lcore)) portmask = dts.create_mask([P0, P1]) self.dut.send_expect("examples/ip_fragmentation/build/ip_fragmentation -c %s -n %d -- -p %s -q %s" % ( core_mask, self.dut.get_memory_channels(), portmask, num_pthreads), "IP_FRAG:", 120) result = [2, lcore, num_pthreads] for size in size_list: dmac = self.dut.get_mac_address(P0) flows = ['Ether(dst="%s")/IP(src="1.2.3.4", dst="100.10.0.1", flags=0)/("X"*%d)' % (dmac, size - 38), 'Ether(dst="%s")/IP(src="1.2.3.4", dst="100.20.0.1", flags=0)/("X"*%d)' % (dmac, size - 38), 'Ether(dst="%s")/IPv6(dst="101:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58), 'Ether(dst="%s")/IPv6(dst="201:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58)] self.tester.scapy_append('wrpcap("test1.pcap", [%s])' % string.join(flows, ',')) # reserved for rx/tx bidirection test dmac = self.dut.get_mac_address(P1) flows = ['Ether(dst="%s")/IP(src="1.2.3.4", dst="100.30.0.1", flags=0)/("X"*%d)' % (dmac, size - 38), 'Ether(dst="%s")/IP(src="1.2.3.4", dst="100.40.0.1", flags=0)/("X"*%d)' % (dmac, size - 38), 'Ether(dst="%s")/IPv6(dst="301:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58), 'Ether(dst="%s")/IPv6(dst="401:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58)] self.tester.scapy_append('wrpcap("test2.pcap", [%s])' % string.join(flows, ',')) self.tester.scapy_execute() tgenInput = [] tgenInput.append((self.tester.get_local_port(P0), self.tester.get_local_port(P1), "test1.pcap")) tgenInput.append((self.tester.get_local_port(P1), self.tester.get_local_port(P0), "test2.pcap")) factor = (size + 1517) / 1518 # wireSpd = 2 * 10000.0 / ((20 + size) * 8) Bps[str(size)], Pps[str(size)] = self.tester.traffic_generator_throughput(tgenInput) self.verify(Pps[str(size)] > 0, "No traffic detected") Pps[str(size)] *= 1.0 / factor / 1000000 Pct[str(size)] = (1.0 * Bps[str(size)] * 100) / (2 * 10000000000) result.append(Pps[str(size)]) result.append(Pct[str(size)]) dts.results_table_add_row(result) self.dut.send_expect("^C", "#")
def lcore_table_print(self, horizontal=False): if not horizontal: dts.results_table_add_header(['Socket', 'Core', 'Thread']) for lcore in self.cores: dts.results_table_add_row([lcore['socket'], lcore['core'], lcore['thread']]) dts.results_table_print() else: dts.results_table_add_header(['X'] + [''] * len(self.cores)) dts.results_table_add_row(['Thread'] + [n['thread'] for n in self.cores]) dts.results_table_add_row(['Core'] + [n['core'] for n in self.cores]) dts.results_table_add_row(['Socket'] + [n['socket'] for n in self.cores]) dts.results_table_print()
def benchmark(self, lcore, ptype, mode, flow_format, size_list, nic): """ Test ans report checksum offload performance for given parameters. """ Bps = dict() Pps = dict() Pct = dict() dmac = self.dut.get_mac_address(self.dut_ports[0]) result = [2, lcore, ptype, mode] for size in size_list: flow = flow_format % (dmac, size) self.tester.scapy_append('wrpcap("test.pcap", [%s])' % flow) self.tester.scapy_execute() tgenInput = [] tgenInput.append( (self.tester.get_local_port(self.dut_ports[0]), self.tester.get_local_port(self.dut_ports[1]), "test.pcap")) tgenInput.append( (self.tester.get_local_port(self.dut_ports[1]), self.tester.get_local_port(self.dut_ports[0]), "test.pcap")) Bps[str(size)], Pps[str( size)] = self.tester.traffic_generator_throughput(tgenInput) self.verify(Pps[str(size)] > 0, "No traffic detected") Pps[str(size)] /= 1E6 Pct[str(size)] = (Pps[str(size)] * 100) / self.wirespeed( self.nic, size, 2) result.append(Pps[str(size)]) result.append(Pct[str(size)]) dts.results_table_add_row(result)
def lcore_table_print(self, horizontal=False): if not horizontal: dts.results_table_add_header(['Socket', 'Core', 'Thread']) for lcore in self.cores: dts.results_table_add_row( [lcore['socket'], lcore['core'], lcore['thread']]) dts.results_table_print() else: dts.results_table_add_header(['X'] + [''] * len(self.cores)) dts.results_table_add_row(['Thread'] + [n['thread'] for n in self.cores]) dts.results_table_add_row(['Core'] + [n['core'] for n in self.cores]) dts.results_table_add_row(['Socket'] + [n['socket'] for n in self.cores]) dts.results_table_print()
def benchmark(self, index, lcore, num_pthreads, size_list): """ Just Test IPv4 Throughput for selected parameters. """ Bps = dict() Pps = dict() Pct = dict() if int(lcore[0]) == 1: core_mask = dts.create_mask(self.dut.get_core_list(lcore, socket=self.ports_socket)) else: core_mask = dts.create_mask(self.dut.get_core_list(lcore)) portmask = dts.create_mask([P0, P1]) self.dut.send_expect( "examples/ip_fragmentation/build/ip_fragmentation -c %s -n %d -- -p %s -q %s" % (core_mask, self.dut.get_memory_channels(), portmask, num_pthreads), "IP_FRAG:", 120, ) result = [2, lcore, num_pthreads] for size in size_list: dmac = self.dut.get_mac_address(P0) flows = [ 'Ether(dst="%s")/IP(src="1.2.3.4", dst="100.10.0.1", flags=0)/("X"*%d)' % (dmac, size - 38), 'Ether(dst="%s")/IP(src="1.2.3.4", dst="100.20.0.1", flags=0)/("X"*%d)' % (dmac, size - 38), 'Ether(dst="%s")/IPv6(dst="101:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58), 'Ether(dst="%s")/IPv6(dst="201:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58), ] self.tester.scapy_append('wrpcap("test1.pcap", [%s])' % string.join(flows, ",")) # reserved for rx/tx bidirection test dmac = self.dut.get_mac_address(P1) flows = [ 'Ether(dst="%s")/IP(src="1.2.3.4", dst="100.30.0.1", flags=0)/("X"*%d)' % (dmac, size - 38), 'Ether(dst="%s")/IP(src="1.2.3.4", dst="100.40.0.1", flags=0)/("X"*%d)' % (dmac, size - 38), 'Ether(dst="%s")/IPv6(dst="301:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58), 'Ether(dst="%s")/IPv6(dst="401:101:101:101:101:101:101:101",src="ee80:ee80:ee80:ee80:ee80:ee80:ee80:ee80")/Raw(load="X"*%d)' % (dmac, size - 58), ] self.tester.scapy_append('wrpcap("test2.pcap", [%s])' % string.join(flows, ",")) self.tester.scapy_execute() tgenInput = [] tgenInput.append((self.tester.get_local_port(P0), self.tester.get_local_port(P1), "test1.pcap")) tgenInput.append((self.tester.get_local_port(P1), self.tester.get_local_port(P0), "test2.pcap")) factor = (size + 1517) / 1518 # wireSpd = 2 * 10000.0 / ((20 + size) * 8) Bps[str(size)], Pps[str(size)] = self.tester.traffic_generator_throughput(tgenInput) self.verify(Pps[str(size)] > 0, "No traffic detected") Pps[str(size)] *= 1.0 / factor / 1000000 Pct[str(size)] = (1.0 * Bps[str(size)] * 100) / (2 * 10000000000) result.append(Pps[str(size)]) result.append(Pct[str(size)]) dts.results_table_add_row(result) self.dut.send_expect("^C", "#")
def test_perf_l3fwd_2ports(self): """ L3fwd main 2 ports. """ header_row = ["Frame", "Ports", "S/C/T", "Mpps", "% linerate", "mode"] self.l3fwd_test_results['header'] = header_row dts.results_table_add_header(header_row) self.l3fwd_test_results['data'] = [] for frame_size in TestL3fwd.frame_sizes: # Prepare traffic flow payload_size = frame_size - HEADER_SIZE['udp'] - \ HEADER_SIZE['ip'] - HEADER_SIZE['eth'] flows = ['Ether()/%s/("X"*%d)' % (flow, payload_size) for flow in self.flows()[:4]] dts.report("Flows for 2 ports, %d frame size.\n" % (frame_size), annex=True) dts.report("%s" % string.join(flows, '\n'), frame=True, annex=True) self.tester.scapy_append('wrpcap("test2ports.pcap", [%s])' % string.join(flows, ',')) self.tester.scapy_execute() # Prepare the command line global corelist pat = re.compile("P([0123]),([0123]),(C\{\d.\d.\d\})") coreMask = {} rtCmdLines = dict(TestL3fwd.test_cases_2_ports) for key in rtCmdLines.keys(): corelist = [] while pat.search(rtCmdLines[key]): rtCmdLines[key] = pat.sub(self.repl, rtCmdLines[key]) self.logger.info("%s\n" % str(corelist)) coreMask[key] = dts.create_mask(set(corelist)) # measure by two different mode for mode in TestL3fwd.methods: # start l3fwd index = 0 subtitle = [] for cores in rtCmdLines.keys(): info = "Executing l3fwd using %s mode, 2 ports, %s and %d frame size.\n" % ( mode, cores, frame_size) self.logger.info(info) dts.report(info, annex=True) subtitle.append(cores) cmdline = rtCmdLines[cores] % (TestL3fwd.path + "l3fwd_" + mode, coreMask[cores], self.dut.get_memory_channels(), dts.create_mask(valports[:2])) dts.report(cmdline + "\n", frame=True, annex=True) out = self.dut.send_expect(cmdline, "L3FWD:", 120) # Measure test tgenInput = [] for rxPort in range(2): # No use on rx/tx limitation if rxPort % 2 == 0: txIntf = self.tester.get_local_port(valports[rxPort + 1]) else: txIntf = self.tester.get_local_port(valports[rxPort - 1]) rxIntf = self.tester.get_local_port(valports[rxPort]) tgenInput.append((txIntf, rxIntf, "test2ports.pcap")) _, pps = self.tester.traffic_generator_throughput(tgenInput) self.verify(pps > 0, "No traffic detected") pps /= 1000000.0 linerate = self.wirespeed(self.nic, frame_size, 2) pct = pps * 100 / linerate index += 1 # Stop l3fwd self.dut.send_expect("^C", "#") data_row = [frame_size, 2, cores, str(pps), str(pct), mode] dts.results_table_add_row(data_row) self.l3fwd_test_results['data'].append(data_row) self.plot_2_ports() dts.results_table_print()
def get_throughput(self, frame_size, rx_queues_per_port, cores_config, command_line): """ Get the throughput for a test case from test_cases_4_ports. """ output_pattern = re.compile("P([0123]),([0123]),(C\{\d.\d.\d\})") bps = dict() pps = dict() pct = dict() global corelist corelist = [] while output_pattern.search(command_line): command_line = output_pattern.sub(self.repl, command_line) self.logger.debug("%s\n" % str(corelist)) core_mask = dts.create_mask(set(corelist)) # First, measure by two different methods for method in TestL3fwd.methods: # start l3fwd method_command_line = command_line % (TestL3fwd.path + "l3fwd_" + method, core_mask, self.dut.get_memory_channels(), dts.create_mask(valports[:4])) dts.report(method_command_line + "\n", frame=True, annex=True) out = self.dut.send_expect(method_command_line, "L3FWD:", 120) # measure test tgen_input = [] for rxPort in range(4): if rxPort % 2 == 0: tx_interface = self.tester.get_local_port(valports[rxPort + 1]) else: tx_interface = self.tester.get_local_port(valports[rxPort - 1]) rx_interface = self.tester.get_local_port(valports[rxPort]) tgen_input.append((tx_interface, rx_interface, "dst%d.pcap" % valports[rxPort])) # FIX ME bps[method], pps[method] = self.tester.traffic_generator_throughput(tgen_input) self.verify(pps[method] > 0, "No traffic detected") pps[method] /= 1000000.0 pct[method] = pps[method] * 100 / float(self.wirespeed(self.nic, frame_size, 4)) # stop l3fwd self.dut.send_expect("^C", "#") data_row = [frame_size, rx_queues_per_port, cores_config] for method in TestL3fwd.methods: data_row.append(pps[method]) data_row.append(pct[method]) # generate report table dts.results_table_add_row(data_row) self.l3fwd_test_results['data'].append(data_row)
def test_perf_pmd_performance_2ports(self): """ PMD Performance Benchmarking with 2 ports. """ all_cores_mask = dts.create_mask(self.dut.get_core_list("all")) # prepare traffic generator input tgen_input = [] tgen_input.append( (self.tester.get_local_port(self.dut_ports[0]), self.tester.get_local_port(self.dut_ports[1]), "test.pcap")) tgen_input.append( (self.tester.get_local_port(self.dut_ports[1]), self.tester.get_local_port(self.dut_ports[0]), "test.pcap")) # run testpmd for each core config for test_cycle in self.test_cycles: core_config = test_cycle['cores'] core_list = self.dut.get_core_list(core_config, socket=self.ports_socket) if len(core_list) > 2: queues = len(core_list) / 2 else: queues = 1 core_mask = dts.create_mask(core_list) port_mask = dts.create_mask([self.dut_ports[0], self.dut_ports[1]]) self.pmdout.start_testpmd( "all", "--coremask=%s --rxq=%d --txq=%d --portmask=%s" % (core_mask, queues, queues, port_mask)) command_line = self.pmdout.get_pmd_cmd() info = "Executing PMD using %s\n" % test_cycle['cores'] self.logger.info(info) dts.report(info, annex=True) dts.report(command_line + "\n\n", frame=True, annex=True) self.dut.send_expect("start", "testpmd> ") for frame_size in self.frame_sizes: wirespeed = self.wirespeed(self.nic, frame_size, 2) # create pcap file self.logger.info("Running with frame size %d " % frame_size) payload_size = frame_size - self.headers_size self.tester.scapy_append( 'wrpcap("test.pcap", [Ether(src="52:00:00:00:00:00")/IP()/UDP()/("X"*%d)])' % payload_size) self.tester.scapy_execute() # run traffic generator _, pps = self.tester.traffic_generator_throughput(tgen_input) pps /= 1000000.0 test_cycle['Mpps'][frame_size] = pps test_cycle['pct'][frame_size] = pps * 100 / wirespeed self.dut.send_expect("stop", "testpmd> ") self.dut.send_expect("quit", "# ", 30) sleep(5) for n in range(len(self.test_cycles)): for frame_size in self.frame_sizes: self.verify(self.test_cycles[n]['Mpps'][frame_size] > 0, "No traffic detected") # Print results dts.results_table_add_header(self.table_header) for frame_size in self.frame_sizes: table_row = [frame_size] for test_cycle in self.test_cycles: table_row.append(test_cycle['Mpps'][frame_size]) table_row.append(test_cycle['pct'][frame_size]) dts.results_table_add_row(table_row) self.plot_results(number_ports=2) dts.results_table_print()
def test_perf_multiprocess_client_serverperformance(self): """ Benchmark Multiprocess client-server performance. """ self.dut.kill_all() self.dut.send_expect("fg", "# ") dutPorts = self.dut.get_ports() txPort = self.tester.get_local_port(dutPorts[0]) rxPort = self.tester.get_local_port(dutPorts[1]) mac = self.tester.get_mac(txPort) self.tester.scapy_append('dmac="%s"' % self.dut.get_mac_address(dutPorts[0])) self.tester.scapy_append('smac="%s"' % mac) if not self.dut.want_perf_tests: self.tester.scapy_append( 'flows = [Ether(src=smac, dst=dmac)/IP(src="192.168.1.%s" % src, dst="192.168.1.%s" % dst)/("X"*26) for src in range(64) for dst in range(64)]' ) else: self.tester.scapy_append( 'flows = [Ether(src=smac, dst=dmac)/IP(src="192.168.1.1", dst="192.168.1.1")/("X"*26)]' ) self.tester.scapy_append('wrpcap("test.pcap", flows)') self.tester.scapy_execute() validExecutions = [] for execution in executions: if len(self.dut.get_core_list( execution['cores'])) == execution['nprocs']: validExecutions.append(execution) for execution in validExecutions: coreList = self.dut.get_core_list(execution['cores']) coreMask = dts.create_mask(self.dut.get_core_list('1S/1C/1T')) portMask = dts.create_mask([dutPorts[0], dutPorts[1]]) self.dut.send_expect( "./examples/multi_process/client_server_mp/mp_server/client_server_mp/mp_server/%s/mp_server -n %d -c %s -- -p %s -n %d" % (self.target, self.dut.get_memory_channels(), "0xA0", portMask, execution['nprocs']), "Finished Process Init", 20) self.dut.send_expect("^Z", "\r\n") self.dut.send_expect("bg", "# ") for n in range(execution['nprocs']): time.sleep(5) coreMask = dts.create_mask([coreList[n]]) self.dut.send_expect( "./examples/multi_process/client_server_mp/mp_client/client_server_mp/mp_client/%s/mp_client -n %d -c %s --proc-type=secondary -- -n %d" % (self.target, self.dut.get_memory_channels(), coreMask, n), "Finished Process Init") self.dut.send_expect("^Z", "\r\n") self.dut.send_expect("bg", "# ") tgenInput = [] tgenInput.append([txPort, rxPort, "test.pcap"]) _, pps = self.tester.traffic_generator_throughput(tgenInput) execution['pps'] = pps self.dut.kill_all() time.sleep(5) for n in range(len(executions)): self.verify(executions[n]['pps'] is not 0, "No traffic detected") dts.results_table_add_header([ 'Server threads', 'Server Cores/Threads', 'Num-procs', 'Sockets/Cores/Threads', 'Num Ports', 'Frame Size', '%-age Line Rate', 'Packet Rate(mpps)' ]) for execution in validExecutions: dts.results_table_add_row([ 1, '1S/1C/1T', execution['nprocs'], execution['cores'], 2, 64, execution['pps'] / float(100000000 / (8 * 84)), execution['pps'] / float(1000000) ]) dts.results_table_print()
def test_perf_pmd_performance_2ports(self): """ PMD Performance Benchmarking with 2 ports. """ all_cores_mask = dts.create_mask(self.dut.get_core_list("all")) # prepare traffic generator input tgen_input = [] tgen_input.append((self.tester.get_local_port(self.dut_ports[0]), self.tester.get_local_port(self.dut_ports[1]), "test.pcap")) tgen_input.append((self.tester.get_local_port(self.dut_ports[1]), self.tester.get_local_port(self.dut_ports[0]), "test.pcap")) # run testpmd for each core config for test_cycle in self.test_cycles: core_config = test_cycle['cores'] core_list = self.dut.get_core_list(core_config, socket=self.ports_socket) if len(core_list) > 2: queues = len(core_list) / 2 else: queues = 1 core_mask = dts.create_mask(core_list) port_mask = dts.create_mask([self.dut_ports[0], self.dut_ports[1]]) self.pmdout.start_testpmd("all", "--coremask=%s --rxq=%d --txq=%d --portmask=%s" % (core_mask, queues, queues, port_mask)) command_line = self.pmdout.get_pmd_cmd() info = "Executing PMD using %s\n" % test_cycle['cores'] self.logger.info(info) dts.report(info, annex=True) dts.report(command_line + "\n\n", frame=True, annex=True) self.dut.send_expect("start", "testpmd> ") for frame_size in self.frame_sizes: wirespeed = self.wirespeed(self.nic, frame_size, 2) # create pcap file self.logger.info("Running with frame size %d " % frame_size) payload_size = frame_size - self.headers_size self.tester.scapy_append( 'wrpcap("test.pcap", [Ether(src="52:00:00:00:00:00")/IP()/UDP()/("X"*%d)])' % payload_size) self.tester.scapy_execute() # run traffic generator _, pps = self.tester.traffic_generator_throughput(tgen_input) pps /= 1000000.0 test_cycle['Mpps'][frame_size] = pps test_cycle['pct'][frame_size] = pps * 100 / wirespeed self.dut.send_expect("stop", "testpmd> ") self.dut.send_expect("quit", "# ", 30) sleep(5) for n in range(len(self.test_cycles)): for frame_size in self.frame_sizes: self.verify(self.test_cycles[n]['Mpps'][ frame_size] > 0, "No traffic detected") # Print results dts.results_table_add_header(self.table_header) for frame_size in self.frame_sizes: table_row = [frame_size] for test_cycle in self.test_cycles: table_row.append(test_cycle['Mpps'][frame_size]) table_row.append(test_cycle['pct'][frame_size]) dts.results_table_add_row(table_row) self.plot_results(number_ports=2) dts.results_table_print()
def test_perf_l2fwd_performance(self): """ Benchmark performance for frame_sizes. """ ports = [] for port in xrange(self.number_of_ports): ports.append(self.dut_ports[port]) port_mask = dts.create_mask(ports) core_mask = dts.create_mask(self.dut.get_core_list(self.core_config, socket=self.ports_socket)) for frame_size in self.frame_sizes: payload_size = frame_size - self.headers_size tgen_input = [] for port in xrange(self.number_of_ports): rx_port = self.tester.get_local_port(self.dut_ports[port % self.number_of_ports]) tx_port = self.tester.get_local_port(self.dut_ports[(port + 1) % self.number_of_ports]) destination_mac = self.dut.get_mac_address(self.dut_ports[(port + 1) % self.number_of_ports]) self.tester.scapy_append('wrpcap("l2fwd_%d.pcap", [Ether(dst="%s")/IP()/UDP()/("X"*%d)])' % ( port, destination_mac, payload_size)) tgen_input.append((tx_port, rx_port, "l2fwd_%d.pcap" % port)) self.tester.scapy_execute() for queues in self.test_queues: command_line = "./examples/l2fwd/build/app/l2fwd -n %d -c %s -- -q %s -p %s &" % \ (self.dut.get_memory_channels(), core_mask, str(queues['queues']), port_mask) self.dut.send_expect(command_line, "memory mapped", 60) info = "Executing l2fwd using %s queues, frame size %d and %s setup.\n" % \ (queues['queues'], frame_size, self.core_config) self.logger.info(info) dts.report(info, annex=True) dts.report(command_line + "\n\n", frame=True, annex=True) _, pps = self.tester.traffic_generator_throughput(tgen_input) Mpps = pps / 1000000.0 queues['Mpps'][frame_size] = Mpps queues['pct'][frame_size] = Mpps * 100 / float(self.wirespeed( self.nic, frame_size, self.number_of_ports)) self.quit_l2fwd() # Look for transmission error in the results for frame_size in self.frame_sizes: for n in range(len(self.test_queues)): self.verify(self.test_queues[n]['Mpps'][frame_size] > 0, "No traffic detected") # Prepare the results for table and plot printing for frame_size in self.frame_sizes: results_row = [] results_row.append(frame_size) for queue in self.test_queues: results_row.append(queue['Mpps'][frame_size]) results_row.append(queue['pct'][frame_size]) dts.results_table_add_row(results_row) self.plot_results() dts.results_table_print()