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

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.BezierRouting, RouteInterface.Dsr, RouteInterface.ECGRIDRouting, RouteInterface.GenericRouting, RouteInterface.HeartbeatProtocol, RouteInterface.MultiTreeRouting, RouteInterface.RandomPathRouting, RouteInterface.ShortestPathRouting, RouteInterface.Zrp
 
Field Summary
static org.apache.log4j.Logger logZRP
          logger for ZRP events.
 
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.
 void dropNotify(Message msg, MacAddress nextHopMac, Reason reason)
          Notification mechanism for packet dropped due to various "Reasons"
 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.
 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)
          Send a message through the routing protocol
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.

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

dropNotify

public void dropNotify(Message msg,
                       MacAddress nextHopMac,
                       Reason reason)
Description copied from interface: NetInterface.NetHandler
Notification mechanism for packet dropped due to various "Reasons"

Specified by:
dropNotify in interface NetInterface.NetHandler

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

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)
Send a message through the routing protocol

Specified by:
send in interface NetInterface.NetHandler
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