routing
Class SprayAndWaitRouter

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

public class SprayAndWaitRouter
extends ActiveRouter

Implementation of Spray and wait router as depicted in Spray and Wait: An Efficient Routing Scheme for Intermittently Connected Mobile Networks by Thrasyvoulos Spyropoulus et al.


Field Summary
static java.lang.String BINARY_MODE
          identifier for the binary-mode setting ("binaryMode")
static java.lang.String NROF_COPIES
          identifier for the intial number of copies setting ("nrofCopies")
static java.lang.String SPRAYANDWAIT_NS
          SprayAndWait router's settins namespace ("SprayAndWaitRouter")
 
Fields inherited from class routing.ActiveRouter
RESPONSE_PREFIX, TTL_CHECK_INTERVAL
 
Fields inherited from class routing.MessageRouter
B_SIZE, DENIED_NO_SPACE, DENIED_OLD, MSG_TTL, msgTtl, RCV_OK, TRY_LATER_BUSY
 
Constructor Summary
  SprayAndWaitRouter(Settings s)
           
protected SprayAndWaitRouter(SprayAndWaitRouter r)
          Copyconstructor.
 
Method Summary
 boolean createNewMessage(DTNHost to, java.lang.String id, int size, int responseSize)
          Creates a new message to the router.
 Message messageTransferred(java.lang.String id, DTNHost from)
          This method should be called (on the receiving host) after a message was successfully transferred.
 int receiveMessage(Message m, DTNHost from)
          Try to start receiving a message from another host.
 SprayAndWaitRouter replicate()
          Creates a replicate of this router.
protected  void transferDone(Connection con)
          Called just before a transfer is finalized (by 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, changedConnection, checkReceiving, dropExpiredMessages, exchangeDeliverableMessages, getConnections, getMessagesForConnected, getOldestMessage, init, isSending, isTransferring, makeRoomForMessage, makeRoomForNewMessage, requestDeliverableMessages, shuffleMessages, startTransfer, transferAborted, tryAllMessages, tryAllMessagesToAllConnections, tryAllMessagesToAllConnections, tryMessagesForConnected
 
Methods inherited from class routing.MessageRouter
addToMessages, deleteMessage, getBufferSize, getFreeBufferSize, getHost, getMessage, getMessageCollection, getNrofMessages, getRoutingInfo, hasMessage, isDeliveredMessage, messageAborted, putToIncomingBuffer, removeFromIncomingBuffer, sendMessage, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NROF_COPIES

public static final java.lang.String NROF_COPIES
identifier for the intial number of copies setting ("nrofCopies")

See Also:
Constant Field Values

BINARY_MODE

public static final java.lang.String BINARY_MODE
identifier for the binary-mode setting ("binaryMode")

See Also:
Constant Field Values

SPRAYANDWAIT_NS

public static final java.lang.String SPRAYANDWAIT_NS
SprayAndWait router's settins namespace ("SprayAndWaitRouter")

See Also:
Constant Field Values
Constructor Detail

SprayAndWaitRouter

public SprayAndWaitRouter(Settings s)

SprayAndWaitRouter

protected SprayAndWaitRouter(SprayAndWaitRouter r)
Copyconstructor.

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

receiveMessage

public int receiveMessage(Message m,
                          DTNHost from)
Description copied from class: MessageRouter
Try to start receiving a message from another host.

Overrides:
receiveMessage in class ActiveRouter
Parameters:
m - Message to put in the receiving buffer
from - Who the message is from
Returns:
Value zero if the node accepted the message (RCV_OK), value less than zero if node rejected the message (e.g. DENIED_OLD), value bigger than zero if the other node should try later (e.g. TRY_LATER_BUSY).

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

createNewMessage

public boolean createNewMessage(DTNHost to,
                                java.lang.String id,
                                int size,
                                int responseSize)
Description copied from class: MessageRouter
Creates a new message to the router.

Overrides:
createNewMessage in class ActiveRouter
Parameters:
to - The host the message is to
id - Identifier of the message (should be unique). A message with non-unique ID will replace an old message with the same ID in this node's buffer and other nodes may reject the message because they have "seen" a message with that ID before.
size - Size of the message (in bytes)
responseSize - Size of the requested response message or 0 if no response is requested
Returns:
True if the creation succeeded, false if not (e.g. the message was too big for the buffer)

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)

transferDone

protected void transferDone(Connection con)
Called just before a transfer is finalized (by ActiveRouter.update()). Reduces the number of copies we have left for a message. In binary Spray and Wait, sending host is left with floor(n/2) copies, but in standard mode, nrof copies left is reduced by one.

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

replicate

public SprayAndWaitRouter 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