我正在仿真脚本中使用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) ...
答案 0 :(得分:0)
我相信ROUTING
服务的规范名称是org.arl.unet.ROUTING
。因此,您可能必须使用该字符串,而不仅仅是ROUTING
def router = agentForService org.arl.unet.ROUTING