[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q: usage of recv(Packet*)



The answer is TTLChecker::recv as can be seen from the backtrace:

#0  TTLChecker::recv (this=0x837e638, p=0x8406048, h=0x0) at ttl.cc:69
#1  0x804fc71 in NsObject::handle (this=0x837e638, e=0x8406048) at object.cc:101
#2  0x804db24 in Scheduler::dispatch (this=0x837cdf8, p=0x8406048, t=1.0023359999999999)
    at scheduler.cc:123
#3  0x804db4d in Scheduler::dispatch (this=0x837cdf8, p=0x8406048) at scheduler.cc:129
...

What I find interesting about this is that TTLChecker::recv isn't
defined to have the second argument as default.  Apparently the
resolution goes like this:
	1. in handle(Event *) the call to recv((Packet*)e)
	   at the compile-time is first substituted with a call to
	   recv((Packet*)e, 0)
	2. at the run-time this is looked up in the virtual table with
	   the result of calling TTLChecker::recv((Packet*)e, 0)
I think somebody just forgot to define TTLChecker::recv(Packet*, Handler* =0).
It seems better style to do so.

  -Yuri

Sjoerd Janssen <[email protected]> writes:

> Hi,
> 
> I'd appreciate input on this following -probably simple- question on ns
> which I require to understand ns better.
> 
> The target_ of the linkdelay object is the ttl checker object. The
> linkdelay object passes a
> packet to the ttl checker object by the following line (in delay.cc)
> 
> s.schedule(target_, p, txt + delay_);     // static links
> 
> if I walk through the code in scheduler.cc I reckon that at the
> scheduled time, the handle() function at the target_ is called, with the
> packet (event) as an argument. At the ttl checker  object, there is no
> handle function so the one defined in object.cc is used (ttl checker
> inherits from connector, inherits from nsobject). That handle function
> does the following:
> 
> recv((Packet *)e);    // e being an event, always a packet in this case
> 
> Q: where can I find the recv(Packet*) function that is called.
> 
> I know that at the classifier object (coming after the ttl checker
> object) the function
> recv(Packet* p, Handler* h) is called, but how is this done given the
> previous?
> 
> Regards, Sjoerd Janssen.