Monday, 6 May 2013

How to debug NS2 using gdb



1) Extract  NS2 tar file.
2) Modify Makefile.in from ns-allinone2.34/ns2.34/
           
1. change CCOPT = @V_CCOPT@ to CCOPT = @V_CCOPT@ -g 
2. add -DNDEBUG -DDEBUG to the end of DEFINE = -DTCP_DELAY_BIND_ALL -DNO_TK @V_DEFINE@ @V_DEFINES@ @DEFS at -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=@CPP_NAMESPACE at -DUSE_SINGLE_ADDRESS_SPACE -Drng_test 

that is: 

DEFINE = -DTCP_DELAY_BIND_ALL -DNO_TK @V_DEFINE@ @V_DEFINES@ @DEFS at -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=@CPP_NAMESPACE at -DUSE_SINGLE_ADDRESS_SPACE -Drng_test -DNDEBUG -DDEBUG 

now browse to .../ns-allinone/ns2.3x and run ./configure and after that "make clean" and then "make"

2) Open terminal and type in "gdb ns"
3)then " run tcl_file_name"

If there are errors gdb will stop at respective location.

2 comments:

  1. hi,
    i've tried your solution, well this now gives me error when i type make, in some other file that i am not even intended to use like (shadowing.cc, aodv.cc, aomdv..) well this questioned the embedded protocols that comes with the allinone-2.34 which until now was compiling fine. have i missed something? i only need to debug my protocols the ones inherent to ns2 are working fine.

    ReplyDelete
  2. hi,
    How to simulate ddos attack in ns2?

    ReplyDelete