1) Downloadthe setup files from http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.34/ns-allinone-2.34.tar.gz/download
2) Unpackedthe file and cd into the directory, run ./install to begin installation. Thereare some problems during the installation. I will list all of them here.
a. While configure the status of tcl8.4.14, the installation process says that it cannotfind the file Makefile.in. I noticed that the path shown is wrong because Ihave install it in a directory whose name has a blank space. I correct thedirectory name then it become ok.
b. While processing to install the otcl, something wrong happens again.
This is because gcc uses “gcc –shared”instaed of “ld –shared” to generate shared libaray after gcc 4.0 while. So weneed to change “ld –shared” into “gcc –shared” at the77th line of ./otcl-1.13/configure.in and the 6304th lineof ./otcl-1.13/configure.
c.
This is an incompatibility caused by the simplified call to class function in the high version of gcc. Correct it by change the ranvar.cc at the 219th line from
return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u,1.0 / alpha_);
to return GammaRandomVariable(1.0+ alpha_, beta_).value() * pow (u, 1.0 / alpha_);
d. In file included from linkstate/ls.cc:67:0:
linkstate/ls.h: In instantiationof ‘void LsMap::eraseAll() [with Key = int; T = LsIdSeq]’:
linkstate/ls.cc:396:28: required from here
linkstate/ls.h:137:20: error:‘erase’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
linkstate/ls.h:137:20: note:declarations in dependent base ‘std::map, std::allocator > >’ are not found by unqualified lookup
linkstate/ls.h:137:20: note: use‘this->erase’ instead
make: *** [linkstate/ls.o] Error 1
Ns make failed!
Solution: Edit ./ns-2.34/linkstate/ls.h,change from
void eraseAll() {erase(baseMap::begin(), baseMap::end()); }
to voideraseAll() { this->erase(baseMap::begin(), baseMap::end()); }
e. 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
mobile/nakagami.cc:183:73:error: for a function-style cast, remove the redundant ‘::ErlangRandomVariable’
mobile/nakagami.cc:185:67: error:cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directly
mobile/nakagami.cc:185:67:error: for a function-style cast, remove the redundant ‘::GammaRandomVariable’
make: *** [mobile/nakagami.o]Error 1
Ns make failed!
The same solution as c
f. mac/mac-802_11Ext.h:In member function ‘u_int32_t PHY_MIBExt::getHdrLen11()’:
mac/mac-802_11Ext.h:176:19: error: expected primary-expressionbefore ‘struct’
mac/mac-802_11Ext.h:176:41: error:‘dh_body’ was not declared in this scope
mac/mac-802_11Ext.h:176:51: error:‘offsetof’ was not declared in this scope
Solution: Edit the./ns-2.34/mac/mac-802_11Ext.h and add #include<cstddef> to the header files.
3) After all of the above processes, the ns2 is installed succesully. But we still need to set the environment variables.
Then run : source/etc/profile
And then check to see if it runswell. Using ./ns-2.34/validate or do as follows. I recommend to run the validate process and it may take servaral minutes to complete.
If validate successfully, you can finally see the message below. Notice that it won’t terminate unless you pressCtrl+C.
But I still have a problem shown below during validation.
Just install the libperl4-corelibs-perlpackage and then everything goes well.
4) Finally,you can also install the nam.
cd ./nam-1.14
./configure
make
sudo make install
If everything goes well, finally type the nam command and you can see the nam window.