Menu

Transmission Speed

Transmission Speed and Volume

Transmission Speed

JennyNet allows to limit the transmission speed of connections, either on a global setting or individual per connection. This enables the application to react meaningful to overload situations by reducing transmission speed for all clients, or for particular clients if so wished. In combination with a data volume control, which can be applied to each connection, a speed setting may also be part of a reaction to irregular transmission behaviours of a single client, e.g. when malicious attacks are performed.

Combined Setting with Parcel Volume

Transmission speed can be set in two ways: either via the connection parameters or directly through setTempo(int) on the connection. The setting in connection parameters offers a complexity with the global parameter settings. The contract is that a setting with setTempo() does not modify the parameter value, while a setting in connection parameters also implies a setTempo() on the connection speed. Global parameter settings only become active on new connections that come into life after the setting occurred. The Server has a method to set tempo to all available connections.

Connection connection;
...
// method 1
connection.getParameters().setTransmissionSpeed(25000);

// method 2
connection.setTempo(25000);

// we may also reduce the transmission parcel size
connection.getParameters.setTransmissionParcelSize(8*1024);

Server server;
...
// we want to rule the connection speed
server.setTempoPrimacy(true);

// and we set it to 100,000 bytes per second
server.getParameters().setTransmissionSpeed(100000);

// if we have connections, we can inform them now (they have no choice)
server.sendTempoToAll(100000);

The reduced connection speed is realised by simulated transmission time via sleep times while the actual data transmission speed of the TCP network is unchanged. This transfers some lesser importance to the connection parameter setting of TRANSMISSION_PARCEL_SIZE. The lower the parcel size is set, the more accurate the transmission speed setting can be simulated. In practice this may not cause a relevant difference but is mentioned here for completeness.

Setting Standards and Complexity

As a base rule any successful speed setting on a connection operates on both sides of the line, the local and the remote station, the sender and the receiver. This implies that no preference can be at work on which side may impose a speed setting, and consequently in normal mode just who changed the speed latest is the ruler in speed setting. There is no negotiation ongoing. However, the server can be set to a primacy mode in which speed settings from any client or particular clients will be rejected and corrected remotely. This is done with Server.setTempoPrimacy(boolean) or on each connection individually by ServerConnection.setTempoFixed(boolean).

There are two standard values to be noted: "-1" stands for "no limitation active" (or speed setting off) and "0" stands for transmission muted. In the latter state no transmission occurs while affected connections still remain connected (and ALIVE signals in operation). The Connection interface may still accept objects for sending until the queues become full. The connection resumes orderly after the zero state is abandoned.


Related

Wiki: User Manual