Could I Config:SetDefault() again in the same Simulator::Run() ?

65 views
Skip to first unread message

Jian Liu

unread,
Mar 15, 2022, 3:56:07 PM3/15/22
to ns-3-users
For example,

Config::SetDefault ("ns3::MmWavePhyMacCommon::CenterFreq", DoubleValue (28000000));

Could I reset it again to a different value later?
Config::SetDefault ("ns3::MmWavePhyMacCommon::CenterFreq", DoubleValue (39000000));  

Soulimane Mammar

unread,
Mar 17, 2022, 1:42:27 AM3/17/22
to ns-3-users
Hi,
If you do this before running the simulation, the last statement will override the first.
If at some point in your simulation, you schedule an event that changes the value of some attribute, the newly changed value will take effect at that moment
Regards 

Tom Henderson

unread,
Mar 18, 2022, 12:14:49 AM3/18/22
to ns-3-...@googlegroups.com, Jian Liu

Yes, you can call this multiple times.  However, the value only affects objects that are instantiated after that statement.

So, for instance:

Config::SetDefault ("ns3::MmWavePhyMacCommon::CenterFreq", DoubleValue (28000000));
Ptr<MmWavePhyMacCommon> common1 = CreateObject<mmWavePhyMacCommon> ();

Config::SetDefault ("ns3::MmWavePhyMacCommon::CenterFreq", DoubleValue (39000000)); 

Ptr<MmWavePhyMacCommon> common2 = CreateObject<mmWavePhyMacCommon> ();

common1 and common2 will have different center frequencies.

Amir Nazeri

unread,
Apr 5, 2022, 6:03:05 PM4/5/22
to ns-3-users
Hi @Tom

What if :

Config::SetDefault ("ns3::MmWavePhyMacCommon::CenterFreq", DoubleValue (28000000));
Ptr<MmWavePhyMacCommon> common1 = CreateObject<mmWavePhyMacCommon> ();

Config::SetDefault ("ns3::MmWavePhyMacCommon::CenterFreq", DoubleValue (39000000));  

Ptr<MmWavePhyMacCommon> common1= CreateObject<mmWavePhyMacCommon> ();

Does that set a new freq to common1. Or common1 freq will remain 28000000?  

Thanks
Reply all
Reply to author
Forward
0 new messages