Installing NS3 in Ubuntu 14.0x : In 5 Simple steps

What is NS-3?
According to its developer's website, the description as follows:
ns-3 is a discrete-event network simulator, targeted primarily for research and educational use. ns-3 is free software, licensed under the GNU GPLv2 license, and is publicly available for research, development, and use.
The goal of the ns-3 project is to develop a preferred, open simulation environment for networking research: it should be aligned with the simulation needs of modern networking research and should encourage community contribution, peer review, and validation of the software.

How to install NS-3 in your Ubuntu 14.0x versions.

Step 1:
You need to install all the dependencies first in order to make your NS-3 work correctly.

In official installation documentation (https://www.nsnam.org/wiki/Installation) the installation process is given step by step, but it will take a long time to complete, instead you can use the following command to complete that 17+ step process in one step process. For other operating system you should look into the above official link. (Since I have tested it for only Ubuntu 14.05 & 14.04 so I can tell you about this only.)

Just copy & paste in the terminal window:

sudo apt-get install gcc g++ python python-dev qt4-dev-tools mercurial bzr gdb valgrind gsl-bin libgsl0-dev libgsl0ldbl flex bison tcpdump sqlite sqlite3 libsqlite3-dev libxml2 libxml2-dev libgtk2.0-0 libgtk2.0-dev uncrustify doxygen graphviz imagemagick texlive texlive-latex-extra texlive-generic-extra texlive-generic-recommended texinfo dia texlive texlive-latex-extra texlive-extra-utils texlive-generic-recommended texi2html python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev python-pygccxml

NOTE: If you are running your Ubuntu in a VM, you need to further install, vtun & lxc. Simply enter the command, sudo apt-get install vtun lxc.

*The above process will take nearly 1200MB of your hard-drive space. So a case might arise that you run out of your space, particularly if you are doing it from a memory limited flash drive.

Step 2:

After finishing with the above step successfully, go to the link: http://www.nsnam.org/release/
To check for the latest  version of NS-3.

In my case it was 3.24, if you want a onder version of NS-3 just note down the version number. 

And enter the following command into your terminal.

   mkdir ns3

   cd ns3
   wget http://www.nsnam.org/release/ns-allinone-3.24.tar.bz2
   tar xjf ns-allinone-3.24.tar.bz2
   cd ns-allinone-3.24/
   ls
 
Before mkdir command make sure you are in right directory( in which you actually want to install, if you are not sure give these command directly, but do remember the path, in my case I have installed it in '/').

After the ls command you are going to see something like this....

bake          constants.pyc  pybindgen-0.17.0.post41+ngd10fa60  util.pyc
build.py      netanim-3.106  README
constants.py  ns-3.24        util.py

Step 3:

After finishing with the above steps, now give the following command:

./build.py --enable-examples --enable-tests

it will take a while to build, once finished goto the ns-3.24 folder. (This folder name Depends upon your NS3 version).

cd ns-3.24

do a ls here
ls

You will see something like this:
AUTHORS          DlRlcStats.txt  scratch          UlRlcStats.txt  waf-tools
bindings         doc             src              utils           wscript
build            examples        test.py          utils.py        wutils.py
CHANGES.html     LICENSE         testpy-output    utils.pyc       wutils.pyc
different.pcap   Makefile        testpy.supp      VERSION
DlMacStats.txt   README          UlMacStats.txt   waf
DlPdcpStats.txt  RELEASE_NOTES   UlPdcpStats.txt  waf.bat

Step 4:

Now we need to build using waf builder. Do the following:

./waf -d debug --enable-examples --enable-tests configure
./waf
 

Step 5:

After done with waf builder. Now its time to check if your installation is ready to work or not? For doing this you need to give the command:

./test.py

If the result is a PASS for all the modules, you are ready with your NS3.



FIRST RUN of NS3:
You might want a first run of NS3 which you have just installed. Just be in the same directory (i.e., ns-3.24, in which the waf & test.py  are) & give the command:

./waf --run first

You will see the output something like this:

Waf: Entering directory `/home/openbts/ns3/ns-allinone-3.24/ns-3.24/build'
Waf: Leaving directory `/home/openbts/ns3/ns-allinone-3.24/ns-3.24/build'
Build commands will be stored in build/compile_commands.json
'build' finished successfully (1.112s)
At time 2s client sent 1024 bytes to 10.1.1.2 port 9
At time 2.00369s server received 1024 bytes from 10.1.1.1 port 49153
At time 2.00369s server sent 1024 bytes to 10.1.1.1 port 49153
At time 2.00737s client received 1024 bytes from 10.1.1.2 port 9

Congrats!
 
 
 
 
Additionally you should also try: 
./waf --run second
./waf --run third
./waf --run fourth
./waf --run fifth
./waf --run sixth     
./waf --run seventh 


Follow the official tutorial of NS-3 from here:
https://www.nsnam.org/docs/release/3.24/tutorial/ns-3-tutorial.pdf

0 comments:

Calculating the Global Extrema (Minima/Maxima) of a quadratic function/equation through MATLAB

An extrema is a maximum or minimum of a function. An extrema may be local (a.k.a. a relative extrema; an extrema in a given region which is not the overall maximum or minimum) or global. In this MATLAB program we are calculating the global extrema of a quadratic function/equation as entered by the user which is in the form,  'ax^2+bx+c=y'.

The program after getting the values of 'a', 'b' & 'c' from the user plots the function 'y' with the varying value of 'x'. And tells the (x,y) coordinates of the global minimum of that quadratic function.

The value of x & y are actually after taking the derivative of the function  ax^2+bx+c. Refer some mathematics text in order to find more about Maxima & Minima (Extremum) Calculation.

Following MATLAB Code is for Calculating the Global Extrema (Minima/Maxima) of a quadratic function/equation.

%Global extremum of a quadratic function

%input the quadratic equation in terms of 'a','b' & 'c', ax^2+bx+c=y
a=input('Enter a for ax^2+bx+c=y:');
b=input('Enter b for ax^2+bx+c=y:');
c=input('Enter c for ax^2+bx+c=y:');

%for plotting 'y' from x=-200 to +200
xx=-100:1:100;
plot(xx,a.*xx.*xx+b.*xx+c);
title('The plot of User Entered Quadratic Equation/Function')
xlabel('x->>');
ylabel('y->>');

%min/max using first derivative
x = (-b)/(2*a);
y = ((4*a*c)-b^2)/(4*a);
disp('Coordinates of Min/max value (x,y)');
if a>0
    disp('It is a minima.');
else
    disp('It is a maxima.');
end
C = [x,y]

Z = b^2 - 4*a*c;% x-intercepts
A1 = (-b + sqrt(Z))/(2*a);
A2 = (-b - sqrt(Z))/(2*a);

disp('X-Intercepts:');
disp(A1)
disp(A2)


Sample Output:

CASE 1:
Calculating the Global Extrema (Minima/Maxima) of a quadratic function/equation through MATLAB
Calculating the Global Extrema (Minima/Maxima) of a quadratic function/equation through MATLAB
Enter a for ax^2+bx+c=y:1
Enter b for ax^2+bx+c=y:0
Enter c for ax^2+bx+c=y:0
Coordinates of Min/max value (x,y)
It is a minima.

C =

     0     0

X-Intercepts:
     0

     0



CASE2:
 
Calculating the Global Extrema (Minima/Maxima) of a quadratic function/equation through MATLAB
Calculating the Global Extrema (Minima/Maxima) of a quadratic function/equation through MATLAB
Enter a for ax^2+bx+c=y:1
Enter b for ax^2+bx+c=y:20
Enter c for ax^2+bx+c=y:1
Coordinates of Min/max value (x,y)
It is a minima.

C =

   -10   -99

X-Intercepts:
   -0.0501

  -19.9499

0 comments: