GridSim 5.0 beta

gridsim.util
Class TrafficGenerator

Object
  extended by TrafficGenerator

public class TrafficGenerator
extends Object

A generator that tells how many packets sent and how big each packet is for every time interval. This generator is used by Output entity to generate junk packets or some background traffic.

This class uses eduni.simjava.distributions package which is available from SimJava2 only. If you want to use other distribution package, then you need to wrap each source file with either DiscreteGenerator or ContinuousGenerator interface class.

Since:
GridSim Toolkit 3.1
Author:
Anthony Sulistio
See Also:
DiscreteGenerator, ContinuousGenerator
Invariant:
$none

Field Summary
static int SEND_ALL
          Sends junk packets to all entities at one time, including resources and/or users
static int SEND_ONE_ONLY
          Sends junk packets to one of the entities at one time using a normal distribution from java.util.Random.nextInt(int)
 
Constructor Summary
TrafficGenerator(ContinuousGenerator freq, ContinuousGenerator timegen)
          Creates a new background traffic generator.
TrafficGenerator(ContinuousGenerator freq, DiscreteGenerator timegen)
          Creates a new background traffic generator.
TrafficGenerator(DiscreteGenerator freq, ContinuousGenerator timegen)
          Creates a new background traffic generator.
TrafficGenerator(DiscreteGenerator freq, DiscreteGenerator timegen)
          Creates a new background traffic generator.
 
Method Summary
 long getNextPacketFreq()
          Gets the next frequency or number of packets sent for each time.
 long getNextPacketSize()
          Gets the next packet size.
 long getNextPacketTime()
          Gets the next inter-arrival time between sending packets.
 int getPattern()
          Gets the sending packet pattern
 int getServiceType()
          Gets the service level of this packet.
 boolean setPacketSize(ContinuousGenerator sizegen)
          Sets the size of each junk packet using a continuous distribution
 boolean setPacketSize(DiscreteGenerator sizegen)
          Sets the size of each junk packet using a discrete distribution
 boolean setPattern(int pattern)
          Sets the sending packet pattern if one or more entities are known.
 boolean setServiceType(int type)
          Sets the service level of this packet.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEND_ALL

public static final int SEND_ALL
Sends junk packets to all entities at one time, including resources and/or users

See Also:
Constant Field Values

SEND_ONE_ONLY

public static final int SEND_ONE_ONLY
Sends junk packets to one of the entities at one time using a normal distribution from java.util.Random.nextInt(int)

See Also:
Constant Field Values
Constructor Detail

TrafficGenerator

public TrafficGenerator(DiscreteGenerator freq,
                        DiscreteGenerator timegen)
Creates a new background traffic generator. Each junk packet has a default size (Link.DEFAULT_MTU), a default service type (0), and it will send to all resource entities and users (if applicable) (SEND_ALL).

Parameters:
freq - a generator for frequency or number of packets sent at one time
timegen - a generator for inter-arrival sending time (second)
Pre Condition:
freq != null, timegen != null
Post Condition:
$none

TrafficGenerator

public TrafficGenerator(ContinuousGenerator freq,
                        ContinuousGenerator timegen)
Creates a new background traffic generator. Each junk packet has a default size (Link.DEFAULT_MTU), a default service type (0), and it will send to all resource entities and users (if applicable) (SEND_ALL).

Parameters:
freq - a generator for frequency or number of packets sent at one time
timegen - a generator for inter-arrival sending time (second)
Pre Condition:
freq != null, timegen != null
Post Condition:
$none

TrafficGenerator

public TrafficGenerator(DiscreteGenerator freq,
                        ContinuousGenerator timegen)
Creates a new background traffic generator. Each junk packet has a default size (Link.DEFAULT_MTU), a default service type (0), and it will send to all resource entities and users (if applicable) (SEND_ALL).

Parameters:
freq - a generator for frequency or number of packets sent at one time
timegen - a generator for inter-arrival sending time (second)
Pre Condition:
freq != null, timegen != null
Post Condition:
$none

TrafficGenerator

public TrafficGenerator(ContinuousGenerator freq,
                        DiscreteGenerator timegen)
Creates a new background traffic generator. Each junk packet has a default size (Link.DEFAULT_MTU), a default service type (0), and it will send to all resource entities and users (if applicable) (SEND_ALL).

Parameters:
freq - a generator for frequency or number of packets sent at one time
timegen - a generator for inter-arrival sending time (second)
Pre Condition:
freq != null, timegen != null
Post Condition:
$none
Method Detail

setPattern

public boolean setPattern(int pattern)
Sets the sending packet pattern if one or more entities are known. The pattern is one of the following:

Parameters:
pattern -
Returns:
true if successful, false otherwise
Pre Condition:
$none
Post Condition:
$none

getPattern

public int getPattern()
Gets the sending packet pattern

Returns:
packet pattern
Pre Condition:
$none
Post Condition:
$none

setPacketSize

public boolean setPacketSize(ContinuousGenerator sizegen)
Sets the size of each junk packet using a continuous distribution

Parameters:
sizegen - a generator for each packet size
Returns:
true if successful, false otherwise
Pre Condition:
sizegen != null
Post Condition:
$none

setPacketSize

public boolean setPacketSize(DiscreteGenerator sizegen)
Sets the size of each junk packet using a discrete distribution

Parameters:
sizegen - a generator for each packet size
Returns:
true if successful, false otherwise
Pre Condition:
sizegen != null
Post Condition:
$none

getNextPacketTime

public long getNextPacketTime()
Gets the next inter-arrival time between sending packets. For using continuous distribution, the value is rounded up to the nearest integer number.

Returns:
the next inter-arrival time
Pre Condition:
$none
Post Condition:
$none

getNextPacketFreq

public long getNextPacketFreq()
Gets the next frequency or number of packets sent for each time. For using continuous distribution, the value is rounded up to the nearest integer number.

Returns:
frequence or number of packets sent for each time
Pre Condition:
$none
Post Condition:
$none

getNextPacketSize

public long getNextPacketSize()
Gets the next packet size. By default, the packet size is Link.DEFAULT_MTU. For using continuous distribution, the value is rounded up to the nearest integer number.

Returns:
the next packet size
Pre Condition:
$none
Post Condition:
$none

getServiceType

public int getServiceType()
Gets the service level of this packet. By default, the value is 0 (zero).

Returns:
the service level of this packet
Pre Condition:
$none
Post Condition:
$none

setServiceType

public boolean setServiceType(int type)
Sets the service level of this packet.

Parameters:
type - the service level of this packet
Returns:
true if successful, false otherwise
Pre Condition:
type >= 0
Post Condition:
$none

GridSim 5.0 beta

The University of Melbourne, Australia, 2009