[ns] [solved] Calculating Queue Length at a wireless node
Jyothirmye Reddy
vjreddy246 at gmail.com
Tue Oct 18 06:36:33 PDT 2011
I found some solution to this problem, not
I defined a procedure QueueLength in the Droptail.cc file this time (and
not in Priqueue.cc file like before)
DropTail::QueueLength (nsaddr_t id) {
struct hdr_cmn *ch;
int QLength = 0;
Packet *p = 0;
for(p = q_->head(); p; p = p->next_) {
ch = HDR_CMN(p);
if(ch->next_hop() == id) // to see any packets in the queue waiting
to reach that node
QLength++;
}
return QLength;
}
and then I added a instance Priqueue *ifq_ in the class definition in my
rtproto.h file, which is a derived class from Agent.
And in the rtproto.cc file, I called it by saying ifq_->QueueLength(id); (id
is the node id of the node of interest).
I am thinking this is a correct method, correct me if my concept is wrong.
and you are welcomed if there is any simpler procedure to do this.
Regds,
Jyothi
On Sat, Oct 15, 2011 at 6:00 PM, JyothiR <vjreddy246 at gmail.com> wrote:
>
>
> Hi,
>
> I am trying to implement a new routing protocol for MANETs, for which I
> need
> to calculate the number of packets waiting at a node (Or) the length of the
> queue.
> I know how to calculate the queue length on a wired network (for which the
> queue is on the link instead of on the node, I am guessing so). I have also
> seen a solution to dump the queue length into the trace from tcl file.
>
> But, what I need is to access the length of the queue in my C++ code (the
> routing protocol).
>
> >From some post I have read, the Queue length can be accessed from the
> "priqueue.cc" file by adding a procedure, because that is where all the
> packets are 'enqued'. Which I did, but the problem is I am unable to access
> the q_ variable, which holds the queue information. I am unable to figure
> out how the variable can be accessed.
>
> This is the code I am trying to execute.
>
> PriQueue *myqueue;
>
> int res = myqueue->QueueLength(node_id);
>
> QueueLength is the procedure defined in priqueue.cc file which is defined
> as,
>
> int PriQueue:QueueLength(nsaddr_t id)
> {
> struct hdr_cmn *ch;
> int QLength = 0;
> Packet *p = 0;
>
> for(p = q_->head(); p; p = p->next_) {
> Packet *p = q_->lookup(i);
> ch = HDR_CMN(p);
> if(ch->next_hop() == id)
> QLength++;
> }
> return QLength;
> }
>
> The point to access the q_ variable "q_->head()" throws a segmentation
> fault
> (core dumped) error. I have seen that q_ variable is not showing any values
> when I called this procedure (Something to do with the instances of a class
> I guess).
>
> Any help (not necessarily solutions- suggestions and hints will also do) is
> greatly appreciated. I have done all the research I could, from the ns
> manual and also the mailing lists, but couldn't get a solution.
>
>
> Regds,
> Jyothi
> --
> View this message in context:
> http://old.nabble.com/-ns--Calculating-Queue-Length-at-a-wireless-node-tp32659587p32659587.html
> Sent from the ns-users mailing list archive at Nabble.com.
>
>
More information about the Ns-users
mailing list