[Ns-developers] ns-3.4 : Random Variables
Gustavo Carneiro
gjcarneiro at gmail.com
Sat Feb 21 13:06:41 PST 2009
2009/2/21 Mathieu Lacage <mathieu.lacage at sophia.inria.fr>
> On Fri, 2009-02-20 at 17:45 -0500, Raj Bhattacharjea wrote:
> > To move forward, let's remove the SetSeed method in question. The
> > functionality it provides will still be exported via the attributes
> > system and the command line. I have an implementation in mind, where
> > the GlobalValue g_rngSeed will initialize from either the command
> > line, or default to a value. This will require shuffling around
> > Mathieu's code a bit.
>
> The following is probably what you have in mind but, in case you don't,
> it should be fairly trivial to:
> - make SeedManager::SetSeed call g_rngSeed.Set ()
> - make GlobalValue::GlobalValue call GetInitialSeedValue shown below:
>
> static AttributeValue GetInitialSeedValue (void)
> {
> // lookup env var first.
> // if set, return env var value.
> // if unset, return default value, that is, '1'.
> }
>
> The above won't allow you to set the seed by the full 6-double array. If
> you wanted to support this, you would have to create a new kind of
> object which can hold a full seed, and, then, give to this object
> 'attribute' powers, just like IntegerValue. I don't think that this is
> worth the effort but this should work.
>
> > This brings up the more general question of how to put environment
> > variables into the mix of attributes/GlobalValues; currently we can
> > override Attribute defaults using Config::SetDefault, or by passing
> > --ns3::AttributeName=value on the command line; perhaps in the future
> > we should come up with a general way to specify how these values
> > should hook into a environment variables automatically, since this
> > kind of behavior might be desired. More on this later.
>
> Yes, it should be possible to add something in the GlobalValue and the
> attribute code to initialize from NS_DEFAULT_VALUE and NS_GLOBAL_VALUE:
> for example, using '=' to separate names from values and ':' values from
> other names:
>
> NS_DEFAULT_VALUE=ns3::Ipv4L3Protocol::Checksum=true:ns3::TcpL4Protocol::Checksum=true
Keep in mind that random variable config value strings already contain ':'
inside, for instance,
Config::SetDefault ("ns3::OnOffApplication::OnTime",
"UniformVariable:1.0:3.0");
Therefore, parsing the environment variable with items separated by : is
going to be difficult. More so because of the :: of C++ identifiers.
Maybe another separator would be better; for instance semicolon.
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
More information about the Ns-developers
mailing list