Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
Generating traffic for network testing

"Why do you have a random number generator in a scientific language" ask some newcomers to the world of programming ... "shouldn't programming be an exact science?". Well yes, and no. It turns out that a random number generator is exceedingly useful in some instances. Here's a real, live example from last week.

In order to test a computer network under load, packets of [[noise]] must be sent between two devices up to the capacity of the line. Rather than have all of the packets of the same size, which would be unnatural, the packets have to be a mixture of small ones (80% of the data must be in small packets), medium size ones (5% of the data) and large ones (the final 15% of the data).

The first - obvious - way to generate the data is 80 small packets, 5 medium ones and 15 big ones. That's wrong - you need to adjust the proportions, increasing the number of small packets and decreasing the number of big ones, since it's the amount of data, not the number of packets that we're looking at. But then even that's going to give a distorted set of traffic with a large batch of small packets followed by a number of medium ones and a number of larger ones. The overall distribution will be correct, but the test results will be broken due to the false patterns in the noise data.

The next approach is, indeed, to bring in random numbers. You start by working out the proportion of PACKETS of each size that are needed to generate the appropriate amounts of DATA. You then take a series of random numbers between 0 and 1 (decimal numbers!) and you compare each random number to the series of proportions - perhaps up to 0.94, you'll send out a small packet, from 0.94 to 0.97 it will be a medium packet, and above that a large packet.

That's better - MUCH better. And indeed I wrote a Tcl proc to illustrate the algorithm during last week's course. Source code.

One of the problems with a program such as this is that it will never produce the same results twice - in one way, that's good as the traffic it represents is inherently different each time anyway, but on the other hand it means that any oddity you see as it is run won't be reproducable. So we can "seed" the random number generator - i.e. give it a know starting point / record the starting point so that we can, if we must, re-run a particular test case. And, yes, this technically means that it isn't random at all but rather pseudorandom.

Here's the result of me running my test code:

Dorothy:~/tcl grahamellis$ tclsh pk4.tcl
1185718234
80 3 15
79 5 15
29 10 59
62 9 7 1 5 12
Dorothy:~/tcl grahamellis$


Firstly, I reported the seed. Then the percentage of traffic in my test pattern of each of the 3 sizes (first three tests) and each of the six sizes (final test). Looks good - I have chosen NOT to output the full test sequence on my blog as it would make it rather long and extremely boring.

Where from here?

In practise, even a straight random distribution isn't perfect. Typically you'll have a long series of small packets after each big packet as the small packets are supposed to take line priority, and a number of them are likely to get queued while a medium or log packet is sent.

The you;ll be looking at traffic models where the bandwidth is less that 100% used, and you'll need to put random timing gaps in. Excecpt they won't be random, because once again after a long packet there's likely to be a backlog of smaller ones queue and - just like you find when you're waiting in line to check in at the airport - it can take a few minutes of flurried activity to clear the backlog once the check in agent has spend some considerable time sorting out the gentleman who brought along his wife's passort by mistake, or the lady who wants to travel on today's flight even though she failed to turn up with her unchangable ticket that had her booked for last Friday.
(written 2007-07-29)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
T206 - Tcl/Tk - Lists
  [4209] Lists in Tcl - fundamentals in a commented source code example - (2013-11-16)
  [3618] lists and struct::list in Tcl - Introduction to struct::list and examples - (2012-02-18)
  [3583] Expanding a list of parameters in Tcl - {*} and eval - (2012-01-17)
  [3582] Tcl collections - lists, dicts and array - (2012-01-16)
  [3415] User defined sorting and other uses of callbacks in Tcl and Tk - (2011-09-02)
  [3394] The difference between lists and strings - Tcl - (2011-08-16)
  [3285] Extracting data from a string / line from file - Tcl - (2011-05-10)
  [2472] split and join in tcl and expect - (2009-10-23)
  [2468] What are Tcl lists? - (2009-10-22)
  [1601] Replacing the last comma with an and - (2008-04-04)
  [1405] Sorting in Tcl - lists and arrays - (2007-10-24)
  [1402] Tcl - append v lappend v concat - (2007-10-23)
  [1334] Stable sorting - Tcl, Perl and others - (2007-09-06)
  [1282] Stringing together Tcl scripts - (2007-07-29)
  [781] Tcl - lappend v concat - (2006-06-27)
  [463] Splitting the difference - (2005-10-13)
  [144] Tcl sandwich - lists in Tcl - (2004-12-08)

T208 - Tcl/Tk - Arrays and dicts
  [3638] Sorting dicts and arrays in Tcl - (2012-03-04)
  [3614] Tcl - dicts - a tutorial and examples - (2012-02-14)
  [3192] Tcl - Some example of HOW TO in handling data files and formats - (2011-03-04)
  [2466] Tcl - passing arrays and strings in and back out of procs - (2009-10-22)
  [1614] When an array is not an array - (2008-04-17)
  [1427] Arrays in Tcl - a demonstration - (2007-11-10)
  [779] The fragility of pancakes - and better structures - (2006-06-26)
  [122] Passing arrays to procs in Tcl - (2004-11-18)


Back to
Stringing together Tcl scripts
Previous and next
or
Horse's mouth home
Forward to
An update on the West Wilts show ...
Some other Articles
Work and play at Well House Manor - Football and Shell Shortcuts
A wasted evening?
In the army, or in civvie street?
An update on the West Wilts show ...
Generating traffic for network testing
Latercomer to the technology
West Wilts - no longer Wet Wilts - show
The Gdansk fireball
West Wilts Show
4316 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/1283_Gen ... sting.html • PAGE BUILT: Thu Sep 18 15:30:25 2014 • BUILD SYSTEM: WomanWithCat