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

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

Windows 11

Windows has always existed to be a stage for the world’s innovation. It’s been the backbone of global businesses and where scrappy startups became household names. The web was born and grew up on Windows. It’s the place where many of us wrote our first email, played our first PC game and wrote our first line of code. Windows is the place people go to create, to connect, to learn and to achieve – a platform over a billion people today rely on. The responsibility of designing for that many people is one we don’t take lightly. The past 18 months brought an incredible shift in how we used our PCs; we went from fitting the PC into our lives to trying to fit our whole lives into the PC. Our devices weren’t just where we went for meetings, classes and to get things done, but where we came to play games with friends, binge watch our favorite shows and, perhaps most meaningfully, connect with one another. In the process we found ourselves recreating the office banter, the hallway chatter, worko

Matter: A next generation home standard

The smart home is evolving. To date, if you've wanted to get into developing a smart home, you've had to deal with the multitude of smart home ecosystems, and making sure that each device you buy is compatible. That, however, may soon change — thanks to new smart home standard called Matter. Matter isn't available just yet, but when it is finally released, it could completely change how you buy smart home products, for the better. All of the best smart home devices could soon support the standard, helping them all work together nicely, and ensuring that no matter what products you buy, you'll be able to use them. Matter is basically the name of a new smart home connectivity standard . But this standard is a little unlike others. That's because of the fact that it's being developed by the Connectivity Standards Alliance, which counts hundreds of companies as members. That includes the likes of Google, Alexa, and Apple. So, whether you prefer to use Google Assista