jist.swans.route
Class RouteZrpZdp

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

public class RouteZrpZdp
extends java.lang.Object
implements RouteInterface.Zrp.Iarp

Zone Routing Protocol: Zone Discovery (sub)Protocol - an alternate IARP.

Since:
SWANS1.0
Version:
$Id: RouteZrpZdp.java,v 1.32 2005/03/13 16:11:55 barr Exp $
Author:
Rimon Barr <barr+jist@cs.cornell.edu>

Nested Class Summary
private static class RouteZrpZdp.LinkEntry
          ZDP link entry.
static class RouteZrpZdp.MessageZdp
          ZDP (Zone Discovery Protocol) packet.
private  class RouteZrpZdp.TimerRefresh
          Link refresh timer.
private  class RouteZrpZdp.TimerSend
          Delayed outgoing send timer.
 
Field Summary
private  byte compress
          compression mode.
static byte COMPRESS_INFINITE
          compression constant: inifinite.
static byte COMPRESS_NODE
          compression constant: aggregate across single node.
static byte COMPRESS_NONE
          compression constant: no aggregation.
static byte COMPRESS_ZONE
          compression constant: aggregate across zone.
static byte COMPRESS_ZONE_REVERSE
          compression constant: aggregate across zone.
private  java.lang.ref.SoftReference computedRoutes
          intra-zone routes: Hashtable dst - RouteEntry.
 long DELAY
          zdp delay time.
 long FLUSH
          zdp flush time.
 long JITTER
          zdp update jitter.
private  java.util.Hashtable links
          zone link state: NetAddress - LinkEntry.
private  java.util.Hashtable linksSrcDst
          zone link state: src - Vector(dst).
static org.apache.log4j.Logger logZDP
          logger for ZDP events.
private  RouteZrpZdp.TimerRefresh refreshTimer
          refresh/flush timer callback.
private  boolean sendScheduled
          whether the send timer is active.
private  RouteZrpZdp.TimerSend sendTimer
          send timer callback.
private  short seq
          zdp link destination-sequence identifier.
private  RouteZrp zrp
          reference to zrp routing framework.
 
Constructor Summary
RouteZrpZdp(RouteZrp zrp)
          Create a new "default" IARP (ZRP sub-protocol) handler.
RouteZrpZdp(RouteZrp zrp, java.lang.String config)
          Create a new "default" IARP (ZRP sub-protocol) handler.
 
Method Summary
private  void addLinkSrcDst(NetAddress src, NetAddress dst)
          Add link from source-destination hashes.
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 computeDistancesToSource()
          Compute distances FROM every node TO source.
private  java.util.Hashtable computeRoutes(NetAddress src)
          (Re-)Compute a minimum hop route for each node in zone using current link state information.
private  void flushLinks()
          Remove any links that have flush bit set, and set flush bit on others (clock algorithm).
private  RouteZrpZdp.LinkEntry getLink(Link link)
          Return link entry.
private  java.util.Collection getLinkDsts(NetAddress src)
          Get known link destinations for given source address.
private  java.util.Collection getLinks()
          Return link entries collection.
 java.util.Enumeration getLinks(NetAddress src)
          Return iterator of links from given source address.
private  java.util.Collection getLinkSrcs()
          Get known link sources.
 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.Hashtable 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 incLinkSeq()
          Increment local link sequence identifier.
private  boolean isLinkUp(Link link)
          Whether link entry exists.
 void linkinfo(Link link, boolean drop)
          Notify IARP of link state change.
private  void linkinfo(Link link, short id, boolean drop)
          Process incoming link information.
 void receive(RouteInterface.Zrp.MessageIarp msg, NetAddress from)
          Process incoming IARP packet.
private  void removeLink(Link link, java.util.Iterator it)
          Remove link from data structures.
private  void removeLinkSrcDst(NetAddress src, NetAddress dst)
          Remove link from source-destination hashes.
private  boolean routesComputed()
          Return whether routes have already been computed.
private  void send()
          Transmit a zone-wide link state delta.
 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.
private  boolean updateLink(Link link, short id, boolean drop)
          Update link information in data structures.
private  void updateLinkSrcDst(NetAddress src, NetAddress dst, boolean drop)
          Add or remove link from source-destination hashes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logZDP

public static final org.apache.log4j.Logger logZDP
logger for ZDP events.


JITTER

public final long JITTER
zdp update jitter.

See Also:
Constant Field Values

DELAY

public final long DELAY
zdp delay time.

See Also:
Constant Field Values

FLUSH

public final long FLUSH
zdp flush time.

See Also:
Constant Field Values

COMPRESS_NONE

public static final byte COMPRESS_NONE
compression constant: no aggregation.

See Also:
Constant Field Values

COMPRESS_NODE

public static final byte COMPRESS_NODE
compression constant: aggregate across single node.

See Also:
Constant Field Values

COMPRESS_ZONE

public static final byte COMPRESS_ZONE
compression constant: aggregate across zone.

See Also:
Constant Field Values

COMPRESS_ZONE_REVERSE

public static final byte COMPRESS_ZONE_REVERSE
compression constant: aggregate across zone.

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.


seq

private short seq
zdp link destination-sequence identifier.


links

private java.util.Hashtable links
zone link state: NetAddress - LinkEntry.


linksSrcDst

private java.util.Hashtable linksSrcDst
zone link state: src - Vector(dst).


computedRoutes

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


sendScheduled

private boolean sendScheduled
whether the send timer is active.


sendTimer

private RouteZrpZdp.TimerSend sendTimer
send timer callback.


refreshTimer

private RouteZrpZdp.TimerRefresh refreshTimer
refresh/flush timer callback.


compress

private byte compress
compression mode.

Constructor Detail

RouteZrpZdp

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

Parameters:
zrp - object reference to zrp routing framework

RouteZrpZdp

public RouteZrpZdp(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

addLinkSrcDst

private void addLinkSrcDst(NetAddress src,
                           NetAddress dst)
Add link from source-destination hashes.

Parameters:
src - link source address
dst - link destination address

removeLinkSrcDst

private void removeLinkSrcDst(NetAddress src,
                              NetAddress dst)
Remove link from source-destination hashes.

Parameters:
src - link source address
dst - link destination address

updateLinkSrcDst

private void updateLinkSrcDst(NetAddress src,
                              NetAddress dst,
                              boolean drop)
Add or remove link from source-destination hashes.

Parameters:
src - link source address
dst - link destination address
drop - whether to add or remove link

getLinkSrcs

private java.util.Collection getLinkSrcs()
Get known link sources.

Returns:
collection of known link source addresses

getLinkDsts

private java.util.Collection getLinkDsts(NetAddress src)
Get known link destinations for given source address.

Parameters:
src - link source address
Returns:
collection of link destinations for given source address

getLink

private RouteZrpZdp.LinkEntry getLink(Link link)
Return link entry.

Parameters:
link - link source-destination pair
Returns:
link entry

isLinkUp

private boolean isLinkUp(Link link)
Whether link entry exists.

Parameters:
link - link source-destination pair
Returns:
whether link entry exists

updateLink

private boolean updateLink(Link link,
                           short id,
                           boolean drop)
Update link information in data structures.

Parameters:
link - source-destination pair
id - destination sequenced identifier
drop - whether link failed
Returns:
whether routing tables need update

removeLink

private void removeLink(Link link,
                        java.util.Iterator it)
Remove link from data structures.

Parameters:
link - link source-destination pair
it - active iterator of link entries, if any

getLinks

private java.util.Collection getLinks()
Return link entries collection.

Returns:
link entries collection

flushLinks

private void flushLinks()
Remove any links that have flush bit set, and set flush bit on others (clock algorithm).


showLinks

public void showLinks()
Display link state.

Specified by:
showLinks in interface RouteInterface.Zrp.Iarp

routesComputed

private boolean routesComputed()
Return whether routes have already been computed.

Returns:
whether routes have already been computed

getRoutes

private java.util.Hashtable 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.Hashtable computeRoutes(NetAddress src)
(Re-)Compute a minimum hop route for each node in zone using current link state information.

Parameters:
src - local address, center of zone
Returns:
hashtable of minimum intra-zone routes: NetAddress -- RouteEntry

showRoutes

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

Specified by:
showRoutes in interface RouteInterface.Zrp.Iarp

computeDistancesToSource

private java.util.Map computeDistancesToSource()
Compute distances FROM every node TO source.

Returns:
map containing shortest distances (Integer) from every node (NetAddress) to the source

incLinkSeq

private short incLinkSeq()
Increment local link sequence identifier.

Returns:
new link sequence identifier

linkinfo

private void linkinfo(Link link,
                      short id,
                      boolean drop)
Process incoming link information.

Parameters:
link - link source-destination pair
id - destination sequenced identifier
drop - whether link failed

send

private void send()
Transmit a zone-wide link state delta.


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

start

public void start()
Start running protocol.

Specified by:
start in interface Protocol