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

Re: [ns] node_ base Agent class




>
>Agent/Ping instproc recv {from rtt} {
>          $self instvar node_
>          puts "node [$node_ id] received ping answer from \
>                $from with round-trip-time $rtt ms."
>  }
>  
>Where does the instance variable node_ come from? In the tutorial it says that 
>it is a member variable of the base class for Agent. I can't find a reference 
to 
>it in any of the code. I have checked many source files, including Agent.cc and 
>Agent.c. Do anyone have any ideas?

tcl/lib/ns-agent.tcl or tcl/lib/ns-lib.tcl maybe? 

>
>Here is another part that troubles me:
>
>sprintf(out, "%s recv %d %3.1f", name(), 
>              hdrip->src_.addr_ >> Address::instance().NodeShift_[1],
>              (Scheduler::instance().clock()-hdr->send_time) * 1000);
>              
>What is the method name()? It clearly should be a metod which executes the recv 
>proc mentioned above. But how does it operate?

I think it just returns a name for the object the method is called on, so you 
can distinguish one agent from the other

>Also, what is the Address::instance stuff doing? Some sort conversion from 
>internal node source address to an tcl address?


please look at the docs. Address also contains a port number, so basically yes 
you need to do a conversion.

>
>I would really appreciate your help,
>
>/Anders 
>
>
>
>
>

Tarik