I think neither trace-queue nor queue-monitor can be used on a wireless
node since both are inserted in links and there are no links in a wireless
topology. In wireless IFQ (interface queue) is implemented on a node (
refer the section on mobilenetworking in ns in ns-manuel for details of
mobile node implementation)
Though I am not an expert in ns, I can share the method I have used to get
the queue length
1. Define a variable qlength_ in the common header of the packet:
ie add the line
int qlength_;
in the struct hdr_cmn.
2.In appropriate place in the queue function you are using, eg in the
recv() function of prique.cc or in enque() function of drop-tail.cc, read
the value of queue length and write it to the above variable qlength_ :
ch->qlength_ = q_->length();
before this declare ch as pointer to common header of the packet by:
struct hdr_cmn *ch = HDR_CMN(p);
3.Now you can access this variable qlength_ from any other function in the
path of the packet.
for eg., in the mac-802_11.cc recvDATA() function, add some printf
statement to display the value of ch->qlength_
or you can write the value into your output file queue1.tr from
mac-802_11.cc recvDATA() function, by adding the following in that
function
//to write to a file
Tcl& tcl = Tcl::instance();
char wrk[100];
sprintf(wrk, "puts $fp1 \"node=%d Q length=%d \" \n", index_,
ch->qlength_);
tcl.eval(wrk);
where fp1 is the pointer to the file queue1.tr. index_ gives the node number
set fp1 [open queue1.tr w] #add this line in your tcl file
Make the ns before executing
Hope this will help you.
Reena
> Date: Tue, 3 Jun 2008 23:58:33 +0530
> From: "Bhanoji Kandalam" <[EMAIL PROTECTED]>
> Subject: [ns] Monitoring a queue in wireless scenario
> To: [email protected]
>
> I am trying to monitor queue using monitor-queue, by using the following
> piece of code
>
> set queue_mon [$ns monitor-queue $node_(0) $node_(1) [open queue1.tr w]
> 0.1]
>
> and then I want to access the packets that are currently there in the
> queue
>
> set packets [$queue_mon set pkts_] #will packets variable hold the
> current number of #packets by using above statement?
>
> When I do this it gives me following error
> can't read "link_(0:1)": no such variable
> while executing
> "$link_([$n1 id]:[$n2 id]) init-monitor $self $qtrace $sampleInterval"
> (procedure "_o3" line 3)
> (Simulator monitor-queue line 3)
> invoked from within
> "$ns monitor-queue $node_(0) $node_(1) [open queue1.tr w] 0.1"
> invoked from within
> "set queue_mon [$ns monitor-queue $node_(0) $node_(1) [open queue1.tr w]
> 0.1]"
>
>
> Some body please help me in this regard