Sunday, April 22, 2012

Re: [ns] How to implement the wireless link queue

Hello Sancale.

Even if it is a somewhat late reply I followed the same steps as you in
order to trace the queue size at a node in wireless scenario, and I hope it
is useful for someone else having this issues.

The first error you report in:

set now [$ns_ now]
set qlen [$node_(0) set curq_]
puts $queuefile "$now $qlen"
$ns_ at [expr $now+$time] "record"

You are trying to access the variable curq_ in node, which is wrong, as
curq_ is member of the class PriQueue. So, in order to access it, you should
first get the PriQueue object, and from it access the variable curq_, as in
the example:

set node0ifq [$node_(0) set ifq_(0)] # node0ifq <= node_0.ifq_(0)
then
set curq_dest [$node0ifq set curq_]

The variable curq_ is traceable because it was instantiated as a TracedInt
variable in the PriQueue.h file. For getting to know better how the trace
process is achieved, I recommend that you consult NS2 litterature which
covers this topic. I suggest "An Introduction to NS2" edited by Springer. It
has a hole chapter on it.

And now..... =)

The solution to the

"I obtain an error in the last line "$node0_ifq attach $queuechan".
If I comment it, I have no error, but qlen.tr is empty. "

The error you find might be of the type:

(_o43 cmd line 1)
invoked from within
"_o43 cmd attach file"
invoked from within
"catch "$self cmd $args" ret"

As you said, it is a very common problem. It appears when you create new
models for NS2. It took me a while to realize, and here comes the
explanation:

The problem comes from the line "$self cmd $args" which yields the _obj cmd
attach file where cmd is cmd command in the OTcl/Tcl Hierarchy, and args (in
our case, but there are many others) reffers to "attach name_of_file". This
cmd command has its counterpart in the C++ hierarchy.

In the file PriQueue.h and PriQueue.cc (ns/queue/priqueue.[h,cc]) there is a
method named "PriQueue::command(int argc, const char*const* argv)" it is an
inherited method which is called when "$self (the queue obj) cmd $args" is
called. There you need to define how to react to the argument "attach", like
in:

int PriQueue::command(int argc, const char*const* argv)
{
Tcl& tcl = Tcl::instance(); // <== ADD INSTANCE OF TCL
if (argc == 2 && strcasecmp(argv[1], "reset") == 0)
{
Terminate();
//FALL-THROUGH to give parents a chance to reset
}

if (strcasecmp(argv[1], "attach") == 0) // ATTEND THE ATTACH CASE
{
int mode;
const char* id = argv[2];
tchan_ = Tcl_GetChannel(tcl.interp(), (char*)id, &mode); // <= Get the
TraceFile if present

// It is declared in the TCL line $node0_ifq attach $queuechan
if (tchan_ == 0){
tcl.resultf("Trace: No se pudo asociar %s para escritura",id);
return(TCL_ERROR);
}
return(TCL_OK);
}
return DropTail::command(argc, argv);
}

In this way you specify how to attach the trace file to your traced
variable. The printing of the trace is made in the "trace" method present in
the PriQueue Class.

Hope It helped you!! Or anybody else out there.

My conclusion nevertheless, is that there is no easy way with this
simulator. It is a very powerful one, but one has to go through the way of
knowing it, by searching the web, reading the NS-manual, and STUDYING the
code.


Best Regards,
Israel Herrera
Mexico City
CINVESTAV


sancale wrote:
>
> Hello,
> I'm trying to monitor queue size in wireless scenario.
> I've read this topic:
> http://old.nabble.com/how-to-monitor-the-queue-on-a-wireless-node-to30608840.html
> how-to-monitor-the-queue-on-a-wireless-node
> And do the things explained in:
> http://hpds.ee.ncku.edu.tw/~smallko/ns2/qa_en.htm
> http://hpds.ee.ncku.edu.tw/~smallko/ns2/qa_en.htm
> but I'm not able to access to curq_ variable.
> I'm trying with a "record" proc like this one:
>
> proc record {} {
> global ns_ node_ queuefile
> set time 1
> set now [$ns_ now]
> set qlen [$node_(0) set curq_]
> puts $queuefile "$now $qlen"
> $ns_ at [expr $now+$time] "record"
> }
> But I obtain the follow error:
> ns: record: can't read "curq_": no such variable.
>
> I think that I'm not reading in a good way the var curq_, because I think
> it is a variable from the queue object (not the node), but I'm not able to
> obtain it.
> Could you explain in detail how you access this variable and trace it?
>
>
>
> By the way, when I try to trace it via
>
> set node0ifq [$node_(0) set ifq_(0)]
> set queuechan [open qlen.tr w]
> $node0_ifq trace curq_
> $node0_ifq attach $queuechan
>
> I obtain an error in the last line "$node0_ifq attach $queuechan".
> If I comment it, I have no error, but qlen.tr is empty.
> How can I fix it?
>
> Sorry if it's a "many times" question, but I haven't found any other
> answer but the one I told before, and it is not useful to me, and if
> nobody ask "at least" one time this question, you will have many other
> people asking same things again and again :S
> I'm using ns2-allinone-2.34 over Ubuntu 10.10 (kernel 2.6.35-25 generic).
> If you need further information, please ask me.
> Thanks and regards!
>
> PS: sorry for my English, I'm not fluent.
>
>
>
>
> Huang-13 wrote:
>>
>>
>>
>> Hey all,
>>
>> I am trying to get the queue sizes of several wireless links (802.11). I
>> configure the 802.11 nodes and set the ifqType as DropTail or RED with
>> ifqlen 60. Then I can trace the "curq_" from the queue object of the
>> node. But is it the same thing as the wireless link queue? Compared to
>> the wired network, we have the node queue and also we can set the link
>> queue by the command like:
>> "ns duplex-link $n0 $n1 10Mb 20ms DropTail".
>> "ns queue - limit $n1 $n2 60"
>>
>> So, I am wandering whether the link queue and node queue are the same
>> thing? If not, how can I convert the node's queue into link queue in
>> wireless?
>>
>> Any comment would be appreciated.
>>
>> Thank you all,
>>
>> Song
>>
>>
>
>
--
View this message in context: http://old.nabble.com/How-to-implement-the-wireless-link-queue-tp29143488p33724033.html
Sent from the ns-users mailing list archive at Nabble.com.

No comments:

Post a Comment

Counter

blogger analytics