Ixia Tcl Development Guide
Total Page:16
File Type:pdf, Size:1020Kb
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 Unix / Linux 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 command to make the archive file executable: chmod +x <archive file name> Example: chmod +x IxOS#.##genericLinux.bin (where #.## is the version number) 3. Execute the archive to extract the installation files and begin the installation: ./<archive file name> 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=<install location> # USER MAY NEED TO CHANGE THESE IF USING OWN TCL LIBRARY TCL_HOME=<install location> 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/tk$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=<build 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 operating system, the IxiaWish.tcl file is installed as part of the IxOS client installation. The path to the IxiaWish.tcl file is similar to this: C:\Program Files\Ixia\IxOS\<version>\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 <chassis-name> 3. ixConnectToChassis <chassis-name> 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)