IxChariot测试必须至少包含一个 pair 对象:pair,hardware pair, VoIP pair, video pair, multicast group, 或者 video multicast group对象实例。当测试开始执行时,会自动创建时间记录(timing record)对象实例。
set test [chrTest new] #设置测试时间值 set runOpts [chrTest getRunOpts $test] chrRunOpts set $runOpts TEST_END FIXED_DURATION chrRunOpts set $runOpts TEST_DURATION 30
set e1 "localhost" set e2 "localhost" set script "c:/Program Files/Ixia/IxChariot/Scripts/Throughput.scr" set testFile "c:/Program Files/Ixia/IxChariot/tests/lbtest.tst" set timeout 60
# (2)创建测试对象 set test [chrTest new] set runOpts [chrTest getRunOpts $test] chrRunOpts set $runOpts TEST_END FIXED_DURATION chrRunOpts set $runOpts TEST_DURATION $timeout; #设置测试运行时间 # (3)创建pair对象 set pair [chrPair new]
# (4)设置pair属性 chrPair set $pair E1_ADDR $e1 E2_ADDR $e2 chrPair set $pair PROTOCOL TCP; #设置协议
# (8)等待测试结束 set $timeout [expr10 + $timeout] if {![chrTest isStopped $test $timeout]} { puts"ERROR: Test didn’t stop" chrTest delete $test force return }
# (9)打印
puts"===========" puts"Test setup:\n----------" puts"Number of pairs = [chrTest getPairCount $test]" puts"E1 address : [chrPair get $pair E1_ADDR]" puts"E2 address : [chrPair get $pair E2_ADDR]" # We didn’t set the protocol, but let’s show it anyway. puts"Protocol : [chrPair get $pair PROTOCOL]" # We’ll show both the script filename and # the application script name. puts"Script filename : [chrPair get $pair SCRIPT_FILENAME]" puts"Appl script name: [chrPair get $pair APPL_SCRIPT_NAME]"
# (10)读取测试结果: 吞吐量 puts"" puts"Test results:\n------------" puts"Number of timing records = \ [chrPair getTimingRecordCount $pair]"
set throughput [chrPairResults get $pair THROUGHPUT] set avg [format"%.3f" [lindex $throughput 0]] set min [format"%.3f" [lindex $throughput 1]] set max [format"%.3f" [lindex $throughput 2]] puts"Throughput:" puts" avg $avg min $min max $max"
# (11)保存测试结果 puts"Save the test..." chrTest save $test $testFile
# (2)创建测试对象 set test [chrTest new] set runOpts [chrTest getRunOpts $test] chrRunOpts set $runOpts TEST_END FIXED_DURATION chrRunOpts set $runOpts TEST_DURATION $timeout; #设置测试运行时间
# (2)创建voippair对象 set voippair1 [chrVoIPPair new]; # VoIP Pair创建
# (3)设置pair属性 chrPair set $voippair1 E1_ADDR $e1 E2_ADDR $e2 chrPair set $voippair1 QOS_NAME "VoIPQoS"; chrVoIPPair set $voippair1 CODEC "G711u";
# (6)等待测试结束 if {![chrTest isStopped $test $timeout]} { puts"ERROR: Test didn’t stop in 2 minutes!" chrTest delete $test force return }
# (7)读取测试结果 # MOS set mos [chrPairResults get $voippair1 MOS_ESTIMATE] set mos_avg [format"%.3f" [lindex $mos 0]] puts"MOS_avg $mos_avg"
# 时延 set delay [chrPairResults get $voippair1 END_TO_END_DELAY] set delay_avg [lindex $delay 0] set delay_avg [format"%.1f" $delay_avg] puts"END_TO_END_DELAY $delay_avg"
# 丢包率 set bytes_recv_e2 [chrCommonResults get $voippair1 BYTES_RECV_E2] # puts "" # puts "BYTES_RECV_E2: $bytes_recv_e2" set bytes_sent_e1 [chrCommonResults get $voippair1 BYTES_SENT_E1] # puts "BYTES_SENT_E1: $bytes_sent_e1" set bytes_lost_rate [format"%.4f" [expr ($bytes_sent_e1 - $bytes_recv_e2)/$bytes_sent_e1]] set bytes_lost_rate [expr $bytes_lost_rate*100] puts"BYTES_LOST_RATE $bytes_lost_rate"
# (11)保存测试结果 puts"Save the test..." chrTest save $test $testFile
# (12)清理 chrTest delete $test force
return
其它
执行tst文件
可以使用runtst工具来执行创建的tst文件:
1 2
$ cd C:\Program Files (x86)\Ixia\IxChariot $ runtst.exe -t20 C:\\Users\DELL\\Documents\\IxChariot\\TESTS\\demo.tst d:\\test\\demo.tst