Chapter 2: Quick Start 2

Installing the IxOS Tcl Client

This chapter provides a quick means of getting started with the Tcl API. An example test is presented and explained.

The IxOS Tcl Client provides an interface between an Ixia Tcl client application and Ixia IxOS Tcl functions. It runs on the / host.

The Windows version of IxOS Tcl Client is included with the IxOS software package; the Unix/Linux version is supplied as a separate a self-extracting archive (.bin) file. You can download it from Ixia’s website, www.ixiacom.com.

There are serveral versions of the IxOS Tcl Client. The correct file to install depends on the set up of the UNIX/Linux machine. Table 2-2 on page 2-1 details the files and their use. Table 2-2. Tcl Client Install Files Install File Purpose

IxOS#.## For Linux versions post Redhat 9. It is distributed as genericLinux.bin a tarball (IxOS#.##genericLinux.bin.tar.gz) due to download issues.

IxOS#.##linux.bin. For Linux platforms older than Redhat 9.

IxOS#.##setup.jar An installer without a bundled Java Virtual Machine. This is distributed only to customers that have issues running the bin installers. It requires a Java Virtual Machine installed on the installation target.

IxOS#.## For Solaris machines. solarisSparc.bin

The versions of UNIX/Linux operating systems that are supported are: • Mandrake 7.2, RedHat 6.2, RedHat 7.0, RedHat 9.0 • RedHat Enterprise 4.0

IxOS Tcl Development Guide, 6.60 EA SP1 2-1 Quick Start 2 Installing the IxOS Tcl Client

• Solaris 2.7 (7), 2.8 (8), 2.9 (9)

Other versions of Linux and Solaris platforms may operate properly, but are not officially supported.

To install the IxOS TCL Client, do the following: 1. Download the self-extracting archive that contains the Unix/Linux Tcl client. 2. Use the following to make the archive file executable: chmod +x Example: chmod +x IxOS#.##genericLinux.bin (where #.## is the version number) 3. Execute the archive to extract the installation files and begin the installation: ./ Example: ./IxOS#.##genericLinux.bin The installation is a typical InstallShield installation. The installer prompts you to select which version of the Tcl Client you want to install (Figure 2-2).

Figure 2-2. Tcl Version selection

The installer also prompts you to select the path where the Tcl Client is installed. (Figure 2-3). The default path is the current folder. 4. Accept the default installation path or enter an alternative, then click Next.

2-2 IxOS Tcl Development Guide, 6.60 EA SP1 Quick Start Installing the IxOS Tcl Client

Figure 2-3. Installation path

IxOS Tcl Development Guide, 6.60 EA SP1 2-3 Quick Start 2 UNIX Environment

UNIX Environment

On UNIX system, when IxOS client is installed, an ixwish file is created under “bin dir”. This ixwish file sets up the environment variables needed to run the IxOS client, and starts the wish shell.

The contents of the file are shown below. The highlighted lines are the environment variables that are set according to the user’s installation. To use Tcl libraries not supplied by IxOS, you should change the TCL_HOME and TCLver variables to point to the correct libraries.

#!/bin/sh # # Environment variables here are all caps if saved and exported # Upper and lower case if used temporarily to set other # variables

IXIA_HOME=

# USER MAY NEED TO CHANGE THESE IF USING OWN TCL

TCL_HOME= TCLver=8.5

# USER NORMALLY DOES NOT CHANGE ANY LINES BELOW

IxiaLibPath=$IXIA_HOME/lib IxiaBinPath=$IXIA_HOME/bin TCLLibPath=$TCL_HOME/lib TCLBinPath=$TCL_HOME/bin TCL_LIBRARY=$TCLLibPath/tcl$TCLver TK_LIBRARY=$TCLLibPath/$TCLver PATH=$IxiaBinPath:.:$TCLBinPath:$PATH #TCLLIBPATH=$IxiaLibPath:$TCLLIBPath; # does not work, not a set of paths, must point to Ixia only TCLLIBPATH=$IxiaLibPath LD_LIBRARY_PATH=$IxiaLibPath:$TCLLibPath:$LD_LIBRARY_PATH IXIA_RESULTS_DIR=/tmp/Ixia/Results IXIA_LOGS_DIR=/tmp/Ixia/Logs IXIA_TCL_DIR=$IxiaLibPath IXIA_SAMPLES=$IxiaLibPath/ixTcl1.0 IXIA_VERSION= export IXIA_HOME TCL_LIBRARY TK_LIBRARY TCLLIBPATH export LD_LIBRARY_PATH IXIA_RESULTS_DIR export IXIA_LOGS_DIR IXIA_TCL_DIR IXIA_SAMPLES export IXIA_TCL_DIR PATH IXIA_VERSION $TCLBinPath/wish ${@+"$@"}

2-4 IxOS Tcl Development Guide, 6.60 EA SP1 Quick Start Windows Environment

Windows Environment

On Windows , the IxiaWish.tcl file is installed as part of the IxOS client installation. The path to the IxiaWish.tcl file is similar to this: :\Program Files\Ixia\IxOS\\TclScripts\bin\IxiaWish.tcl

This IxiaWish.tcl file sets up the environment variables needed to run the IxOS Tcl client. When Tcl 8.5 wish is started, IxiaWish.tcl is sourced to set up the IxTclHAL environment as part of the startup.

Alternatively, you can use a third-party wish like ActiveTcl, and set up the environment for accessing the IxOS Tcl package by sourcing the file named in the path above.

IxOS Tcl Development Guide, 6.60 EA SP1 2-5 Quick Start Installing Platform Independent package - tarball

Installing Platform Independent package - tarball

To install tarball, perform the following steps: 1. Create a folder tarball inside the root directory. 2. Copy the IxOSTclClient.tar.gz inside the tarball and then extract it as tar –zxvf IxOSTclClient.tar.gz. 3. Two folders lib and TclDevelopmentGuide.pdf are created. 4. Create folders tcl8.5 and mpexpr-1.1 inside lib. 5. Create another folder activetcl inside tarball. 6. Download the tar file http://www.activestate.com/activetcl/downloads/thank- you?dl=http://downloads.activestate.com/ActiveTcl/releases/8.5.13.0/ ActiveTcl8.5.13.0.296436-linux-x86_64-threaded.tar.gz and copy it to the activetcl folder. 7. Extract the above tar file as tar –zxvf ActiveTcl8.5.13.0.296436-linux-x86_64- threaded.tar. 7. A folder ActiveTcl8.5.13.296436-linux-x86_64-threaded gets created. 8. Copy the contents of tcl8.5 folder located in /root/tarball/activetcl/ ActiveTcl8.5.13.296436-linux-x86_64-threaded/payload/lib to tcl8.5 folder located in /root/tarball/lib. 9. Copy the contents of the mpexpr-1.1 folder located inside the IxOS installation directory /root/ixos1/lib to mpexpr-1.1 folder located inside /root/ tarball/lib. 10.Set the environment file as:

# /bin/bash Environments: # Source this file to setup environment variables IXIA_HOME=/root/tarball TCL_LIBRARY=/root/tarball/lib/tcl8.5 LD_LIBRARY_PATH=/root/tarball/ lib:$IxiaLibPath:$TclLibPath:$LD_LIBRARY_PATH IXIA_TCL_DIR=/root/tarball/lib TCLLIBPATH="$LOCAL_TCLLIBPATH /root/tarball/lib" IXIA_SAMPLES=/root/tarball/lib/ixTcl1.0 IXIA_VERSION=6.60 export TCLLIBPATH IXIA_HOME TCL_LIBRARY LD_LIBRARY_PATH export IXIA_SAMPLES IXIA_TCL_DIR IXIA_VERSION

Connect to IxServer

To connect to IxServer, perform the following steps: 1. Source the environment file for tarball. 2. ixConnectToTclServer 3. ixConnectToChassis

IxOS Tcl Development Guide, 6.60 EA SP1 2-6 Quick Start 2 IxSampleTcl Test Program

IxSampleTcl Test Program

The IxSampleTcl.tcl file is included just below, along with comments which explain the test. ############################################################### ############### # IxTclHAL Version :5.20.0.165 # Product version :5.20.0 Build 165# # File: IxSampleTCL.tcl # # Copyright © 1997 - 2009 by IXIA # All Rights Reserved. # # The following is an example of how streams, ports and filters are configured, # data capture started, transmission started and statistics collected. # The chassis is connected to first, streams are created, filters are set, # then capture is started on Rx port and transmisssion is started on Tx port. # After the transmition is complete, some statistics are collected and # displayed # to standard out. # Note: This test requires two ports which should be connected via loopback # cable. # ############################################################### ############### # This package is required to have access to the Ixia Tcl commands package req IxTclHal set userName IxiaTclUser set hostname localhost set retCode $::TCL_OK

# If on unix/linux, we must connect to the tclServer. This would need to be # uncommented and a tclServer host name would need to be supplied. : # NOTE: IxTclServer should not run on the chassis. #if {[isUNIX]} { # set retCode [ixConnectToTclServer $hostname] #} ixPuts "\n\tIxia Tcl Sample Script" # Log in user ixLogin $userName ixPuts "\nUser logged in as: $userName" set recCode [ixConnectToChassis $hostname] if {$retCode != $::TCL_OK} { return $retCode }

set chasId [ixGetChassisID $hostname] set card 1 #added line below on July 2 to make ports selectable instead of hardwired set port1 3

2-7 IxOS Tcl Development Guide, 6.60 EA SP1 Quick Start 2 IxSampleTcl Test Program

set port2 4

# Assume transmit from port 1 to port 2 on same card for this example set portList [list [list $chasId $card $port1] [list $chasId $card $port2]] # Decide on some mac & ip addresses - lots of ways to do this, this is one # example

set macAddress(sa,$chasId,$card,$port1) [format "be ef be ef %02x %02x" $card $port1] set macAddress(sa,$chasId,$card,$port2) [format "be ef be ef %02x %02x" $card $port2] set macAddress(da,$chasId,$card,$port1) $macAddress(sa,$chasId,$card,$port2) set macAddress(da,$chasId,$card,$port2) $macAddress(sa,$chasId,$card,$port1)

set ipAddress(sa,$chasId,$card,$port1) [format "199.17.%d.%d" $card $port1] set ipAddress(sa,$chasId,$card,$port2) [format "199.17.%d.%d" $card $port2] set ipAddress(da,$chasId,$card,$port1) $ipAddress(sa,$chasId,$card,$port2) set ipAddress(da,$chasId,$card,$port2) $ipAddress(sa,$chasId,$card,$port1)

# Take ownership of the ports if [ixTakeOwnership $portList] { return $::TCL_ERROR }

proc clearOwnershipAndLogout {} { global portList ixClearOwnership $portList # Log off user ixLogout cleanUp }

# Display version information ixPuts "\nIxTclHAL Version :[version cget -ixTclHALVersion]" ixPuts "Product version :[version cget -productVersion]" ixPuts "Installed version :[version cget -installVersion]\n" # Set ports to factory defaults. Dumps out on error. ixPuts "Setting ports to factory defaults..." foreach item $portList { scan $item "%d %d %d" chasId card port if [port setFactoryDefaults $chasId $card $port] { errorMsg "Error setting factory defaults on $chasId.$card.$port]." clearOwnershipAndLogout return $::TCL_ERROR } } # Writes port properties in hardware if {[ixWritePortsToHardware portList]} { clearOwnershipAndLogout return $::TCL_ERROR }

# Check the link state of the ports

2-8 IxOS Tcl Development Guide, 6.60 EA SP1 Quick Start IxSampleTcl Test Program

if {[ixCheckLinkState portList]} { clearOwnershipAndLogout return $::TCL_ERROR }

ixPuts "Configuring streams..." ixGlobalSetDefault protocol config -ethernetType ethernetII protocol config -name ip # Set up some generic stream config items that are shared on all streams # generated.

stream config -numFrames 10 stream config -rateMode streamRateModePercentRate stream config -percentPacketRate 42

foreach item $portList { scan $item "%d %d %d" chasId card port set frameSize 64 ;# we will make 20 streams w/incr. framesizes

ip config -sourceIpAddr $ipAddress(sa,$chasId,$card,$port) ip config -destIpAddr $ipAddress(da,$chasId,$card,$port)

######debug lines added by cz june 26##### puts "debug info source IP address for port $port is:$ipAddress(sa,$chasId,$card,$port)" puts "debug info destination IP address for port $port is:$ipAddress(da,$chasId,$card,$port)" ######debug#####

if [ip set $chasId $card $port] { logMsg "Error setting IP on $chasId,$card,$port" set retCode $::TCL_ERROR break } stream config -sa $macAddress(sa,$chasId,$card,$port) stream config -da $macAddress(da,$chasId,$card,$port)

######debug lines added by cz june 26##### puts "debug info source MAC for port $port is:$macAddress(sa,$chasId,$card,$port)" puts "debug info destination MAC for port $port is:$macAddress(da,$chasId,$card,$port)" ######debug#####

stream config -dma advance set udfPattern [lrange [stream cget -da] 2 end] ######debug lines added by cz june 26##### puts "udfPattern is :$udfPattern" ######debug##### udf config -enable true udf config -offset 42 udf config -initval $udfPattern udf config -countertype c32 udf config -maskselect {00 00 00 00} udf config -maskval {00 00 00 00} udf config -random false

IxOS Tcl Development Guide, 6.60 EA SP1 2-9 Quick Start 2 IxSampleTcl Test Program

udf config -continuousCount false udf config -repeat 1 if [udf set 4] { errorMsg "Error setting UDF 4" set retCode $::TCL_ERROR break } # Configure 20 streams on Tx port for {set streamId 1} {$streamId < 20} {incr streamId} { stream config -name "Stream $streamId - IP sample stream" stream config -framesize $frameSize incr frameSize 42 if [stream set $chasId $card $port $streamId] { errorMsg "Error setting stream $chasId,$card,$port.$streamId - $ixErrorInfo" set retCode $::TCL_ERROR break } }

incr streamId -1 # Set last stream to STOP stream config -dma stopStream if [stream set $chasId $card $port $streamId] { errorMsg "Error setting stream $chasId,$card,$port.$streamId - $ixErrorInfo" set retCode $::TCL_ERROR break }

#### TK change set rxUdfPattern [lrange $macAddress(sa,$chasId,$card,$port) 2 end]

# Set the filter parameters filterPallette config -pattern2 $rxUdfPattern filterPallette config -patternOffset2 [udf cget -offset] filter config -userDefinedStat2Pattern pattern2 filter config -userDefinedStat2Enable true filter config -userDefinedStat2Error errGoodFrame filter config -captureTriggerEnable true filter config -captureFilterEnable true if [filterPallette set $chasId $card $port] { errorMsg "Error setting filter pallette for $chasId,$card,$port." set retCode $::TCL_ERROR break } if [filter set $chasId $card $port] { errorMsg "Error setting filters on $chasId,$card,$port." set retCode $::TCL_ERROR break } }

# Dump out now if there were any errors.. maybe you want to throw instead of a # return. if {$retCode != $::TCL_OK} { clearOwnershipAndLogout return $retCode }

2-10 IxOS Tcl Development Guide, 6.60 EA SP1 Quick Start IxSampleTcl Test Program

# Writes all the configuration on ports in hardware # NOTE: This does NOT take link down, so no point in checking link state # afterward and no need for any delays # Also note that this is an example of a throw instead of a return if [ixWriteConfigToHardware portList] { return -code error } # Zero all statistic counters on ports if [ixClearStats portList] { return -code error } ixPuts "Start capture..." if [ixStartCapture portList] { return -code error } ixPuts "Start transmit..." if [ixStartTransmit portList] { return -code error } # Let it transmit for a bit; if this were a real test, we might want to wait for # approx. the total transmit time. Since it's not, 1 sec is sufficient for the # streams we've created. after 1000 # Checks whether transmission is done on a group of ports if {[ixCheckTransmitDone portList] == $::TCL_ERROR} { clearOwnershipAndLogout return -code error } else { ixPuts "Transmission is complete." }

# Stop capture on ports - not really necessary, as any read of capture will # automatically stop capture ixPuts "Stop capture..." if [ixStopCapture portList] { clearOwnershipAndLogout return -code error }

# This will request stats from all ports in the portList - it's really # efficient and the best way to collect stats when you have multiple ports to # contend with. ixRequestStats portList foreach item $portList { scan $item "%d %d %d" chasId card port if {[statList get $chasId $card $port]} { ixPuts "Error getting stats for $chasId,$card,$port" set retCode $TCL_ERROR break }

# note that if a stat is not supported on a particular port type, the cget # will throw so it is best to protect that in the following fashion:

IxOS Tcl Development Guide, 6.60 EA SP1 2-11 Quick Start 2 IxSampleTcl Test Program

if [catch {statList cget -scheduledFramesSent} numTxFrames ] { set numTxFrames 0 ixPuts "WARNING: -scheduledFramesSent not supported on $chasId,$card,$port. Value set to 0" }

if [catch {statList cget -userDefinedStat2} numRxFrames ] { set numRxFrames 0 ixPuts "WARNING: -userDefinedStat2 not supported on $chasId,$card,$port. Value set to 0" }

if [captureBuffer get $chasId $card $port 1 $numRxFrames] { ixPuts "Error getting captureBuffer on $chasId $card $numRxFrames" set retCode $::TCL_ERROR #break removed by cz on July 2nd 2009 #break }

ixPuts "Port: $chasId,$card,$port" ixPuts -nonewline "Speed: [stat getLineSpeed $chasId $card $port]\t" ixPuts -nonewline "Frames sent: $numTxFrames\t" ixPuts -nonewline "Frames Rcvd: $numRxFrames\t" ixPuts "Number of packets captured :[captureBuffer cget - numFrames]\n" }

ixPuts "\nSample test complete.\n" clearOwnershipAndLogout

2-12 IxOS Tcl Development Guide, 6.60 EA SP1