ReplicaNet and RNLobby  1
Public Types | Static Public Member Functions | List of all members
NetworkEmulation Class Reference

#include <NetworkEmulation.h>

Public Types

enum  ConnectionTypes {
  kPerfect = 0, kModem28k, kModem56k, kDSL512MB_Down128Up,
  kLAN
}
 

Static Public Member Functions

static void SetEnabled (const bool enable=false)
 
static bool GetEnabled (void)
 
static void SetConnection (const ConnectionTypes type=kPerfect, const bool enable=true)
 
static void SetPacketLoss (const float percent=0)
 
static float GetPacketLoss (void)
 
static void SetMaximumOutputBandwidth (const int bytesPerSecond=0)
 
static int GetMaximumOutputBandwidth (void)
 
static void SetMaximumInputBandwidth (const int bytesPerSecond=0)
 
static int GetMaximumInputBandwidth (void)
 
static void SetAverageLatency (const float seconds=0.0f)
 
static float GetAverageLatency (void)
 
static void SetJitter (const float seconds=0.0f)
 
static float GetJitter (void)
 

Detailed Description

NetworkEmulation allows various emulated network settings to be changed to allow the user to test their application with emulated packet loss, latency, jitter and bandwidth controls.
This class is a static access class.

Member Enumeration Documentation

Enumeration for the SetConnection function for standard types of connection

Enumerator
kPerfect 

No packet loss, latency or bandwidth impairment.

kModem28k 

Simulates a 28k analogue modem

kModem56k 

Simulates a 56k analogue modem

kDSL512MB_Down128Up 

Simulates a common type of DSL connection

kLAN 

Simulates a LAN network

Member Function Documentation

static float GetAverageLatency ( void  )
static

Reads the configuration value set by SetAverageLatency()

Returns
the configured value
static bool GetEnabled ( void  )
static

Allows the network emulation activation status to be read

Returns
true is the network emulation is enabled
static float GetJitter ( void  )
static

Reads the configuration value set by SetJitter()

Returns
the configured value
static int GetMaximumInputBandwidth ( void  )
static

Reads the configuration value set by GetMaximumInputBandwidth().

Returns
the configured value
static int GetMaximumOutputBandwidth ( void  )
static

Reads the configuration value set by SetMaximumOutputBandwidth()

Returns
the configured value
static float GetPacketLoss ( void  )
static

This allows the configured emulated packet loss to be read.

Returns
the emulated packet loss value
static void SetAverageLatency ( const float  seconds = 0.0f)
static

Sets the average packet latency, this is half round trip time.

Parameters
milliSecondsthe latency in seconds. So setting this to be 0.1f will mean a packet latency of 100ms is used. The default value is 0 meaning there is no latency.
static void SetConnection ( const ConnectionTypes  type = kPerfect,
const bool  enable = true 
)
static

Allows the network emulation parameters to be set quickly for various standard testing types

Parameters
typethe type of connection to emulate
enableenable or disable the emulation
static void SetEnabled ( const bool  enable = false)
static

Allows the network emulation to be turned on or off

Parameters
enableset this to be true or false to turn on or off the network emulation. The default is false.
static void SetJitter ( const float  seconds = 0.0f)
static

Allows the amount by which the latency value can fluctuate

Parameters
milliSecondsthe jitter in seconds. So setting this to be 0.05f and latency to 0.1f will mean a packet latency of 50ms to 150ms (100ms +-50ms) can be used. The default value is 0 meaning there is no jitter.
static void SetMaximumInputBandwidth ( const int  bytesPerSecond = 0)
static

Sets the maximum input bandwidth for emulation.

Parameters
bytesPerSecondthe bandwidth in bytes per second. The default value is 0 meaning there is no limit.
static void SetMaximumOutputBandwidth ( const int  bytesPerSecond = 0)
static

Sets the maximum output bandwidth for emulation.

Parameters
bytesPerSecondthe bandwidth in bytes per second. The default value is 0 meaning there is no limit.
static void SetPacketLoss ( const float  percent = 0)
static

This sets the emulated packet loss for the network layer.

Parameters
percentSets the emulated packet loss level where percent is any value from 0 to 100 percent packet loss. The default value is 0 meaning no packet loss.