The ONE使用笔记:DTNHost、MessageRouter、Message间的关系

本文以UML类图方式给出The ONE中DTNHostMessageRouterMessage间的关系,并以示意图的形式给出incomingMessage, messages, deliverredMessages间的联系,即消息在The ONE的流动。

1. UML类图



2. Message与MessageRouter


private HashMap<String, Message> messages;            //The messages this router is carrying
private HashMap<String, Message> incomingMessages;    //The messages being transferred with msgID_hostName keys
private HashMap<String, Message> deliveredMessages;   //The messages this router has received as the final recipient

private HashMap<String, Object> blacklistedMessages;  //The messages that Applications on this router have blacklisted


/*** 标识消息 ***/
private String id;                    //Identifier of the message
private int uniqueId;                 //Unique ID of this message
private int size;                     //Size of the message (bytes)
private static int nextUniqueId;      //Next unique identifier to be given

/*** 记录消息传输路径 ***/
private DTNHost from;
private DTNHost to;
private List<DTNHost> path;           //List of nodes this message has passed

/*** Time to live ***/
private double timeReceived;          //The time this message was received
private double timeCreated;           //The time when this message was created
private int initTtl;                  //Initial TTL of the message
public static final String TTL_SECONDS_S = "Scenario.ttlSeconds";
private static boolean ttlAsSeconds = false;          //ture for seconds, false for minutes
public static final int INFINITE_TTL = -1;            //Value for infinite TTL of message

/*** response message ***/
private int responseSize;              //0 if no response is requested
private Message requestMsg;            //if this message is a response message, this is set to the request msg

/** Container for generic message properties. Note that all values
 * stored in the properties should be immutable because only a shallow
 * copy of the properties is made when replicating messages */
private Map<String, Object> properties;

private String    appID;              //Application ID of the application that created the message

3. 消息缓冲区

The ONE消息的转换如下图所示。新创建的消息放在messages,正在传输的消息放在incomingMessages;传输成功的消息若为目的节点则放在deliverredMessages,否则放在messages



电子邮件地址不会被公开。 必填项已用*标注