GridSim 5.0 beta

gridsim.net.fnb
Class FnbNetPacket

Object
  extended by FnbNetPacket
All Implemented Interfaces:
Packet

public class FnbNetPacket
extends Object
implements Packet

This class contains the structure of a packet for the purpose of finite network buffers.

In order to minimise duplications, hence, to reduce memory consumption, common attributes to all packets have been stored in the FnbEndToEndPath class. The common attributes are destination ID, source ID, class type and total number of packets.

Since:
GridSim Toolkit 4.2
Author:
Agustin Caminero, Universidad de Castilla-La Mancha (UCLM) (Spain)
See Also:
FnbEndToEndPath

Constructor Summary
FnbNetPacket(Object data, int pktID, long size, int tag, int srcID)
          Constructs a network packet for data that fits into a single network packet.
FnbNetPacket(Object data, int pktID, long size, int tag, int srcID, int pktNum)
          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 getObjectID()
          Returns the gridlet/file to which this packet belongs
 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.
 boolean isFile()
          Checks whether this packet contains a file or not
 void setData(Object data)
          Modifies the data encapsulated in this packet.
 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.
 void setPath(FnbEndToEndPath connection)
          Establishes the end to end path to another entity
 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

FnbNetPacket

public FnbNetPacket(Object data,
                    int pktID,
                    long size,
                    int tag,
                    int srcID)
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.
Pre Condition:
$none
Post Condition:
$none

FnbNetPacket

public FnbNetPacket(Object data,
                    int pktID,
                    long size,
                    int tag,
                    int srcID,
                    int pktNum)
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 broken 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.
pktNum - The packet number of this packet in its series. If there are 10 packets, they should be numbered from 1 to 10.
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 packet 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 packet.

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

setPath

public void setPath(FnbEndToEndPath connection)
Establishes the end to end path to another entity

Parameters:
connection - an end-to-end connection path

getObjectID

public int getObjectID()
Returns the gridlet/file to which this packet belongs

Returns:
the gridlet/file to which this packet belongs

isFile

public boolean isFile()
Checks whether this packet contains a file or not

Returns:
true if this is a file, false otherwise

GridSim 5.0 beta

The University of Melbourne, Australia, 2009