core
Class VBRConnection

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

public class VBRConnection
extends Connection

A connection between two DTN nodes. The transmission speed is updated every round from the endpoint transmission speeds


Field Summary
 
Fields inherited from class core.Connection
bytesTransferred, fromInterface, fromNode, msgFromNode, msgOnFly, toInterface, toNode
 
Constructor Summary
VBRConnection(DTNHost fromNode, NetworkInterface fromInterface, DTNHost toNode, NetworkInterface toInterface)
          Creates a new connection between nodes and sets the connection state to "up".
 
Method Summary
 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
 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.
 void update()
          Calculate the current transmission speed from the information given by the interfaces, and calculate the missing data amount.
 
Methods inherited from class core.Connection
abortTransfer, clearMsgOnFly, finalizeTransfer, getMessage, getOtherInterface, getOtherNode, getTotalBytesTransferred, isInitiator, isReadyForTransfer, isUp, setUpState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VBRConnection

public VBRConnection(DTNHost fromNode,
                     NetworkInterface fromInterface,
                     DTNHost toNode,
                     NetworkInterface toInterface)
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
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)

update

public void update()
Calculate the current transmission speed from the information given by the interfaces, and calculate the missing data amount.

Overrides:
update in class Connection

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

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

toString

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

Overrides:
toString in class Connection