atmtmbasic.tcl

来自「smartbits二次开发示例代码」· TCL 代码 · 共 459 行 · 第 1/2 页

TCL
459 行
字号
####################################################################################
#                                                                                  # 
# ATMTMBasic.tcl                                                                   #
#                                                                                  #
# - This sample applies to ATM 3451/3453 cards. It uses the first slot in a        #
#   chassis, connected back to back.                                               #
# - This sample creates 4 VCs, 12 IP streams with OC3 speed port. Each VC is bound #
#   with 3 IP streams, and sends out a single burst of 3 IP frames. It will then   #
#   display the packets captured on the receiver.                                  #                                                                    #
#                                                                                  #
# 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
     }
}


#Define variables
set TxHub 0
set TxSlot 1
set TxPort 0
set RxHub 0
set RxSlot 1
set RxPort 1

set DataLength       64

set VCCount          4
set StreamCountPerVC 3
set StreamCountTotal [expr $StreamCountPerVC * $VCCount]

set BurstCountPerVC  $StreamCountPerVC
set PacketCount      [expr $VCCount * $BurstCountPerVC ]

set atmFlag          $AT_CLP_OFF

###########################################################################################
# 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 $RxHub $RxSlot $RxPort
LIBCMD HTResetPort $RESET_FULL $TxHub $TxSlot $TxPort
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 ..."

#Declare ATM port structure
struct_new AtPort ATPortConfig

#Define ATM port contents and config TX/RX port, and delete ATM port structure
set AtPort(ucInterfaceSpeed)            $AT_SPEED_OC3
set AtPort(ucFramingMode)               $AT_SONET_FRAMING
set AtPort(ucTxClockSource)             $AT_INTERNAL_CLOCK
set AtPort(ucCellScramblingMode)        $AT_CELL_SCRAMBLING_PAYLOAD
set AtPort(ucHecCosetEnable)            1
set AtPort(ucLoopbackMode)              $AT_LOOPBACK_DISABLED
set AtPort(ucIdleCellHeaderGFC)         0
set AtPort(ucIdleCellHeaderPTI)         $AT_USRDATA_NOT_CONGESTED
set AtPort(ucIdleCellHeaderCLP)         0
set AtPort(ucIdleCellPayloadByte)       0x6A
set AtPort(ucPathSignalLabel)           $AT_PATH_SIGNAL_LABEL_ATM
set AtPort(ucHecErrorHandlingMode)      $AT_HEC_ERROR_HANDLING_CORRECT
set AtPort(ucSONETCountMode)            $AT_ERROR_COUNT_INDIVIDUAL
set AtPort(ulVCInterleaveDepth)         $AT_VC_INTERLEAVE_ALL
set AtPort(ulMaxRxCutThroughBufferSize) $AT_VC_INTERLEAVE_ALL  
set AtPort(ulErrorInjection)            0
set AtPort(ulFlags)                     $AT_PORT_DEFAULT_FLAGS
LIBCMD HTSetStructure $AT_PORT_CONFIG 0 0 0 AtPort 0 $TxHub $TxSlot $TxPort

set AtPort(ucTxClockSource)             $AT_LOOP_TIMED_CLOCK
LIBCMD HTSetStructure $AT_PORT_CONFIG 0 0 0 AtPort 0 $RxHub $RxSlot $RxPort
unset AtPort


###########################################################################################
# Config ATM VCs.                                                        #
###########################################################################################

puts "Configuring ATM VCs ..."

#Declare ATM VC structure
struct_new AtVC ATVC

#Define ATM VC contents and config VCs on TX/RX port, and delete ATM VC structure
#
#For OC3 speed port, the PCR is 353207. Considering multiple VCs are configured on the port,
#we evenly distribute the PCR between the multiple VCs.
#So that we have "set AtVC(ulPCR) [expr 353207/$VCCount]" below
#It is not necessary to always set the PCR of the VC as [expr 353207/$VCCount] as long as
#the summation of the PCRs of all the VC is equal or smaller than 353207 on the OC3 port.  
set AtVC(ucTxEnable)        1
set AtVC(ucRxEnable)        1
set AtVC(ucConnType)        $STR_CONN_TYPE_PVC
set AtVC(uiVPI)             0
set AtVC(uiVCI)             32
set AtVC(ucGFC)             0
set AtVC(ucPTI)             $AT_USRDATA_NOT_CONGESTED
set AtVC(ucAALType)         $AT_AAL5
set AtVC(ucEncapType)       $AT_ENCAP_TYPE_LLC_IPV4
set AtVC(ucCaptureEnable)   1
set AtVC(ucRateClass)       $AT_RATE_CLASS_UBR
set AtVC(ulPCR)             [expr 353207/$VCCount]
set AtVC(ulRxCutThroughBufferSize)	$AT_VC_RX_CT_BUFFER_SIZE	
set AtVC(ulTxMode)          $SINGLE_BURST_MODE
set AtVC(ulBurstCount)      $BurstCountPerVC
set AtVC(ulMburstCount)     0
set AtVC(ulBurstGap)        0
set AtVC(ucCLIPInARPEnable) 0
set AtVC(ucCLIPUnSolicitedInARPReplyEnable)   0
LIBCMD HTSetStructure $AT_VC_CREATE 0 $VCCount 0 AtVC 0 $TxHub $TxSlot $TxPort
LIBCMD HTSetStructure $AT_VC_CREATE 0 $VCCount 0 AtVC 0 $RxHub $RxSlot $RxPort
unset AtVC

###########################################################################################
# Define One IP stream on Tx Card.                                                        #
###########################################################################################

puts "Defining one IP stream ..."

#Declare IP stream structure
struct_new streamIP StreamIP

#Define IP stream contents
set streamIP(ucActive)       1
set streamIP(ucProtocolType) $STREAM_PROTOCOL_IP
set streamIP(uiFrameLength)  $DataLength
set streamIP(TimeToLive)     10
set streamIP(Protocol)       4

set streamIP(DestinationIP) {10 100 10 1}
set streamIP(SourceIP)      {10 100 20 2}

#Set Stream definition to the TX Card, starting at index 1, and delete streamIP structure.
LIBCMD HTSetStructure $L3_DEFINE_IP_STREAM 0 0 0 streamIP 0 $TxHub $TxSlot $TxPort
unset streamIP

###########################################################################################
#Define [$StreamCountTotal - 1] more streams on TX card, based on the first stream.                             #
#Also, increment the Destination MAC address in each additional stream by 1.              #
#Therefore,                                                                               #
#The first stream has a Destination IP address of 10 100 10 1 (as defined above);        #
#The second stream has a Destination IP address of 10 100 10 2;                          #
#The third stream has a Destination IP address of 10 100 10 3, etc..                     #
###########################################################################################

puts "Defining [expr $StreamCountTotal - 1] more IP Streams ..."

#Declare IP stream structure
struct_new streamIP StreamIP

#Define IP fields wish to increment, and the value to increment by.
set streamIP(DestinationIP) {0 0 0 1}

#Copy additional more IP streams to the TX Card, based on the first stream, and delete stream structure.
LIBCMD HTSetStructure $L3_DEFINE_MULTI_IP_STREAM 1 [expr $StreamCountTotal - 1] 0 streamIP 0 $TxHub $TxSlot $TxPort
unset streamIP

###########################################################################################
# Use stream extension to set frame rate for the first stream on Tx Card.                                                        #
###########################################################################################

puts "Setup stream frame rate with stream extension ..."

#Declare IP stream structure

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?