TCL Automationwith Ix Network Sept 2013
TCL Automationwith Ix Network Sept 2013
COURSE # 985-1001
September 2013
Copyright © 2013 Ixia. All rights reserved.
This publication may not be copied, in whole or in part, without Ixia’s consent.
RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the U.S. Government is subject to the restrictions set forth in subparagraph (c)(1
)(II) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR 52.227-19.
Ixia, the Ixia logo, and all Ixia brand names and product names in this document are either trademarks or registered trademarks of Ixia in the United
States and/or other countries. All other trademarks belong to their respective owners.
This material is for informational purposes only and subject to change without notice. It describes Ixia’s present plans to develop and make available
to its customers certain products, features and functionality. Ixia is only obligated to provide those deliverables specifically included in a written
agreement between Ixia and the customer.
Sept 2013
Tcl Automation with IxNetwork i
Table of Contents
Overview
Ixia products all come with a powerful and flexible GUI in which to design, execute and analyze
tests. These GUI’s are great tools for when you need to quickly and easily create an Ixia test.
However, many Ixia customers are using Ixia products in an automation environment, and thus, the
GUI’s will not help.
This course will go over the basics of the Ixia Tcl API for our IxNetwork product. This API, named
“IxTclNetwork” provides thousands of Tcl commands for connecting to a chassis, configuring Ixia
ports, configuring and starting routing/switching protocols, creating and sending L2/L3 traffic and
analyzing the results. This course will also introduce customers to built-in Ixia tools for simplifying
the automation process as well as how to customize stats on an “as-needed” basis.
Obviously, we cannot cover every command in this API during this class, so it is our goal to provide
a good foundation by covering the structure of the API, the tools provided by Ixia to help in the
creation of scripts, and the most commonly used commands.
Sept 2013
Tcl Automation with IxNetwork 3
Overview
Getting started is the easy part. Here is where we start the Wish console, load Ixia libraries, and
take ownership of some ports. Most Ixia scripts will start exactly like this. This helps to set the
stage for the rest of your script. You will find that getting started does not require very much code,
but the code that is there is crucial.
Another piece of script is often to ensure that the scripts are cross-platform. In other words, that
the script work in both Windows as well as Linux or Unix. Later we will use a tool that will create
some scripts for us that will include a few lines of code that will insure our scripts are cross-
platform.
© IXIA 2013
Tcl Automation with IxNetwork 5
© IXIA 2013
Tcl Automation with IxNetwork 7
© IXIA 2013
Tcl Automation with IxNetwork 9
© IXIA 2013
Tcl Automation with IxNetwork 11
© IXIA 2013
Tcl Automation with IxNetwork 13
© IXIA 2013
Tcl Automation with IxNetwork 15
© IXIA 2013
Tcl Automation with IxNetwork 17
© IXIA 2013
Tcl Automation with IxNetwork 19
© IXIA 2013
Tcl Automation with IxNetwork 21
© IXIA 2013
Tcl Automation with IxNetwork 23
© IXIA 2013
Tcl Automation with IxNetwork 25
© IXIA 2013
Tcl Automation with IxNetwork 27
© IXIA 2013
Tcl Automation with IxNetwork 29
Overview
Tcl, when combined with the Ixia APIs (application programming interfaces), provides a relatively
easy to learn scripting and programming environment that is well suited for working with the Ixia
test suite. In essence, Ixia created their own Tcl extension for allowing the control of an Ixia chassis
in the automation of IxNetwork tests.
In this lab we will start the Wish console that provides Tcl/Tk functionality, load the IxNetwork
libraries, connect to the IxNetwork Tcl Server, and configure some cards and ports that we will use
for the remainder of the class.
Lab Objectives
Students who complete this lab will be able to:
• Start Wish console session
• Load the IxNetwork Tcl API (IxTclNetwork)
• Connect to the IxNetwork Tcl Server
• See which cards and ports are available
• Start our script by creating the root object (top of the data model)
• Configure cards and ports
Test Topology
See Figure 1 for the topology of this test. This topology diagram shows the physical wiring and
layout of the Ixia chassis, as well as the devices that are used for running the tests.
© IXIA 2013
Tcl Automation with IxNetwork 31
Procedure
1. Before we get into the script writing, let’s make sure our IxNetwork Tcl Server is running.
Go to “Start/Programs/Ixia/IxNetwork/IxNetwork(version)/Aptixia IxNetwork Tcl Server”
2. Now let’s open a blank Notepad document. We are not going to run interactively in these
labs. We will type our code into Notepad and then either source the code, or copy and
paste.
3. Very likely, the first command in your script will be to load the IxNetwork Tcl API. The API
is not loaded automatically and must be done manually. Type the following command at the
top of your Notepad page:
4. From here, you must connect to the IxNetwork Tcl Server. The Tcl server resides on your
student client machine. You can either put the IP address of your machine, or just type
“localhost”. Type the following after your package require:
Note: We are passing the port number of the Tcl Server machine and the version
number of IxNetwork to ensure we are pointing to the correct libraries. If you do
not do this, it will default to IxNetwork 5.30 which is a different API.
5. Next, we will make sure that any config that might be currently on the Tcl Server will be
cleaned out. This will just clean up the environment for us. Add the following line to your
script:
6. We need to create the top/root object of our script. Everything we add after this point will
be children of our top object. Add the following lines to your script:
7. Next we will figure out what cards we have available, and then create some variables to
store our ports information. Remember to use the ports assigned to you by your instructor.
DO NOT use the ports in the following code, as these are the instructor’s ports. The code
you will type will look very similar to the following:
© IXIA 2013
Tcl Automation with IxNetwork 33
8. And finally in this section we will assign our port assignments to virtual ports that we will
create as children of root. Throughout the rest of this script, everything we do will be to our
“virtual” ports which contain handles to our real ports. To finalize this lab, add the
following commands to your script:
9. Save your Notepad script and give it a unique name. In case we are using an application
server in class, you will want to make your script name unique from the rest of the students.
I recommend naming your script something like ixnetscript_xx.tcl. (Where the xx are your
initials). Make sure that you save the file with a .tcl extension and change the file type to
“All Files”.
10. Now let’s see if it works! For this first lab, we are going to cut and paste the code into our
Wish Console so that we can see what the returns are for the commands. In future labs we
will use the Tcl “source” command, but in this lab, make sure to copy and paste the code.
11. Go to “Start/Programs/Ixia/IxNetwork/IxNetwork(version)/Wish Console for Aptixia
IxNetwork”
12. From here, just select the text in your script and copy it into the wish console.
13. Your output should like something like this:
14. The cool thing about the Tcl Server is you can see immediately if your script is working.
Double click on the Tcl Server icon at the lower left-hand side of the screen and you should
see the following:
15. Click on the Ports option in the resource tree and you should see your own ports
configuration:
© IXIA 2013
Tcl Automation with IxNetwork 35
16. If you do not see something that looks like the 2 previous screen captures, please inform
your instructor who will help you troubleshoot your script and output.
Overview
Now that we have successfully loaded libraries, connect to the IxNetwork Tcl Server, added our
ports and verified our configuration using the Tcl Server GUI, we can move on and configure our
protocols. For the purpose of this lab, we will be configuring OSPF. This lab will concentrate on the
configuration of the protocol. We will not actually start the protocol in the script until a later lab.
However, we will use the IxNetwork GUI after our protocols are configured to see if we can start
and stop the protocol. We will do this manually with the GUI. A later lab will add the code
necessary to start/stop the protocol.
© IXIA 2013
Tcl Automation with IxNetwork 37
© IXIA 2013
Tcl Automation with IxNetwork 39
© IXIA 2013
Tcl Automation with IxNetwork 41
© IXIA 2013
Tcl Automation with IxNetwork 43
© IXIA 2013
Tcl Automation with IxNetwork 45
© IXIA 2013
Tcl Automation with IxNetwork 47
© IXIA 2013
Tcl Automation with IxNetwork 49
Overview
Now that we have successfully loaded libraries, connect to the IxNetwork Tcl Server, added our
ports and verified our config using the Tcl Server GUI, we can move on and configure our protocol.
For the purpose of this lab, we will be configuring OSPF. This lab will concentrate on the
configuration of the protocol. We will not actually start the protocol running in the script until a
later lab. However, we will use the IxNetwork GUI after our protocols are configured to see if we
can start and stop the protocol. We will do this manually with the GUI. A later lab will add the code
necessary to start/stop the protocol.
Objectives
At the end of this lab, students will be able to:
• Enable protocols
• Configure the interfaces on the port
• Configure the protocol specific parameters
© IXIA 2013
Tcl Automation with IxNetwork 51
Test Topology
See Figure 1 for the topology of this test. This topology diagram shows the physical wiring and
layout of the Ixia chassis, as well as the devices that are used for running the tests.
Lab Procedure
1. Now that we have successful connected to your 2 test ports, we can start configuring
your protocol. The first step is to enable the protocol in your script. Add the following
commands to your script:
2. Now that you have enabled the protocol, we will configure the interfaces on the ports.
We will do this one port at a time for practice. In the future, it is more likely you will
create a looping construct to configure multiple ports at once. Add the following
commands to your script:
Note: The IP addresses you will configure are based on the table provided at the
back of this manual. Those above are examples and are not correct for you!
© IXIA 2013
Tcl Automation with IxNetwork 53
3. We need to configure IPv4, which is a child object of interface. Add the following
commands to your script:
4. We will configure an emulated router on our newly configured interface. Add the
following commands to your script:
5. We need to finish configuring our interface to make sure that everything we need
enabled is enabled to establish the protocol. We are almost done with the first port’s
protocol config! Note: Your IP addresses are different from what you see here.
Remember to use the table at the back of the manual. Add the following to your script:
© IXIA 2013
Tcl Automation with IxNetwork 55
6. One last thing that we want to do with this protocol config. We want to advertise routes
so we must configure a route range. We will create 10 routes on our emulated router.
Note: DO NOT copy the route IP directly on this page. You MUST use the table provided
in the back of the book for your student ID. Add the following to your script:
7. Next we need to configure the 2nd port. For this part, we are NOT going to provide all of
the code. What you should do is copy the code you have for the first port and paste it to
the end of your script.
8. Next, you will need to make sure to change all the references to your first port to the
references for your second port. You will also need to change all your “interface1” to
“interface2”, etc.
9. If you would like the code instead, please ask your instructor who will provide a sample
handout.
10. Once you have finished, let’s run script and see what you get. This time we are going to
source our whole script and see how it affects our IxNetwork Tcl Server.
11. To source your script, first make sure it is saved. Then open your Wish Console if it isn’t
already open. From here, go to the File menu at the top of the Wish window, and select
source from the drop-down menu. Navigate to your script to select it.
12. Because we are not running interactively, you won’t see much happen in the Wish
Console. However, you should see the following in the IxNetwork Tcl Server.
13. Now let’s see if we can start the protocol manually. At the top of the IxNetwork Tcl
Server window, you should see 2 buttons, one that says “Protocols” and one that says
“OSPF”. If you do not see these buttons, click on the “Protocol Configuration” option
from the resource tree. Click on either one of these buttons to start OSPF.
© IXIA 2013
Tcl Automation with IxNetwork 57
14. To see if our protocols come up correctly, we are going to manually enable a statistic to
see if our script has worked up to this point. In the Home menu of the Tcl Server, you
should see a button called “Test Options”. Click on this button to open the Test Options
dialog box.
15. From here, make sure you are looking at Stat View Options (button on left-hand side),
highlight OSPF and put a check in the checkboxes and then hit Close.
16. Now, click the button to start the protocol if you have not done so. To see the stats we
just enabled you may need to click the button called “Global Protocol Statistics” and put
a check box next to the OSPF stats. This will build the stat views.
© IXIA 2013
Tcl Automation with IxNetwork 59
17. If the protocol establishes correctly, you should see the following stat views:
Overview
Once your protocols are configured, once you start them, you could be done in theory. A lot of
customers of Ixia use IxNetwork to simply configure, start and establish protocols. However, one of
the benefits of IxNetwork is the ability to run traffic over your routing protocol topologies. This
isn’t strictly required, but is very common. In this module, we will create traffic, and then manually
start the traffic to see if it works. In a later lab, we will add commands to the script to
programmatically start and stop traffic.
© IXIA 2013
Tcl Automation with IxNetwork 63
© IXIA 2013
Tcl Automation with IxNetwork 65
© IXIA 2013
Tcl Automation with IxNetwork 67
© IXIA 2013
Tcl Automation with IxNetwork 69
Overview
Once your protocols are configured, once you start them, you could be done in theory. A lot of
customers of Ixia use IxNetwork to simply configure, start and establish protocols. However, one of
the benefits of IxNetwork is the ability to run traffic over your routing protocol topologies. This
isn’t strictly required, but is very common. In this module, we will create traffic, and then manually
start the traffic to see if it works. In a later lab, we will add commands to the script to
programmatically start and stop traffic.
Objectives
At the end of this lab, students will be able to:
• Creating IxNetwork L2/L3 Traffic
• Apply the traffic Item to the port
• Manually start the traffic in the IxNetwork Tcl Server for troubleshooting
Test Topology
See Figure 1 for the topology of this test. This topology diagram shows the physical wiring and
layout of the Ixia chassis, as well as the devices that are used for running the tests.
© IXIA 2013
Tcl Automation with IxNetwork 71
Lab Procedure
1. We have configured our ports and configured our routing protocol topology. Now let’s
create some traffic to send across this routing protocol topology. For the purpose of this
class, we will keep the traffic configuration pretty simple. To start, let’s add a pause to
the script to make sure the protocol config has time to commit to the ports. We will use
the Tcl after command for this. Here we will add 10 seconds. Add this command after
your protocol configuration section:
after 10000
2. Next we will add a traffic item to the root of this program. Add the following commands
to the end of your script:
ixNet commit
3. Next we will create an endpoint set (the sources and destinations for our traffic). Add
the following commands to the end of your script:
4. Now we must generate this traffic item on the Ixia port. Remember that Tcl scripts are
designed to run as fast as they can, so we are going to add some “sleep” time into our
script using the Tcl after command. Add the following command to your script:
5. In order for our script to be able to finish this exec before the next set of commands, we
will add a Tcl “after” command of 5 seconds to complete the exec. Add the following
command to your script:
after 5000
6. Save your script and let’s source it again. If you don’t have the IxNetwork Tcl Server
open, you should open it so you can see what affects these new commands will have on
our script. Remember to use the File menu in the Wish Console to source the script.
7. Once you have sourced the script, your IxNetwork Tcl Server should look like the
following screen captures.
© IXIA 2013
Tcl Automation with IxNetwork 73
8. Now let’s manually start the traffic to see if it works. We will add commands in a later
lab to start and stop traffic manually. First let’s make sure we have a stat view for the
port statistics. To do so, click on the Traffic Statistics button and make sure to select
Port Statistics from the dialog box that opens.
9. No to actually start the traffic and see the results. Click the “Start Traffic” button at the
top of the home menu and look at the “Port Stats” tab to see if you are sending and
receiving your traffic.
© IXIA 2013
Tcl Automation with IxNetwork 75
Note: the number of frames you see here will be different from this screen
capture!
Overview
We’ve done a lot so far! This next module is critical but will be very short. The commands that you
need to start and stop protocols and traffic are few, but very important. Generally you will add
commands to start the protocol(s) and then you will give your script enough time for the protocols
to establish. After the protocols are up and running, you will add commands to start and stop traffic.
The default is that the traffic will send until you manually stop the traffic, so we will add both start
and stop commands to our script.
© IXIA 2013
Tcl Automation with IxNetwork 77
© IXIA 2013
Tcl Automation with IxNetwork 79
© IXIA 2013
Tcl Automation with IxNetwork 81
Overview
We’ve done a lot so far! This next module is critical but will be very short. The commands that you
need to start and stop protocols and traffic are few, but very important. Generally you will add
commands to start the protocol(s) and then you will give your script enough time for the protocols
to establish. After the protocols are up and running, you will add commands to start and stop traffic.
The default is that the traffic will send until you manually stop the traffic, so we will add both start
and stop commands to our script.
In this lab we will do everything programmatically except analyze the stats. We will add commands
in the next lab to analyze the results. In this lab, we will use the IxNetwork Tcl Server to see the
results.
Objectives
At this end of this lab, students will be able to:
Lab Procedure
1. We need to start the OSPF protocol. Since OSPF is the only protocol we have configured we
will use a command that will start all the protocols. At the end of the script add the
following command:
2. Just to have some clue as to when this will start in our script, we will add an explicit puts
command and an update when these protocols start. Add the following command:
3. Now we need to add time to the script to establish the protocols. We will add 45 seconds to
our script to make sure the protocols are up and running before starting and stopping
traffic. Add the following command:
after 45000
4. Now we will apply and start our traffic and add another message to print to our console
when the traffic has started. Add the following commands:
5. We will run this traffic for 20 seconds and then we will stop the traffic. Add the following
commands:
after 20000
ixNet exec stop $traffic
© IXIA 2013
Tcl Automation with IxNetwork 83
6. Now let’s source our script and see what happens! Make sure you use the File menu to
source the file. Go to the IxNetwork Tcl Server to see what happens. Make sure you look at
the traffic stats “port statistics” to see if it works. It should look something like the
following:
© IXIA 2013
Tcl Automation with IxNetwork 85
Overview
Our script is nearly fully functional! However, we do not have any code for analyzing the results of
the test. IxNetwork API provides access to pre-defined statistics. However, you must first enable
the stat view and then extrapolate the results. You can access as many or as few statistics as you
need to in your script.
In this lab, we will first specify the stats we are interested in printing out to the console window and
we will format those stats to display. We will do this with only a couple of statistics in the lab, but
in theory, this could be ported to many stats, as long as you know how to access the stat view you
are interested in.
© IXIA 2013
Tcl Automation with IxNetwork 87
© IXIA 2013
Tcl Automation with IxNetwork 89
© IXIA 2013
Tcl Automation with IxNetwork 91
© IXIA 2013
Tcl Automation with IxNetwork 93
© IXIA 2013
Tcl Automation with IxNetwork 95
Overview
Our script is nearly fully functional! However, we do not have any code for analyzing the results of
the test. IxNetwork API provides access to pre-defined statistics. However, you must first enable
the stat view and then extrapolate the results. You can access as many or as few statistics as you
need to in your script.
In this lab, we will first specify the stats we are interested in printing out to the console window and
we will format those stats to display. We will do this with only a couple of statistics in the lab, but
in theory, this could be ported to many stats, as long as you know how to access the stat view you
are interested in.
Objectives
At the end of this lab, students will be able to:
• Create a statistic view object
• Parse the stats in the view
• Use Tcl formatting options to display the pertinent stats
• Create a Tcl proc for querying stats
Lab Procedure
1. The last command we added in the previous lab was a stop traffic command. You always
want to add sleep time to your script after you stop transmit but before you start querying
stats to make sure your stats have settled in each of the ports. This can be done by adding
the following to the end of your script:
after 3000
2. Now we need to add a child object of the root object to create the view. This view will later
be populated with the stats we specify. Add the following commands to your script:
3. To actually enable the stat view, you have to add a couple more lines. Add the following
command to your script:
© IXIA 2013
Tcl Automation with IxNetwork 97
4. Next we will build a Tcl procedure to simplify future stat calls. This is not programmatically
necessary, but it is cleaner code. This is a long procedure, so be careful when typing it out.
Add the following block of code to your script:
5. Once the procedure is created, you need to call it. Creating and calling Tcl procedures are
two different steps. You don’t have to call the procedure immediately after creating it, but
you should make sure to call it after you have completed your sends and receives. Let’s add
the line of code necessary to call your procedure. Add the following command to your
script:
GetResults $view
6. Now let’s go back to the beginning, source the entire script and see if it works! Remember
to launch your IxNetwork Wish Console and use the File menu to source your script. Make
sure you’ve saved it!
7. If it all works as planned, you should see it look something like this. Remember that the
number of frames you end up sending and receiving will be different than what you see in
the screen capture below.
© IXIA 2013
Tcl Automation with IxNetwork 99
Overview
Scriptgen is a built-in tool for generating Tcl scripts out of your IxNetwork’s current configuration.
Up until now, we have written our script from scratch. This was necessary to understand the parts
of a script and the necessary structure and order of the commands. However, in the future, you
may never start with a blank page in a text editor. You might start by configuring in the IxNetwork
GUI and generating a Tcl script. This script can then be sourced from the Wish Console. Because it
is Tcl code, it can be modified to best fit your needs, or you can add looping constructs or
conditional statements for cleaner code. Either way, using Scriptgen you will not have have to write
all of your scripts from scratch.
© IXIA 2013
Tcl Automation with IxNetwork 101
© IXIA 2013
Tcl Automation with IxNetwork 103
© IXIA 2013
Tcl Automation with IxNetwork 105
Overview
Scriptgen is a built-in tool for generating Tcl scripts out of your IxNetwork’s current configuration.
Up until now, we have written our script from scratch. This was necessary to understand the parts
of a script and the necessary structure and order of the commands. However, in the future, you
may never start with a blank page in a text editor. You might start by configuring in the IxNetwork
GUI and generating a Tcl script. This script can then be sourced from the Wish Console. Because it
is Tcl code, it can be modified to best fit your needs, or you can add looping constructs or
conditional statements for cleaner code. Either way, using Scriptgen you will not have have to write
all of your scripts from scratch.
Objectives
At this end of this lab, students will be able to:
© IXIA 2013
Tcl Automation with IxNetwork 107
Lab Procedure
1. After having completed the 5 previous labs in this class, you should have a fully function Tcl
script. We will use the configuration this script created with Scriptgen.
If you have not already done so, make sure the IxNetwork Tcl Server is running. If it is not,
relaunch it by going to:
2. From here, make sure you have run the Tcl script you created over the past 5 labs. To do
this, launch the IxNetwork Wish Console (in the same location) and then use the File menu
in the Wish Console to navigate to and run your Tcl script.
3. When this script has completed, open up the IxNetwork Tcl Server GUI so that you can see
the configuration the script created.
4. Now that you’ve done all of this, you are ready to run Scriptgen. First, you have to go to the
Automation Tab of the GUI.
5. Once the dialog box opens, you need to give your Scriptgen script a name. Select the Browse
button in the top right of the window and then give your script a unique name. For
example: script_xx.tcl (where the xx are your student number or your initials).
© IXIA 2013
Tcl Automation with IxNetwork 109
6. Once you hit Save, it will bring you back to the Scriptgen Dialog box. Check or uncheck
boxes to match the screen capture below:
7. When you are done editing the settings, you can click OK. You won’t see much happen as we
specifically told Scriptgen not to launch a text editor. To see the Tcl script you generated,
you need to launch Notepad, navigate to your script and open it. Remember that the script
has a Tcl extension, so if you don’t change the file type to “All Files”, you won’t be able to
find it.
8. Open the file so that you can see what Scriptgen created for you. This will look A LOT like
the script you wrote, however, there is a lot more code. The reason is that Scriptgen will
include a lot of the options in the script, even if you did not make any changes to those
values. Here is the beginning of a Scriptgen script for reference.
© IXIA 2013
Tcl Automation with IxNetwork 111
9. Now, to re-run the Tcl script, you can source it just like you did in your previous labs. I
would start by loading an empty config in IxNetwork Tcl Server so that you don’t just
append your scriptgen config to any config that is sitting around. To do this, just click on the
“New” button at the top of the IxNetwork Tcl Server window.
10. After you source your file, you should end up with the GUI looking something like this.
11. From you, this Tcl script is yours to do what you need to with it. Scriptgen will save you a
lot of manual scripting.
Port Assignments
XMV-16 STXS-4
User Port 1 Port 2 Port 1 Port 2
1 1 1 1 2 1 1 1 2
2 1 3 1 4 1 3 1 4
3 1 5 1 6 2 1 2 2
4 1 7 1 8 2 3 2 4
5 1 9 1 10 3 1 3 2
6 1 11 1 12 3 3 3 4
7 1 13 1 14 4 1 4 2
8 1 15 1 16 4 3 4 4
9 2 1 2 2 5 1 5 2
10 2 3 2 4 5 3 5 4
11 2 5 2 6 6 1 6 2
12 2 7 2 8 6 3 6 4
13 2 9 2 10 7 1 7 2
14 2 11 2 12 7 3 7 4
15 2 13 2 14 8 1 8 2
16 2 15 2 16 8 3 8 4
© IXIA 2013
Tcl Automation with IxNetwork 115