Table Of Contents

Previous topic

21.30. The MathDeviceConvert Object

Next topic

21.32. The NetworkLatencySimulator Object

This Page

21.31. The NetworkLatencyBehavior Object

An object used by NetworkLatencySimulator to provide the latency scheduling.

It models the average latency to the server and has a delay period to simulate the spikes often seen with TCP connections due to dropped packets. It randomizes the time periods to provide more variation.

Users can implement their own behavior object if they want to simulate specific conditions.

21.31.1. Constructor create


Creates an object to pass to the NetworkLatencySimulator.create().


var behavior = NetworkLatencyBehavior.create({latency : 50,
                                            delayPeriod : 1000,
                                            delayDuration : 100});

var simulator = NetworkLatencySimulator.create(behavior);

This is the simulated latency to the server in ms. The total latencies will be:

Total latency (to server) = (simulated latency + actual latency to/from server) x 2

Total latency (to other client) = (simulated latency + actual latency to/from server) x 2 + (other client’s simulated latency + other client’s actual latency to/from server) x 2

For a local server the actual latency is typically <30ms where as a remote server will depend on location and connection.

This is the average time period between spikes in latency in ms.
This is the average length of the spike in ms.

21.31.2. Methods nextMessageDelay


Returns an integer number of ms the next message should be delayed by. Used only by NetworkLatencySimulator.