Sim
Class Packet

java.lang.Object
  extended by Sim.Packet

public class Packet
extends java.lang.Object

Packet contains data that will be sent at the network layer.


Constructor Summary
Packet(int source, int dest, int dataSize)
          Constructs a new Packet, without a listener.
Packet(int source, int dest, int dataSize, PacketListener listener)
          Constructs a new Packet.
 
Method Summary
 int getDataSize()
           
 int getDest()
           
 int getSize()
          Returns the size of the serialized form of this Packet in number of bytes.
 int getSource()
           
 boolean hasArrived()
          Reports true if this Packet has arrived at its destination at least once.
 void reportArrival(double time)
          Tells a Packet that it has arrived at its destination at the given time.
 void reportHop(double d)
          reports when this packet has gone a hop;
 void reportSent(double time)
          Tells a Packet that it has been introduced to a Node for sending.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Packet

public Packet(int source,
              int dest,
              int dataSize,
              PacketListener listener)
Constructs a new Packet.

Parameters:
source - source Node address
dest - destination Node address
dataSize - size of the user data segment of this packet
listener - nullable listener to receive events.

Packet

public Packet(int source,
              int dest,
              int dataSize)
Constructs a new Packet, without a listener.

Parameters:
source - source Node address
dest - destination Node address
dataSize - size of the user data segment of this packet
Method Detail

reportSent

public void reportSent(double time)
Tells a Packet that it has been introduced to a Node for sending.

Parameters:
time - Time of origination

reportArrival

public void reportArrival(double time)
Tells a Packet that it has arrived at its destination at the given time.

Parameters:
time - Time of arrival, must be greater than or equal to time reported in reportSent(double).

reportHop

public void reportHop(double d)
reports when this packet has gone a hop;


hasArrived

public boolean hasArrived()
Reports true if this Packet has arrived at its destination at least once.


getSource

public int getSource()

getDest

public int getDest()

getSize

public int getSize()
Returns the size of the serialized form of this Packet in number of bytes.


getDataSize

public int getDataSize()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object