+ return base_p1, max_p1
+
+def create_streams_v46(base_pkt_a, base_pkt_b, vm1, vm2, frame_size):
+ """Create STLStream streams
+
+ :param base_pkt_a: Base packet a for stream_a
+ :param base_pkt_b: Base packet b for stream_b
+ :param vm1: vm for stream_a
+ :param vm2: vm for stream_b
+ :param frame_size: frame size or name of traffic profile
+ :type base_pkt_a: Eth (scapy)
+ :type base_pkt_b: Eth (scapy)
+ :type vm1: STLScVmRaw
+ :type vm2: STLScVmRaw
+ :frame_size: int or string
+ :return: stream_a, stream_b, stream_a_latency, stream_b_latency
+ :rtype: STLStream, STLStream, STLStream, STLStream
+ """
+
+ if type(frame_size) is int:
+
+ fsize_no_fcs = frame_size - 4 # no FCS
+ 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)
+ pkt_lat_a = STLPktBuilder(pkt=base_pkt_a/generate_payload(
+ max(0, fsize_no_fcs-len(base_pkt_a))))
+ pkt_lat_b = STLPktBuilder(pkt=base_pkt_b/generate_payload(
+ max(0, fsize_no_fcs-len(base_pkt_b))))
+ lat_stream1 = STLStream(packet=pkt_lat_a,
+ flow_stats=STLFlowLatencyStats(pg_id=0),
+ mode=STLTXCont(pps=1000))
+ # second traffic stream with a phase of 10ns (inter stream gap)
+ lat_stream2 = STLStream(packet=pkt_lat_b,
+ isg=10.0,
+ flow_stats=STLFlowLatencyStats(pg_id=1),
+ mode=STLTXCont(pps=1000))
+
+ stream1 = STLStream(packet=pkt_a,
+ mode=STLTXCont(pps=1000))
+ # second traffic stream with a phase of 10ns (inter stream gap)
+ stream2 = STLStream(packet=pkt_b,
+ isg=10.0,
+ mode=STLTXCont(pps=1000))
+ elif type(frame_size) is str:
+ lat_stream1 = []
+ lat_stream2 = []
+ stream1 = []
+ stream2 = []
+
+ for x in stream_table[frame_size]:
+ fsize_no_fcs = x['size'] - 4 # no FCS
+ 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)
+
+ stream1.append(STLStream(packet=pkt_a,
+ isg=x['isg'],
+ mode=STLTXCont(pps=x['pps'])))
+ stream2.append(STLStream(packet=pkt_b,
+ isg=x['isg'],
+ mode=STLTXCont(pps=x['pps'])))
+
+ else:
+ raise ValueError("Unknown frame_size type")
+
+ return (stream1, stream2, lat_stream1, lat_stream2)
+
+def create_streams(traffic_options, frame_size=64):
+ """Create two IP 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 < 64:
+ print_error("Frame min. size is 64B")
+ sys.exit(1)
+
+ 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']
+
+ 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")
+
+ 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)