routing
Class FirstContactRouter

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

public class FirstContactRouter
extends ActiveRouter

First contact router which uses only a single copy of the message (or fragments) and forwards it to the first available contact.


Field Summary
 
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 FirstContactRouter(FirstContactRouter r)
          Copy constructor.
  FirstContactRouter(Settings s)
          Constructor.
 
Method Summary
protected  int checkReceiving(Message m)
          Checks if router "wants" to start receiving message (i.e.
 FirstContactRouter 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, changedConnection, createNewMessage, dropExpiredMessages, exchangeDeliverableMessages, getConnections, getMessagesForConnected, getOldestMessage, init, isSending, isTransferring, makeRoomForMessage, makeRoomForNewMessage, messageTransferred, 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, getRoutingInfo, 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
 

Constructor Detail

FirstContactRouter

public FirstContactRouter(Settings s)
Constructor. Creates a new message router based on the settings in the given Settings object.

Parameters:
s - The settings object

FirstContactRouter

protected FirstContactRouter(FirstContactRouter r)
Copy constructor.

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

checkReceiving

protected int checkReceiving(Message m)
Description copied from class: ActiveRouter
Checks if router "wants" to start receiving message (i.e. router isn't transferring, doesn't have the message and has room for it).

Overrides:
checkReceiving in class ActiveRouter
Parameters:
m - The message to check
Returns:
A return code similar to MessageRouter.receiveMessage(Message, DTNHost), i.e. MessageRouter.RCV_OK if receiving seems to be OK, TRY_LATER_BUSY if router is transferring, DENIED_OLD if the router is already carrying the message or it has been delivered to this router (as final recipient), or DENIED_NO_SPACE if the message does not fit into 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)
Description copied from class: ActiveRouter
Method is called just before a transfer is finalized at ActiveRouter.update(). Subclasses that are interested of the event may want to override this.

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

replicate

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