| Modifier and Type | Field and Description |
|---|---|
static int |
INFINITE_TTL
Value for infinite TTL of message
|
static java.lang.String |
TTL_SECONDS_S
Time-to-live (TTL) as seconds -setting id ("Scenario.ttlSeconds").
|
| Constructor and Description |
|---|
Message(DTNHost from,
DTNHost to,
java.lang.String id,
int size)
Creates a new Message.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNodeOnPath(DTNHost node)
Adds a new node on the list of nodes this message has passed
|
void |
addProperty(java.lang.String key,
java.lang.Object value)
Adds a generic property for this message.
|
int |
compareTo(Message m)
Compares two messages by their ID (alphabetically).
|
protected void |
copyFrom(Message m)
Deep copies message data from other message.
|
java.lang.String |
getAppID() |
double |
getCreationTime()
Returns the time when this message was created
|
DTNHost |
getFrom()
Returns the node this message is originally from
|
int |
getHopCount()
Returns the amount of hops this message has passed
|
java.util.List<DTNHost> |
getHops()
Returns a list of nodes this message has passed so far
|
java.lang.String |
getId()
Returns the ID of the message
|
java.lang.Object |
getProperty(java.lang.String key)
Returns an object that was stored to this message using the given
key.
|
double |
getReceiveTime()
Returns the time when this message was received
|
Message |
getRequest()
Returns the message this message is response to or null if this is not
a response message
|
int |
getResponseSize()
Returns the size of the requested response message or 0 if no response
is requested.
|
int |
getSize()
Returns the size of the message (in bytes)
|
DTNHost |
getTo()
Returns the node this message is originally to
|
int |
getTtl()
Returns the time to live (in minutes or seconds, depending on the setting
TTL_SECONDS_S) of the message or Integer.MAX_VALUE
if the TTL is infinite. |
int |
getUniqueId()
Returns an ID that is unique per message instance
(different for replicates too)
|
boolean |
isResponse()
Returns true if this message is a response message
|
Message |
replicate()
Returns a replicate of this message (identical except for the unique id)
|
static void |
reset()
Resets all static fields to default values
|
void |
setAppID(java.lang.String appID) |
void |
setReceiveTime(double time)
Sets the time when this message was received.
|
void |
setRequest(Message request)
If this message is a response to a request, sets the request message
|
void |
setResponseSize(int size)
Sets the requested response message's size.
|
void |
setTtl(int ttl)
Sets the initial TTL (time-to-live) for this message.
|
java.lang.String |
toString()
Returns a string representation of the message
|
void |
updateProperty(java.lang.String key,
java.lang.Object value)
Updates a value for an existing property.
|
public static final java.lang.String TTL_SECONDS_S
public static final int INFINITE_TTL
public Message(DTNHost from, DTNHost to, java.lang.String id, int size)
from - Who the message is (originally) fromto - Who the message is (originally) toid - Message identifier (must be unique for message but
will be the same for all replicates of the message)size - Size of the message (in bytes)public DTNHost getFrom()
public DTNHost getTo()
public java.lang.String getId()
public int getUniqueId()
public int getSize()
public void addNodeOnPath(DTNHost node)
node - The node to addpublic java.util.List<DTNHost> getHops()
public int getHopCount()
public int getTtl()
TTL_SECONDS_S) of the message or Integer.MAX_VALUE
if the TTL is infinite. Returned value can be negative if the TTL has
passed already.public void setTtl(int ttl)
ttl - The time-to-live to setpublic void setReceiveTime(double time)
time - The time to setpublic double getReceiveTime()
public double getCreationTime()
public void setRequest(Message request)
request - The request messagepublic Message getRequest()
public boolean isResponse()
public void setResponseSize(int size)
size - Size of the response messagepublic int getResponseSize()
public java.lang.String toString()
toString in class java.lang.Objectprotected void copyFrom(Message m)
m - The message where the data is copiedpublic void addProperty(java.lang.String key,
java.lang.Object value)
throws SimError
key - The key which is used to lookup the valuevalue - The value to storeSimError - if the message already has a value for the given keypublic java.lang.Object getProperty(java.lang.String key)
key - The key used to lookup the objectpublic void updateProperty(java.lang.String key,
java.lang.Object value)
throws SimError
addProperty(String, Object) should be used which
checks for name space clashes.key - The key which is used to lookup the valuevalue - The new value to storeSimErrorpublic Message replicate()
public int compareTo(Message m)
compareTo in interface java.lang.Comparable<Message>String.compareTo(String)public static void reset()
public java.lang.String getAppID()
public void setAppID(java.lang.String appID)
appID - the appID to set