How to overcome the overriding problem?

58 views
Skip to first unread message

Doaa Terri

unread,
Jul 20, 2015, 10:01:56 AM7/20/15
to ns-3-...@googlegroups.com
Hi all,

I want to modify the contention window ( CW) value for a specific node, I found that the CW can be changeable using an attribute system.   

So I use this: 
void SetCwMin(uint16_t cw)
{
   Config::Set("/NodeList/0/DeviceList/0/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/DcaTxop/CwMin", UintegerValue(cw));

}

Simulator::Schedule(Seconds(20.0), &SetCwMin, 2); 

However, this value is not changing. Through my search , I found that this happens because there is already a predefined CW value in the DCF class that my value is overriding. 
The proposed solution was here : 

I tried to follow the same thing but unable to do so. Actually, I did not understand what to do exactly. 
I tried to add this as mentioned :  
attribute; e.g. 

+    .AddAttribute ("CwMin", 
+                  "Set the minimum contention window.", 
+                  UintegerValue (15), 
+                  MakeUintegerAccessor (&DcaTxop::m_cwMin), 
+                  MakeUintegerChecker<uint32_t> ())

but I got that m_cwMin is undefined!

Can some one help me in this. 
 

pdbarnes

unread,
Jul 20, 2015, 10:23:49 AM7/20/15
to ns-3-...@googlegroups.com
The Config system changes the default value for new instances, but that doesn't affect any instances which already exist. Usually you need to change the Config before creating your model.

For your Attribute You'll have to give the error message for us say anything useful.

Peter

Doaa Terri

unread,
Jul 20, 2015, 10:35:08 AM7/20/15
to ns-3-...@googlegroups.com
Thank you Peter for your reply!

How can I change the config before creating the model?

this is the error I got :
error: class"ns3: DcaTxop" has no member "m_cwMin"



--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/2zEdg2lUe84/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Konstantinos

unread,
Jul 20, 2015, 10:39:24 AM7/20/15
to ns-3-...@googlegroups.com, doaa...@gmail.com
Hi Doaa,

I do not think that you can change the contention window using the Config system.
You shouldn't have added any new attribute. The MinCw and MaxCw exist in DcaTxop class 

Try using the method proposed here 

You can move the CW setting within another method which you can schedule at some other time.

Doaa Terri

unread,
Jul 20, 2015, 1:35:52 PM7/20/15
to ns-3-...@googlegroups.com
Hi Konstantinos!

Thank you for your reply!

Your suggested method works fine! 

This method works without putting the cw inside a method and then scheduling it later on , but i do not know why 

this is what I have tried : 

I made the input for the function as follows: the node, min and max CW 

void chaan( Ptr<Node> node, uint32_t minCw, uint32_t maxCw )
{

 //Ptr<Node> node = wifiStaNodes.Get(0);

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)


Then inside the main, I added the scheduling as follows: 
Simulator::Schedule(Seconds(20.0), &chaan, wifiStaNodes.Get(0), 2,2); 


--
Reply all
Reply to author
Forward
0 new messages