[ns] Queue length monitor on wireless medium
Amr Ramadan
amr_silver at hotmail.com
Mon Apr 27 06:15:19 PDT 2009
Dear All
I found someone with a method to monitor queue length on wireless on ns2
but the problem that I can't assign which node number to read the queue
length from it so can anybody tell me how to assign the node number to this
method and here is the method:
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
BR
More information about the Ns-users
mailing list