After setting cwMin and cwMax some stations are returning to default (StaWifiMac::Receive function)

145 views
Skip to first unread message

Klaudia Gądek

unread,
Apr 4, 2018, 2:57:30 PM4/4/18
to ns-3-users
After setting CwMin and CwMax. We can see that some Cw min and CW max values are returning to default. Could somebody tell me, why ns-3 is setting EDCA parameters during simulations, not only in initialization phase. It is set in StaWifiMac::Receive function(sta-wifi-mac.cc file). 

I would be grateful if you could tell my why it is implemented this way?

Thank, you in advance. 


More informations:

I am setting CwMin and CwMax in script: 
for (uint16_t i = 0; i < nnode+1; ++i)
{
Ptr<Node> node;
if (i==nnode){
        node = wifiApNode.Get(0);
}
else{
        node = wifiStaNode.Get(nnode - (i+1)); // Get station from node container 
}
Ptr<NetDevice> dev = node->GetDevice(0);
Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice>(dev);
Ptr<WifiMac> mac = wifi_dev->GetMac();
        PointerValue ptr;
Ptr<EdcaTxopN> edca;
mac->GetAttribute("VO_EdcaTxopN", ptr);
edca = ptr.Get<EdcaTxopN>();
edca->SetMinCw(CWmin);
edca->SetMaxCw(CWmax);
mac->GetAttribute("VI_EdcaTxopN", ptr);
edca = ptr.Get<EdcaTxopN>();
edca->SetMinCw(CWmin);
edca->SetMaxCw(CWmax);

mac->GetAttribute("BE_EdcaTxopN", ptr);
edca = ptr.Get<EdcaTxopN>();
edca->SetMinCw(CWmin);
edca->SetMaxCw(CWmax);
mac->GetAttribute("BK_EdcaTxopN", ptr);
edca = ptr.Get<EdcaTxopN>();
edca->SetMinCw(CWmin);
edca->SetMaxCw(CWmax);
}

Logs(We can see that Cwmin and CWmax were set):

Line 2690: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMinCw(0x2671e90, 1)
Line 2691: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMaxCw(0x2671e90, 1)
Line 2692: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMinCw(0x26725c0, 1)
Line 2693: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMaxCw(0x26725c0, 1)
Line 2694: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMinCw(0x2672d00, 1)
Line 2695: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMaxCw(0x2672d00, 1)
Line 2696: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMinCw(0x2673450, 1)
Line 2697: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMaxCw(0x2673450, 1)
Line 2698: [mac=00:00:00:00:00:09] EdcaTxopN:SetMinCw(0x266e100, 1)
Line 2699: [mac=00:00:00:00:00:09] EdcaTxopN:SetMaxCw(0x266e100, 1)
Line 2700: [mac=00:00:00:00:00:09] EdcaTxopN:SetMinCw(0x266e830, 1)
Line 2701: [mac=00:00:00:00:00:09] EdcaTxopN:SetMaxCw(0x266e830, 1)
Line 2702: [mac=00:00:00:00:00:09] EdcaTxopN:SetMinCw(0x266ef70, 1)
Line 2703: [mac=00:00:00:00:00:09] EdcaTxopN:SetMaxCw(0x266ef70, 1)
Line 2704: [mac=00:00:00:00:00:09] EdcaTxopN:SetMinCw(0x266f6c0, 1)
Line 2705: [mac=00:00:00:00:00:09] EdcaTxopN:SetMaxCw(0x266f6c0, 1)
Line 2706: [mac=00:00:00:00:00:08] EdcaTxopN:SetMinCw(0x266a400, 1)
Line 2707: [mac=00:00:00:00:00:08] EdcaTxopN:SetMaxCw(0x266a400, 1)
Line 2708: [mac=00:00:00:00:00:08] EdcaTxopN:SetMinCw(0x266ab30, 1)
Line 2709: [mac=00:00:00:00:00:08] EdcaTxopN:SetMaxCw(0x266ab30, 1)
Line 2710: [mac=00:00:00:00:00:08] EdcaTxopN:SetMinCw(0x266b270, 1)
Line 2711: [mac=00:00:00:00:00:08] EdcaTxopN:SetMaxCw(0x266b270, 1)
Line 2712: [mac=00:00:00:00:00:08] EdcaTxopN:SetMinCw(0x266b9c0, 1)
Line 2713: [mac=00:00:00:00:00:08] EdcaTxopN:SetMaxCw(0x266b9c0, 1)
Line 2714: [mac=00:00:00:00:00:07] EdcaTxopN:SetMinCw(0x2666700, 1)
Line 2715: [mac=00:00:00:00:00:07] EdcaTxopN:SetMaxCw(0x2666700, 1)
Line 2716: [mac=00:00:00:00:00:07] EdcaTxopN:SetMinCw(0x2666e30, 1)
Line 2717: [mac=00:00:00:00:00:07] EdcaTxopN:SetMaxCw(0x2666e30, 1)
Line 2718: [mac=00:00:00:00:00:07] EdcaTxopN:SetMinCw(0x2667570, 1)
Line 7419: [mac=00:00:00:00:00:0a] DcaTxop:SetMinCw(0x2671a20, 15)
Line 7420: [mac=00:00:00:00:00:0a] DcaTxop:SetMaxCw(0x2671a20, 1023)
Line 7423: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMinCw(0x2672d00, 15)
Line 7424: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMaxCw(0x2672d00, 1023)
Line 7427: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMinCw(0x2673450, 15)
Line 7428: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMaxCw(0x2673450, 1023)
Line 7431: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMinCw(0x26725c0, 7)
Line 7432: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMaxCw(0x26725c0, 15)
Line 7435: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMinCw(0x2671e90, 3)
Line 7436: [mac=00:00:00:00:00:0a] EdcaTxopN:SetMaxCw(0x2671e90, 7)
Line 9113: [mac=00:00:00:00:00:0b] EdcaTxopN:GetMinCw(0x2676b50)
Line 9114: [mac=00:00:00:00:00:0b] EdcaTxopN:GetMaxCw(0x2676b50)

I am not sure why we are setting EDCA parameters here:

void
StaWifiMac::Receive (Ptr<Packet> packet, const WifiMacHeader *hdr)
{
  NS_LOG_FUNCTION (this << packet << hdr);
  NS_ASSERT (!hdr->IsCtl ());
  if (hdr->GetAddr3 () == GetAddress ())
    {
      NS_LOG_LOGIC ("packet sent by us.");
      return;
    }
  else if (hdr->GetAddr1 () != GetAddress ()
           && !hdr->GetAddr1 ().IsGroup ())
    {
      NS_LOG_LOGIC ("packet is not for us");
      NotifyRxDrop (packet);
      return;
    }
  else if (hdr->IsData ())
    {
      if (!IsAssociated ())
        {
          NS_LOG_LOGIC ("Received data frame while not associated: ignore");
          NotifyRxDrop (packet);
          return;
        }
      if (!(hdr->IsFromDs () && !hdr->IsToDs ()))
        {
          NS_LOG_LOGIC ("Received data frame not from the DS: ignore");
          NotifyRxDrop (packet);
          return;
        }
      if (hdr->GetAddr2 () != GetBssid ())
        {
          NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore");
          NotifyRxDrop (packet);
          return;
        }
      if (hdr->IsQosData ())
        {
          if (hdr->IsQosAmsdu ())
            {
              NS_ASSERT (hdr->GetAddr3 () == GetBssid ());
              DeaggregateAmsduAndForward (packet, hdr);
              packet = 0;
            }
          else
            {
              ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
            }
        }
      else
        {
          ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
        }
      return;
    }
  else if (hdr->IsProbeReq ()
           || hdr->IsAssocReq ())
    {
      //This is a frame aimed at an AP, so we can safely ignore it.
      NotifyRxDrop (packet);
      return;
    }
  else if (hdr->IsBeacon ())
    {
      MgtBeaconHeader beacon;
      packet->RemoveHeader (beacon);
      CapabilityInformation capabilities = beacon.GetCapabilities ();
      bool goodBeacon = false;
      if (GetSsid ().IsBroadcast ()
          || beacon.GetSsid ().IsEqual (GetSsid ()))
        {
          NS_LOG_LOGIC ("Beacon is for our SSID");
          goodBeacon = true;
        }
      SupportedRates rates = beacon.GetSupportedRates ();
      bool bssMembershipSelectorMatch = false;
      for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
        {
          uint32_t selector = m_phy->GetBssMembershipSelector (i);
          if (rates.IsBssMembershipSelectorRate (selector))
            {
              NS_LOG_LOGIC ("Beacon is matched to our BSS membership selector");
              bssMembershipSelectorMatch = true;
            }
        }
      if (m_phy->GetNBssMembershipSelectors () > 0 && bssMembershipSelectorMatch == false)
        {
          NS_LOG_LOGIC ("No match for BSS membership selector");
          goodBeacon = false;
        }
      if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ())
        {
          NS_LOG_LOGIC ("Beacon is not for us");
          goodBeacon = false;
        }
      if (goodBeacon)
        {
          Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons);
          RestartBeaconWatchdog (delay);
          SetBssid (hdr->GetAddr3 ());
          bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
          if (m_erpSupported)
            {
              ErpInformation erpInformation = beacon.GetErpInformation ();
              isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
              if (erpInformation.GetUseProtection() == true)
                {
                  m_stationManager->SetUseNonErpProtection (true);
                }
              else
                {
                  m_stationManager->SetUseNonErpProtection (false);
                }
              if (capabilities.IsShortSlotTime () == true)
                {
                  //enable short slot time
                  SetSlot (MicroSeconds (9));
                }
              else
                {
                  //disable short slot time
                  SetSlot (MicroSeconds (20));
                }
            }
           // if (m_qosSupported)
           // {
           //   EdcaParameterSet edcaParameters = beacon.GetEdcaParameterSet ();
          //    //The value of the TXOP Limit field is specified as an unsigned integer, with the least significant octet transmitted first, in units of 32 μs.
          //    SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin(), edcaParameters.GetBeCWmax(), edcaParameters.GetBeAifsn(), 32 * MicroSeconds (edcaParameters.GetBeTXOPLimit()));
          //    SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin(), edcaParameters.GetBkCWmax(), edcaParameters.GetBkAifsn(), 32 * MicroSeconds (edcaParameters.GetBkTXOPLimit()));
          //    SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin(), edcaParameters.GetViCWmax(), edcaParameters.GetViAifsn(), 32 * MicroSeconds (edcaParameters.GetViTXOPLimit()));
          //    SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin(), edcaParameters.GetVoCWmax(), edcaParameters.GetVoAifsn(), 32 * MicroSeconds (edcaParameters.GetVoTXOPLimit()));
          //  }
          m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
          m_stationManager->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ());
        }
      if (goodBeacon && m_state == BEACON_MISSED)
        {
          SetState (WAIT_ASSOC_RESP);
          SendAssociationRequest ();
        }
      return;
    }
  else if (hdr->IsProbeResp ())
    {
      if (m_state == WAIT_PROBE_RESP)
        {
          MgtProbeResponseHeader probeResp;
          packet->RemoveHeader (probeResp);
          CapabilityInformation capabilities = probeResp.GetCapabilities ();
          if (!probeResp.GetSsid ().IsEqual (GetSsid ()))
            {
              //not a probe resp for our ssid.
              return;
            }
          SupportedRates rates = probeResp.GetSupportedRates ();
          for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++)
            {
              uint32_t selector = m_phy->GetBssMembershipSelector (i);
              if (!rates.IsSupportedRate (selector))
                {
                  return;
                }
            }
          for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
            {
              WifiMode mode = m_phy->GetMode (i);
              uint8_t nss = 1; // Assume 1 spatial stream
              if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, nss)))
                {
                  m_stationManager->AddSupportedMode (hdr->GetAddr2 (), mode);
                  if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, nss)))
                    {
                      m_stationManager->AddBasicMode (mode);
                    }
                }
            }
            
          bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
          if (m_erpSupported)
            {
              bool isErpAllowed = false;
              for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
              {
                WifiMode mode = m_phy->GetMode (i);
                if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM && rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)))
                  {
                    isErpAllowed = true;
                    break;
                  }
              }
              if (!isErpAllowed)
                {
                  //disable short slot time and set cwMin to 31
                  SetSlot (MicroSeconds (20));
                  //ConfigureContentionWindow (31, 1023);
                }
              else
                {
                  ErpInformation erpInformation = probeResp.GetErpInformation ();
                  isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
                  if (m_stationManager->GetShortSlotTimeEnabled ())
                    {
                      //enable short slot time
                      SetSlot (MicroSeconds (9));
                    }
                  else
                    {
                      //disable short slot time
                      SetSlot (MicroSeconds (20));
                    }
                  //ConfigureContentionWindow (15, 1023);
                }
            }
          m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled);
          m_stationManager->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ());
          SetBssid (hdr->GetAddr3 ());
          Time delay = MicroSeconds (probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons);
          RestartBeaconWatchdog (delay);
          if (m_probeRequestEvent.IsRunning ())
            {
              m_probeRequestEvent.Cancel ();
            }
          SetState (WAIT_ASSOC_RESP);
          SendAssociationRequest ();
        }
      return;
    }
  else if (hdr->IsAssocResp ())
    {
      if (m_state == WAIT_ASSOC_RESP)
        {
          MgtAssocResponseHeader assocResp;
          packet->RemoveHeader (assocResp);
          if (m_assocRequestEvent.IsRunning ())
            {
              m_assocRequestEvent.Cancel ();
            }
          if (assocResp.GetStatusCode ().IsSuccess ())
            {
              SetState (ASSOCIATED);
              NS_LOG_DEBUG ("assoc completed");
              CapabilityInformation capabilities = assocResp.GetCapabilities ();
              SupportedRates rates = assocResp.GetSupportedRates ();
              bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
              if (m_erpSupported)
                {
                  bool isErpAllowed = false;
                  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
                  {
                    WifiMode mode = m_phy->GetMode (i);
                    if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM && rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)))
                      {
                        isErpAllowed = true;
                        break;
                      }
                  }
                  if (!isErpAllowed)
                    {
                      //disable short slot time and set cwMin to 31
                      SetSlot (MicroSeconds (20));
                      //ConfigureContentionWindow (31, 1023);
                    }
                  else
                    {
                      ErpInformation erpInformation = assocResp.GetErpInformation ();
                      isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
                      if (m_stationManager->GetShortSlotTimeEnabled ())
                        {
                          //enable short slot time
                          SetSlot (MicroSeconds (9));
                        }
                      else
                        {
                          //disable short slot time
                          SetSlot (MicroSeconds (20));
                        }
                      //ConfigureContentionWindow (15, 1023);
                    }
                }


Rediet

unread,
Apr 9, 2018, 6:14:43 AM4/9/18
to ns-3-users
It's up to the AP to define the parameters that'll be used on its BSS. Why not set the AP's parameters also so that they may be notified later on?
Reply all
Reply to author
Forward
0 new messages