yass.packet
Class Packet

java.lang.Object
  extended by yass.packet.Packet
Direct Known Subclasses:
IgfPacket

public class Packet
extends java.lang.Object

Represents a data packet which traverses the simulated network


Field Summary
protected  double creationTimestamp
          The time at which this packet was created
protected  double deadline
          The time by which this packet must arrive at its destination to be useful
protected  Node destination
          Eventual destination node of this packet
protected  int headerSize
          Size of this packet's header, in bits
protected  int id
          Globally-unique ID for this packet
protected  java.lang.Object payload
          Packet payload
protected  int payloadSize
          Size of this packet's payload, in bits
protected  java.util.Set<Node> proposedNextHops
          The intended next-hop nodes for the next transmission of this packet
protected  Route route
          Route traversed thus far by this packet
protected  int size
          Total size of this packet, in bits
protected  Node source
          Source node of this packet
protected  int ttl
          Remaining packet TTL in network hops
protected  PacketType type
          The type of data encapsulated by this packet
 
Constructor Summary
protected Packet()
          No-args constructor to implement initialisation common to all Packet instances.
  Packet(int id, Node source, Node destination, int headerSize, int payloadSize, java.lang.Object payload, java.util.Set<Node> proposedNextHops, double deadline, double creationTimestamp, int ttl, PacketType type)
          Constructs a new instance of Packet.
 
Method Summary
 void appendToTrace(Node node)
          Appends an additional node to the existing node-traversal trace
 Packet copy()
          Copies this packet, supplying an object representing a distinct instance of the same packet.
 int decrementTtl()
          Reduces the TTL by 1, and return the new TTL
 boolean equals(java.lang.Object o)
          Determines if the supplied arbitrary object is equal to this Packet
 double getCreationTimestamp()
          Obtains the simulation-global time at which the packet was created
 double getDeadline()
          Obtains the packet delivery deadline
 Node getDestination()
          Obtains the destination node for this packet
 int getHeaderSize()
          Obtains the header size, in bits
 int getId()
          Obtains the globally-unique identifier for this packet
 java.lang.Object getPayload()
          Obtains the payload attached to this packet
 int getPayloadSize()
          Obtains the payload size, in bits
 java.util.Set<Node> getProposedNextHops()
          Obtains the set of proposed next-hop nodes for the next transmission of this packet
 Route getRoute()
          Obtains the route traversed thus far by this packet
 int getSize()
          Obtains the total size of this packet, in bits
 Node getSource()
          Obtains the source node for this packet
 int getTtl()
          Obtains the remaining TTL in network hops
 PacketType getType()
          Obtains the type of this packet
 int hashCode()
          Obtains a hashcode value for this Packet
 void setDestination(Node destination)
          Sets the packet destination to the supplied node
 java.lang.String toString()
          Obtains a textual representation of this packet
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected int id
Globally-unique ID for this packet


size

protected int size
Total size of this packet, in bits


headerSize

protected int headerSize
Size of this packet's header, in bits


payloadSize

protected int payloadSize
Size of this packet's payload, in bits


source

protected Node source
Source node of this packet


destination

protected Node destination
Eventual destination node of this packet


route

protected Route route
Route traversed thus far by this packet


payload

protected java.lang.Object payload
Packet payload


proposedNextHops

protected java.util.Set<Node> proposedNextHops
The intended next-hop nodes for the next transmission of this packet


deadline

protected double deadline
The time by which this packet must arrive at its destination to be useful


creationTimestamp

protected double creationTimestamp
The time at which this packet was created


ttl

protected int ttl
Remaining packet TTL in network hops


type

protected PacketType type
The type of data encapsulated by this packet

Constructor Detail

Packet

protected Packet()
No-args constructor to implement initialisation common to all Packet instances. This constructor should be chained by all public constructors, both of base type Packet and all of its subclasses. This constructor should not be called directly by clients, however, as it only performs partial initialisation; the new Packet instance will not be fully initialised into a consistent state by this constructor alone.


Packet

public Packet(int id,
              Node source,
              Node destination,
              int headerSize,
              int payloadSize,
              java.lang.Object payload,
              java.util.Set<Node> proposedNextHops,
              double deadline,
              double creationTimestamp,
              int ttl,
              PacketType type)
Constructs a new instance of Packet. Subclasses are responsible for overriding this operation if necessary and returning an object of appropriate type, but this return type will always implement the interface of Packet.

Parameters:
ttl - the number of remaining permitted node-node hops for
id - globally-unique ID for this packet
source - source node of this packet
destination - eventual destination node of this packet
payload - packet payload
proposedNextHops - intended next-hop nodes for the next transmission of this packet
deadline - the time by which this packet must arrive at its destination to be considered useful
creationTimestamp - the simulation-global time at which the packet was created, not the node-local time at which the node thinks it created the packet
headerSize - header size, in bits
payloadSize - payload size, in bits
type - the packet type
Method Detail

copy

public Packet copy()
Copies this packet, supplying an object representing a distinct instance of the same packet. This models the situation where a packet is copied from one node to another; the packet posessed by the source and destination are in some sense the same packet, but are nevertheless distinct.

Returns:
a copy of the packet

appendToTrace

public void appendToTrace(Node node)
Appends an additional node to the existing node-traversal trace

Parameters:
node - the node to append to the existing trace

decrementTtl

public int decrementTtl()
Reduces the TTL by 1, and return the new TTL

Returns:
the new TTL

hashCode

public int hashCode()
Obtains a hashcode value for this Packet

Overrides:
hashCode in class java.lang.Object
Returns:
a hashcode value for this Packet

equals

public boolean equals(java.lang.Object o)
Determines if the supplied arbitrary object is equal to this Packet

Overrides:
equals in class java.lang.Object
Parameters:
o - the object against which a test of equality is to be applied
Returns:
true if the supplied object is equal to this Route, otherwise false

toString

public java.lang.String toString()
Obtains a textual representation of this packet

Overrides:
toString in class java.lang.Object
Returns:
a textual representation of this packet

getId

public int getId()
Obtains the globally-unique identifier for this packet

Returns:
the globally-unique identifier for this packet

getSize

public int getSize()
Obtains the total size of this packet, in bits

Returns:
the total size of this packet, in bits

getHeaderSize

public int getHeaderSize()
Obtains the header size, in bits

Returns:
the header size, in bits

getPayloadSize

public int getPayloadSize()
Obtains the payload size, in bits

Returns:
the payload size, in bits

getSource

public Node getSource()
Obtains the source node for this packet

Returns:
the source node for this packet

getDestination

public Node getDestination()
Obtains the destination node for this packet

Returns:
the destination node for this packet

setDestination

public void setDestination(Node destination)
Sets the packet destination to the supplied node

Parameters:
destination - the new destination

getRoute

public Route getRoute()
Obtains the route traversed thus far by this packet

Returns:
the route traversed thus far by this packet

getProposedNextHops

public java.util.Set<Node> getProposedNextHops()
Obtains the set of proposed next-hop nodes for the next transmission of this packet

Returns:
the set of proposed next-hop nodes

getPayload

public java.lang.Object getPayload()
Obtains the payload attached to this packet

Returns:
the payload attached to this packet

getDeadline

public double getDeadline()
Obtains the packet delivery deadline

Returns:
the packet delivery deadline

getCreationTimestamp

public double getCreationTimestamp()
Obtains the simulation-global time at which the packet was created

Returns:
the simulation-global time at which the packet was created

getTtl

public int getTtl()
Obtains the remaining TTL in network hops

Returns:
the remaining TTL in network hops

getType

public PacketType getType()
Obtains the type of this packet

Returns:
the type of this packet