GridSim 5.0 beta

gridsim.net.flow
Class FlowPacket

Object
  extended by FlowPacket
All Implemented Interfaces:
Packet

public class FlowPacket
extends Object
implements Packet

Structure of a packet used to encapsulate flow passing through the network.

Since:
GridSim Toolkit 4.2
Author:
James Broberg
Invariant:
$none

Constructor Summary
FlowPacket(Object data, int pktID, long size, int tag, int srcID, int destID)
          Constructs a network flow for data that fits into a single network flow packet.
FlowPacket(Object data, int pktID, long size, int tag, int srcID, int destID, int netServiceType, int pktNum, int totalPkts)
          This is used to construct a flow that is one in a series.
 
Method Summary
 void addBaudRate(Link link)
          Adds baud rate of current link, and sets bottleneck bandwidth and ID if the link is this flow's bottleneck
 void addLatency(double latency)
          Adds to the current sum of latency over the path from source to dest.
 void addLink(Link link)
          Adds current link, and calls addBaudRate() and addLatency()
 double getBandwidth()
          Returns the current bottleneck bandwidth of this flow.
 int getBottleneckID()
          Returns the FlowLink ID of the bottleneck of this flow
 Object getData()
          Returns the data encapsulated in this FlowPacket
 int getDestID()
          Returns the destination ID of this flow packet
 int getID()
          Returns the ID of this packet
 int getLast()
          Returns the ID of the last hop that this flow packet traversed.
 double getLatency()
          Returns the current sum of latency over the path from source to dest.
 Vector getLinks()
          Returns a vector of links that make up this flow's path
 int getNetServiceType()
          Returns the class type of this flow packet.
 int getPacketNum()
          Returns the serial number of this flow packet.
 long getRemSize()
          Returns the remaining size of a flow
 long getSize()
          Gets the size of this flow packet
 int getSrcID()
          Returns the source ID of this packet.
 double getStartTime()
          Returns the current start time of this flow.
 int getTag()
          Returns the tag associated originally with data that was encapsulated in this flow packet.
 int getTotalPackets()
          Returns the total number of flow packets in this stream.
 double getUpdateTime()
          Returns the last time a flow was updated (i.e.
 void setBandwidth(double bandwidth_)
          Sets the current bottleneck bandwidth of this flow.
 void setBottleneckID(int bottleneckID)
          Sets the FlowLink ID of the bottleneck of this flow param bottleneckID the ID of the bottleneck FlowLink
 void setData(Object data)
          Modifies the data encapsulated in this FlowPacket.
 void setDestID(int id)
          Sets the destination id of this flow packet
 void setLast(int last)
          Sets the last hop that this FlowPacket traversed.
 void setLatency(double latency)
          Sets the current latency over the path from source to dest.
 void setNetServiceType(int netServiceType)
          Sets the network class type of this flow packet, so that it can receive differentiated services.
 void setRemSize(long remSize)
          Sets the remaining size of a flow param remSize the remaining size of a flow
 boolean setSize(long size)
          Sets the packet size
 void setSrcID(int srcID)
          Sets the source ID for a FlowPacket param srcID the id of the source of this flow
 void setStartTime(double startTime)
          Sets the current start time of this flow.
 void setTag(int tag)
          Sets the tag of this packet
 void setUpdateTime(double updateTime)
          Sets the last time a flow was updated (i.e.
 String toString()
          Returns a description of this flow
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FlowPacket

public FlowPacket(Object data,
                  int pktID,
                  long size,
                  int tag,
                  int srcID,
                  int destID)
Constructs a network flow for data that fits into a single network flow packet.

Parameters:
data - The data to be encapsulated.
pktID - The ID of this packet
size - The size of the data (in bytes)
tag - The original tag which was used with the data, its reapplied when the data is extracted from the NetPacket.
srcID - The id of the entity where the packet was created.
destID - The destination to which the packet has to be sent.
Pre Condition:
$none
Post Condition:
$none

FlowPacket

public FlowPacket(Object data,
                  int pktID,
                  long size,
                  int tag,
                  int srcID,
                  int destID,
                  int netServiceType,
                  int pktNum,
                  int totalPkts)
This is used to construct a flow that is one in a series. This happens when a large piece of data is required to be brokwn down into smaller chunks so that they can traverse of links that only support a certain MTU. It also allows setting of a classtype so that network schedulers maybe provide differntial service to it.

Parameters:
data - The data to be encapsulated.
pktID - The ID of this packet
size - The size of the data (in bytes)
tag - The original tag which was used with the data, its reapplied when the data is extracted from the NetPacket.
srcID - The id of the entity where the packet was created.
destID - The destination to which the packet has to be sent.
netServiceType - the network class type of this packet
pktNum - The packet number of this packet in its series. If there are 10 packets, they should be numbered from 1 to 10.
totalPkts - The total number of packets that the original data was split into. This is used by the receiver to confirm that all packets have been received.
Pre Condition:
$none
Post Condition:
$none
Method Detail

toString

public String toString()
Returns a description of this flow

Specified by:
toString in interface Packet
Overrides:
toString in class Object
Returns:
a description of this flow
Pre Condition:
$none
Post Condition:
$none

getData

public Object getData()
Returns the data encapsulated in this FlowPacket

Returns:
data encapsulated in this packet
Pre Condition:
$none
Post Condition:
$none

getSrcID

public int getSrcID()
Returns the source ID of this packet. The source ID is where the FlowPacket was originally created.

Specified by:
getSrcID in interface Packet
Returns:
the source id.
Pre Condition:
$none
Post Condition:
$none

getID

public int getID()
Returns the ID of this packet

Specified by:
getID in interface Packet
Returns:
packet ID
Pre Condition:
$none
Post Condition:
$none

setData

public void setData(Object data)
Modifies the data encapsulated in this FlowPacket.

Parameters:
data - the packet's data
Pre Condition:
$none
Post Condition:
$none

getSize

public long getSize()
Gets the size of this flow packet

Specified by:
getSize in interface Packet
Returns:
the packet size
Pre Condition:
$none
Post Condition:
$none

setSize

public boolean setSize(long size)
Sets the packet size

Specified by:
setSize in interface Packet
Parameters:
size - the flow packet size
Returns:
true if it is successful, false otherwise
Pre Condition:
size >= 0
Post Condition:
$none

getTag

public int getTag()
Returns the tag associated originally with data that was encapsulated in this flow packet.

Specified by:
getTag in interface Packet
Returns:
the tag of the data contained.
Pre Condition:
$none
Post Condition:
$none

getDestID

public int getDestID()
Returns the destination ID of this flow packet

Specified by:
getDestID in interface Packet
Returns:
destination ID
Pre Condition:
$none
Post Condition:
$none

setDestID

public void setDestID(int id)
Sets the destination id of this flow packet

Parameters:
id - the destination id
Pre Condition:
id >= 0
Post Condition:
$none

setLast

public void setLast(int last)
Sets the last hop that this FlowPacket traversed. This is used to determine the next hop at routers. Only routers and hosts/GridResources set this, links do not modify it.

Specified by:
setLast in interface Packet
Parameters:
last - the entity ID from the last hop
Pre Condition:
last >= 0
Post Condition:
$none

getLast

public int getLast()
Returns the ID of the last hop that this flow packet traversed. This could be the ID of a router, host or GridResource.

Specified by:
getLast in interface Packet
Returns:
ID of the last hop
Pre Condition:
$none
Post Condition:
$none

setNetServiceType

public void setNetServiceType(int netServiceType)
Sets the network class type of this flow packet, so that it can receive differentiated services.

Specified by:
setNetServiceType in interface Packet
Parameters:
netServiceType - a network service type
Pre Condition:
netServiceType >= 0
Post Condition:
$none

getNetServiceType

public int getNetServiceType()
Returns the class type of this flow packet. Used by routers etc. to determine the level of service that this flow packet should obtain.

Specified by:
getNetServiceType in interface Packet
Returns:
the class of this packet
Pre Condition:
$none
Post Condition:
$none

getPacketNum

public int getPacketNum()
Returns the serial number of this flow packet.

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

getTotalPackets

public int getTotalPackets()
Returns the total number of flow packets in this stream. A stream of packets is sent whenever the data is too big to be sent as one packet.

Returns:
total number of flow packets in this stream.
Pre Condition:
$none
Post Condition:
$none

getLatency

public double getLatency()
Returns the current sum of latency over the path from source to dest.

Returns:
latency
Pre Condition:
$none
Post Condition:
$none

setLatency

public void setLatency(double latency)
Sets the current latency over the path from source to dest. param latency

Pre Condition:
$none
Post Condition:
$none

addLatency

public void addLatency(double latency)
Adds to the current sum of latency over the path from source to dest.

Parameters:
latency - the latency of a given link
Pre Condition:
$none
Post Condition:
$none

addBaudRate

public void addBaudRate(Link link)
Adds baud rate of current link, and sets bottleneck bandwidth and ID if the link is this flow's bottleneck

Parameters:
link - a given link
Pre Condition:
$none
Post Condition:
$none

getBandwidth

public double getBandwidth()
Returns the current bottleneck bandwidth of this flow.

Returns:
bandwidth_
Pre Condition:
$none
Post Condition:
$none

setBandwidth

public void setBandwidth(double bandwidth_)
Sets the current bottleneck bandwidth of this flow. param bandwidth_ the current bottleneck bandwidth

Pre Condition:
$none
Post Condition:
$none

addLink

public void addLink(Link link)
Adds current link, and calls addBaudRate() and addLatency()

Parameters:
link - a given link
Pre Condition:
$none
Post Condition:
$none

getStartTime

public double getStartTime()
Returns the current start time of this flow.

Returns:
startTime
Pre Condition:
$none
Post Condition:
$none

setStartTime

public void setStartTime(double startTime)
Sets the current start time of this flow.

Parameters:
startTime - the time a flow begins holding at the destination
Pre Condition:
$none
Post Condition:
$none

getUpdateTime

public double getUpdateTime()
Returns the last time a flow was updated (i.e. bottleneck bandwidth changed and forecast was recomputed)

Returns:
updateTime
Pre Condition:
$none
Post Condition:
$none

setUpdateTime

public void setUpdateTime(double updateTime)
Sets the last time a flow was updated (i.e. bottleneck bandwidth changed and forecast was recomputed)

Parameters:
updateTime - the time a flow's forecast was last updated
Pre Condition:
$none
Post Condition:
$none

getRemSize

public long getRemSize()
Returns the remaining size of a flow

Returns:
remSize
Pre Condition:
$none
Post Condition:
$none

setRemSize

public void setRemSize(long remSize)
Sets the remaining size of a flow param remSize the remaining size of a flow

Pre Condition:
$none
Post Condition:
$none

getLinks

public Vector getLinks()
Returns a vector of links that make up this flow's path

Returns:
links_
Pre Condition:
$none
Post Condition:
$none

getBottleneckID

public int getBottleneckID()
Returns the FlowLink ID of the bottleneck of this flow

Returns:
bottleneckID
Pre Condition:
$none
Post Condition:
$none

setBottleneckID

public void setBottleneckID(int bottleneckID)
Sets the FlowLink ID of the bottleneck of this flow param bottleneckID the ID of the bottleneck FlowLink

Pre Condition:
$none
Post Condition:
$none

setSrcID

public void setSrcID(int srcID)
Sets the source ID for a FlowPacket param srcID the id of the source of this flow

Pre Condition:
$none
Post Condition:
$none

setTag

public void setTag(int tag)
Sets the tag of this packet

Parameters:
tag - the packet's tag
Pre Condition:
$none
Post Condition:
$none

GridSim 5.0 beta

The University of Melbourne, Australia, 2009