core
Class CBRConnection

java.lang.Object
  extended by core.Connection
      extended by core.CBRConnection

public class CBRConnection
extends Connection

A constant bit-rate connection between two DTN nodes.


Field Summary
 
Fields inherited from class core.Connection
bytesTransferred, fromInterface, fromNode, msgFromNode, msgOnFly, toInterface, toNode
 
Constructor Summary
CBRConnection(DTNHost fromNode, NetworkInterface fromInterface, DTNHost toNode, NetworkInterface toInterface, int connectionSpeed)
          Creates a new connection between nodes and sets the connection state to "up".
 
Method Summary
 void abortTransfer()
          Aborts the transfer of the currently transferred message.
 int getRemainingByteCount()
          Returns the amount of bytes to be transferred before ongoing transfer is ready or 0 if there's no ongoing transfer or it has finished already
 double getSpeed()
          returns the current speed of the connection
 double getTransferDoneTime()
          Gets the transferdonetime
 boolean isMessageTransferred()
          Returns true if the current message transfer is done.
 int startTransfer(DTNHost from, Message m)
          Sets a message that this connection is currently transferring.
 java.lang.String toString()
          Returns a String presentation of the connection.
 
Methods inherited from class core.Connection
clearMsgOnFly, finalizeTransfer, getMessage, getOtherInterface, getOtherNode, getTotalBytesTransferred, isInitiator, isReadyForTransfer, isUp, setUpState, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CBRConnection

public CBRConnection(DTNHost fromNode,
                     NetworkInterface fromInterface,
                     DTNHost toNode,
                     NetworkInterface toInterface,
                     int connectionSpeed)
Creates a new connection between nodes and sets the connection state to "up".

Parameters:
fromNode - The node that initiated the connection
fromInterface - The interface that initiated the connection
toNode - The node in the other side of the connection
toInterface - The interface in the other side of the connection
connectionSpeed - Transfer speed of the connection (Bps) when the connection is initiated
Method Detail

startTransfer

public int startTransfer(DTNHost from,
                         Message m)
Sets a message that this connection is currently transferring. If message passing is controlled by external events, this method is not needed (but then e.g. Connection.finalizeTransfer() and isMessageTransferred() will not work either). Only a one message at a time can be transferred using one connection.

Specified by:
startTransfer in class Connection
Parameters:
from - The host sending the message
m - The message
Returns:
The value returned by MessageRouter.receiveMessage(Message, DTNHost)

abortTransfer

public void abortTransfer()
Aborts the transfer of the currently transferred message.

Overrides:
abortTransfer in class Connection

getTransferDoneTime

public double getTransferDoneTime()
Gets the transferdonetime


isMessageTransferred

public boolean isMessageTransferred()
Returns true if the current message transfer is done.

Specified by:
isMessageTransferred in class Connection
Returns:
True if the transfer is done, false if not

getSpeed

public double getSpeed()
returns the current speed of the connection

Specified by:
getSpeed in class Connection

getRemainingByteCount

public int getRemainingByteCount()
Returns the amount of bytes to be transferred before ongoing transfer is ready or 0 if there's no ongoing transfer or it has finished already

Specified by:
getRemainingByteCount in class Connection
Returns:
the amount of bytes to be transferred

toString

public java.lang.String toString()
Returns a String presentation of the connection.

Overrides:
toString in class Connection