我在模拟脚本中使用 node.startup ={} 通过在每个节点发送 routeDiscoveryNtf 来生成静态路由。我已经包含了所有标题,但仍然无法识别 ROUTING 服务。
模拟脚本如下,所有节点的启动功能都相同
//! Simulation: 5-node network
import org.arl.fjage.*
import org.arl.fjage.Agent.*
import org.arl.fjage.RealTimePlatform
import org.arl.unet.sim.*
import org.arl.unet.sim.channels.*
import org.arl.unet.phy.*
import org.arl.unet.phy.Physical.*
import org.arl.unet.net.*
import org.arl.unet.*
import org.arl.unet.DatagramReq
import org.arl.unet.net.Router
import org.arl.unet.Services
platform = RealTimePlatform
channel.model = ProtocolChannelModel
channel.soundSpeed = 1500.mps // c
channel.communicationRange = 100.m // Rc
channel.detectionRange = 100.m // Rd
channel.interferenceRange = 100.m // Ri
channel.pDetection = 1 // pd
channel.pDecoding = 1 // pc
simulate {
def n1 = node '1', address: 1, location: [0.m, 0.m, 0.m], shell: true, stack:"$home/etc/initrc-stack"
n1.startup = {
def router = agentForService ROUTING
router.send new RouteDiscoveryNtf(to:4,nextHop:1)
router.send new RouteDiscoveryNtf(to:2,nextHop:1)
router.send new RouteDiscoveryNtf(to:3,nextHop:1)
router.send new RouteDiscoveryNtf(to:5,nextHop:1)
}
def n2 =node '2', address: 2, location: [70.m, 0.m, 0.m], shell:5102, stack: "$home/etc/initrc-stack"
n2.startup = {
def router = agentForService ROUTING
router.send new RouteDiscoveryNtf(to:4,nextHop:2)
router.send new RouteDiscoveryNtf(to:1,nextHop:2)
router.send new RouteDiscoveryNtf(to:5,nextHop:2)
router.send new RouteDiscoveryNtf(to:3,nextHop:4)
router.send new RouteDiscoveryNtf(to:3,nextHop:1)
router.send new RouteDiscoveryNtf(to:1,nextHop:5)
}
def n3 = node '3', address: 3, location: [-70.m, 0.m, 0.m], shell: 5103, stack:"$home/etc/initrc-stack"
n3.startup = {
def router = agentForService ROUTING
router.send new RouteDiscoveryNtf(to:4,nextHop:3)
router.send new RouteDiscoveryNtf(to:1,nextHop:3)
router.send new RouteDiscoveryNtf(to:5,nextHop:3)
router.send new RouteDiscoveryNtf(to:2,nextHop:4)
router.send new RouteDiscoveryNtf(to:2,nextHop:1)
router.send new RouteDiscoveryNtf(to:2,nextHop:5)
}
def n4 = node '4', address: 4, location: [0.m, 70.m, 0.m], shell: 5104, stack:"$home/etc/initrc-stack"
n4.startup = {
def router = agentForService ROUTING
router.send new RouteDiscoveryNtf(to:1,nextHop:4)
router.send new RouteDiscoveryNtf(to:2,nextHop:4)
router.send new RouteDiscoveryNtf(to:3,nextHop:4)
router.send new RouteDiscoveryNtf(to:5,nextHop:1)
router.send new RouteDiscoveryNtf(to:5,nextHop:2)
router.send new RouteDiscoveryNtf(to:5,nextHop:3)
}
def n5 = node '5', address: 5, location: [0.m, -70.m, 0.m], shell: 5105, stack:"$home/etc/initrc-stack"
n5.startup = {
def router = agentForService ROUTING
router.send new RouteDiscoveryNtf(to: 1 , nextHop:5)
router.send new RouteDiscoveryNtf(to: 3 , nextHop:5)
router.send new RouteDiscoveryNtf(to: 2 , nextHop:5)
router.send new RouteDiscoveryNtf(to: 4 , nextHop:1)
router.send new RouteDiscoveryNtf(to: 4 , nextHop:2)
router.send new RouteDiscoveryNtf(to: 4 , nextHop:3)
}
}
仿真误差如下:
SEVERE: <3> > Exception in agent: simulator
SEVERE: <4> > Exception in agent: simulator
SEVERE: <1> > Exception in agent: simulator
SEVERE: <5> > Exception in agent: simulator
SEVERE: <2> > Exception in agent: simulator
尽管每个节点上都加载了堆栈,但并未创建路由。
日志文件统计信息是:
1562654374493|SEVERE|<1>@36:run|Exception in agent: simulator
groovy.lang.MissingPropertyException: No such property: ROUTING for class: org.arl.unet.sim.SimulationAgent
Stack trace: ...
org.arl.unet.sim.SimulationAgent.propertyMissing(initrc.groovy:216) ...
org.arl.unet.sim.SimulationAgent.getProperty(initrc.groovy) ...
ping-sim2$_run_closure1$_closure2.doCall(ping-sim2.groovy:37)
ping-sim2$_run_closure1$_closure2.doCall(ping-sim2.groovy) ...
org.arl.unet.sim.SimulationAgent.this$dist$invoke$2(initrc.groovy)
org.arl.unet.sim.SimulationAgent$1.methodMissing(initrc.groovy) ...
org.arl.unet.sim.SimulationAgent$1.action(initrc.groovy:172)
org.arl.fjage.Agent.run(Agent.java:777) ...