- # 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")
-
- pkt_a = STLPktBuilder(pkt=base_pkt_a/generate_payload(
- max(0, fsize_no_fcs-len(base_pkt_a))), vm=vm1)
- pkt_b = STLPktBuilder(pkt=base_pkt_b/generate_payload(
- max(0, fsize_no_fcs-len(base_pkt_b))), vm=vm2)
-
- return(pkt_a, pkt_b)
-
-def simple_burst(pkt_a, pkt_b, duration=10, rate="1mpps", warmup_time=5):
+ # 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)
+
+
+def create_streams_v6(traffic_options, frame_size=78):
+ """Create two IPv6 packets to be used in stream.
+
+ :param traffic_options: Parameters for packets.
+ :param frame_size: Size of L2 frame.
+ :type traffic_options: List
+ :type frame_size: int
+ :return: Packet instances.
+ :rtype: Tuple of STLPktBuilder
+ """
+
+ if type(frame_size) is int and frame_size < 78:
+ print_error("Frame min. size is 78B")
+ sys.exit(2)
+
+ p1_src_start_ip = traffic_options['p1_src_start_ip']
+ p1_src_end_ip = traffic_options['p1_src_end_ip']
+ p1_dst_start_ip = traffic_options['p1_dst_start_ip']
+ p2_src_start_ip = traffic_options['p2_src_start_ip']
+ 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()/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/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)
+
+def simple_burst(stream_a, stream_b, stream_lat_a, stream_lat_b, duration, rate,
+ warmup_time, async_start, latency):