getTransmissionChannel() 正在崩溃 omnet++ 模拟

getTransmissionChannel() is crashing omnet++ simulation

我在我的简单模块中定义了这个 getTransmissionChannel()。 对于以下模拟连接,它完美地工作:

    CustomedNode1.Netport <--> LinkDefinedChannel <--> mySwitch.connectedToPort1;
    CustomedNode2.Netport <--> LinkDefinedChannel <--> mySwitch.connectedToPort2;
    CustomedNode3.Netport <--> LinkDefinedChannel <--> mySwitch.connectedToPort3;
    CustomedNode4.Netport <--> LinkDefinedChannel <--> mySwitch.connectedToPort4;
    CustomedNode5.Netport <--> LinkDefinedChannel <--> mySwitch.connectedToPort5;

然后我将 node5 替换为另一种类型的节点,但使用相同的端口,生成的新连接是:

    CustomedNode1.Netport <--> LinkDefinedChannel <--> ibSwitch.connectedToPort1;
    CustomedNode2.Netport <--> LinkDefinedChannel <--> ibSwitch.connectedToPort2;
    CustomedNode3.Netport <--> LinkDefinedChannel <--> ibSwitch.connectedToPort3;
    CustomedNode4.Netport <--> LinkDefinedChannel <--> ibSwitch.connectedToPort4;
    mySwitch.connectedToPort5 <--> gatewayNode.Netport ;

现在模拟崩溃,提示 getTransmissionChannel() 找不到传输通道。

I don't know what happened suddenly. I have just replaced with a new node with same type of net port.

getTransmissionChannel()returns传输。如果您未在链接中指定任何通道,则 OMNet++ 会透明地替换为 cIdealChannel,这基本上意味着没有通道对象已分配给连接。

在您的情况下,在节点替换新连接后 mySwitch.connectedToPort5 <--> gatewayNode.Netport ; 没有定义任何频道。所以 IDE 替换为 cIdealChannel,因此 getTransmissionChannel() 找不到任何传输通道,因为没有为此连接定义通道对象。

所以改为替换

mySwitch.connectedToPort5 <--> gatewayNode.Netport ;

mySwitch.connectedToPort5 <--> LinkDefinedChannel <--> gatewayNode.Netport ;

现在 getTransmissionChannel() 应该可以获取传输通道,因为您正在为此连接定义一个通道对象。