Setting EDCA Contention Windows (Cw) parameters in 802.11

1,551 views
Skip to first unread message

Mehmet Ali Ertürk

unread,
Jan 7, 2014, 9:15:15 AM1/7/14
to ns-3-...@googlegroups.com
Hi,

I had some issues when setting contention windows parameters (cw) and finally it is fixed. I hope this will help others too. 

When I  set Contention Windows params with DcaTxop and EdcaTxopN pointers, (I see this action in the log EnableLogComponents )
but when nodes initialised default parameters set, not the ones specified as minCw, maxCw. 

int minCw = 32;

int maxCw = minCw;


Ptr<DcaTxop> m_beaconDca = CreateObject<DcaTxop>();

m_beaconDca->SetMinCw(minCw);

m_beaconDca->SetMaxCw(maxCw);


Ptr<EdcaTxopN> m_edca = CreateObject<EdcaTxopN>();

m_edca->SetMinCw(minCw);

m_edca->SetMaxCw(maxCw);



I fixed this problem by getting each node and setting params separately for each node in the network. Also, for EDCA every category has to be defined. Here is the solution;


        Ptr<Node> node = stas.Get(i); // 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;

mac->GetAttribute("DcaTxop", ptr);

        Ptr<DcaTxop> dca = ptr.Get<DcaTxop>();

dca->SetMinCw(minCw);

dca->SetMaxCw(maxCw);

//dca->SetAifsn(2);


Ptr<EdcaTxopN> edca;

mac->GetAttribute("VO_EdcaTxopN", ptr);

edca = ptr.Get<EdcaTxopN>();

edca->SetMinCw(minCw);

edca->SetMaxCw(maxCw);

//edca->SetAifsn(2);


mac->GetAttribute("VI_EdcaTxopN", ptr);

edca = ptr.Get<EdcaTxopN>();

edca->SetMinCw(minCw);

edca->SetMaxCw(maxCw);

//edca->SetAifsn(2);


mac->GetAttribute("BE_EdcaTxopN", ptr);

edca = ptr.Get<EdcaTxopN>();

edca->SetMinCw(minCw);

edca->SetMaxCw(maxCw);

//edca->SetAifsn(2);


mac->GetAttribute("BK_EdcaTxopN", ptr);

edca = ptr.Get<EdcaTxopN>();

edca->SetMinCw(minCw);

edca->SetMaxCw(maxCw);

//edca->SetAifsn(2);

Shahwaiz

unread,
Jan 7, 2014, 10:03:45 AM1/7/14
to ns-3-...@googlegroups.com
Hi Mehmet,

Thanks a lot. Your method definitely works.

Can you give any idea of how to fix difs value of a the cheating node?
In the wifi-mac.cc, there is a parameter EifsNoDifs. But how can I set the DIFS value only?

Regards,
Shahwaiz

Mehmet Ali Ertürk

unread,
Jan 7, 2014, 10:20:41 AM1/7/14
to ns-3-...@googlegroups.com
Hi,

Available parameters for wifi-mac are listed as below;
  • CtsTimeout: When this timeout expires, the RTS/CTS handshake has failed.
  • AckTimeout: When this timeout expires, the DATA/ACK handshake has failed.
  • BasicBlockAckTimeout: When this timeout expires, the BASIC_BLOCK_ACK_REQ/BASIC_BLOCK_ACK handshake has failed.
  • CompressedBlockAckTimeout: When this timeout expires, the COMPRESSED_BLOCK_ACK_REQ/COMPRESSED_BLOCK_ACK handshake has failed.
  • Sifs: The value of the SIFS constant.
  • EifsNoDifs: The value of EIFS-DIFS
  • Slot: The duration of a Slot.
  • Pifs: The value of the PIFS constant.
  • Rifs: The value of the RIFS constant.
  • MaxPropagationDelay: The maximum propagation delay. Unused for now.
  • Ssid: The ssid we want to belong to.
I don't see anything for setting just DIFS. I'm not sure if there are alternative ways to do it.

M Ali
7 Ocak 2014 Salı 17:03:45 UTC+2 tarihinde Shahwaiz yazdı:

Konstantinos

unread,
Jan 7, 2014, 11:58:46 AM1/7/14
to ns-3-...@googlegroups.com
Hi,

Following the standard (IEEE 802.11-2012),

DIFS = SIFS + (2 * Slot time)

So you can control DIFS by changing SIFS. 

Steve muni

unread,
Jan 8, 2014, 6:10:07 AM1/8/14
to ns-3-...@googlegroups.com
Thanks! very useful

Steve muni

unread,
Jul 31, 2014, 2:55:57 PM7/31/14
to ns-3-...@googlegroups.com
Hi Konstantinos

Do you know where in the code is implemented this statement? I would like modify it but I cant find it.

Thank you

kind regards
Message has been deleted

Konstantinos

unread,
May 19, 2015, 10:17:20 AM5/19/15
to ns-3-...@googlegroups.com, lewo...@gmail.com
Hi Kevin,

Have you tried this and does it work? 
Because I would say that this code snipped you posted is just wrong.

The XX_EdcaTxopN and DcaTxop attributes of RegularWifiMac that you are setting with this code need a PointerValue pointing to a Queue object
They are READ-ONLY attributes. 

So, future readers of the list please discard the above mentioned 'simpler' way as it is not correct. 

Regards,
K.

On Tuesday, May 19, 2015 at 2:51:57 PM UTC+1, Kevin Tewouda wrote:
Hello,
I would point out that there is a much simpler way to assign values to all nodes without going through a loop and in a few lines.
here it is:
Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/VO_EdcaTxopN", UintegerValue (63));
Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/VI_EdcaTxopN", UintegerValue (63));
Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/BE_EdcaTxopN", UintegerValue (63));
Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/BK_EdcaTxopN", UintegerValue (63));
Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/DcaTxop", UintegerValue (63));

Kevin Tewouda

unread,
May 20, 2015, 5:13:29 AM5/20/15
to ns-3-...@googlegroups.com, lewo...@gmail.com
Hi Konstantinos,
thank you for your notice. I realized it this morning while running my simulation. I apologize.
 Is there no simpler solution than what is proposed above?

Konstantinos

unread,
May 20, 2015, 5:18:39 AM5/20/15
to ns-3-...@googlegroups.com, lewo...@gmail.com
Not that I am aware.

You could wrap it within a function that will only require input e.g. the node and the CW limit so that the code is hidden by the end-user.
That's up to you.

Kevin Tewouda

unread,
May 20, 2015, 11:12:00 AM5/20/15
to ns-3-...@googlegroups.com, lewo...@gmail.com
Ok thank you.

Tann Lybear

unread,
May 22, 2015, 9:05:40 AM5/22/15
to ns-3-...@googlegroups.com
Hi Mehmet Ali Ertürk, 

I am really appreciate with your help !

I want to testing relationship between throughput and delay with different value of contention Window , I have configuration like code below , but I don't know how to debug or know my setting is correct or not.
I try to change with different value of this setting ,but still the throughput is same  ,so i think the coding is missing some things.
could you give some idea about this ?

Thanks 
best regards,
libea

uint32_t minCw = 15;
uint32_t maxCw = 30;
// setup AP
mac.SetType ("ns3::ApWifiMac","Ssid", SsidValue (ssid));
NetDeviceContainer apDevice;
apDevice = wifi.Install (phy, mac, wifiApNode);

// setup STATIOIN
mac.SetType ("ns3::StaWifiMac","Ssid", SsidValue (ssid),"ActiveProbing", BooleanValue (false));
NetDeviceContainer staDevices;
staDevices = wifi.Install (phy, mac, wifiNodes);

DcaTxop dcatxop;
dcatxop.SetMinCw(minCw);
dcatxop.SetMaxCw(maxCw);
Message has been deleted
Message has been deleted

Konstantinos

unread,
Oct 3, 2015, 5:54:29 AM10/3/15
to ns-3-users
Have you that perhaps the node has only one NetDevice?

On Saturday, October 3, 2015 at 10:30:59 AM UTC+1, CvAnet wrote:

When I replace  the line Ptr<NetDevice> dev = node->GetDevice(0); with

Ptr<NetDevice> dev = node->GetDevice(1);

why it generates error.

Please help

CvAnet

unread,
Oct 3, 2015, 6:08:57 AM10/3/15
to ns-3-users
Sir,
I am new to NS3.

In my script I am using 3 nodes and I want to set MaxCw and MinCw.

I have configured each node as mentioned in the above script and Its working fine .

Ptr<NetDevice> dev = node->GetDevice(0);      does it mean that set one net device for each node ?



Regards

Konstantinos

unread,
Oct 3, 2015, 9:04:14 AM10/3/15
to ns-3-users
Please study the tutorial for NS-3 first to understand the code and I may also say that you might need some C++ basics (objects).
The line you used 
Ptr<NetDevice> dev = node->GetDevice(0);  

simply means that you get the first NetDevice (since C++ starts counting from zero) from the particular 'node'.
If you want to do this for all the nodes, or any nodes, you have to get the corresponding pointers to those nodes.

Regards,
K.

Shey Janota

unread,
Apr 4, 2022, 7:14:10 PM4/4/22
to ns-3-users
Hi guys,

I'm trying to print the values of CW on Ubuntu's Terminal but is not working. can anyone help me figure this out  please?
I'm using class Txop to access the values of CW like this

#include "ns3/txop.h"


/*
Helper Function for TX Operation
*/
Ptr<Txop> GetTxop(Ptr<Node> node)
{

    Ptr<NetDevice> dev = node->GetDevice(0);
    Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
    Ptr<WifiMac> rmac = wifi_dev->GetMac ();
    PointerValue ptr;
    rmac->GetAttribute ("Txop", ptr);
    Ptr<Txop> txop = ptr.Get<Txop> ();
   
    return txop;
}

void CwTrace (std::string context, uint32_t oldVal, uint32_t newVal)
{
  std::cout << "CwTrace " << std::endl;
  NS_LOG_INFO ("CW time=" << Simulator::Now () << " node=" << ContextToNodeId (context) << " val=" << newVal);
  if (tracing)
    {
      std::cout << Simulator::Now ().GetSeconds () << " " << ContextToNodeId (context) << " " << newVal << std::endl;
    }
}

Inside the Main I added a callback to trace CW

// Trace CW evolution
  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/Txop/CwTrace", MakeCallback (&CwTrace));

Tom Henderson

unread,
Apr 4, 2022, 8:33:52 PM4/4/22
to ns-3-...@googlegroups.com
On 4/4/22 16:14, Shey Janota wrote:
> Hi guys,
>
> I'm trying to print the values of CW on Ubuntu's Terminal but is not
> working. can anyone help me figure this out  please?
> I'm using class Txop to access the values of CW like this

Mak sure that you call Config::Connect after you install the Wifi
devices (i.e., the object has to exist before you try to connect to it).

- Tom

Shey Janota

unread,
Apr 5, 2022, 11:15:48 AM4/5/22
to ns-3-...@googlegroups.com
Hi Tom,

Yes, Config::Connect is being called after the installation of the Wifi devices.


Sheila Janota

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/83287314-a222-713e-4f00-920d6cee16cf%40tomh.org.

Tom Henderson

unread,
Apr 5, 2022, 11:20:44 AM4/5/22
to ns-3-...@googlegroups.com
On 4/5/22 08:18, Shey Janota wrote:
> Hi Tom,
>
> Yes, Config::Connect is being called after the installation of the Wifi
> devices.
>

I don't have other advice at the moment, then. The wifi-bianchi.cc
example program demonstrates how to use the trace source. If you need
more help, you may have to post your program for review.

- Tom

Tom Henderson

unread,
Apr 5, 2022, 12:22:04 PM4/5/22
to ns-3-...@googlegroups.com
On 4/5/22 08:18, Shey Janota wrote:
> Hi Tom,
>
> Yes, Config::Connect is being called after the installation of the
> Wifi devices.

If you are using ns-3.29, please make sure that the Config::Connect
string path matches the config path for that release.  There was a
change between ns-3.29 and ns-3.30 (documented in the file CHANGES.html).

Doxygen is maintained on the website for all releases; e.g.:
https://www.nsnam.org/docs/release/3.29/doxygen/index.html

- Tom

Shey Janota

unread,
Apr 5, 2022, 12:27:04 PM4/5/22
to ns-3-...@googlegroups.com
As an attachment, I'm sending the rate adaptation distance that I'm working on.

I tried to run The wifi-bianchi.cc example in ns-3.29 which is the version that I'm using. and it didn't work.

I suppose it should be running at version ns-3.35.

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
rate-adaptation-distance-v003.cc
Reply all
Reply to author
Forward
0 new messages