Modify code source in ns2

63 views
Skip to first unread message

arnaudmw...@gmail.com

unread,
Dec 15, 2020, 7:54:54 AM12/15/20
to Network Simulator 2 (NS2)
hi, i installed centos6.10 and nist-mob module to simulate  a vertical handover between wimax and wifi. I prefer modifying the source code handover-2.cc from the folder ns-2.29/hsntg and execute it form OTCL interpreter but i don't know how to proceed. 

Could you help me with steps on how to modify source code in ns2 and execute it from OTCL interpreter, please ?

knudfl

unread,
Dec 15, 2020, 8:19:35 AM12/15/20
to Network Simulator 2 (NS2)
Hi.

CentOS 6 - i386:
su
yum install gcc-c++ compat-gcc-34-c++ autoconf automake libtool libXmu-devel
-----

The default ns2 procedure is this :
tar xvf ns-allinone-2.29.3.tar.gz
cd ns-allinone-2.29/
tar xvf ns-2.29-nist-mob-022707.tgz
patch -p0 < pmip6-for-ns-2.29-nist.patch    ## if pmip6 is to be included
           ## modify handover-2.cc
export CC=gcc34 CXX=g++34 && ./install
cd ns-2.29/
copy ns ns-nist-new         ## ns-nist-new  is the new "OTCL interpreter"
su
copy ns-nist-new /usr/local/bin/
-------------- Simulation ---------------
ns-nist-new file.tcl

arnaudmw...@gmail.com

unread,
Dec 15, 2020, 8:44:19 AM12/15/20
to Network Simulator 2 (NS2)
Thank you sir for replying. After modifying the handover-2.cc how can i do to compile it ? so that the modification can be taken in consideration by NS

arnaudmw...@gmail.com

unread,
Dec 15, 2020, 9:26:42 AM12/15/20
to Network Simulator 2 (NS2)
I researched on google on how to compile a code source ( for example handover-2.cc) in ns2. I found this : g++ handover-2.cc -o handover-2.
When i execute i receive the following error :
      
      In file included from handover-2.cc:31:
      handover-2.h : 34:22 error : handover.h: No such file or directory
     handover-2.h : 35:23 error :  simulator.h: No such file or directory  
    handover-2.cc : 33:18 error :  mip6.h:  No such file or directory  
     .........

I thought that it was the problem of the file handover-2.cc. I used another file " dumb-agent.cc" when i compile it with this command in the prompt (g++  dumb-agent.cc -o dumb-agent ) , i receive a simular message: 
             In file included from  dumb-agent.cc: 49:
            dumb-agent.h: 56:19: error: agent.h: No suchfile or directory
             dumb-agent.h: 57:16: error: ll.h: No such file or directory
           dumb-agent.h: 58:19: error:  trace.h: No such file or directory  
          .........
        How can i fix this issue ?

knudfl

unread,
Dec 15, 2020, 12:25:34 PM12/15/20
to Network Simulator 2 (NS2)
ns2 : Usually no single file (or a single folder with files) can be compiled separately.
See Makefile.in to know how things are connected.
I.e. to create the interpreter = ns ,  the following is required .....
otcl/*, tcl/*/*, tclcl/*, ns-2.29/{ ~200 c++ files, tcl/lib/files.tcl }

arnaudmw...@gmail.com

unread,
Dec 15, 2020, 3:36:18 PM12/15/20
to Network Simulator 2 (NS2)
Thank you sir. I have other two questions:

        First:  all folders  (otcl/*, tcl/*/*, tclcl/*, ns-2.29  ) are in my ns-allinone2.29. Could you help me with steps on how to compile a file with cc as extension in NS2 ?
       Second question: concerns the precedent thread about Xgraph 
       I tried to follow with
                        Build xgraph :  Please make sure that automake is installed ....
# yum install autoconf automake libtool

Fedora 12 :
cd xgraph-12.2/
rm -f depcomp
ln -s /usr/share/automake-1.11/depcomp
./configure
make
su
# cp xgraph /usr/local/bin/
exit
cd examples/
xgraph xgtest.xg
*******************************************
  When i run ./configure, i get at the end this information:  autoconf.h  is unchanged
  When i run  make, i get this error: 
             

gcc -DHAVE_CONFIG_H -I. -I. -I.        -g    -c dialog.c
dialog.c: In function ‘make_msg_box’:
dialog.c:780: warning: passing argument 2 of ‘getline’ from incompatible pointer type
/usr/include/stdio.h:673: note: expected ‘size_t * __restrict__’ but argument is of type ‘char *’
dialog.c:780: error: too few arguments to function ‘getline’
dialog.c: In function ‘getline’:
dialog.c:899: error: argument ‘lptr’ doesn’t match prototype
/usr/include/stdio.h:673: error: prototype declaration
dialog.c:899: error: number of arguments doesn’t match prototype
/usr/include/stdio.h:673: error: prototype declaration
make: *** [dialog.o] Error 1

Please, could you help ?

knudfl

unread,
Dec 15, 2020, 6:38:58 PM12/15/20
to Network Simulator 2 (NS2)
1.ns-allinone-2.29
»»Could you help me with steps on how to compile a file with cc as extension in NS2 ?«« :
A file : No .....  not possible,  see my previous answer → Repeat →
→  All files are required to compile a file / an otcl interpreter.
Simple : Delete ns-2.29/hsntg/handover-2.o  and  ns-2.29/ns  (if present)
( 'make clean' will delete all files.o and ns ).
.... and run make  in ns-2.29
Or run export CC=gcc34 CXX=g++34 && ./install in ns-allinone-2.29

2.   Xgraph : The year 2005 version in ns-allinone-2.29 is too old.
$ tar xvf ns-allinone-2.35_gcc5.tar.gz          ## 2014 update
https://drive.google.com/file/d/0B7S255p3kFXNVVlxR0ZNRGVORjQ/view?usp=sharing
cd ns-allinone-2.35/xgraph-12.2/
 ........ and continue according to the Fedora 12 / CentOS 6 description you found.
Reply all
Reply to author
Forward
0 new messages