Search code examples
simulationomnet++inet

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


I have a network of 5 nodes and TCP traffic from node1 to node2 (using TCPBasicClientApp and TCPGenericSrvApp) from INET framework.

I want to have a separate node that act as a monitor for the delay between node1 and node2. How can I get the values from different nodes to compute the delay? I used

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

in socketDataArrived of TCPBasicClientApp to compute the delay but could not access the value from the monitor node.

The NED for the network is:

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++;
}

Solution

  • You can set up an input gate in Monitor. And make that TCP module perform a sendDirect carrying the value of delay in a simple cMessage. Then monitor can process the value comparing with threshold.