Query about collision and NAV statistics in WiFi

109 views
Skip to first unread message

BB

unread,
May 7, 2019, 4:33:38 PM5/7/19
to ns-3-users
I want to run a simulation with one AP and several STAs. For each successful transmission of a packet by a node, I want to record:

1. The number of collisions faced for that particular transmission.
2. The amount of time the node deferred prior to the successful transmission of this packet.

My problem is the following:

1. I don't know if there is any field in the 802.11 MAC header which indicates the total number of collisions faced by a received frame.
2. I want to know which function in the source code should be modified to report the amount of defer time prior to successful transmission of a packet.

Any help/pointers on this will be highly appreciated.
Thanks.

BB

unread,
May 22, 2019, 9:45:51 AM5/22/19
to ns-3-users
Guys,

I'm really stuck on this. Any help will be highly appreciated.

Thanks.
Peshal

Con con

unread,
May 23, 2019, 4:58:21 AM5/23/19
to ns-3-users
Hello, as far as I know there are the following callbacks :
Maybe there are other but these are the callbacks I used.
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/MonitorSnifferRx", MakeCallback (&MonitorSnifferRxCallback));
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxDrop", MakeCallback (&PhyTxDropCallback));
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop", MakeCallback (&PhyRxDropCallback));
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/MacRxDrop", MakeCallback (&MacRxDropCallback));
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/MonitorSnifferRx", MakeCallback (&MonitorSnifferTxCallback));

you have to define a callback function also for each one of them and write the calculations/logic within this callback function .. for example. 
void MonitorSnifferRxCallback(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu, struct signalNoiseDbm signalNoise)
{
  std::cout << "Packet Received  ! " << std::endl;
}

There is a problem last months that people is not contributing to this forum anymore and do not know why... If someone knows something let us know.

Adil Alsuhaim

unread,
May 24, 2019, 10:41:29 AM5/24/19
to ns-3-users
Here's a suggestion, I think you should look into ChannelAccessManager class. You can see what's going on if you enable logging on it

LogComponentEnable ("ChannelAccessManager", LOG_LEVEL_ALL);



Or running the ns3 program as follows

NS_LOG="ChannelAccessManager" ./waf --run ProgramName



This should show you collisions and internal collisions. I don't think you have a trace source that you can use to trace those values, so you can either have your program run (with Logging enabled) then post process the programs' output (write a script that extract the information you need) or modify ChannelAccessManager by adding some code to save to a file , or variable, and create a function to get that value. 

You may also want to consider enabling logging on MacLow  if the parameters in it are interesting.  

BB

unread,
Jun 11, 2019, 5:55:00 PM6/11/19
to ns-3-users
Hi Con con

Thanks for your reply. This was very useful. I've a question regarding MonitorSnifferRx. I used the callback using the example you stated. But I'm unable to understand how to obtain the duration of the transmission for the packet. I print out the rate. But the rate that it provides does not map to any 802.11 rate. For instance, it gives values of rate as 24, 130, 128. How do I map these to the phy data rate used for transmitting this packet? Or is there another way to obtain the rate. I'm using rate to calculate the packet transmission duration. Is there any other way to obtain the transmission duration?

Thanks.

Yiannis

unread,
Jun 13, 2019, 11:40:01 AM6/13/19
to ns-3-users
Hi BB,

the duration of the packets is calculated in many places (as far as I remember), e.g. use logging in MacLow as mentioned by Adil and check the CalculateTxDuration(). 
How did you print the rate? Are they HE-rates?

BR,
yiannis

BB

unread,
Jun 13, 2019, 6:05:35 PM6/13/19
to ns-3-users
Hi yiannis,

Thanks for your reply. To print the rates, I used the method that Con Con had suggested.

Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/MonitorSnifferRx", MakeCallback (&MonitorSnifferRxCallback));

and then

void MonitorSnifferRxCallback(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu, struct signalNoiseDbm signalNoise)
{

  std
::cout << rate << std::endl;
}

In my simulations, I use WIFI_PHY_STANDARD_80211n_2_4GHZ to set the standards.

Thanks.
Peshal

Hamid Sanan

unread,
Jan 11, 2021, 10:49:23 AM1/11/21
to ns-3-users

Kindly share the basic script with me, i am also working on same problem. I am dealing with collisions in wifi using QoS
Reply all
Reply to author
Forward
0 new messages