|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcore.Connection
public abstract class Connection
A connection between two DTN nodes.
Field Summary | |
---|---|
protected int |
bytesTransferred
how many bytes this connection has transferred |
protected NetworkInterface |
fromInterface
|
protected DTNHost |
fromNode
|
protected DTNHost |
msgFromNode
|
protected Message |
msgOnFly
|
protected NetworkInterface |
toInterface
|
protected DTNHost |
toNode
|
Constructor Summary | |
---|---|
Connection(DTNHost fromNode,
NetworkInterface fromInterface,
DTNHost toNode,
NetworkInterface toInterface)
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. |
protected void |
clearMsgOnFly()
Clears the message that is currently being transferred. |
void |
finalizeTransfer()
Finalizes the transfer of the currently transferred message. |
Message |
getMessage()
Gets the message that this connection is currently transferring. |
NetworkInterface |
getOtherInterface(NetworkInterface i)
Returns the interface in the other end of the connection |
DTNHost |
getOtherNode(DTNHost node)
Returns the node in the other end of the connection |
abstract 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 |
abstract double |
getSpeed()
Gets the current connection speed |
int |
getTotalBytesTransferred()
Returns the total amount of bytes this connection has transferred so far (including all transfers). |
boolean |
isInitiator(DTNHost node)
Returns true if the given node is the initiator of the connection, false otherwise |
abstract boolean |
isMessageTransferred()
Returns true if the current message transfer is done |
boolean |
isReadyForTransfer()
Returns true if the connection is ready to transfer a message (connection is up and there is no message being transferred). |
boolean |
isUp()
Returns true if the connection is up |
void |
setUpState(boolean state)
Sets the state of the connection. |
abstract 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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected DTNHost toNode
protected NetworkInterface toInterface
protected DTNHost fromNode
protected NetworkInterface fromInterface
protected DTNHost msgFromNode
protected Message msgOnFly
protected int bytesTransferred
Constructor Detail |
---|
public Connection(DTNHost fromNode, NetworkInterface fromInterface, DTNHost toNode, NetworkInterface toInterface)
fromNode
- The node that initiated the connectionfromInterface
- The interface that initiated the connectiontoNode
- The node in the other side of the connectiontoInterface
- The interface in the other side of the connectionMethod Detail |
---|
public boolean isUp()
public boolean isInitiator(DTNHost node)
node
- The node to check
public void setUpState(boolean state)
state
- True if the connection is up, false if notpublic abstract int startTransfer(DTNHost from, Message m)
finalizeTransfer()
and
isMessageTransferred()
will not work either). Only a one message
at a time can be transferred using one connection.
m
- The message
MessageRouter.receiveMessage(Message, DTNHost)
public void update()
public void abortTransfer()
public abstract int getRemainingByteCount()
protected void clearMsgOnFly()
getMessage()
will return null after this.
public void finalizeTransfer()
getMessage()
).
public abstract boolean isMessageTransferred()
public boolean isReadyForTransfer()
public Message getMessage()
public abstract double getSpeed()
public int getTotalBytesTransferred()
public DTNHost getOtherNode(DTNHost node)
node
- The node in this end of the connection
public NetworkInterface getOtherInterface(NetworkInterface i)
i
- The interface in this end of the connection
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |