Sometimes, we need to know how something runs in NS2 and check if it is ok. Here I will introduce a way to trace the operation, which I get from the wpan model in NS2.
1. add some trace words in a C++ function (e.g. in xx.cc, function yy):
#ifdef TraceMark fprintf(stdout,"[%s::%s][%f] Just a test\n",__FILE__,__FUNCTION__,Scheduler::instance().clock()); #endif
2. add trace support in Makefile:
DEFINE = -DTCP_DELAY_BIND_ALL -DNO_TK -DTCLCL_CLASSINSTVAR -DNDEBUG -DLINUX_TCP_HEADER -DUSE_SHM -DHAVE_LIBTCLCL -DHAVE_TCLCL_H -DHAVE_LIBOTCL1_13 -DHAVE_OTCL_H -DHAVE_LIBTK8_4 -DHAVE_TK_H -DHAVE_LIBTCL8_4 -DHAVE_TCL_H -DHAVE_CONFIG_H -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=std -DUSE_SINGLE_ADDRESS_SPACE -Drng_test -DTraceMark
Remember not -TraceMark but -DTraceMark. (C++ Debug tech)
Then "make" the new simulator, run a script, you will find the following on the stdout.
[xx.cc::yy][5.004672] Just a test. |