MCPcopy Create free account
hub / github.com/akeranen/the-one / MessageEventGenerator

Class MessageEventGenerator

input/MessageEventGenerator.java:17–231  ·  view source on GitHub ↗

Message creation -external events generator. Creates uniformly distributed message creation patterns whose message size and inter-message intervals can be configured.

Source from the content-addressed store, hash-verified

15 * be configured.
16 */
17public class MessageEventGenerator implements EventQueue {
18 /** Message size range -setting id ({@value}). Can be either a single
19 * value or a range (min, max) of uniformly distributed random values.
20 * Defines the message size (bytes). */
21 public static final String MESSAGE_SIZE_S = "size";
22 /** Message creation interval range -setting id ({@value}). Can be either a
23 * single value or a range (min, max) of uniformly distributed
24 * random values. Defines the inter-message creation interval (seconds). */
25 public static final String MESSAGE_INTERVAL_S = "interval";
26 /** Sender/receiver address range -setting id ({@value}).
27 * The lower bound is inclusive and upper bound exclusive. */
28 public static final String HOST_RANGE_S = "hosts";
29 /** (Optional) receiver address range -setting id ({@value}).
30 * If a value for this setting is defined, the destination hosts are
31 * selected from this range and the source hosts from the
32 * {@link #HOST_RANGE_S} setting's range.
33 * The lower bound is inclusive and upper bound exclusive. */
34 public static final String TO_HOST_RANGE_S = "tohosts";
35
36 /** Message ID prefix -setting id ({@value}). The value must be unique
37 * for all message sources, so if you have more than one message generator,
38 * use different prefix for all of them. The random number generator's
39 * seed is derived from the prefix, so by changing the prefix, you'll get
40 * also a new message sequence. */
41 public static final String MESSAGE_ID_PREFIX_S = "prefix";
42 /** Message creation time range -setting id ({@value}). Defines the time
43 * range when messages are created. No messages are created before the first
44 * and after the second value. By default, messages are created for the
45 * whole simulation time. */
46 public static final String MESSAGE_TIME_S = "time";
47
48 /** Time of the next event (simulated seconds) */
49 protected double nextEventsTime = 0;
50 /** Range of host addresses that can be senders or receivers */
51 protected int[] hostRange = {0, 0};
52 /** Range of host addresses that can be receivers */
53 protected int[] toHostRange = null;
54 /** Next identifier for a message */
55 private int id = 0;
56 /** Prefix for the messages */
57 protected String idPrefix;
58 /** Size range of the messages (min, max) */
59 private int[] sizeRange;
60 /** Interval between messages (min, max) */
61 private int[] msgInterval;
62 /** Time range for message creation (min, max) */
63 protected double[] msgTime;
64
65 /** Random number generator for this Class */
66 protected Random rng;
67
68 /**
69 * Constructor, initializes the interval between events,
70 * and the size of messages generated, as well as number
71 * of hosts in the network.
72 * @param s Settings for this generator.
73 */
74 public MessageEventGenerator(Settings s){

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected