Sim.Routing.DSR
Class DataHeader

java.lang.Object
  extended by Sim.Routing.DSR.DataHeader
All Implemented Interfaces:
ProtocolFrame

public class DataHeader
extends java.lang.Object
implements ProtocolFrame

DataHeader represents a packet with an explicit route. A DataHeader is put onto any routed (opposed to flooded) packet, and can contain a user data Packet or a nexted ProtocolFrame as extra data.


Constructor Summary
DataHeader(Route route, PacketId id)
          Constructs a new DataHeader that is for routing a user packet.
DataHeader(Route route, PacketId id, ProtocolFrame extraData)
          Constructs a new DataHeader to contain a nested ProtocolFrame.
 
Method Summary
 ProtocolFrame getExtraData()
          DataHeaders can carry additional data for use by DSR itself, and if a DSR-internal packet is being routed, it is contained as extra data.
 PacketId getId()
           
 int getNextAddress()
          Returns the next hop.
 Route getRouteRemaining()
          Returns the remaining portion of the route to the destination.
 int getSecondAddress()
          Returns the address of the hop after this one, or an invalid address less than 0 if there is no next hop.
 int getSize()
          Returns the "serialized" size of this portion of the packet.
 boolean isSingleHop()
          Returns true if the contained route has only a single hop (usually this means the packet is at the destination).
 DataHeader makeForward()
          Constructs a new DataHeader that is a forwarded version of this header.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataHeader

public DataHeader(Route route,
                  PacketId id)
Constructs a new DataHeader that is for routing a user packet.

Parameters:
route - non-null Route to take
id - non-null id to be used throughout this packet's lifetime

DataHeader

public DataHeader(Route route,
                  PacketId id,
                  ProtocolFrame extraData)
Constructs a new DataHeader to contain a nested ProtocolFrame.

Parameters:
route - non-null Route to take
id - non-null id to be used throughout this packet's lifetime
extraData - nullable ProtocolFrame (if null, works like DataHeader( Route, PacketId )
Method Detail

getRouteRemaining

public Route getRouteRemaining()
Returns the remaining portion of the route to the destination.

Returns:
non-null Route

getId

public PacketId getId()

getExtraData

public ProtocolFrame getExtraData()
DataHeaders can carry additional data for use by DSR itself, and if a DSR-internal packet is being routed, it is contained as extra data.

Returns:
nullable ProtocolFrame

isSingleHop

public boolean isSingleHop()
Returns true if the contained route has only a single hop (usually this means the packet is at the destination).


getNextAddress

public int getNextAddress()
Returns the next hop.


getSecondAddress

public int getSecondAddress()
Returns the address of the hop after this one, or an invalid address less than 0 if there is no next hop.


makeForward

public DataHeader makeForward()
Constructs a new DataHeader that is a forwarded version of this header.


getSize

public int getSize()
Returns the "serialized" size of this portion of the packet.

Specified by:
getSize in interface ProtocolFrame

toString

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