Skip to main content

Custom VuC functions: connectspeed

Roland Stens, Independent Consultant
Roland Stens is an independent consultant based in Vancouver, Canada, who specializes in QA and testing -- particularly performance and robustness testing. His background is in programming, system analysis, database and network management, testing, and project/test management. As an active participant in various forums related to performance testing, he shares his insights with other testers to help expand their knowledge and vision of the tools and testing processes. He is happy to answer questions by e-mail.

Summary:  This custom VuC function sets a random VU connection speed distributed normally over a range of predefined values. This function is part of a library of customized utilites and VuC functions created by experts in the testing community.

Date:  28 Apr 2004
Level:  Introductory
Activity:  197 views
Comments:  

Editor's note: This article is part of a library of custom VuC functions developed by performance test engineers to handle special situations encountered in scripting applications. For an overview of the library and links to other custom functions, see "A library of custom VuC functions."

The connectspeed function sets a random VU connection speed distributed normally over a range of predefined values.

Purpose/Use

In simulating a user model as realistically as possible, you need to consider user connection speeds. IBM® Rational® TestManager® offers standard ways to set the connection speed for each user group, and this functionality is enough for most purposes. But in more complex scenarios it can become quite a burden to correctly merge your connection speed requirements in your test suite.

That's why I developed the connectspeed function, which allows you to specify a range of speeds and the proportion of users connected at each speed. Thanks to this function, you no longer need to create user groups for the sole purpose of testing different connection speeds. Adding a range of connection speeds to your scripts becomes very simple.

My research indicated that the posted modem/connection speeds are hardly ever reached and that typically only 75% of the throughput is realized. In other words, if you have a 56.6 kilobits-per-second modem, the best throughput you can hope to realize is 42 Kbps. This is due to protocol overhead, other traffic, network hops, and line quality. To simulate connection speeds more realistically, we have to take this fact into account.

The connectspeed function uses the normdist function to create a normal distribution of the specified connection speeds. The peak of the normal distribution coincides with 75% of the posted connection speed, for the reason just mentioned. The result is a function that will provide a very "natural" spread of connection speeds.

The connectspeed function takes no parameters but does require you to create ten shared variables in your test suite (Speed1 to Speed10) relating to the different connection speeds you want to simulate. You can assign a weight to each of these variables to define how frequently the related speed should be chosen. It makes sense to choose weights that add up to 100 (as in 100%), but the function will accept any combination of numbers. Remember that the numbers are all relative to each other.

Table 1 shows the connection speeds represented by the shared variables in the connectspeed function as written. You can change these connection speeds by replacing them in the function code with the speeds you want.

Shared variableConnection speed (bps)Shared variableConnection speed (bps)
Speed128800Speed61000000
Speed256600Speed71540000
Speed3128000Speed83000000
Speed4256000Speed910000000
Speed5900000Speed10Unlimited

Table 1: Connection speeds represented by the shared variables

To set up the shared variables in your test suite, choose Suite > Edit Shared Variables in TestManager and enter the desired weights in the Shared Variable Settings window, as exemplified in Figure 1. You can add the connection speed in the comment field as a reminder of the speed the shared variable represents.

Setting up the shared variables in your test suite

Figure 1: Setting up the shared variables in your test suitee


Requirements

This function uses the normdist function.


Function Code

Here's the code for the connectspeed function, to be placed in your script or in a .h file:

/* Add these shared variables to your suite. 
You need as many variables as entries in 
your nSimulationSpeed array. */
shared int Speed1; //28800: The old 28.8 Kbps modem
shared int Speed2; //56600: The 56.6 Kbps modem
shared int Speed3; //128000: Single channel ISDN
shared int Speed4; //256000: Dual channel ISDN
shared int Speed5; //900000: Typical ADSL speed
shared int Speed6; //1000000: Typical cable speed
shared int Speed7; //1540000: T1
shared int Speed8; //3000000: 3Mbs
shared int Speed9; //10000000: 10Mbs
shared int Speed10; //Unlimited: Up to the maximum speed on your local connection

int func connectspeed()
{
int iSeed;
int iTemp;
int nCount;
/* Add the speeds you want to simulate to this array. */
int nSimulationSpeed\[\] =
{28800,
56600,
128000,
256000,
900000,
1000000,
1540000,
3000000,
10000000,
0};
int nSpeedWeight\[\];
//Place the shared variables in an array to be able to iterate
//through them.
nSpeedWeight\[0\] = Speed1;
nSpeedWeight\[1\] = Speed2;
nSpeedWeight\[2\] = Speed3;
nSpeedWeight\[3\] = Speed4;
nSpeedWeight\[4\] = Speed5;
nSpeedWeight\[5\] = Speed6;
nSpeedWeight\[6\] = Speed7;
nSpeedWeight\[7\] = Speed8;
nSpeedWeight\[8\] = Speed9;
nSpeedWeight\[9\] = Speed10;

/* Select a random number between 1 and the sum of the shared variable values 
*/
iSeed=uniform(1,Speed1+Speed2+Speed3+Speed4+Speed5+Speed6+Speed7+Speed8+Speed9
+Speed10);
nCount=0;
iTemp=0;
while(nCount<10)
{
   iTemp = iTemp + nSpeedWeight\[nCount\]; if (iSeed<=iTemp && 
nSpeedWeight\[nCount\]> 0)
   {
      if (nSimulationSpeed\[nCount\]==0)
         return 0;
      else    
return normdist(nSimulationSpeed\[nCount\]/2,nSimulationSpeed\[nCount\],(nSimulationSpeed
\[nCount\]- nSimulationSpeed\[nCount\]/2)/3);
   }

   nCount++;
}
}

The connectspeed function can be placed in each calling script immediately following the #include command, or it can go in a separate .h file referenced by an additional #include command. The function can then be put in either the test script section of the repository or the Rational Test include directory. Putting it in the latter location will give you the benefit of not having to copy this function into every repository you work with.

To use the connectspeed function, you need to put a reference to the normdist function in your test script. Place either one of the following #include statements just below the #include <vu.h> line at the top of your script:

#include <normdist.h> /* If normdist.h is in your c:\Program
Files\Rational\Rational Test\include directory */

or

#include "normdist.h" /* If normdist.h is in your repository's script
Directory */


Command Syntax

int connectspeed()

To set the connection speed per virtual user for the whole suite, insert the following code in the first script of a suite before your first emulation command:

/*** All you need to set the connection speed for a script ***/
{int iSpeed;}
iSpeed= connectspeed();
push Line_speed = iSpeed;
printf("Connection Speed is %d.\n", iSpeed);
/********************************************************/

And don't forget to include

pop Line_speed;

at the end of the last script in your suite to remove the value of the VU environment variable Line_speed from the top of the stack.


Examples of Use

As an example of how connectspeed works, consider the scenario for simulation shown in Table 2.

Connection speed (bps)WeightConnection speed (bps)Weight
288005100000015
5660015154000030
128000130000002
2560000100000000
90000010Unlimited0

Table 2: A scenario for simulating different connection speeds

When we apply the connectspeed function with these weights assigned, the actual speeds used in our simulation will resemble the graphic representation in Figure 2.

Spread of connection speeds when connectspeed is applied

Figure 2: Spread of connection speeds when connectspeed is applied

It's very clear that both the weighting and the normal distribution have been applied.


About the author

Roland Stens is an independent consultant based in Vancouver, Canada, who specializes in QA and testing -- particularly performance and robustness testing. His background is in programming, system analysis, database and network management, testing, and project/test management. As an active participant in various forums related to performance testing, he shares his insights with other testers to help expand their knowledge and vision of the tools and testing processes. He is happy to answer questions by e-mail.

Comments



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=4287
ArticleTitle=Custom VuC functions: connectspeed
publish-date=04282004
author1-email=rstens@shaw.ca
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers