def TurnOnCapture(portHandleList, port): captureHndList = [] for portHnd in portHandleList.split(): print "Turn on capture on %s" % portHnd capture = sth.invoke('stc::get %s -children-capture' % portHnd) sth.invoke('stc::perform CaptureStart -CaptureProxyId ' + capture) captureHndList.append(capture) return captureHndList
def TurnOffCapture (portHandleList,port) : fileNameList = [] for portHnd in portHandleList.split() : print "Turn off capture on %s" % portHnd captureHnd = sth.invoke('stc::get %s -children-capture' % portHnd) sth.invoke('stc::perform CaptureStop -CaptureProxyId ' + captureHnd) name = port print "Saving capture to : " + name sth.invoke ('stc::perform SaveSelectedCaptureData -CaptureProxyId %s -filename %s.pcap' % (captureHnd,name)) fileNameList.append('%s.pcap' % name) print "Save file Name list = %s" % fileNameList return fileNameList
def printProperties(lbl, handle): if handle.isspace(): print " " else: print "%s Properties" % lbl print "================" handle_list = sth.invoke('stc::get %s' % handle) handle_list1 = handle_list.split(" -") for i in handle_list1: print i
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') ############################################################## # step8: connect pppoe server and pppoe client ############################################################## print 'Connect PPPoE server' ps_control = sth.pppox_server_control(action='connect', port_handle=port_handle[0]) status = ps_control['status'] if status == '0': print "run sth.pppox_server_control failed" print ps_control else:
test_duration_mode = 'seconds', test_duration = '10', load_unit = 'percent_line_rate', load_type = 'step', load_start = '20', load_step = '10', load_end = '30') status = latency_config['status'] if (status == '0') : print("run sth.test_rfc2544_config failed") print(latency_config) else: print("***** run sth.test_rfc2544_config successfully") sth.invoke ('stc::perform saveasxml -config system1 -filename rfc2544_latency.xml') latency_control = sth.test_rfc2544_control ( action = 'run', wait = '1'); status = latency_control['status'] if (status == '0') : print("run sth.test_rfc2544_control failed") print(latency_control) else: print("***** run sth.test_rfc2544_control successfully") latency_results = sth.test_rfc2544_info ( test_type = 'latency', clear_result = '0');
print("***** run sth.test_rfc3918_info successfully, and results is:") print(results_ret1) ctrl_ret_stop = sth.test_rfc3918_control ( action = 'stop', cleanup = '1'); status = ctrl_ret_stop['status'] if (status == '0') : print("run sth.test_rfc3918_control failed") print(ctrl_ret_stop) else: print("***** run sth.test_rfc3918_control successfully") #config part is finished sth.invoke ('stc::perform saveasxml -filename rfc3918_all.xml') ############################################################## # Step 13. Release resources ############################################################## print "Release resources" 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
length_mode='fixed', ip_src_addr='11.55.0.2', ip_dst_addr='10.21.0.2', ip_dst_count='4', ip_src_count='2', mac_discovery_gw='11.55.0.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 sth.invoke('stc::perform saveasxml -filename interfaceconfig_subinterface.xml') ############################################################## # Step4. Start capture ############################################################## print "Start capture" packet_control = sth.packet_control(port_handle='all', action='start') ############################################################## # Step5. Start traffic ############################################################## print "Start traffic on port1 and port2" traffic_ctrl_ret = sth.traffic_control(port_handle='all', action='run') status = traffic_ctrl_ret['status'] if (status == '0'):
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') ############################################################## # step5: connect pppoe client ############################################################## pc_control = sth.pppox_control(action='connect', handle=deviceHdlClient) status = pc_control['status'] if status == '0': print "run sth.pppox_control failed" print pc_control else: print '***** run sth.pppox_control successfully' time.sleep(10)
handle=dhcp_handle, mac_addr='00.00.10.95.11.15', mac_addr_step='00:00:00:00:00:01', num_sessions='20', local_ipv6_addr='2009::2', gateway_ipv6_addr='2005::1') status = device_ret1['status'] if (status == '0'): print "run sth.emulation_dhcp_group_config failed" print device_ret1 else: print "***** run sth.emulation_dhcp_group_config successfully" #config part is finished sth.invoke('stc::perform saveasxml -filename dhcpv6_basic.xml') ######################################### ## Step5: Start Dhcp Server ######################################### ctrl_ret1 = sth.emulation_dhcp_server_control(port_handle=port_handle[1], action='connect', ip_version='6') status = ctrl_ret1['status'] if (status == '0'): print "run sth.emulation_dhcp_server_control failed" print ctrl_ret1 else: print "***** run sth.emulation_dhcp_server_control successfully"
mac_addr='00:10:94:01:00:45', mac_addr_step='00.00.00.00.00.01', vlan_id='200', vlan_id_count='2', vlan_id_outer='300', vlan_id_outer_count='5') status = device_pc['status'] if status == '0': print "run sth.pppox_config failed" print device_pc else: print '***** run sth.pppox_config successfully' #config part is finished sth.invoke('stc::perform saveasxml -filename pppox_server.xml') ######################################## # Step5: Connect PPPoE server & client ######################################## print 'Connect PPPoE server' ps_control = sth.pppox_server_control(action='connect', port_handle=port_handle[0]) status = ps_control['status'] if status == '0': print "run sth.pppox_server_control failed" print ps_control else:
ls_prefix_desc_ip_prefix_type='ipv4_prefix', ls_prefix_desc_ipv4_prefix='1.0.0.0', ls_prefix_desc_ipv4_prefix_length='24', ls_prefix_desc_ipv4_prefix_step='1', ls_prefix_desc_ospf_route_type='intra_area') status = ipv4_prefix_hnd['status'] if status == 0: print "run sth.emulation_bgp_route_ipv4_prefix_hnd failed" print ipv4_prefix_hnd else: print "run sth.emulation_bgp_route_ipv4_prefix_hnd successfully" print ipv4_prefix_hnd #config part is finished sth.invoke('stc::perform saveasxml -filename bgp_ls_py.xml') ############################################################## # Step 3.start BGP ############################################################## device_list = [device_ret0['handle'], device_ret1['handle']] ctrl_ret1 = sth.emulation_bgp_control(handle=device_list, mode='start') status = ctrl_ret1['status'] if (status == '0'): print("run sth.emulation_bgp_control failed") print(ctrl_ret1) else: print("***** run sth.emulation_bgp_control successfully")
transmit_mode='continuous', pkts_per_burst='3', rate_pps='5') status = device_ret1['status'] if (status == '0'): print("run sth.emulation_oam_config_msg failed") print(device_ret1) else: print("***** run sth.emulation_oam_config_msg successfully") print device_ret1 msgHandleList2 = device_ret1['handle'] #config part is finished sth.invoke('stc::perform saveasxml -filename eoam_msg_802.1ag_vlan.xml') ######################################## # Step3. Start EOAM ######################################## print "Start EOAM on port1" ctrl_ret1 = sth.emulation_oam_control(handle=msgHandleList1, action='start') status = ctrl_ret1['status'] if (status == '0'): print("run sth.emulation_oam_control failed") print(ctrl_ret1) else: print("***** run sth.emulation_oam_control successfully") print "Wait 10 seconds"
mac_discovery_gw='42.1.0.1', mac_dst_mode='increment', mac_src='00.21.00.00.00.22', mac_dst='01:00:5E:00:00:06', ip_src_addr='13.14.0.10', ip_dst_addr='225.18.0.10') 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 sth.invoke('stc::perform saveasxml -filename pim_highscale.xml') ############################################################## # Step 6. Start traffic ############################################################## traffic_ctrl_ret = sth.traffic_control( port_handle=[port_handle[0], port_handle[1]], action='run') 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")
ip_dst_addr='10.0.0.1', l4_protocol='tcp', tcp_src_port='1000', tcp_dst_port='2000') status = streamblock_ret2['status'] if (status == '0'): print("run sth.traffic_config failed") print(streamblock_ret2) else: print("***** run sth.traffic_config successfully") dscpstreamHandle = streamblock_ret2['stream_id'] #config part is finished sth.invoke('stc::perform saveasxml -filename traffic_qos.xml') ######################################## # Step6. Start taffic and then get real time results based on DSCP value ######################################## print "Start traffic generator for filtering DSCP value..." traffic_ctrl_ret = sth.traffic_control(port_handle=[port_handle[0]], action='run', get='dscp') status = traffic_ctrl_ret['status'] if (status == '0'): print("run sth.traffic_control failed") print(traffic_ctrl_ret) else:
remote_username_suffix_step='3', call_using_aor='1', remote_host='150.1.0.5', remote_host_step='1') status = device_ret1['status'] if (status == '0'): print("run sth.emulation_sip_config failed") print(device_ret1) else: print("***** run sth.emulation_sip_config successfully") sipCaller = device_ret1['handle'] #config part is finished sth.invoke('stc::perform saveasxml -filename sip_proxyserver.xml') #Turn on capture TurnOnCapture(port_handle[1], "port2") ######################################## # Step4. Register caller and callee ######################################## handleList = [sipCallee, sipCaller] for sipHandle in handleList: ctrl_ret1 = sth.emulation_sip_control(handle=sipHandle, action='register') status = ctrl_ret1['status'] if (status == '0'):
route_config9 = sth.emulation_ospf_topology_route_config(mode='create', type='router', handle=router4, link_enable='1', router_id='20.0.0.1') status = route_config8['status'] if (status == '0'): print("run sth.emulation_ospf_topology_route_config failed") print(route_config8) else: print("***** run sth.emulation_ospf_topology_route_config successfully") #config part is finished sth.invoke('stc::perform saveasxml -filename ospfv2_topology_enhance.xml') ############################################################## # Step 3. Start OSPF ############################################################## for i in range(0, 4): devices1 = handle_list1.split(" ")[i] ctrl_ret1 = sth.emulation_ospf_control(handle=devices1, mode='start') status = ctrl_ret1['status'] if (status == '0'): print("run sth.emulation_ospf_control failed") print(ctrl_ret1) else: print("***** run sth.emulation_ospf_control successfully")
opt_list = ['1','6','15','33','44'], host_name = 'client_@p-@b-@s', ipv4_gateway_address = '192.85.2.1', mac_addr = '00:10:94:00:00:01', mac_addr_step = '00:00:00:00:00:01', num_sessions = '1'); status = device_ret1['status'] if (status == '0') : print "run sth.emulation_dhcp_group_config failed" print device_ret1 else: print "***** run sth.emulation_dhcp_group_config successfully" #config part is finished sth.invoke ('stc::perform saveasxml -filename results.xml') #Set data packet capture and start capture packet_config_buffers = sth.packet_config_buffers ( port_handle = 'all', action = 'wrap'); packet_control = sth.packet_control ( port_handle = 'all', action = 'start'); ############################################################## # Step 3: Start DHCP server and Bind DHCP device on DHCP client ##############################################################
mac_addr = '00.00.10.95.11.15', mac_addr_step = '00:00:00:00:00:01', num_sessions = '20'); status = device_ret1['status'] if (status == '0') : print "run sth.emulation_dhcp_group_config failed" print device_ret1 else: print "***** run sth.emulation_dhcp_group_config successfully" #config part is finished sth.invoke ('stc::perform saveasxml -filename dhcp_server_relay_agent.xml') ######################################## # Step6: Start Dhcp Server ######################################## ctrl_ret1 = sth.emulation_dhcp_server_control ( port_handle = port_handle[1], action = 'connect', ip_version = '4'); status = ctrl_ret1['status'] if (status == '0') : print "run sth.emulation_dhcp_server_control failed"
registration_server_enable='0', call_using_aor='1', remote_host='192.1.0.15', remote_host_step='1') status = device_ret1['status'] if (status == '0'): print("run sth.emulation_sip_config failed") print(device_ret1) else: print("***** run sth.emulation_sip_config successfully") sipCaller = device_ret1['handle'] #config part is finished sth.invoke('stc::perform saveasxml -filename sip_p2p.xml') #turn on capture TurnOnCapture(port_handle[1], "port2") handleList = [sipCallee, sipCaller] ######################################## # Step4. Establish a call between callers and callees(no registering in P2P scenario) ######################################## establish = sth.emulation_sip_control(action='establish', handle=sipCaller) status = establish['status'] if (status == '0'): print("run sth.emulation_sip_control failed")
udp_src_port = '1701', lcp_proxy_mode = 'none', secret = 'spirent', hostname = 'server.spirent.com', rws = '4') status = device_ret1['status'] if status == '0' : print "run sth.l2tp_config_lns failed" print device_ret1 else: print "***** run sth.l2tp_config_lns successfully" #config part is finished sth.invoke ('stc::perform saveasxml -filename pppol2tp.xml') ############################################################## #Step4. Start LAC-LNS Connect and Pppoe ############################################################## device1 = device_ret1['handle'] ctrl_ret1 = sth.l2tp_control ( handle = device1, action = 'connect'); status = ctrl_ret1['status'] if status == '0' : print "run sth.l2tp_control_lns failed" print ctrl_ret1 else:
# Step 7. Join IGMP hosts to multicast group ############################################################## print " IGMP Host Join the Multicast Group" joinStatus = sth.emulation_igmp_control(handle=igmpHostHandle, mode='join') status = joinStatus['status'] if (status == '0'): print("Started(Join) IGMP Host failed") print(joinStatus) else: print("***** Started(Join) IGMP Host successfully") time.sleep(10) #config part is finished sth.invoke('stc::perform saveasxml -filename igmp_querier.xml') ############################################################## # Step 8. Get IGMP hosts Stats ############################################################## results_hosts = sth.emulation_igmp_info(handle=igmpHostHandle, mode='stats') status = results_hosts['status'] if (status == '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)
############################################################## print "Bound IGMP to multicast group" membershipStatus = sth.emulation_igmp_group_config(session_handle=igmpSession, mode='create', group_pool_handle=igmpGroup) status = membershipStatus['status'] 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) #config part is finished sth.invoke('stc::perform saveasxml -filename igmpopppoe.xml') ############################################################## # Step 7. Connect PPPoE client and check status ############################################################## print "Connect PPPoE client" pc_control = sth.pppox_control(action='connect', handle=pppox_handles) status = pc_control['status'] if status == '0': print "run sth.pppox_control failed" print pc_control else: print '***** run sth.pppox_control successfully' time.sleep(60)
else: print("***** run sth.test_rfc3918_control successfully") print "+++++ Start to get results of mixed class throughput test : " results_ret1 = sth.test_rfc3918_info(test_type='mixed_tput', clear_result='0') status = results_ret1['status'] if (status == '0'): print("run sth.test_rfc3918_info failed") print(results_ret1) else: print("***** run sth.test_rfc3918_info successfully, and results is:") print(results_ret1) #config part is finished sth.invoke('stc::perform saveasxml -filename rfc3918_mixed_tput.xml') ############################################################## # Step 8. Release resources ############################################################## print "Release resources" 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"
port_handle=port_handle[1], length_mode='fixed', l3_length='256', emulation_src_handle=ceProvideSide, emulation_dst_handle=ceCustomSide, rate_pps='10') status = streamblock_ret1['status'] if (status == '0'): print("Failed to create traffic") print(streamblock_ret1) else: print("***** Create traffic successfully") #config part is finished sth.invoke( 'stc::perform saveasxml -filename mpls_l3vpn_over_gre_multipleCE.xml') ############################################################## # Step18.Start catpure and start traffic ############################################################## print "Start capture" for i in range(0, len(port_list)): TurnOnCapture(port_handle[i], "port%s" % i) print "Start traffic on port1 and port2" traffic_ctrl_ret = sth.traffic_control(port_handle='all', action='run') status = traffic_ctrl_ret['status'] if (status == '0'): print("run sth.traffic_control failed") print(traffic_ctrl_ret)
intf_mode = 'ethernet', speed = speed, scheduling_mode = 'PORT_BASED', port_load = '100', port_loadunit = 'PERCENT_LINE_RATE') status = returnedString['status'] if (status == '0') : print("run sth.interface_config failed") print returnedString else: print("***** run sth.interface_config successfully") print returnedString #config part is finished sth.invoke ('stc::perform saveasxml -filename interfaceconfig_port_load.xml') ############################################################## #Step3: Check interface stats ############################################################## print "Check interface stats of port1" returnedString = sth.interface_stats ( port_handle = port_handle[0]) status = returnedString['status'] if (status == '0') : print("run sth.interface_config failed") print returnedString else: print("***** run sth.interface_config successfully")
update_interval='30', routes_per_msg='2000', ipv4_unicast_nlri='1', active_connect_enable='1', bfd_registration='1') status = device_ret0['status'] if (status == '0'): print("run sth.emulation_bgp_config failed") print(device_ret0) else: print("***** run sth.emulation_bgp_config successfully") bgpHandle = device_ret0['handles'] #config part is finished sth.invoke('stc::perform saveasxml -filename BGP_BFD.xml') ############################################################## # Step 3.start BGP router ############################################################## ctrl_ret1 = sth.emulation_bgp_control(handle=bgpHandle, mode='start') status = ctrl_ret1['status'] if (status == '0'): print("run sth.emulation_bgp_control failed") print(ctrl_ret1) else: print("***** run sth.emulation_bgp_control successfully") time.sleep(5) ##############################################################
duration_mode='seconds', padding_pattern='random', padding_len='140', scalability_mode='normal', duration='120', timeout='60') status = device_cfg_ret0_sessionhandle_1['status'] if (status == '0'): print("run sth.emulation_twamp_session_config failed") print(device_cfg_ret0_sessionhandle_1) else: print("***** run sth.emulation_twamp_session_config successfully") #config part is finished sth.invoke('stc::perform saveasxml -filename twamp.xml') ######################################## # Step7. Start twamp server and client ######################################## ctrl_ret0 = sth.emulation_twamp_control(handle=devicehandle2, mode='start') status = ctrl_ret0['status'] if (status == '0'): print("run sth.emulation_twamp_control failed") print(ctrl_ret0) else: print("***** run sth.emulation_twamp_control successfully") ctrl_ret1 = sth.emulation_twamp_control(handle=devicehandle1, mode='start')
f='0', dl_id=['priority', 'macaddr', 'nameid', 'fabricname', 'fka_adv_period'], priority='64', macaddr='00:10:94:00:00:01', nameid='10:00:10:94:00:00:00:01', fabricname='20:00:10:94:00:00:00:01') status = streamblock_fip_ret['status'] if (status == '0'): print("run sth.fip_traffic_config failed") print(streamblock_fip_ret) else: print("***** run sth.fip_traffic_config successfully") #config part is finished sth.invoke('stc::perform saveasxml -filename fcoe_traffic.xml') ######################################## # Step4. Run the Traffic ######################################## traffic_ctrl_ret = sth.traffic_control(port_handle='all', action='run') 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") ##############################################################
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') status = streamblock_ret1['status'] if (status == '0'): print("run sth.traffic_config failed") print(streamblock_ret1) else: print("***** run sth.traffic_config successfully") #config part is finished sth.invoke('stc::perform saveasxml -filename isis_sr.xml') ############################################################## # Step4. Start ISIS ############################################################## device_list0 = device_ret0['handle'].split()[0] ctrl_ret0 = sth.emulation_isis_control(handle=device_list0, mode='start') status = ctrl_ret0['status'] if (status == '0'): print("run sth.emulation_isis_control failed") print(ctrl_ret0) else: print("***** run sth.emulation_isis_control successfully")
port_handle=port_handle[1], length_mode='fixed', l3_length='256', emulation_src_handle=ceProvideSide, emulation_dst_handle=ceCustomSide, rate_pps='10') status = streamblock_ret1['status'] if (status == '0'): print("Failed to create traffic") print(streamblock_ret1) else: print("***** Create traffic successfully") #config part is finished sth.invoke('stc::perform saveasxml -filename mpls_martini_PWE_multipleCE.xml') ############################################################## # Step13.Start OSPF router ############################################################## print "Start OSPF router" ctrl_ret1 = sth.emulation_ospf_control(handle=ospfRouterPE, mode='start') status = ctrl_ret1['status'] if (status == '0'): print("Start OSPF router failed") print(ctrl_ret1) else: print("***** Start OSPF router successfully") print "Wait 20 seconds......"