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

Re: [ns] Queue-monitoring Agent



Hi Andreas,

Following my earlier email, I have tried the 2nd approach (using call back function & define queue as friend class of my agent) but also encountered segmentation fault (core dumped) during ns run.

I wanted to try the third method you suggested but not sure how to derive a class from both my agent and queue.

Do you have any examples or have you implemented anything similar ?

Thank you.


Cheers,
Aziz

Andreas Alexelis wrote:

    Hi,

    Actually, there are a couple of ways to do it. The "orthodox" way
would be to make the agent ask the queues about their size every time
some other event happens, or using a timer to wake up the agent etc. In
this way you don't need to modify the existing queue models, only the
agent.

    Another way would be to implement a queue with some kind of call
back function. In this case you write a function for the queue to check
it's length and if over the threshold, call some public (or if you make
queue a friend class to your agent whichever)  function of the agent.
With this approach, the queue must have a way to know which agent to
inform ( a pointer at initialization time or sth)

The last (that I can think of) and most "provocative" way ( in a
programming sense) is to derive a class both from Agent and from Queue,
overload "command" and "recv" to do both intended jobs, implement your
agent stuff there, then make it the queue of the link you are interested
in! (some compliers are not friently to classes with multiple occurance
of virtual base class. If yours is one of them, game over ;-)

Hope it helped,

--
Andreas Alexelis, Lab.1 ACR,
Advanced Telecommunications Research, Japan
E-mail: [email protected]

-- 
Abdul Aziz Bin Mustafa                          | Ph: +61 2 9385-4358
School of Computer Science & Engineering        | Fx: +61 2 9385-5995   
University of New  South Wales , Sydney         | Email: [email protected]
NSW 2052 Australia                              | Http://www.cse.unsw.edu.au/~amustafa