def test_flow_fields(serializer, api): """ This will test setting values for individual flow packet fields """ port = Port(name='port') port_endpoint = PortEndpoint(tx_port_name=port.name) mac_counter = Counter(start='00:00:fa:ce:fa:ce', step='00:00:01:02:03:04', count=7) ethernet = Ethernet( dst=Pattern(mac_counter), src=Pattern(mac_counter), ) vlan1 = Vlan(priority=Pattern('1'), id=Pattern(Counter(start='67', step='3', count=9))) vlan2 = Vlan(id=Pattern(Counter(start='34', step='2', count=5))) ipv4 = Ipv4() flow = Flow( name=__name__, endpoint=Endpoint(port_endpoint), packet=[Header(ethernet), Header(vlan1), Header(vlan2), Header(ipv4)]) config = Config(ports=[port], flows=[flow]) api.set_state(State(ConfigState(config=config, state='set')))
def one_hundred_gbe(testbed, conn_graph_facts, fanout_graph_facts, serializer): fanout_devices = IxiaFanoutManager(fanout_graph_facts) fanout_devices.get_fanout_device_details(device_number=0) device_conn = conn_graph_facts['device_conn'] # The number of ports should be at least two for this test available_phy_port = fanout_devices.get_ports() pytest_assert( len(available_phy_port) > 2, "Number of physical ports must be at least 2") configs = [] for i in range(len(available_phy_port)): rx_id = i tx_id = (i + 1) % len(available_phy_port) phy_tx_port = get_location(available_phy_port[tx_id]) phy_rx_port = get_location(available_phy_port[rx_id]) ######################################################################### # common L1 configuration ######################################################################### tx = Port(name='Tx', location=phy_tx_port) rx = Port(name='Rx', location=phy_rx_port) 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', flow_control=flow_ctl, rs_fec=True) common_l1_config = Layer1(name='common L1 config', choice=l1_oneHundredGbe, port_names=[tx.name, rx.name]) config = Config(ports=[tx, rx], layer1=[common_l1_config], options=Options(PortOptions(location_preemption=True))) configs.append(config) return configs
def create_config(self): fanout_devices = IxiaFanoutManager(self.fanout_graph_facts) fanout_devices.get_fanout_device_details(device_number=0) device_conn = self.conn_graph_facts['device_conn'] # The number of ports should be at least three for this test available_phy_port = fanout_devices.get_ports() pytest_assert( len(available_phy_port) > 3, "Number of physical ports must be at least 3") # Get interface speed of peer port for intf in available_phy_port: peer_port = intf['peer_port'] intf['speed'] = int(device_conn[peer_port]['speed']) config = "" port1_location = get_location(available_phy_port[0]) port2_location = get_location(available_phy_port[1]) port3_location = get_location(available_phy_port[2]) port1 = Port(name='Port1', location=port1_location) port2 = Port(name='Port2', location=port2_location) port3 = Port(name='Port3', location=port3_location) 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', flow_control=flow_ctl, rs_fec=True) common_l1_config = Layer1( name='common L1 config', choice=l1_oneHundredGbe, port_names=[port1.name, port2.name, port3.name]) config = Config(ports=[port1, port2, port3], layer1=[common_l1_config], options=Options( PortOptions(location_preemption=True))) return config
def test_port_pfc_pause_traffic(serializer, tx, rx): pfc_pause = PfcPause(dst=Pattern('000001020304'), src=Pattern('0000002030405'), control_op_code=Pattern('01')) pfc_flow = Flow(name='Pfc Traffic', tx_rx=TxRx(PortTxRx(tx_port_name=tx.name)), packet=[Header(pfc_pause)], size=Size(64), rate=Rate(unit='pps', value=1000000), duration=Duration(Continuous())) config = Config(ports=[tx], flows=[pfc_flow]) print(serializer.json(config))
def create_config(self, phy_ports): """ Creates config for traffic generator with given physical ports :param phy_ports: Physical ports config creation on traffic generator """ ports = [] one_hundred_gbe_ports = [] for index, phy_port in enumerate(phy_ports, 1): port_location = get_location(phy_port) port = Port(name='Port' + str(index), location=port_location) if (phy_port['speed'] / 1000 == 100): one_hundred_gbe_ports.append(port.name) else: pytest_assert( False, "This test supports only 100gbe speed as of now, need to enhance the script based on requirement" ) ports.append(port) 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) one_hundred_gbe = OneHundredGbe(link_training=True, ieee_media_defaults=False, auto_negotiate=False, speed='one_hundred_gbps', flow_control=flow_ctl, rs_fec=True) layer1 = Layer1(name='Layer1 settings', choice=one_hundred_gbe, port_names=one_hundred_gbe_ports) config = Config(ports=ports, layer1=[layer1], options=Options( PortOptions(location_preemption=True))) return config
def test_capture(serializer): """Demonstrate how to specify capture settings for a configuration """ config = Config() config.ports.append(Port(name='port1')) capture = Capture(name='capture1', port_names=[config.ports[0].name], choice=[ BasicFilter( MacAddressFilter('source', filter='000000000000')) ]) config.captures.append(capture) print(serializer.json(config))
def test_phb_ecn(serializer, api, tx_port, rx_port): """ This will test that phb and ecn are set on an ipv4 header """ port_endpoint = PortTxRx(tx_port_name=tx_port.name, rx_port_names=[rx_port.name]) dscp = Dscp(phb=Pattern([Dscp.PHB_CS2, Dscp.PHB_CS1, Dscp.PHB_CS5]), ecn=Pattern(Dscp.ECN_CAPABLE_TRANSPORT_1)) priority = Priority(dscp) ipv4 = Ipv4(priority=priority) flow = Flow(name='Ipv4 with Phb and Ecn', tx_rx=TxRx(port_endpoint), packet=[Header(Ethernet()), Header(ipv4)]) config = Config(ports=[tx_port, rx_port], flows=[flow]) api.set_state(State(ConfigState(config=config, state='set')))
def b2b_port_flow_config(options, tx_port, rx_port): """Returns a configuration with an ethernet flow. The flow uses a PortTxRx endpoint. """ from abstract_open_traffic_generator.config import Config from abstract_open_traffic_generator.flow import Flow, TxRx, PortTxRx, \ Size, Rate, Duration, FixedPackets, Header, Ethernet endpoint = PortTxRx(tx_port_name=tx_port.name, rx_port_names=[rx_port.name]) flow = Flow(name='Port Flow', tx_rx=TxRx(endpoint), packet=[Header(Ethernet())], size=Size(128), rate=Rate(unit='pps', value=1000), duration=Duration(FixedPackets(packets=10000))) return Config(ports=[tx_port, rx_port], flows=[flow], options=options)
def test_device_ipv4_fixed(serializer, api): """Test the creation of ipv4 fixed properties """ port = Port('port 1') port.devices = [ Device(name='device', device_count=15, choice=Ipv4(name='ipv4', address=Pattern('1.1.1.1'), prefix=Pattern('24'), gateway=Pattern('1.1.2.1'), ethernet=Ethernet(name='eth', mac=Pattern('00:00:fa:ce:fa:ce'), mtu=Pattern('1200')))) ] config = Config(ports=[port]) api.set_state(State(ConfigState(config=config, state='set')))
def test_port_traffic(serializer, tx, rx): dscp = Dscp(phb=Pattern(Dscp.PHB_EF46), ecn=Pattern(Dscp.ECN_CAPABLE_TRANSPORT_1)) ipv4 = Ipv4(src=Pattern('1.1.1.1'), dst=Pattern(Counter(start='1.1.2.1', step='0.0.0.1', count=10)), priority=Priority(dscp)) background = Flow( name='Background Traffic', tx_rx=TxRx(PortTxRx(tx_port_name=tx.name)), packet=[Header(Ethernet()), Header(Vlan()), Header(ipv4)], size=Size(512), rate=Rate(unit='pps', value=1000000), duration=Duration(Continuous())) config = Config(ports=[tx], flows=[background]) print(serializer.json(config))
def port_configs(): """This fixture demonstrates setting up configurations that consist only of port, layer1 and device settings. """ from abstract_open_traffic_generator.config import Config from abstract_open_traffic_generator.device import Device, Ethernet, Ipv4 from abstract_open_traffic_generator.layer1 import FlowControl, Ieee8021qbb, Layer1, OneHundredGbe from abstract_open_traffic_generator.port import Port port1 = Port(name='Port 1') port2 = Port(name='Port 2') configs = [] for ports in [[port1, port2], [copy.deepcopy(port2), copy.deepcopy(port1)]]: 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) one_hundred_gbe = OneHundredGbe(link_training=True, ieee_media_defaults=False, auto_negotiate=False, speed='one_hundred_gbps', flow_control=flow_ctl, rs_fec=True) layer1 = Layer1(name='Layer1 settings', choice=one_hundred_gbe, port_names=[ports[0].name, ports[1].name]) ports[0].devices.append( Device('Tx Devices', choice=Ipv4(name='Tx Ipv4', ethernet=Ethernet(name='Tx Ethernet')))) ports[1].devices.append( Device('Rx Devices', choice=Ipv4(name='Rx Ipv4', ethernet=Ethernet(name='Rx Ethernet')))) config = Config(ports=ports, layer1=[layer1]) configs.append(config) return configs
def test_devices(serializer): """Demonstrate how to build a device configuration on a port """ config = Config() config.ports.append(Port(name='port1')) bgpv4 = Bgpv4(name='bgpv4', ipv4=Ipv4(name='ipv4', ethernet=Ethernet(name='eth1', vlans=[ Vlan(name='vlan1'), Vlan(name='vlan2'), Vlan(name='vlan3') ]))) device = Device(name='device', container_name=config.ports[0].name, choice=bgpv4, device_count=10) config.devices.append(device) print(serializer.json(config))
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 test_capture_settings(serializer, api, tx_port): """Demonstrates how to configure basic capture settings """ src = MacAddressFilter(mac='source', filter='0000faceface', mask='000000000000') dst = MacAddressFilter(mac='destination', filter='0000faceface', mask='000000000000') custom = CustomFilter(filter='fffefdfcfbfa', mask='000000000000', offset=50) tx_port.capture = Capture(choice=[ BasicFilter(src, and_operator=False, not_operator=True), BasicFilter(dst, and_operator=False, not_operator=True), BasicFilter(custom, and_operator=False, not_operator=True) ]) config = Config(ports=[tx_port]) api.set_state(State(ConfigState(config=config, state='set')))
def test_json_config(serializer, api, b2b_devices): state = State(ConfigState(config=Config(ports=b2b_devices), state='set')) state = serializer.json(state) api.set_state(state)
def test_config(serializer, tx, rx, port_ipv4_traffic): config = Config(ports=[tx], flows=[port_ipv4_traffic]) print(serializer.json(config))
def testbed_config(conn_graph_facts, fanout_graph_facts, duthost): ixia_fanout = get_peer_ixia_chassis(conn_data=conn_graph_facts, dut_hostname=duthost.hostname) pytest_require(ixia_fanout is not None, skip_message="Cannot find the peer IXIA chassis") ixia_fanout_id = list(fanout_graph_facts.keys()).index(ixia_fanout) ixia_fanout_list = IxiaFanoutManager(fanout_graph_facts) ixia_fanout_list.get_fanout_device_details(device_number=ixia_fanout_id) ixia_ports = ixia_fanout_list.get_ports(peer_device=duthost.hostname) pytest_require(len(ixia_ports) >= 2, skip_message="The test requires at least two ports") rx_id = 0 tx_id = 1 rx_port_location = get_tgen_location(ixia_ports[rx_id]) tx_port_location = get_tgen_location(ixia_ports[tx_id]) rx_port_speed = int(ixia_ports[rx_id]['speed']) tx_port_speed = int(ixia_ports[tx_id]['speed']) pytest_require(rx_port_speed == tx_port_speed, skip_message="Two ports should have the same speed") """ L1 configuration """ rx_port = Port(name='Rx Port', location=rx_port_location) tx_port = Port(name='Tx Port', location=tx_port_location) 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) auto_negotiation = AutoNegotiation(link_training=True, rs_fec=True) l1_config = Layer1(name='L1 config', speed='speed_%d_gbps' % (rx_port_speed / 1000), auto_negotiate=False, auto_negotiation=auto_negotiation, flow_control=flow_ctl, port_names=[tx_port.name, rx_port.name]) config = Config(ports=[tx_port, rx_port], layer1=[l1_config], options=Options(PortOptions(location_preemption=True))) 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] prefix = vlan_subnet.split('/')[1] tx_port_ip = vlan_ip_addrs[0] rx_port_ip = vlan_ip_addrs[1] tx_gateway_ip = gw_addr rx_gateway_ip = gw_addr """ L2/L3 configuration """ tx_ipv4 = Ipv4(name='Tx Ipv4', address=Pattern(tx_port_ip), prefix=Pattern(prefix), gateway=Pattern(tx_gateway_ip), ethernet=Ethernet(name='Tx Ethernet')) config.devices.append( Device(name='Tx Device', device_count=1, container_name=tx_port.name, choice=tx_ipv4)) rx_ipv4 = Ipv4(name='Rx Ipv4', address=Pattern(rx_port_ip), prefix=Pattern(prefix), gateway=Pattern(rx_gateway_ip), ethernet=Ethernet(name='Rx Ethernet')) config.devices.append( Device(name='Rx Device', device_count=1, container_name=rx_port.name, choice=rx_ipv4)) return config
def ixia_testbed_config(conn_graph_facts, fanout_graph_facts, duthosts, rand_one_dut_hostname): """ Geenrate Tgen API config and port config information for the testbed Args: conn_graph_facts (pytest fixture) fanout_graph_facts (pytest fixture) duthosts (pytest fixture): list of DUTs rand_one_dut_hostname (pytest fixture): DUT hostname Returns: - config (obj): Tgen API config of the testbed - port_config_list (list): list of port configuration information """ duthost = duthosts[rand_one_dut_hostname] """ Generate L1 config """ ixia_fanout = get_peer_ixia_chassis(conn_data=conn_graph_facts, dut_hostname=duthost.hostname) pytest_assert(ixia_fanout is not None, 'Fail to get ixia_fanout') ixia_fanout_id = list(fanout_graph_facts.keys()).index(ixia_fanout) ixia_fanout_list = IxiaFanoutManager(fanout_graph_facts) ixia_fanout_list.get_fanout_device_details(device_number=ixia_fanout_id) ixia_ports = ixia_fanout_list.get_ports(peer_device=duthost.hostname) ports = [] port_names = [] port_speed = None for i in range(len(ixia_ports)): port = Port(name='Port {}'.format(i), location=get_tgen_location(ixia_ports[i])) ports.append(port) port_names.append(port.name) if port_speed is None: port_speed = int(ixia_ports[i]['speed']) pytest_assert(port_speed == int(ixia_ports[i]['speed']), 'Ports have different link speeds') pfc = Ieee8021qbb(pfc_delay=0, 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) auto_negotiation = AutoNegotiation(link_training=True, rs_fec=True) speed_gbps = int(port_speed / 1000) l1_config = Layer1(name='L1 config', speed='speed_{}_gbps'.format(speed_gbps), auto_negotiate=False, auto_negotiation=auto_negotiation, ieee_media_defaults=False, flow_control=flow_ctl, port_names=port_names) config = Config(ports=ports, layer1=[l1_config], options=Options(PortOptions(location_preemption=True))) port_config_list = [] config_result = __vlan_intf_config(config=config, port_config_list=port_config_list, duthost=duthost, ixia_ports=ixia_ports) pytest_assert(config_result is True, 'Fail to configure Vlan interfaces') config_result = __portchannel_intf_config( config=config, port_config_list=port_config_list, duthost=duthost, ixia_ports=ixia_ports) pytest_assert(config_result is True, 'Fail to configure portchannel interfaces') return config, port_config_list
def ixia_testbed(conn_graph_facts, fanout_graph_facts, duthosts, rand_one_dut_hostname): """ L2/L3 Tgen API config for the T0 testbed Args: conn_graph_facts (pytest fixture) fanout_graph_facts (pytest fixture) duthosts (pytest fixture): list of DUTs rand_one_dut_hostname (pytest fixture): DUT hostname Returns: L2/L3 config for the T0 testbed """ duthost = duthosts[rand_one_dut_hostname] ixia_fanout = get_peer_ixia_chassis(conn_data=conn_graph_facts, dut_hostname=duthost.hostname) if ixia_fanout is None: return None ixia_fanout_id = list(fanout_graph_facts.keys()).index(ixia_fanout) ixia_fanout_list = IxiaFanoutManager(fanout_graph_facts) ixia_fanout_list.get_fanout_device_details(device_number=ixia_fanout_id) ixia_ports = ixia_fanout_list.get_ports(peer_device=duthost.hostname) ports = list() port_names = list() port_speed = None """ L1 config """ for i in range(len(ixia_ports)): port = Port(name='Port {}'.format(i), location=get_tgen_location(ixia_ports[i])) ports.append(port) port_names.append(port.name) if port_speed is None: port_speed = int(ixia_ports[i]['speed']) elif port_speed != int(ixia_ports[i]['speed']): """ All the ports should have the same bandwidth """ return None pfc = Ieee8021qbb(pfc_delay=0, 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) auto_negotiation = AutoNegotiation(link_training=True, rs_fec=True) l1_config = Layer1(name='L1 config', speed='speed_%d_gbps' % int(port_speed / 1000), auto_negotiate=False, auto_negotiation=auto_negotiation, ieee_media_defaults=False, flow_control=flow_ctl, port_names=port_names) config = Config(ports=ports, layer1=[l1_config], options=Options(PortOptions(location_preemption=True))) """ L2/L3 config """ vlan_subnet = get_vlan_subnet(duthost) if vlan_subnet is None: return None vlan_ip_addrs = get_addrs_in_subnet(vlan_subnet, len(ixia_ports)) gw_addr = vlan_subnet.split('/')[0] prefix = vlan_subnet.split('/')[1] for i in range(len(ixia_ports)): ip_stack = Ipv4(name='Ipv4 {}'.format(i), address=Pattern(vlan_ip_addrs[i]), prefix=Pattern(prefix), gateway=Pattern(gw_addr), ethernet=Ethernet(name='Ethernet {}'.format(i))) device = Device(name='Device {}'.format(i), device_count=1, container_name=port_names[i], choice=ip_stack) config.devices.append(device) return config
def test_config_options(serializer): options = Options(PortOptions(location_preemption=True)) config = Config(options=options) print(serializer.json(config))
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 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)) tx_ethernet = Ethernet(name='Tx Ethernet', ipv4=tx_ipv4) tx_device = Device(name='Tx Device', devices_per_port=1, ethernets=[tx_ethernet]) tx_device_group = DeviceGroup(name='Tx Device Group', port_names=[tx.name], devices=[tx_device]) ########################################################################### # Create RX stack configuration ########################################################################### rx_ipv4 = Ipv4(name='Rx Ipv4', address=Pattern(rx_port_ip), prefix=Pattern('24'), gateway=Pattern(rx_gateway_ip)) rx_ethernet = Ethernet(name='Rx Ethernet', ipv4=rx_ipv4) rx_device = Device(name='Rx Device', devices_per_port=1, ethernets=[rx_ethernet]) rx_device_group = DeviceGroup(name='Rx Device Group', port_names=[rx.name], devices=[rx_device]) ########################################################################### # Traffic configuration Test data # DHCP = [3, 4] # ECN BIT = 1 ########################################################################### test_dscp = Priority( Dscp(phb=FieldPattern(choice=[3, 4]), ecn=FieldPattern('1'))) data_endpoint = DeviceEndpoint(tx_device_names=[tx_device.name], rx_device_names=[rx_device.name], packet_encap='ipv4', src_dst_mesh='', route_host_mesh='', bi_directional=False, allow_self_destined=False) test_flow = Flow(name='Test Data', endpoint=Endpoint(data_endpoint), packet=[ Header(choice=EthernetHeader()), Header(choice=Ipv4Header(priority=test_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 = PortEndpoint(tx_port_name=rx.name) 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', endpoint=Endpoint(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, pause_flow] else: flows = [test_flow] ########################################################################### # Set config ########################################################################### config = Config(ports=[tx, rx], layer1=[common_l1_config], device_groups=[tx_device_group, rx_device_group], flows=flows) api.set_config(config) return config