def _pfcwd_multi_host_configs(prio): """ Fixture to create multihost configuration :param prio: dscp priority """ line_rate = traffic_line_rate configs = pfcwd_configs(prio) for config in configs: ###################################################################### # Traffic configuration Traffic 1->3 ####################################################################### dscp_prio = Priority(Dscp(phb=FieldPattern(choice=[str(prio)]))) flow_1to3 = Flow( name="Traffic 1->3", tx_rx=TxRx( DeviceTxRx( tx_device_names=[config.ports[0].devices[0].name], rx_device_names=[config.ports[2].devices[0].name])), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=dscp_prio)), ], size=Size(frame_size), rate=Rate('line', line_rate), duration=Duration( Continuous(delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(flow_1to3) ###################################################################### # Traffic configuration Traffic 3->1 ####################################################################### flow_3to1 = Flow( name="Traffic 3->1", tx_rx=TxRx( DeviceTxRx( tx_device_names=[config.ports[2].devices[0].name], rx_device_names=[config.ports[0].devices[0].name])), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=dscp_prio)), ], size=Size(frame_size), rate=Rate('line', line_rate), duration=Duration( Continuous(delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(flow_3to1) return configs
def _pfc_watch_dog_multi_host_config(start_delay, pause_line_rate, traffic_line_rate, frame_size, t_start_pause, pi): line_rate = traffic_line_rate config = pfc_watch_dog_config(start_delay, pause_line_rate, traffic_line_rate, frame_size, t_start_pause, pi) ###################################################################### # Traffic configuration Traffic 1->3 ####################################################################### dscp_pi = Priority(Dscp(phb=FieldPattern(choice=[str(pi)]))) flow_1to3 = Flow(name="Traffic 1->3", tx_rx=TxRx(DeviceTxRx(tx_device_names=[config.ports[0].devices[0].name], rx_device_names=[config.ports[2].devices[0].name])), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=dscp_pi)), ], size=Size(frame_size), rate=Rate('line', line_rate), duration=Duration(Continuous(delay=start_delay, delay_unit='nanoseconds')) ) config.flows.append(flow_1to3) ###################################################################### # Traffic configuration Traffic 3->1 ####################################################################### flow_3to1 = Flow(name="Traffic 3->1", tx_rx=TxRx(DeviceTxRx(tx_device_names=[config.ports[2].devices[0].name], rx_device_names=[config.ports[0].devices[0].name])), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=dscp_pi)), ], size=Size(frame_size), rate=Rate('line', line_rate), duration=Duration(Continuous(delay=start_delay, delay_unit='nanoseconds')) ) config.flows.append(flow_3to1) return config
def traffic_config(testbed_config): config = testbed_config """ Traffic configuraiton """ flow_name = 'Test Flow' rate_percent = 50 duration_sec = 2 pkt_size = 1024 data_endpoint = DeviceTxRx( tx_device_names=[config.devices[0].name], rx_device_names=[config.devices[1].name], ) flow_dscp = Priority(Dscp(phb=FieldPattern(choice=[3, 4]))) flow = Flow(name=flow_name, tx_rx=TxRx(data_endpoint), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=flow_dscp)) ], size=Size(pkt_size), rate=Rate('line', rate_percent), duration=Duration( FixedSeconds(seconds=duration_sec, delay=0, delay_unit='nanoseconds'))) config.flows = [flow] return config
def __gen_traffic(testbed_config, port_id, data_flow_name, data_flow_dur_sec, data_pkt_size, prio_list, prio_dscp_map): """ Generate configurations of flows Args: testbed_config (obj): L2/L3 config of a T0 testbed port_id (int): ID of DUT port to test. data_flow_name (str): data flow name data_flow_dur_sec (int): duration of data flows in second data_pkt_size (int): size of data packets in byte prio_list (list): priorities of data flows prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: flows configurations (list): the list should have configurations of len(prio_list) data flows """ rx_port_id = port_id tx_port_id = (port_id + 1) % len(testbed_config.devices) data_endpoint = DeviceTxRx( tx_device_names=[testbed_config.devices[tx_port_id].name], rx_device_names=[testbed_config.devices[rx_port_id].name], ) result = list() data_flow_rate_percent = int(100 / len(prio_list)) """ For each priority """ for prio in prio_list: ip_prio = Priority( Dscp(phb=FieldPattern(choice=prio_dscp_map[prio]), ecn=FieldPattern(choice=Dscp.ECN_CAPABLE_TRANSPORT_1))) pfc_queue = FieldPattern([prio]) data_flow = Flow( name='{} Prio {}'.format(data_flow_name, prio), tx_rx=TxRx(data_endpoint), packet=[ Header(choice=EthernetHeader(pfc_queue=pfc_queue)), Header(choice=Ipv4Header(priority=ip_prio)) ], size=Size(data_pkt_size), rate=Rate('line', data_flow_rate_percent), duration=Duration(FixedSeconds(seconds=data_flow_dur_sec))) result.append(data_flow) return result
def __gen_data_flow(testbed_config, src_port_id, dst_port_id, flow_name_prefix, flow_prio, flow_rate_percent, flow_dur_sec, data_pkt_size, prio_dscp_map): """ Generate the configuration for a data flow Args: testbed_config (obj): L2/L3 config of a T0 testbed src_port_id (int): ID of the source port dst_port_id (int): ID of destination port flow_name_prefix (str): prefix of flow' name flow_prio_list (list): priorities of the flow flow_rate_percent (int): rate percentage for the flow flow_dur_sec (int): duration of the flow in second data_pkt_size (int): packet size of the flow in byte prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: flow configuration (obj): including name, packet format, rate, ... """ data_endpoint = DeviceTxRx( tx_device_names=[testbed_config.devices[src_port_id].name], rx_device_names=[testbed_config.devices[dst_port_id].name], ) ip_prio = Priority( Dscp(phb=FieldPattern(choice=prio_dscp_map[flow_prio]), ecn=FieldPattern(choice=Dscp.ECN_CAPABLE_TRANSPORT_1))) pfc_queue = FieldPattern([flow_prio]) flow_name = __data_flow_name(name_prefix=flow_name_prefix, src_id=src_port_id, dst_id=dst_port_id, prio=flow_prio) flow = Flow(name=flow_name, tx_rx=TxRx(data_endpoint), packet=[ Header(choice=EthernetHeader(pfc_queue=pfc_queue)), Header(choice=Ipv4Header(priority=ip_prio)) ], size=Size(data_pkt_size), rate=Rate('line', flow_rate_percent), duration=Duration(FixedSeconds(seconds=flow_dur_sec))) return flow
def flow_configs(port_configs): """This fixture demonstrates adding flows to port configurations. """ from abstract_open_traffic_generator.flow import DeviceTxRx, Duration, FixedPackets, Flow, Rate, Size, TxRx for config in port_configs: device_tx_rx = DeviceTxRx( tx_device_names=[config.ports[0].devices[0].name], rx_device_names=[config.ports[1].devices[0].name]) config.flows.append( Flow(name='%s --> %s' % (config.ports[0].name, config.ports[1].name), tx_rx=TxRx(device_tx_rx), size=Size(128), rate=Rate(unit='pps', value=50000), duration=Duration(FixedPackets(packets=10000000)))) return port_configs
def b2b_ipv4_flow_config(options, b2b_simple_device): """Returns a configuration with an ipv4 flow. The flow uses a DeviceTxRx endpoint. """ from abstract_open_traffic_generator.config import Config from abstract_open_traffic_generator.flow import Flow, TxRx, DeviceTxRx, \ Size, Rate, Duration, FixedPackets, Header, Ethernet, Vlan, Ipv4 tx_rx_devices = DeviceTxRx( tx_device_names=[b2b_simple_device[0].devices[0].name], rx_device_names=[b2b_simple_device[1].devices[0].name]) flow = Flow(name='Ipv4 Flow', tx_rx=TxRx(tx_rx_devices), packet=[Header(Ethernet()), Header(Vlan()), Header(Ipv4())], size=Size(512), rate=Rate(unit='pps', value=100000), duration=Duration(FixedPackets(1000000))) return Config(ports=b2b_simple_device, flows=[flow], options=options)
def __gen_traffic(testbed_config, dut_hostname, dut_port, conn_data, fanout_data): tx_port_id = get_dut_port_id(dut_hostname=dut_hostname, dut_port=dut_port, conn_data=conn_data, fanout_data=fanout_data) if tx_port_id is None: return None rx_port_id = (tx_port_id + 1) % len(testbed_config.devices) """ Traffic configuraiton """ flow_name = 'Test Flow' rate_percent = 50 duration_sec = 2 pkt_size = 1024 data_endpoint = DeviceTxRx( tx_device_names=[testbed_config.devices[tx_port_id].name], rx_device_names=[testbed_config.devices[rx_port_id].name], ) flow_dscp = Priority(Dscp(phb=FieldPattern(choice=[3, 4]))) flow = Flow(name=flow_name, tx_rx=TxRx(data_endpoint), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=flow_dscp)) ], size=Size(pkt_size), rate=Rate('line', rate_percent), duration=Duration( FixedSeconds(seconds=duration_sec, delay=0, delay_unit='nanoseconds'))) return [flow]
def __gen_traffic(testbed_config, port_id, pause_flow_name, data_flow_name, prio, data_pkt_size, data_pkt_cnt, data_flow_delay_sec, exp_dur_sec, prio_dscp_map): """ Generate configurations of flows, including a data flow and a PFC pause storm. Args: testbed_config (obj): L2/L3 config of a T0 testbed port_id (int): ID of DUT port to test pause_flow_name (str): name of the pause storm data_flow_name (str): name of the data flow prio (int): priority of the data flow and PFC pause storm data_pkt_size (int): packet size of the data flow in byte data_pkt_cnt (int): # of packets of the data flow data_flow_delay_sec (float): start delay of the data flow in second exp_dur_sec (float): experiment duration in second prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: Configurations of the data flow and the PFC pause storm (list) """ result = list() rx_port_id = port_id tx_port_id = (port_id + 1) % len(testbed_config.devices) data_endpoint = DeviceTxRx( tx_device_names=[testbed_config.devices[tx_port_id].name], rx_device_names=[testbed_config.devices[rx_port_id].name], ) data_flow_delay_nanosec = sec_to_nanosec(data_flow_delay_sec) """ Data Flow """ ip_prio = Priority( Dscp(phb=FieldPattern(choice=prio_dscp_map[prio]), ecn=FieldPattern(choice=Dscp.ECN_CAPABLE_TRANSPORT_1))) pfc_queue = FieldPattern([prio]) data_flow = Flow(name=data_flow_name, tx_rx=TxRx(data_endpoint), packet=[ Header(choice=EthernetHeader(pfc_queue=pfc_queue)), Header(choice=Ipv4Header(priority=ip_prio)) ], size=Size(data_pkt_size), rate=Rate('line', 100), duration=Duration( FixedPackets(packets=data_pkt_cnt, delay=data_flow_delay_nanosec, delay_unit='nanoseconds'))) result.append(data_flow) """ PFC Pause Storm """ pause_time = [] for x in range(8): if x == prio: pause_time.append('ffff') else: pause_time.append('0000') vector = pfc_class_enable_vector([prio]) pause_pkt = Header( PfcPause( dst=FieldPattern(choice='01:80:C2:00:00:01'), src=FieldPattern(choice='00:00:fa:ce:fa:ce'), class_enable_vector=FieldPattern(choice=vector), pause_class_0=FieldPattern(choice=pause_time[0]), pause_class_1=FieldPattern(choice=pause_time[1]), pause_class_2=FieldPattern(choice=pause_time[2]), pause_class_3=FieldPattern(choice=pause_time[3]), pause_class_4=FieldPattern(choice=pause_time[4]), pause_class_5=FieldPattern(choice=pause_time[5]), pause_class_6=FieldPattern(choice=pause_time[6]), pause_class_7=FieldPattern(choice=pause_time[7]), )) """ Pause frames are sent from the RX port """ pause_src_point = PortTxRx( tx_port_name=testbed_config.ports[rx_port_id].name, rx_port_name=testbed_config.ports[tx_port_id].name) speed_str = testbed_config.layer1[0].speed speed_gbps = int(speed_str.split('_')[1]) pause_dur = 65535 * 64 * 8.0 / (speed_gbps * 1e9) pps = int(2 / pause_dur) pause_flow = Flow(name=pause_flow_name, tx_rx=TxRx(pause_src_point), packet=[pause_pkt], size=Size(64), rate=Rate('pps', value=pps), duration=Duration( FixedSeconds(seconds=exp_dur_sec, delay=0, delay_unit='nanoseconds'))) result.append(pause_flow) return result
def base_configs(testbed, conn_graph_facts, duthost, lossless_prio_dscp_map, one_hundred_gbe, start_delay, traffic_duration, pause_line_rate, traffic_line_rate, pause_frame_type, frame_size, serializer): for config in one_hundred_gbe: start_delay = start_delay * 1000000000.0 bg_dscp_list = [str(prio) for prio in lossless_prio_dscp_map] test_dscp_list = [str(x) for x in range(64) if x not in bg_dscp_list] tx = config.ports[0] rx = config.ports[1] vlan_subnet = get_vlan_subnet(duthost) pytest_assert(vlan_subnet is not None, "Fail to get Vlan subnet information") vlan_ip_addrs = get_addrs_in_subnet(vlan_subnet, 2) gw_addr = vlan_subnet.split('/')[0] interface_ip_addr = vlan_ip_addrs[0] tx_port_ip = vlan_ip_addrs[1] rx_port_ip = vlan_ip_addrs[0] tx_gateway_ip = gw_addr rx_gateway_ip = gw_addr test_flow_name = 'Test Data' background_flow_name = 'Background Data' test_line_rate = traffic_line_rate background_line_rate = traffic_line_rate pause_line_rate = pause_line_rate pytest_assert( test_line_rate + background_line_rate <= 100, "test_line_rate + background_line_rate should be less than 100") ###################################################################### # Create TX stack configuration ###################################################################### tx_ipv4 = Ipv4(name='Tx Ipv4', address=Pattern(tx_port_ip), prefix=Pattern('24'), gateway=Pattern(tx_gateway_ip), ethernet=Ethernet(name='Tx Ethernet')) tx.devices.append( Device(name='Tx Device', device_count=1, choice=tx_ipv4)) ###################################################################### # Create RX stack configuration ###################################################################### rx_ipv4 = Ipv4(name='Rx Ipv4', address=Pattern(rx_port_ip), prefix=Pattern('24'), gateway=Pattern(rx_gateway_ip), ethernet=Ethernet(name='Rx Ethernet')) rx.devices.append( Device(name='Rx Device', device_count=1, choice=rx_ipv4)) ###################################################################### # Traffic configuration Test data ###################################################################### data_endpoint = DeviceTxRx( tx_device_names=[tx.devices[0].name], rx_device_names=[rx.devices[0].name], ) test_dscp = Priority(Dscp(phb=FieldPattern(choice=test_dscp_list))) test_flow = Flow(name=test_flow_name, tx_rx=TxRx(data_endpoint), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=test_dscp)) ], size=Size(frame_size), rate=Rate('line', test_line_rate), duration=Duration( FixedSeconds(seconds=traffic_duration, delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(test_flow) ####################################################################### # Traffic configuration Background data ####################################################################### background_dscp = Priority(Dscp(phb=FieldPattern(choice=bg_dscp_list))) background_flow = Flow( name=background_flow_name, tx_rx=TxRx(data_endpoint), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=background_dscp)) ], size=Size(frame_size), rate=Rate('line', background_line_rate), duration=Duration( FixedSeconds(seconds=traffic_duration, delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(background_flow) ####################################################################### # Traffic configuration Pause ####################################################################### pause_endpoint = PortTxRx(tx_port_name='Rx', rx_port_names=['Rx']) if (pause_frame_type == 'priority'): pause = Header( PfcPause( dst=FieldPattern(choice='01:80:C2:00:00:01'), src=FieldPattern(choice='00:00:fa:ce:fa:ce'), class_enable_vector=FieldPattern(choice='E7'), pause_class_0=FieldPattern(choice='ffff'), pause_class_1=FieldPattern(choice='ffff'), pause_class_2=FieldPattern(choice='ffff'), pause_class_3=FieldPattern(choice='0'), pause_class_4=FieldPattern(choice='0'), pause_class_5=FieldPattern(choice='ffff'), pause_class_6=FieldPattern(choice='ffff'), pause_class_7=FieldPattern(choice='ffff'), )) pause_flow = Flow(name='Pause Storm', tx_rx=TxRx(pause_endpoint), packet=[pause], size=Size(64), rate=Rate('line', value=100), duration=Duration( FixedPackets(packets=0, delay=0, delay_unit='nanoseconds'))) elif (pause_frame_type == 'global'): pause = Header( EthernetPause(dst=FieldPattern(choice='01:80:C2:00:00:01'), src=FieldPattern(choice='00:00:fa:ce:fa:ce'))) pause_flow = Flow(name='Pause Storm', tx_rx=TxRx(pause_endpoint), packet=[pause], size=Size(64), rate=Rate('line', value=pause_line_rate), duration=Duration( FixedPackets(packets=0, delay=0, delay_unit='nanoseconds'))) else: pass config.flows.append(pause_flow) return one_hundred_gbe
def _pfcwd_configs(prio): """ A fixture to create pfcwd configs on traffic generator using open traffic genertor model :param prio: dscp priority 3 or 4 """ vlan_subnet = get_vlan_subnet(duthost) pytest_assert(vlan_subnet is not None, "Fail to get Vlan subnet information") vlan_ip_addrs = get_addrs_in_subnet(vlan_subnet, 3) gw_addr = vlan_subnet.split('/')[0] device1_ip = vlan_ip_addrs[0] device2_ip = vlan_ip_addrs[1] device3_ip = vlan_ip_addrs[2] device1_gateway_ip = gw_addr device2_gateway_ip = gw_addr device3_gateway_ip = gw_addr available_phy_port = ports_config.get_available_phy_ports() pytest_assert( len(available_phy_port) > 3, "Number of physical ports must be at least 3") ports_list = ports_config.create_ports_list(no_of_ports=3) configs = [] for phy_ports in ports_list: config = ports_config.create_config(phy_ports) line_rate = traffic_line_rate ###################################################################### # Device Configuration ###################################################################### port1 = config.ports[0] port2 = config.ports[1] port3 = config.ports[2] #Device 1 configuration port1.devices = [ Device(name='Port 1', device_count=1, choice=Ipv4(name='Ipv4 1', address=Pattern(device1_ip), prefix=Pattern('24'), gateway=Pattern(device1_gateway_ip), ethernet=Ethernet(name='Ethernet 1'))) ] #Device 2 configuration port2.devices = [ Device(name='Port 2', device_count=1, choice=Ipv4(name='Ipv4 2', address=Pattern(device2_ip), prefix=Pattern('24'), gateway=Pattern(device2_gateway_ip), ethernet=Ethernet(name='Ethernet 2'))) ] #Device 3 configuration port3.devices = [ Device(name='Port 3', device_count=1, choice=Ipv4(name='Ipv4 3', address=Pattern(device3_ip), prefix=Pattern('24'), gateway=Pattern(device3_gateway_ip), ethernet=Ethernet(name='Ethernet 3'))) ] device1 = port1.devices[0] device2 = port2.devices[0] device3 = port3.devices[0] ###################################################################### # Traffic configuration Traffic 1->2 ###################################################################### dscp_prio = Priority(Dscp(phb=FieldPattern(choice=[str(prio)]))) flow_1to2 = Flow(name="Traffic 1->2", tx_rx=TxRx( DeviceTxRx(tx_device_names=[device1.name], rx_device_names=[device2.name])), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=dscp_prio)), ], size=Size(frame_size), rate=Rate('line', line_rate), duration=Duration( Continuous(delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(flow_1to2) ###################################################################### # Traffic configuration Traffic 2->1 ###################################################################### flow_2to1 = Flow(name="Traffic 2->1", tx_rx=TxRx( DeviceTxRx(tx_device_names=[device2.name], rx_device_names=[device1.name])), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=dscp_prio)), ], size=Size(frame_size), rate=Rate('line', line_rate), duration=Duration( Continuous(delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(flow_2to1) ###################################################################### # Traffic configuration Traffic 2->3 ####################################################################### flow_2to3 = Flow(name="Traffic 2->3", tx_rx=TxRx( DeviceTxRx(tx_device_names=[device2.name], rx_device_names=[device3.name])), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=dscp_prio)), ], size=Size(frame_size), rate=Rate('line', line_rate), duration=Duration( Continuous(delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(flow_2to3) ###################################################################### # Traffic configuration Traffic 3->2 ####################################################################### flow_3to2 = Flow(name="Traffic 3->2", tx_rx=TxRx( DeviceTxRx(tx_device_names=[device3.name], rx_device_names=[device2.name])), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=dscp_prio)), ], size=Size(frame_size), rate=Rate('line', line_rate), duration=Duration( Continuous(delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(flow_3to2) ####################################################################### # Traffic configuration Pause ####################################################################### if prio == 3: pause = Header( PfcPause( dst=FieldPattern(choice='01:80:C2:00:00:01'), src=FieldPattern(choice='00:00:fa:ce:fa:ce'), class_enable_vector=FieldPattern(choice='8'), pause_class_0=FieldPattern(choice='0'), pause_class_1=FieldPattern(choice='0'), pause_class_2=FieldPattern(choice='0'), pause_class_3=FieldPattern(choice='ffff'), pause_class_4=FieldPattern(choice='0'), pause_class_5=FieldPattern(choice='0'), pause_class_6=FieldPattern(choice='0'), pause_class_7=FieldPattern(choice='0'), )) elif prio == 4: pause = Header( PfcPause( dst=FieldPattern(choice='01:80:C2:00:00:01'), src=FieldPattern(choice='00:00:fa:ce:fa:ce'), class_enable_vector=FieldPattern(choice='10'), pause_class_0=FieldPattern(choice='0'), pause_class_1=FieldPattern(choice='0'), pause_class_2=FieldPattern(choice='0'), pause_class_3=FieldPattern(choice='0'), pause_class_4=FieldPattern(choice='ffff'), pause_class_5=FieldPattern(choice='0'), pause_class_6=FieldPattern(choice='0'), pause_class_7=FieldPattern(choice='0'), )) else: pytest_assert( False, "This testcase supports only lossless priorities 3 & 4, need to enhance the script based on requirement" ) pause_flow = Flow(name='Pause Storm', tx_rx=TxRx( PortTxRx(tx_port_name=port3.name, rx_port_names=[port3.name])), packet=[pause], size=Size(64), rate=Rate('line', value=pause_line_rate), duration=Duration( Continuous(delay=t_start_pause * (10**9), delay_unit='nanoseconds'))) config.flows.append(pause_flow) configs.append(config) return configs
def configure_pfc_lossy(api, phy_tx_port, phy_rx_port, port_speed, tx_port_ip='0.0.0.0', rx_port_ip='0.0.0.0', tx_gateway_ip='0.0.0.0', rx_gateway_ip='0.0.0.', tx_ip_incr='0.0.0.0', rx_ip_incr='0.0.0.0', tx_gateway_incr='0.0.0.0', rx_gateway_incr='0.0.0.0', configure_pause_frame=True): api.set_config(None) tx = Port(name='Tx', location=phy_tx_port) rx = Port(name='Rx', location=phy_rx_port) ######################################################################### # common L1 configuration ######################################################################### pfc = Ieee8021qbb(pfc_delay=1, pfc_class_0=0, pfc_class_1=1, pfc_class_2=2, pfc_class_3=3, pfc_class_4=4, pfc_class_5=5, pfc_class_6=6, pfc_class_7=7) flow_ctl = FlowControl(choice=pfc) l1_oneHundredGbe = OneHundredGbe(link_training=True, ieee_media_defaults=False, auto_negotiate=False, speed='one_hundred_gbps', rs_fec=True, flow_control=flow_ctl) common_l1_config = Layer1(name='common L1 config', choice=l1_oneHundredGbe, port_names=[tx.name, rx.name]) ########################################################################### # Create TX stack configuration ########################################################################### tx_ipv4 = Ipv4(name='Tx Ipv4', address=Pattern(tx_port_ip), prefix=Pattern('24'), gateway=Pattern(tx_gateway_ip), ethernet=Ethernet(name='Tx Ethernet')) tx.devices.append(Device(name='Tx Device', device_count=1, choice=tx_ipv4)) ########################################################################### # Create RX stack configuration ########################################################################### rx_ipv4 = Ipv4(name='Rx Ipv4', address=Pattern(rx_port_ip), prefix=Pattern('24'), gateway=Pattern(rx_gateway_ip), ethernet=Ethernet(name='Rx Ethernet')) rx.devices.append(Device(name='Rx Device', device_count=1, choice=rx_ipv4)) ########################################################################### # Traffic configuration Test data ########################################################################### data_endpoint = DeviceTxRx(tx_device_names=[tx.devices[0].name], rx_device_names=[rx.devices[0].name]) test_dscp = Priority( Dscp(phb=PATTERN(choice=["0", "1", "2", "5", "6", "7"]))) test_flow = Flow(name='Test Data', tx_rx=TxRx(data_endpoint), packet=[ Header(choice=ETHERNET()), Header(choice=IPV4(priority=test_dscp)) ], size=Size(128), rate=Rate('line', 50), duration=Duration( FixedPackets(packets=0, delay=1000000000, delay_unit='nanoseconds'))) ########################################################################### # Traffic configuration Background data ########################################################################### background_dscp = Priority(Dscp(phb=PATTERN(choice=["3", "4"]))) background_flow = Flow(name='Background Data', tx_rx=TxRx(data_endpoint), packet=[ Header(choice=ETHERNET()), Header(choice=IPV4(priority=background_dscp)) ], size=Size(128), rate=Rate('line', 50), duration=Duration( FixedPackets(packets=0, delay=1000000000, delay_unit='nanoseconds'))) ########################################################################### # Traffic configuration Pause ########################################################################### if (configure_pause_frame): pause_endpoint = PortTxRx(tx_port_name=rx.name) pause = Header( PfcPause( dst=PATTERN(choice='01:80:C2:00:00:01'), src=PATTERN(choice='00:00:fa:ce:fa:ce'), class_enable_vector=PATTERN(choice='E7'), pause_class_0=PATTERN(choice='ffff'), pause_class_1=PATTERN(choice='ffff'), pause_class_2=PATTERN(choice='ffff'), pause_class_3=PATTERN(choice='0'), pause_class_4=PATTERN(choice='0'), pause_class_5=PATTERN(choice='ffff'), pause_class_6=PATTERN(choice='ffff'), pause_class_7=PATTERN(choice='ffff'), )) pause_flow = Flow(name='Pause Storm', tx_rx=TxRx(pause_endpoint), packet=[pause], size=Size(64), rate=Rate('line', value=100), duration=Duration( FixedPackets(packets=0, delay=0, delay_unit='nanoseconds'))) flows = [test_flow, background_flow, pause_flow] else: flows = [test_flow, background_flow] ########################################################################### # Set config ########################################################################### config = Config(ports=[tx, rx], layer1=[common_l1_config], flows=flows) api.set_config(config) return config
def __gen_traffic(testbed_config, port_id, pause_flow_name, pause_flow_dur_sec, data_flow_name_list, data_flow_delay_sec_list, data_flow_dur_sec_list, data_pkt_size, prio_list, prio_dscp_map): """ Generate configurations of flows, including data flows and pause storm. Args: testbed_config (obj): L2/L3 config of a T0 testbed port_id (int): ID of DUT port to test. pause_flow_name (str): name of pause storm pause_flow_dur_sec (float): duration of pause storm in second data_flow_name_list (list): list of data flow names data_flow_delay_sec_list (list): list of data flow start delays in second data_flow_dur_sec_list (list): list of data flow durations in second data_pkt_size (int): size of data packets in byte prio_list (list): priorities of data flows and pause storm prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: flows configurations (list): the list should have configurations of len(prio_list) * 2 data flows, and a pause storm. """ result = list() rx_port_id = port_id tx_port_id = (port_id + 1) % len(testbed_config.devices) data_endpoint = DeviceTxRx( tx_device_names=[testbed_config.devices[tx_port_id].name], rx_device_names=[testbed_config.devices[rx_port_id].name], ) """ PFC storm """ pause_time = [] for x in range(8): if x in prio_list: pause_time.append('ffff') else: pause_time.append('0000') vector = pfc_class_enable_vector(prio_list) pause_pkt = Header( PfcPause( dst=FieldPattern(choice='01:80:C2:00:00:01'), src=FieldPattern(choice='00:00:fa:ce:fa:ce'), class_enable_vector=FieldPattern(choice=vector), pause_class_0=FieldPattern(choice=pause_time[0]), pause_class_1=FieldPattern(choice=pause_time[1]), pause_class_2=FieldPattern(choice=pause_time[2]), pause_class_3=FieldPattern(choice=pause_time[3]), pause_class_4=FieldPattern(choice=pause_time[4]), pause_class_5=FieldPattern(choice=pause_time[5]), pause_class_6=FieldPattern(choice=pause_time[6]), pause_class_7=FieldPattern(choice=pause_time[7]), )) pause_src_point = PortTxRx( tx_port_name=testbed_config.ports[rx_port_id].name, rx_port_name=testbed_config.ports[tx_port_id].name) speed_str = testbed_config.layer1[0].speed speed_gbps = int(speed_str.split('_')[1]) pause_dur = 65535 * 64 * 8.0 / (speed_gbps * 1e9) pps = int(2 / pause_dur) pause_pkt_cnt = pps * pause_flow_dur_sec pause_flow = Flow(name=pause_flow_name, tx_rx=TxRx(pause_src_point), packet=[pause_pkt], size=Size(64), rate=Rate('pps', value=pps), duration=Duration( FixedPackets(packets=pause_pkt_cnt, delay=0))) result.append(pause_flow) data_flow_rate_percent = int(100 / len(prio_list)) """ For each data flow """ for i in range(len(data_flow_name_list)): """ For each priority """ for prio in prio_list: ip_prio = Priority( Dscp(phb=FieldPattern(choice=prio_dscp_map[prio]), ecn=FieldPattern(choice=Dscp.ECN_CAPABLE_TRANSPORT_1))) pfc_queue = FieldPattern([prio]) data_flow = Flow( name='{} Prio {}'.format(data_flow_name_list[i], prio), tx_rx=TxRx(data_endpoint), packet=[ Header(choice=EthernetHeader(pfc_queue=pfc_queue)), Header(choice=Ipv4Header(priority=ip_prio)) ], size=Size(data_pkt_size), rate=Rate('line', data_flow_rate_percent), duration=Duration( FixedSeconds(seconds=data_flow_dur_sec_list[i], delay=sec_to_nanosec( data_flow_delay_sec_list[i]), delay_unit='nanoseconds'))) result.append(data_flow) return result
def _pfc_watch_dog_config(pi): vlan_subnet = get_vlan_subnet(duthost) pytest_assert(vlan_subnet is not None, "Fail to get Vlan subnet information") vlan_ip_addrs = get_addrs_in_subnet(vlan_subnet, 3) gw_addr = vlan_subnet.split('/')[0] interface_ip_addr = vlan_ip_addrs[0] device1_ip = vlan_ip_addrs[0] device2_ip = vlan_ip_addrs[1] device3_ip = vlan_ip_addrs[2] device1_gateway_ip = gw_addr device2_gateway_ip = gw_addr device3_gateway_ip = gw_addr config = one_hundred_gbe.create_config() line_rate = pfcwd_params['traffic_line_rate'] pause_line_rate = pfcwd_params['pause_line_rate'] start_delay = pfcwd_params['start_delay'] frame_size = pfcwd_params['frame_size'] t_start_pause = pfcwd_params['t_start_pause'] ###################################################################### # Device Configuration ###################################################################### port1 = config.ports[0] port2 = config.ports[1] port3 = config.ports[2] #Device 1 configuration port1.devices = [ Device(name='Port 1', device_count=1, choice=Ipv4(name='Ipv4 1', address=Pattern(device1_ip), prefix=Pattern('24'), gateway=Pattern(device1_gateway_ip), ethernet=Ethernet(name='Ethernet 1'))) ] #Device 2 configuration port2.devices = [ Device(name='Port 2', device_count=1, choice=Ipv4(name='Ipv4 2', address=Pattern(device2_ip), prefix=Pattern('24'), gateway=Pattern(device2_gateway_ip), ethernet=Ethernet(name='Ethernet 2'))) ] #Device 3 configuration port3.devices = [ Device(name='Port 3', device_count=1, choice=Ipv4(name='Ipv4 3', address=Pattern(device3_ip), prefix=Pattern('24'), gateway=Pattern(device3_gateway_ip), ethernet=Ethernet(name='Ethernet 3'))) ] device1 = port1.devices[0] device2 = port2.devices[0] device3 = port3.devices[0] ###################################################################### # Traffic configuration Traffic 1->2 ###################################################################### dscp_pi = Priority(Dscp(phb=FieldPattern(choice=[str(pi)]))) flow_1to2 = Flow(name="Traffic 1->2", tx_rx=TxRx( DeviceTxRx(tx_device_names=[device1.name], rx_device_names=[device2.name])), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=dscp_pi)), ], size=Size(frame_size), rate=Rate('line', line_rate), duration=Duration( Continuous(delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(flow_1to2) ###################################################################### # Traffic configuration Traffic 2->1 ###################################################################### flow_2to1 = Flow(name="Traffic 2->1", tx_rx=TxRx( DeviceTxRx(tx_device_names=[device2.name], rx_device_names=[device1.name])), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=dscp_pi)), ], size=Size(frame_size), rate=Rate('line', line_rate), duration=Duration( Continuous(delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(flow_2to1) ###################################################################### # Traffic configuration Traffic 2->3 ####################################################################### flow_2to3 = Flow(name="Traffic 2->3", tx_rx=TxRx( DeviceTxRx(tx_device_names=[device2.name], rx_device_names=[device3.name])), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=dscp_pi)), ], size=Size(frame_size), rate=Rate('line', line_rate), duration=Duration( Continuous(delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(flow_2to3) ###################################################################### # Traffic configuration Traffic 3->2 ####################################################################### flow_3to2 = Flow(name="Traffic 3->2", tx_rx=TxRx( DeviceTxRx(tx_device_names=[device3.name], rx_device_names=[device2.name])), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=dscp_pi)), ], size=Size(frame_size), rate=Rate('line', line_rate), duration=Duration( Continuous(delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(flow_3to2) ####################################################################### # Traffic configuration Pause ####################################################################### if (pi == 3): pause = Header( PfcPause( dst=FieldPattern(choice='01:80:C2:00:00:01'), src=FieldPattern(choice='00:00:fa:ce:fa:ce'), class_enable_vector=FieldPattern(choice='8'), pause_class_0=FieldPattern(choice='0'), pause_class_1=FieldPattern(choice='0'), pause_class_2=FieldPattern(choice='0'), pause_class_3=FieldPattern(choice='ffff'), pause_class_4=FieldPattern(choice='0'), pause_class_5=FieldPattern(choice='0'), pause_class_6=FieldPattern(choice='0'), pause_class_7=FieldPattern(choice='0'), )) elif (pi == 4): pause = Header( PfcPause( dst=FieldPattern(choice='01:80:C2:00:00:01'), src=FieldPattern(choice='00:00:fa:ce:fa:ce'), class_enable_vector=FieldPattern(choice='10'), pause_class_0=FieldPattern(choice='0'), pause_class_1=FieldPattern(choice='0'), pause_class_2=FieldPattern(choice='0'), pause_class_3=FieldPattern(choice='0'), pause_class_4=FieldPattern(choice='ffff'), pause_class_5=FieldPattern(choice='0'), pause_class_6=FieldPattern(choice='0'), pause_class_7=FieldPattern(choice='0'), )) else: pytest_assert( False, "This testcase supports only lossless priorities 3 & 4") pause_flow = Flow(name='Pause Storm', tx_rx=TxRx( PortTxRx(tx_port_name=port3.name, rx_port_names=[port3.name])), packet=[pause], size=Size(64), rate=Rate('line', value=pause_line_rate), duration=Duration( Continuous(delay=t_start_pause * (10**9), delay_unit='nanoseconds'))) config.flows.append(pause_flow) return config
def __gen_traffic(testbed_config, port_id, pause_flow_name, global_pause, pause_prio_list, test_flow_name, test_flow_prio_list, test_flow_rate_percent, bg_flow_name, bg_flow_prio_list, bg_flow_rate_percent, data_flow_dur_sec, data_flow_delay_sec, data_pkt_size, prio_dscp_map): """ Generate configurations of flows, including test flows, background flows and pause storm. Test flows and background flows are also known as data flows. Args: testbed_config (obj): L2/L3 config of a T0 testbed port_id (int): ID of DUT port to test. pause_flow_name (str): name of pause storm global_pause (bool): if pause frame is IEEE 802.3X pause pause_prio_list (list): priorities to pause for pause frames test_flow_name (str): name of test flows test_prio_list (list): priorities of test flows test_flow_rate_percent (int): rate percentage for each test flow bg_flow_name (str): name of background flows bg_prio_list (list): priorities of background flows bg_flow_rate_percent (int): rate percentage for each background flow data_flow_dur_sec (int): duration of data flows in second data_flow_delay_sec (int): start delay of data flows in second data_pkt_size (int): packet size of data flows in byte prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: flows configurations (list): the list should have configurations of len(test_flow_prio_list) test flow, len(bg_flow_prio_list) background flows and a pause storm. """ result = list() rx_port_id = port_id tx_port_id = (port_id + 1) % len(testbed_config.devices) data_endpoint = DeviceTxRx( tx_device_names=[testbed_config.devices[tx_port_id].name], rx_device_names=[testbed_config.devices[rx_port_id].name], ) data_flow_delay_nanosec = sec_to_nanosec(data_flow_delay_sec) """ Test flows """ for prio in test_flow_prio_list: ip_prio = Priority( Dscp(phb=FieldPattern(choice=prio_dscp_map[prio]), ecn=FieldPattern(choice=Dscp.ECN_CAPABLE_TRANSPORT_1))) pfc_queue = FieldPattern([prio]) test_flow = Flow( name='{} Prio {}'.format(test_flow_name, prio), tx_rx=TxRx(data_endpoint), packet=[ Header(choice=EthernetHeader(pfc_queue=pfc_queue)), Header(choice=Ipv4Header(priority=ip_prio)) ], size=Size(data_pkt_size), rate=Rate('line', test_flow_rate_percent), duration=Duration( FixedSeconds(seconds=data_flow_dur_sec, delay=data_flow_delay_nanosec, delay_unit='nanoseconds'))) result.append(test_flow) """ Background flows """ for prio in bg_flow_prio_list: ip_prio = Priority( Dscp(phb=FieldPattern(choice=prio_dscp_map[prio]), ecn=FieldPattern(choice=Dscp.ECN_CAPABLE_TRANSPORT_1))) pfc_queue = FieldPattern([prio]) bg_flow = Flow(name='{} Prio {}'.format(bg_flow_name, prio), tx_rx=TxRx(data_endpoint), packet=[ Header(choice=EthernetHeader(pfc_queue=pfc_queue)), Header(choice=Ipv4Header(priority=ip_prio)) ], size=Size(data_pkt_size), rate=Rate('line', bg_flow_rate_percent), duration=Duration( FixedSeconds(seconds=data_flow_dur_sec, delay=data_flow_delay_nanosec, delay_unit='nanoseconds'))) result.append(bg_flow) """ Pause storm """ if global_pause: pause_pkt = Header( EthernetPause(dst=FieldPattern(choice='01:80:C2:00:00:01'), src=FieldPattern(choice='00:00:fa:ce:fa:ce'))) else: pause_time = [] for x in range(8): if x in pause_prio_list: pause_time.append('ffff') else: pause_time.append('0000') vector = pfc_class_enable_vector(pause_prio_list) pause_pkt = Header( PfcPause( dst=FieldPattern(choice='01:80:C2:00:00:01'), src=FieldPattern(choice='00:00:fa:ce:fa:ce'), class_enable_vector=FieldPattern(choice=vector), pause_class_0=FieldPattern(choice=pause_time[0]), pause_class_1=FieldPattern(choice=pause_time[1]), pause_class_2=FieldPattern(choice=pause_time[2]), pause_class_3=FieldPattern(choice=pause_time[3]), pause_class_4=FieldPattern(choice=pause_time[4]), pause_class_5=FieldPattern(choice=pause_time[5]), pause_class_6=FieldPattern(choice=pause_time[6]), pause_class_7=FieldPattern(choice=pause_time[7]), )) """ Pause frames are sent from the RX port """ pause_src_point = PortTxRx( tx_port_name=testbed_config.ports[rx_port_id].name, rx_port_name=testbed_config.ports[tx_port_id].name) speed_str = testbed_config.layer1[0].speed speed_gbps = int(speed_str.split('_')[1]) pause_dur = 65535 * 64 * 8.0 / (speed_gbps * 1e9) pps = int(2 / pause_dur) pause_flow = Flow(name=pause_flow_name, tx_rx=TxRx(pause_src_point), packet=[pause_pkt], size=Size(64), rate=Rate('pps', value=pps), duration=Duration( Continuous(delay=0, delay_unit='nanoseconds'))) result.append(pause_flow) return result
def base_configs(testbed, conn_graph_facts, duthost, lossless_prio_dscp_map, one_hundred_gbe, start_delay, pause_line_rate, traffic_line_rate, frame_size, ecn_thresholds, serializer): for config in one_hundred_gbe: start_delay = start_delay * 1000000000.0 test_dscp_list = [str(prio) for prio in lossless_prio_dscp_map] tx = config.ports[0] rx = config.ports[1] vlan_subnet = get_vlan_subnet(duthost) pytest_assert(vlan_subnet is not None, "Fail to get Vlan subnet information") vlan_ip_addrs = get_addrs_in_subnet(vlan_subnet, 2) gw_addr = vlan_subnet.split('/')[0] interface_ip_addr = vlan_ip_addrs[0] tx_port_ip = vlan_ip_addrs[1] rx_port_ip = vlan_ip_addrs[0] tx_gateway_ip = gw_addr rx_gateway_ip = gw_addr test_flow_name = 'Test Data' test_line_rate = traffic_line_rate pause_line_rate = pause_line_rate pytest_assert(test_line_rate <= pause_line_rate, "test_line_rate + should be less than pause_line_rate") ###################################################################### # Create TX stack configuration ###################################################################### tx_ipv4 = Ipv4(name='Tx Ipv4', address=Pattern(tx_port_ip), prefix=Pattern('24'), gateway=Pattern(tx_gateway_ip), ethernet=Ethernet(name='Tx Ethernet')) tx.devices.append( Device(name='Tx Device', device_count=1, choice=tx_ipv4)) ###################################################################### # Create RX stack configuration ###################################################################### rx_ipv4 = Ipv4(name='Rx Ipv4', address=Pattern(rx_port_ip), prefix=Pattern('24'), gateway=Pattern(rx_gateway_ip), ethernet=Ethernet(name='Rx Ethernet')) rx.devices.append( Device(name='Rx Device', device_count=1, choice=rx_ipv4)) ###################################################################### # Traffic configuration Test data ###################################################################### data_endpoint = DeviceTxRx( tx_device_names=[tx.devices[0].name], rx_device_names=[rx.devices[0].name], ) pytest_assert(ecn_thresholds < 1024 * 1024, "keep the ECN thresholds less than 1MB") test_dscp = Priority( Dscp(phb=FieldPattern(choice=test_dscp_list), ecn=FieldPattern(Dscp.ECN_CAPABLE_TRANSPORT_1))) # ecn_thresholds in bytes number_of_packets = int(2 * (ecn_thresholds / frame_size)) logger.info("Total number of packets to send = 2 * %s = %s"\ %(ecn_thresholds / frame_size, number_of_packets)) test_flow = Flow(name=test_flow_name, tx_rx=TxRx(data_endpoint), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=test_dscp)) ], size=Size(frame_size), rate=Rate('line', test_line_rate), duration=Duration( FixedPackets(packets=number_of_packets, delay=start_delay, delay_unit='nanoseconds'))) config.flows.append(test_flow) ####################################################################### # Traffic configuration Pause ####################################################################### pause_endpoint = PortTxRx(tx_port_name='Rx', rx_port_names=['Rx']) pause = Header( PfcPause( dst=FieldPattern(choice='01:80:C2:00:00:01'), src=FieldPattern(choice='00:00:fa:ce:fa:ce'), class_enable_vector=FieldPattern(choice='18'), pause_class_0=FieldPattern(choice='0'), pause_class_1=FieldPattern(choice='0'), pause_class_2=FieldPattern(choice='0'), pause_class_3=FieldPattern(choice='ffff'), pause_class_4=FieldPattern(choice='ffff'), pause_class_5=FieldPattern(choice='0'), pause_class_6=FieldPattern(choice='0'), pause_class_7=FieldPattern(choice='0'), )) pause_flow = Flow(name='Pause Storm', tx_rx=TxRx(pause_endpoint), packet=[pause], size=Size(64), rate=Rate('line', value=100), duration=Duration( FixedPackets(packets=0, delay=0, delay_unit='nanoseconds'))) config.flows.append(pause_flow) return one_hundred_gbe