Sunday, April 14, 2013

INSTALL NS 2.35 ON UBUNTU 12.04 LTS

                              INSTALL NS 2.35 ON UBUNTU

Step 1:Make it sure that internet connectivity is good.Download NS2.35 from
http://www.isi.edu/nsnam/ns/

Step 2:make a new folder [ns] in /home/Extracts downloaded files in above folder.

Step 3 :copy downloaded ns-allinone-2.35.tar.gz in /home/ns/

Step 4 :open terminal

Step 5:Run following commands
cd ns-allinone-2.35

sudo apt-get update

sudo apt-get install build-essential autoconf automake libxmu-dev


Step 6 :Run following command
./install

Step 7:Run following command to install X – graph
$ sudo apt-get install xgraph

Step 8.Set environment variables by run this command
gedit ~/.bashrc

Add the following lines to the end of the file. Remember replace "/your/path" by the folder where you have stored extracted the ns-2 file (For example, if your Linux account name is purple, and you have extracted the file to your home directory, you have to change /your path to /home/ns)
# LD_LIBRARY_PATH
OTCL_LIB=/your/path/ns-allinone-2.35/otcl-1.13
NS2_LIB=/your/path/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=/your/path/ns-allinone-2.35/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/your/path/ns-allinone-2.35/bin:/your/path/ns-allinone-2.35/tcl8.4.18/unix:/your/path/ns-allinone-
2.35/tk8.4.18/unix
NS=/your/path/ns-allinone-2.35/ns-2.35/
NAM=/your/path/ns-allinone-2.35/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM

Step 9 :run following command
source ~/.bashrc

Now you can run your ns with ns command...
The "%" symbol appears on the screen. Type "exit" to quit.

INSTALL NS 2.35 ON UBUNTU 12.04 LTS

INSTALL NS 2.35 ON UBUNTU

Step 1:Make it sure that internet connectivity is good.Download NS2.35 from
http://www.isi.edu/nsnam/ns/

Step 2:make a new folder [ns] in /home/Extracts downloaded files in above folder.

Step 3 :copy downloaded ns-allinone-2.35.tar.gz in /home/ns/

Step 4 :open terminal

Step 5:Run following command
        $cd ns-allinone-2.35

        $sudo apt-get update

        $sudo apt-get install build-essential autoconf automake libxmu-dev

Step 6 :Run following command
        $./install

Step 7:Run following command to install X – graph
         $ sudo apt-get install xgraph

Step 8.Set environment variables by run this command
          $gedit ~/.bashrc

And
Add the following lines to the end of the file. Remember replace "/your/path" by the folder where you have stored extracted the ns-2 file (For example, if your Linux account name is purple, and you have extracted the file to your home directory, you have to change /your path to /home/ns)

# LD_LIBRARY_PATH
OTCL_LIB=/your/path/ns-allinone-2.35/otcl-1.13
NS2_LIB=/your/path/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=/your/path/ns-allinone-2.35/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/your/path/ns-allinone-2.35/bin:/your/path/ns-allinone-2.35/tcl8.4.18/unix:/your/path/ns-allinone-
2.35/tk8.4.18/unix
NS=/your/path/ns-allinone-2.35/ns-2.35/
NAM=/your/path/ns-allinone-2.35/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM

Step 9 :run following command
            $source ~/.bashrc

Now you can run your ns with ns command...
The "%" symbol appears on the screen. Type "exit" to quit.

and type $ns


By

Arvind Shukla

Saturday, April 13, 2013

Simple ns2 script(Example)


Basically NS 2 programming contains the following steps.                                                                                    
1.Create the event scheduler

2.Turn on tracing

3.Creating network

            a) Computing setup routing - rtproto
            b) Creating transport connection-Agents
            c) Creating traffic-Applications

4. Monitoring

         a) Visualization using nam


Note: every tcl script must write in small letters only except protocol agents i.e. TCP, FTP,UDP


Example 

Every ns2 script starts with creating simulator object  
               
                    set ns [new Simulator] 

How to create node                                               
                      
                    set n0 [$ns node]
                    set n1 [$ns node]
       
Creating link  
                 
                  $ns duplex-link $n0 $n1 1Mb 10ms DropTail

        This line tells the simulator object to connect the nodes n0 and n1 with a duplex link with the bandwidth.1Megabit,  a delay of 10ms and a DropTail queue.
       




·  How to use Trace?

   We use simulator to see results. How is it achieved? Using trace

         Two types of trace

             1. generic trace
                       for use with xgraph, and other things

             2. nam trace
                        for use with visualization

                  # open trace file
                   set tracefile [open out.tr w]
                   $ns trace-all $tracefile

                  #Open the nam trace file
                  set nf [open out.nam w]
                  $ns namtrace-all $nf

       Since we have started tracing, we should end also. For this we use finish procedure.

   #Define a 'finish' procedure
            proc finish {}
            {
                   global ns tracefile nf
                   $ns flush-trace
                   close $nf
                   close $tracefile          # close tracefile
                   exec nam out.nam &   #Execute nam on the trace file
                   exit 0
            }


 Finish procedure is forced to be called at the end with the line
            $ns at 5.0 “finish”

 Every tcl script must contain following statement

              $ns run

Friday, April 12, 2013

STEPS TO INSTALL NS 2.35/NS2.34 IN UBUNTU 12.04 and 12.10

STEP TO INSTALL NS-2.34 IN UBUNTU 12.04 LTS



Step 1:Make it sure that internet connectivity is good.Download NS2.34 from
http://www.isi.edu/nsnam/ns/

Step 2:make a new folder [ns] in /home/Extracts downloaded files in above folder.

Step 3 :copy downloaded ns-allinone-2.34.tar.gz in /home/ns/

Step 4 :open terminal

Step 5:Run following commands
cd ns-allinone-2.34

sudo apt-get update

sudo apt-get install build-essential autoconf automake libxmu-dev

Step 6 :Run following command
./install

IF U MET WITH THE ERRORS THEN MAKE FOLLOWING CHANGES IN THE PACKAGE :

1. ERROR
ld: libotcl.so: hidden symbol `__stack_chk_fail_local' isn't defined
ld: final link failed: Bad value
make: *** [libotcl.so] Error 1
otcl-1.13 make failed! Exiting ...
Solution:
In otcl-1.13/configure, line number 6304
  Replace 
-SHLIB_LD="ld -shared" 
with
+SHLIB_LD="gcc -shared"

2. ERROR
tools/ranvar.cc: In member function ‘virtual double GammaRandomVariable::value()’:
tools/ranvar.cc:219:70: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directly [-fpermissive]
tools/ranvar.cc:219:70: error:   for a function-style cast, remove the redundant ‘::GammaRandomVariable’ [-fpermissive]
make: *** [tools/ranvar.o] Error 1

Solution:
In ns-2.34/tools/ranvar.cc, line 219
REPLACE
-return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);WITH
+return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
3.ERROR
In file included from mac/mac-802_11Ext.cc:66:0:
mac/mac-802_11Ext.h: In member function ‘u_int32_t PHY_MIBExt::getHdrLen11()’:
mac/mac-802_11Ext.h:175:19: error: expected primary-expression before ‘struct’
mac/mac-802_11Ext.h:175:41: error: ‘dh_body’ was not declared in this scope
mac/mac-802_11Ext.h:175:51: error: ‘offsetof’ was not declared in this scope
mac/mac-802_11Ext.h:177:3: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [mac/mac-802_11Ext.o] Error 1
Ns make failed!

Solution:
In mac/mac-802_Ext.h, line 65

+#include 

4.ERROR
mobile/nakagami.cc: In member function ‘virtual double Nakagami::Pr(PacketStamp*, PacketStamp*, WirelessPhy*)’:
mobile/nakagami.cc:183:73: error: cannot call constructor ‘ErlangRandomVariable::ErlangRandomVariable’ directly [-fpermissive]
mobile/nakagami.cc:183:73: error:   for a function-style cast, remove the redundant ‘::ErlangRandomVariable’ [-fpermissive]
mobile/nakagami.cc:185:67: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directly [-fpermissive]
mobile/nakagami.cc:185:67: error:   for a function-style cast, remove the redundant ‘::GammaRandomVariable’ [-fpermissive]
make: *** [mobile/nakagami.o] Error 1

Solution:
In ns-2.34/mobile/nakagami.cc ,


if (int_m == m) {
             resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m, int_m).value();
         } else {
             resultPower = GammaRandomVariable::GammaRandomVariable(m, Pr/m).value();
         }
        return resultPower;  }
Replace the above with :  if (int_m == m) {
            resultPower = ErlangRandomVariable(Pr/m, int_m).value();
         } else {
             resultPower = GammaRandomVariable(m, Pr/m).value();
         }
        return resultPower;
    }

Step 7:Run following command to install X – graph
$ sudo apt-get install xgraph

Step 8.Set environment variables by run this command
gedit ~/.bashrc

Add the following lines to the end of the file. Remember replace "/your/path" by the folder where you have stored extracted the ns-2 file (For example, if your Linux account name is purple, and you have extracted the file to your home directory, you have to change /your path to /home/ns)
# LD_LIBRARY_PATH
OTCL_LIB=/your/path/ns-allinone-2.34/otcl-1.13
NS2_LIB=/your/path/ns-allinone-2.34/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=/your/path/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/your/path/ns-allinone-2.34/bin:/your/path/ns-allinone-2.34/tcl8.4.18/unix:/your/path/ns-allinone-
2.34/tk8.4.18/unix
NS=/your/path/ns-allinone-2.34/ns-2.34/
NAM=/your/path/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM

Step 9 :run following command
source ~/.bashrc

Now you can run your ns with ns command...
The "%" symbol appears on the screen. Type "exit" to quit.

Tuesday, April 2, 2013

About NS2


Basic Steps for Setting Simulation Environment:

Here, we are going to introduce the concepts of:-

Part of introduction to TCP/IP model
Where can you write scripts?
Basic NS2 programming steps
Template
Golden rules
Simple Examples


1.                                  TCP/IP model 
Application Layer
                Applications agents are Telnet, FTP, CBR
 .

Transport Layer
               The transport uses two protocols, UDP and TCP. UDP which stands for User Datagram Protocol does not guarantee packet delivery and applications which use this must provide their own means of verifying delivery. TCP does guarantee delivery of packets to the applications which use it.


Network Layer
               The network layer is concerned with packet routing and used low level protocols such as ICMP, IP, and IGMP. Here Network protocols are omitted for simple examples


Link Layer
            The link layer is concerned with the actual transmittal of packets as well as IP to Ethernet address translation. Data transfer in two modes i.e. simplex mode and in duplex mode.
All the links are created at data link layer. Network layer next is to data link layer. 



                        Part of Introduction to TCP/IP Model                                                                                                   
Application LayerCBR,FTP,telnet..
Transport layerTCP,UDP
Network layerrtproto
Data link LayerTransmission mode
  • Simplex mode
  • Duplex mode
Physical layer 











Where can we/you write tcl Scripts?                                                                                                                

After login into terminal, follow step given below

1. vi filename.tcl
           It will open page, there you can write tcl scripts.

2. save file
          Press esc-> colon (shift + semicolon) ->wq (save and quit)
It save the file

3. To run tcl script
          ns filename.tcl
or 
 In case of  ubuntu operating system
1.open any editor(document)
2.there you can write tcl scripts.
3.save this with .tcl extension,i.e filename.tcl.
4.for run tcl script
     type at terminal ns filename.tcl,e.g ns DSDV.tcl,ns DSR.tcl.





Machine Learning for Agriculture

  Machine learning has the potential to revolutionize agriculture by helping farmers make more informed decisions and optimize their operati...