GridSim 5.0 beta

gridsim.net
Class NetPacket

Object
  extended by NetPacket
All Implemented Interfaces:
Packet

public class NetPacket
extends Object
implements Packet

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

Since:
GridSim Toolkit 3.1
Author:
Gokul Poduval & Chen-Khong Tham, National University of Singapore
Invariant:
$none

Constructor Summary
NetPacket(Object data, int pktID, long size, int tag, int srcID, int destID)
          Constructs a network packet for data that fits into a single network packet.
NetPacket(Object data, int pktID, long size, int tag, int srcID, int destID, int netServiceType, int pktNum, int totalPkts)
          This is used to construct a packet that is one in a series.
 
Method Summary
 Object getData()
          Returns the data encapsulated in this NetPacket
 int getDestID()
          Returns the destination ID of this packet
 int getID()
          Returns the ID of this packet
 int getLast()
          Returns the ID of the last hop that this packet traversed.
 int getNetServiceType()
          Returns the class type of this packet.
 int getPacketNum()
          Returns the serial number of this packet.
 long getSize()
          Gets the size of this packet
 int getSrcID()
          Returns the source ID of this packet.
 int getTag()
          Returns the tag associated originally with data that was encapsulated in this packet.
 int getTotalPackets()
          Returns the total number of packets in this stream.
 void setData(Object data)
          Modifies the data encapsulated in this NetPacket.
 void setDestID(int id)
          Sets the destination id of this packet
 void setLast(int last)
          Sets the last hop that this NetPacket traversed.
 void setNetServiceType(int netServiceType)
          Sets the network class type of this packet, so that it can receive differentiated services.
 boolean setSize(long size)
          Sets the packet size
 String toString()
          Returns a description of this packet
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NetPacket

public NetPacket(Object data,
                 int pktID,
                 long size,
                 int tag,
                 int srcID,
                 int destID)
Constructs a network packet for data that fits into a single network 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

NetPacket

public NetPacket(Object data,
                 int pktID,
                 long size,
                 int tag,
                 int srcID,
                 int destID,
                 int netServiceType,
                 int pktNum,
                 int totalPkts)
This is used to construct a packet 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 packet

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

getData

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

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 NetPacket 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 NetPacket.

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

getSize

public long getSize()
Gets the size of this 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 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 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 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 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 NetPacket 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 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 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 packet. Used by routers etc. to determine the level of service that this 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 packet.

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

getTotalPackets

public int getTotalPackets()
Returns the total number of 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 packets in this stream.
Pre Condition:
$none
Post Condition:
$none

GridSim 5.0 beta

The University of Melbourne, Australia, 2009