jist.swans.route
Class RouteDsr

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

public class RouteDsr
extends java.lang.Object
implements RouteInterface.Dsr

An implementation of the Dynamic Source Routing protocol.

Since:
SWANS1.0
See Also:
DSR Specification

Nested Class Summary
 
Nested classes/interfaces inherited from interface jist.swans.route.RouteInterface.Dsr
RouteInterface.Dsr.BufferedPacket
 
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 long BROADCAST_JITTER
          The maximum amount of jitter before sending a packet.
static long GRAT_REPLY_HOLDOFF
          The minimum time between sending gratuitous Route Replies.
static long MAINT_PERIOD
          The timeout before retransmitting a packet using network-level acknowledgements.
static int MAX_MAINT_REXMT
          The maximum number of times a packet will be retransmitted using network-level acknowledgements.
static long MAX_REQUEST_PERIOD
          The maximum timeout before retransmitting a Route Request.
static int MAX_REQUEST_TABLE_IDS
          The maximum number of ID values to store in a single Route Request Table entry.
static int MAX_SALVAGE_COUNT
          The maximum number of times a packet can be salvaged.
static byte MAX_TTL
          The maximum Time-To-Live for a DSR packet.
static long PASSIVE_ACK_TIMEOUT
          The timeout before retransmitting a packet using passive acknowledgements.
static long REQUEST_PERIOD
          The initial timeout before retransmitting a Route Request.
static long SEND_BUFFER_TIMEOUT
          The maximum amount of time a packet can remain in the Send Buffer.
static int TRY_PASSIVE_ACKS
          The number of times to try retransmission using passive ackknowledgments.
 
Constructor Summary
RouteDsr(NetAddress localAddr)
          Creates a new RouteDsr object.
 
Method Summary
 void AddRouteReplyEntry(NetAddress originator, NetAddress lastHop)
          Adds a new entry to the Gratuitous Route Reply Table.
 void DeleteBuffer(RouteInterface.Dsr.BufferedPacket msg)
          Removes the given BufferedPacket from the Send Buffer.
 void DeleteRouteReplyEntry(NetAddress originator, NetAddress lastHop)
          Deletes an entry from the Gratuitous Route Reply Table.
 void DiscoverRoute(NetAddress dest, short requestId)
          Initiates a Route Discovery for the given address.
 void dropNotify(Message msg, MacAddress nextHopMac, Reason reason)
          Notification mechanism for packet dropped due to various "Reasons"
 RouteInterface.Dsr getProxy()
          Gets the proxy interface for this object.
 void InsertBuffer(NetMessage.Ip msg)
          Inserts a new packet into the Send Buffer, annotating it with the current system time.
 void InsertRouteCache(NetAddress dest, NetAddress[] route)
          Inserts a new route into the Route Cache.
 void peek(NetMessage msg, MacAddress lastHop)
          If the given message uses the DSR protocol, the DSR header is examined to see if any actions need to be performed on this packet (such as forwarding it).
 void receive(Message msg, NetAddress src, MacAddress lastHop, byte macId, NetAddress dst, byte priority, byte ttl)
          Receives a message from the network.
 void send(NetMessage msg)
          Sends the given message.
 void setNetEntity(NetInterface netEntity)
          Sets the interface to the network layer.
 void TransmitWithNetworkAck(NetMessage.Ip msg, java.lang.Short ackId, long timeout, int numRetransmits)
          Sends the given message.
 void TransmitWithPassiveAck(NetMessage.Ip msg, int numRetransmits)
          Sends the given message and waits for a passive acknowledgement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BROADCAST_JITTER

public static final long BROADCAST_JITTER
The maximum amount of jitter before sending a packet.

See Also:
Constant Field Values

SEND_BUFFER_TIMEOUT

public static final long SEND_BUFFER_TIMEOUT
The maximum amount of time a packet can remain in the Send Buffer.

See Also:
Constant Field Values

REQUEST_PERIOD

public static final long REQUEST_PERIOD
The initial timeout before retransmitting a Route Request.

See Also:
Constant Field Values

MAX_REQUEST_PERIOD

public static final long MAX_REQUEST_PERIOD
The maximum timeout before retransmitting a Route Request.

See Also:
Constant Field Values

MAX_MAINT_REXMT

public static final int MAX_MAINT_REXMT
The maximum number of times a packet will be retransmitted using network-level acknowledgements.

See Also:
Constant Field Values

MAINT_PERIOD

public static final long MAINT_PERIOD
The timeout before retransmitting a packet using network-level acknowledgements.

See Also:
Constant Field Values

GRAT_REPLY_HOLDOFF

public static final long GRAT_REPLY_HOLDOFF
The minimum time between sending gratuitous Route Replies.

See Also:
Constant Field Values

PASSIVE_ACK_TIMEOUT

public static final long PASSIVE_ACK_TIMEOUT
The timeout before retransmitting a packet using passive acknowledgements.

See Also:
Constant Field Values

TRY_PASSIVE_ACKS

public static final int TRY_PASSIVE_ACKS
The number of times to try retransmission using passive ackknowledgments.

See Also:
Constant Field Values

MAX_REQUEST_TABLE_IDS

public static final int MAX_REQUEST_TABLE_IDS
The maximum number of ID values to store in a single Route Request Table entry.

See Also:
Constant Field Values

MAX_TTL

public static final byte MAX_TTL
The maximum Time-To-Live for a DSR packet.

See Also:
Constant Field Values

MAX_SALVAGE_COUNT

public static final int MAX_SALVAGE_COUNT
The maximum number of times a packet can be salvaged.

See Also:
Constant Field Values
Constructor Detail

RouteDsr

public RouteDsr(NetAddress localAddr)
Creates a new RouteDsr object.

Parameters:
localAddr - local node address
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

setNetEntity

public void setNetEntity(NetInterface netEntity)
Sets the interface to the network layer.

Parameters:
netEntity - the interface to the network layer

getProxy

public RouteInterface.Dsr getProxy()
Gets the proxy interface for this object.

Returns:
the proxy RouteInterface.Dsr interface for this object

DiscoverRoute

public void DiscoverRoute(NetAddress dest,
                          short requestId)
Initiates a Route Discovery for the given address. Messages containing Route Request headers are broadcast to all nodes within range.

Specified by:
DiscoverRoute in interface RouteInterface.Dsr
Parameters:
dest - the address to which we desire a route
requestId - the ID number of the request to be performed. DiscoverRoute should always be invoked with a unique value in this parameter.

InsertRouteCache

public void InsertRouteCache(NetAddress dest,
                             NetAddress[] route)
Inserts a new route into the Route Cache. All routes stored in the Route Cache are assumed to be routes from this node to another node.

Parameters:
dest - the destination of the route to be added
route - the sequence of nodes from here to dest. Neither the IP address of this node nor of the dest node should be included in the route array.

InsertBuffer

public void InsertBuffer(NetMessage.Ip msg)
Inserts a new packet into the Send Buffer, annotating it with the current system time.

Specified by:
InsertBuffer in interface RouteInterface.Dsr
Parameters:
msg - the message to insert into the buffer

DeleteBuffer

public void DeleteBuffer(RouteInterface.Dsr.BufferedPacket msg)
Removes the given BufferedPacket from the Send Buffer.

Specified by:
DeleteBuffer in interface RouteInterface.Dsr
Parameters:
msg - the packet to remove from the Send Buffer

AddRouteReplyEntry

public void AddRouteReplyEntry(NetAddress originator,
                               NetAddress lastHop)
Adds a new entry to the Gratuitous Route Reply Table.

Specified by:
AddRouteReplyEntry in interface RouteInterface.Dsr
Parameters:
originator - the originator of the shortened Source Route
lastHop - the most recent hop address of the shortened Source Route

DeleteRouteReplyEntry

public void DeleteRouteReplyEntry(NetAddress originator,
                                  NetAddress lastHop)
Deletes an entry from the Gratuitous Route Reply Table.

Specified by:
DeleteRouteReplyEntry in interface RouteInterface.Dsr
Parameters:
originator - the originator of the shortened Source Route
lastHop - the most recent hop address of the shortened Source Route

TransmitWithPassiveAck

public void TransmitWithPassiveAck(NetMessage.Ip msg,
                                   int numRetransmits)
Sends the given message and waits for a passive acknowledgement. If no acknowledgement is heard, the message will be retransmitted up to TRY_PASSIVE_ACKS times.

Specified by:
TransmitWithPassiveAck in interface RouteInterface.Dsr
Parameters:
msg - the message to be sent
numRetransmits - the number of times this message has already been retransmitted. Callers should usually pass in zero for this.

TransmitWithNetworkAck

public void TransmitWithNetworkAck(NetMessage.Ip msg,
                                   java.lang.Short ackId,
                                   long timeout,
                                   int numRetransmits)
Sends the given message. The message should be a DSR packet containing an acknowledgement request with the given id. If no acknowledgement is received within the given timeout, the packet will be retransmitted up to MAX_MAINT_REXMT times.

Specified by:
TransmitWithNetworkAck in interface RouteInterface.Dsr
Parameters:
msg - the message to be sent
ackId - the ID number of the Acknowledgement Request
timeout - the number of clock ticks to wait before retransmitting the message
numRetransmits - the number of times this packet has already been transmitted. Callers should normally pass in zero for this.

peek

public void peek(NetMessage msg,
                 MacAddress lastHop)
If the given message uses the DSR protocol, the DSR header is examined to see if any actions need to be performed on this packet (such as forwarding it).

Specified by:
peek in interface RouteInterface
Parameters:
msg - the message to examine
lastHop - the MAC address of the node that sent this message

send

public void send(NetMessage msg)
Sends the given message. This method can be called because this node is originating a packet (in which case a DSR header is added to the packet and it is sent) or because this node is forwarding a packet (in which case this method actually does nothing, with all DSR header option processing being performed by peek.

Specified by:
send in interface NetInterface.NetHandler
Specified by:
send in interface RouteInterface
Parameters:
msg - the message to be sent

receive

public void receive(Message msg,
                    NetAddress src,
                    MacAddress lastHop,
                    byte macId,
                    NetAddress dst,
                    byte priority,
                    byte ttl)
Receives a message from the network. This method merely strips off the DSR header and hands the message off to the transport layer.

Specified by:
receive in interface NetInterface.NetHandler
Parameters:
msg - the message being received
src - the address of the originator of the message
lastHop - the MAC address of the most recent node to forward the message
macId - the ID of the MAC interface
dst - the address of the destination of the message (which should be the IP address of this node)
priority - the IP priority of the message
ttl - the IP time to live of the message