From Cng1wiki

Revision as of 12:51, 16 June 2009 by Vallati (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<analytics uacct="UA-1580095-2" ></analytics>

The Network Simulator 2 (ns2) is an open source tool for network simulation. When planning for large-scale simulation experiments, an efficient and flexible data collection and a statistically sound output data analysis are important aspects to keep in mind. Unfortunately, ns2 offers little support for data collection, and statistical analysis of the simulation results is most often performed offline, using either home made code or available packages, which are not integrated with ns2.

In this site, you will find two complementary contributions:

  • the first one consists of a set of C++ modules, that allow a flexible and efficient data collection;
  • the second one is a software framework, which is fully integrated with ns2, which performs all the operations required to carry out simulation experiments in a statistically sound way.

Our framework allows a user to significantly reduce the post-processing overhead and to save simulation time, especially with large-scale simulations.

If you use our extension for your research, we would appreciate if you could cite the following reference:

   An Integrated Framework for Enabling Effective
   Data Collection and Statistical Analysis with ns2
   Claudio Cicconetti, Enzo Mingozzi, Giovanni Stea
   Workshop on ns-2: the IP network simulator (WNS2)
   Pisa, Italy, October 10, 2006.

IMPORTANT NOTICE We have recently enhanced our tools to collect measures in ns-2, which can be downloaded as a stand-alone package here (the utilities are included in the patch below). Changes include:

  • Metrics can be enabled/disabled via Tcl. It is not anymore necessary to define metrics at compile time in the common/statconf.h file, which has thus been removed.
  • New types of metrics have been added, i.e. 'counter' (which stores the sum of the samples collected during simulation) and 'traced' (which print all the samples collected during simulation, along with a timestamp of when they were collected, on a trace file, mostly intended for debugging purposes)
  • The current value of any measure can be retrieved from the statistics collector object
  • The user can now define a function which is called at the end of simulation to perform operations on the samples collected. This is mostly useful if the user needs to cross-check the collected measures for debugging purposes or needs to derive composed metrics which involve a combination of the values obtained by different measure probes.
  • A 'check' utility has been added to the set of tools, which checks whether a set of saved data have reached a given level of statistical confidence. This utility is intended as a replacement of the loader/analyzer joint work, since the latter has been reported not to work correctly because their inter-process communication protocol. A comprehensive example is included in the tcl/ex/stat/ directory which is bundled in the patch file below. Also, note that the stat utilities are now included in the patch file below, as well, in the directory indep-utils/stat/.



To install the patch, follow the instructions below:

1. download the ns-allinone-2.31 package from SourceForge

2. unpack the file that you just downloaded in your preferred location (let us assume the location is /usr/local). This will create a directory named /usr/local/ns-allinone-2.31

3. download the latest patch (let us assume that you downloaded the file in /tmp)

4. apply the patch, by executing the following command:

     cd /usr/local/ns-allinone-2.31/ns-2.31
     gzip -dc /tmp/ns2measure-2.31-070909.patch.gz | patch -Np1

5. compile the all-in-one patched ns-2.31, by executing the following command:


6. (optional) run the test in tcl/ex/stat/ (check the README in that directory)

     If you use ns2 version 2.33 you can try this new patch: patch2.33


After having installed the patch and compiled ns-2, you are able to add measure probes in your C++ code by calling the following static function:

   Stat::put ("my_metric", ID, sample);

where my_metric is the human-readable name that is used to identify the metric that you are collecting, ID is the identifier of the current set of values (e.g. can be the traffic flow identifier, or the source IP, of the node MAC address, or simply 0), and sample is the sample that is being added to this metric.

Note that the #include <stat.h> statement must be added to the file where you are calling the Stat::put() function.

In order to enable the metric, you have to add a Tcl statement to your script, such as one of the following ones:

   $ns stat add my_metric avg TYPE
   $ns stat add my_metric dst TYPE X Y S
   $ns stat trace my_metric ID FILE


  • TYPE is one among 'rate', 'counter', 'discrete', 'average' (see the paper above to know the different among these metric types)
  • X,Y are the lower,upper bounds of the distributions metric, and S is the bin size of the distribution metric
  • ID is the metric idenfitier that is going to be traced into the file FILE


If you have any questions or comments, or if you just want to be kept informed of any forthcoming releases of the ns2measure extension, send an email to the support team.

License information

ns2measure has been developed by the Computer Networking Group of the Dipartimento di Ingegneria dell'Informazione of the University of Pisa, Italy.

All the software and documentation related to ns2measure and available in this page is released under the GNU General Public License, which means (roughly) that you can download the sources and modify them and do with them whatever you are legally entitled to, provided that you keep the license information in all the files that you use/redistribute. BUT, you cannot incorporate this software into proprietary programs.

Related work

If you find this software useful, then you may also be interested in Akaroa, which is a commercial product (free for teaching and non profit research activities at universities) developed at the University of Canterbury in Christchurch, New Zealand, since 1992. Akaroa is a software framework to perform multiple replications in parallel on different processors.


The old ns2measure module, i.e. that using the common/statconf.h file as described in the paper above, is considered legacy and will not be maintained anymore. However, if you really need that code, here are the patches for versions from 2.28 to 2.30:

Additionally, the latest version of the old statistics utilities can be found here. Note that the statistics utilities are now bundled in the ns-2 patch above.

Finally, you can download a GUI to configure in a visual environment the Stat ns2 module and the analyzer utility here as source code. You need the GTK 1.2 libraries. If you want to have a rough idea of what the GUI allows you to do, have a look to the screenshots of the statconf.h editor and the analyzer configuration editor.

Personal tools