Beispiel #1
0
def b2b_simple_device(tx_port, rx_port):
    """Returns a B2B tuple of tx port and rx port each with distinct device
        groups of ethernet and ipv4 devices
        """
    from abstract_open_traffic_generator.device import Device, Ethernet, Vlan, Ipv4
    from abstract_open_traffic_generator.device import Pattern

    tx_port.devices = [
        Device(name='Tx Devices Ipv4',
               device_count=1,
               choice=Ipv4(name='Tx Ipv4',
                           address=Pattern('1.1.1.1'),
                           prefix=Pattern('24'),
                           gateway=Pattern('1.1.2.1'),
                           ethernet=Ethernet(name='Tx Ipv4 Eth',
                                             vlans=[Vlan(name='Tx Ipv4 Vlan')
                                                    ])))
    ]
    rx_port.devices = [
        Device(name='Rx Devices Ipv4',
               device_count=1,
               choice=Ipv4(name='Rx Ipv4',
                           address=Pattern('1.1.2.1'),
                           prefix=Pattern('24'),
                           gateway=Pattern('1.1.1.1'),
                           ethernet=Ethernet(name='Rx Ipv4 Eth',
                                             vlans=[Vlan(name='Rx Ipv4 Vlan')
                                                    ]))),
    ]
    return [tx_port, rx_port]
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
Beispiel #3
0
def lossy_configs(testbed, conn_graph_facts, duthost, lossless_prio_dscp_map,
                  one_hundred_gbe, start_delay, serializer):

    for config in one_hundred_gbe:

        bg_dscp_list = [prio for prio in lossless_prio_dscp_map]
        test_dscp_list = [x for x in range(64) if x not in bg_dscp_list]

        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 = 50
        background_line_rate = 50
        pause_line_rate = 100

        configure_pause_frame = 1
        ######################################################################
        # 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'],
                                      devices=[tx_device])

        config.device_groups.append(tx_device_group)

        ######################################################################
        # 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'],
                                      devices=[rx_device])

        config.device_groups.append(rx_device_group)
        ######################################################################
        # Traffic configuration Test data
        ######################################################################
        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_dscp = Priority(Dscp(phb=FieldPattern(choice=test_dscp_list)))

        test_flow = Flow(name=test_flow_name,
                         endpoint=Endpoint(data_endpoint),
                         packet=[
                             Header(choice=EthernetHeader()),
                             Header(choice=Ipv4Header(priority=test_dscp))
                         ],
                         size=Size(1024),
                         rate=Rate('line', test_line_rate),
                         duration=Duration(
                             Fixed(packets=0,
                                   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,
            endpoint=Endpoint(data_endpoint),
            packet=[
                Header(choice=EthernetHeader()),
                Header(choice=Ipv4Header(priority=background_dscp))
            ],
            size=Size(1024),
            rate=Rate('line', background_line_rate),
            duration=Duration(
                Fixed(packets=0, delay=start_delay, delay_unit='nanoseconds')))
        config.flows.append(background_flow)

        #######################################################################
        # Traffic configuration Pause
        #######################################################################
        if (configure_pause_frame):
            pause_endpoint = PortEndpoint(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='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',
                              endpoint=Endpoint(pause_endpoint),
                              packet=[pause],
                              size=Size(64),
                              rate=Rate('line', value=pause_line_rate),
                              duration=Duration(
                                  Fixed(packets=0,
                                        delay=0,
                                        delay_unit='nanoseconds')))

            config.flows.append(pause_flow)

    return one_hundred_gbe
Beispiel #4
0
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
Beispiel #5
0
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
Beispiel #6
0
def __portchannel_intf_config(config, port_config_list, duthost, ixia_ports):
    """
    Generate Tgen configuration of portchannel interfaces

    Args:
        config (obj): Tgen API config of the testbed
        port_config_list (list): list of IXIA port configuration information
        duthost (object): device under test
        ixia_ports (list): list of IXIA port information

    Returns:
        True if we successfully generate configuration or False
    """
    mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
    pc_facts = mg_facts['minigraph_portchannels']
    if len(pc_facts) == 0:
        return True

    pc_member = {}
    for k, v in pc_facts.items():
        pc_member[k] = v['members']

    pc_intf_facts = mg_facts['minigraph_portchannel_interfaces']
    pc_intf = {}
    for v in pc_intf_facts:
        if v['prefixlen'] <= 32:
            pc_intf[v['attachto']] = v

    dut_mac = duthost.facts['router_mac']
    """ For each port channel """
    for pc in pc_member:
        phy_intfs = pc_member[pc]
        gw_addr = str(pc_intf[pc]['addr'])
        prefix = str(pc_intf[pc]['prefixlen'])
        pc_ip_addr = str(pc_intf[pc]['peer_addr'])

        lag_ports = []

        for i in range(len(phy_intfs)):
            phy_intf = phy_intfs[i]

            port_ids = [id for id, ixia_pot in enumerate(ixia_ports) \
                        if ixia_pot['peer_port'] == phy_intf]
            if len(port_ids) != 1:
                return False

            port_id = port_ids[0]
            mac = __gen_mac(port_id)

            proto = lag.Protocol(
                choice=lag.Lacp(actor_system_id='00:00:00:00:00:01',
                                actor_system_priority=1,
                                actor_port_priority=1,
                                actor_port_number=1,
                                actor_key=1))

            ethernet = lag.Ethernet(name='Ethernet Port {}'.format(port_id),
                                    mac=mac)

            lag_port = lag.Port(port_name=config.ports[port_id].name,
                                protocol=proto,
                                ethernet=ethernet)

            lag_ports.append(lag_port)

            port_config = IxiaPortConfig(
                id=port_id,
                ip=pc_ip_addr,
                mac=mac,
                gw=gw_addr,
                gw_mac=dut_mac,
                prefix_len=prefix,
                port_type=IxiaPortType.PortChannelMember,
                peer_port=phy_intf)

            port_config_list.append(port_config)

        lag_intf = lag.Lag(name='Lag {}'.format(pc), ports=lag_ports)
        config.lags.append(lag_intf)

        ip_stack = Ipv4(name='Ipv4 {}'.format(pc),
                        address=Pattern(pc_ip_addr),
                        prefix=Pattern(prefix),
                        gateway=Pattern(gw_addr),
                        ethernet=Ethernet(name='Ethernet {}'.format(pc)))

        device = Device(name='Device {}'.format(pc),
                        device_count=1,
                        container_name=lag_intf.name,
                        choice=ip_stack)

        config.devices.append(device)

    return True
Beispiel #7
0
def __vlan_intf_config(config, port_config_list, duthost, ixia_ports):
    """
    Generate Tgen configuration of Vlan interfaces

    Args:
        config (obj): Tgen API config of the testbed
        port_config_list (list): list of IXIA port configuration information
        duthost (object): device under test
        ixia_ports (list): list of IXIA port information

    Returns:
        True if we successfully generate configuration or False
    """
    mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
    vlan_facts = mg_facts['minigraph_vlans']
    if len(vlan_facts) == 0:
        return True

    vlan_member = {}
    for k, v in vlan_facts.items():
        vlan_member[k] = v['members']

    vlan_intf_facts = mg_facts['minigraph_vlan_interfaces']
    vlan_intf = {}
    for v in vlan_intf_facts:
        if v['prefixlen'] <= 32:
            vlan_intf[v['attachto']] = v

    dut_mac = duthost.facts['router_mac']
    """ For each Vlan """
    for vlan in vlan_member:
        phy_intfs = vlan_member[vlan]
        gw_addr = str(vlan_intf[vlan]['addr'])
        prefix = str(vlan_intf[vlan]['prefixlen'])
        vlan_subnet = '{}/{}'.format(gw_addr, prefix)
        vlan_ip_addrs = get_addrs_in_subnet(vlan_subnet, len(phy_intfs))
        """ For each physical interface attached to this Vlan """
        for i in range(len(phy_intfs)):
            phy_intf = phy_intfs[i]
            vlan_ip_addr = vlan_ip_addrs[i]

            port_ids = [id for id, ixia_pot in enumerate(ixia_ports) \
                        if ixia_pot['peer_port'] == phy_intf]
            if len(port_ids) != 1:
                return False

            port_id = port_ids[0]
            mac = __gen_mac(port_id)
            ethernet = Ethernet(name='Ethernet Port {}'.format(port_id),
                                mac=Pattern(mac))

            ip_stack = Ipv4(name='Ipv4 Port {}'.format(port_id),
                            address=Pattern(vlan_ip_addr),
                            prefix=Pattern(prefix),
                            gateway=Pattern(gw_addr),
                            ethernet=ethernet)

            device = Device(name='Device Port {}'.format(port_id),
                            device_count=1,
                            container_name=config.ports[port_id].name,
                            choice=ip_stack)

            config.devices.append(device)

            port_config = IxiaPortConfig(id=port_id,
                                         ip=vlan_ip_addr,
                                         mac=mac,
                                         gw=gw_addr,
                                         gw_mac=dut_mac,
                                         prefix_len=prefix,
                                         port_type=IxiaPortType.VlanMember,
                                         peer_port=phy_intf)

            port_config_list.append(port_config)

    return True
Beispiel #8
0
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
Beispiel #9
0
def b2b_devices(tx_port, rx_port):
    """Returns a B2B tuple of tx port and rx port each with distinct device
    groups of ethernet, ipv4, ipv6 and bgpv4 devices
    """
    from abstract_open_traffic_generator.device import Device, Ethernet, Vlan
    from abstract_open_traffic_generator.device import Ipv4, Ipv6, Bgpv4
    from abstract_open_traffic_generator.device import Pattern

    tx_port.devices = [
        Device(name='Tx Devices Eth',
               device_count=1,
               choice=Ethernet(name='Tx Eth',
                               vlans=[Vlan(name='Tx Eth Vlan')])),
        Device(name='Tx Devices Ipv4',
               device_count=2,
               choice=Ipv4(name='Tx Ipv4',
                           address=Pattern('1.1.1.1'),
                           prefix=Pattern('24'),
                           gateway=Pattern('1.1.2.1'),
                           ethernet=Ethernet(name='Tx Ipv4 Eth',
                                             vlans=[Vlan(name='Tx Ipv4 Vlan')
                                                    ]))),
        Device(name='Tx Devices Ipv6',
               device_count=3,
               choice=Ipv6(name='Tx Ipv6',
                           ethernet=Ethernet(name='Tx Ipv6 Eth',
                                             vlans=[Vlan(name='Tx Ipv6 Vlan')
                                                    ]))),
        Device(name='Tx Devices Bgpv4',
               device_count=10,
               choice=Bgpv4(name='Tx Bgpv4',
                            ipv4=Ipv4(name='Tx Bgpv4 Ipv4',
                                      ethernet=Ethernet(
                                          name='Tx Bgpv4 Eth',
                                          vlans=[Vlan(name='Tx Bgpv4 Vlan')
                                                 ]))))
    ]
    rx_port.devices = [
        Device(name='Rx Devices Eth',
               device_count=1,
               choice=Ethernet(name='Rx Eth',
                               vlans=[Vlan(name='Rx Eth Vlan')])),
        Device(name='Rx Devices Ipv4',
               device_count=2,
               choice=Ipv4(name='Rx Ipv4',
                           address=Pattern('1.1.1.1'),
                           prefix=Pattern('24'),
                           gateway=Pattern('1.1.2.1'),
                           ethernet=Ethernet(name='Rx Ipv4 Eth',
                                             vlans=[Vlan(name='Rx Ipv4 Vlan')
                                                    ]))),
        Device(name='Rx Devices Ipv6',
               device_count=3,
               choice=Ipv6(name='Rx Ipv6',
                           ethernet=Ethernet(name='Rx Ipv6 Eth',
                                             vlans=[Vlan(name='Rx Ipv6 Vlan')
                                                    ]))),
        Device(name='Rx Devices Bgpv4',
               device_count=10,
               choice=Bgpv4(name='Rx Bgpv4',
                            ipv4=Ipv4(name='Rx Bgpv4 Ipv4',
                                      ethernet=Ethernet(
                                          name='Rx Bgpv4 Eth',
                                          vlans=[Vlan(name='Rx Bgpv4 Vlan')
                                                 ]))))
    ]
    return [tx_port, rx_port]
Beispiel #10
0
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
Beispiel #11
0
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
Beispiel #12
0
def __l3_intf_config(config, port_config_list, duthost, ixia_ports):
    """
    Generate Tgen configuration of layer 3 interfaces

    Args:
        config (obj): Tgen API config of the testbed
        port_config_list (list): list of IXIA port configuration information
        duthost (object): device under test
        ixia_ports (list): list of IXIA port information

    Returns:
        True if we successfully generate configuration or False
    """
    mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
    if 'minigraph_interfaces' in mg_facts:
        l3_intf_facts = mg_facts['minigraph_interfaces']
    else:
        return True

    if len(l3_intf_facts) == 0:
        return True

    l3_intf = {}
    for v in l3_intf_facts:
        if __valid_ipv4_addr(v['addr']):
            l3_intf[v['attachto']] = v

    dut_mac = str(duthost.facts['router_mac'])

    for k, v in l3_intf.items():
        intf = str(k)
        gw_addr = str(v['addr'])
        prefix = str(v['prefixlen'])
        ip = str(v['peer_addr'])

        port_ids = [id for id, ixia_pot in enumerate(ixia_ports) \
                    if ixia_pot['peer_port'] == intf]
        if len(port_ids) != 1:
            return False

        port_id = port_ids[0]
        mac = __gen_mac(port_id)
        ethernet = Ethernet(name='Ethernet Port {}'.format(port_id),
                            mac=Pattern(mac))

        ip_stack = Ipv4(name='Ipv4 Port {}'.format(port_id),
                        address=Pattern(ip),
                        prefix=Pattern(prefix),
                        gateway=Pattern(gw_addr),
                        ethernet=ethernet)

        device = Device(name='Device Port {}'.format(port_id),
                        device_count=1,
                        container_name=config.ports[port_id].name,
                        choice=ip_stack)

        config.devices.append(device)

        port_config = IxiaPortConfig(id=port_id,
                                     ip=ip,
                                     mac=mac,
                                     gw=gw_addr,
                                     gw_mac=dut_mac,
                                     prefix_len=prefix,
                                     port_type=IxiaPortType.IPInterface,
                                     peer_port=intf)

        port_config_list.append(port_config)

    return True
Beispiel #13
0
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