jist.swans.route
Class RouteZrp

java.lang.Object
  extended by jist.swans.route.RouteZrp
All Implemented Interfaces:
JistAPI.Proxiable, JistAPI.Timeless, Protocol, NetInterface.NetHandler, RouteInterface, RouteInterface.Zrp

public class RouteZrp
extends java.lang.Object
implements RouteInterface.Zrp

Zone Routing Protocol Implementation.

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

Nested Class Summary
static class RouteZrp.ZrpPacketStats
          Data structure to collect ZRP packet statistics.
static class RouteZrp.ZrpStats
          Data structure to collect ZRP statistics.
 
Nested classes/interfaces inherited from interface jist.swans.route.RouteInterface.Zrp
RouteInterface.Zrp.Brp, RouteInterface.Zrp.Iarp, RouteInterface.Zrp.Ierp, RouteInterface.Zrp.MessageBrp, RouteInterface.Zrp.MessageIarp, RouteInterface.Zrp.MessageIerp, RouteInterface.Zrp.MessageNdp, RouteInterface.Zrp.MessageZrp, RouteInterface.Zrp.Ndp
 
Nested classes/interfaces inherited from interface jist.swans.route.RouteInterface
RouteInterface.Aodv, RouteInterface.Dsr, RouteInterface.Zrp
 
Field Summary
private  RouteInterface.Zrp.Brp brp
          reference to BRP sub-protocol.
private  RouteInterface.Zrp.Iarp iarp
          reference to IARP sub-protocol.
private  RouteInterface.Zrp.Ierp ierp
          reference to IERP sub-protocol.
private  NetAddress localAddr
          local network address.
static org.apache.log4j.Logger logZRP
          logger for ZRP events.
private  RouteInterface.Zrp.Ndp ndp
          reference to NDP sub-protocol.
private  NetInterface netEntity
          network entity.
private  byte radius
          zone radius.
private  RouteInterface.Zrp self
          self-referencing proxy entity.
private  RouteZrp.ZrpStats stats
          statistics accumulator.
 
Constructor Summary
RouteZrp(NetAddress localAddr, int radius)
          Create and initialize new ZRP instance.
RouteZrp(NetAddress localAddr, java.lang.String config)
          Create and initialize new ZRP instance.
 
Method Summary
 void broadcast(RouteInterface.Zrp.MessageZrp msg)
          Send out a message for a sub-protocol.
 RouteInterface.Zrp.Brp getBrp()
          Return BRP sub-protocol implementation.
 RouteInterface.Zrp.Iarp getIarp()
          Return IARP sub-protocol implementation.
 RouteInterface.Zrp.Ierp getIerp()
          Return IERP sub-protocol implementation.
 NetAddress getLocalAddr()
          Return local network address.
 RouteInterface.Zrp.Ndp getNdp()
          Return NDP sub-protocol implementation.
 RouteInterface.Zrp getProxy()
          Return self-referencing proxy entity.
 byte getRadius()
          Return ZRP zone radius.
 RouteZrp.ZrpStats getStats()
          Return zrp statistics.
private  void init(NetAddress localAddr, int radius)
          Initialize new ZRP instance.
 void peek(NetMessage msg, MacAddress lastHop)
          Called by the network layer for every incoming packet.
 void receive(Message msg, NetAddress src, MacAddress lastHop, byte macId, NetAddress dst, byte priority, byte ttl)
          Receive a message from network layer.
static NetAddress[] replaceDest(NetAddress[] route, NetAddress finder, NetAddress[] remainder)
          Replace end of route with route to destination.
 void send(NetMessage.Ip msg, NetAddress dst)
          Send out a data packet.
 void send(NetMessage msg)
          Called by the network layer to request transmission of a packet that requires routing.
static boolean seqAfter(int seq1, int seq2)
          Whether first sequence number is after the second (with wrap-around).
 void setBrp(RouteInterface.Zrp.Brp brp)
          Set BRP sub-protocol implementation.
 void setIarp(RouteInterface.Zrp.Iarp iarp)
          Set IARP sub-protocol implementation.
 void setIerp(RouteInterface.Zrp.Ierp ierp)
          Set IERP sub-protocol implementation.
 void setNdp(RouteInterface.Zrp.Ndp ndp)
          Set NDP sub-protocol implementation.
 void setNetEntity(NetInterface netEntity)
          Set network entity.
 void setStats(RouteZrp.ZrpStats stats)
          Set zrp statistics object.
 void setSubProtocols(RouteInterface.Zrp.Ndp ndp, RouteInterface.Zrp.Iarp iarp, RouteInterface.Zrp.Brp brp, RouteInterface.Zrp.Ierp ierp)
          Set all the ZRP sub-protocol implementations.
 void setSubProtocolsDefault()
          Set all the ZRP sub-protocols to default implementations.
 void start()
          Start running protocol.
 void timeout(Timer t)
          Process timer expiration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logZRP

public static final org.apache.log4j.Logger logZRP
logger for ZRP events.


netEntity

private NetInterface netEntity
network entity.


self

private RouteInterface.Zrp self
self-referencing proxy entity.


ndp

private RouteInterface.Zrp.Ndp ndp
reference to NDP sub-protocol.


iarp

private RouteInterface.Zrp.Iarp iarp
reference to IARP sub-protocol.


brp

private RouteInterface.Zrp.Brp brp
reference to BRP sub-protocol.


ierp

private RouteInterface.Zrp.Ierp ierp
reference to IERP sub-protocol.


radius

private byte radius
zone radius.


localAddr

private NetAddress localAddr
local network address.


stats

private RouteZrp.ZrpStats stats
statistics accumulator.

Constructor Detail

RouteZrp

public RouteZrp(NetAddress localAddr,
                int radius)
Create and initialize new ZRP instance.

Parameters:
localAddr - local node address
radius - zone radius

RouteZrp

public RouteZrp(NetAddress localAddr,
                java.lang.String config)
Create and initialize new ZRP instance.

Parameters:
localAddr - local node address
config - configuration string
Method Detail

seqAfter

public static boolean seqAfter(int seq1,
                               int seq2)
Whether first sequence number is after the second (with wrap-around).

Parameters:
seq1 - first sequence number
seq2 - second sequence number
Returns:
whether first sequence number is after the second (with wrap-around)

replaceDest

public static NetAddress[] replaceDest(NetAddress[] route,
                                       NetAddress finder,
                                       NetAddress[] remainder)
Replace end of route with route to destination.

Parameters:
route - route in format: (src ... partial route ... dst)
finder - node that knows route to destination
remainder - route to destination from finder
Returns:
complete route from source to destination

init

private void init(NetAddress localAddr,
                  int radius)
Initialize new ZRP instance.

Parameters:
localAddr - local node address
radius - zone radius

setNetEntity

public void setNetEntity(NetInterface netEntity)
Set network entity. Also starts timers. Should be called only once.

Parameters:
netEntity - network entity

getProxy

public RouteInterface.Zrp getProxy()
Return self-referencing proxy entity.

Returns:
self-referencing proxy entity

getLocalAddr

public NetAddress getLocalAddr()
Return local network address.

Returns:
local network address

getRadius

public byte getRadius()
Return ZRP zone radius.

Returns:
ZRP zone radius

setStats

public void setStats(RouteZrp.ZrpStats stats)
Set zrp statistics object.

Parameters:
stats - zrp statistics object

getStats

public RouteZrp.ZrpStats getStats()
Return zrp statistics.

Returns:
zrp statistics

setNdp

public void setNdp(RouteInterface.Zrp.Ndp ndp)
Set NDP sub-protocol implementation.

Parameters:
ndp - NDP sub-protocol implementation

getNdp

public RouteInterface.Zrp.Ndp getNdp()
Return NDP sub-protocol implementation.

Returns:
NDP sub-protocol implementation

setIarp

public void setIarp(RouteInterface.Zrp.Iarp iarp)
Set IARP sub-protocol implementation.

Parameters:
iarp - IARP sub-protocol implementation

getIarp

public RouteInterface.Zrp.Iarp getIarp()
Return IARP sub-protocol implementation.

Returns:
IARP sub-protocol implementation

setBrp

public void setBrp(RouteInterface.Zrp.Brp brp)
Set BRP sub-protocol implementation.

Parameters:
brp - BRP sub-protocol implementation

getBrp

public RouteInterface.Zrp.Brp getBrp()
Return BRP sub-protocol implementation.

Returns:
BRP sub-protocol implementation

setIerp

public void setIerp(RouteInterface.Zrp.Ierp ierp)
Set IERP sub-protocol implementation.

Parameters:
ierp - IERP sub-protocol implementation

getIerp

public RouteInterface.Zrp.Ierp getIerp()
Return IERP sub-protocol implementation.

Returns:
IERP sub-protocol implementation

setSubProtocols

public void setSubProtocols(RouteInterface.Zrp.Ndp ndp,
                            RouteInterface.Zrp.Iarp iarp,
                            RouteInterface.Zrp.Brp brp,
                            RouteInterface.Zrp.Ierp ierp)
Set all the ZRP sub-protocol implementations.

Parameters:
ndp - NDP sub-protocol implementation
iarp - IARP sub-protocol implementation
brp - BRP sub-protocol implementation
ierp - IERP sub-protocol implementation

setSubProtocolsDefault

public void setSubProtocolsDefault()
Set all the ZRP sub-protocols to default implementations.


timeout

public void timeout(Timer t)
Process timer expiration.

Specified by:
timeout in interface RouteInterface.Zrp
Parameters:
t - timer that expired

start

public void start()
Start running protocol.

Specified by:
start in interface Protocol

peek

public void peek(NetMessage msg,
                 MacAddress lastHop)
Called by the network layer for every incoming packet. A routing implementation may wish to look at these packets for informational purposes, but should not change their contents.

Specified by:
peek in interface RouteInterface
Parameters:
msg - incoming packet
lastHop - last link-level hop of incoming packet

send

public void send(NetMessage msg)
Called by the network layer to request transmission of a packet that requires routing. It is the responsibility of the routing layer to provide a best-effort transmission of this packet to an appropriate next hop by calling the network layer sending routines once this routing information becomes available.

Specified by:
send in interface RouteInterface
Parameters:
msg - outgoing packet

broadcast

public void broadcast(RouteInterface.Zrp.MessageZrp msg)
Send out a message for a sub-protocol.

Parameters:
msg - packet payload

send

public void send(NetMessage.Ip msg,
                 NetAddress dst)
Send out a data packet.

Parameters:
msg - data packet
dst - packet destination

receive

public void receive(Message msg,
                    NetAddress src,
                    MacAddress lastHop,
                    byte macId,
                    NetAddress dst,
                    byte priority,
                    byte ttl)
Receive a message from network layer.

Specified by:
receive in interface NetInterface.NetHandler
Parameters:
msg - message received
src - source network address
lastHop - source link address
macId - incoming interface
dst - destination network address
priority - packet priority
ttl - packet time-to-live