When will the attribute setting take effect by "Config::SetDefault"?

27 views
Skip to first unread message

John Young

unread,
Dec 23, 2016, 1:48:56 AM12/23/16
to ns-3-users
I used "Config::SetDefault" before the creation of instance. However, when I print the value of the attribute in the construct function,  it was not the value I set. 
So when will the value setting happen?

pdbarnes

unread,
Dec 23, 2016, 10:40:02 AM12/23/16
to ns-3-users
As explained in the documentation you should set the value with Config::SetDefault *before* creating the object.

Peter

Tom Henderson

unread,
Dec 23, 2016, 11:01:25 AM12/23/16
to ns-3-...@googlegroups.com
The ns-3 object creation will assign attribute values *after* the
object's constructor is called. If you are testing the value from
within the body of the constructor, you are too early in the object
lifecycle.

The manual chapter on Attributes explains this in more detail and
explains how to force this assignment early if you really need them
available in the body of the constructor.

- Tom

John Young

unread,
Dec 24, 2016, 8:27:09 AM12/24/16
to ns-3-users
Ok, thanks.

在 2016年12月23日星期五 UTC+8下午11:40:02,pdbarnes写道:

John Young

unread,
Dec 24, 2016, 8:27:20 AM12/24/16
to ns-3-users
Ok, thanks

在 2016年12月24日星期六 UTC+8上午12:01:25,Tom Henderson写道:
Reply all
Reply to author
Forward
0 new messages