OMNeT++4.6与INET4仿真报错:FlatNetworkConfigurator类未找到求助
OMNeT++ 4.6 + INET 4仿真报错:Class "FlatNetworkConfigurator" not found
我在OMNeT++ 4.6与INET 4环境下搭建仿真实验,通过test.ned构建网络拓扑,编写test.ini配置文件,但运行时出现错误:网络初始化阶段模块Test(id=1)报错,提示Class "FlatNetworkConfigurator" not found。已尝试将FlatNetworkConfigurator替换为IPv4NetworkConfigurator,且已在项目设置中添加INET作为引用,但问题仍未解决。
相关代码
test.ned
package test1; import inet.networklayer.autorouting.ipv4.FlatNetworkConfigurator; import inet.nodes.inet.StandardHost; import inet.nodes.ethernet.EtherSwitch; import inet.nodes.inet.Router; import ned.DatarateChannel; import inet.networklayer.autorouting.ipv4.IPv4NetworkConfigurator; // // TODO auto-generated type // network Test { @display("bgb=961,379"); types: submodules: etherHost2: StandardHost { @display("p=89,249"); } etherHost1: StandardHost { @display("p=746,179"); } etherSwitch2: EtherSwitch { @display("p=341,233"); gates: ethg[3]; } etherHost3: StandardHost { @display("p=227,333"); } etherHost4: StandardHost { @display("p=398,333"); } etherSwitch3: EtherSwitch { @display("p=528,38"); gates: ethg[2]; } router: Router { @display("p=447,157"); } router1: Router { @display("p=206,153"); } configurator: FlatNetworkConfigurator { @display("p=73,87"); } connections: router.ethg++ <--> DatarateChannel { datarate = default(1000Mbps); } <--> etherSwitch3.ethg++; router1.ethg++ <--> DatarateChannel { datarate = default(100Mbps); } <--> router.ethg++; etherSwitch2.ethg[0] <--> DatarateChannel { datarate = default(100Mbps); } <--> router1.ethg++; etherSwitch2.ethg[0] <--> DatarateChannel { datarate = default(100Mbps); } <--> etherHost2.ethg++; etherSwitch3.ethg[0] <--> DatarateChannel { datarate = default(100Mbps); } <--> etherHost1.ethg++; etherSwitch2.ethg[0] <--> DatarateChannel { datarate = default(100Mbps); } <--> etherHost3.ethg++; etherSwitch2.ethg[0] <--> DatarateChannel { datarate = default(100Mbps); } <--> etherHost4.ethg++; }
test.ini
[General] network = Test #configurator *.configurator.dumpAddresses = true *.configurator.dumpTopology = true *.configurator.dumpLinks = true *.configurator.dumpRoutes = true # Routing settings *.*.ipv4.arp.typename = "GlobalArp" *.*.ipv4.routingTable.netmaskRoutes = "" *.router*.tcpType="TCP" **.etherSwitch*.relayUnitType = "MACRelayUnit" #config für Switch **.eth[*].mac.duplexMode = true **.eth.typename="EthernetInterface" *.etherHost*.tcpType = "TCP_none" *.etherHost*.udpType ="UDP" *.etherHost*.sctpType ="SCTP" **.eth[*].queueType = "DropTailQueue" # in routers **.eth[*].queue.dataQueue.frameCapacity = 10 # in routers
问题排查与解决方案
核心版本兼容性问题
INET 4.x系列要求OMNeT版本至少为5.6,OMNeT4.6与INET4完全不兼容,这是导致类找不到的根本原因。解决办法:- 升级OMNeT++到5.6.2或更高版本(推荐6.x),重新适配INET4
- 若无法升级OMNeT++,则更换为与OMNeT++4.6兼容的INET版本(如INET 2.x或3.x)
配置器类路径修正(若升级版本后)
INET4中FlatNetworkConfigurator的路径已变更,正确的导入路径应为:import inet.networklayer.configurator.ipv4.FlatNetworkConfigurator;若使用
IPv4NetworkConfigurator,同样需确认路径是否为inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator项目引用与编译检查
- 确认INET项目已正确添加为当前项目的依赖,且INET项目已完整编译
- 清理当前项目的build目录,重新编译整个项目
- 在OMNeT++ IDE中检查项目的引用顺序,确保INET项目排在自定义项目之前
内容的提问来源于stack exchange,提问作者julius0411
相关产品推荐
相关产品推荐

