门未连接到 omnet++ 上的兄弟或父模块

gate is not connected to sibling or parent module on omnet++

我正在尝试创建一个网络,其中 "n" 个客户端节点(由用户选择)连接到中央服务器

   simple serveur 
    {        
     gates:
     inout port[];
    }

   simple client
    {
    //  @display("i=device/pc");

     gates:
      inout port;
      }
      network networks
    {

        int nb;   
        submodules:
      n[nb]: client;
        server: serveur;

       connections :
        for i=0..nb-1 
        {   
         n[i].port <--> {  delay = 0.1ms; datarate = 100Mbps; } <--> server.port++ if uniform(0,1)<0.8;
        }

       }

但是当我尝试 运行 模拟器时出现了这个错误:

Gate 'networks.n[3].port$i' is not connected to sibling or parent module.

OMNeT++要求所有门都连通。但是,可以通过在 connections 之后添加 allowunconnected 字来关闭 all 门的连通性检查,因此在您的代码中应该是:

   connections allowunconnected:
    for i=0..nb-1 
    {   
     n[i].port <--> {  delay = 0.1ms; datarate = 100Mbps; } <--> server.port++ if uniform(0,1)<0.8;
    }