X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Ftools%2Ft-rex%2Ft-rex-stateless.py;h=f456b6631651e4ee8c11b003328a4bf22c41250e;hp=04f7a25294069aa5d628b84355ba9e6063d0f870;hb=72be8262ea5dc0136a21032402b7f4ffa5ff4576;hpb=ccdcc18ff5ab339f715179d3215fe174252a1187 diff --git a/resources/tools/t-rex/t-rex-stateless.py b/resources/tools/t-rex/t-rex-stateless.py index 04f7a25294..f456b66316 100755 --- a/resources/tools/t-rex/t-rex-stateless.py +++ b/resources/tools/t-rex/t-rex-stateless.py @@ -96,7 +96,7 @@ def get_start_end_ipv6(start_ip, end_ip): print "IPv6: start_ip is greater then end_ip" sys.exit(2) - max_p1 = abs(int(lo1) - int(lo2)) + 1 + max_p1 = abs(int(lo1) - int(lo2)) base_p1 = lo1 except AddressValueError as ex_error: print ex_error @@ -194,29 +194,45 @@ def create_streams(traffic_options, frame_size=64): p2_src_end_ip = traffic_options['p2_src_end_ip'] p2_dst_start_ip = traffic_options['p2_dst_start_ip'] + p1_dst_end_ip = traffic_options['p1_dst_end_ip'] + p2_dst_end_ip = traffic_options['p2_dst_end_ip'] + base_pkt_a = Ether()/IP(src=p1_src_start_ip, dst=p1_dst_start_ip, proto=61) base_pkt_b = Ether()/IP(src=p2_src_start_ip, dst=p2_dst_start_ip, proto=61) - # The following code applies raw instructions to packet (IP src increment). - # It splits the generated traffic by "ip_src" variable to cores and fix - # IPv4 header checksum. - vm1 = STLScVmRaw([STLVmFlowVar(name="src", - min_value=p1_src_start_ip, - max_value=p1_src_end_ip, - size=4, op="inc"), - STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"), - STLVmFixIpv4(offset="IP"), - ], split_by_field="src") - # The following code applies raw instructions to packet (IP src increment). - # It splits the generated traffic by "ip_src" variable to cores and fix - # IPv4 header checksum. - vm2 = STLScVmRaw([STLVmFlowVar(name="src", - min_value=p2_src_start_ip, - max_value=p2_src_end_ip, - size=4, op="inc"), - STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"), - STLVmFixIpv4(offset="IP"), - ], split_by_field="src") + # The following code applies raw instructions to packet (IP src/dst + # increment). It splits the generated traffic by "ip_src"/"ip_dst" variable + # to cores and fix IPv4 header checksum. + if p1_dst_end_ip and p2_dst_end_ip: + vm1 = STLScVmRaw([STLVmFlowVar(name="dst", + min_value=p1_dst_start_ip, + max_value=p1_dst_end_ip, + size=4, op="inc"), + STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"), + STLVmFixIpv4(offset="IP"), + ], split_by_field="dst") + vm2 = STLScVmRaw([STLVmFlowVar(name="dst", + min_value=p2_dst_start_ip, + max_value=p2_dst_end_ip, + size=4, op="inc"), + STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"), + STLVmFixIpv4(offset="IP"), + ], split_by_field="dst") + else: + vm1 = STLScVmRaw([STLVmFlowVar(name="src", + min_value=p1_src_start_ip, + max_value=p1_src_end_ip, + size=4, op="inc"), + STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"), + STLVmFixIpv4(offset="IP"), + ], split_by_field="src") + vm2 = STLScVmRaw([STLVmFlowVar(name="src", + min_value=p2_src_start_ip, + max_value=p2_src_end_ip, + size=4, op="inc"), + STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"), + STLVmFixIpv4(offset="IP"), + ], split_by_field="src") return create_streams_v46(base_pkt_a, base_pkt_b, vm1, vm2, frame_size) @@ -243,33 +259,59 @@ def create_streams_v6(traffic_options, frame_size=78): p2_src_end_ip = traffic_options['p2_src_end_ip'] p2_dst_start_ip = traffic_options['p2_dst_start_ip'] - base_p1, max_p1 = get_start_end_ipv6(p1_src_start_ip, p1_src_end_ip) - base_p2, max_p2 = get_start_end_ipv6(p2_src_start_ip, p2_src_end_ip) + p1_dst_end_ip = traffic_options['p1_dst_end_ip'] + p2_dst_end_ip = traffic_options['p2_dst_end_ip'] base_pkt_a = Ether()/IPv6(src=p1_src_start_ip, dst=p1_dst_start_ip) base_pkt_b = Ether()/IPv6(src=p2_src_start_ip, dst=p2_dst_start_ip) - # The following code applies raw instructions to packet (IP src increment). - # It splits the generated traffic by "ip_src" variable to cores - vm1 = STLScVmRaw([STLVmFlowVar(name="ipv6_src", - min_value=base_p1, - max_value=max_p1+base_p1, - size=8, op="inc"), - STLVmWrFlowVar(fv_name="ipv6_src", pkt_offset="IPv6.src", - offset_fixup=8) - ] - , split_by_field="ipv6_src") - - # The following code applies raw instructions to packet (IP src increment). - # It splits the generated traffic by "ip_src" variable to cores - vm2 = STLScVmRaw([STLVmFlowVar(name="ipv6_src", - min_value=base_p2, - max_value=max_p2+base_p2, - size=8, op="inc"), - STLVmWrFlowVar(fv_name="ipv6_src", pkt_offset="IPv6.src", - offset_fixup=8) - ] - , split_by_field="ipv6_src") + # The following code applies raw instructions to packet (IP src/dst + # increment). It splits the generated traffic by "ip_src"/"ip_dst" variable + # to cores. + if p1_dst_end_ip and p2_dst_end_ip: + base_p1, max_p1 = get_start_end_ipv6(p1_dst_start_ip, p1_dst_end_ip) + base_p2, max_p2 = get_start_end_ipv6(p2_dst_start_ip, p2_dst_end_ip) + + vm1 = STLScVmRaw([STLVmFlowVar(name="ipv6_dst", + min_value=base_p1, + max_value=max_p1+base_p1, + size=8, op="inc"), + STLVmWrFlowVar(fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8) + ] + , split_by_field="ipv6_dst") + vm2 = STLScVmRaw([STLVmFlowVar(name="ipv6_dst", + min_value=base_p2, + max_value=max_p2+base_p2, + size=8, op="inc"), + STLVmWrFlowVar(fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8) + ] + , split_by_field="ipv6_dst") + else: + base_p1, max_p1 = get_start_end_ipv6(p1_src_start_ip, p1_src_end_ip) + base_p2, max_p2 = get_start_end_ipv6(p2_src_start_ip, p2_src_end_ip) + + vm1 = STLScVmRaw([STLVmFlowVar(name="ipv6_src", + min_value=base_p1, + max_value=max_p1+base_p1, + size=8, op="inc"), + STLVmWrFlowVar(fv_name="ipv6_src", + pkt_offset="IPv6.src", + offset_fixup=8) + ] + , split_by_field="ipv6_src") + vm2 = STLScVmRaw([STLVmFlowVar(name="ipv6_src", + min_value=base_p2, + max_value=max_p2+base_p2, + size=8, op="inc"), + STLVmWrFlowVar(fv_name="ipv6_src", + pkt_offset="IPv6.src", + offset_fixup=8) + ] + , split_by_field="ipv6_src") return create_streams_v46(base_pkt_a, base_pkt_b, vm1, vm2, frame_size) @@ -338,7 +380,7 @@ def simple_burst(stream_a, stream_b, stream_lat_a, stream_lat_b, duration, rate, if client.get_warnings(): for warning in client.get_warnings(): - print_error(warning) + print(warning) # read the stats after the test stats = client.get_stats() @@ -366,7 +408,7 @@ def simple_burst(stream_a, stream_b, stream_lat_a, stream_lat_b, duration, rate, if client.get_warnings(): for warning in client.get_warnings(): - print_error(warning) + print(warning) # read the stats after the test stats = client.get_stats() @@ -451,24 +493,28 @@ def parse_args(): # help="Port 1 destination MAC address") parser.add_argument("--p1_src_start_ip", required=True, help="Port 1 source start IP address") - parser.add_argument("--p1_src_end_ip", required=True, + parser.add_argument("--p1_src_end_ip", + default=False, help="Port 1 source end IP address") parser.add_argument("--p1_dst_start_ip", required=True, help="Port 1 destination start IP address") -# parser.add_argument("--p1_dst_end_ip", -# help="Port 1 destination end IP address") + parser.add_argument("--p1_dst_end_ip", + default=False, + help="Port 1 destination end IP address") # parser.add_argument("--p2_src_mac", # help="Port 2 source MAC address") # parser.add_argument("--p2_dst_mac", # help="Port 2 destination MAC address") parser.add_argument("--p2_src_start_ip", required=True, help="Port 2 source start IP address") - parser.add_argument("--p2_src_end_ip", required=True, + parser.add_argument("--p2_src_end_ip", + default=False, help="Port 2 source end IP address") parser.add_argument("--p2_dst_start_ip", required=True, help="Port 2 destination start IP address") -# parser.add_argument("--p2_dst_end_ip", -# help="Port 2 destination end IP address") + parser.add_argument("--p2_dst_end_ip", + default=False, + help="Port 2 destination end IP address") return parser.parse_args()