Failure in Wi-Fi physical layer!

111 views
Skip to first unread message

Samyuktha Sena

unread,
Nov 14, 2023, 7:07:35 AM11/14/23
to ns-3-users

I have set up two Access Points (APs) in my network. The first AP (AP1) is connected to two stations, and the second AP (AP2) is connected to one station. I've established a UDP flow between a station connected to AP1 and another connected to AP2.

The issue I'm facing is that the flow is being interrupted, causing logical failures in the code. Both AP1 and AP2 are connected through ad-hoc Wi-Fi, allowing direct communication between them. I need help resolving the conflict to ensure uninterrupted UDP flow between the stations without additional socket communication between AP1 and AP2.

Additionally, the error generated now is an assert failure with the following message:

assert failed. cond="!m_state->IsStateTx () && !m_state->IsStateSwitching ()", +43.020044033356s 6 file=../src/wifi/model/wifi-phy.cc, line=1684

I'm curious if prioritizing communication between AP1 and AP2 over the UDP flow might be a viable solution. If so, what steps or configurations can I implement to prioritize communication between the two APs?

Any insights or suggestions, especially regarding the error message, would be greatly appreciated. Thank you!

Tommaso Pecorella

unread,
Nov 14, 2023, 5:51:53 PM11/14/23
to ns-3-users
Mainly this:
1. Try to replicate it in ns-3-dev.
2. Check if it's a known issue (look in our bug tracker)

If the issue is known, contact the wifi maintainers to help them fix the problem
If the issue is new (and can be replicated), open a new issue (and contact the wifi maintainers).

About the "flow being interrupted", try getting the WiFi devices on different channel numbers, possibly not interfering with each other. The list of the WiFi channel numbers and their interference is on wikipedia.

Samyuktha Sena

unread,
Nov 17, 2023, 3:37:13 PM11/17/23
to ns-3-users
Hello all,

@Tommaso Pecorella, Thank you very much for your suggestion! I am trying to upgrade from ns-3.34 to the development version, it seems to take a lot of time to integrate the tsn part.

Meanwhile, can anyone who is wifi expert look into this implementation to suggest some changes that could possibly be generating this issue.
Any inputs will be much appreciated!

This is the current implementation
/**
 * For the coordination of resources, the communication between APs is performed via the MAC Layer.
 * For this, we model an Ad-Hoc network with all APs
 */
NetDeviceContainer AdHocNet(NodeContainer& Ap1,NodeContainer& Ap2){

   //std::string phyMode ("DsssRate1Mbps");
  //double rss = -80;  // -dBm
  uint32_t packetSize = 1000; // bytes
  uint32_t numPackets = 10;
  double interval = 1.0; // seconds
  bool verbose = false;
 
  CommandLine cmd (__FILE__);

  cmd.AddValue ("packetSize", "size of application packet sent", packetSize);
  cmd.AddValue ("numPackets", "number of packets generated", numPackets);
  cmd.AddValue ("interval", "interval (seconds) between packets", interval);
  cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose);

  /* TODO: commands are currently statically set; for the next version they can be passed via the command line */
  //cmd.Parse (argc, argv);
  // Convert to time object
  Time interPacketInterval = Seconds (interval);
 
  // Fix non-unicast data rate to be the same as that of unicast
  //Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
    //                  StringValue (phyMode));

  Config::SetDefault ("ns3::WifiDefaultAckManager::DlMuAckSequenceType",
EnumValue (WifiAcknowledgment::DL_MU_TF_MU_BAR));
 
  NodeContainer c;
  c.Add(Ap1);
  c.Add(Ap2);
 
  // Define the channel settings, including propagation model, frequency, bandwidth, etc.
  WifiHelper wifi;
  if (verbose)
    {
      wifi.EnableLogComponents ();  // Turn on Wifi logging
    }
  wifi.SetStandard (WIFI_STANDARD_80211ax_5GHZ);

  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();

  Ptr<FriisPropagationLossModel> lossModel
          = CreateObject<FriisPropagationLossModel> ();
lossModel->SetFrequency (5.180e9);
          spectrumChannel->AddPropagationLossModel (lossModel);
  Ptr<ConstantSpeedPropagationDelayModel> delayModel
            = CreateObject<ConstantSpeedPropagationDelayModel> ();
          spectrumChannel->SetPropagationDelayModel (delayModel);

SpectrumWifiPhyHelper phy;
phy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
phy.SetChannel (spectrumChannel);
 
//Set channel physical parameters through new attribute system

TupleValue<UintegerValue, UintegerValue, EnumValue, UintegerValue> value;
value.Set (WifiPhy::ChannelTuple {42, 80, WIFI_PHY_BAND_5GHZ, 0});
phy.Set ("ChannelSettings", value);
WifiMacHelper wifiMac;
int m_mcs = 9;
  std::ostringstream oss;
oss << "HeMcs" << m_mcs;
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", StringValue (oss.str ()),
"ControlMode", StringValue (oss.str ()));



// Activate Ad-Hoc mode
wifiMac.SetType ("ns3::AdhocWifiMac");
NetDeviceContainer devices = wifi.Install (phy, wifiMac, c);

return devices;

}

/******************************************************************************************************
* The next functions handle the implementation of the co-OFDMA probabilistic approach
*
****************************************************************************************************/

/**
* RECEIVER function: SetChanWidth handles the reception by an AP of a frame (model for an Action Frame based on raw sockets) used to
* coordinate the share resources. It then changes the channel frequency in accordance with the received parameters
*/

void SetChanWidth(Ptr<PacketSocketServer>& server)
{

Ptr<Packet> recv = server->GetPkt();
MyHeader destinationHeader;
recv->RemoveHeader (destinationHeader);
int randpara = destinationHeader.GetData();
NS_LOG_UNCOND("Value sent and received= "<<randpara);
NS_LOG_UNCOND("Time is sentrx: "<<Simulator::Now().GetSeconds());

 
float thresh= 0.5;
float result = float(randpara)/float(100);

if (result >= thresh){

// Modifying channel width and number through attribute system
// Both AP and station parameters need to be changed

// Node 6, device 1 (AP2)
Config::Set ("/NodeList/6/DeviceList/1/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelSettings",
             StringValue ("{40, 20, BAND_5GHZ, 0}"));

// Node 9, device 0 (WS1)
Config::Set ("/NodeList/9/DeviceList/0/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelSettings",
             StringValue ("{40, 20, BAND_5GHZ, 0}"));
Ptr<WifiPhy> wp2 = wnd2->GetPhy ();
NS_LOG_UNCOND("\n Channel freq of AP2 is currently =" << wp2->GetFrequency()<<"and channelWidth = "<< wp2->GetChannelWidth());

}

else if (result < thresh){


Config::Set ("/NodeList/6/DeviceList/1/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelSettings",
             StringValue ("{38, 40, BAND_5GHZ, 0}"));

Config::Set ("/NodeList/9/DeviceList/0/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelSettings",
             StringValue ("{38, 40, BAND_5GHZ, 0}"));
Ptr<WifiPhy> wp2 = wnd2->GetPhy ();
NS_LOG_UNCOND("\n Channel freq of AP2 is currently =" << wp2->GetFrequency()<<"and channelWidth = "<< wp2->GetChannelWidth());

}

}


/**
* SENDER function: On the initiating AP, SimValSetup is used to probabilistically select when to change channel parameters
* If the selected value is larger than a threshould then an adaptation to the channel is immediately done, and a message to neighboring
* APs is sent.
*/

void SimValSetup(NodeContainer& AP1NodeContainer,NodeContainer& AP2NodeContainer,NetDeviceContainer& ad_hoc)
{

// Generating random number

RngSeedManager::SetSeed (6);
int randpara;
int min = 1;
int max = 100;
Ptr<UniformRandomVariable> x = CreateObject<UniformRandomVariable> ();
x->SetAttribute ("Min", DoubleValue (min));
x->SetAttribute ("Max", DoubleValue (max));
randpara = x->GetValue ();
NS_LOG_UNCOND("Random value "<<randpara);
 
 // TODO: explore dynamic thresholds
 // TODO: allow the threshold value to be set via arguments on the command line.
float thresh= 0.5;
float result = float(randpara)/float(100);

if (result >= thresh){
// Modifying channel width and number through attribute system
// Both AP and station parameters need to be changed

// Node 5, device 1 (AP1)
// Node 7, device 0 (WS3)
// Node 8, device 0 (WS2)
Config::Set ("/NodeList/5/DeviceList/1/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelSettings",
             StringValue ("{36, 20, BAND_5GHZ, 0}"));
Config::Set ("/NodeList/7/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelSettings",
             StringValue ("{36, 20, BAND_5GHZ, 0}"));
Config::Set ("/NodeList/8/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelSettings",
             StringValue ("{36, 20, BAND_5GHZ, 0}"));

Ptr<WifiPhy> wp1 = wnd->GetPhy ();
NS_LOG_UNCOND("\n Channel freq of AP1 is currently =" << wp1->GetFrequency()<<"and channelWidth = "<< wp1->GetChannelWidth());

}

else if (result < thresh){

Config::Set ("/NodeList/5/DeviceList/1/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelSettings",
             StringValue ("{38, 40, BAND_5GHZ, 0}"));
Config::Set ("/NodeList/7/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelSettings",
            StringValue ("{38, 40, BAND_5GHZ, 0}"));
Config::Set ("/NodeList/8/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelSettings",
             StringValue ("{38, 40, BAND_5GHZ, 0}"));

Ptr<WifiPhy> wp1 = wnd->GetPhy ();
NS_LOG_UNCOND("\n Channel freq of AP1 is currently =" << wp1->GetFrequency()<<"and channelWidth = "<< wp1->GetChannelWidth());

}


/**
* Creates a custom header for the frame to be sent via raw sockets from the initiating AP to the receiving AP
* Header carries the random value randpara
*/
MyHeader test;
MyHeader test2;
Ptr<Packet> p = Create<Packet> (10);
test.SetData(randpara);
p->AddHeader (test);
NS_LOG_UNCOND("Size of packet with header "<<p->GetSize());

// Creating raw sockets
PacketSocketAddress socketAddr;
socketAddr.SetSingleDevice (ad_hoc.Get (0)->GetIfIndex ());
socketAddr.SetPhysicalAddress (ad_hoc.Get (1)->GetAddress ());
// Arbitrary protocol type.
// Note: PacketSocket doesn't have any L4 multiplexing or demultiplexing
// The only mux/demux is based on the protocol field
socketAddr.SetProtocol (1);

Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
client->SetRemote (socketAddr);
client->SetPacket(p);
 

Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
server->SetLocal (socketAddr);
 

AP1NodeContainer.Get (0)->AddApplication (client);
AP2NodeContainer.Get (0)->AddApplication (server);

// Sends frame/packet every 10 seconds - worst case scenario, similar to Beacon interval
// TODO: explore other intervals
Simulator::Schedule ( Seconds (10), &SimValSetup, AP1NodeContainer, AP2NodeContainer,ad_hoc);
Simulator::Schedule ( Seconds (0.02), &SetChanWidth, server);
}

Thank you very much!
Reply all
Reply to author
Forward
0 new messages