Hi Jana,

I suggest you first check whether the bound variables work with AODV in 
the first place.
If they do not work then you will need to get a reference to the AODV 
agent in .tcl simulation script. You can start looking in tcl/lib

P.

Jana Henniger wrote:
> I’m new to ns-2 and C++ and need help concerning OTCL-Linkage.
> I’ve created a new class ContextAgent which has AODV as friendclass. 
> ContextAgent has two public variables that are bound to OTCL using the 
> bind()-function (as it is used in the Example ex-linkage.cc from the tutorial 
> “ns by example”). That works, as far as I could see.
>
> My problem is, how can I call on the variables from the AODV-function 
> sendRequest()?
> Since the ContextAgent is created in the simulation script, I don’t know the 
> name of it to assign it to an object of the type ContextAgent.
>
> I send parts of my source code for better understanding. Please help!!
>
> *************************************************
>
> class ContextAgent : public Agent{
>
> friend class AODV;
>
> public:
>       ContextAgent();
>       int rq_context;
>       int rt_context;
> }
>
> //LinkObject
> static class ContextAgentClass : public TclClass {
> public:
>       ContextAgentClass() : TclClass("Agent/Context"){}
>       TclObject* create(int, const char*const*) {
>               return (new ContextAgent());
>       }
> } class_context_agent;
>
> //Constructor
> ContextAgent::ContextAgent() : Agent(PT_AODV) {
>       bind("rq_cxt_otcl", &rq_context);
>       bind("rt_cxt_otcl", &rt_context);
> };
>
> *************************************
>
> class AODV: public Agent {
>  ...
> private:
>       ContextAgent  *ContextAgentObject;
>  ...
> };
>
> **************************************
>
> // call in AODV-function
> void
> AODV::sendRequest(nsaddr_t dst) {
>  ...
>       ContextAgentObject = ????;
>       rq->rq_cxt = ContextAgentObject->rq_context;
>  ...
> }
>
> **************************************
>
> # tcl-code
>  ...
>       set context1 [new Agent/Context]
>         $ns_ attach-agent $node_(1) $context1
>         $context1 set rq_cxt_otcl 0   
>         $context1 set rt_cxt_otcl 5   
>  ...
>
>
>   

Reply via email to