[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] question about #define DEBUG and printout of variable
Thanks Lloyd for your quick and kind answer.
I still can't fix my problem.
I am doing my simulation about modified AODV routing mechanism. I tried to
printout some values of existing variable in ~ns/ns-2.1b8a/aodv.cc like:
void
AODV::recvRequest(Packet *p)
{
Tcl& tcl = Tcl::instance();
Node *thisnode = Node::get_node_by_address(index);
MobileNode *node_;
struct hdr_cmn *ch = HDR_CMN(p);
struct hdr_ip *ih = HDR_IP(p);
struct hdr_aodv_request *rq = HDR_AODV_REQUEST(p);
rt_entry *rt;
double x = 0.0, y = 0.0, z = 0.0;
node_ -> getLoc(&x, &y, &z);
printf("time = %.9f, x = %.2f, y = %.2f, z = %.2f, this node = %d\n",
CURRENT_TIME, x, y, z, index);
tcl.evalf("time = %.9f, x = %.2f, y = %.2f, z = %.2f, this node = %d\n",
CURRENT_TIME, x, y, z, index);
.............
.............
.............
}
As you might see from above tcl script, I tried to print out the value of
CURRENT_TIME, x, y, z and index whenever recvRequest function is called.
But there is nothing happened during my simulation.
How can I see this values or make this value to be stored in specific file?
Could you help me?
Thank you in advance.
Joo-Han
----- Original Message -----
From: "Lloyd Wood" <l.wood@eim.surrey.ac.uk>
To: "Joo-Han Song" <sjh1swj@telus.net>
Cc: "ns-users" <ns-users@ISI.EDU>
Sent: Tuesday, December 25, 2001 12:37 PM
Subject: Re: [ns] question about #define DEBUG
> On Tue, 25 Dec 2001, Joo-Han Song wrote:
>
> > The reason why I am trying to use DEBUG option is that I hope to trace a
> > specific variable during my simulation whenever specific function is
called.
> > So is there any method I can use to trace the changes of specific
variable?
>
> print it out; the debug class variable allows you to do
> if (debug_) printf("blah %i", metasyntacthing);
>
> only on that variable for the particular objects you are interested in
> (once you have done/scheduled $object set debug_ 1), rather than say
> the other thousand or so objects your simulate-the-internet simulation
> might also have running. Easier than trying to print out info to
> identify which object you're looking at.
>
> Alternatively, there's gdb and its trace and
> breakpoint functionality...
>
> L.
>
> <L.Wood@surrey.ac.uk>PGP<http://www.ee.surrey.ac.uk/Personal/L.Wood/>
>