[ns] Return value of a scheduled command

2009-10-05 Thread Karsten Roscher

Hello.

I was wondering if there is a way to access the return value of a TCL
command scheduled with $ns at ... (where $ns is the instance of the
simulator). Maybe an example will clarify what I mean:

Let's say I want to setup and cancel some time slot reservation. I have
two commands on a node setup with a bunch of parameters, returning the
id of a reservation and cancel expecting the id of a reservation. What I
wanted to do in my script is something like this...

$ns at 2.0 $node setup ... - we need to access the return value here
$ns at 4.0 $node cancel $id

I tried
$ns at 2.0 set id [$node setup ...]
and also
set id [$ns at 2.0 $node setup ...]


The first one gives an error that (when using cancel) the $id variable is
not defined and the second stores a value in the id but it's not the id
assigned (returned) by the method.

I was wondering if it is possible at all to access the value because as
far as I understood, the at command only schedules the events (and they
get evaluated later). Hence, when scheduling the cancel event the setup
command hasn't been run yet and therefore the assigend id is unknown. But
maybe I'm missing something here. Any ideas? Thanks for your help.

Kind regards,
Karsten Roscher





[ns] Good approach to extend MAC 802_11Ext

2009-07-24 Thread Karsten Roscher

Hello.

I am working on incorporating some MAC functionalities from the 802.11e
standard and later based on this some ideas from the 802.11s draft into
ns-2 (version 2.34) for my thesis.
After some analysis I thought that the new 802.11 MAC (found in
mac-802_11Ext) should be a good basis and the authors consider their
modular design to be easily extendable. However, simply extending the
classes via inheritance seems impossible because most of the member
variables and methods are declared private and I didn't want to touch the
original files. I also guess that there is a reason for making them
private in the first place, I just don't see it.

So far, the only choices I see are either changing the original file
(which I don't want to), use inheritance but reimplement (copy) a lot of
the former code to have it again accessible in the child classes or make a
copy of the original files and adjust them to my needs. I'm leaning
towards the last one but it still doesn't feel right. Is there a better
way to do this?

Thanks a lot.

Regards,
Karsten