#设置Chassis的基本參数, including the IP address. Number of ports, etc.
Set CHASSISADDR 10.132.238.190
Set Islot 1
Set Portlist {One-by-one}; #端口的排列顺序是port1, Port2
If {[Catch {
#载入STC API Lib
Cd.. /source
#载入HLAPI Lib
source./cstc.tcl
Setlogoption-debug Enable
# Start connecting the machine
Testdevice Chassis1 $chassisAddr
# Start with two ports reserved
For {set I 0} {$i <[llength $portList]} {incr i} {
Chassis1 createtestport-portlocation $islot/[lindex $portList $i]-portname port[expr $i +1]-porttype Ethernet
}
#port1 Createsubint-subintname Vlan1
# Configure VLAN Sub-interfaces
#vlan1 Configvlanif-vlantag 300
# Create Host Object
Port1 createhost-hostname host1-ipversion ipv4-ipv4addr 192.168.34.242-ipv4addrgateway 192.168.34.1 \
-ipv4addrprefixlen 24-flagping Enable
Port2 createhost-hostname host2-ipversion ipv4-ipv4addr 192.168.34.243-ipv4addrgateway 192.168.34.1 \
-ipv4addrprefixlen 24-flagping Enable
Saveconfigasxml "C:/host.xml"
#host1 ping-host 192.168.34.243-count 4-interval 2-result ret
Host1 ping-host host2-count 4-interval 2-result ret
Array Set Stats1 $ret
Parray Stats1
#host1 ping-host "192.168.34.244"-interval 1-result ret
#array Set Stats2 $ret
#parray stats2
After 3000
#清除測试过程中所作的全部配置和释放測试过程中占用的全部资源
Chassis1 Cleanuptest
} Err]} {
Puts "error occurred in script execution: $err"
#清除測试过程中所作的全部配置和释放測试过程中占用的全部资源
Chassis1 Cleanuptest
}
Tcl script calls the high-level API to implement its own proactive test example for instrumentation usage and host creation configuration