OMNeT++:如何从不同模块访问 TCP 应用程序的值?

OMNeT++: how to access values of TCP app from different module?

我有一个包含 5 个节点的网络和来自 INET 框架的从节点 1 到节点 2 的 TCP 流量(使用 TCPBasicClientAppTCPGenericSrvApp)。

我想要一个单独的节点作为节点 1 和节点 2 之间延迟的监视器。如何从不同节点获取值来计算延迟? 我用了

simtime_t delay = simTime() - msg->getCreationTime();
EV << "Message delay: " <<delay<<endl;

TCPBasicClientAppsocketDataArrived 中计算延迟但无法从监视器节点访问值。

网络的 NED 是:

package myNetwork;

import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator;
import inet.node.inet.StandardHost;
import inet.node.ethernet.EtherSwitch;
import inet.node.ethernet.Eth10M;

network myNetwork
{
    parameters:
        @display("bgb=970,411");
    submodules:

        monitor: DelMonitor {

            @display("p=98.6175,348.20502");
        }

        configurator: IPv4NetworkConfigurator {

            @display("p=15,150");
        }
        node1: StandardHost {
            @display("p=33,286");
        }
        node2: StandardHost {

            @display("p=181,293");
        }
        node3: StandardHost {

            @display("p=296,301");
        }
        node4: StandardHost {

            @display("p=449,301");
        }
        node5: StandardHost {

            @display("p=673.2775,277.59");
        }

        switch1: EtherSwitch {
            @display("p=119.315,119.315");
        }

        switch2: EtherSwitch {
            @display("p=239.8475,119.315");
        }
        switch3: EtherSwitch {
            @display("p=393.2525,119.315");
        }
        switch4: EtherSwitch {
            @display("p=551.5275,119.315");
        }
        switch5: EtherSwitch {

            @display("p=720.76,119.315");
        }
    connections:

        switch1.ethg++ <--> Eth10M <--> node1.ethg++;
        switch2.ethg++ <--> Eth10M <--> node2.ethg++;
        switch3.ethg++ <--> Eth10M <--> node3.ethg++;
        switch4.ethg++ <--> Eth10M <--> node4.ethg++;
        switch5.ethg++ <--> Eth10M <--> node5.ethg++;

        switch1.ethg++ <--> Eth10M <--> switch2.ethg++;
        switch2.ethg++ <--> Eth10M <--> switch3.ethg++;
        switch3.ethg++ <--> Eth10M <--> switch4.ethg++;
        switch4.ethg++ <--> Eth10M <--> switch5.ethg++;

        monitor.gate <--> Eth10M <--> node1.ethg++;
}

您可以在监视器中设置输入门控。 并使该 TCP 模块在简单的 cMessage 中执行携带延迟值的 sendDirect。然后监视器可以处理与阈值比较的值。