jist.swans.route
Class RouteZrpIarp

java.lang.Object
  extended by jist.swans.route.RouteZrpIarp
All Implemented Interfaces:
Protocol, Timer, RouteInterface.Zrp.Iarp

public class RouteZrpIarp
extends java.lang.Object
implements RouteInterface.Zrp.Iarp, Timer

Zone Routing Protocol: IntrAzone Routing (sub)Protocol: Default implementation.

Since:
SWANS1.0
Version:
$Id: RouteZrpIarp.java,v 1.24 2004/04/06 16:07:51 barr Exp $
Author:
Rimon Barr <barr+jist@cs.cornell.edu>

Nested Class Summary
private static class RouteZrpIarp.LinkStateEntry
          IARP Link state entry.
private static class RouteZrpIarp.MessageIarp
          IARP (IntrAzone Routing Protocol) packet.
static class RouteZrpIarp.RouteEntry
          IARP route entry.
 
Field Summary
private  byte compress
          compression mode.
static byte COMPRESS_INFINITE
          compression constant: inifinite.
static byte COMPRESS_NONE
          compression constant: no aggregation.
private  java.lang.ref.SoftReference computedRoutes
          intra-zone routes: NetAddress - RouteEntry.
static long JITTER
          iarp transmission jitter.
static long LINK_LIFETIME
          link state expiration time.
private  java.util.HashMap linkState
          zone link state: NetAddress - LinkStateEntry.
private  short linkStateSeq
          iarp identifier.
static org.apache.log4j.Logger logIARP
          logger for IARP events.
private  RouteZrp zrp
          reference to zrp routing framework.
 
Constructor Summary
RouteZrpIarp(RouteZrp zrp)
          Create a new "default" IARP (ZRP sub-protocol) handler.
RouteZrpIarp(RouteZrp zrp, java.lang.String config)
          Create a new "default" IARP (ZRP sub-protocol) handler.
 
Method Summary
private  void clearRoutes()
          Flush the computed routes.
 java.util.Set computeCoverage(NetAddress src, int depth)
          Find the set of nodes within a given distance of source.
private  java.util.Map computeRoutes()
          (Re-)Compute a minimum hop route for each node in zone using current link state information.
private  boolean flushLinkState()
          Flush out IARP link state that has expired.
 java.util.Enumeration getLinks(NetAddress src)
          Return iterator of links from given source address.
 int getNumLinks()
          Return number of intra-zone links.
 int getNumRoutes()
          Return number of intra-zone routes.
 java.util.Collection getPeripheral()
          Return all peripheral nodes.
 NetAddress[] getRoute(NetAddress dst)
          Return intra-zone route.
private  java.util.Map getRoutes()
          Return the intra-zone routes, computing them if necessary.
 boolean hasRoute(NetAddress dst)
          Return whether node is within zone (if IARP has route to it).
private  short incLinkStateSeq()
          Return new link state sequence number.
 void linkinfo(Link link, boolean drop)
          Notify IARP of link state change.
private  void neighboursChanged()
          Neighbours have changed.
 void receive(RouteInterface.Zrp.MessageIarp msg, NetAddress from)
          Process incoming IARP packet.
 void setCompress(byte compress)
          Set packet compression mode.
 void showLinks()
          Display link state.
 void showRoutes()
          Display in-zone routing table.
 void start()
          Start running protocol.
 void timeout()
          Timer expiration processing.
private  boolean updateLinkState(NetAddress src, short seq, NetAddress[] dst)
          Update link state with new information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logIARP

public static final org.apache.log4j.Logger logIARP
logger for IARP events.


LINK_LIFETIME

public static final long LINK_LIFETIME
link state expiration time.

See Also:
Constant Field Values

JITTER

public static final long JITTER
iarp transmission jitter.

See Also:
Constant Field Values

COMPRESS_NONE

public static final byte COMPRESS_NONE
compression constant: no aggregation.

See Also:
Constant Field Values

COMPRESS_INFINITE

public static final byte COMPRESS_INFINITE
compression constant: inifinite.

See Also:
Constant Field Values

zrp

private RouteZrp zrp
reference to zrp routing framework.


linkState

private java.util.HashMap linkState
zone link state: NetAddress - LinkStateEntry.


linkStateSeq

private short linkStateSeq
iarp identifier.


computedRoutes

private java.lang.ref.SoftReference computedRoutes
intra-zone routes: NetAddress - RouteEntry.


compress

private byte compress
compression mode.

Constructor Detail

RouteZrpIarp

public RouteZrpIarp(RouteZrp zrp)
Create a new "default" IARP (ZRP sub-protocol) handler.

Parameters:
zrp - object reference to zrp routing framework

RouteZrpIarp

public RouteZrpIarp(RouteZrp zrp,
                    java.lang.String config)
Create a new "default" IARP (ZRP sub-protocol) handler.

Parameters:
zrp - object reference to zrp routing framework
config - configuration string
Method Detail

setCompress

public void setCompress(byte compress)
Set packet compression mode.

Parameters:
compress - packet compression mode

incLinkStateSeq

private short incLinkStateSeq()
Return new link state sequence number.

Returns:
new link state sequence number.

neighboursChanged

private void neighboursChanged()
Neighbours have changed.


updateLinkState

private boolean updateLinkState(NetAddress src,
                                short seq,
                                NetAddress[] dst)
Update link state with new information.

Parameters:
src - link state information source
seq - link state source sequence number
dst - list of links from source
Returns:
whether local link state changed

flushLinkState

private boolean flushLinkState()
Flush out IARP link state that has expired.

Returns:
whether link state changed

getRoutes

private java.util.Map getRoutes()
Return the intra-zone routes, computing them if necessary.

Returns:
hashtable of minimum intra-zone routes: NetAddress -- RouteEntry

clearRoutes

private void clearRoutes()
Flush the computed routes.


computeRoutes

private java.util.Map computeRoutes()
(Re-)Compute a minimum hop route for each node in zone using current link state information.

Returns:
hashtable of minimum intra-zone routes: NetAddress -- RouteEntry

showLinks

public void showLinks()
Display link state.

Specified by:
showLinks in interface RouteInterface.Zrp.Iarp

showRoutes

public void showRoutes()
Display in-zone routing table.

Specified by:
showRoutes in interface RouteInterface.Zrp.Iarp

start

public void start()
Start running protocol.

Specified by:
start in interface Protocol

receive

public void receive(RouteInterface.Zrp.MessageIarp msg,
                    NetAddress from)
Process incoming IARP packet.

Specified by:
receive in interface RouteInterface.Zrp.Iarp
Parameters:
msg - iarp packet
from - source of iarp packet

linkinfo

public void linkinfo(Link link,
                     boolean drop)
Notify IARP of link state change.

Specified by:
linkinfo in interface RouteInterface.Zrp.Iarp
Parameters:
link - link that has changed
drop - whether link has failed (or been created)

getNumLinks

public int getNumLinks()
Return number of intra-zone links.

Specified by:
getNumLinks in interface RouteInterface.Zrp.Iarp
Returns:
number of intra-zone links

getLinks

public java.util.Enumeration getLinks(NetAddress src)
Return iterator of links from given source address.

Specified by:
getLinks in interface RouteInterface.Zrp.Iarp
Parameters:
src - link source address
Returns:
iterator of known link destination addresses

hasRoute

public boolean hasRoute(NetAddress dst)
Return whether node is within zone (if IARP has route to it).

Specified by:
hasRoute in interface RouteInterface.Zrp.Iarp
Parameters:
dst - destination node
Returns:
whether node is within zone

getRoute

public NetAddress[] getRoute(NetAddress dst)
Return intra-zone route.

Specified by:
getRoute in interface RouteInterface.Zrp.Iarp
Parameters:
dst - destination node
Returns:
route to node, or NullPointerException if dst not in zone

getNumRoutes

public int getNumRoutes()
Return number of intra-zone routes.

Specified by:
getNumRoutes in interface RouteInterface.Zrp.Iarp
Returns:
number of intra-zone routes

getPeripheral

public java.util.Collection getPeripheral()
Return all peripheral nodes.

Specified by:
getPeripheral in interface RouteInterface.Zrp.Iarp
Returns:
set of peripheral nodes

computeCoverage

public java.util.Set computeCoverage(NetAddress src,
                                     int depth)
Find the set of nodes within a given distance of source.

Specified by:
computeCoverage in interface RouteInterface.Zrp.Iarp
Parameters:
src - source node
depth - radius
Returns:
set of node addresses within distance of source

timeout

public void timeout()
Timer expiration processing.

Specified by:
timeout in interface Timer