WifiNetDevice: access to packet's informations when they are dropped by collision or at reception

89 views
Skip to first unread message

Kevin Tewouda

unread,
Mar 25, 2015, 12:33:13 PM3/25/15
to ns-3-...@googlegroups.com
Hello everyone,
I have three questions
1- I'm testing Wifi Netdevice and I would like to know when there is a packet collision. Indeed, looking at the official documentation, I realized that there are traces to determine if a packet is successfully sent, received and accepted, received but refused (phyRxEnd, PhyRxDrop,..). But I do not see how to know if a packet has been destroyed following a road collision.
Does anyone have an idea?

2- 
Regarding the callback function for packets deleted at the reception => typedef void (* ns3 :: Packet :: TracedCallback) (const Ptr <const Packet> packet)
I created a method inspired by a example I saw me and which run correctly, in order to access the source ip address and the destination ip address.



void PhyRxDrop (std::string context, Ptr<const Packet> p)
{
   
Ptr<Packet> packet = p->Copy();
   
SocketAddressTag tag;
   
bool found;
   found
= packet->PeekPacketTag (tag);
   
if(found)
   
{
     
...
     
InetSocketAddress addr = InetSocketAddress::ConvertFrom (tag.GetAddress ());
      oss
<< " PHY : received one packet from " << addr.GetIpv4 ();
   
}
}

i don't know why but the line found = packet->peekPacketTag(tag) doesn't work. Does anyone have an idea?

3 - The last question, is how can i use this callback in an example to get the snr of the packet dropped at reception. 

typedef Callback<void,Ptr<const Packet>, double> ns3::WifiPhy::RxErrorCallback

Best regards.

Kevin Tewouda

unread,
Mar 27, 2015, 3:45:55 AM3/27/15
to ns-3-...@googlegroups.com
Hello,
Please, can someone help me answer these questions.
Best regards.

Tommaso Pecorella

unread,
Mar 27, 2015, 4:45:35 AM3/27/15
to ns-3-...@googlegroups.com
Hi,

question 1: see YansWifiPhy::EndReceive

  if (m_random->GetValue () > snrPer.per)
   
{
...
   
}
 
else
   
{
     
/* failure. */
     
NotifyRxDrop (packet);
      m_state
->SwitchFromRxEndError (packet, snrPer.snr);
   
}


Question 2: the tag is added by the L4 protocol, where the IP address is already known. See for example UdpSocketImpl::ForwardUp.
The trace you're looking at is fired by L2 (or below) and doesn't contain that info.
As a side note, searching for that info is not "right". If the packet is dropped by the MAC, the node doesn't know where the packet came from, and can't know. If the packet is dropped it's because of errors, and any info from the partially decoded packet is unreliable.

Question 3: I don't understand the question. You use it as any other callback. The manual is full if examples (and the examples directory too).

T.
Reply all
Reply to author
Forward
0 new messages