You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Omnet++中定义NED文件后网络设计未达预期效果

NED文件网络拓扑显示不符合预期

按教程编写的NED代码运行后,实际生成的网络拓扑与预期效果不符。

NED原代码

simple Txc10
{
    parameters:
        @display("i=block/routing");
    gates:
        input in[];  // declare in[] and out[] to be vector gates
        output out[];
}

network Tictock10
{
    @display("bgb=259,198");
    submodules:
        tic[6]: Txc10;
    connections:
        tic[0].out++ --> {  delay = 100ms; } --> tic[1].in++;
        tic[0].in++ <-- {  delay = 100ms; } <-- tic[1].out++;

        tic[1].out++ --> {  delay = 100ms; } --> tic[2].in++;
        tic[1].in++ <-- {  delay = 100ms; } <-- tic[2].out++;

        tic[1].out++ --> {  delay = 100ms; } --> tic[4].in++;
        tic[1].in++ <-- {  delay = 100ms; } <-- tic[4].out++;

        tic[3].out++ --> {  delay = 100ms; } --> tic[4].in++;
        tic[3].in++ <-- {  delay = 100ms; } <-- tic[4].out++;

        tic[4].out++ --> {  delay = 100ms; } --> tic[5].in++;
        tic[4].in++ <-- {  delay = 100ms; } <-- tic[5].out++;
}

拓扑对比

  • 预期拓扑图:
    预期拓扑图
  • 实际显示拓扑图:
    实际显示拓扑图

问题原因与解决方案

OMNeT++默认会自动布局子模块,导致节点位置随机混乱。要实现预期的拓扑结构,需要给每个tic子模块添加@display参数指定坐标位置。

修改后的网络模块代码如下:

network Tictock10
{
    @display("bgb=400,300"); // 调整画布大小适配节点位置
    submodules:
        tic[0]: Txc10 @display("p=50,100;");
        tic[1]: Txc10 @display("p=150,100;");
        tic[2]: Txc10 @display("p=250,50;");
        tic[3]: Txc10 @display("p=50,200;");
        tic[4]: Txc10 @display("p=150,200;");
        tic[5]: Txc10 @display("p=250,200;");
    connections:
        tic[0].out++ --> {  delay = 100ms; } --> tic[1].in++;
        tic[0].in++ <-- {  delay = 100ms; } <-- tic[1].out++;

        tic[1].out++ --> {  delay = 100ms; } --> tic[2].in++;
        tic[1].in++ <-- {  delay = 100ms; } <-- tic[2].out++;

        tic[1].out++ --> {  delay = 100ms; } --> tic[4].in++;
        tic[1].in++ <-- {  delay = 100ms; } <-- tic[4].out++;

        tic[3].out++ --> {  delay = 100ms; } --> tic[4].in++;
        tic[3].in++ <-- {  delay = 100ms; } <-- tic[4].out++;

        tic[4].out++ --> {  delay = 100ms; } --> tic[5].in++;
        tic[4].in++ <-- {  delay = 100ms; } <-- tic[5].out++;
}

通过给每个tic节点指定p=x,y的坐标,就能让拓扑布局和预期一致,同时可以调整画布大小bgb=width,height来适配整体显示。

内容的提问来源于stack exchange,提问作者Abaah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 14:02:43