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
Post a Comment