Re: [ns] accessing queue length in 802.11 MAC

2011-06-14 Thread St4Ski0


Hi, anyone as tested this method?
I've insert following code in mac-802_11.cc in recvDATA() but i've
segmentation fault problem...why if i test if the pointer is non-null?

int pkt_in_q = 0;

//Thesis
if ( ((LL *)uptarget_)-ifq()){
//code if non-null
pkt_in_q = ((LL *)uptarget_)-ifq()-length();
printf(non-null queue \n);
} else {
// code if null
printf(null queue \n);
}


M. Shen wrote:
 
 
 Dear guys,
 
 I tried to access queue length in MAC. So I wrote 
 int pkt_num = ((LL *)uptarget_)-ifq()-length(); 
 
 When I run the simulation us gdb, segmentation fault occurs. I shows
 that
 
 Program received signal SIGSEGV, Segmentation fault.
 0x080c3ad4 in Queue::length() (this=0x0) at queue/queue.h:136
 136 int length() { return pq_-length(); }  /* number of pkts currently
 in
 
 Does any one know how to deal with this problem?
 
 Thank you very much,
 Min
 
 
 

-- 
View this message in context: 
http://old.nabble.com/Re%3A-accessing-queue-length-in-802.11-MAC-tp7713314p31833588.html
Sent from the ns-users mailing list archive at Nabble.com.



Re: [ns] accessing queue length in 802.11 MAC

2006-12-06 Thread M. Shen

Dear ghada,

Thank you very much for your reply. But how to check if the queue is
null or not? Should I do it in the queue.cc peoriodically and transfer
the state to mac? Or check it in the MAC? If it's the latter, we still
need to access ifq() in the mac.cc, right?

thanks,
Min


On Wed, 6 Dec 2006 14:03:15 +0900
 ghada [EMAIL PROTECTED] wrote:
 
  I think you can solve this problem if you check first  if the queue
 is null 
 or not before using length() function.
 
 
 - Original Message - From: M. Shen [EMAIL PROTECTED]
 To: ns-users@ISI.EDU
 Sent: Wednesday, December 06, 2006 12:10 PM
 Subject: Re: [ns] accessing queue length in 802.11 MAC
 
 
 
  Dear guys,
 
  I tried to access queue length in MAC. So I wrote
  int pkt_num = ((LL *)uptarget_)-ifq()-length();
 
  When I run the simulation us gdb, segmentation fault occurs. I
 shows
  that
 
  Program received signal SIGSEGV, Segmentation fault.
  0x080c3ad4 in Queue::length() (this=0x0) at queue/queue.h:136
  136 int length() { return pq_-length(); }  /* number of pkts
 currently
  in
 
  Does any one know how to deal with this problem?
 
  Thank you very much,
  Min
 
  
 



Re: [ns] accessing queue length in 802.11 MAC

2006-12-06 Thread Pedro Vale Estrela



Use:

If( ((LL *)uptarget_)-ifq()){
//code if non-null
} else {
// code if null
}

note that a null queue é a node without a queue, NOT an empty queue!


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
 Of M. Shen
 Sent: quarta-feira, 6 de Dezembro de 2006 14:56
 To: ghada; ns-users@ISI.EDU
 Subject: Re: [ns] accessing queue length in 802.11 MAC
 
 
 Dear ghada,
 
 Thank you very much for your reply. But how to check if the queue is
 null or not? Should I do it in the queue.cc peoriodically and transfer
 the state to mac? Or check it in the MAC? If it's the latter, we still
 need to access ifq() in the mac.cc, right?
 
 thanks,
 Min
 
 
 On Wed, 6 Dec 2006 14:03:15 +0900
  ghada [EMAIL PROTECTED] wrote:
 
   I think you can solve this problem if you check first  if the queue
  is null
  or not before using length() function.
 
 
  - Original Message - From: M. Shen [EMAIL PROTECTED]
  To: ns-users@ISI.EDU
  Sent: Wednesday, December 06, 2006 12:10 PM
  Subject: Re: [ns] accessing queue length in 802.11 MAC
 
 
  
   Dear guys,
  
   I tried to access queue length in MAC. So I wrote
   int pkt_num = ((LL *)uptarget_)-ifq()-length();
  
   When I run the simulation us gdb, segmentation fault occurs. I
  shows
   that
  
   Program received signal SIGSEGV, Segmentation fault.
   0x080c3ad4 in Queue::length() (this=0x0) at queue/queue.h:136
   136 int length() { return pq_-length(); }  /* number of pkts
  currently
   in
  
   Does any one know how to deal with this problem?
  
   Thank you very much,
   Min