Exemplo n.º 1
0
    status = int_ret0['status']
    if (status == '0'):
        print("run sth.interface_config failed")
        print(int_ret0)

##############################################################
#stream config
##############################################################
for i in range(len(port_list)):
    Stream_config['port_handle'] = port_handle[i]
    if (i == 0):
        Stream_config['dest_port_list'] = port_handle[i + 1]
    else:
        Stream_config['dest_port_list'] = port_handle[i - 1]
    Stream_config['name'] = Streams[i]
    streamblock_ret1 = sth.traffic_config(**Stream_config)
    status = streamblock_ret1['status']
    if (status == '0'):
        print("run sth.traffic_config failed")
        print(streamblock_ret1)

#############################################################
#start traffic
##############################################################
print("Traffic Started")
traffic_ctrl_ret = sth.traffic_control(
    port_handle=[port_handle[0], port_handle[1]], action='run', duration='30')

status = traffic_ctrl_ret['status']
if (status == '0'):
    print("run sth.traffic_control failed")
Exemplo n.º 2
0
#EX_TelnetSendCommand "configure terminal"

#EX_TelnetSendCommand "interface gigabitEthernet 13/31"
#EX_TelnetSendCommand "ip vrf forwarding vpn123"
#EX_TelnetSendCommand "ip address 13.31.0.1 255.255.0.0"

#EX_TelnetClose

##############################################################
# Step12.Create MPLS L2VPN traffic
##############################################################
print "Create traffic from left CE to right CE"
streamblock_ret1 = sth.traffic_config(mode='create',
                                      port_handle=port_handle[0],
                                      length_mode='fixed',
                                      l3_length='256',
                                      emulation_src_handle=ceCustomSide,
                                      emulation_dst_handle=ceProvideSide,
                                      rate_pps='10')

status = streamblock_ret1['status']
if (status == '0'):
    print("Failed to create traffic")
    print(streamblock_ret1)
else:
    print("***** Create traffic successfully")

print "Create traffic from right CE to left CE"

streamblock_ret1 = sth.traffic_config(mode='create',
                                      port_handle=port_handle[1],
Exemplo n.º 3
0
test_ctrl_sta = sth.test_control(action='enable')

status = test_ctrl_sta['status']
if (status == '0'):
    print("run sth.test_control failed")
    print(test_ctrl_sta)
else:
    print("***** run sth.test_control successfully")

############################################################################
# Step2. Configure streamblock with multiple inner and outer vlan priorities
############################################################################

streamblock_ret1 = sth.traffic_config(mode='create',
                                      name='BIP',
                                      port_handle=port_handle[0],
                                      l2_encap='ethernet_ii')

status = streamblock_ret1['status']
if (status == '0'):
    print("run sth.traffic_config failed")
    print(streamblock_ret1)
else:
    print("***** run sth.traffic_config successfully")
    stream_id1 = streamblock_ret1['stream_id']
    sth._private_invoke('stc::config %s -AllowInvalidHeaders true' %
                        stream_id1)
# add NOKIA BIP header to raw stream block

protocolData = dict()
protocolData['newHeader'] = 'bip'  # Mention new Header to be added
Exemplo n.º 4
0
status = test_ctrl_sta['status']
if (status == '0'):
    print("run sth.test_control failed")
    print(test_ctrl_sta)
else:
    print("***** run sth.test_control successfully")

########################################
# Step2. Genearte L2 Traffic on Port1 and Port2
########################################

streamblock_ret1 = sth.traffic_config(mode='create',
                                      port_handle=port_handle[0],
                                      l2_encap='ethernet_ii',
                                      transmit_mode='continuous',
                                      length_mode='fixed',
                                      l3_length='1002',
                                      rate_pps='1000')

status = streamblock_ret1['status']
if (status == '0'):
    print("run sth.traffic_config failed")
    print(streamblock_ret1)
else:
    print("***** run sth.traffic_config successfully")

sb1 = streamblock_ret1['stream_id']

streamblock_ret2 = sth.traffic_config(mode='create',
                                      port_handle=port_handle[1],
Exemplo n.º 5
0
streamblock_ret1 = sth.traffic_config(
    mode='create',
    port_handle=port_handle[0],
    l2_encap='ethernet_ii_vlan',
    vlan_id_repeat='0',
    vlan_id_mode='increment',
    vlan_id_count='399',
    vlan_id_step='1',
    mac_src='00:10:94:13:00:01',
    mac_dst='00:10:94:14:00:01',
    vlan_cfi='0',
    vlan_tpid='33024',
    vlan_id='1',
    vlan_user_priority='0',
    enable_control_plane='0',
    l3_length='9078',
    name='StreamBlock_2',
    fill_type='constant',
    fcs_error='0',
    fill_value='0',
    frame_size='9100',
    traffic_state='1',
    high_speed_result_analysis='1',
    length_mode='fixed',
    tx_port_sending_traffic_to_self_en='false',
    disable_signature='0',
    enable_stream_only_gen='1',
    pkts_per_burst='1',
    inter_stream_gap_unit='bytes',
    inter_stream_gap='12',
    rate_mbps='800',
    enable_stream='false')
if (status == '0') :
    print("***** Bound the IGMP and the Multicast Group failed")
    print(membershipStatus)
else:
    print("***** Bound the IGMP and the Multicast Group successfully")
    print(membershipStatus)
    
##############################################################
# Step 6. Create multicast and unicast streamblock 
##############################################################

streamblock_multicast = sth.traffic_config (
        mode                                             = 'create',
        port_handle                                      = port_handle[0],
        emulation_src_handle                             = hdl,
        emulation_dst_handle                             = McGroupHandle,
        l3_length                                        = '128',
        length_mode                                      = 'fixed',
        mac_discovery_gw                                 = '6.41.1.100',
        rate_percent                                     = '10')

status = streamblock_multicast['status']
if (status == '0') :
    print("run sth.traffic_config failed")
    print(streamblock_multicast)
else:
    print("***** run sth.traffic_config successfully")
    
streamblock_unicast = sth.traffic_config (
        mode                                             = 'create',
        port_handle                                      = port_handle[0],
Exemplo n.º 7
0
def dip():

    ##############################################################
    #config the parameters for the logging
    ##############################################################

    test_sta = sth.test_config (
            log                                              = '1',
            logfile                                          = 'dip2_logfile',
            vendorlogfile                                    = 'dip2_stcExport',
            vendorlog                                        = '1',
            hltlog                                           = '1',
            hltlogfile                                       = 'dip2_hltExport',
            hlt2stcmappingfile                               = 'dip2_hlt2StcMapping',
            hlt2stcmapping                                   = '1',
            log_level                                        = '7');

    status = test_sta['status']
    if (status == '0') :
        print("run sth.test_config failed")
        print(test_sta)
    else:
        print("***** run sth.test_config successfully")


    ##############################################################
    #config the parameters for optimization and parsing
    ##############################################################

    test_ctrl_sta = sth.test_control (
            action                                           = 'enable');

    status = test_ctrl_sta['status']
    if (status == '0') :
        print("run sth.test_control failed")
        print(test_ctrl_sta)
    else:
        print("***** run sth.test_control successfully")


    ##############################################################
    #connect to chassis and reserve port list
    ##############################################################

    i = 0
    device = "10.91.113.124"
    port_list = ['11/8','4/6']
    port_handle = []
    intStatus = sth.connect (
            device                                           = device,
            port_list                                        = port_list,
            break_locks                                      = 1,
            offline                                          = 0 )

    status = intStatus['status']

    if (status == '1') :
        for port in port_list :
            port_handle.append(intStatus['port_handle'][device][port])
            print("\n reserved ports",port,":", port_handle[i])
            i += 1
    else :
        print("\nFailed to retrieve port handle!\n")
        print(port_handle)


    ##############################################################
    #interface config
    ##############################################################

    int_ret0 = sth.interface_config (
            mode                                             = 'config',
            port_handle                                      = port_handle[0],
            create_host                                      = 'false',
            intf_mode                                        = 'ethernet',
            phy_mode                                         = 'fiber',
            scheduling_mode                                  = 'RATE_BASED',
            port_loadunit                                    = 'PERCENT_LINE_RATE',
            port_load                                        = '10',
            enable_ping_response                             = '0',
            control_plane_mtu                                = '1500',
            flow_control                                     = 'false',
            speed                                            = 'ether1000',
            data_path_mode                                   = 'normal',
            autonegotiation                                  = '1');

    status = int_ret0['status']
    if (status == '0') :
        print("run sth.interface_config failed")
        print(int_ret0)
    else:
        print("***** run sth.interface_config successfully")

    int_ret1 = sth.interface_config (
            mode                                             = 'config',
            port_handle                                      = port_handle[1],
            create_host                                      = 'false',
            intf_mode                                        = 'ethernet',
            phy_mode                                         = 'fiber',
            scheduling_mode                                  = 'RATE_BASED',
            port_loadunit                                    = 'PERCENT_LINE_RATE',
            port_load                                        = '10',
            enable_ping_response                             = '0',
            control_plane_mtu                                = '1500',
            flow_control                                     = 'false',
            speed                                            = 'ether1000',
            data_path_mode                                   = 'normal',
            autonegotiation                                  = '1');

    status = int_ret1['status']
    if (status == '0') :
        print("run sth.interface_config failed")
        print(int_ret1)
    else:
        print("***** run sth.interface_config successfully")


    ##############################################################
    #create device and config the protocol on it
    ##############################################################

    #start to create the device: Device 1
    device_ret0 = sth.emulation_device_config (
            mode                                             = 'create',
            ip_version                                       = 'ipv4',
            encapsulation                                    = 'ethernet_ii_vlan',
            port_handle                                      = port_handle[0],
            vlan_user_pri                                    = '7',
            vlan_cfi                                         = '0',
            vlan_id                                          = '20',
            vlan_tpid                                        = '33024',
            vlan_id_repeat_count                             = '0',
            vlan_id_step                                     = '0',
            router_id                                        = '192.0.0.5',
            count                                            = '1',
            enable_ping_response                             = '1',
            mac_addr                                         = '00:10:94:00:00:05',
            mac_addr_step                                    = '00:00:00:00:00:01',
            intf_ip_addr                                     = '192.168.10.1',
            intf_prefix_len                                  = '24',
            resolve_gateway_mac                              = 'true',
            gateway_ip_addr                                  = '192.168.10.2',
            gateway_ip_addr_step                             = '0.0.0.0',
            intf_ip_addr_step                                = '0.0.0.1');

    status = device_ret0['status']
    if (status == '0') :
        print("run sth.emulation_device_config failed")
        print(device_ret0)
    else:
        print("***** run sth.emulation_device_config successfully")

    #start to create the device: Device 2
    device_ret1 = sth.emulation_device_config (
            mode                                             = 'create',
            ip_version                                       = 'ipv4',
            encapsulation                                    = 'ethernet_ii_vlan',
            port_handle                                      = port_handle[1],
            vlan_user_pri                                    = '7',
            vlan_cfi                                         = '0',
            vlan_id                                          = '20',
            vlan_tpid                                        = '33024',
            vlan_id_repeat_count                             = '0',
            vlan_id_step                                     = '0',
            router_id                                        = '192.0.0.6',
            count                                            = '1',
            enable_ping_response                             = '1',
            mac_addr                                         = '00:10:94:00:00:06',
            mac_addr_step                                    = '00:00:00:00:00:01',
            intf_ip_addr                                     = '192.168.10.2',
            intf_prefix_len                                  = '24',
            resolve_gateway_mac                              = 'true',
            gateway_ip_addr                                  = '192.168.10.1',
            gateway_ip_addr_step                             = '0.0.0.0',
            intf_ip_addr_step                                = '0.0.0.1');

    status = device_ret1['status']
    if (status == '0') :
        print("run sth.emulation_device_config failed")
        print(device_ret1)
    else:
        print("***** run sth.emulation_device_config successfully")


    ##############################################################
    #create traffic
    ##############################################################

    src_hdl = device_ret0['handle'].split()[0]

    dst_hdl = device_ret1['handle'].split()[0]


    streamblock_ret1 = sth.traffic_config (
            mode                                             = 'create',
            port_handle                                      = port_handle[0],
            emulation_src_handle                             = src_hdl,
            emulation_dst_handle                             = dst_hdl,
            l3_protocol                                      = 'ipv4',
            ip_id                                            = '0',
            ip_ttl                                           = '255',
            ip_hdr_length                                    = '5',
            ip_protocol                                      = '253',
            ip_fragment_offset                               = '0',
            ip_mbz                                           = '0',
            ip_precedence                                    = '6',
            ip_tos_field                                     = '0',
            enable_control_plane                             = '0',
            l3_length                                        = '9100',
            name                                             = 'StreamBlock_18-3',
            fill_type                                        = 'constant',
            fcs_error                                        = '0',
            fill_value                                       = '0',
            frame_size                                       = '9100',
            traffic_state                                    = '1',
            high_speed_result_analysis                       = '1',
            length_mode                                      = 'fixed',
            dest_port_list                                   = ['port2','port1'],
            tx_port_sending_traffic_to_self_en               = 'false',
            disable_signature                                = '0',
            enable_stream_only_gen                           = '1',
            pkts_per_burst                                   = '1',
            inter_stream_gap_unit                            = 'bytes',
            inter_stream_gap                                 = '12',
            rate_mbps                                        = '50',
            mac_discovery_gw                                 = '192.168.10.2');

    status = streamblock_ret1['status']
    if (status == '0') :
        print("run sth.traffic_config failed")
        print(streamblock_ret1)
    else:
        print("***** run sth.traffic_config successfully")

    src_hdl = device_ret1['handle'].split()[0]

    dst_hdl = device_ret0['handle'].split()[0]


    streamblock_ret2 = sth.traffic_config (
            mode                                             = 'create',
            port_handle                                      = port_handle[1],
            emulation_src_handle                             = src_hdl,
            emulation_dst_handle                             = dst_hdl,
            l3_protocol                                      = 'ipv4',
            ip_id                                            = '0',
            ip_ttl                                           = '255',
            ip_hdr_length                                    = '5',
            ip_protocol                                      = '253',
            ip_fragment_offset                               = '0',
            ip_mbz                                           = '0',
            ip_precedence                                    = '6',
            ip_tos_field                                     = '0',
            enable_control_plane                             = '0',
            l3_length                                        = '9100',
            name                                             = 'StreamBlock_18-4',
            fill_type                                        = 'constant',
            fcs_error                                        = '0',
            fill_value                                       = '0',
            frame_size                                       = '9100',
            traffic_state                                    = '1',
            high_speed_result_analysis                       = '1',
            length_mode                                      = 'fixed',
            dest_port_list                                   = ['port2','port1'],
            tx_port_sending_traffic_to_self_en               = 'false',
            disable_signature                                = '0',
            enable_stream_only_gen                           = '1',
            pkts_per_burst                                   = '1',
            inter_stream_gap_unit                            = 'bytes',
            inter_stream_gap                                 = '12',
            rate_mbps                                        = '50',
            mac_discovery_gw                                 = '192.168.10.1');

    status = streamblock_ret2['status']
    if (status == '0') :
        print("run sth.traffic_config failed")
        print(streamblock_ret2)
    else:
        print("***** run sth.traffic_config successfully")

    #config part is finished

    ##############################################################
    #start devices
    ##############################################################


    ##############################################################
    #start traffic
    ##############################################################

    traffic_ctrl_ret = sth.traffic_control (
            port_handle                                      = [port_handle[0],port_handle[1]],
            action                                           = 'run',
            duration                                         = '30');

    status = traffic_ctrl_ret['status']
    if (status == '0') :
        print("run sth.traffic_control failed")
        print(traffic_ctrl_ret)
    else:
        print("***** run sth.traffic_control successfully")


    ##############################################################
    #start to get the device results
    ##############################################################


    ##############################################################
    #start to get the traffic results
    ##############################################################

    traffic_results_ret = sth.traffic_stats (
            port_handle                                      = [port_handle[0],port_handle[1]],
            mode                                             = 'all');

    status = traffic_results_ret['status']
    if (status == '0') :
        print("run sth.traffic_stats failed")
        print(traffic_results_ret)
    else:
        print("***** run sth.traffic_stats successfully, and results is:")
        print(traffic_results_ret)


    ##############################################################
    #clean up the session, release the ports reserved and cleanup the dbfile
    ##############################################################

    cleanup_sta = sth.cleanup_session (
            port_handle                                      = [port_handle[0],port_handle[1]],
            clean_dbfile                                     = '1');

    status = cleanup_sta['status']
    if (status == '0') :
        print("run sth.cleanup_session failed")
        print(cleanup_sta)
    else:
        print("***** run sth.cleanup_session successfully")


    print("**************Finish***************")

    result = SpirentResult(traffic_results_ret, port_list)
    return result
else:
    print "***** run sth.emulation_device_config successfully."
    

##############################################################
#Step 6: Create two streamblocks on port1 and port2
##############################################################

#get host handle from hostblock and DHCP_group_config
hd1 = device_ret1['handle']
hd2 = hostblock['handle']

streamblock = sth.traffic_config (
    mode = 'create',
    port_handle = port_handle[0],
    port_handle2 = port_handle[1],
    emulation_src_handle = hd1,
    emulation_dst_handle = hd2,
    bidirectional = '1');

status = streamblock['status']
if (status =='0') :
    print "run sth.traffic_config failed"
    print streamblock
else:
    print "***** run sth.traffic_config successfully."

streamId = streamblock ['stream_id']
streamIdList = list(streamId.values())

##############################################################
Exemplo n.º 9
0
def spi2():
    Booked_ports, Interface_config, Stream_config, Spirent_Test_Infra = spirent_items(
    )
    test_sta = sth.test_config(
        log='1',
        logfile='SteamConfig-WithPercentageTraffic_logfile',
        vendorlogfile='SteamConfig-WithPercentageTraffic_stcExport',
        vendorlog='1',
        hltlog='1',
        hltlogfile='SteamConfig-WithPercentageTraffic_hltExport',
        hlt2stcmappingfile='SteamConfig-WithPercentageTraffic_hlt2StcMapping',
        hlt2stcmapping='1',
        log_level='7')
    Number_of_ports = Spirent_Test_Infra['Number_of_ports']
    status = test_sta['status']
    if (status == '0'):
        print("run sth.test_config failed")
        print(test_sta)
    ##############################################################
    #config the parameters for optimization and parsing
    ##############################################################

    test_ctrl_sta = sth.test_control(action='enable')

    status = test_ctrl_sta['status']
    if (status == '0'):
        print("run sth.test_control failed")
        print(test_ctrl_sta)
    ##############################################################
    #connect to chassis and reserve port list
    ##############################################################
    i = 0
    device = "10.91.113.124"
    port_list = list(Booked_ports.values())
    port_handle = []
    intStatus = sth.connect(device=device,
                            port_list=port_list,
                            break_locks=1,
                            offline=0)

    status = intStatus['status']

    if (status == '1'):
        for port in port_list:
            port_handle.append(intStatus['port_handle'][device][port])
            i += 1
    else:
        print("\nFailed to retrieve port handle!\n")
        print(port_handle)

    ##############################################################
    #interface config
    ##############################################################

    Interface_config['port_handle'] = port_handle[0]
    int_ret0 = sth.interface_config(**Interface_config)
    status = int_ret0['status']
    if (status == '0'):
        print("run sth.interface_config failed")
        print(int_ret0)
    Interface_config['port_handle'] = port_handle[1]
    int_ret1 = sth.interface_config(**Interface_config)
    status = int_ret1['status']
    if (status == '0'):
        print("run sth.interface_config failed")
        print(int_ret0)
    ##############################################################
    #stream config
    ##############################################################
    Stream_config['port_handle'] = port_handle[0]
    Stream_config['dest_port_list'] = port_handle[1]
    Stream_config['name'] = 'Stream From 9-3 to 9-4'
    streamblock_ret1 = sth.traffic_config(**Stream_config)
    status = streamblock_ret1['status']
    if (status == '0'):
        print("run sth.traffic_config failed")
        print(streamblock_ret1)
    Stream_config['port_handle'] = port_handle[1]
    Stream_config['dest_port_list'] = port_handle[0]
    Stream_config['name'] = 'Stream From 9-4 to 9-3'
    streamblock_ret1 = sth.traffic_config(**Stream_config)
    status = streamblock_ret1['status']
    if (status == '0'):
        print("run sth.traffic_config failed")
        print(streamblock_ret1)
    #############################################################
    #start traffic
    ##############################################################
    print("Traffic Started")
    traffic_ctrl_ret = sth.traffic_control(
        port_handle=[port_handle[0], port_handle[1]],
        action='run',
        duration='30')

    status = traffic_ctrl_ret['status']
    if (status == '0'):
        print("run sth.traffic_control failed")
        print(traffic_ctrl_ret)
    print("Test Traffic Stopped now adding delay before collecting stats")
    time.sleep(10)
    print("Traffic collection started")
    ##############################################################
    #start to get the traffic results
    ##############################################################
    traffic_results_ret = sth.traffic_stats(
        port_handle=[port_handle[0], port_handle[1]], mode='all')

    status = traffic_results_ret['status']
    if (status == '0'):
        print("run sth.traffic_stats failed")
        print(traffic_results_ret)

    # ##############################################################
    # #Get required values from Stats
    # ##############################################################
    # Streams_rx_stat = []
    # Streams_tx_stat = []
    # for i in range(1,Number_of_ports+1):
    # 	Port_Index = 'port'+ str(i)
    # 	Stream_Index = 'streamblock' + str(i)
    # 	Streams_rx_stats = traffic_results_ret[Port_Index]['stream'][Stream_Index]['rx']
    # 	Streams_tx_stats = traffic_results_ret[Port_Index]['stream'][Stream_Index]['tx']
    # 	Streams_rx_stat.append(int(Streams_rx_stats['total_pkt_bytes']))
    # 	Streams_tx_stat.append(int(Streams_tx_stats['total_pkt_bytes']))
    #
    # if((Streams_tx_stat[0] == Streams_rx_stat[1]) and (Streams_tx_stat[1] == Streams_rx_stat[0])):
    # 	print("Great Test Case is passed")
    # 	print("streamblock1 TX = ", Streams_tx_stat[0], "streamblock1 RX = ", Streams_rx_stat[0], "streamblock2 TX = ", Streams_tx_stat[1], "streamblock2 RX = ", Streams_rx_stat[1])
    #
    # 	stats = "streamblock1 TX = ", Streams_tx_stat[0], "streamblock1 RX = ", Streams_rx_stat[0], "streamblock2 TX = ", Streams_tx_stat[1], "streamblock2 RX = ", Streams_rx_stat[1]
    # 	status = "Great Test Case is passed\n" + str(stats)
    # 	return status
    #
    # else:
    # 	print("Oops Tst Case Failed")
    # 	print("streamblock1 TX = ", Streams_tx_stat[0], "streamblock1 RX = ", Streams_rx_stat[0], "streamblock2 TX = ", Streams_tx_stat[1], "streamblock2 RX = ", Streams_rx_stat[1])
    #
    # 	stats = "streamblock1 TX = ", Streams_tx_stat[0], "streamblock1 RX = ", Streams_rx_stat[0], "streamblock2 TX = ", Streams_tx_stat[1], "streamblock2 RX = ", Streams_rx_stat[1]
    # 	status = "Oops Tst Case Failed" + str(stats)
    # 	return status
    # 	Stream1_packet_loss_in_msec = ((Streams_tx_stat[0] - Streams_rx_stat[1]) / 1000)
    # 	Stream2_packet_loss_in_msec = ((Streams_tx_stat[1] - Streams_rx_stat[0]) / 1000)

    ##############################################################
    #Get required values from Stats
    ##############################################################

    result = SpirentResult(traffic_results_ret, port_list)
    return result
Exemplo n.º 10
0
else:
    print("***** run sth.test_control successfully")

########################################
# Step2. Configure streamblock with multiple inner and outer vlan priorities
########################################
streamblock_ret1 = sth.traffic_config(mode='create',
                                      port_handle=port_handle[0],
                                      l2_encap='ethernet_ii_vlan',
                                      fill_type='prbs',
                                      vlan_id='1',
                                      vlan_id_count='3',
                                      vlan_id_step='1',
                                      vlan_user_priority='1',
                                      vlan_id_outer='100',
                                      vlan_id_outer_step='1',
                                      rate_pps='1000',
                                      l3_protocol='ipv4',
                                      vlan_id_repeat='0',
                                      vlan_id_mode='increment',
                                      vlan_id_outer_count='3',
                                      vlan_outer_user_priority='4',
                                      transmit_mode='continuous',
                                      ip_src_addr='10.0.0.11',
                                      ip_dst_addr='10.0.0.1')

status = streamblock_ret1['status']
if (status == '0'):
    print("run sth.traffic_config failed")
    print(streamblock_ret1)
else:
Exemplo n.º 11
0
def spi1():

    ##############################################################
    #config the parameters for the logging
    ##############################################################

    test_sta = sth.test_config(
        log='1',
        logfile='BasciTraffic_logfile',
        vendorlogfile='BasciTraffic_stcExport',
        vendorlog='1',
        hltlog='1',
        hltlogfile='BasciTraffic_hltExport',
        hlt2stcmappingfile='BasciTraffic_hlt2StcMapping',
        hlt2stcmapping='1',
        log_level='7')

    status = test_sta['status']
    if (status == '0'):
        print("run sth.test_config failed")
        print(test_sta)
    else:
        print("***** run sth.test_config successfully")

    ##############################################################
    #config the parameters for optimization and parsing
    ##############################################################

    test_ctrl_sta = sth.test_control(action='enable')

    status = test_ctrl_sta['status']
    if (status == '0'):
        print("run sth.test_control failed")
        print(test_ctrl_sta)
    else:
        print("***** run sth.test_control successfully")

    ##############################################################
    #connect to chassis and reserve port list
    ##############################################################

    i = 0
    device = "10.91.113.124"
    port_list = ['8/5', '8/6']
    port_handle = []
    intStatus = sth.connect(device=device,
                            port_list=port_list,
                            break_locks=1,
                            offline=0)

    status = intStatus['status']

    if (status == '1'):
        for port in port_list:
            port_handle.append(intStatus['port_handle'][device][port])
            print("\n reserved ports", port, ":", port_handle[i])
            i += 1
    else:
        print("\nFailed to retrieve port handle!\n")
        print(port_handle)

    ##############################################################
    #interface config
    ##############################################################

    int_ret0 = sth.interface_config(mode='config',
                                    port_handle=port_handle[0],
                                    create_host='false',
                                    intf_mode='ethernet',
                                    phy_mode='fiber',
                                    scheduling_mode='RATE_BASED',
                                    port_loadunit='FRAMES_PER_SECOND',
                                    port_load='1000',
                                    enable_ping_response='0',
                                    control_plane_mtu='1500',
                                    flow_control='false',
                                    speed='ether1000',
                                    data_path_mode='normal',
                                    autonegotiation='1')

    status = int_ret0['status']
    if (status == '0'):
        print("run sth.interface_config failed")
        print(int_ret0)
    else:
        print("***** run sth.interface_config successfully")

    int_ret1 = sth.interface_config(mode='config',
                                    port_handle=port_handle[1],
                                    create_host='false',
                                    intf_mode='ethernet',
                                    phy_mode='fiber',
                                    scheduling_mode='RATE_BASED',
                                    port_loadunit='FRAMES_PER_SECOND',
                                    port_load='1000',
                                    enable_ping_response='0',
                                    control_plane_mtu='1500',
                                    flow_control='false',
                                    speed='ether1000',
                                    data_path_mode='normal',
                                    autonegotiation='1')

    status = int_ret1['status']
    if (status == '0'):
        print("run sth.interface_config failed")
        print(int_ret1)
    else:
        print("***** run sth.interface_config successfully")

    ##############################################################
    #create device and config the protocol on it
    ##############################################################

    #start to create the device: ar1-100
    device_ret0 = sth.emulation_device_config(
        mode='create',
        ip_version='ipv4',
        encapsulation='ethernet_ii_vlan',
        port_handle=port_handle[0],
        vlan_user_pri='7',
        vlan_cfi='0',
        vlan_id='100',
        vlan_tpid='33024',
        vlan_id_repeat_count='0',
        vlan_id_step='0',
        router_id='192.0.0.3',
        count='1',
        enable_ping_response='1',
        mac_addr='00:10:94:00:00:03',
        mac_addr_step='00:00:00:00:00:01',
        intf_ip_addr='172.16.146.0',
        intf_prefix_len='31',
        resolve_gateway_mac='true',
        gateway_ip_addr='172.16.146.1',
        gateway_ip_addr_step='0.0.0.0',
        gateway_mac='00:a7:42:16:5f:23',
        intf_ip_addr_step='0.0.0.1')

    status = device_ret0['status']
    if (status == '0'):
        print("run sth.emulation_device_config failed")
        print(device_ret0)
    else:
        print("***** run sth.emulation_device_config successfully")

    #start to create the device: ar6-100
    device_ret1 = sth.emulation_device_config(
        mode='create',
        ip_version='ipv4',
        encapsulation='ethernet_ii_vlan',
        port_handle=port_handle[1],
        vlan_user_pri='7',
        vlan_cfi='0',
        vlan_id='100',
        vlan_tpid='33024',
        vlan_id_repeat_count='0',
        vlan_id_step='0',
        router_id='192.0.0.4',
        count='1',
        enable_ping_response='1',
        mac_addr='00:10:94:00:00:04',
        mac_addr_step='00:00:00:00:00:01',
        intf_ip_addr='172.17.146.0',
        intf_prefix_len='31',
        resolve_gateway_mac='true',
        gateway_ip_addr='172.17.146.1',
        gateway_ip_addr_step='0.0.0.0',
        gateway_mac='00:a7:42:36:12:8f',
        intf_ip_addr_step='0.0.0.1')

    status = device_ret1['status']
    if (status == '0'):
        print("run sth.emulation_device_config failed")
        print(device_ret1)
    else:
        print("***** run sth.emulation_device_config successfully")

    #start to create the device: ar1-101
    device_ret2 = sth.emulation_device_config(
        mode='create',
        ip_version='ipv4',
        encapsulation='ethernet_ii_vlan',
        port_handle=port_handle[0],
        vlan_user_pri='7',
        vlan_cfi='0',
        vlan_id='101',
        vlan_tpid='33024',
        vlan_id_repeat_count='0',
        vlan_id_step='0',
        router_id='192.0.0.5',
        count='1',
        enable_ping_response='1',
        mac_addr='00:10:94:00:00:05',
        mac_addr_step='00:00:00:00:00:01',
        intf_ip_addr='172.18.146.0',
        intf_prefix_len='31',
        resolve_gateway_mac='true',
        gateway_ip_addr='172.18.146.1',
        gateway_ip_addr_step='0.0.0.0',
        gateway_mac='00:a7:42:16:5f:23',
        intf_ip_addr_step='0.0.0.1')

    status = device_ret2['status']
    if (status == '0'):
        print("run sth.emulation_device_config failed")
        print(device_ret2)
    else:
        print("***** run sth.emulation_device_config successfully")

    #start to create the device: ar1-111 L2
    device_ret3 = sth.emulation_device_config(
        mode='create',
        ip_version='ipv4',
        encapsulation='ethernet_ii_vlan',
        port_handle=port_handle[0],
        vlan_user_pri='5',
        vlan_cfi='0',
        vlan_id='111',
        vlan_tpid='33024',
        vlan_id_repeat_count='0',
        vlan_id_step='0',
        router_id='192.0.0.6',
        count='1',
        enable_ping_response='1',
        mac_addr='00:11:11:00:00:01',
        mac_addr_step='00:00:00:00:00:01',
        intf_ip_addr='192.168.111.10',
        intf_prefix_len='24',
        resolve_gateway_mac='true',
        gateway_ip_addr='192.168.111.2',
        gateway_ip_addr_step='0.0.0.0',
        gateway_mac='00:10:94:00:00:07',
        intf_ip_addr_step='0.0.0.1')

    status = device_ret3['status']
    if (status == '0'):
        print("run sth.emulation_device_config failed")
        print(device_ret3)
    else:
        print("***** run sth.emulation_device_config successfully")

    #start to create the device: ar6-111 L2
    device_ret4 = sth.emulation_device_config(
        mode='create',
        ip_version='ipv4',
        encapsulation='ethernet_ii_vlan',
        port_handle=port_handle[1],
        vlan_user_pri='5',
        vlan_cfi='0',
        vlan_id='111',
        vlan_tpid='33024',
        vlan_id_repeat_count='0',
        vlan_id_step='0',
        router_id='192.0.0.7',
        count='1',
        enable_ping_response='1',
        mac_addr='00:10:94:00:00:07',
        mac_addr_step='00:00:00:00:00:01',
        intf_ip_addr='192.168.111.2',
        intf_prefix_len='24',
        resolve_gateway_mac='true',
        gateway_ip_addr='192.168.111.10',
        gateway_ip_addr_step='0.0.0.0',
        gateway_mac='00:11:11:00:00:01',
        intf_ip_addr_step='0.0.0.1')

    status = device_ret4['status']
    if (status == '0'):
        print("run sth.emulation_device_config failed")
        print(device_ret4)
    else:
        print("***** run sth.emulation_device_config successfully")

    #start to create the device: ar1-110 L2
    device_ret5 = sth.emulation_device_config(
        mode='create',
        ip_version='ipv4',
        encapsulation='ethernet_ii_vlan',
        port_handle=port_handle[0],
        vlan_user_pri='3',
        vlan_cfi='0',
        vlan_id='110',
        vlan_tpid='33024',
        vlan_id_repeat_count='0',
        vlan_id_step='0',
        router_id='192.0.0.6',
        count='1',
        enable_ping_response='1',
        mac_addr='00:10:94:00:00:06',
        mac_addr_step='00:00:00:00:00:01',
        intf_ip_addr='110.168.110.111',
        intf_prefix_len='24',
        resolve_gateway_mac='true',
        gateway_ip_addr='110.168.110.112',
        gateway_ip_addr_step='0.0.0.0',
        gateway_mac='00:10:94:00:00:07',
        intf_ip_addr_step='0.0.0.1')

    status = device_ret5['status']
    if (status == '0'):
        print("run sth.emulation_device_config failed")
        print(device_ret5)
    else:
        print("***** run sth.emulation_device_config successfully")

    #start to create the device: ar6-110 L2
    device_ret6 = sth.emulation_device_config(
        mode='create',
        ip_version='ipv4',
        encapsulation='ethernet_ii_vlan',
        port_handle=port_handle[1],
        vlan_user_pri='3',
        vlan_cfi='0',
        vlan_id='110',
        vlan_tpid='33024',
        vlan_id_repeat_count='0',
        vlan_id_step='0',
        router_id='192.0.0.7',
        count='1',
        enable_ping_response='1',
        mac_addr='00:10:94:00:00:07',
        mac_addr_step='00:00:00:00:00:01',
        intf_ip_addr='110.168.110.112',
        intf_prefix_len='24',
        resolve_gateway_mac='true',
        gateway_ip_addr='110.168.110.111',
        gateway_ip_addr_step='0.0.0.0',
        gateway_mac='00:10:94:00:00:06',
        intf_ip_addr_step='0.0.0.1')

    status = device_ret6['status']
    if (status == '0'):
        print("run sth.emulation_device_config failed")
        print(device_ret6)
    else:
        print("***** run sth.emulation_device_config successfully")

    #start to create the device: ar6-112 L2
    device_ret7 = sth.emulation_device_config(
        mode='create',
        ip_version='ipv4',
        encapsulation='ethernet_ii_vlan',
        port_handle=port_handle[1],
        vlan_user_pri='3',
        vlan_cfi='0',
        vlan_id='112',
        vlan_tpid='33024',
        vlan_id_repeat_count='0',
        vlan_id_step='0',
        router_id='192.0.0.7',
        count='1',
        enable_ping_response='1',
        mac_addr='00:10:94:00:00:07',
        mac_addr_step='00:00:00:00:00:01',
        intf_ip_addr='112.112.12.1',
        intf_prefix_len='24',
        resolve_gateway_mac='true',
        gateway_ip_addr='112.112.12.2',
        gateway_ip_addr_step='0.0.0.0',
        gateway_mac='00:12:94:00:00:06',
        intf_ip_addr_step='0.0.0.1')

    status = device_ret7['status']
    if (status == '0'):
        print("run sth.emulation_device_config failed")
        print(device_ret7)
    else:
        print("***** run sth.emulation_device_config successfully")

    #start to create the device: ar1-112 L2
    device_ret8 = sth.emulation_device_config(
        mode='create',
        ip_version='ipv4',
        encapsulation='ethernet_ii_vlan',
        port_handle=port_handle[0],
        vlan_user_pri='3',
        vlan_cfi='0',
        vlan_id='112',
        vlan_tpid='33024',
        vlan_id_repeat_count='0',
        vlan_id_step='0',
        router_id='192.0.0.6',
        count='1',
        enable_ping_response='1',
        mac_addr='00:12:94:00:00:06',
        mac_addr_step='00:00:00:00:00:01',
        intf_ip_addr='112.112.12.2',
        intf_prefix_len='24',
        resolve_gateway_mac='true',
        gateway_ip_addr='112.112.12.1',
        gateway_ip_addr_step='0.0.0.0',
        gateway_mac='00:10:94:00:00:07',
        intf_ip_addr_step='0.0.0.1')

    status = device_ret8['status']
    if (status == '0'):
        print("run sth.emulation_device_config failed")
        print(device_ret8)
    else:
        print("***** run sth.emulation_device_config successfully")

    #start to create the device: ar1-113 L2
    device_ret9 = sth.emulation_device_config(
        mode='create',
        ip_version='ipv4',
        encapsulation='ethernet_ii_vlan',
        port_handle=port_handle[0],
        vlan_user_pri='3',
        vlan_cfi='0',
        vlan_id='113',
        vlan_tpid='33024',
        vlan_id_repeat_count='0',
        vlan_id_step='0',
        router_id='192.0.0.6',
        count='1',
        enable_ping_response='1',
        mac_addr='00:12:94:00:00:06',
        mac_addr_step='00:00:00:00:00:01',
        intf_ip_addr='13.113.13.2',
        intf_prefix_len='24',
        resolve_gateway_mac='true',
        gateway_ip_addr='13.113.13.1',
        gateway_ip_addr_step='0.0.0.0',
        gateway_mac='00:10:94:00:00:07',
        intf_ip_addr_step='0.0.0.1')

    status = device_ret9['status']
    if (status == '0'):
        print("run sth.emulation_device_config failed")
        print(device_ret9)
    else:
        print("***** run sth.emulation_device_config successfully")

    #start to create the device: ar6-113 L2
    device_ret10 = sth.emulation_device_config(
        mode='create',
        ip_version='ipv4',
        encapsulation='ethernet_ii_vlan',
        port_handle=port_handle[1],
        vlan_user_pri='3',
        vlan_cfi='0',
        vlan_id='113',
        vlan_tpid='33024',
        vlan_id_repeat_count='0',
        vlan_id_step='0',
        router_id='192.0.0.7',
        count='1',
        enable_ping_response='1',
        mac_addr='00:10:94:00:00:07',
        mac_addr_step='00:00:00:00:00:01',
        intf_ip_addr='13.113.13.1',
        intf_prefix_len='24',
        resolve_gateway_mac='true',
        gateway_ip_addr='13.113.13.2',
        gateway_ip_addr_step='0.0.0.0',
        gateway_mac='00:12:94:00:00:06',
        intf_ip_addr_step='0.0.0.1')

    status = device_ret10['status']
    if (status == '0'):
        print("run sth.emulation_device_config failed")
        print(device_ret10)
    else:
        print("***** run sth.emulation_device_config successfully")

    ##############################################################
    #create traffic
    ##############################################################

    src_hdl = device_ret0['handle'].split()[0]

    dst_hdl = device_ret1['handle'].split()[0]

    streamblock_ret1 = sth.traffic_config(
        mode='create',
        port_handle=port_handle[0],
        emulation_src_handle=src_hdl,
        emulation_dst_handle=dst_hdl,
        l3_protocol='ipv4',
        ip_id='0',
        ip_ttl='255',
        ip_hdr_length='5',
        ip_protocol='253',
        ip_fragment_offset='0',
        ip_dscp='10',
        enable_control_plane='0',
        l3_length='1500',
        name='ar1-100_B3',
        fill_type='constant',
        fcs_error='0',
        fill_value='0',
        frame_size='1500',
        traffic_state='1',
        high_speed_result_analysis='1',
        length_mode='fixed',
        dest_port_list=['port2', 'port1'],
        tx_port_sending_traffic_to_self_en='false',
        disable_signature='0',
        enable_stream_only_gen='1',
        pkts_per_burst='1',
        inter_stream_gap_unit='bytes',
        burst_loop_count='30',
        transmit_mode='continuous',
        inter_stream_gap='12',
        rate_pps='1000',
        mac_discovery_gw='172.16.146.1')

    status = streamblock_ret1['status']
    if (status == '0'):
        print("run sth.traffic_config failed")
        print(streamblock_ret1)
    else:
        print("***** run sth.traffic_config successfully")

    src_hdl = device_ret1['handle'].split()[0]

    dst_hdl = device_ret0['handle'].split()[0]

    streamblock_ret2 = sth.traffic_config(
        mode='create',
        port_handle=port_handle[1],
        emulation_src_handle=src_hdl,
        emulation_dst_handle=dst_hdl,
        l3_protocol='ipv4',
        ip_id='0',
        ip_ttl='255',
        ip_hdr_length='5',
        ip_protocol='253',
        ip_fragment_offset='0',
        ip_dscp='10',
        enable_control_plane='0',
        l3_length='1500',
        name='ar6-100_B3',
        fill_type='constant',
        fcs_error='0',
        fill_value='0',
        frame_size='1500',
        traffic_state='1',
        high_speed_result_analysis='1',
        length_mode='fixed',
        dest_port_list=['port2', 'port1'],
        tx_port_sending_traffic_to_self_en='false',
        disable_signature='0',
        enable_stream_only_gen='1',
        pkts_per_burst='1',
        inter_stream_gap_unit='bytes',
        burst_loop_count='30',
        transmit_mode='continuous',
        inter_stream_gap='12',
        rate_pps='1000',
        mac_discovery_gw='172.17.146.1')

    status = streamblock_ret2['status']
    if (status == '0'):
        print("run sth.traffic_config failed")
        print(streamblock_ret2)
    else:
        print("***** run sth.traffic_config successfully")

    #config part is finished

    ##############################################################
    #start devices
    ##############################################################

    ##############################################################
    #start traffic
    ##############################################################

    traffic_ctrl_ret = sth.traffic_control(
        port_handle=[port_handle[0], port_handle[1]],
        action='run',
        duration='30')

    status = traffic_ctrl_ret['status']
    if (status == '0'):
        print("run sth.traffic_control failed")
        print(traffic_ctrl_ret)
    else:
        print("***** run sth.traffic_control successfully")

    ##############################################################
    #start to get the device results
    ##############################################################

    time.sleep(30)

    ##############################################################
    #start to get the traffic results
    ##############################################################

    traffic_results_ret = sth.traffic_stats(
        port_handle=[port_handle[0], port_handle[1]], mode='all')

    status = traffic_results_ret['status']
    if (status == '0'):
        print("run sth.traffic_stats failed")
        print(traffic_results_ret)

    else:
        print("***** run sth.traffic_stats successfully, and results is:")
        print(traffic_results_ret)

    ##############################################################
    #clean up the session, release the ports reserved and cleanup the dbfile
    ##############################################################

    cleanup_sta = sth.cleanup_session(
        port_handle=[port_handle[0], port_handle[1]], clean_dbfile='1')

    status = cleanup_sta['status']
    if (status == '0'):
        print("run sth.cleanup_session failed")
        print(cleanup_sta)
    else:
        print("***** run sth.cleanup_session successfully")

    print("**************Finish***************")

    result = SpirentResult(traffic_results_ret, port_list)
    return result
    print("***** run sth.interface_config successfully")
    print int_ret1

##############################################################
#Step3. Configure streamblock on two ports
##############################################################
print "Configure streamblock on port1 : port1 -> port2"
streamblock_ret1 = sth.traffic_config(mode='create',
                                      port_handle=port_handle[0],
                                      l2_encap='ethernet_ii_vlan',
                                      l3_protocol='ipv4',
                                      vlan_id='4',
                                      vlan_id_count='4',
                                      l3_length='108',
                                      transmit_mode='continuous',
                                      length_mode='fixed',
                                      ip_src_addr='10.21.0.2',
                                      ip_dst_addr='11.55.0.2',
                                      mac_discovery_gw='10.21.0.1',
                                      mac_discovery_gw_step='0.1.0.0',
                                      mac_discovery_gw_count='4',
                                      ip_src_step='0.1.0.0',
                                      ip_src_count='4',
                                      ip_dst_count='2')

status = streamblock_ret1['status']
if (status == '0'):
    print("run sth.traffic_config failed")
    print(streamblock_ret1)
else:
    print("***** run sth.traffic_config successfully")
Exemplo n.º 13
0
def Spirent_MAC_Transperancy_Traffic_Testing_For_EVPN_Service():
    Booked_ports, Interface_config, Stream_config, Spirent_Test_Infra, Stream_Name = get_spirent_data(
    )
    Number_of_ports = Spirent_Test_Infra['Number_of_ports']
    Number_of_streams_per_Port = Spirent_Test_Infra[
        'Number_of_streams_per_Port']
    Total_Number_of_stream = Spirent_Test_Infra['Total_Number_of_stream']
    Initial_MAC_address = Spirent_Test_Infra['Initial_MAC_address']

    ##############################################################
    # Creation of Spirent Test config with log file
    ##############################################################

    test_sta = sth.test_config(
        log='1',
        logfile='SteamConfig-WithPercentageTraffic_logfile',
        vendorlogfile='SteamConfig-WithPercentageTraffic_stcExport',
        vendorlog='1',
        hltlog='1',
        hltlogfile='SteamConfig-WithPercentageTraffic_hltExport',
        hlt2stcmappingfile='SteamConfig-WithPercentageTraffic_hlt2StcMapping',
        hlt2stcmapping='1',
        log_level='7')

    status = test_sta['status']
    if (status == '0'):
        print("run sth.test_config failed")

    ##############################################################
    # config the parameters for optimization and parsing
    ##############################################################

    test_ctrl_sta = sth.test_control(action='enable')

    status = test_ctrl_sta['status']
    if (status == '0'):
        print("run sth.test_control failed")

    ##############################################################
    # connect to chassis and reserve port list
    ##############################################################
    i = 0
    device = "10.91.113.124"
    port_list = list(Booked_ports.values())
    Streams = list(Stream_Name.values())
    port_handle = []
    intStatus = sth.connect(device=device,
                            port_list=port_list,
                            break_locks=1,
                            offline=0)

    status = intStatus['status']

    if (status == '1'):
        for port in port_list:
            port_handle.append(intStatus['port_handle'][device][port])
            i += 1
    else:
        print("\nFailed to retrieve port handle!\n")
    #		print(port_handle)
    print(port_handle)
    ##############################################################
    # Spirent Ports configuration
    ##############################################################
    for i in range(len(port_list)):
        int_ret0 = sth.interface_config(mode='config',
                                        port_handle=port_handle[i],
                                        create_host='false',
                                        intf_mode='ethernet',
                                        phy_mode='fiber',
                                        scheduling_mode='RATE_BASED',
                                        port_loadunit='PERCENT_LINE_RATE',
                                        port_load='50',
                                        enable_ping_response='0',
                                        control_plane_mtu='1500',
                                        flow_control='false',
                                        speed='ether1000',
                                        data_path_mode='normal',
                                        autonegotiation='1')
        status = int_ret0['status']
        if (status == '0'):
            print("run sth.interface_config failed")
    # print(int_ret0)
    ##############################################################
    # create traffic
    ##############################################################
    streamblock_ret1 = sth.traffic_config(
        mode='create',
        port_handle=port_handle[0],
        l2_encap='ethernet_ii',
        l3_protocol='ipv4',
        ip_id='0',
        ip_src_addr='192.85.1.2',
        ip_dst_addr='192.0.0.1',
        ip_ttl='255',
        ip_hdr_length='5',
        ip_protocol='253',
        ip_fragment_offset='0',
        ip_mbz='0',
        ip_precedence='0',
        ip_tos_field='0',
        mac_dst_mode='increment',
        mac_dst_repeat_count='0',
        mac_dst_count='50',
        mac_src_count='50',
        mac_src_mode='increment',
        mac_src_repeat_count='0',
        mac_src='00:10:94:00:00:02',
        mac_dst='00:00:01:00:00:01',
        enable_control_plane='0',
        l3_length='4982',
        name='StreamBlock_11',
        fill_type='constant',
        fcs_error='0',
        fill_value='0',
        frame_size='2000',
        traffic_state='1',
        high_speed_result_analysis='1',
        length_mode='fixed',
        dest_port_list=port_handle[1],
        tx_port_sending_traffic_to_self_en='false',
        disable_signature='0',
        enable_stream_only_gen='1',
        pkts_per_burst='1',
        inter_stream_gap_unit='bytes',
        burst_loop_count='6000',
        transmit_mode='continuous',
        inter_stream_gap='12',
        rate_mbps='800',
        mac_discovery_gw='192.85.1.1',
        enable_stream='false')

    status = streamblock_ret1['status']
    if (status == '0'):
        print("run sth.traffic_config failed")
        print(streamblock_ret1)
    else:
        print("***** run sth.traffic_config successfully")

    streamblock_ret2 = sth.traffic_config(
        mode='create',
        port_handle=port_handle[1],
        l2_encap='ethernet_ii',
        l3_protocol='ipv4',
        ip_id='0',
        ip_src_addr='192.85.1.2',
        ip_dst_addr='192.0.0.1',
        ip_ttl='255',
        ip_hdr_length='5',
        ip_protocol='253',
        ip_fragment_offset='0',
        ip_mbz='0',
        ip_precedence='0',
        ip_tos_field='0',
        mac_dst_mode='increment',
        mac_dst_repeat_count='0',
        mac_dst_count='50',
        mac_src_count='50',
        mac_src_mode='increment',
        mac_src_repeat_count='0',
        mac_src='00:00:01:00:00:01',
        mac_dst='00:10:94:00:00:02',
        enable_control_plane='0',
        l3_length='4982',
        name='StreamBlock_12',
        fill_type='constant',
        fcs_error='0',
        fill_value='0',
        frame_size='5000',
        traffic_state='1',
        high_speed_result_analysis='1',
        length_mode='fixed',
        dest_port_list=port_handle[0],
        tx_port_sending_traffic_to_self_en='false',
        disable_signature='0',
        enable_stream_only_gen='1',
        pkts_per_burst='1',
        inter_stream_gap_unit='bytes',
        burst_loop_count='6000',
        transmit_mode='continuous',
        inter_stream_gap='12',
        rate_mbps='800',
        mac_discovery_gw='192.85.1.1',
        enable_stream='false')

    status = streamblock_ret2['status']
    if (status == '0'):
        print("run sth.traffic_config failed")
        print(streamblock_ret2)
    else:
        print("***** run sth.traffic_config successfully")

    # config part is finished
    #############################################################
    # start traffic
    ##############################################################
    print("Traffic Started First Time")
    traffic_ctrl_ret = sth.traffic_control(
        port_handle=[port_handle[0], port_handle[1]],
        action='run',
        duration='30')
    time.sleep(60)
    print("After Aging Timer")
    traffic_ctrl_ret = sth.traffic_control(
        port_handle=[port_handle[0], port_handle[1]], action='clear_stats')
    print("Delay before Second Traffic Started Second Time")
    time.sleep(60)
    print("Traffic Started Second Time")
    traffic_ctrl_ret = sth.traffic_control(
        port_handle=[port_handle[0], port_handle[1]],
        action='run',
        duration='10')
    status = traffic_ctrl_ret['status']
    if (status == '0'):
        print("run sth.traffic_control failed")
    # print(traffic_ctrl_ret)
    print("Test Traffic Stopped now adding delay before collecting stats")
    time.sleep(70)
    print("Traffic collection started")
    ##############################################################
    # start to get the traffic results
    ##############################################################
    traffic_results_ret = sth.traffic_stats(
        port_handle=[port_handle[0], port_handle[1]], mode='all')
    print("Traffic collection stopped")
    status = traffic_results_ret['status']
    if (status == '0'):
        print("run sth.traffic_stats failed")
    pprint(traffic_results_ret)
    cleanup_sta = sth.cleanup_session(
        port_handle=[port_handle[0], port_handle[1]], clean_dbfile='1')
    print("Port Cleanedup")
    ##############################################################
    # Get required values from Stats
    ##############################################################

    traffic_result = str(traffic_results_ret)

    # regex to get rx, tx and streams from traffic_results_ret
    RX = '(streamblock\d+)\S+\s+\S+(rx)\S+\s+\S+total_pkt_bytes\S+\s+\S(\d+)'
    TX = '(streamblock\d+).*?(tx)\S+\s+\S+total_pkt_bytes\S+\s+\S(\d+)'

    StreamBlock = 'streamblock\d+'

    print('Spirent Ports= ' + str(port_list) + '\nTotal Ports= ' +
          str(len(port_list)))
    PortStatus = 'Spirent Ports= ' + str(port_list) + '\nTotal Ports= ' + str(
        len(port_list))
    StreamBlock = re.findall(StreamBlock, traffic_result)
    print('Stream Configured= ' + str(StreamBlock) + '\nTotal Streams= ' +
          str(len(StreamBlock)))
    StreamStatus = 'Stream Configured= ' + str(
        StreamBlock) + '\nTotal Streams= ' + str(len(StreamBlock))
    rx_stats = re.findall(RX, traffic_result)
    tx_stats = re.findall(TX, traffic_result)

    print('rx_stats= ' + str(rx_stats))
    print('tx_stats= ' + str(tx_stats))

    stats = 'rx_stats= ' + str(rx_stats) + '\ntx_stats= ' + str(tx_stats)

    StreamResult = []

    for i in range(0, len(StreamBlock)):
        if rx_stats[i][2] == tx_stats[i][2]:
            print(str(rx_stats[i][0] + ' = pass'))
            StreamResult.append('pass')

        else:
            print(str(rx_stats[i][0] + ' = fail'))
            StreamResult.append('fail')

    print(str(StreamResult))

    OverallStatus = '\n' + PortStatus + '\n' + StreamStatus + '\n' + stats + '\n' + str(
        StreamResult)
    # print(OverallStatus)

    return OverallStatus
Exemplo n.º 14
0
if (status == '0'):
    print("run sth.emulation_dhcp_group_config failed")
    print(device_cfg_ret1)
else:
    print("***** run sth.emulation_dhcp_group_config successfully")

##############################################
#step7: create stream block
#############################################

streamblock = sth.traffic_config(mode='create',
                                 port_handle=port_handle[0],
                                 port_handle2=port_handle[1],
                                 emulation_src_handle=deviceHdlServer,
                                 emulation_dst_handle=deviceHdlClient,
                                 l3_protocol='ipv6',
                                 l2_encap='ethernet_ii',
                                 ipv6_src_addr='aaaa:1::2',
                                 ipv6_src_mode='fixed',
                                 mac_src='00.00.02.00.00.01',
                                 mac_discovery_gw='aaaa:1::1')

status = streamblock['status']
if (status == '0'):
    print "run sth.traffic_config failed"
    print streamblock
else:
    print "***** run sth.traffic_config successfully."

#config part is finished
sth.invoke('stc::perform saveasxml -filename pppoe_dhcpv6pd_traffic.xml')
Exemplo n.º 15
0
    printProperties(lbl, pimGroupMemberHandle2)

##############################################################
# Step5. Config traffic
##############################################################
src_hdl = device_ret0['handle'].split()[0]

dst_hdl = device_ret1_pim_group0_macstgroup['handle'].split()[0]

streamblock_ret1 = sth.traffic_config(mode='create',
                                      port_handle=port_handle[0],
                                      emulation_src_handle=src_hdl,
                                      emulation_dst_handle=dst_hdl,
                                      l2_encap='ethernet_ii',
                                      l3_protocol='ipv4',
                                      l3_length='128',
                                      length_mode='fixed',
                                      mac_discovery_gw='41.1.0.1',
                                      mac_dst_mode='increment',
                                      mac_src='00.21.00.00.00.21',
                                      mac_dst='01:00:5E:00:00:01',
                                      ip_src_addr='13.13.0.10',
                                      ip_dst_addr='225.19.0.10')

status = streamblock_ret1['status']
if (status == '0'):
    print("run sth.traffic_config failed")
    print(streamblock_ret1)
else:
    print("***** run sth.traffic_config successfully")

src_hdl = device_ret1['handle'].split()[0]
Exemplo n.º 16
0
    print("run sth.interface_config failed")
    print(int_ret1)
else:
    print("***** run sth.interface_config successfully")
    print int_ret1
    
##############################################################
#Step3. Configure streamblock on two ports
##############################################################
print "Configure streamblock on port1 : port1 -> port2"
streamblock_ret1 = sth.traffic_config (
        mode                                             = 'create',
        port_handle                                      = port_handle[0],
        l2_encap                                         = 'ethernet_ii',
        l3_protocol                                      = 'ipv4',
        l3_length                                        = '256',
        length_mode                                      = 'fixed',
        ip_src_addr                                      = '192.168.1.10',
        ip_dst_addr                                      = '192.168.1.100',
        mac_discovery_gw                                 = '192.168.1.100',
        mac_dst                                          = '00:10:94:00:00:03',
        mac_src                                          = '00:10:94:00:00:02')
                
status = streamblock_ret1['status']
if (status == '0') :
    print("run sth.traffic_config failed")
    print(streamblock_ret1)
else:
    print("***** run sth.traffic_config successfully")

streamblock1 = streamblock_ret1['stream_id']
Exemplo n.º 17
0
    print("run sth.emulation_igmp_host_info failed")
    print(results_hosts)
else:
    print(
        "***** run sth.emulation_igmp_host_info successfully, and results is:")
    print(results_hosts)

##############################################################
# Step 10. Setup ipv4 multicast traffic
##############################################################
print "Setup ipv4 multicast traffic"
streamblock = sth.traffic_config(mode='create',
                                 port_handle=port_handle[1],
                                 rate_pps='1000',
                                 l2_encap='ethernet_ii',
                                 l3_protocol='ipv4',
                                 l3_length='128',
                                 transmit_mode='continuous',
                                 length_mode='fixed',
                                 ip_src_addr='20.0.0.2',
                                 emulation_dst_handle=igmpGroup)

status = streamblock['status']
if (status == '0'):
    print("run sth.traffic_config failed")
    print(streamblock)
else:
    print("***** run sth.traffic_config successfully")
    print(streamblock)

stream_down_id = streamblock['stream_id']
Exemplo n.º 18
0
status = device_ret1['status']
if (status == '0'):
    print("run sth.pppox_config failed")
    print(device_ret1)
else:
    print("***** run sth.pppox_config successfully")
    deviceHdlClient = device_ret1['handle']

##############################################
#step4: create stream block
#############################################

streamblock = sth.traffic_config(mode='create',
                                 port_handle=port_handle[0],
                                 port_handle2=port_handle[1],
                                 emulation_src_handle=deviceHdlClient,
                                 emulation_dst_handle=deviceHdlClient,
                                 l3_protocol='ipv6',
                                 l2_encap='ethernet_ii')

status = streamblock['status']
if (status == '0'):
    print "run sth.traffic_config failed"
    print streamblock
else:
    print "***** run sth.traffic_config successfully."

#config part is finished
sth.invoke('stc::perform saveasxml -filename pppox_ipv6_traffic.xml')

##############################################################
Exemplo n.º 19
0
    def Execute_Loopback_Test(self):
        def command_ouput(self, interface_name_list, device_list):
            print("**** statistic of traffic on both devices")
            for uni_port, device in zip(interface_name_list, device_list):
                net_connect = Netmiko(**device)
                command = 'show policy-map interface {}.{} | utility egrep "Match\|input\|output\|Drop"'.format(
                    uni_port, self.sub_interface)
                command_ouput = net_connect.send_command("show run hostname")
                command_ouput += net_connect.send_command(command)
                print(command_ouput)
                net_connect.disconnect()

        def clear_QOS_ouput(self, interface_name_list, device_list):
            print("**** clearing statistic on both devices")
            for uni_port, device in zip(interface_name_list, device_list):
                net_connect = Netmiko(**device)
                command = 'clear qos counters interface {}.{}'.format(
                    uni_port, self.sub_interface)
                command_ouput = net_connect.send_command(command)
                print(command_ouput)
                net_connect.disconnect()

        def Command_Creation(self, filename, item1, item2, inter_exter,
                             loop_id, **interface_name):
            if inter_exter == 'internal':
                dict_to_render = {
                    'main_inf': interface_name['deviceB'],
                    'sub_if': self.sub_interface,
                    'internal_external': inter_exter,
                    'Loop_id': loop_id
                }
            else:
                dict_to_render = {
                    'main_inf': interface_name['deviceA'],
                    'sub_if': self.sub_interface,
                    'internal_external': inter_exter,
                    'Loop_id': loop_id
                }
            with open(filename, 'r') as f:
                Temp = f.read()
                failure_command = Template(Temp).render(**dict_to_render)
                f.close()
                file_open = open(
                    self.file_path + "/Loopback_Commands/" + str(item1) +
                    "_Loop_" + str(inter_exter) + "_" + str(item2) +
                    "_command.txt", 'w+')
                file_open.write(failure_command)
                file_open.write('\n')
                file_open.close()

        def netmiko_Set_config(self, item1, inter_exter):
            if inter_exter == 'internal':
                net_connect = Netmiko(**self.deviceB)
                print('***** log in to device {}'.format(self.deviceB['host']))
            else:
                net_connect = Netmiko(**self.deviceA)
                print('***** log in to device {}'.format(self.deviceA['host']))
            f = open(
                self.file_path + "/Loopback_Commands/" + str(item1) +
                "_Loop_" + str(inter_exter) + "_Set_command.txt", 'r')
            f2 = f.readlines()
            clear_QOS_ouput(self, self.interface_name_list, self.device_list)
            output = net_connect.send_config_set(f2)
            net_connect.commit()
            net_connect.exit_config_mode()
            print(output)
            command = "show ethernet loopback active | include ID"
            show_output = net_connect.send_command(command)
            if item1 == "L2":
                show_output_list = show_output.split(" ")
                loop_id_to_render = show_output_list[-1]
                if loop_id_to_render != "1":
                    print("**** doing rendering one more time")
                    Command_Creation(self, location, item1, item2, inter_exter,
                                     loop_id_to_render, **self.interface_name)
            net_connect.disconnect()

        def netmiko_Release_config(self, item1, inter_exter):
            if inter_exter == 'internal':
                net_connect = Netmiko(**self.deviceB)
                print('***** log in to device {}'.format(self.deviceB['host']))
            else:
                net_connect = Netmiko(**self.deviceA)
                print('***** log in to device {}'.format(self.deviceA['host']))
            f = open(
                self.file_path + "/Loopback_Commands/" + str(item1) +
                "_Loop_" + str(inter_exter) + "_Release_command.txt", 'r')
            f2 = f.readlines()
            time.sleep(15)
            command_ouput(self, self.interface_name_list, self.device_list)
            output = net_connect.send_config_set(f2)
            net_connect.commit()
            net_connect.exit_config_mode()
            print(output)
            net_connect.disconnect()

        def spirent_traffic(self, steam_name, item1, inter_exter):
            stream = steam_name['stream_id']
            traffic_ctrl_ret = sth.traffic_control(stream_handle=[stream],
                                                   action='run',
                                                   traffic_start_mode='sync',
                                                   duration='30')

            status = traffic_ctrl_ret['status']
            if (status == '0'):
                print("run sth.traffic_control failed")
                print(traffic_ctrl_ret)
            else:
                print("***** run sth.traffic started successfully")

            traffic_results_ret = sth.traffic_stats(
                port_handle=[port_handle[0], port_handle[1]], mode='all')

            status = traffic_results_ret['status']
            if (status == '0'):
                print("run sth.traffic_stats failed")
                print(traffic_results_ret)
            else:
                print(
                    "***** run sth.traffic_stats successfully, and results is:"
                )
                pprint(traffic_results_ret)
                # pprint(traffic_results_ret1)

            deviceA_tx = traffic_results_ret[
                port_handle[0]]['aggregate']['tx']['pkt_count']
            deviceA_rx = traffic_results_ret[
                port_handle[0]]['aggregate']['rx']['pkt_count']
            deviceB_tx = traffic_results_ret[
                port_handle[1]]['aggregate']['tx']['pkt_count']
            deviceB_rx = traffic_results_ret[
                port_handle[1]]['aggregate']['rx']['pkt_count']

            if deviceA_rx == deviceA_tx:
                print("***************** " + str(item1) + " " +
                      str(inter_exter) + "Test has Passed")
                print("**** No of Rx packets on deviceA are: " +
                      str(deviceA_rx))
                print("**** No of Tx packets on deviceA are: " +
                      str(deviceA_tx))
                test_result = 'Passed'
            elif deviceB_rx == deviceA_tx:
                print("***************** " + str(item1) + " " +
                      str(inter_exter) + "Test has failed")
                print("**** No of Rx packets on deviceB are: " +
                      str(deviceB_rx))
                print("**** No of Tx packets on deviceA are: " +
                      str(deviceA_tx))
                print("**** No of Rx packets on deviceA are: " +
                      str(deviceA_rx))
                print("**** No of Tx packets on deviceB are: " +
                      str(deviceB_tx))
                test_result = 'Fail'  # It was mentioned as 'Failed'
            else:
                print("something wrong")
                test_result = 'something wrong'

            dict_name = '{}_{}_result'.format(item1, inter_exter)
            dict_local = {}
            dict_local['deviceA_tx'] = deviceA_tx
            dict_local['deviceA_rx'] = deviceA_rx
            dict_local['deviceB_tx'] = deviceB_tx
            dict_local['deviceB_rx'] = deviceB_rx
            dict_local['result'] = test_result
            dict_local['Traffic_rate'] = self.traffic_rate
            self.dict_result[dict_name] = dict_local

            traffic_ctrl_ret = sth.traffic_control(
                port_handle=[port_handle[0], port_handle[1]],
                action='clear_stats')

        if self.serv_type == "PP":
            pass
        elif self.serv_type == "PPLLF":
            self.sub_interface = None
        else:
            pass

        for k, v in self.interface_name.items():
            self.interface_name_list.append(v)

        ##############################################################
        # config the parameters for the logging
        ##############################################################

        test_sta = sth.test_config(
            log='0',
            logfile='Loopback_logfile',
            vendorlogfile='Loopback_stcExport',
            vendorlog='0',
            hltlog='1',
            hltlogfile='Loopback_hltExport',
            hlt2stcmappingfile='Loopback_hlt2StcMapping',
            hlt2stcmapping='1',
            log_level='0')

        status = test_sta['status']
        if (status == '0'):
            print("run sth.test_config failed")
            print(test_sta)
        else:
            print("***** run sth.test_config successfully")

        ##############################################################
        # config the parameters for optimization and parsing
        ##############################################################

        test_ctrl_sta = sth.test_control(action='enable')

        status = test_ctrl_sta['status']
        if (status == '0'):
            print("run sth.test_control failed")
            print(test_ctrl_sta)
        else:
            print("***** run sth.test_control successfully")

        ##############################################################
        # connect to chassis and reserve port list
        ##############################################################

        i = 0
        device = "10.91.113.124"
        port_handle = []
        intStatus = sth.connect(device=device,
                                port_list=self.port_list,
                                break_locks=1,
                                offline=0)

        status = intStatus['status']

        if (status == '1'):
            for port in self.port_list:
                port_handle.append(intStatus['port_handle'][device][port])
                print("\n reserved ports", port, ":", port_handle[i])
                i += 1
        else:
            print("\nFailed to retrieve port handle!\n")
            print(port_handle)

        ##############################################################
        # interface config
        ##############################################################
        if self.port_speed == "ether1000":
            for i in range(2):
                interface = 'int_ret_{}'.format(i)
                interface = sth.interface_config(
                    mode='config',
                    port_handle=port_handle[i],
                    create_host='false',
                    intf_mode='ethernet',
                    phy_mode=self.copper_fiber,
                    scheduling_mode='RATE_BASED',
                    port_loadunit='PERCENT_LINE_RATE',
                    port_load='10',
                    enable_ping_response='0',
                    control_plane_mtu='1500',
                    flow_control='false',
                    speed=self.port_speed,
                    data_path_mode='normal',
                    autonegotiation='1')

                status = interface['status']
                if (status == '0'):
                    print("run sth.interface_config failed")
                    print(interface)
                else:
                    print(
                        '***** run sth.interface_config deviceA_{} successfully with 1G speed'
                        .format(i))
        else:
            for i in range(2):
                interface = 'int_ret_{}'.format(i)
                interface = sth.interface_config(
                    mode='config',
                    port_handle=port_handle[i],
                    create_host='false',
                    intf_mode='ethernet',
                    phy_mode=self.copper_fiber,
                    scheduling_mode='RATE_BASED',
                    port_loadunit='PERCENT_LINE_RATE',
                    port_load='10',
                    enable_ping_response='0',
                    control_plane_mtu='1500',
                    flow_control='false',
                    speed=self.port_speed,
                    data_path_mode='normal',
                    autonegotiation='1',
                    duplex='full')

                status = interface['status']
                if (status == '0'):
                    print("run sth.interface_config failed")
                    print(interface)
                else:
                    print(
                        '***** run sth.interface_config deviceA_{} successfully with 10G speed'
                        .format(i))

        if self.serv_type == "FF" or self.serv_type == "PP":
            streamblock_retFF = sth.traffic_config(
                mode='create',
                port_handle=port_handle[0],
                l2_encap='ethernet_ii_vlan',
                mac_src=self.mac['SMAC'],
                mac_dst=self.mac['DMAC'],
                vlan_cfi='0',
                vlan_tpid='33024',
                vlan_id=self.F_vlan,
                vlan_user_priority='2',
                enable_control_plane='0',
                l3_length='9078',
                name='StreamBlock_F-F',
                fill_type='constant',
                fcs_error='0',
                fill_value='0',
                frame_size='9100',
                traffic_state='1',
                high_speed_result_analysis='1',
                length_mode='fixed',
                tx_port_sending_traffic_to_self_en='false',
                disable_signature='0',
                enable_stream_only_gen='1',
                pkts_per_burst='1',
                inter_stream_gap_unit='bytes',
                burst_loop_count='30',
                transmit_mode='continuous',
                inter_stream_gap='12',
                rate_mbps=self.traffic_rate)

            status = streamblock_retFF['status']
            if (status == '0'):
                print("run sth.traffic_config failed")
                print(streamblock_retFF)
            else:
                print(
                    "***** run sth.traffic_config StreamBlock_F-F on DeviceA successfully"
                )
        elif self.serv_type == "XX":
            streamblock_retXX = sth.traffic_config(
                mode='create',
                port_handle=port_handle[0],
                l2_encap='ethernet_ii_vlan',
                mac_src=self.mac['SMAC'],
                mac_dst=self.mac['DMAC'],
                vlan_outer_cfi='0',
                vlan_outer_tpid='33024',
                vlan_outer_user_priority='2',
                vlan_id_outer=self.deviceA_X_VLAN,
                vlan_cfi='0',
                vlan_tpid='33024',
                vlan_id=self.deviceB_X_VLAN,
                vlan_user_priority='2',
                enable_control_plane='0',
                l3_length='9074',
                name='StreamBlock_X-X',
                fill_type='constant',
                fcs_error='0',
                fill_value='0',
                frame_size='9100',
                traffic_state='1',
                high_speed_result_analysis='1',
                length_mode='fixed',
                tx_port_sending_traffic_to_self_en='false',
                disable_signature='0',
                enable_stream_only_gen='1',
                pkts_per_burst='1',
                inter_stream_gap_unit='bytes',
                burst_loop_count='30',
                transmit_mode='continuous',
                inter_stream_gap='12',
                rate_mbps=self.traffic_rate)

            status = streamblock_retXX['status']
            if (status == '0'):
                print("run sth.traffic_config failed")
                print(streamblock_retXX)
            else:
                print(
                    "***** run sth.traffic_config StreamBlock_X-X on DeviceA successfully"
                )

        elif self.serv_type == "YF":
            streamblock_retYF = sth.traffic_config(
                mode='create',
                port_handle=port_handle[0],
                l2_encap='ethernet_ii_vlan',
                mac_src=self.mac['SMAC'],
                mac_dst=self.mac['DMAC'],
                vlan_outer_cfi='0',
                vlan_outer_tpid='34984',
                vlan_outer_user_priority='2',
                vlan_id_outer=self.deviceA_Y_VLAN[0],
                vlan_cfi='0',
                vlan_tpid='33024',
                vlan_id=self.deviceA_Y_VLAN[1],
                vlan_user_priority='2',
                enable_control_plane='0',
                l3_length='9074',
                name='StreamBlock_Y-F',
                fill_type='constant',
                fcs_error='0',
                fill_value='0',
                frame_size='9100',
                traffic_state='1',
                high_speed_result_analysis='1',
                length_mode='fixed',
                tx_port_sending_traffic_to_self_en='false',
                disable_signature='0',
                enable_stream_only_gen='1',
                pkts_per_burst='1',
                inter_stream_gap_unit='bytes',
                burst_loop_count='30',
                transmit_mode='continuous',
                inter_stream_gap='12',
                rate_mbps=self.traffic_rate)

            status = streamblock_retYF['status']
            if (status == '0'):
                print("run sth.traffic_config failed")
                print(streamblock_retYF)
            else:
                print(
                    "***** run sth.traffic_config StreamBlock_Y-F on deviceA successfully"
                )
        else:
            print("No streams are created")

        ##############################################################
        # start devices
        ##############################################################

        for item1 in self.List1:
            if item1 == "L2":
                inter_exter_list = ['internal', 'external']
            else:
                inter_exter_list = ['internal', 'external', 'line']
            for inter_exter in inter_exter_list:
                for item2 in self.List2:
                    location = self.file_path + "/Loopback_Template/" + "tem_" + item1 + "_Loop_" + item2 + "_command.j2"
                    Command_Creation(self, location, item1, item2, inter_exter,
                                     self.loop_id, **self.interface_name)
                    print("**** Templateing Done for " + str(item1) + " " +
                          str(inter_exter) + " & " + str(item2) + " command")

        for item1 in self.List1:
            if item1 == "L2":
                inter_exter_list = ['internal', 'external']
            else:
                inter_exter_list = ['internal', 'external', 'line']

            for inter_exter in inter_exter_list:
                print("**** perform " + str(item1) + " " + str(inter_exter) +
                      " Loop ")
                netmiko_Set_config(self, item1, inter_exter)
                if self.serv_type == "FF" or self.serv_type == "PP":
                    spirent_traffic(self, streamblock_retFF, item1,
                                    inter_exter)
                elif self.serv_type == "XX":
                    spirent_traffic(self, streamblock_retXX, item1,
                                    inter_exter)
                elif self.serv_type == "YF":
                    spirent_traffic(self, streamblock_retYF, item1,
                                    inter_exter)
                else:
                    print("something wrong, streams can not be started")
                print("**** Release " + str(item1) + " " + str(inter_exter) +
                      " Loop ")
                netmiko_Release_config(self, item1, inter_exter)
                time.sleep(30)

        ##############################################################
        # clean up the session, release the ports reserved and cleanup the dbfile
        ##############################################################

        cleanup_sta = sth.cleanup_session(
            port_handle=[port_handle[0], port_handle[1]], clean_dbfile='1')

        status = cleanup_sta['status']
        if (status == '0'):
            print("run sth.cleanup_session failed")
            print(cleanup_sta)
        else:
            print("***** run sth.cleanup_session successfully")

        print("**************Finish***************")

        print(json.dumps(self.dict_result, indent=4))
        Final_Result = []
        for result in self.dict_result.values():
            Final_Result.append(result["result"])
        return (Final_Result)
Exemplo n.º 20
0
 def Stream_Config_Creation_Single_Tagged_VLAN_Mbps(self,
                                                    src_port_handle_index,
                                                    dest_port_handle_index,
                                                    **kwargs):
     if 'Stream_Name' in kwargs.keys():
         self.Stream_Name = kwargs['Stream_Name']
     else:
         self.Stream_Name = 'Test_StreamBlock'
     if 'Frame_Size' in kwargs.keys():
         self.Frame_Size = kwargs['Frame_Size']
     else:
         self.Frame_Size = 1500
     if 'MAC_Src' in kwargs.keys():
         self.mac_src = kwargs['MAC_Src']
     else:
         self.mac_src = '00:10:94:00:00:02'
     if 'MAC_Dest' in kwargs.keys():
         self.mac_dst = kwargs['MAC_Dest']
     else:
         self.mac_dst = '00:10:94:00:00:03'
     if 'Rate_Mbps' in kwargs.keys():
         self.Rate_Mbps = kwargs['Rate_Mbps']
     else:
         self.Rate_Mbps = 100
     if 'VLAN_EtherType' in kwargs.keys():
         self.vlan_tpid = str(int(kwargs['VLAN_EtherType'], 10))
     else:
         self.vlan_tpid = '33024'
     if 'VLAN_ID' in kwargs.keys():
         self.vlan_id = str(int(kwargs['VLAN_ID'], 10))
     else:
         self.vlan_id = '100'
     if 'VLAN_Priority' in kwargs.keys():
         self.vlan_user_priority = str(
             int(kwargs['Inner_VLAN_Priority'], 10))
     else:
         self.vlan_user_priority = '2'
     self.l2_encap = 'ethernet_ii'
     print("Inside Init, Remove this print after testing")
     streamblock_ret = sth.traffic_config(
         mode='create',
         port_handle=self.port_handle[src_port_handle_index],
         l2_encap=self.l2_encap,
         vlan_tpid=self.vlan_tpid,
         vlan_id=self.vlan_id,
         vlan_user_priority=self.vlan_user_priority,
         l3_protocol='ipv4',
         ip_id='0',
         ip_src_addr='192.85.1.2',
         ip_dst_addr='192.0.0.1',
         ip_ttl='255',
         ip_hdr_length='5',
         ip_protocol='253',
         ip_fragment_offset='0',
         ip_mbz='0',
         ip_precedence='0',
         ip_tos_field='0',
         mac_src=self.mac_src,
         mac_dst=self.mac_dst,
         enable_control_plane='0',
         l3_length='4978',
         name=self.Stream_Name,
         fill_type='constant',
         fcs_error='0',
         fill_value='0',
         frame_size=self.Frame_Size,
         traffic_state='1',
         high_speed_result_analysis='1',
         length_mode='fixed',
         dest_port_list=self.port_handle[dest_port_handle_index],
         tx_port_sending_traffic_to_self_en='false',
         disable_signature='0',
         enable_stream_only_gen='1',
         pkts_per_burst='1',
         inter_stream_gap_unit='bytes',
         burst_loop_count='6000',
         transmit_mode='multi_burst',
         inter_stream_gap='12',
         rate_mbps=self.Rate_Mbps,
         mac_discovery_gw='192.85.1.1',
         enable_stream='false')
     return (streamblock_ret)
Exemplo n.º 21
0
streamblock_retYF = sth.traffic_config(
    mode='create',
    port_handle=port_handle[0],
    l2_encap='ethernet_ii_vlan',
    mac_src=mac['SMAC'],
    mac_dst=mac['DMAC'],
    vlan_outer_cfi='0',
    vlan_outer_tpid='34984',
    vlan_outer_user_priority='2',
    vlan_id_outer=deviceA_Y_VLAN[0],
    vlan_cfi='0',
    vlan_tpid='33024',
    vlan_id=deviceA_Y_VLAN[1],
    vlan_user_priority='2',
    enable_control_plane='0',
    l3_length='9074',
    name='StreamBlock_Y-F',
    fill_type='constant',
    fcs_error='0',
    fill_value='0',
    frame_size='9100',
    traffic_state='1',
    high_speed_result_analysis='1',
    length_mode='fixed',
    tx_port_sending_traffic_to_self_en='false',
    disable_signature='0',
    enable_stream_only_gen='1',
    pkts_per_burst='1',
    inter_stream_gap_unit='bytes',
    burst_loop_count='30',
    transmit_mode='continuous',
    inter_stream_gap='12',
    rate_mbps=traffic_rate)
Exemplo n.º 22
0
streamblock_ret1 = sth.traffic_config(
    mode='create',
    port_handle=port_handle[1],
    emulation_src_handle=src_hdl,
    emulation_dst_handle=lsp1,
    tunnel_bottom_label=src_hdl,
    l3_protocol='ipv4',
    ip_id='0',
    ip_dst_addr='192.0.0.1',
    ip_ttl='255',
    ip_hdr_length='5',
    ip_protocol='253',
    ip_fragment_offset='0',
    ip_mbz='0',
    ip_precedence='6',
    ip_tos_field='0',
    enable_control_plane='0',
    l3_length='128',
    name='StreamBlock_2-2',
    fill_type='constant',
    fcs_error='0',
    fill_value='0',
    frame_size='128',
    traffic_state='1',
    high_speed_result_analysis='1',
    length_mode='fixed',
    tx_port_sending_traffic_to_self_en='false',
    disable_signature='0',
    enable_stream_only_gen='1',
    pkts_per_burst='1',
    inter_stream_gap_unit='bytes',
    burst_loop_count='1',
    transmit_mode='multi_burst',
    inter_stream_gap='12',
    rate_percent='10',
    mac_discovery_gw='10.1.1.1')
Exemplo n.º 23
0
    print("***** Bound the IGMP and the Multicast Group failed")
    print(membershipStatus)
else:
    print("***** Bound the IGMP and the Multicast Group successfully")
    print(membershipStatus)

##############################################################
# Step 6. Configure downstream traffic : port2 -> port1
##############################################################
print "Configure downstream traffic : port2 -> port1"
streamblock = sth.traffic_config(mode='create',
                                 port_handle=port_handle[1],
                                 rate_pps='1000',
                                 l2_encap='ethernet_ii',
                                 l3_protocol='ipv4',
                                 l3_length='108',
                                 transmit_mode='continuous',
                                 length_mode='fixed',
                                 ip_src_addr='172.17.0.2',
                                 ip_dst_addr='225.0.0.25',
                                 mac_src='00:10:94:00:00:11',
                                 mac_dst='01.00.5E.00.00.11')

status = streamblock['status']
if (status == '0'):
    print("run sth.traffic_config failed")
    print(streamblock)
else:
    print("***** run sth.traffic_config successfully")
    print(streamblock)

##############################################################