[ns] Accessing queue length in 802.11 MAC

Hiddink, Gerrit (Gerrit) ghiddink@agere.com
Tue Jan 7 05:17:03 2003


Hi,

I don't think the downtarget of ll_ is its ifq, as the ifq
is a member class of LL. The downtarget of ll_ is probably
the mac, and if you cast it to a Queue object then you indeed
could get odd values for the length field. 

You could try to trace whether or not the ifq of LL gets
initialized, and to what value. Just setup a simulation with
one node so that you also have only one LL object (otherwise
you could be confused by the different LL objects). 

Good luck,

Gerrit

> -----Original Message-----
> From: Dennis Pong [mailto:unidennis@optushome.com.au]
> Sent: Tuesday, January 07, 2003 1:44 AM
> To: ns-users@ISI.EDU
> Subject: [ns] Accessing queue length in 802.11 MAC
> 
> 
> 
> Hi,
> 
> Thanks Gerrit and Summer for your help. I followed Summer's 
> instructions to 
> initialise the pointer to the LL object. But it seems 
> ll_->ifq() is still 
> NULL and I still get a segmentation fault. Then I tried a 
> different way to 
> get ifq by
> 
> ((Queue *)(ll_->downtarget()))->length(); 
> 
> which I think is doing the same thing as 
> 
> ll_->ifq()->length();
> 
> And I have a queue length of 136211836 everytime I called the 
> send function, 
> which really doesn't make sense. Can anyone help me out?
> 
> Thanks,
> Dennis
> 
> 
> --------------------------------------------------------------
> ------------
> Hi, Dennis
> 
> What Gerrit said is right, the segmentation fault is caused 
> by the NULL 
> pointer. Though "ll_" is a member of Mac class, the only 
> assighment of 
> "ll_" is in the construction function of Mac::Mac():ll_(0), 
> so the "ll_" 
> would equal to 0 all the time. What you can do now is to 
> modify the code. 
> 
> In fact, you can find in "ns-mobilenode.tcl", the structure 
> of a mobilenode 
> is like this: 
> 
> $ll mac $mac
> $ll down-target $ifq
> $ifq target $mac
> $mac netif $netif
> $mac up-target $ll
> 
> as you can see, $ll is set as the up-target of $mac, so you 
> can get the 
> pointer of ll in the command():
> 
> Mac802_11::command(int argc, const char*const* argv)
> {
>         if (argc >= 3) {
>                 if (strcmp(argv[1], "log-target") == 0) {
>                         logtarget_ = (NsObject*) 
> TclObject::lookup(argv[2]);
>                         if(logtarget_ == 0)
>                                 return TCL_ERROR;
>                         return TCL_OK;
>                 } else if(strcmp(argv[1], "nodes") == 0) {
>                         if(cache_) return TCL_ERROR;
>                         cache_node_count_ = atoi(argv[2]);
>                         cache_ = new Host[cache_node_count_ + 1];
>                         assert(cache_);
>                         bzero(cache_, sizeof(Host) * 
> (cache_node_count_+1 ));
>                         return TCL_OK;
>                 }
> 
>           //add your code here
>                   else if(strcmp(argv[1], "up-target") == 0) {
>                            ll_ = (LL *)TclObject::lookup(argv[2]);
>                   }
>          //end here. 
> 
> //Notice, there is no "return TCL_OK" here, becase the 
> "up-target" should 
> be send
> //up to Mac::command()
>          
>          }
>     return Mac::command(argc, argv);
> 
> Then you can get the pointer ll_ and access the ifq_ of it. 
> 
> 
> 
> Summer
> 
> 
> 
> 
> 
> 
> 
> From: "Hiddink, Gerrit (Gerrit)" <ghiddink@agere.com>
> >To: "'unidennis@optushome.com.au'" <unidennis@optushome.com.au>,   
> ns-users@ISI.EDU
> >Subject: RE: [ns] Accessing queue length in 802.11 MAC
> >Date: Mon, 6 Jan 2003 04:00:35 -0500
> >
> >
> >Hi,
> >
> >one of the primary causes of a segmentation fault are
> >references to NULL pointers. So maybe the ll_ pointer is
> >NULL, or its ifq() results NULL. It is good coding style to
> >always check the result of the ifq() call, and to check whether
> >the ll_ pointer is valid.
> >
> >Regards, Gerrit
> >
> > > -----Original Message-----
> > > From: Dennis Pong [mailto:unidennis@optushome.com.au]
> > > Sent: Monday, January 06, 2003 1:28 AM
> > > To: ns-users@ISI.EDU
> > > Subject: [ns] Accessing queue length in 802.11 MAC
> > >
> > >
> > >
> > > Hi ns users,
> > >
> > > I'm trying to access the queue length information from
> > > mac-802_11.cc at the
> > > MAC level. I added the following line in void
> > > Mac802_11::send(Packet* p,
> > > Handler* h)
> > >
> > > int queuelength = ll_->ifq()->length();
> > >
> > > But I got a segmentation fault error. Does anyone knows
> > > what's wrong with it
> > > or any alternative ways to do this?
> > >
> > > Regards,
> > > Dennis
> > >
> 
> 
> _________________________________________________________________
> ?????????????? MSN Messenger: http://messenger.msn.com/cn 
>