jist.swans.route
Class RouteZrpIerp.MessageIerp

java.lang.Object
  extended by jist.swans.route.RouteZrpIerp.MessageIerp
All Implemented Interfaces:
JistAPI.Timeless, Message, RouteInterface.Zrp.MessageIerp, RouteInterface.Zrp.MessageZrp
Enclosing class:
RouteZrpIerp

private static class RouteZrpIerp.MessageIerp
extends java.lang.Object
implements RouteInterface.Zrp.MessageIerp

IERP (IntErzone Routing Protocol) packet.

   type (req, rep)               size: 1
   length                        size: 1  -- computed
   node pointer                  size: 1
   RESERVED                      size: 1
   query ID                      size: 2
   RESERVED                      size: 2
   src .. route .. dst           size: 4 * n
  


Field Summary
static int FIXED_SIZE
          fixed ierp packet size.
static int INC_SIZE
          incremental ierp packet size.
private  NetAddress[] route
          route.
private  short seq
          unique source-sequence request identifier.
private  byte type
          packet type.
static byte TYPE_RREP
          ierp packet type constant: reply.
static byte TYPE_RREQ
          ierp packet type constant: request.
 
Fields inherited from interface jist.swans.misc.Message
NULL
 
Constructor Summary
private RouteZrpIerp.MessageIerp(byte type, short seq, NetAddress[] route)
          Create new IERP packet.
  RouteZrpIerp.MessageIerp(short seq, NetAddress dst)
          Create new IERP route request packet.
 
Method Summary
 RouteZrpIerp.MessageIerp appendHop(NetAddress nextHop)
          Create new packet and append hop to packet route.
 void getBytes(byte[] b, int offset)
          Store packet into byte array.
 NetAddress getDst()
          Return packet destination address, if available.
 short getID()
          Return packet identifier, if available.
 byte getLength()
          Return packet length.
 NetAddress[] getRoute()
          Return route.
 int getSize()
          Return packet size or Constants.ZERO_WIRE_SIZE.
 NetAddress getSrc()
          Return packet source address, if available.
 byte getType()
          Return packet type.
 RouteZrpIerp.MessageIerp makeReply(NetAddress finder, NetAddress[] routeToDst)
          Create a reply IERP packet.
private static NetAddress[] routeAppend(NetAddress[] route, NetAddress nextHop)
          Helper method: append hop to route.
private static boolean routeDupCheck(NetAddress[] route)
          Return whether is a cycle in the route.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIXED_SIZE

public static final int FIXED_SIZE
fixed ierp packet size.

See Also:
Constant Field Values

INC_SIZE

public static final int INC_SIZE
incremental ierp packet size.

See Also:
Constant Field Values

TYPE_RREQ

public static final byte TYPE_RREQ
ierp packet type constant: request.

See Also:
Constant Field Values

TYPE_RREP

public static final byte TYPE_RREP
ierp packet type constant: reply.

See Also:
Constant Field Values

type

private byte type
packet type.


seq

private short seq
unique source-sequence request identifier.


route

private NetAddress[] route
route.

Constructor Detail

RouteZrpIerp.MessageIerp

public RouteZrpIerp.MessageIerp(short seq,
                                NetAddress dst)
Create new IERP route request packet.

Parameters:
seq - source-sequence request number
dst - route request destination

RouteZrpIerp.MessageIerp

private RouteZrpIerp.MessageIerp(byte type,
                                 short seq,
                                 NetAddress[] route)
Create new IERP packet.

Parameters:
type - ierp packet type
seq - source-sequence request number
route - route
Method Detail

getType

public byte getType()
Return packet type.

Returns:
packet type

getLength

public byte getLength()
Return packet length.

Returns:
packet length

getID

public short getID()
Return packet identifier, if available.

Specified by:
getID in interface RouteInterface.Zrp.MessageIerp
Returns:
packet identifier

getSrc

public NetAddress getSrc()
Return packet source address, if available.

Specified by:
getSrc in interface RouteInterface.Zrp.MessageIerp
Returns:
packet source address

getDst

public NetAddress getDst()
Return packet destination address, if available.

Specified by:
getDst in interface RouteInterface.Zrp.MessageIerp
Returns:
packet destination address

getRoute

public NetAddress[] getRoute()
Return route.

Returns:
route (do not modify)

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getSize

public int getSize()
Return packet size or Constants.ZERO_WIRE_SIZE.

Specified by:
getSize in interface Message
Returns:
packet size

getBytes

public void getBytes(byte[] b,
                     int offset)
Store packet into byte array.

Specified by:
getBytes in interface Message
Parameters:
b - destination byte array
offset - byte array starting offset

routeAppend

private static NetAddress[] routeAppend(NetAddress[] route,
                                        NetAddress nextHop)
Helper method: append hop to route.

Parameters:
route - existing route (source .. route .. destination)
nextHop - next hop to append (before destination)
Returns:
new route

routeDupCheck

private static boolean routeDupCheck(NetAddress[] route)
Return whether is a cycle in the route.

Parameters:
route - route to check for cycle
Returns:
whether there is a cycle in the route

appendHop

public RouteZrpIerp.MessageIerp appendHop(NetAddress nextHop)
Create new packet and append hop to packet route.

Parameters:
nextHop - next hop to append to route
Returns:
new message with next hop appended

makeReply

public RouteZrpIerp.MessageIerp makeReply(NetAddress finder,
                                          NetAddress[] routeToDst)
Create a reply IERP packet.

Parameters:
finder - address of node that found destination
routeToDst - remaining route to destination
Returns:
reply ierp packet