atmtm_ns_hist_combo_per_stream.tcl
来自「smartbits二次开发示例代码」· TCL 代码 · 共 380 行 · 第 1/2 页
TCL
380 行
################################################################################
# ATMTM_ns_his_combo_per_stream.tcl #
# #
# - This sample applies to ATM 3451/3453 cards. It uses the first slot in a #
# chassis, connected back to back. #
# - This sample creates 1 VC, 10 IP streams with OC3 speed port. The VC is #
# bound with the 10 IP streams, and sends out a single burst of 10000 IP #
# frames. It then uses histogram to displays latency and sequence #
# information #
# #
# NOTE: This script works on the following cards: #
# - ATM-3451/3453 with SmartLib 3.50, TM 3.60.42/TM 4.00 #
# #
################################################################################
# If smartlib.tcl is not loaded, attempt to locate it at the default location.
# The actual location is different on different platforms.
if {$tcl_platform(platform) == "windows"} {
set libPath "../../../../tcl/tclfiles/smartlib.tcl"
} else {
set libPath "../../../../include/smartlib.tcl"
}
# if "smartlib.tcl" is not loaded, try to source it from the default path
if { ! [info exists __SMARTLIB_TCL__] } {
if {[file exists $libPath]} {
source $libPath
} else {
#Enter the location of the "smartlib.tcl" file or enter "Q" or "q" to quit
while {1} {
puts "Could not find the file $libPath."
puts "Enter the path of smartlib.tcl, or q to exit."
gets stdin libPath
if {$libPath == "q" || $libPath == "Q"} {
exit
}
if {[file exists $libPath]} {
source $libPath
break
}
}
}
}
# If chassis is not currently linked prompt for IP and link
if {[ETGetLinkStatus] < 0} {
puts "SmartBits not linked - Enter chassis IP address"
gets stdin ipaddr
set retval [NSSocketLink $ipaddr 16385 $::RESERVE_NONE]
if {$retval < 0 } {
puts "Unable to connect to $ipaddr. Please try again."
exit
}
}
##############################################################################
# Set test constants #
##############################################################################
set TxHub 0
set TxSlot 0
set TxPort 0
set RxHub 0
set RxSlot 0
set RxPort 1
set num2Add 9
# Set ranges for latency distribution
set R0 1
set R1 2
set R2 3
set R3 4
set R4 5
set R5 6
set R6 8
set R7 10
set R8 50
set R9 100
set R10 500
set R11 1000
set R12 5000
set R13 10000
set R14 50000
set R15 100000
set BurstPerStream 1000
set BurstSize [expr ( 1 + $num2Add ) * $BurstPerStream ]
set DATA_LENGTH 88
###########################################################################################
# Reserve cards #
# TxSlot and RxSlot are the same in this script so that only reserve TxSlot #
###########################################################################################
puts "Reserving Tx and Rx cards ..."
LIBCMD HTSlotReserve $TxHub $TxSlot
###########################################################################################
# Reset cards #
###########################################################################################
puts "Resetting Tx and Rx cards ..."
LIBCMD HTResetPort $::RESET_FULL $TxHub $TxSlot $TxPort
LIBCMD HTResetPort $::RESET_FULL $RxHub $RxSlot $RxPort
after 2000
###########################################################################################
# Config ATM ports. #
# #
# Note for the ucTxClockSource #
# Time synchronization is an important part of SONET/SDH. Either a NE(Network Element,#
# Switch or end station) would use timeoff the line(fiber, AT_LOOP_TIMED_CLOCK) or #
# AT_INTERNAL_CLOCK to transmit a SONET frame. #
# Only restriction is BOTH end points of the fiber cannot have LOOP TIMING. Both can #
# be internal... and the BEST timing is when one of the end points is using its #
# internal clock and the other using the same clock off the fiber. #
# Therefore for this back-to-back test, ucTxClockSource is setting differently on the #
# TX and RX port in this script #
# #
###########################################################################################
puts "Configuring ATM ports ..."
#Configure ATM TX/RX port
LIBCMD HTSetStructure $AT_PORT_CONFIG 0 0 0 - 0 $TxHub $TxSlot $TxPort\
-ucTxClockSource $AT_INTERNAL_CLOCK
LIBCMD HTSetStructure $AT_PORT_CONFIG 0 0 0 - 0 $RxHub $RxSlot $RxPort\
-ucTxClockSource $AT_LOOP_TIMED_CLOCK
###########################################################################################
# Config ATM VC. #
# Only one single VC of index 1 is created #
###########################################################################################
puts "Configuring ATM VCs ..."
#Configure VC on ATM TX/RX port
LIBCMD HTSetStructure $AT_VC_CREATE 1 0 0 - 0 $TxHub $TxSlot $TxPort\
-ulTxMode $SINGLE_BURST_MODE \
-ulBurstCount $BurstSize \
-ucEncapType $AT_ENCAP_TYPE_LLC_IPV4
LIBCMD HTSetStructure $AT_VC_CREATE 1 0 0 - 0 $RxHub $RxSlot $RxPort\
-ulTxMode $SINGLE_BURST_MODE \
-ulBurstCount $BurstSize \
-ucEncapType $AT_ENCAP_TYPE_LLC_IPV4
###########################################################################################
# Config streams. #
###########################################################################################
#set up streams
LIBCMD HTSetStructure $L3_DEFINE_IP_STREAM 0 0 0 - 0 $TxHub $TxSlot $TxPort\
-ucActive 1 \
-ucProtocolType $STREAM_PROTOCOL_IP \
-uiFrameLength $DATA_LENGTH \
-ucRandomLength 0 \
-ucTagField 1 \
-TimeToLive 10 \
-DestinationIP {192 158 100 1} \
-SourceIP {192 148 100 1} \
-Netmask {255 255 255 0} \
-Gateway {192 148 100 1} \
-Protocol 4
struct_new ip StreamIP
set ip(DestinationIP) {0 0 0 1}
set ip(SourceIP) {0 0 0 1}
LIBCMD HTSetStructure $L3_DEFINE_MULTI_IP_STREAM 1 $num2Add 0 ip 0 $TxHub $TxSlot $TxPort \
unset ip
# Calculate frame rate based on the PCR (353207) of the configured port speed OC3
#
# There is only one VC configured, and the VC has PCR 353207, as configured above. This
# calculation is based on this VC PCR and evenly distributed it to the streams which are
# bound to the VC - and use its equivalent frame rate as the frame rate of the streams
# NOTE:
# It is not necessary to always set the stream frame rate as as this equivalent VC PCR
# frame rate as long as the summation of the frame rate of all the streams bound on the
# VC is equal to or smaller than the allocated VC PCR.
#
set CellsPerFrame [expr floor(($DATA_LENGTH + 5) / 48) + 1 ]
set PCRPerVC 353207 ;#only one VC configured
set PCRPerStream [expr $PCRPerVC / ($num2Add + 1) ]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?