Skip to main content

NS2 trace analysis IN MATLAB

Hey, In this post we are discussing about How to do ns2 trace analysis under Matlab using Tracegraph Tool

The following procedure shows the way to do trace analysis under Matlab using the Tracegraph tool :

About Software versions used :

  • We can use ns2.35 for the proposed simulation (even it will run under some lower versions also).
  • We are using the new version of Tracegraph Version 2.05. 
  • We are using the new version of Trace Converter Version 1.01. We can get it from the following link: http://www.tracegraph.com/trconvertwin.zip
  • Matlab 6.5 can be used to run the source version of Tracegraph.

We will use a trace converter because Tracegraph could not handle the trace file generated by the wired cum wireless scenario.

Refer Internet for further information about Tracegraph and trace converter.

Diagram Explaining the Simulation and Analysis Steps.

The highlighted model (Case – 4)  in the following diagram shows the simulation and analysis using we are using in this example. Since we are using hierarchical addressing in wired cum wireless scenario, Manual IP conversion is required.

Installation

  • Install ns2.28 or higher in Linux or Windows
  • Install trace converter, preferably windows binary version
  • Install the Tracegraph, preferably Matlab source version for windows. And run it from inside the Matlab command window. (For Running binary version of windows we have to do a lot of things. It will not require Matlab. But it will require some Matlab runtime environment components)

Procedure

1. Run any example simulation script (simulation1.tcl) in a terminal window using ns simulator as follows (here we assume that the trace file outputs are logged in the file (output.tr).

#ns simulation1.tcl

It will produce two files as output. They are output.nam and output.tr.

2. To visualize the scenario use nam as follows.

#nam output.nam

4. To do trace analysis using the Tracegraph, we have to do the following.
4a) copy the output.tr into the trace converter directory. Run a terminal window and change to the trace converter directory and issue the command as follows.

(if you are having trace converter installed under D drive )
D:trconvertwin>trconvert output.tr -mixed13 -ip
Converting output.tr trace file…
IP file (output.tr.ip ) does not exist.
Extracting IP addresses from output.tr …
IP addresses have been saved to output.tr.ip
IP addresses to node numbers manual conversion are needed (see help).
output.tr has not been converted.

4b) Since manual conversion is needed, edit the file output.tr.ip as explained in the following section.
5. Again run the trace converter to convert the ns trace file to the Tracegraph – It may produce an output as follows :

D:trconvertwin>trconvert output.tr
Trying to recognize the format of output.tr trace file…
10000 lines have been processed to recognize trace format.
wired-new trace format has been detected
IP addresses have been detected
Converting output.tr trace file…
output.tr has been converted to output_tg.tr
Finally, we will have the trace file for The Tracegraph, output_tg.tr
5. Copy the file output_tg.tr to trace the graph directory.
6. Run Matlab and set Matlab path to trace graph directory (example: D:Tracegraph205_winTracegraph205Windows).
7. In the Matlab command window issue the following command

>> trgraph output_tg.tr
8 In the Tracegraph window, select the necessary menu for displaying necessary graphs and statistics


NS2 Hierarchical IP address to Tracegraph IP format conversion

1. Copy the output file output.tr in Traceconvert directory and issue the ‘trconvert.  command from the same directory. It will produce output as follows :

# trconvert output.tr -mixed13 –ip

Trying to recognize format of output.tr trace file…
10000 lines have been processed to recognize trace format.
wired-new trace format has been detected
IP addresses have been detected
Converting output.tr trace file…
IP file (output.tr.ip ) does not exist.
Extracting IP addresses from output.tr …
IP addresses have been saved to output.tr.ip
IP addresses to node numbers manual conversion are needed (see help).
output.tr has not been converted.

It will produce the following output file ‘output.tr.ip’ in the same directory – and it may like as follows.
0.0.1
1.0.1
1.0.2
4194304
4194305
4194306

2. Since manual conversion is needed, manually assign suitable IP address for a hierarchical ip address.
Now the output file ‘output.tr.ip’ will look as follows.
0.0.1 1
1.0.1 2
1.0.2 3
4194304 4
4194305 5
4194306 6

3. Using the new ‘output.tr.ip’ again run the same command as follows

# trconvert output.tr

now it will convert the ns output trace file output.tr to Tracegraph format trace file output_tg.tr. Now using this file we can do trace analysis on the Tracegraph.

Trace Analysis
Trace analysis using output_tg.tr

Copy the output_tg.tr file from the Traceconvertor directory to Tracegraph directory.

If you are using the source version of the Tracegraph, run Matlab (preferably 6.5) and change to the Tracegraph directory in the Matlab directory window(left top text box).

In Matlab command window issue the following command
>>trgraph output_tg.tr

After a few seconds or minutes (depending upon the magnitude of the problem and speed of the computer) the windows similar to that following will appear.

In this following example,

In the right bottom window, you can select some parameters.
In the top window, you can select the necessary graphs.
In the left middle window, you can select some statistics.

The following screen shows an example of one of such typical analysis results.


Happy Coding!!

Comments

Popular posts from this blog

NS2 INSTALLATION IN UBUNTU 21.04

  Hello, this post explains how to install ns2 in Ubuntu 21.04.  1) First you have to download ns2 all-in-one package from following link;    http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.35/ns-allinone-2.35.tar.gz/download 2) Extract the downloaded zip file 'ns-allinone-2.35.tar.gz file' to home folder. 3)  Now you need to download some essential packages for ns2,these packages can be downloaded by using the following commands :  applications>accessories>terminal or dashhome>terminal   and   then type the below lines one by one on the terminal window sudo apt-get update sudo apt-get dist-upgrade sudo apt-get update 4) Install the basic libraries; sudo apt install build-essential autoconf automake libxmu-dev 5) Install gcc and g++ and for that please do following; open the file using sudo mode sudo nano /etc/apt/sources.list Include the following line in list;  deb http://in.archive.ubuntu.com/ubuntu bionic main universe then open terminal and exec

Link State Routing Protocol

Link state routing is a method in which each router shares its neighborhood’s knowledge with every other router on the internetwork. In this algorithm, each router in the network understands the network topology and then makes a routing table depending on this topology. Each router will share data about its connection to its neighbor, who will, consecutively, reproduce the data to its neighbors, etc. This appears just before all routers have constructed a topology of the network. In LSP, each node transmits its IP address and the MAC to its neighbor with its signature. Neighbors determine the signature and maintain a record of the combining IP address and the MAC. The Neighbor Lookup Protocol (NLP) of LSP derives and maintains the MAC and IP address of every network frame accepted by a node. The extracted data can support the mapping of MACs and IP addresses. The link-state flooding algorithm prevents the general issues of broadcast in the existence of loops by having every node mainta

NS2 INSTALLATION IN UBUNTU 20.04

Hello, this post explains how to install ns2 in Ubuntu 20.04.  1) First you have to download ns2 all-in-one package from following link;    http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.35/ns-allinone-2.35.tar.gz/download 2) Extract the downloaded zip file 'ns-allinone-2.35.tar.gz file' to home folder. 3)  Now you need to download some essential packages for ns2,these packages can be downloaded by using the following commands :  applications>accessories>terminal or dashhome>terminal  and   then type the below lines one by one on the terminal window sudo apt-get update sudo apt-get dist-upgrade sudo apt-get update 4) Install the basic libraries; sudo apt install build-essential autoconf automake libxmu-dev 5) Install gcc and g++ and for that please do following; open the file using sudo mode sudo nano /etc/apt/sources.list Include the following line in list;  deb http://in.archive.ubuntu.com/ubuntu bionic main universe then open terminal and execute