Exemple #1
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
Exemple #2
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
Exemple #3
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
Exemple #4
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
Exemple #5
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
def run_pfc_exp(session,
                dut,
                tx_port,
                rx_port,
                port_bw,
                test_prio_list,
                test_dscp_list,
                bg_dscp_list,
                exp_dur,
                start_delay=START_DELAY,
                test_traffic_pause_expected=True,
                send_pause_frame=True):
    """
    Run a PFC experiment.
    1. IXIA sends test traffic and background traffic from tx_port.
    2. IXIA sends PFC pause frames from rx_port to pause priorities.
    3. Background traffic should not be interruped - all background traffic
       will be received at the rx_port.
    4. No test traffic will be received at the rx_port when pause priority
       is equal to test traffic priority.

    Note: PFC pause frames should always be dropped, regardless of their
          pause priorities.

    Args:
        session (IxNetwork Session object): IxNetwork session.
        dut (object): Ansible instance of SONiC device under test (DUT).
        tx_port (object Ixia vport): IXIA port to transmit traffic.
        rx_port (object Ixia vport): IXIA port to receive traffic.
        port_bw (int): bandwidth (in Mbps) of tx_port and rx_port.
        test_prio_list (list of integers): PFC priorities of test traffic and
            PFC pause frames.
        test_dscp_list (list of integers): DSCP values of test traffic.
        bg_dscp_list (list of integers): DSCP values of background traffic.
        exp_dur (integer): experiment duration in second.
        start_delay (float): approximated initial delay to start the traffic.
        test_traffic_pause_expected (bool): Do you expect test traffic to
            be stopped? If yes, this should be true; false otherwise.
        send_pause_frame (bool): True/False depending on whether you want to
           send pause frame Rx port or not.

    Returns:
        This function returns nothing.
    """

    # Disable DUT's PFC watchdog.
    dut.shell('sudo pfcwd stop')

    vlan_subnet = get_vlan_subnet(dut)
    pytest_assert(vlan_subnet is not None,
                  "Fail to get Vlan subnet information")

    gw_addr = vlan_subnet.split('/')[0]
    # One for sender and the other one for receiver.
    vlan_ip_addrs = get_addrs_in_subnet(vlan_subnet, 2)

    topo_receiver = create_topology(session=session,
                                    name="Receiver",
                                    ports=list(rx_port),
                                    ip_start=vlan_ip_addrs[0],
                                    ip_incr_step='0.0.0.1',
                                    gw_start=gw_addr,
                                    gw_incr_step='0.0.0.0')

    # Assumption: Line rate percentage of background data traffic
    # is equal to Line rate percentage of test data traffic.
    pytest_assert(2 * RATE_PERCENTAGE <= 100,
                  "Value of RATE_PERCENTAGE should not be more than 50!")

    topo_sender = create_topology(session=session,
                                  name="Sender",
                                  ports=list(tx_port),
                                  ip_start=vlan_ip_addrs[1],
                                  ip_incr_step='0.0.0.1',
                                  gw_start=gw_addr,
                                  gw_incr_step='0.0.0.0')
    start_protocols(session)

    test_traffic = create_ipv4_traffic(session=session,
                                       name='Test Data Traffic',
                                       source=topo_sender,
                                       destination=topo_receiver,
                                       pkt_size=DATA_PKT_SIZE,
                                       duration=exp_dur,
                                       rate_percent=RATE_PERCENTAGE,
                                       start_delay=start_delay,
                                       dscp_list=test_dscp_list,
                                       lossless_prio_list=test_prio_list)

    bg_priority_list = [b for b in range(8) if b not in test_prio_list]
    background_traffic = create_ipv4_traffic(
        session=session,
        name='Background Data Traffic',
        source=topo_sender,
        destination=topo_receiver,
        pkt_size=DATA_PKT_SIZE,
        duration=exp_dur,
        rate_percent=RATE_PERCENTAGE,
        start_delay=start_delay,
        dscp_list=bg_dscp_list,
        lossless_prio_list=bg_priority_list)

    # Pause time duration (in second) for each PFC pause frame.
    pause_dur_per_pkt = 65535 * 64 * 8.0 / (port_bw * 1000000)

    # Do not specify duration here as we want it keep running.
    if send_pause_frame:
        pfc_traffic = create_pause_traffic(session=session,
                                           name='PFC Pause Storm',
                                           source=rx_port,
                                           pkt_per_sec=1.1 / pause_dur_per_pkt,
                                           start_delay=0,
                                           global_pause=False,
                                           pause_prio_list=test_prio_list)

    start_traffic(session)

    # Wait for test and background traffic to finish.
    time.sleep(exp_dur + start_delay + 1)

    # Capture traffic statistics.
    flow_statistics = get_traffic_statistics(session)
    logger.info(flow_statistics)

    exp_tx_bytes = (exp_dur * port_bw * 1000000 *
                    (RATE_PERCENTAGE / 100.0)) / 8
    for row_number, flow_stat in enumerate(flow_statistics.Rows):
        tx_frames = int(flow_stat['Tx Frames'])
        rx_frames = int(flow_stat['Rx Frames'])
        rx_bytes = int(flow_stat['Rx Bytes'])

        tolerance_ratio = rx_bytes / exp_tx_bytes
        if 'Test' in flow_stat['Traffic Item']:
            if test_traffic_pause_expected:
                pytest_assert(tx_frames > 0 and rx_frames == 0,
                              "Test traffic should be fully paused")
            else:
                pytest_assert(tx_frames > 0 and tx_frames == rx_frames,
                              "Test traffic packets should not be dropped")

                if ((tolerance_ratio < TOLERANCE_THRESHOLD)
                        or (tolerance_ratio > 1)):
                    logger.error("Expected Tx/Rx = %s actual Rx = %s" %
                                 (exp_tx_bytes, rx_bytes))

                    logger.error("tolerance_ratio = %s" % (tolerance_ratio))

                    pytest_assert(
                        False,
                        "expected % of packets not received at the RX port")

        elif 'PFC' in flow_stat['Traffic Item']:
            pytest_assert(tx_frames > 0 and rx_frames == 0,
                          "PFC packets should be dropped")
        else:
            pytest_assert(tx_frames > 0 and tx_frames == rx_frames,
                          "Background traffic should not be impacted")

            if ((tolerance_ratio < TOLERANCE_THRESHOLD)
                    or (tolerance_ratio > 1)):
                logger.error("Expected Tx/Rx = %s actual Rx = %s" %
                             (exp_tx_bytes, rx_bytes))

                logger.error("tolerance_ratio = %s" % (tolerance_ratio))

                pytest_assert(
                    False, "expected % of packets not received at the RX port")

    stop_traffic(session)
    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
Exemple #8
0
    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 test_testbed(conn_graph_facts, duthosts, rand_one_dut_hostname,
                 fanout_graph_facts, ixia_api_server_session, fanouthosts):
    duthost = duthosts[rand_one_dut_hostname]

    logger.info("Connection Graph Facts = %s " % (conn_graph_facts))
    logger.info("Fanout Graph facts = %s" % (fanout_graph_facts))
    logger.info("DUT hostname = %s" % (duthost.hostname))

    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)

    logger.info("Configuring ports.")
    port_list = ixia_fanout_list.get_ports(peer_device=duthost.hostname)
    session = ixia_api_server_session
    vports = configure_ports(session=session, port_list=port_list)

    subnet = get_vlan_subnet(duthost)
    gw = subnet.split('/')[0]
    ip_list = get_addrs_in_subnet(subnet=subnet, number_of_ip=len(vports))

    logger.info("Creating topology.")
    topo_receiver = create_topology(session=session,
                                    name="Receiver",
                                    port_list=[vports[0]],
                                    ip_list=[ip_list[0]],
                                    gw_list=[gw])

    topo_sender = create_topology(session=session,
                                  name="Sender",
                                  port_list=vports[1:],
                                  ip_list=ip_list[1:],
                                  gw_list=[gw] * len(vports[1:]))

    logger.info("Starting all protocols")
    start_protocols(session)

    # Create a traffic item
    logger.info("Configuring traffic.")
    traffic_item = create_ipv4_traffic(session=session,
                                       name="Test Data Traffic",
                                       source=topo_sender,
                                       destination=topo_receiver)

    # Generate, apply and start traffic.
    start_traffic(session)

    logger.info("run traffic for 5 seconds")
    time.sleep(5)

    # Fetch per-flow statistics.
    stats = dump_flow_statistics(session=session)

    logger.info(stats)

    stop_traffic(session)
    stop_protocols(session)
Exemple #10
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