Tracegraph is a great application that comes handy to ns2 users. It eliminates the need to configure and run perl/awk scripts over the trace file. Trace file analysis simplified. Though I feel that Tracegraph is still in its infancy, its existing scope just provides all that a researcher using ns2 needs.
The steps mentioned in this post were tested to be successful in Ubuntu 10.10 and I believe it would work in other Linux distros and Ubuntu versions too.(Remember that the command sudo doesn’t work in non-debian distributions of Linux.)
First, Download the following packages:
Tracegraph seems to have been developed using Matlab and therefore supporting code is needed make it run in Linux. This is the reason behind installing mglinstaller.
Extract tracegraph202linux.tar.gz in your homefolder. In my case this would result in /home/micman/tracegraph202
Next extract mglinstaller.gz into /home/micman/tracegraph202
A single executable named mglinstaller would appear in the tracegraph202 folder.
Next, provide executable permission to mglinstaller and run it using the following command:
$sudo chmod 777 mglinstaller
You would then be prompted with an information, all you have to do is to hit ENTER.
This would create a new folder named glnx86 in the following location: /home/micman/tracegraph202/bin/
Next, copy all the folders and files in /home/micman/tracegraph202/ location and paste them into /home/micman/tracegraph202/bin/glnx86/
Finally, enter the following line in Terminal:
$ sudo export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/micman/tracegraph202/bin/glnx86
Remember, micman in the above line is my account name, replace it with your account name(user name).
Exit the Terminal and Re-invoke it.
Now, navigate to this location: /home/micman/tracegraph202/bin/glnx86/
$ cd /home/micman/tracegraph202/bin/glnx86
List all the files in this location
you would see an executable named trgraph in this location.Provide executable permission to this file and execute it.
$ sudo su
# chmod 777 trgraph
To run tracegraph every time, just navigate to /home/micman/tracegraph202/bin/glnx86 in Terminal and execute trgraph as follows:
Tip by Siddharth
Place the trgraph executable in the location /usr/bin/ so that you can execute it from the Terminal without having to “cd” into the installation directory everytime. The command to copy the trgraph executable into /usr/bin/ looks like this:
$ sudo cp /home/micman/tracegraph202/bin/glnx86/trgraph /usr/bin
If you encounter an error something like the following:
bash: ./trgraph: No such file or directory
It is probably because you are trying to run this tracegraph on a 64-bit machione.
To fix this issue, you need to install 32bit libraries, by running the following command in the Terminal:
sudo apt-get install ia32-libs
after this you can just execute ./trgraph as mentioned in the tutorial.
This link helped me find this solution.
Was this post helpful? Then thank me by clicking <this link>
Finding Node Position,Velocity and Speed in NS2.34
This article is now moved to this location: Google da. NS2 help
To read this article in Scribd go <here>
For an alternative method to obtain a nodes position, go <here>
Happy to meet you in another interesting task in NS2!
This time we will “dynamically” calculate a nodes position and remaining energy.This post is based on the valuable tips mentioned <here> by Elmurod Talipov.
Now to the task…
I will be modifying the sample script simple-wireless.tcl found at ~/ns-allinone-2.34/ns-2.34/tcl/ex and all my tasks in ns2 would be based on AODV protocol.
1. In simple-wireless.tcl, change the routing protocol to AODV, enable Energy model and set the initial energy value.
2. In the node configuration set the EnergyModel, Initial Energy value, power spent in receiving mode,transmit mode,idle mode and sleep mode.
3. Now we will move to the backend code(c++). Our edits would be performed only in aodv.cc and aodv.h.
4. In aodv.h,first include the following header file that contains the procedures/functions needed to access node postion,energy and several other functions.
You will find class AODV, something like the one shown below.
With that, no more work to be done in aodv.h. What we have actually done here is to declare the variables that we will using in aodv.cc to record a nodes position and energy.
6. In aodv.cc, we will initialize the variables that we have just declared in aodv.h. This we do in the AODV “constructor“(invoked only once during node creation).
7. Next, we include the code to access the functions in mobilenode.h, that fetch the nodes current position and energy.
I have included that code AODV::forward() function, so that the nodes position and energy are printed each time it forwards a packet. Where and When you want them to be printed is your choice. Alternatively, you may have the code included in the function of your choice and have the output redirected to a file.
8. Thats all! All we have to do now is to run simple-wireless.tcl
and the output would be something like this:
If you find any discrepancies in this post, please feel free to drop me a mail at email@example.com. By doing so, You would be saving the valuable time of many researchers.
Suppose you have three files, viz:
and if you want to integrate these into your existing NS2 installation, just follow the procedure explained by Mr. Teerawat Issariyakul.
Download PPT on [Adding a new module to NS2] by Mr. Teerawat Issariyakul
For more such interesting tips and NS2 guidance, have a look at: