| Constructor and Description |
|---|
DTNHost(java.util.List<MessageListener> msgLs,
java.util.List<MovementListener> movLs,
java.lang.String groupId,
java.util.List<NetworkInterface> interf,
ModuleCommunicationBus comBus,
MovementModel mmProto,
MessageRouter mRouterProto)
Creates a new DTNHost.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAccidentAt(MapNode node)
Add node to the set of known accidents
|
int |
compareTo(DTNHost h)
Compares two DTNHosts by their addresses.
|
void |
connect(DTNHost h)
for tests only --- do not use!!!
|
void |
connectionDown(Connection con) |
void |
connectionUp(Connection con)
Informs the router of this host about state change in a connection
object.
|
void |
createNewMessage(Message m)
Creates a new message to this host's router
|
void |
deleteMessage(java.lang.String id,
boolean drop)
Deletes a message from this host
|
boolean |
equals(DTNHost otherHost)
Checks if a host is the same as this host by comparing the object
reference
|
void |
forceConnection(DTNHost anotherHost,
java.lang.String interfaceId,
boolean up)
Force a connection event
|
int |
getAddress()
Returns the network-layer address of this host.
|
double |
getBufferOccupancy()
Returns the buffer occupancy percentage.
|
ModuleCommunicationBus |
getComBus()
Returns this hosts's ModuleCommunicationBus
|
java.util.List<Connection> |
getConnections()
Returns a copy of the list of connections this host has with other hosts
|
int |
getDangerMode()
Return the danger mode
|
NetworkInterface |
getInterface(int interfaceNo)
Find the network interface based on the index
|
protected NetworkInterface |
getInterface(java.lang.String interfacetype)
Find the network interface based on the interfacetype
|
java.util.List<NetworkInterface> |
getInterfaces()
Returns the interface objects of the node
|
java.util.Set<MapNode> |
getKnownAccidents()
Getter for known accidents set
|
java.util.Map<DTNHost,util.Tuple<Coord,java.lang.Integer>> |
getKnownLocations()
Getter for the known locations map
|
Coord |
getLocation()
Returns the current location of this host.
|
java.util.Collection<Message> |
getMessageCollection()
Returns the messages in a collection.
|
java.util.List<MapNode> |
getNodePath()
Getter for nodePath nodePath is a list of the entire path between the
node and his final destination (computed by Dijkstra's algorithm)
|
int |
getNrofMessages()
Returns the number of messages this node is carrying.
|
Path |
getPath()
Returns the Path this node is currently traveling or null if no path is
in use at the moment.
|
MessageRouter |
getRouter()
Returns the router of this host
|
RoutingInfo |
getRoutingInfo()
Returns routing info of this host's router.
|
int |
getStamp()
Getter for stamp
|
boolean |
isAwareOfAccidentAt(MapNode from)
True if the host if aware of the accident at the node
|
boolean |
isMovementActive()
Returns true if this node is actively moving (false if not)
|
boolean |
isRadioActive()
Returns true if this node's radio is active (false if not)
|
boolean |
isRecalculatingRoute()
Getter for recalculatingRoute boolean
|
boolean |
isStucked()
Return the stucked boolean
|
boolean |
isWarned()
Return the warned boolean
|
void |
messageAborted(java.lang.String id,
DTNHost from,
int bytesRemaining)
Informs the host that a message transfer was aborted.
|
void |
messageTransferred(java.lang.String id,
DTNHost from)
Informs the host that a message was successfully transferred.
|
void |
move(double timeIncrement)
Moves the node towards the next waypoint or waits if it is not time to
move yet
|
int |
receiveMessage(Message m,
DTNHost from)
Start receiving a message from another host
|
boolean |
requestDeliverableMessages(Connection con)
Requests for deliverable message from this host to be sent trough a
connection.
|
static void |
reset()
Reset the host and its interfaces
|
void |
sendMessage(java.lang.String id,
DTNHost to)
Sends a message from this host to another host
|
void |
setDangerMode(int dangerMode)
Set the danger mode
|
void |
setLocation(Coord location)
Sets the Node's location overriding any location set by movement model
|
void |
setName(java.lang.String name)
Sets the Node's name overriding the default name (groupId + netAddress)
|
void |
setNodePath(java.util.List<MapNode> nodePath)
Setter for nodePath
|
void |
setRecalculatingRoute(boolean recalculatingRoute)
Setter for recalculatingRoute boolean
|
void |
setStamp(int stamp)
Setter for stamp
|
void |
setStucked(boolean stucked)
Set stucked boolean
|
void |
setWarned(boolean warned)
Set warned boolean
|
java.lang.String |
toString()
Returns a string presentation of the host.
|
void |
update(boolean simulateConnections)
Updates node's network layer and router.
|
void |
updateKnownLocations(DTNHost host,
Coord c,
java.lang.Integer stamp)
Update known location based on freshness value
|
void |
updateSelfKnownLocation()
Update self known location Should be called before sending message
|
public DTNHost(java.util.List<MessageListener> msgLs, java.util.List<MovementListener> movLs, java.lang.String groupId, java.util.List<NetworkInterface> interf, ModuleCommunicationBus comBus, MovementModel mmProto, MessageRouter mRouterProto)
msgLs - Message listenersmovLs - Movement listenersgroupId - GroupID of this hostinterf - List of NetworkInterfaces for the classcomBus - Module communication bus objectmmProto - Prototype of the movement model of this hostmRouterProto - Prototype of the message router of this hostpublic static void reset()
public boolean isMovementActive()
public boolean isRadioActive()
public MessageRouter getRouter()
public int getAddress()
public ModuleCommunicationBus getComBus()
public void connectionUp(Connection con)
con - The connection object whose state changedpublic void connectionDown(Connection con)
public java.util.List<Connection> getConnections()
public Coord getLocation()
public Path getPath()
public void setLocation(Coord location)
location - The location to setpublic void setName(java.lang.String name)
name - The name to setpublic java.util.Collection<Message> getMessageCollection()
public int getNrofMessages()
public double getBufferOccupancy()
public RoutingInfo getRoutingInfo()
public java.util.List<NetworkInterface> getInterfaces()
public NetworkInterface getInterface(int interfaceNo)
protected NetworkInterface getInterface(java.lang.String interfacetype)
public void forceConnection(DTNHost anotherHost, java.lang.String interfaceId, boolean up)
public void connect(DTNHost h)
public void update(boolean simulateConnections)
simulateConnections - Should network layer be updated toopublic void move(double timeIncrement)
timeIncrement - How long time the node movespublic void sendMessage(java.lang.String id,
DTNHost to)
id - Identifier of the messageto - Host the message should be sent topublic int receiveMessage(Message m, DTNHost from)
m - The messagefrom - Who the message is fromMessageRouter.receiveMessage(Message, DTNHost)public void messageTransferred(java.lang.String id,
DTNHost from)
id - Identifier of the messagefrom - From who the message was frompublic boolean requestDeliverableMessages(Connection con)
con - The connection to send the messages troughpublic void messageAborted(java.lang.String id,
DTNHost from,
int bytesRemaining)
id - Identifier of the messagefrom - From who the message was frombytesRemaining - Nrof bytes that were left before the transfer would have been
ready; or -1 if the number of bytes is not knownpublic void createNewMessage(Message m)
m - The message to createpublic void deleteMessage(java.lang.String id,
boolean drop)
id - Identifier of the messagedrop - True if the message is deleted because of "dropping" (e.g.
buffer is full) or false if it was deleted for some other
reason (e.g. the message got delivered to final destination).
This effects the way the removing is reported to the message
listeners.public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(DTNHost otherHost)
otherHost - The other hostpublic int compareTo(DTNHost h)
compareTo in interface java.lang.Comparable<DTNHost>Comparable.compareTo(Object)public int getDangerMode()
public void setDangerMode(int dangerMode)
dangerMode - public boolean isWarned()
public void setWarned(boolean warned)
warned - booleanpublic boolean isStucked()
public void setStucked(boolean stucked)
stucked - booleanpublic boolean isAwareOfAccidentAt(MapNode from)
from - nodepublic void addAccidentAt(MapNode node)
node - Accident nodepublic java.util.Set<MapNode> getKnownAccidents()
public java.util.Map<DTNHost,util.Tuple<Coord,java.lang.Integer>> getKnownLocations()
public void updateKnownLocations(DTNHost host, Coord c, java.lang.Integer stamp)
host - hostc - coord of the hosth - freshness valuepublic void updateSelfKnownLocation()
public int getStamp()
public void setStamp(int stamp)
stamp - public boolean isRecalculatingRoute()
public void setRecalculatingRoute(boolean recalculatingRoute)
recalculatingRoute - booleanpublic java.util.List<MapNode> getNodePath()
public void setNodePath(java.util.List<MapNode> nodePath)
nodePath -