changes from ns3.14 to ns3.15 with RandomVariableValue

38 views
Skip to first unread message

amelie...@gmail.com

unread,
Apr 1, 2014, 3:47:24 AM4/1/14
to ns-3-...@googlegroups.com
the old code is
RandomVariableValue (ConstantVariable (0))
the new code is
StringValue("ns3::ConstantRandomVariable[Constant=0]")

but when i meet this code
RandomVariableValue (ConstantVariable (m_totalTime))
 i do not know how to change it.
 could you help me?
thanks a lot !

Tom Henderson

unread,
Apr 1, 2014, 10:04:56 AM4/1/14
to ns-3-...@googlegroups.com
Have you tried:

StringValue("ns3::ConstantRandomVariable[Constant=m_totalTime]")

- Tom

ling li

unread,
Apr 1, 2014, 9:13:19 PM4/1/14
to ns-3-...@googlegroups.com
it did not work,"Invalid value for attribute set (OnTime) on ns3::OnOffApplication"




--
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/uAD0UY1ZW5s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@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.

Tom Henderson

unread,
Apr 2, 2014, 1:09:43 AM4/2/14
to ns-3-...@googlegroups.com
On 04/01/2014 06:13 PM, ling li wrote:
> it did not work,"Invalid value for attribute set (OnTime) on
> ns3::OnOffApplication"

Ah, that was a bad suggestion on my part. This value takes a string so
there cannot be a variable name embedded in it. You must instead build
the string that you want at runtime and pass it in; e.g.

#include <sstream>

std::ostringstream stream;
stream << "ns3::ConstantRandomVariable[Constant=" << m_totalTime << "]";

and then later use it such as:

StringValue (stream.str())

- Tom

>
>
> 2014-04-01 22:04 GMT+08:00 Tom Henderson <to...@tomh.org
> <mailto:to...@tomh.org>>:
>
> On 04/01/2014 12:47 AM, amelie...@gmail.com
> <mailto:amelie...@gmail.com> wrote:
>
> the old code is
> RandomVariableValue (ConstantVariable (0))
> the new code is
> StringValue("ns3::__ConstantRandomVariable[__Constant=0]")
>
> but when i meet this code
> RandomVariableValue (ConstantVariable (m_totalTime))
> i do not know how to change it.
> could you help me?
> thanks a lot !
>
>
> Have you tried:
>
> StringValue("ns3::__ConstantRandomVariable[__Constant=m_totalTime]")
>
> - Tom
>
>

ling li

unread,
Apr 2, 2014, 9:34:10 PM4/2/14
to ns-3-...@googlegroups.com
it works.
thank you very very very much.


Reply all
Reply to author
Forward
0 new messages