routing
Class MaxPropRouter

java.lang.Object
  extended by routing.MessageRouter
      extended by routing.ActiveRouter
          extended by routing.MaxPropRouter

public class MaxPropRouter
extends ActiveRouter

Implementation of MaxProp router as described in MaxProp: Routing for Vehicle-Based Disruption-Tolerant Networks by John Burgess et al.


Field Summary
static java.lang.String ALPHA_S
          The alpha parameter string
static int BYTES_TRANSFERRED_AVG_SAMPLES
          Over how many samples the "average number of bytes transferred per transfer opportunity" is taken
static double DEFAULT_ALPHA
          The default value for alpha
static int DEFAULT_PROB_SET_MAX_SIZE
          Default value for the meeting probability set maximum size (50).
static java.lang.String MAXPROP_NS
          Router's setting namespace ("MaxPropRouter")
static java.lang.String PROB_SET_MAX_SIZE_S
          Meeting probability set maximum size -setting id ("probSetMaxSize").
 
Fields inherited from class routing.ActiveRouter
DELETE_DELIVERED_S, deleteDelivered, RESPONSE_PREFIX, sendingConnections, TTL_CHECK_INTERVAL
 
Fields inherited from class routing.MessageRouter
B_SIZE_S, DENIED_NO_SPACE, DENIED_OLD, DENIED_TTL, DENIED_UNSPECIFIED, MSG_TTL_S, msgTtl, Q_MODE_FIFO, Q_MODE_RANDOM, RCV_OK, SEND_QUEUE_MODE_S, TRY_LATER_BUSY
 
Constructor Summary
protected MaxPropRouter(MaxPropRouter r)
          Copy constructor.
  MaxPropRouter(Settings settings)
          Constructor.
 
Method Summary
 int calcThreshold()
          Calculates and returns the current threshold value for the buffer's split based on the average number of bytes transferred per transfer opportunity and the hop counts of the messages in the buffer.
 void changedConnection(Connection con)
          Called when a connection's state changes.
 double getCost(DTNHost from, DTNHost to)
          Returns the message delivery cost between two hosts from this host's point of view.
protected  Message getOldestMessage(boolean excludeMsgBeingSent)
          Returns the next message that should be dropped, according to MaxProp's message ordering scheme (see MaxPropTupleComparator).
 RoutingInfo getRoutingInfo()
          Returns routing information about this router.
 Message messageTransferred(java.lang.String id, DTNHost from)
          This method should be called (on the receiving host) after a message was successfully transferred.
 MessageRouter replicate()
          Creates a replicate of this router.
protected  void transferDone(Connection con)
          Method is called just before a transfer is finalized at ActiveRouter.update().
 void update()
          Checks out all sending connections to finalize the ready ones and abort those whose connection went down.
 
Methods inherited from class routing.ActiveRouter
addToSendingConnections, canStartTransfer, checkReceiving, createNewMessage, dropExpiredMessages, exchangeDeliverableMessages, getConnections, getMessagesForConnected, init, isSending, isTransferring, makeRoomForMessage, makeRoomForNewMessage, receiveMessage, requestDeliverableMessages, shuffleMessages, startTransfer, transferAborted, tryAllMessages, tryAllMessagesToAllConnections, tryMessagesForConnected, tryMessagesToConnections
 
Methods inherited from class routing.MessageRouter
addApplication, addToMessages, compareByQueueMode, deleteMessage, getApplications, getBufferSize, getFreeBufferSize, getHost, getMessage, getMessageCollection, getNrofMessages, hasMessage, isDeliveredMessage, isIncomingMessage, messageAborted, putToIncomingBuffer, removeFromIncomingBuffer, removeFromMessages, sendMessage, sortByQueueMode, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAXPROP_NS

public static final java.lang.String MAXPROP_NS
Router's setting namespace ("MaxPropRouter")

See Also:
Constant Field Values

PROB_SET_MAX_SIZE_S

public static final java.lang.String PROB_SET_MAX_SIZE_S
Meeting probability set maximum size -setting id ("probSetMaxSize"). The maximum amount of meeting probabilities to store.

See Also:
Constant Field Values

DEFAULT_PROB_SET_MAX_SIZE

public static final int DEFAULT_PROB_SET_MAX_SIZE
Default value for the meeting probability set maximum size (50).

See Also:
Constant Field Values

BYTES_TRANSFERRED_AVG_SAMPLES

public static int BYTES_TRANSFERRED_AVG_SAMPLES
Over how many samples the "average number of bytes transferred per transfer opportunity" is taken


ALPHA_S

public static final java.lang.String ALPHA_S
The alpha parameter string

See Also:
Constant Field Values

DEFAULT_ALPHA

public static final double DEFAULT_ALPHA
The default value for alpha

See Also:
Constant Field Values
Constructor Detail

MaxPropRouter

public MaxPropRouter(Settings settings)
Constructor. Creates a new prototype router based on the settings in the given Settings object.

Parameters:
settings - The settings object

MaxPropRouter

protected MaxPropRouter(MaxPropRouter r)
Copy constructor. Creates a new router based on the given prototype.

Parameters:
r - The router prototype where setting values are copied from
Method Detail

changedConnection

public void changedConnection(Connection con)
Description copied from class: ActiveRouter
Called when a connection's state changes. This version doesn't do anything but subclasses may want to override this.

Overrides:
changedConnection in class ActiveRouter
Parameters:
con - The connection that changed

messageTransferred

public Message messageTransferred(java.lang.String id,
                                  DTNHost from)
Description copied from class: MessageRouter
This method should be called (on the receiving host) after a message was successfully transferred. The transferred message is put to the message buffer unless this host is the final recipient of the message.

Overrides:
messageTransferred in class ActiveRouter
Parameters:
id - Id of the transferred message
from - Host the message was from (previous hop)
Returns:
The message that this host received

transferDone

protected void transferDone(Connection con)
Method is called just before a transfer is finalized at ActiveRouter.update(). MaxProp makes book keeping of the delivered messages so their IDs are stored.

Overrides:
transferDone in class ActiveRouter
Parameters:
con - The connection whose transfer was finalized

getOldestMessage

protected Message getOldestMessage(boolean excludeMsgBeingSent)
Returns the next message that should be dropped, according to MaxProp's message ordering scheme (see MaxPropTupleComparator).

Overrides:
getOldestMessage in class ActiveRouter
Parameters:
excludeMsgBeingSent - If true, excludes message(s) that are being sent from the next-to-be-dropped check (i.e., if next message to drop is being sent, the following message is returned)
Returns:
The oldest message or null if no message could be returned (no messages in buffer or all messages in buffer are being sent and exludeMsgBeingSent is true)

update

public void update()
Description copied from class: ActiveRouter
Checks out all sending connections to finalize the ready ones and abort those whose connection went down. Also drops messages whose TTL <= 0 (checking every one simulated minute).

Overrides:
update in class ActiveRouter
See Also:
ActiveRouter.addToSendingConnections(Connection)

getCost

public double getCost(DTNHost from,
                      DTNHost to)
Returns the message delivery cost between two hosts from this host's point of view. If there is no path between "from" and "to" host, Double.MAX_VALUE is returned. Paths are calculated only to hosts that this host has messages to.

Parameters:
from - The host where a message is coming from
to - The host where a message would be destined to
Returns:
The cost of the cheapest path to the destination or Double.MAX_VALUE if such a path doesn't exist

calcThreshold

public int calcThreshold()
Calculates and returns the current threshold value for the buffer's split based on the average number of bytes transferred per transfer opportunity and the hop counts of the messages in the buffer. Method is public only to make testing easier.

Returns:
current threshold value (hop count) for the buffer's split

getRoutingInfo

public RoutingInfo getRoutingInfo()
Description copied from class: MessageRouter
Returns routing information about this router.

Overrides:
getRoutingInfo in class MessageRouter
Returns:
The routing information.

replicate

public MessageRouter replicate()
Description copied from class: MessageRouter
Creates a replicate of this router. The replicate has the same settings as this router but empty buffers and routing tables.

Specified by:
replicate in class MessageRouter
Returns:
The replicate