Friday, April 4, 2014

AntHocNet installation in Ubuntu 12.04

The steps to be followed are:
  1. Download the AntHocNet patch for NS-2.34 from the following link http://anthocnet.svn.sourceforge.net/viewvc/anthocnet/ 
  2. Modify the makefile because the entries for anthocnet were missing in the patch. 
  3. Compile the patch using:
    1. ./configure
    2. make clean
    3. make
    4. make install
  4. Now, you run example files with routing protocol as "AntHocNet"

The common errors:
  • trace/cmu-trace.o: In function `AntBasicPacket::access(Packet const*)':cmu-trace.cc:(.text._ZN14AntBasicPacket6accessEPK6Packet[AntBasicPacket::access(Packetconst*)]+0x7): undefined reference to `AntBasicPacket::offset_'collect2: ld returned 1 exit status 
        make: *** [ns] Error 1
        Ns make failed!
        See http://www.isi.edu/nsnam/ns/ns-problems.html for problems        
        Solution:
        Update the  makefile with proper path for object files.
 

Tuesday, October 22, 2013

NS-2.33 installation in Ubuntu 12.04


Follow the below given steps:

Download ns-allinnone-2.33 from nasam website
             http://sourceforge.net/projects/nsnam/files/ns-2
Create a folder in home with name ns2
 Extract the tar file in ns2
Open terminal and type cd ns2/ns-allinone-2.33
 Install required libraries for ns2 using terminal
            sudo apt-get install build-essential autoconf automake libxmu-dev
 Then, sudo ./install

For errors,


1.
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

-SHLIB_LD="ld -shared"
+SHLIB_LD="gcc -shared"

2.
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.33/tools/ranvar.cc, line 219

-return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
+return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);

3.
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<cstddef>

4.
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.33/mobile/nakagami.cc, Line no.

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

 +if (int_m == m) {
 +           resultPower = ErlangRandomVariable(Pr/m, int_m).value();
 +        } else {
 +            resultPower = GammaRandomVariable(m, Pr/m).value();
 +        }
 +       return resultPower;
 +   }

Path Setup:
In terminal sudo gedit ~/.bash_aliases
Then update the environmrnt variable

# LD_LIBRARY_PATH
OTCL_LIB=/home/ramakrishna/ns2/ns-allinone-2.33/otcl-1.13
NS2_LIB=/home/ramakrishna/ns2/ns-allinone-2.33/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/ramakrishna/ns2/ns-allinone-2.33/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/home/ramakrishna/ns2/ns-allinone-2.33/bin:/home/ramakrishna/ns2/ns-allinone-2.33/tcl8.4.18/unix:/home/ramakrishna/ns2/ns-allinone-2.33/tk8.4.18/unix
NS=/home/ramakrishna/ns2/ns-allinone-2.33/ns-2.33/
NAM=/home/ramakrishna/ns2/ns-allinone-2.33/nam-1.13/
PATH=$PATH:$XGRAPH:$NS:$NAM

NS-2 Error


Application initialization failed: Can't find a usable init.tcl in the following 

directories:
 
../../../linux/lib/tcltk/lib/tcl8.3 ../../../linux/lib/tcltk/lib/tcl8.3



Solution:


1. Go to location root-usr-local-bin by giving following command in terminal

cd /usr/local/bin


2. There you would find the ns file. We just need to remove it by giving following command


rm ns


3. Thats it, you are done. Now your ns starts running successfully.

Saturday, October 5, 2013

Error while including wireless-phy.h

The below error is solved:

./mac/wireless-phy.h:129: error: expected identifier before 'r'
./mac/wireless-phy.h:129: error: expected `}' before 'r'
./mac/wireless-phy.h:129: error: expected unqualified-id before 'r'
./mac/wireless-phy.h: In member function ‘bool& WirelessPhy::Is_node_on()’:
./mac/wireless-phy.h:97: error: ‘node_on_’ was not declared in this scope
./mac/wireless-phy.h: In member function ‘bool WirelessPhy::Is_sleeping()’:
./mac/wireless-phy.h:98: error: ‘status_’ was not declared in this scope
./mac/wireless-phy.h: At global scope:
./mac/wireless-phy.h:131: error: no matching function for call to ‘Sleep_Timer::Sleep_Timer()’
./mac/wireless-phy.h:58: note: candidates are: Sleep_Timer::Sleep_Timer(WirelessPhy*)
./mac/wireless-phy.h:56: note:                 Sleep_Timer::Sleep_Timer(const Sleep_Timer&)
./mac/wireless-phy.h:134: error: expected unqualified-id before ‘private’
./mac/wireless-phy.h: In function ‘EnergyModel* em()’:
./mac/wireless-phy.h:142: error: ‘node’ was not declared in this scope
./mac/wireless-phy.h: At global scope:
./mac/wireless-phy.h:144: error: ‘friend’ can only be specified inside a class
./mac/wireless-phy.h:146: error: expected declaration before ‘}’ token 



The error is due to duplicate link to SEND and RECV, so we need to change one of the file as shown below:

In cmu-trace.cc

- #define    RECV    'r'
- #define    SEND    's'


Rename as follows:

+ #define    RECVs    'r'
+ #define    SENDs    's' 


 

Friday, October 4, 2013

Installing LEACH in NS-2.34

The home directory of NS-2.34 is “/home/ns2/ns-allinone-2.34″

        1. Download the package “ns-234-leach.tar.gz” into the directory “/home/ns2/ns-allinone-2.34/ns-2.34″.
        2. Download the bash file “leach-setup.sh” into the directory “/home/ns2/ns-allinone-2.34/ns-2.34″.
    If the home directory of your “NS-2.34″ is other than “/home/ns2/ns-allinone-2.34″, then you need to find “ns-allinone-2.34″ and replace with “yourpath/ns-allinone-2.34″ for the file “leach-setup.sh”.
        3. Move to the directory “/home/ns2/ns-allinone-2.34/ns-2.34″ and patch the file “leach-setup.sh” by run this command :
        ns2@ubuntu-10.04:~$ cd /home/ns2/ns-allinone-2.34/ns-2.34/
        ns2@ubuntu-10.04:/home/ns2/ns-allinone-2.34/ns-2.34$ bash leach-setup.sh
    If the home directory of your “ns-2.34″ is other than “/home/ns2/ns-allinone-2.34″, then you need to find “…/ns-allinone-2.34″ and replace with “yourpath/ns-allinone-2.34″ for the following two files:
         ”Makefile” : found in the directory “/home/ns2/ns-allinone-2.34/ns-2.34″.
        “Makefile.in” : found in the directory “/home/ns2/ns-allinone-2.34/ns-2.34″.
        4. Edit both “Makefile” & “Makefile.in” as following:
        CC = gcc-4.3
        CPP = g++-4.3

        5. Run the following commands
        ns2@ubuntu-10.04:/home/ns2/ns-allinone-2.34/ns-2.34$ ./configure
        ns2@ubuntu-10.04:/home/ns2/ns-allinone-2.34/ns-2.34$ make clean
        ns2@ubuntu-10.04:/home/ns2/ns-allinone-2.34/ns-2.34$ make

    If you have a problem while ‘make’ and shown error message like this : “trace/cmu-trace.cc: In member function ‘void CMUTrace::format(Packet*, const char*)’: trace/cmu-trace.cc:1327: error: ‘format_rca’ was not declared in this scope trace/cmu-trace.cc: At global scope: trace/cmu-trace.cc:1523: error: no ‘void CMUTrace::format_rca(Packet*, int)’ member function declared in class ‘CMUTrace’ make: *** [trace/cmu-trace.o] Error 1″

Then you need to add this lines into your cmu-trace.h:
    // start from line 165
    #ifdef MIT_uAMPS
    void format_rca(Packet *p, int offset);
    #define ADV_CHAR ‘A’
    #define REQ_CHAR ‘R’
    #define DATA_CHAR ‘D’

    #endif

and also add this line into ns-default.tcl (line 765):

    # ——————————————————
    Phy/WirelessPhy set alive_ 1
    Phy/WirelessPhy set Efriss_amp_ 100e-12
    Phy/WirelessPhy set Etwo_ray_amp_ 0.013e-12

    Phy/WirelessPhy set EXcvr_ 50e-9
    Phy/WirelessPhy set sleep_ 0
    Phy/WirelessPhy set ss_ 1
    Phy/WirelessPhy set dist_ 0
    # ——————————————————

After that you need to re-make.

If the previous commands passed successfully then you are ready to test your “Leach” by running ./test:

ns2@ubuntu-10.04:/home/ns2/ns-allinone-2.34/ns-2.34$ ./test


Check the file “leach.err”, if no error reported then go to “leach.out” for results.

Sunday, August 11, 2013

TCL Error

TCL compilation error:

/home/ramakrishna/ns2/ns-allinone-2.34/tcl8.4.18/library:/usr/lib /home/ramakrishna/ns2/ns-allinone-2.32/lib/tcl8.4 /home/ramakrishna/ns2/ns-allinone-2.34/tcl8.4.18/library:/usr/lib /home/ramakrishna/ns2/ns-allinone-2.34/tcl8.4.18/library:/usr/tcl8.4 /usr/local/lib/tcl8.4 /usr/lib/tcl8.4 /usr/local/library /usr/library /usr/tcl8.4.15/library /tcl8.4.15/library /home/ramakrishna/ns2/ns-allinone-2.32/lib/tcl8.4



This probably means that Tcl wasn't installed properly.


1) cd ns-allinone-2.34/tcl8.4.18/ && ln -s lib/ library
2) Reinstall ns-allinone-2.34

OR

1. Go to location root-usr-local-bin by giving following command in terminal
cd /usr/local/bin
2. There you would find the ns file. We just need to remove it by giving following command
rm ns
3. Thats it, you are done. Now your ns starts running successfully.

Friday, May 31, 2013

'make depend' Error


/bin/sh: Syntax error: Bad fd number
make: *** [depend] Error 2

This is because the default ubuntu 10.04 setting uses dash instead of bash for sh command. Thus, rename the old link of /bin/sh to dash and create new link of /bin/sh to bash.

cd /bin
sudo mv sh sh_orig
sudo ln -s /bin/bash sh