Random PeriodicInformInterval doesn't work as expected

Dan Morphis dan at milkcarton.com
Thu Mar 28 13:24:21 EDT 2019


Two questions, why do you want an interval so low, and why do you want a
random interval? Load?

Looking through sandbox.js we see this:

// Monkey-patch Math.random() to make it deterministic
context.random = random;
vm.runInContext("Math.random = random;", context);
delete context.random;

And random is defined as:
function random() {
  if (!state.rng)
    state.rng = seedrandom(state.sessionContext.deviceId);

  return state.rng();
}

random.seed = function(s) {
  state.rng = seedrandom(s);
}

This means for that particular device id, you will always get the same
"random" value

-dan

On Thu, Mar 28, 2019 at 9:19 AM George Chelidze <george.chelidze at magticom.ge>
wrote:

> Hi,
>
> I try to set random PeriodicInformInterval with the following Provision
> script:
>
> const randomInterval = get_random_interval(60, 30);
> declare("InternetGatewayDevice.ManagementServer.PeriodicInformInterval",
> null, {value: randomInterval});
>
> function get_random_interval(interval, offset) {
>     return interval + Math.floor(Math.random() * offset - offset / 2);
> }
>
> What I expect to see is PeriodicInformInterval with some value which is
> between 45 secs and 75 secs. Instead it's always set to 71. Any idea
> what I am doing wrong?
>
> TIA,
>
> George Chelidze
>
>
> _______________________________________________
> Users mailing list
> Users at lists.genieacs.com
> http://lists.genieacs.com/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.genieacs.com/pipermail/users/attachments/20190328/a152cd68/attachment-0001.html>


More information about the Users mailing list