首页 > 解决方案 > 一次模拟中的多个网络(如何配置 ini)

问题描述

我有两个网络。例如,我使用教程Tictok1Tictok2在一个.ned文件中。如何在一个模拟中运行它?最近两天我尝试在谷歌中找到解决方案。

我尝试过这样的配置:

[General]
network = Tictoc1,Tictoc2

或者

[General]
network = Tictoc1;Tictoc2

tictoc1.ned 文件:

simple Txc1
{
    gates:
        input in;
        output out;
}


simple Txc2
{
    parameters:
        @display("i=block/routing"); // add a default icon
    gates:
        input in;
        output out;
}
network Tictoc1
{
    submodules:
        tic: Txc1;
        toc: Txc1;
    connections:
        tic.out --> {  delay = 100ms; } --> toc.in;
        tic.in <-- {  delay = 100ms; } <-- toc.out;
}

network Tictoc2
{
    submodules:
        tic: Txc2 {
            parameters:
                @display("i=,cyan"); // do not change the icon (first arg of i=) just colorize it
        }
        toc: Txc2 {
            parameters:
                @display("i=,gold"); // here too
        }
    connections:
        tic.out --> {  delay = 100ms; } --> toc.in;
        tic.in <-- {  delay = 100ms; } <-- toc.out;
}

我想现在有可能做到这一点以及如何做到这一点。我当然可以:

[General]
[Config Tictoc1]
network = Tictoc1
[Config Tictoc2]
network = Tictoc2

但这将开始单独的模拟。我需要这个二合一。

标签: networkinginiomnet++

解决方案


在 OMNeT++ 中,无法同时使用多个网络。
但是,您可以将每个网络视为一个复合模块来实现您的目标。在tictoc1.ned刚刚的变化中:

  • network Tictoc1进入module Tictoc1
  • network Tictoc2进入module Tictoc2

并在末尾添加tictoc1.ned

network TicTocNet {
    submodules:
      network1: Tictoc1;
      network2: Tictoc2;
}

套装中omnetpp.ini

[General]
[Config TicTocNet]
network = TicTocNet 

推荐阅读