一、203_TC_FrameRate-1.tcl
set chassisAddr 10.132.238.190
set islot 1set portList {9 10} ;#端口的排列顺序是port1, port2
set ipList {10.0.0.3 20.0.0.3} ;#ip列表与端口的排列顺序相对应
set macList {00-00-00-00-00-01 00-00-00-00-00-02}
set gwList {10.0.0.1 20.0.0.1}
set iFramelen 256
set streamLoad 100
if { [catch {
cd ../Source
#加载HLAPI Lib
source ./CSTC.tcl
SetLogOption -Debug Enable
# 开始连接机器
TestDevice chassis1 $chassisAddr
# 开始预留两个端口
for {set i 0} {$i <[llength $portList]} {incr i} {
chassis1 CreateTestPort -PortLocation $islot/[lindex $portList $i] -PortName port[expr $i+1] -PortType Ethernet
}
port1 CreateTraffic -TrafficName traffic1
traffic1 CreateProfile -Name profile1 -TrafficLoad 100 -TrafficLoadUnit fps
traffic1 CreateStream -StreamName stream1 -FrameLen 500 -ProfileName profile1 \
-L2 ethernet -L3 IPv4 -L4 Udp -IpSrcAddr 192.168.0.1 -IpDstAddr 192.168.5.7 -udpsrcport 2000 -udpdstport 3000
traffic1 ConfigStream -StreamName stream1 -L2 ethernet -L3 IPv4 -EthDst 00:00:10:E1:01:08 -EthSrc 00:00:11:E1:00:09
#创建统计和分析对象Statistics1,Statistics2,Analysis2
port1 CreateStaEngine -StaEngineName Statistics1 -StaType Statistics
port2 CreateStaEngine -StaEngineName Statistics2 -StaType Statistics
port2 CreateStaEngine -StaEngineName Analysis2 -StaType Analysis
#SaveConfigAsXML "c:/framerate.xml"
puts "配置捕获模式,将数据报capture到指定文件,可用于数据包的分析"
Analysis2 ConfigCaptureMode -CaptureMode allpkt -CaptureFile "c:/Framerate.pcap"
# 开始捕获报文
puts "开始捕获报文"
for {set i 0} {$i < 1} {incr i} {
traffic1 ConfigProfile -Name profile1 -TrafficLoad [expr 100 + $i * 100] -TrafficLoadUnit fps
Analysis2 StartCapture
puts "配置捕获模式,将数据报capture到指定文件"
Analysis2 ConfigCaptureMode -CaptureMode allpkt -CaptureFile "c:/Framerate[expr 100 + $i * 100].pcap"
port1 StartStaEngine
port2 StartStaEngine
port1 StartTraffic
# 等待5秒
after 5000
# 在tx端口停止流量发送
port1 StopTraffic
after 5000
array set stats1 [Statistics1 GetPortStats ]
parray stats1
array set stats2 [Statistics2 GetPortStats ]
parray stats2
# 基于流,获取stream1,stream2,stream3,stream4的统计值,存储在stats数组并打印出来
array set stats3 [Statistics1 GetStreamStats -StreamName stream1]
parray stats3
#array set stats4 [Statistics1 GetStreamStats -StreamName stream2]
#parray stats4
#array set stats5 [Statistics1 GetStreamStats -StreamName stream3]
#parray stats5
port1 StopStaEngine
port2 StopStaEngine
Analysis2 StopCapture
}
#清除测试过程中所作的所有配置和释放测试过程中占用的所有资源
chassis1 CleanupTest
} err ] } {
puts "脚本运行中出现错误: $err"
#清除测试过程中所作的所有配置和释放测试过程中占用的所有资源
chassis1 CleanupTest
}
二、203_TC_FrameRate-2.tcl
set chassisAddr 10.132.238.190
set islot 1
set portList {9 10} ;#端口的排列顺序是port1, port2
set ipList {10.0.0.3 20.0.0.3} ;#ip列表与端口的排列顺序相对应
set macList {00-00-00-00-00-01 00-00-00-00-00-02}
set gwList {10.0.0.1 20.0.0.1}
set iFramelen {64 128 256 512 1518}
set streamLoad 100
if { [catch {
cd ../Source
#加载HLAPI Lib
source ./CSTC.tcl
SetLogOption -Debug Enable
# 开始连接机器
TestDevice chassis1 $chassisAddr
# 开始预留两个端口
for {set i 0} {$i <[llength $portList]} {incr i} {
chassis1 CreateTestPort -PortLocation $islot/[lindex $portList $i] -PortName port[expr $i+1] -PortType Ethernet
}
port1 CreateTraffic -TrafficName traffic1
traffic1 CreateProfile -Name profile1 -TrafficLoad 100 -TrafficLoadUnit fps
traffic1 CreateStream -StreamName stream1 -FrameLen 500 -ProfileName profile1 \
-L2 ethernet -L3 IPv4 -L4 Udp -IpSrcAddr 192.168.0.1 -IpDstAddr 192.168.5.7 -udpsrcport 2000 -udpdstport 3000
traffic1 ConfigStream -StreamName stream1 -L2 ethernet -L3 IPv4 -EthDst 00:00:10:E1:01:08 -EthSrc 00:00:11:E1:00:09
#创建统计和分析对象Statistics1,Statistics2,Analysis2
port1 CreateStaEngine -StaEngineName TxStatistics1 -StaType Statistics
port2 CreateStaEngine -StaEngineName RxStatistics1 -StaType Statistics
port2 CreateStaEngine -StaEngineName Analysis2 -StaType Analysis
#SaveConfigAsXML "c:/framerate.xml"
puts "配置捕获模式,将数据报capture到指定文件,可用于数据包的分析"
Analysis2 ConfigCaptureMode -CaptureMode allpkt -CaptureFile "c:/Framerate.pcap"
# 开始捕获报文
puts "开始捕获报文"
for {set i 0} {$i < 3} {incr i} {
traffic1 ConfigProfile -Name profile1 -TrafficLoad [expr 100 + $i * 100] -TrafficLoadUnit fps
traffic1 ConfigStream -StreamName stream1 -FrameLen [ lindex $iFramelen $i ]
Analysis2 StartCapture
puts "配置捕获模式,将数据报capture到指定文件"
Analysis2 ConfigCaptureMode -CaptureMode allpkt -CaptureFile "c:/Framerate[expr 100 + $i * 100].pcap"
port1 StartStaEngine
port2 StartStaEngine
port1 StartTraffic
# 等待5秒
after 5000
# 在tx端口停止流量发送
port1 StopTraffic
after 5000
set TxStats1 [TxStatistics1 GetPortStats ]
puts "-------------------------------"
puts $TxStats1
puts "-------------------------------"
set txFrameIndex [lsearch $TxStats1 -TxSignature ]
set txFrameRateIndex [lsearch $TxStats1 -TxSignatureRate]
set txFrameNum [lindex $TxStats1 [expr $txFrameIndex + 1]]
set txFrameRate [lindex $TxStats1 [expr $txFrameRateIndex + 1]]
#array set RxStats1 [RxStatistics1 GetPortStats ]
set RxStats1 [RxStatistics1 GetPortStats ]
puts "-------------------------------"
puts $RxStats1
puts "-------------------------------"
set rxFrameIndex [lsearch $RxStats1 -RxSignature ]
set rxFrameRateIndex [lsearch $RxStats1 -RxSignatureRate ]
set rxFrameNum [lindex $RxStats1 [expr $rxFrameIndex + 1]]
set rxFrameRate [lindex $RxStats1 [expr $rxFrameRateIndex + 1]]
puts "TxFrame=$txFrameNum"
puts "RxFrame=$rxFrameNum"
port1 StopStaEngine
port2 StopStaEngine
Analysis2 StopCapture
}
#清除测试过程中所作的所有配置和释放测试过程中占用的所有资源
chassis1 CleanupTest
} err ] } {
puts "脚本运行中出现错误: $err"
#清除测试过程中所作的所有配置和释放测试过程中占用的所有资源
chassis1 CleanupTest
}