From d18bbeed7e6facd01605d90bf55e184c0880e176 Mon Sep 17 00:00:00 2001 From: Andrew Theurer Date: Thu, 10 Dec 2020 13:01:58 -0500 Subject: [PATCH 1/5] avoid tmux --- launch-trex.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launch-trex.sh b/launch-trex.sh index a271d36..f5f21e3 100755 --- a/launch-trex.sh +++ b/launch-trex.sh @@ -251,7 +251,7 @@ if [ -d ${trex_dir} -a -d ${tmp_dir} ]; then cat ${yaml_file} echo "-------------------------------------------------------------------" rm -fv /tmp/trex.server.out - tmux new-session -d -n server -s trex "bash -c '${trex_server_cmd} | tee /tmp/trex.server.out'" + ${trex_server_cmd} 2>&1 >/tmp/trex.server.out & # wait for trex server to be ready count=60 From e8031225ff1861ed769fed8abaf731e596d3748d Mon Sep 17 00:00:00 2001 From: Andrew Theurer Date: Mon, 11 Jan 2021 19:56:00 -0500 Subject: [PATCH 2/5] Skip ofed check -should not be necessary if proper packages (lib-rdma) are installed -may not have ofed installed --- launch-trex.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launch-trex.sh b/launch-trex.sh index f5f21e3..e343abc 100755 --- a/launch-trex.sh +++ b/launch-trex.sh @@ -244,7 +244,7 @@ if [ -d ${trex_dir} -a -d ${tmp_dir} ]; then else vlan_opt="" fi - trex_server_cmd="./t-rex-64 -i -c ${trex_cpus} --checksum-offload --cfg ${yaml_file} --iom 0 -v 4 --prefix trafficgen_trex_ ${vlan_opt}" + trex_server_cmd="./t-rex-64 -i -c ${trex_cpus} --no-ofed-check --checksum-offload --cfg ${yaml_file} --iom 0 -v 4 --prefix trafficgen_trex_ ${vlan_opt}" echo "about to run: ${trex_server_cmd}" echo "trex yaml:" echo "-------------------------------------------------------------------" From 433327bbad86f0f6af654135eee5f76d1071e2b7 Mon Sep 17 00:00:00 2001 From: Andrew Theurer Date: Tue, 12 Jan 2021 10:18:34 -0500 Subject: [PATCH 3/5] Updates for further experiment with VFs in pods --- install-trex.sh | 2 +- tg_lib.py | 19 +++++++++++++++++++ trex_tg_lib.py | 11 +++++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/install-trex.sh b/install-trex.sh index fc10e88..09eda63 100755 --- a/install-trex.sh +++ b/install-trex.sh @@ -2,7 +2,7 @@ base_dir="/opt/trex" tmp_dir="/tmp" -trex_ver="v2.82" +trex_ver="v2.87" insecure_curl=0 force_install=0 diff --git a/tg_lib.py b/tg_lib.py index 94ab32e..527ac1c 100644 --- a/tg_lib.py +++ b/tg_lib.py @@ -50,6 +50,25 @@ def ip_to_int (ip): return ip_int +def int_to_ip (_int): + octet = int(_int / (256**3)) + _int = _int - (octet * 256**3) + ip = str(octet) + + octet = int(_int / (256**2)) + _int = _int - (octet * 256**2) + ip = ip + "." + str(octet) + + octet = int(_int / (256**1)) + _int = _int - (octet * 256**1) + ip = ip + "." + str(octet) + + _int = _int - (octet * 256**1) + ip = ip + "." + str(octet) + print("int_to_ip(), ip is " + ip) + return ip + + def calculate_latency_pps (dividend, divisor, total_rate, protocols): return int((float(dividend) / float(divisor) * total_rate / protocols)) diff --git a/trex_tg_lib.py b/trex_tg_lib.py index a4a3fb5..437bf70 100644 --- a/trex_tg_lib.py +++ b/trex_tg_lib.py @@ -163,6 +163,8 @@ def create_generic_pkt (size, mac_src, mac_dst, ip_src, ip_dst, port_src, port_d size = int(size) size -= 4 + print("ip_src: " + ip_src); + print("ip_dst: " + ip_dst); port_range = { "start": 0, "end": 65535 } if num_flows > 1 and (flow_mods['port']['src'] or flow_mods['port']['dst']): if num_flows < 1000: @@ -197,8 +199,8 @@ def create_generic_pkt (size, mac_src, mac_dst, ip_src, ip_dst, port_src, port_d tmp_num_flows = num_flows - 1 - ip_src = { "start": ip_to_int(ip_src) + flow_offset, "end": ip_to_int(ip_src) + tmp_num_flows + flow_offset } - ip_dst = { "start": ip_to_int(ip_dst) + flow_offset, "end": ip_to_int(ip_dst) + tmp_num_flows + flow_offset } + ip_src = { "start": int_to_ip(ip_to_int(ip_src) + flow_offset), "end": int_to_ip(ip_to_int(ip_src) + tmp_num_flows + flow_offset) } + ip_dst = { "start": int_to_ip(ip_to_int(ip_dst) + flow_offset), "end": int_to_ip(ip_to_int(ip_dst) + tmp_num_flows + flow_offset) } vm = [] if flow_mods['ip']['src'] and tmp_num_flows: @@ -252,18 +254,23 @@ def create_generic_pkt (size, mac_src, mac_dst, ip_src, ip_dst, port_src, port_d ] base = Ether(src = mac_src, dst = mac_dst) + print("initial base with mac:" + dump_json_readable(base)) if vlan_id is not None: base = base/Dot1Q(vlan = vlan_id) # with vlan tag, minimum 64 L2 frame size is required, otherwise trex will fail size = max(64, size) + print("str(ip_src[start]): " + str(ip_src['start'])) + print("str(ip_dst[start]): " + str(ip_dst['start'])) base = base/IP(src = str(ip_src['start']), dst = str(ip_dst['start'])) + print("base with IP:" + dump_json_readable(base)) if packet_protocol == "UDP": base = base/UDP(sport = port_src['init'], dport = port_dst['init'] ) elif packet_protocol == "TCP": base = base/TCP(sport = port_src['init'], dport = port_dst['init'] ) + print("base: " + dump_json_readable(base)) pad = max(0, size-len(base)) * 'x' the_packet = base/pad From 12b6b0529e67ce97691d137aab6832694ad84bcc Mon Sep 17 00:00:00 2001 From: Andrew Theurer Date: Sun, 17 Jan 2021 12:38:59 -0500 Subject: [PATCH 4/5] remove unneeded prints --- tg_lib.py | 1 - trex_tg_lib.py | 20 -------------------- 2 files changed, 21 deletions(-) diff --git a/tg_lib.py b/tg_lib.py index 527ac1c..1bc75c8 100644 --- a/tg_lib.py +++ b/tg_lib.py @@ -65,7 +65,6 @@ def int_to_ip (_int): _int = _int - (octet * 256**1) ip = ip + "." + str(octet) - print("int_to_ip(), ip is " + ip) return ip diff --git a/trex_tg_lib.py b/trex_tg_lib.py index 437bf70..66e4c5f 100644 --- a/trex_tg_lib.py +++ b/trex_tg_lib.py @@ -85,8 +85,6 @@ def create_icmp_pkt (size, mac_src, mac_dst, ip_src, ip_dst, vlan_id, flow_mods, pad = max(0, size - len(the_packet)) * 'x' the_packet = the_packet/pad - #print("create_icmp_pkt: scapy:%s\n" % (the_packet.command())) - if tmp_num_flows and (flow_mods['ip']['src'] or flow_mods['ip']['dst'] or flow_mods['mac']['src'] or flow_mods['mac']['dst']): vm = vm + [STLVmFixIpv4(offset = "IP")] @@ -145,8 +143,6 @@ def create_garp_pkt (mac_src, ip_src, vlan_id, arp_op, flow_mods, num_flows, ena the_packet = the_packet/ARP(op = arp_op, hwsrc = mac_src, psrc = str(ip_src['start']), hwdst = arp_mac_target, pdst = str(ip_src['start'])) - #print("create_garp_pkt: scapy:%s\n" % (the_packet.command())) - if tmp_num_flows and (flow_mods['ip']['src'] or flow_mods['mac']['src']): if enable_flow_cache: vm = STLScVmRaw(list_of_commands = vm, @@ -163,8 +159,6 @@ def create_generic_pkt (size, mac_src, mac_dst, ip_src, ip_dst, port_src, port_d size = int(size) size -= 4 - print("ip_src: " + ip_src); - print("ip_dst: " + ip_dst); port_range = { "start": 0, "end": 65535 } if num_flows > 1 and (flow_mods['port']['src'] or flow_mods['port']['dst']): if num_flows < 1000: @@ -254,27 +248,21 @@ def create_generic_pkt (size, mac_src, mac_dst, ip_src, ip_dst, port_src, port_d ] base = Ether(src = mac_src, dst = mac_dst) - print("initial base with mac:" + dump_json_readable(base)) if vlan_id is not None: base = base/Dot1Q(vlan = vlan_id) # with vlan tag, minimum 64 L2 frame size is required, otherwise trex will fail size = max(64, size) - print("str(ip_src[start]): " + str(ip_src['start'])) - print("str(ip_dst[start]): " + str(ip_dst['start'])) base = base/IP(src = str(ip_src['start']), dst = str(ip_dst['start'])) - print("base with IP:" + dump_json_readable(base)) if packet_protocol == "UDP": base = base/UDP(sport = port_src['init'], dport = port_dst['init'] ) elif packet_protocol == "TCP": base = base/TCP(sport = port_src['init'], dport = port_dst['init'] ) - print("base: " + dump_json_readable(base)) pad = max(0, size-len(base)) * 'x' the_packet = base/pad - #print("create_generic_pkt: scapy:%s\n" % (the_packet.command())) if tmp_num_flows and (flow_mods['ip']['src'] or flow_mods['ip']['dst'] or flow_mods['mac']['src'] or flow_mods['mac']['dst'] or flow_mods['port']['src'] or flow_mods['port']['dst']): if packet_protocol == "UDP": @@ -303,8 +291,6 @@ def load_user_pkt (the_packet, size, mac_src, mac_dst, ip_src, ip_dst, port_src, while True: layer = the_packet.getlayer(layer_counter) if not layer is None: - #print("Layer %d is '%s'" % (layer_counter, layer.name)) - #print(dump_json_readable(layer)) if layer.name == "TCP" or layer.name == "UDP": packet_protocol = layer.name @@ -318,7 +304,6 @@ def load_user_pkt (the_packet, size, mac_src, mac_dst, ip_src, ip_dst, port_src, layer.src = mac_src layer.dst = mac_dst - #print(dump_json_readable(layer)) else: break layer_counter += 1 @@ -415,8 +400,6 @@ def load_user_pkt (the_packet, size, mac_src, mac_dst, ip_src, ip_dst, port_src, pad = max(0, size-len(the_packet)) * 'x' the_packet = the_packet/pad - #print("load_user_pkt: scapy:%s\n" % (the_packet.command())) - if tmp_num_flows and (flow_mods['ip']['src'] or flow_mods['ip']['dst'] or flow_mods['mac']['src'] or flow_mods['mac']['dst'] or flow_mods['port']['src'] or flow_mods['port']['dst']): if packet_protocol == "UDP": vm = vm + [ STLVmFixChecksumHw(l3_offset = "IP", l4_offset = "UDP", l4_type = CTRexVmInsFixHwCs.L4_TYPE_UDP) ] @@ -509,7 +492,6 @@ def validate_profile_stream(stream, rate_modifier): elif (key == 'the_packet') and (fields[0] == 'scapy'): try: stream[key] = eval(fields[1]) - #print("validate_profile_stream:the_packet: scapy:%s\n" % (stream[key].command())) except: raise ValueError("Failed to eval '%s' for '%s'" % (fields[1], key)) @@ -705,8 +687,6 @@ def sanitize_profiler_value(value): def trex_profiler_process_sample(sample, stats, prev_sample): sample = json.loads(sample) prev_sample = json.loads(prev_sample) - #print(dump_json_readable(sample)) - #print(dump_json_readable(prev_sample)) stats[sample['timestamp']]['tsdelta'] = sample['timestamp_delta'] From ca84e376478a3934666fa7b61d8df8f9b73d4fca Mon Sep 17 00:00:00 2001 From: Andrew Theurer Date: Tue, 19 Jan 2021 09:50:40 -0500 Subject: [PATCH 5/5] Put tmux back -some people may miss it --- launch-trex.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launch-trex.sh b/launch-trex.sh index e343abc..6675034 100755 --- a/launch-trex.sh +++ b/launch-trex.sh @@ -251,7 +251,7 @@ if [ -d ${trex_dir} -a -d ${tmp_dir} ]; then cat ${yaml_file} echo "-------------------------------------------------------------------" rm -fv /tmp/trex.server.out - ${trex_server_cmd} 2>&1 >/tmp/trex.server.out & + tmux new-session -d -n server -s trex "bash -c '${trex_server_cmd} | tee /tmp/trex.server.out'" # wait for trex server to be ready count=60