The ONE设置文件包含一系列变量,有些很有迷惑性,如hosts
是包括上界但不包括上界,即[a, b)
。本文给出The ONE变量含义及其单位。
1. 概述
# 仿真时间,单位是秒,浮点型double,43200s = 12h Scenario.endTime = 43200 # 更新间隔,单位是秒,浮点型double Scenario.updateInterval = 0.1 # 传输速度(比特率),单位是字节每秒(bytes per second), 整点型int, 250kBps=2Mbps btInterface.transmitSpeed = 250k # 传输范围range,单位是米,浮点型double btInterface.transmitRange = 10 # 到达目的节点等待时间(min, max),时间为秒,浮点型double minimum and maximum wait times (seconds) after reaching destination Group.waitTime = 0, 120 # 移动的速度(min, max),单位m/s, 浮点型double, minimum and maximum speeds (m/s) when moving on a path Group.speed = 0.5, 1.5 # 消息生存时间time-to-live,单位为分minutes,整型Integer, default=infinite Group.msgTtl = 300 # 缓冲区大小,单位为字节byte,整型Integer Group.bufferSize = 50M Events1.class = MessageEventGenerator # 消息产生间隔(min, max),单位为秒,整型int Events1.interval = 25,35 # 消息大小范围(min, max),单位为byte,整型int Events1.size = 500k,1M # range of message source/destination addresses,值得注意的是包括下界不包括上界,即[0, 126) Events1.hosts = 0,126
2. 上下界
(1)endTime
和updateInterval
Scenario.endTime = 50 Scenario.updateInterval = 1
第一次运行world.update
是在1s(值得注意的是,0s没有运行world.update
),最后一次是50s,world.update
总共被执行50次。
(2)产生消息
Scenario.endTime = 50 Events1.class = MessageEventGenerator Events1.interval = 2
第一次产生消息是在2s(值得注意的是,0s没有产生消息),最后一次产生消息是在25s,Event1
在整个仿真中共产生25个消息。另,处理事件是在updateHosts
之前。在2s时,先产生消息,运行updateHosts
时,新消息已经产生了。
3. Message和Connection的顺序
getMessageCollection
()得到节点的缓冲区,即消息的集合。消息的顺序是没法保证的,因为消息是用HashMap
存储的。
//MessageRouter.java private HashMap<String, Message> messages; public Collection<Message> getMessageCollection() { return this.messages.values(); }
然而,getConnections
取得的连接集合是有序,因为是用ArrayList
存储,顺序是按插入的顺序。更直白的说,哪条连接先与该节点建立连接,就在前面。相关源代码如下:
//ActiveRouter.java protected List<Connection> getConnections() { return getHost().getConnections(); } //DTNHost.java public List<Connection> getConnections() { List<Connection> lc = new ArrayList<Connection>(); for (NetworkInterface i : net) { lc.addAll(i.getConnections()); } return lc; } //NetworkInterface.java protected List<Connection> connections; //connected hosts public List<Connection> getConnections() { return this.connections; } //ConnectionEvent.java public void processEvent(World world) { DTNHost from = world.getNodeByAddress(this.fromAddr); DTNHost to = world.getNodeByAddress(this.toAddr); from.forceConnection(to, interfaceId, this.isUp); } //DTNHost.java 在forceConnection() if (up) { ni.createConnection(no); } else { ni.destroyConnection(no); }
待完善……
赞赏微信赞赏
支付宝赞赏
您好。(2)产生消息 中 “最后一次产生消息是在25s”。这个该怎么理解?
很抱歉,这么迟才回复。
刚才重新看了下博文,25s是笔误,50s才对。
如hosts是包括上界但不包括上界,即[a, b)。这里有错误!
谢谢指正。
Pingback: The ONE使用笔记:目录 | Spark & Shine