inputOutputHandler
Class ReplyDecision

java.lang.Object
  extended by inputOutputHandler.ReplyDecision

final class ReplyDecision
extends java.lang.Object

Decides about the optimal reply size and time depending on the current traffic situation (only used by last mix of cascade).

"Traffic situation" means the amount of data available to reply (for each channel/user) at a given point of time.

"Optimal size" means the best tradeoff between padding and the total amount of (available) data actually sent. A "perfect size" is only possible if all channels contain the same amount of data. In any other situation, optimizing one parameter will have a negative effect on the other. So, "the best tradeoff" depends on situational conditions and therefore can't be generalized.

"Optimal time" means the best point of time for returning the data available which again is a tradeoff and depends on situational conditions and therefore can't be generalized.

Author:
Karl-Peter Fuchs

Field Summary
private  long batchBegin
          Timestamp of the first validation (of the traffic situation) for the current decision.
private  int CIPHER_BLOCK_SIZE
          Block size of the cryptographic algorithm used to encrypt Replyies in byte.
private static NetworkClockController clock
           
private  double g
          Tradeoff-indicator between padding and the total amount of (available) data actually sent.
private  InputOutputHandlerController inputOutputHandler
          Reference on InputOutputHandlerController (used to add unprocessed Replyies).
private static InternalInformationPortController internalInformationPort
          Reference on component InternalInformationPort.
private  boolean isNewDecision
          Indicates whether the first validation (of the traffic situation) for the current decision has already taken place or not (used to calculate timeout condition).
private static java.util.logging.Logger LOGGER
          Logger used to log and display information.
private  int MAX_REPLY_LENGTH
          Maximum size a Reply may have in byte.
private  float MIN_FILLED_CHANNELS
          Minimum number of channels with data available to be returned (before replying is allowed).
private  int MIN_VOLUME_PER_CHANNEL
          Minimum amount of data per Reply in byte (before replying is allowed).
private  long TIMEOUT
          Timeout for reply size decision in ms.
private  long VOLUME_DECISSION_CHECK_RATE
          Amount of time between validations of the traffic situation.
 
Constructor Summary
protected ReplyDecision(InputOutputHandlerController inputOutputHandler)
          Creates a new ReplyDecision object which can be used to decides about the optimal reply size and time depending on the current traffic situation by the last mix of a cascade.
 
Method Summary
private  int adjustBlockSizeToCryptographicBlockSize(int blockSize)
          Adjusts the "optimal size" to the CIPHER_BLOCK_SIZE (only multiples of the CIPHER_BLOCK_SIZE are useful).
private  void generateReplyBatch(User[] channels)
          Decides about the optimal reply size and time depending on the current traffic situation for the bypassed channels/users.
private static java.lang.String getProperty(java.lang.String key)
          Simply used to shorten method calls (calls internalInformationPort.getProperty(key)).
private  int[] getVolumeForEachChannel(User[] channels)
          Returns an array containing the amount of data currently available in each bypassed channel.
private  int getWeightedMedian(int[] bytesReadSoFar)
          Decides about the "optimal size" of the reply batch (in byte).
private  boolean isEnoughDataAvailable(int[] bytesReadSoFar)
          Decides whether "enough" data is available for replying or not.
protected  void manageReplyProcess(User[] channels)
          Decides about the optimal reply size and time depending on the current traffic situation for the bypassed channels/users.
private  void processMessages(int replySize, User[] channels)
          Generates Replyies and passes them to the InputOutputHandlerController.
private  boolean shallMixReply(int[] bytesReadSoFar)
          Decides whether it's time to reply or not ("true" when timeout reached or isEnoughDataAvailable() == true).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

internalInformationPort

private static InternalInformationPortController internalInformationPort
Reference on component InternalInformationPort. Used to display and/or log data and read general settings.


LOGGER

private static final java.util.logging.Logger LOGGER
Logger used to log and display information.


clock

private static NetworkClockController clock

inputOutputHandler

private InputOutputHandlerController inputOutputHandler
Reference on InputOutputHandlerController (used to add unprocessed Replyies).

See Also:
InputOutputHandlerController.addUnprocessedReply(ReplyMessage)

TIMEOUT

private final long TIMEOUT
Timeout for reply size decision in ms.


MAX_REPLY_LENGTH

private final int MAX_REPLY_LENGTH
Maximum size a Reply may have in byte.


CIPHER_BLOCK_SIZE

private final int CIPHER_BLOCK_SIZE
Block size of the cryptographic algorithm used to encrypt Replyies in byte.


MIN_VOLUME_PER_CHANNEL

private final int MIN_VOLUME_PER_CHANNEL
Minimum amount of data per Reply in byte (before replying is allowed).

See Also:
MIN_FILLED_CHANNELS

MIN_FILLED_CHANNELS

private final float MIN_FILLED_CHANNELS
Minimum number of channels with data available to be returned (before replying is allowed).

See Also:
MIN_VOLUME_PER_CHANNEL

VOLUME_DECISSION_CHECK_RATE

private final long VOLUME_DECISSION_CHECK_RATE
Amount of time between validations of the traffic situation.


g

private double g
Tradeoff-indicator between padding and the total amount of (available) data actually sent.


batchBegin

private long batchBegin
Timestamp of the first validation (of the traffic situation) for the current decision.


isNewDecision

private boolean isNewDecision
Indicates whether the first validation (of the traffic situation) for the current decision has already taken place or not (used to calculate timeout condition).

Constructor Detail

ReplyDecision

protected ReplyDecision(InputOutputHandlerController inputOutputHandler)
Creates a new ReplyDecision object which can be used to decides about the optimal reply size and time depending on the current traffic situation by the last mix of a cascade.

"Traffic situation" means the amount of data available to reply (for each channel/user) at a given point of time.

"Optimal size" means the best tradeoff between padding and the total amount of (available) data actually sent. A "perfect size" is only possible if all channels contain the same amount of data. In any other situation, optimizing one parameter will have a negative effect on the other. So, "the best tradeoff" depends on situational conditions and therefore can't be generalized.

"Optimal time" means the best point of time for returning the data available which again is a tradeoff and depends on situational conditions and therefore can't be generalized.

Parameters:
inputOutputHandler - Reference on InputOutputHandlerController (used to add unprocessed Replyies).
Method Detail

manageReplyProcess

protected void manageReplyProcess(User[] channels)
Decides about the optimal reply size and time depending on the current traffic situation for the bypassed channels/users.

Parameters:
channels - The channels/users to be observed.

generateReplyBatch

private void generateReplyBatch(User[] channels)
Decides about the optimal reply size and time depending on the current traffic situation for the bypassed channels/users.

Parameters:
channels - The channels/users to be observed.

getVolumeForEachChannel

private int[] getVolumeForEachChannel(User[] channels)
Returns an array containing the amount of data currently available in each bypassed channel.

Parameters:
channels - The channels/users to be observed.
Returns:
Amount of data currently available in each bypassed channel.

shallMixReply

private boolean shallMixReply(int[] bytesReadSoFar)
Decides whether it's time to reply or not ("true" when timeout reached or isEnoughDataAvailable() == true).

Parameters:
bytesReadSoFar - Amount of data currently available in each channel.
Returns:
Whether it's time to reply or not.

isEnoughDataAvailable

private boolean isEnoughDataAvailable(int[] bytesReadSoFar)
Decides whether "enough" data is available for replying or not. "Enough" means MIN_VOLUME_PER_CHANNEL data in MIN_FILLED_CHANNELS channels available.

Parameters:
bytesReadSoFar - Amount of data currently available in each channel.
Returns:
"Enough" data available or not.
See Also:
MIN_FILLED_CHANNELS, MIN_VOLUME_PER_CHANNEL

getWeightedMedian

private int getWeightedMedian(int[] bytesReadSoFar)
Decides about the "optimal size" of the reply batch (in byte).

Parameters:
bytesReadSoFar - Amount of data currently available in each channel (in byte).
Returns:
"Optimal size" (in byte).

adjustBlockSizeToCryptographicBlockSize

private int adjustBlockSizeToCryptographicBlockSize(int blockSize)
Adjusts the "optimal size" to the CIPHER_BLOCK_SIZE (only multiples of the CIPHER_BLOCK_SIZE are useful).

Parameters:
blockSize - "Optimal size" (not adjusted).
Returns:
Adjusted "optimal size".
See Also:
CIPHER_BLOCK_SIZE

processMessages

private void processMessages(int replySize,
                             User[] channels)
Generates Replyies and passes them to the InputOutputHandlerController.

Parameters:
replySize - Size the replies shall have.
channels - Channels/users to send replies to.

getProperty

private static java.lang.String getProperty(java.lang.String key)
Simply used to shorten method calls (calls internalInformationPort.getProperty(key)). Returns the property with the specified key from the property file.

Parameters:
key - The property key.
Returns:
The property with the specified key in the property file.