脚本实现测试仪2口发,通过DUT设备转发到测试仪4口收的功能,并验证收发是否相等。
package require IxTclHal
global one2oneArray
set userName dwang
set hostName 192.168.2.99
if [isUNIX] {
ix [ixConnectToTclServer $hostName] {
ixPuts "Could not connect to $hostName"
return 1
}
}
ixLogin $userName
if [ixConnectToChassis $hostName] {
return 1
}
#chasID get $hostName
set chasID [ixGetChassisID $hostName]
set cardID 15
set txport 2
set rxport 4
set txPortList [list [list $chasID $cardID $txport]]
set rxPortList [list [list $chasID $cardID $rxport]]
set portList [list [list $chasID $cardID $txport] [list $chasID $cardID $rxport]]
if [ixTakeOwnership $portList force] {
ixPuts $::ixErrorInfo
return 1
}
if [port setFactoryDefaults $chasID $cardID $txport] {
errorMsg "Error setting factory defaults on port $txport."
set retCode 1
}
if [port setFactoryDefaults $chasID $cardID $rxport] {
errorMsg "Error setting factory defaults on port $rxport."
set retCode 1
}
map new -type one2one
map config -type one2one
map add $chasID $cardID $txport $chasID $cardID $rxport
if [port setFactoryDefaults $chasID $cardID $txport] {
errorMsg "Error setting factory defaults on port $txport."
set retCode 1
}
if [port setFactoryDefaults $chasID $cardID $rxport] {
errorMsg "Error setting factory defaults on port $rxport."
set retCode 1
}
#if [port setPhyMode portPhyModeFiber $chasID $cardID $rxport] {
# errorMsg "Errot setting fiber mode on $rxport"
# set retCode 1
#}
if {[ixWritePortsToHardware one2oneArray]} {
ixPuts "Error writing port to hardware"
set retVal 1
}
# Checks the link state of the ports
if {[ixCheckLinkState one2oneArray]} {
return -code error
}
logOn "E:/ixia.log"
logMsg "Configuring $chasID $cardID $txport --> $chasID $cardID $rxport"
# Set default values
stream setDefault
udf setDefault
filter setDefault
filterPallette setDefault
# Stream 1
set streamID 1
stream setDefault
stream config -numBursts 100
stream config -numFrames 100000
stream config -dma advance
stream config -rateMode streamRateModePercentRate
stream config -percentPacketRate 30
stream config -frameSizeType sizeRandom
#stream config -dma stopStream
#stream config -sa {00 de ad be ef 00}
#stream config -da {00 ba be fa ce 00}
protocol setDefault
protocol config -name ipV4
protocol config -ethernetType ethernetII
ip setDefault
ip config -ipProtocol ipV4ProtocolTcp
ip config -sourceIpAddr "2.0.0.0"
ip config -sourceIpMask "255.240.0.0"
ip config -sourceIpAddrMode ipIncrHost
#ip config -sourceIpAddrMode ipIdle /ipIncrHost /ipDecrHost /ipContIncrHost /ipIncrNetwork/ ipRandom
ip config -sourceIpAddrRepeatCount 20000
#ip config -sourceClass classA
ip config -destIpAddr "1.0.0.0"
ip config -destIpMask "255.255.0.0"
ip config -destIpAddrMode ipDecrHost
ip config -destIpAddrRepeatCount 20000
ip set $chasID $cardID $txport
tcp setDefault
tcp config -sourcePort 80
tcp config -destPort 8080
tcp set $chasID $cardID $txport
if [stream set $chasID $cardID $txport $streamID] {
ixPuts "Can't stream set $chasID $cardID $txport $streamID"
}
#stream 2
set streamID 2
#stream setDefault
stream config -numBursts 10
stream config -numFrames 200000
stream config -rateMode streamRateModePercentRate
stream config -percentPacketRate 30
stream config -dma stopStream
stream config -frameSizeType sizeRandom
protocol setDefault
protocol config -name ipV4
protocol config -ethernetType ethernetII
ip setDefault
ip config -ipProtocol ipV4ProtocolUdp
ip config -sourceIpAddr "4.0.0.0"
ip config -sourceIpAddrRepeatCount 20000
#ip config -sourceClass classA
ip config -sourceIpAddrMode ipIncrHost
ip config -destIpAddr "3.0.0.0"
ip config -destIpMask "255.255.0.0"
ip config -destIpAddrMode ipDecrHost
ip config -destIpAddrRepeatCount 20000
ip set $chasID $cardID $txport
udp setDefault
udp config -sourcePort 80
udp config -destPort 8080
udp set $chasID $cardID $txport
if [stream set $chasID $cardID $txport $streamID] {
ixPuts "Can't stream set $chasID $cardID $txport $streamID"
}
#ixWritePortsToHardware one2oneArray #DO NOT USE THIS COMMAND AT THIS
ixWriteConfigToHardware one2oneArray
# Zero all statistic counters on ports
if [ixClearStats one2oneArray] {
return -code error
}
# Start transmission on Tx port
ixPuts "Start transmit..."
if [ixStartTransmit txPortList] {
return -code error
}
after 1000
# Checks whether transmission is done on a group of ports
if {[ixCheckTransmitDone txPortList] == 1} {
return -code error
} else {
ixPuts "Transmission is complete."
}
after 1000
if [stat get statAllStats $chasID $cardID $txport] {
ixPuts "Statistics get statAllStats failed for $chasID $cardID $rxport"
return 1
} else {
set frameSent [stat cget -framesSent]
set bytesSent [stat cget -bytesSent]
ixPuts "\nNumber of frames sent: [stat cget -framesSent]"
ixPuts "Number of Bytes sent: [stat cget -bytesSent]"
ixPuts "Tx line speed: [stat cget -lineSpeed]"
}
if [stat get statAllStats $chasID $cardID $rxport] {
ixPuts "Statistics get statAllStats failed for $chasID $cardID $rxport"
return 1
} else {
set frameReceived [stat cget -framesReceived]
set bytesReceived [stat cget -bytesReceived]
ixPuts "\nNumber of frames received: [stat cget -framesReceived]"
ixPuts "Number of Bytes received: [stat cget -bytesReceived]"
ixPuts "Rx line speed: [stat cget -lineSpeed]\n"
}
if [ string equal "$frameSent" "$frameReceived" ] {
logMsg "frame send equal to frame received."
}
if { 1 } {
ixClearOwnership $portList
ixDisconnectFromChassis $hostName
if [isUNIX] {
ixDisconnectTclServer $hostName
}
}
logOff
|
阅读(1611) | 评论(0) | 转发(0) |