Hi All, Our website moved to a new URL. Please bookmark the new link: https://ns2bloggers.blogspot.com/

Thursday, 2 September 2021

Tour de Technology Facts Coming Soon


History of NS2

 

Ns started as a variant of the important network simulator software in 1989 and has progressed considerably over the past few years. In 1995 ns development was encouraged by agency called DARPA through the VINT project at LBL, Xerox PARC, UCB, and USC/ISI. Currently ns development is sustained through Defense Advanced Research Projects Agency (DARPA) with SAMAN and thru National Science Foundation with CONSER, each united with alternative researchers like ACIRI. Ns has invariably enclosed substantial contributions from alternative researchers, that includes wireless code from the UCB Daedelus and CMU Monarch comes and Sun Microsystems.

Average Packet End to End Delay Calculation

 




Suppose we run a simulation ,and obtain a trace file. We have to compute the average values of delay. Let’s define delay as the duration since a packet enters a queue of a beginning node until it it arrives at the ending node. The definition of beginning and ending nodes depends on the type of delay under consideration as follows:

Average delay is computed by :
 E(delay)= summation of all delay samples/ no. of samples
where a delay sample is delay associated with a packet. 
The key to collect delay sample is to record packet arrival time in an associative array variable, namely t_arr whose index is the packet unique ID. 
When a new packet enters a queue of a beginning node, the associated time is recorded in a variable $t_arr[pid], where pid is the packet unique ID. 
When a packet with the same unique ID arrives at an ending node, the delay is computed as “(current time) - $t_arr[pid]”. 
The delay same is accumulated in the variable $total_delay, and the number of samles is incremented by one.
At the end of the program, the average delay is computed and stored in a variable avg_delay.


A sample execution of the AWK script is shown below:


============ awk for delay =========
BEGIN {
fromNode=2; toNode=3;
num_samples = 0;
total_delay = 0;
}
/^\+/&&$3==fromNode&&$4==toNode {
t_arr[$12] = $2;
};
/^r/&&$3==fromNode&&$4==toNode {
if (t_arr[$12] > 0) {
num_samples++;
delay = $2 - t_arr[$12];
total_delay += delay;
};
};
END{
avg_delay = total_delay/num_samples;
print "Average queuing transmission delay is " avg_delay " seconds";
print "Measurement details:";
print " - Start when packets enter the node " fromNode;
print " - Until the packets arrive the node " toNode;
};
============ abbfile.awk =========
BEGIN {
src="0.0"; dst="3.0";
num_samples = 0;
total_delay = 0;
}
/^\+/&&$9==src&&$10==dst {
t_arr[$12] = $2;
};
/^r/&&$9==src&&$10==dst{
if (t_arr[$12] > 0) {
num_samples++;
delay = $2 - t_arr[$12];
total_delay += delay;
};
};
END{
avg_delay = total_delay/num_samples;
print "Average end-to-end transmission delay is " avg_delay " seconds";
print "Measurement details:";
print " - Since packets are created from the address " src;
print " - Until the packets are destroyed at the address " dst;
};



Enjoy. Happy Coding.

Friday, 21 September 2018

NS2 UNINSTALLATION ON LINUX

1) Delete the directory ns-allinone-2.35.
2) Delete all ns2 related files from bin folder: /usr/local/lib
3) After completing the deletion type the following command in the command window

    gedit ~/.bashrc

4) Now an editor window appears,please remove following codes from bash file (note that '/home/abhiram/Desktop/ns-allinone-2.35/octl-1.14' in each line in the below code  varies with your location )


# LD_LIBRARY_PATH
OTCL_LIB=/home/abhiram/Desktop/ns-allinone-2.35/otcl-1.14
NS2_LIB=/home/abhiram/Desktop/ns-allinone-2.35/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB

# TCL_LIBRARY
TCL_LIB=/home/abhiram/Desktop/ns-allinone-2.35/tcl8.5.10/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/home/abhiram/Desktop/ns-allinone-2.35/bin:/home/abhiram/Desktop/ns-allinone-2.35/tcl8.5.10/unix:/home/abhiram/Desktop/ns-allinone-2.35/tk8.5.10/unix
NS=/home/abhiram/Desktop/ns-allinone-2.35/ns-2.35/
NAM=/home/abhiram/Desktop/ns-allinone-2.35/nam-1.15/
PATH=$PATH:$XGRAPH:$NS:$NAM

5) Save and close the text editor and then type the following command on the terminal

     source ~/.bashrc

6) Restart PC and wait

7) After restart, Please type following commands : applications>accessories>terminal or dashhome>terminal for removing and clean all dependency files of ns2.

    "sudo apt-get autoremove"
    "sudo apt-get clean"


Cheers!!

NS2 INSTALLATION ON UBUNTU 16.04

1) Download 'ns-allinone-2.35' from :
  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 desktop.

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
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"
    "sudo apt-get gcc"
    "sudo apt-get install build-essential autoconf automake"
    "sudo apt-get install tcl8.5-dev tk8.5-dev"
    "sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev"

4) Now change your directory(here i have already extracted the downloaded files to desktop,so my location is desktop) type the following codes in the command window to install NS2.

    cd Desktop  
    cd ns-allinone-2.35
    ./install

                              The installation procedure will take a few minutes..........

5) After compleating the installation type the following command in the command window

    gedit ~/.bashrc

6) Now an editor window appears,please copy and paste the follwing codes in the end of the text file (note that '/home/abhiram/Desktop/ns-allinone-2.35/octl-1.14' in each line in the below code should be replaced with your location where the 'ns-allinone-2.35.tar.gz'file is extracted)


# LD_LIBRARY_PATH
OTCL_LIB=/home/abhiram/Desktop/ns-allinone-2.35/otcl-1.14
NS2_LIB=/home/abhiram/Desktop/ns-allinone-2.35/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB

# TCL_LIBRARY
TCL_LIB=/home/abhiram/Desktop/ns-allinone-2.35/tcl8.5.10/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/home/abhiram/Desktop/ns-allinone-2.35/bin:/home/abhiram/Desktop/ns-allinone-2.35/tcl8.5.10/unix:/home/abhiram/Desktop/ns-allinone-2.35/tk8.5.10/unix
NS=/home/abhiram/Desktop/ns-allinone-2.35/ns-2.35/
NAM=/home/abhiram/Desktop/ns-allinone-2.35/nam-1.15/
PATH=$PATH:$XGRAPH:$NS:$NAM

7) Save and close the text editor and then type the following command on the terminal

    source ~/.bashrc

8) Close the terminal window and start a new terminal window and now change the directory to ns-2.35 and validate ns-2.35 by exicuting the following command ( it takes 30 to 45 minutes)

    cd ns-2.35
    ./validate

9) If the installation is successful, then you will be able to see % at the command prompt while typing the following command

    ns

10) Now type

    exit

Sunday, 10 December 2017

Queuing Models and Simulations

Hi guys,
    Today we are going to discuss about a new topics : "Queuing Models in NS2". I hope you all know about different queuing models and i am least interested on discussing about that. We are going straight to our main topic.

Why Queuing Models and Simulations??


  • Simulations are normally used in the analysis part of queuing models 
  • Queuing Model is nothing but a simple representation  of a network flow with traffic. 
  • Queuing models provide the analyst with a powerful tool for designing and evaluating the performance of queuing systems.
  • Normally it measures; Utilization of Server, Length of Waiting Bucket and Delay Duration.
  • In simple systems, We can calculate it mathematically but in the case of large and complex networks, we need simulation.
Elements In a Queuing System

  • Customer : It is nothing but anything which requires services from server.
  • Server : Refers to any resource which provides service to customer.
  • Calling Population : A group of customer. It may be finite or infinite.

For Simulation and Comparison of Queue Scheduling Algorithms; Click here