0% found this document useful (0 votes)
58 views119 pages

TCL Automationwith Ix Network Sept 2013

Uploaded by

Diego de Leon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views119 pages

TCL Automationwith Ix Network Sept 2013

Uploaded by

Diego de Leon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 119

Automation with IxNetwork

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.

Corporate Headquarters Ixia Worldwide Headquarters Web site: www.ixiacom.com


26601 W. Agoura Rd. General: [email protected]
Calabasas, CA 91302 Investor Relations: [email protected]
USA Training: [email protected]
(877) FOR IXIA (877-367-4942) Support: [email protected]
+1 (818) 871-1800 (International)
(FAX) +1 (818) 871-1805
[email protected]
EMEA Ixia Europe Limited Support: [email protected]
Part 2nd floor +44 1869 356370 (Option 5)
Clarion House, Norreys Drive
Maidenhead SL6 4FL
United Kingdom+44 1869 356370
Fax: +44 1628 39916
[email protected]

Asia Pacific Ixia Asia Pacific Representative Office Support: [email protected]


New Shanghai International Tower, Suite 26E +1 (818) 871-1800
360 Pudong Nan Rd.
Shanghai 200120
China
+86 21 50543439
[email protected]
Japan Ixia KK Support: [email protected]
Aioi Sampo Shinjuku Building, 16th Floor 3-25- +1 (818) 871-1800
3 Yoyogi Shibuya-Ku
Tokyo, 151-0053
Japan
+81 3 5365 4690
(FAX) +81 3 3299 6263
[email protected]
India Ixia India Support:[email protected]
7th Floor Umiya Bay +91 80 49396408
Cessna Business Park
Outer Ring Road
Bangalore - 560037
Karnataka,India
+91 80 49396400
[email protected]

Sept 2013
Tcl Automation with IxNetwork i

Table of Contents

Automation with IxNetwork Introduction 1


Module 1 – Getting Started with IxNetwork Tcl API 3
Lab 1: Loading Libraries and Working with Cards and Ports 29
Module 2 – Configuring Protocols 36
Lab 2: Configuring OSPF on the Ixia Ports 50
Module 3 – Creating IxNetwork Traffic 61
Lab 3: Configuring IxNetwork Traffic 69
Module 4 – Starting and Stopping Protocols/Traffic 76
Lab 4: Starting and Stopping Protocols/Traffic 81
Module 5 – Working with IxNetwork Statistics 85
Lab 5: Working with IxNetwork Statistics 95
Module 6 – IxNetwork Scriptgen 99
Lab 6: IxNetwork Scriptgen 106
Appendix A Parameter Tables 113

Tcl Automation with IxNetwork


Automation with IxNetwork 1

Automation with IxNetwork Introduction

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.

Tcl Automation with IxNetwork


2 Tcl Automation with IxNetwork

Sept 2013
Tcl Automation with IxNetwork 3

Module 1 – Getting Started with IxNetwork Tcl API

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.

Lab 1 – Getting Started with IxNetwork API


4 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 5

Lab 1 – Getting Started with IxNetwork API


6 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 7

Lab 1 – Getting Started with IxNetwork API


8 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 9

Lab 1 – Getting Started with IxNetwork API


10 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 11

Lab 1 – Getting Started with IxNetwork API


12 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 13

Lab 1 – Getting Started with IxNetwork API


14 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 15

Lab 1 – Getting Started with IxNetwork API


16 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 17

Lab 1 – Getting Started with IxNetwork API


18 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 19

Lab 1 – Getting Started with IxNetwork API


20 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 21

Lab 1 – Getting Started with IxNetwork API


22 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 23

Lab 1 – Getting Started with IxNetwork API


24 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 25

Lab 1 – Getting Started with IxNetwork API


26 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 27

Lab 1 – Getting Started with IxNetwork API


28 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 29

Lab 1: Loading Libraries and Working with Cards and Ports

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

Lab 1 – Getting Started with IxNetwork API


30 Tcl Automation with IxNetwork

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.

Figure 1: Port Management Topology

© IXIA 2013
Tcl Automation with IxNetwork 31

Description of Lab Procedure


This test procedure will consist of the following major steps as listed below.
A. Load IxNetwork library
B. Connect to the IxNetwork Tcl Server
C. Create the root object to start program
D. Figure out what cards and ports we have
E. Configure 2 ports

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:

package require IxTclNetwork

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:

ixNet connect localhost -port 8009 -version 6.20

Lab 1 – Getting Started with IxNetwork API


32 Tcl Automation with IxNetwork

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:

ixNet exec newConfig

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:

set top [ixNet getRoot]


set chas [ixNet add $top/availableHardware chassis]
ixNet setAttribute $chas -hostname 10.205.6.68
ixNet commit
set chas [ixNet remapIds $chas]

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:

set availableCards [ixNet getList $chas card]


set mycard [lindex $availableCards 0]
set availablePorts [ixNet getList $mycard port]
set port1 [lindex $availablePorts 0]
set port2 [lindex $availablePorts 1]

© 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:

set vport1 [ixNet add $top vport]


ixNet setAttribute $vport1 -connectedTo $port1
set vport2 [ixNet add $top vport]
ixNet setAttribute $vport2 -connectedTo $port2
ixNet commit

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:

Lab 1 – Getting Started with IxNetwork API


34 Tcl Automation with IxNetwork

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.

<END OF LAB 1>

Lab 1 – Getting Started with IxNetwork API


36 Tcl Automation with IxNetwork

Module 2 – Configuring Protocols

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

Module 2 – Configuring Protocols


38 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 39

Module 2 – Configuring Protocols


40 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 41

Module 2 – Configuring Protocols


42 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 43

Module 2 – Configuring Protocols


44 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 45

Module 2 – Configuring Protocols


46 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 47

Module 2 – Configuring Protocols


48 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 49

Module 2 – Configuring Protocols


50 Tcl Automation with IxNetwork

Lab 2: Configuring OSPF on the Ixia Ports

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.

Figure 2: Port Management Topology

Module 2 – Configuring Protocols


52 Tcl Automation with IxNetwork

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:

ixNet setMultiAttrs $vport1/protocols/ospf \


-enabled True \
-rateControlInterval 0

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:

set interface1 [ixNet add $vport1 interface]


ixNet setMultiAttrs $interface1 \
-description {20.3.1.2/24 - 211:219 - 1} \
-enabled True
set interface1 [lindex [ixNet remapIds $interface1] 0]

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:

set ipv4 [ixNet add $interface1 ipv4]


ixNet setMultiAttrs $ipv4 \
-gateway 20.3.1.1 \
-ip 20.3.1.2 \
-maskWidth 24
ixNet commit
set ipv4 [lindex [ixNet remapIds $ipv4] 0]

4. We will configure an emulated router on our newly configured interface. Add the
following commands to your script:

set router [ixNet add $vport1/protocols/ospf router]


ixNet setMultiAttrs $router \
-discardLearnedLsa True \
-enabled True \
-generateRouterLsa True \
-routerId 20.3.1.2 \
-trafficGroupId ::ixNet::OBJ-null
ixNet commit
set router [lindex [ixNet remapIds $router] 0]
set vport1 $router

Module 2 – Configuring Protocols


54 Tcl Automation with IxNetwork

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:

set interface1 [ixNet add $vport1 interface]


ixNet setMultiAttrs $interface1 \
-areaId 0\
-enabled True \
-connectedToDut True \
-interfaceIpAddress 20.3.1.2 \
-interfaceIpMaskAddress 255.255.255.0 \
-interfaceType {Protocol Interface} \
-interfaces $interface1 \
ixNet setMultiAttrs $interface1/learnedFilter \
-linkStateId 0.0.0.0 \
-howExternalAsLsa True \
-showNetworkLsa True \
-showNssaLsa True \
-showOpaqueAreaLsa True \
-showOpaqueDomainLsa True \
-showOpaqueLocalLsa True \
-showRouterLsa True \
-showSummaryAsLsa True \
-showSummaryIpLsa True
ixNet commit
set interface1 [lindex [ixNet remapIds $interface1] 0]

© 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:

set routeRange [ixNet add $vport1 routeRange]


ixNet setMultiAttrs $routeRange \
-enabled True \
-mask 24 \
-metric 15 \
-networkNumber 200.1.1.0 \
-numberOfRoutes 10 \
-origin area
ixNet commit
set routeRange [lindex [ixNet remapIds $routeRange] 0]

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.

Module 2 – Configuring Protocols


56 Tcl Automation with IxNetwork

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.

Module 2 – Configuring Protocols


58 Tcl Automation with IxNetwork

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:

<END OF LAB 2>

Module 2 – Configuring Protocols


Tcl Automation with IxNetwork 61

Module 3 – Creating IxNetwork Traffic

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.

Module 3 – Configuring IxNetwork Traffic


62 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 63

Module 3 – Configuring IxNetwork Traffic


64 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 65

Module 3 – Configuring IxNetwork Traffic


66 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 67

Module 3 – Configuring IxNetwork Traffic


68 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 69

Lab 3: Configuring IxNetwork Traffic

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

Module 3 – Configuring IxNetwork Traffic


70 Tcl Automation with IxNetwork

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:

set trafficItem [ixNet add [ixNet getRoot]/traffic


trafficItem]
ixNet setMultiAttrs $trafficItem \
-name {Traffic Item 1} \
-allowSelfDestined False \
-trafficItemType l2L3 \
-mergeDestinations True \
-egressEnabled False \
-srcDestMesh oneToOne \
-enabled True \
-routeMesh oneToOne \
-transmitMode interleaved \
-biDirectional False \
-trafficType {ipv4} \
-hostsPerNetwork 1

ixNet commit

set trafficItem [lindex [ixNet remapIds $trafficItem] 0]


set trafficItem $trafficItem

Module 3 – Configuring IxNetwork Traffic


72 Tcl Automation with IxNetwork

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:

set endpointSet1 [ixNet add $trafficItem endpointSet]


ixNet setMultiAttrs $endpointSet1 \
-destinations $vport2 \
-name {EndpointSet-1} \
-sources $vport1 \
-sourceFilter {} \
-destinationFilter {} \
-trafficGroups {}
ixNet commit
set endpointSet1 [lindex [ixNet remapIds $endpointSet1] 0]

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:

ixNet exec generate $trafficItem

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

Module 3 – Configuring IxNetwork Traffic


74 Tcl Automation with IxNetwork

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!

<End of Lab 3>

Module 3 – Configuring IxNetwork Traffic


76 Tcl Automation with IxNetwork

Module 4 – Starting and Stopping Protocols/Traffic

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

Module 4: Starting and Stopping Protocols/Traffic


78 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 79

Module 4: Starting and Stopping Protocols/Traffic


80 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 81

Lab 4: Starting and Stopping Protocols/Traffic

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:

• Start the OSPF protocol on the port


• Factor in sleep time to allow protocol to establish
• Start the L2/L3 traffic
• Send traffic for 20 seconds
• Stop the L2/L3 traffic
• See the stats in the GUI

Module 4: Starting and Stopping Protocols/Traffic


82 Tcl Automation with IxNetwork

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:

ixNet exec startAllProtocols

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:

puts “Starting protocols now”


update

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:

set traffic [ixNet getRoot]/traffic


puts "Apply traffic"
update
ixNet exec apply $traffic

puts "Start traffic"


update

ixNet exec start $traffic

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:

<END OF LAB 4>

Module 4: Starting and Stopping Protocols/Traffic


84 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 85

Module 5 – Working with IxNetwork Statistics

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.

Module 5 – Working with IxNetwork Statistics


86 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 87

Module 5 – Working with IxNetwork Statistics


88 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 89

Module 5 – Working with IxNetwork Statistics


90 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 91

Module 5 – Working with IxNetwork Statistics


92 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 93

Module 5 – Working with IxNetwork Statistics


94 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 95

Lab 5: Working with IxNetwork Statistics

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

Module 5 – Working with IxNetwork Statistics


96 Tcl Automation with IxNetwork

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:

set viewList [ixNet getList [ixNet getRoot]/statistics view]


set portStatsViewIndex [lsearch -regexp $viewList "Port
Statistics"]
set view [lindex $viewList $portStatsViewIndex]

3. To actually enable the stat view, you have to add a couple more lines. Add the following
command to your script:

ixNet setAttribute $view -enabled true


ixNet commit

© 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:

proc GetResults {view} {


set columnList [ixNet getAttribute ${view}/page -columnCaptions]
set FrameTxIndex [lsearch -regexp $columnList "Frames Tx."]
set FrameRxIndex [lsearch -regexp $columnList "Valid Frames Rx."]
puts "[format "%-30s %-20s %-20s" "Stat Name" "Frms Tx." "Valid Frms Rx."]"
puts "----------------------------------------------------------------"

set totalPages [ixNet getAttribute $view/page -totalPages]

for {set currPage 1} {$currPage <= $totalPages} {incr currPage} {


ixNet setAttribute $view/page -currentPage $currPage
ixNet commit
while {[ixNet getAttribute $view/page -isReady] != true} {
after 500
}

set pageList [ixNet getAttribute $view/page -rowValues]

for {set pageListIndex 0} {$pageListIndex < [llength $pageList]} {incr \


pageListIndex} {
set rowList [lindex $pageList $pageListIndex]

for {set rowIndex 0} {$rowIndex < [llength $rowList]} {incr rowIndex} {


set cellList [lindex $rowList $rowIndex]
set StatName [lindex $cellList 0]
set TxFrame [lindex $cellList $FrameTxIndex]
set RxFrame [lindex $cellList $FrameRxIndex]
puts "[format "%-30s %-20s %-20s" $StatName $TxFrame $RxFrame]"
}
}
}
}

Module 5 – Working with IxNetwork Statistics


98 Tcl Automation with IxNetwork

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.

<End of Lab 5>

© IXIA 2013
Tcl Automation with IxNetwork 99

Module 6 – IxNetwork Scriptgen

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.

Module 6 – IxNetwork Scriptgen


100 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 101

Module 6 – IxNetwork Scriptgen


102 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 103

Module 6 – IxNetwork Scriptgen


104 Tcl Automation with IxNetwork

© IXIA 2013
Tcl Automation with IxNetwork 105

Module 6 – IxNetwork Scriptgen


106 Tcl Automation with IxNetwork

Lab 6: IxNetwork Scriptgen

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:

• Open the IxNetwork Tcl Server (if it is not already open)


• Run the script that you’ve created over the past few labs
• Launch and configure Scriptgen
• Generate a Tcl Script
• Re-run the script in the Wish Console

© 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:

Start/Programs/Ixia/IxNetwork/IxNetwork(version)/IxNetwork Tcl Server

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.

Module 6 – IxNetwork Scriptgen


108 Tcl Automation with IxNetwork

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.

Module 6 – IxNetwork Scriptgen


110 Tcl Automation with IxNetwork

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.

<End of Lab 6>

Module 6 – IxNetwork Scriptgen


Tcl Automation with IxNetwork 113

Appendix A Parameter Tables

Port Assignments
XMV-16 STXS-4
User Port 1 Port 2 Port 1 Port 2

Card/Slot Port Card/Slot Port Card/Slot Port Card/Slot Port

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

Appendix A: Parameter Tables


114 Tcl Automation with IxNetwork

OSPF Lab Parameter Table


TESTER (Ixia)
Gateway
User Port
Address First Network in
First IP Address
Route Range

1 Port 1 20.3.1.1 20.3.1.2/24 200.1.1 .0/24


Port 2 20.3.2.1 20.3.2.2/24 203.1.1 .0/24

2 Port 1 20.3.3.1 20.3.3.2/24 200.2.1 .0/24


Port 2 20.3.4.1 20.3.4.2/24 203.2.1 .0/24

3 Port 1 20.3.5.1 20.3.5.2/24 200.3.1 .0/24


Port 2 20.3.6.1 20.3.6.2/24 203.3.1 .0/24

4 Port 1 20.3.7.1 20.3.7.2/24 200.4.1.0/24


Port 2 20.3.8.1 20.3.8.2/24 203.4.1 .0/24

5 Port 1 20.3.9.1 20.3.9.2/24 200.5.1 .0/24


Port 2 20.3.10.1 20.3.10.2/24 203.5.1 .0/24

6 Port 1 20.3.11.1 20.3.11.2/24 200.6.1.0/24


Port 2 20.3.12.1 20.3.12.2/24 203.6.1 .0/24

7 Port 1 20.3.13.1 20.3.13.2/24 200.7.1 .0/24


Port 2 20.3.14.1 20.3.14.2/24 203.7.1 .0/24

8 Port 1 20.3.15.1 20.3.15.2/24 200.8.1.0/24


Port 2 20.3.16.1 20.3.16.2/24 203.8.1 .0/24

9 Port 1 20.3.17.1 20.3.17.2/24 200.9.1 .0/24


Port 2 20.3.18.1 20.3.18.2/24 203.9.1 .0/24

10 Port 1 20.3.19.1 20.3.19.2/24 200.10.1.0/24


Port 2 20.3.20.1 20.3.20.2/24 203.10.1.0/24

11 Port 1 20.3.21.1 20.3.21.2/24 200.11.1.0/24


Port 2 20.3.22.1 20.3.22.2/24 203.11.1.0/24

12 Port 1 20.3.23.1 20.3.23.2/24 200.12.1.0/24


Port 2 20.3.24.1 20.3.24.2/24 203.12.1.0/24

13 Port 1 20.3.25.1 20.3.25.2/24 200.13.1.0/24


Port 2 20.3.26.1 20.3.26.2/24 203.13.1.0/24

14 Port 1 20.3.27.1 20.3.27.2/24 200.14.1.0/24


Port 2 20.3.28.1 20.3.28.2/24 203.14.1.0/24

15 Port 1 20.3.29.1 20.3.29.2/24 200.15.1.0/24


Port 2 20.3.30.1 20.3.30.2/24 203.15.1.0/24
Port 1 20.3.31.1 20.3.31.2/24 200.16.1.0/24
16
Port 2 20.3.32.1 20.3.32.2/24 203.16.1.0/24

© IXIA 2013
Tcl Automation with IxNetwork 115

Appendix A: Parameter Tables

You might also like