Exemplo n.º 1
0
def verify_traffic():
    ifapi.clear_interface_counters(vars.D1)
    ifapi.show_interface_counters_all(vars.D1)
    st.log("Starting of traffic from TGen")
    tg.tg_traffic_control(action='run',
                          stream_handle=tg_info['tg1_stream_id'],
                          duration=10)
    st.wait(sc_data.wait_stream_run)
    st.log("Stopping of traffic from TGen to get interface counters")
    tg.tg_traffic_control(action='stop',
                          stream_handle=tg_info['tg1_stream_id'])
    st.wait(sc_data.wait_for_stats)
    ifapi.show_interface_counters_all(vars.D1)
    tg_1_stats = tgapi.get_traffic_stats(tg,
                                         mode='aggregate',
                                         port_handle=tg_handler["tg_ph_1"])
    tg_2_stats = tgapi.get_traffic_stats(tg,
                                         mode='aggregate',
                                         port_handle=tg_handler["tg_ph_3"])
    total_rx_tg2 = tg_2_stats.rx.total_packets
    total_tx_tg1 = tg_1_stats.tx.total_packets
    percentage_95_total_tx_tg1 = (95 * int(total_tx_tg1)) / 100
    if not int(percentage_95_total_tx_tg1) <= int(total_rx_tg2):
        st.report_fail("traffic_transmission_failed", vars.T1D1P1)
    return True
Exemplo n.º 2
0
def nat_reboot_debug_fun():
    st.banner("Start of Collecting the needed debug info for failure analysis", width=100)
    ip_obj.show_ip_route(vars.D1)
    intf_obj.show_interface_counters_all(vars.D1)
    arp_obj.show_arp(vars.D1)
    nat_obj.show_nat_translations(vars.D1)
    st.banner("End of Collecting the needed debug info for failure analysis", width=100)
Exemplo n.º 3
0
def test_ft_dynamic_nat_warmboot():
    # ################ Author Details ################
    # Name: Kesava Swamy Karedla
    # Eamil: [email protected]
    # ################################################
    # Objective - FtOpSoRoNatWb001 - Verify warm boot with dynamic nat scaling entries.
    # #################################################
    result_flag=0
    platform = basic_obj.get_hwsku(vars.D1)
    common_constants = st.get_datastore(vars.D1, "constants", "default")
    if not platform.lower() in common_constants['WARM_REBOOT_SUPPORTED_PLATFORMS']:
        st.error("Warm-Reboot is not supported for this platform {}".format(platform))
        st.report_unsupported('test_case_unsupported')
    nat_obj.clear_nat(vars.D1, translations=True)
    nat_obj.config_nat_pool_binding(vars.D1, binding_name=data.bind_name[0], pool_name=data.pool_name[0],
                                    config=data.config_del)
    nat_obj.config_nat_pool_binding(vars.D1, binding_name="scale_bind", pool_name="scale_pool",
                                    acl_name=data.acl_table_in_nat_eg, config=data.config_add)
    st.log("Sending continuous traffic at 600 pps for the max dynamic nat entries to get learned")
    tg1.tg_traffic_control(action='run', handle=tg_str_data[1]["tg1_scale_nat_udp_data_str_id_1"])
    st.log("Waiting for traffic to run, such that max nat entries get learned")
    if not util_check_nat_translations_count(vars.D1,20,data.max_nat_entries):
        nat_reboot_debug_fun()
        st.log("Failed to learn max nat entries")
        result_flag = 1
    tg1.tg_traffic_control(action='stop', handle=tg_str_data[1]["tg1_scale_nat_udp_data_str_id_1"])
    # Show command for debugging purpose in case of failures.
    intf_obj.show_interface_counters_all(vars.D1)
    st.log("Warm boot verification")
    tgapi.traffic_action_control(tg_handler, actions=['clear_stats'])
    tg1.tg_traffic_control(action='run', handle=tg_str_data[1]["tg1_scale_nat_udp_data_str_id_1"])
    st.log("Performing warm-reboot, while traffic is forwarding for nat entries")
    st.reboot(vars.D1, 'warm')
    tg1.tg_traffic_control(action='stop', handle=tg_str_data[1]["tg1_scale_nat_udp_data_str_id_1"])
    traffic_details = {
        '1': {
            'tx_ports': [vars.T1D1P1],
            'tx_obj': [tg1],
            'exp_ratio': [1],
            'rx_ports': [vars.T1D1P2],
            'rx_obj': [tg2],
             }
                      }

    filter_result = tgapi.validate_tgen_traffic(traffic_details=traffic_details, mode='aggregate', comp_type='packet_count')
    if not filter_result:
        nat_reboot_debug_fun()
        st.log("Traffic loss observed for the SNAT traffic during warm-boot")
        result_flag = 1
    nat_obj.config_nat_pool_binding(vars.D1, binding_name=data.bind_name[1], pool_name=data.pool_name[1],
                                    config=data.config_add)
    nat_obj.config_nat_pool_binding(vars.D1, binding_name="scale_bind", pool_name="scale_pool",
                                    acl_name=data.acl_table_in_nat_eg, config=data.config_del)
    if result_flag:
        st.report_fail("nat_warm_reboot_failed")
    st.report_pass("test_case_passed")
Exemplo n.º 4
0
def verify_bum_traffic_mode(mode, tg_stream, skip_traffic_verify=False, duration=10):
    """
    :param mode:
    :param tg_stream:
    :param skip_traffic_verify:
    :param duration:
    :return:
    """
    if mode not in ["unknown-unicast", "unknown-multicast", "broadcast"]:
        st.log("Unsupported mode provided")
        return False
    st.banner("verifying  {} traffic ".format(mode))
    st.log("Clearing stats before sending traffic ...")
    tg.tg_traffic_control(action="clear_stats", port_handle=tg_handler["tg_ph_list"])
    st.wait(2)
    if mode == 'broadcast':
        st.log("Enabling {} traffic ".format(mode))
        tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='modify',duration=10, stream_id=tg_stream,
                             mac_src="00:00:00:00:00:01", mac_dst="ff:ff:ff:ff:ff:ff", rate_pps=5000)
    elif mode == 'unknown-multicast':
        st.log("Enabling {} traffic ".format(mode))
        tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='modify', duration=10,stream_id=tg_stream,
                             mac_src="00:00:00:00:00:01",mac_dst="01:00:5e:01:02:03",rate_pps=5000)
    elif mode == 'unknown-unicast':
        st.log("Enabling {} traffic ".format(mode))
        tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"],duration=10, mode='modify', stream_id=tg_stream,
                             mac_src="00:00:00:00:00:01", mac_dst="00:00:00:00:00:02",
                             rate_pps=5000)
    if not skip_traffic_verify:
        ifapi.clear_interface_counters(vars.D1,interface_type="all")
        ifapi.show_interface_counters_all(vars.D1)
        st.log("Starting of traffic from TGen")
        tg.tg_traffic_control(action='run', stream_handle=tg_stream, duration=10)
        st.wait(sc_data.wait_stream_run)
        st.log("Stopping of traffic from TGen to get interface counters")
        tg.tg_traffic_control(action='stop', stream_handle=tg_stream)
        st.wait(sc_data.wait_for_stats)
        ifapi.show_interface_counters_all(vars.D1)
        tg_1_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_1"], direction='tx')
        tg_2_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_2"])
        counter = tg_2_stats.rx.total_packets
        counter2 = tg_1_stats.tx.total_packets
        if counter2 == 0:
            st.report_fail("storm_control_traffic_verification_failed")
        counters_avg = counter / duration
        st.log("Average of counters are : {}".format(counters_avg))
        st.log("Higher packet count value is : {}".format(sc_data.higher_pkt_count ))
        st.log("Lower packet count value is : {}".format(sc_data.lower_pkt_count))
        if  counters_avg > sc_data.higher_pkt_count or counters_avg < sc_data.lower_pkt_count:
            st.report_fail("storm_control_traffic_verification_failed")
    return True
def verify_traffic_hashed_or_not(dut,
                                 port_list,
                                 pkts_per_port,
                                 traffic_loss_verify=False,
                                 rx_port='',
                                 tx_port='',
                                 dut2=''):
    if traffic_loss_verify is True:
        [output,
         exceptions] = exec_all(True,
                                [[intfobj.show_interface_counters_all, dut],
                                 [intfobj.show_interface_counters_all, dut2]])
        ensure_no_exception(exceptions)
        static_data.intf_counters_1, static_data.intf_counters_2 = output
    else:
        static_data.intf_counters_1 = intfobj.show_interface_counters_all(dut)
    static_data.intf_count_dict = {}
    for port in port_list:
        for counter_dict in static_data.intf_counters_1:
            if counter_dict['iface'] == port:
                try:
                    tx_ok_counter = counter_dict['tx_ok'].replace(',', '')
                    static_data.intf_count_dict[port] = int(
                        tx_ok_counter) if tx_ok_counter.isdigit() else 0
                except Exception:
                    st.report_fail('invalid_traffic_stats')
                if not (static_data.intf_count_dict[port] >= pkts_per_port):
                    intfobj.show_interface_counters_detailed(
                        vars.D1, vars.D1T1P1)
                    st.report_fail("traffic_not_hashed", dut)
    if traffic_loss_verify is True:
        for counter_dict in static_data.intf_counters_1:
            if counter_dict['iface'] == rx_port:
                try:
                    rx_ok_counter = counter_dict['rx_ok'].replace(',', '')
                    static_data.rx_traffic = int(
                        rx_ok_counter) if rx_ok_counter.isdigit() else 0
                except Exception:
                    st.report_fail('invalid_traffic_stats')
                break
        for counter_dict in static_data.intf_counters_2:
            if counter_dict['iface'] == tx_port:
                try:
                    tx_ok_counter = counter_dict['tx_ok'].replace(',', '')
                    static_data.tx_traffic = int(
                        tx_ok_counter) if tx_ok_counter.isdigit() else 0
                except Exception:
                    st.report_fail('invalid_traffic_stats')
                break
        if not (static_data.tx_traffic >= 0.95 * static_data.rx_traffic):
            st.log("data.tx_traffic:{}".format(static_data.tx_traffic))
            st.log("data.rx_traffic:{}".format(static_data.rx_traffic))
            intfobj.show_interface_counters_detailed(vars.D1, vars.D1T1P1)
            st.report_fail('traffic_loss_observed')
    return True
Exemplo n.º 6
0
def threshold_feature_debug(dut, mode, platform=None, test=''):
    """
    Debug calls for Threshold feature.
    Author: Prudvi Mangadu ([email protected])
    :param dut:
    :param mode:
    :param platform:
    :param test:
    :return:
    """
    mode_li = list(mode) if isinstance(mode, list) else [mode]
    for each_mode in mode_li:
        if each_mode == 'clear_counters':
            intapi.clear_interface_counters(dut)
            # intapi.clear_watermark_counters(dut,'all')

        if each_mode == 'show_counters':
            intapi.show_interface_counters_all(dut)
            # intapi.show_watermark_counters(dut,'all')
            asicapi.clear_counters(dut)
            st.wait(1)
            asicapi.dump_counters(dut)

        if each_mode == 'asic_info':
            asicapi.dump_threshold_info(dut, test, platform, 'asic_info')

        if each_mode == 'debug_log_enable':
            st.config(dut, 'swssloglevel -l DEBUG -c thresholdmgr', skip_error_check=True)
            st.config(dut, 'swssloglevel -l SAI_LOG_LEVEL_DEBUG -s -c TAM', skip_error_check=True)

        if each_mode == 'debug_log_disable':
            st.config(dut, 'swssloglevel -l INFO -c thresholdmgr', skip_error_check=True)
            st.config(dut, 'swssloglevel -l SAI_LOG_LEVEL_INFO -s -c TAM', skip_error_check=True)

        if each_mode == 'show_logging':
            logapi.show_logging(dut, lines=100)

        if each_mode == 'port_map':
            asicapi.dump_threshold_info(dut, test, platform, 'asic_portmap')
def verify_traffic_hash(dut, port_list, pkts_per_port, traffic_loss_verify=False, rx_port = '',
                                 tx_port = '', dut2 =''):
    if traffic_loss_verify:
        sub_list = []
        sub_list.append([intf_obj.show_interface_counters_all, dut])
        sub_list.append([intf_obj.show_interface_counters_all, dut2])
        [output, exceptions] = utils.exec_all(True, sub_list)
        utils.ensure_no_exception(exceptions)
        data.int_cntr_1, data.int_cntr_2 = output
    else:
        data.int_cntr_1 = intf_obj.show_interface_counters_all(dut)
    data.intf_count_dict = {}
    for port in port_list:
        for counter_dict in iterable(data.int_cntr_1):
            if counter_dict['iface'] == port:
                try:
                    data.intf_count_dict[port] = int(counter_dict['tx_ok'].replace(',',''))
                except Exception:
                    st.report_fail('invalid_traffic_stats')
                if not (data.intf_count_dict[port] >= pkts_per_port):
                    intf_obj.show_interface_counters_detailed(vars.D1, vars.D1T1P1)
                    st.report_fail("traffic_not_hashed", dut)
    if traffic_loss_verify:
        for counter_dict in data.int_cntr_1:
            if counter_dict['iface'] == rx_port:
                try:
                    data.rx_traffic = int(counter_dict['rx_ok'].replace(',', ''))
                except Exception:
                    st.report_fail('invalid_traffic_stats')
                break
        for counter_dict in data.int_cntr_2:
            if counter_dict['iface'] == tx_port:
                try:
                    data.tx_traffic = int(counter_dict['tx_ok'].replace(',', ''))
                except Exception:
                    st.report_fail('invalid_traffic_stats')
                break
        if not (data.tx_traffic >= 0.95* data.rx_traffic):
            st.log("data.tx_traffic:{}".format(data.tx_traffic))
            st.log("data.rx_traffic:{}".format(data.rx_traffic))
            intf_obj.show_interface_counters_detailed(vars.D1, vars.D1T1P1)
            st.report_fail('traffic_loss_observed')
    return data.intf_count_dict
Exemplo n.º 8
0
def test_ft_vlan_save_config_warm_and_fast_reboot():
    '''
    Author: Sai Durga <*****@*****.**>
    This script covers the below scenarios

    ft_max_vlan_save_reload	    Verify the save and reload functionality with max vlan configuration.
    ft_max_vlan_fast_reload	    Verify the max vlan configuration is retained after fast-reboot.
    FtOpSoSwVlFn026	            Verify that VLAN is present and traffic is not disturbed during and after warm reboot
    FtOpSoSysFRFn005            Verify the Fast-Reboot must disrupt control plane not more than 90 seconds (from sonic test suite -configuration tests)
    ft_reboot_fdb_fast_reboot   Verify that the FDB entry is retained after fast reboot.

    '''
    status = True
    msg_id = "max_vlan_config_retain_after_save_fast_warm_reboot"
    vlan_module_epilog()
    vlan_module_config(config='yes')
    st.log("Device name is : {}".format(sc_data.dut_platform))

    st.log("Saving the MAX VLAN config on the device")
    reboot.config_save(vars.D1)

    st.log("Performing reboot and checking the VLAN configuration")
    st.reboot(vars.D1)
    st.log("Checking VLAN config after reboot")
    max_vlan_verify()

    st.log(
        "Sending traffic with 100 MAC,Checking FDB table updated with 100 MAC addresses and performing reboot and checking the VLAN configuration"
    )
    tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"])
    tg_1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"],
                                mode='create',
                                length_mode='fixed',
                                frame_size=72,
                                mac_src='00:01:00:00:00:01',
                                mac_src_step='00:00:00:00:00:01',
                                mac_src_mode='increment',
                                mac_src_count=sc_data.mac_count,
                                mac_dst='00:02:00:00:00:02',
                                rate_pps=2000,
                                l2_encap='ethernet_ii_vlan',
                                vlan="enable",
                                vlan_id=sc_data.vlan,
                                transmit_mode='continuous')
    tg_info['tg1_stream_id'] = tg_1['stream_id']
    tg.tg_traffic_control(action='run', stream_handle=tg_info['tg1_stream_id'])
    st.wait(2)
    tg.tg_traffic_control(action='stop',
                          stream_handle=tg_info['tg1_stream_id'])

    if not poll_wait(mac_verify, 300):
        st.error("mac_address_verification_fail")

    st.log("Performing fast-reboot and checking the VLAN configuration")
    st.reboot(vars.D1, 'fast')
    st.log("Checking VLAN config after fast-reboot")
    max_vlan_verify()
    st.log("Sending traffic after fast reboot and checking the FDB table")
    tg.tg_traffic_control(action='run', stream_handle=tg_info['tg1_stream_id'])
    st.wait(2)
    tg.tg_traffic_control(action='stop',
                          stream_handle=tg_info['tg1_stream_id'])

    if not poll_wait(mac_verify, 300):
        st.error("mac_address_verification_fail")

    st.log("Performing warm reboot and checking the traffic")
    ifapi.clear_interface_counters(vars.D1)
    st.wait(2)
    ifapi.show_interface_counters_all(vars.D1)
    st.wait(2)
    tg.tg_traffic_control(action='run', stream_handle=tg_info['tg1_stream_id'])
    st.wait(2)
    st.reboot(vars.D1, 'warm')
    st.log("Checking VLAN config after warm-reboot")
    max_vlan_verify()
    tg.tg_traffic_control(action='stop',
                          stream_handle=tg_info['tg1_stream_id'])
    st.log("Checking traffic is forwarded without any loss after warm-reboot")
    st.log("Fetching TGen statistics")
    st.wait(2)
    ifapi.show_interface_counters_all(vars.D1)

    stats_tg1 = tgapi.get_traffic_stats(tg,
                                        mode="aggregate",
                                        port_handle=tg_handler["tg_ph_1"])
    total_tx_tg1 = stats_tg1.tx.total_bytes

    stats_tg2 = tgapi.get_traffic_stats(tg,
                                        mode="aggregate",
                                        port_handle=tg_handler["tg_ph_2"])
    total_rx_tg2 = stats_tg2.rx.total_bytes

    percentage_95_total_tx_tg1 = (95 * int(total_tx_tg1)) / 100
    st.log("###############")
    st.log("Sent bytes: {} and Received bytes : {}".format(
        percentage_95_total_tx_tg1, total_rx_tg2))
    st.log("##############")
    if int(percentage_95_total_tx_tg1) > int(total_rx_tg2):
        st.report_fail("traffic_transmission_failed", vars.T1D1P1)

    report_result(status, msg_id)
Exemplo n.º 9
0
def test_ft_arp_dynamic_renew_traffic_test(fixture_ft_arp_dynamic_renew_traffic_test):
    ################## Author Details ################
    # Name: Rakesh Kumar Vooturi
    # Email: [email protected]
    ##################################################
    #
    # Objective - Verify a dynamic ARP table entry can be created.
    # Objective - Verify that there is no data traffic loss during ARP dynamic review.
    #
    ############### Test bed details ################
    #  TG-----DUT-----TG
    #################################################
    # Set DUT values
    st.log("Setting the DUT values")
    arp_obj.set_arp_ageout_time(dut1,75,cli_type=data.cli_type)

    # Ping from tgen to DUT.
    res = tgapi.verify_ping(src_obj=tg, port_handle=tg_handler["tg_ph_1"], dev_handle=h1['handle'],
                     dst_ip=data.d1t1_ip_addr,ping_count='1', exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    res = tgapi.verify_ping(src_obj=tg, port_handle=tg_handler["tg_ph_2"], dev_handle=h2['handle'],
                     dst_ip=data.d1t2_ip_addr,ping_count='1', exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    # TG ports reset
    st.log("Resetting the TG ports")
    tg.tg_traffic_control(action="clear_stats", port_handle=tg_handler["tg_ph_list"])

    #TG stream formation
    s1 = tg.tg_traffic_config(port_handle= tg_handler["tg_ph_2"],mode='create',rate_pps=10,
                    mac_src=data.t2d1_mac_addr,transmit_mode="continuous",mac_dst=d1_mac_addr,
                    l2_encap='ethernet_ii_vlan',l3_protocol="ipv4",ip_dst_addr=data.t1d1_ip_addr,
                    ip_src_addr=data.t2d1_ip_addr,vlan_id=data.vlan_1,vlan="enable")
    interface_obj.clear_interface_counters(dut1)
    tg.tg_traffic_control(action="run", stream_handle=s1['stream_id'])

    # Waiting for more than arp ageout time
    st.wait(10)

    tg.tg_traffic_control(action="stop", stream_handle=s1['stream_id'])

    # Adding sleep
    st.wait(5)

    st.log("Checking the stats and verifying the traffic flow")
    traffic_details = {
            '1': {
            'tx_ports': [vars.T1D1P2],
            'tx_obj': [tg],
            'exp_ratio': [1],
            'rx_ports': [vars.T1D1P1],
            'rx_obj': [tg],
        }
    }
    if not tgapi.validate_tgen_traffic(traffic_details=traffic_details, mode='aggregate', comp_type='packet_count'):
        interface_obj.show_interface_counters_all(dut1)
        st.report_fail("traffic_verification_failed")
    else:
        st.log("traffic verification passed")
    st.report_pass("test_case_passed")
Exemplo n.º 10
0
def test_ft_wred_functionality():
    """
    Author : Sai Durga <*****@*****.**>
    FtOpSoQsWdFn012 : Verify that WRED fnctionality working fine and WRED green drop counters incremented properly.
    Setup:
    ===========
    DUT-----3---- TGen

    Procedure:
    ===========
    1. Create a VLAN 10 and participate all the 3 ports in VLAN 10.
    2. Send tagged traffic from 3rd port and check the FDB table.
    3. Now configure WRED, dscp_to_tc_map and tc to queue map tables and bind it to 3 ports.
    4. Now send matched traffic from port1 to port3 and unmatched traffic from port2 to port3.

    Expected Results:
    =====================
    1. Verify that VLAN 10 created and all the 3 ports added to vlan 10
    2. Verify that FDB table updated with 3rd port MAC addresses.
    3. Verify that WRED, dscp_to_tc_map and tc to queue map tables created and binded to 3 ports
    5. Verify that matched traffic forwared to configured queues based on the min and max threshold values and unmatched traffic is dropped and WRED green incremented properly.


    """

    st.log("Configuring MAC age time out")
    fdb_config()
    st.log("Creating vlan and adding the TGen connected ports to it")
    vlan_config()
    st.log("Clearing the interface counters before sending the traffic")
    ifapi.clear_interface_counters(vars.D1, interface_type="all")
    st.log("Sending traffic from port 3 to learn the MAC in FDB table")
    data.tg.tg_traffic_control(
        action='run', stream_handle=data.streams['vlan_tagged_egress'])
    st.log("Verifying FDB table")
    if not poll_wait(mac_obj.verify_mac_address_table, 30, vars.D1,
                     data.dscp_dest_mac):
        st.log(
            "Displaying the interface counters to verify traffic is sent or not"
        )
        ifapi.show_interface_counters_all(vars.D1)
        st.report_fail("mac_address_verification_fail")
    wred_running_config()
    configuring_tc_to_queue_map()
    configuring_dscp_to_tc_map()
    binding_queue_map_to_interfaces()
    st.log("Clearing the interface counters before sending the traffic")
    ifapi.clear_interface_counters(vars.D1, interface_type="all")
    st.log("Sending traffic from 1st and 2nd port")
    data.tg.tg_traffic_control(
        action='run',
        stream_handle=[data.streams['dscp1'], data.streams['dscp2']])
    st.wait(3)
    data.tg.tg_traffic_control(action='stop',
                               stream_handle=[
                                   data.streams['dscp1'],
                                   data.streams['dscp2'],
                                   data.streams['vlan_tagged_egress']
                               ])
    st.log("Displaying the interface counters after traffic test")
    ifapi.show_interface_counters_all(vars.D1)
    cos_counters_checking()
    st.report_pass("test_case_passed")
Exemplo n.º 11
0
def test_ft_l3_fwding():
    """
    Testcase : verify the basic L3 traffic validation
    Author : Praveen Kumar Kota <*****@*****.**>
    """
    sub_intf = 0
    operation_tg1 = {
        "openconfig-if-ip:config": {
            "ip": "192.168.1.1",
            "prefix-length": 24
        }
    }
    operation_tg2 = {
        "openconfig-if-ip:config": {
            "ip": "192.168.2.1",
            "prefix-length": 24
        }
    }
    rest_urls = st.get_datastore(vars.D1, "rest_urls")
    url = rest_urls['ip_config'].format(vars.D1T1P1, sub_intf,
                                        data.ip4_addr_t1)
    url2 = rest_urls['ip_config'].format(vars.D1T1P2, sub_intf,
                                         data.ip4_addr_t2)

    config_rest(vars.D1,
                http_method="rest-patch",
                rest_url=url,
                json_data=operation_tg1)
    get_rest(vars.D1, rest_url=url)
    config_rest(vars.D1,
                http_method="rest-patch",
                rest_url=url2,
                json_data=operation_tg2)
    get_rest(vars.D1, rest_url=url2)

    h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"],
                                mode='config',
                                intf_ip_addr=data.ip4_addr_t1_tg,
                                gateway=data.ip4_addr_t1,
                                src_mac_addr=data.tg_mac1,
                                arp_send_req='1')
    tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"],
                           mode='config',
                           intf_ip_addr=data.ip4_addr_t2_tg,
                           gateway=data.ip4_addr_t2,
                           src_mac_addr=data.tg_mac2,
                           arp_send_req='1')
    res = tgapi.verify_ping(src_obj=tg,
                            port_handle=tg_handler["tg_ph_1"],
                            dev_handle=h1['handle'],
                            dst_ip=data.ip4_addr_t2_tg,
                            ping_count='1',
                            exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")
    dut_rt_int_mac1 = basic_obj.get_ifconfig_ether(vars.D1, vars.D1T1P1)
    tr1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='create', transmit_mode='single_burst',
                               pkts_per_burst=1000, length_mode='fixed', rate_pps=1000, l3_protocol='ipv4', mac_src=data.tg_mac1, \
                               mac_dst=dut_rt_int_mac1, ip_src_addr=data.ip4_addr_t1_tg, ip_dst_addr=data.ip4_addr_t2_tg)
    ifapi.clear_interface_counters(vars.D1, interface_type="all")
    ifapi.show_interface_counters_all(vars.D1)
    tg.tg_traffic_control(action='run', stream_handle=tr1['stream_id'])
    st.wait(2)
    tg.tg_traffic_control(action='stop', stream_handle=tr1['stream_id'])
    st.wait(2)
    ifapi.show_interface_counters_all(vars.D1)
    tg_1_stats = tgapi.get_traffic_stats(tg,
                                         mode='aggregate',
                                         port_handle=tg_handler["tg_ph_1"])
    tg_2_stats = tgapi.get_traffic_stats(tg,
                                         mode='aggregate',
                                         port_handle=tg_handler["tg_ph_2"])
    counter1 = tg_2_stats.rx.total_packets
    counter2 = tg_1_stats.tx.total_packets
    if not counter1 >= counter2:
        ifapi.show_interface_counters_all(vars.D1)
        st.report_fail("test_case_failed")
    st.report_pass("test_case_passed")