OMNeT++ Simulation Source code

 OMNET++ simulation source code maintains information of how network performance metrics are calculated in this OMNET++ simulation. The performance metrics are,

  • Latency.
  • Speed.
  • Throughput.

 

Throughput:

  • Throughput is a measure of how much actual data can be sent per unit of time across a network, channel or interface.

Where, t – Throughput

s- Distance

cm – speed of light in the medium


void ThruputMeter::initialize()
{
    startTime = par("startTime");
    long _batchSize = par("batchSize");
    if ((_batchSize < 0) || (((long)(unsigned int)_batchSize) != _batchSize)) throw cRuntimeError("Invalid 'batchSize=%ld' parameter at '%s' module", _batchSize, getFullPath().c_str()); batchSize = (unsigned int)_batchSize; maxInterval = par("maxInterval"); numPackets = numBits = 0; intvlStartTime = intvlLastPkTime = 0; intvlNumPackets = intvlNumBits = 0; WATCH(numPackets); WATCH(numBits); WATCH(intvlStartTime); WATCH(intvlNumPackets); WATCH(intvlNumBits); bitpersecVector.setName("thruput (bit/sec)"); pkpersecVector.setName("packet/sec"); } void ThruputMeter::handleMessage(cMessage *msg) { updateStats(simTime(), PK(msg)->getBitLength());
    send(msg, "out");
}

void ThruputMeter::updateStats(simtime_t now, unsigned long bits)
{
    numPackets++;
    numBits += bits;

    // packet should be counted to new interval
    if (intvlNumPackets >= batchSize || now-intvlStartTime >= maxInterval)
        beginNewInterval(now);

    intvlNumPackets++;
    intvlNumBits += bits;
    intvlLastPkTime = now;
}

Speed:

  • Speed is defined as the rate at which something moves, is done or acts.

 

Formula for calculating network speed:

Where   S – Speed

D – Distance

T – Time

 channel C extends DatarateChannel
{
    delay = 0.01us; // ~ 2m
    datarate = 10Mbps;
}
module SubTest
{
    parameters:
        string cliTcpType = default("n/a");
        string srvTcpType = default("n/a");
        int k = default(3);
    submodules:
        server: StandardHost {
            parameters:
                numTcpApps = 1;
                tcpType = srvTcpType;
        }
        switch: Router {
            parameters:
        }
        client[k]: StandardHost {
            parameters:
                numTcpApps = 1;
                tcpType = cliTcpType;
                tcpApp[0].connectAddress = substringBeforeLast(fullPath(),".client[")+".server";
        }
    connections:
        server.pppg++ <--> C <--> switch.pppg++;
        for i=0..k-1 {
            client[i].pppg++ <--> C <--> switch.pppg++;
        }
}