Skip to content

Commit

Permalink
add ThruputMeter to node definition
Browse files Browse the repository at this point in the history
  • Loading branch information
aarizaq committed May 17, 2020
1 parent 341053c commit 1255643
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/inet/common/misc/ThruputMeter.cc
Expand Up @@ -46,7 +46,9 @@ void ThruputMeter::initialize()

void ThruputMeter::handleMessage(cMessage *msg)
{
updateStats(simTime(), PK(msg)->getBitLength());
auto pkt = dynamic_cast<cPacket *>(msg);
if (pkt)
updateStats(simTime(), pkt->getBitLength());
send(msg, "out");
}

Expand Down
19 changes: 16 additions & 3 deletions src/inet/node/base/ApplicationLayerNodeBase.ned
Expand Up @@ -19,30 +19,43 @@ package inet.node.base;

import inet.applications.contract.IApp;
import inet.common.MessageDispatcher;
import inet.common.misc.ThruputMeter;

module ApplicationLayerNodeBase extends TransportLayerNodeBase
{
parameters:
int numApps = default(0);
bool hasThrugmeter = default(false);
@figure[applicationLayer](type=rectangle; pos=250,6; size=1000,130; lineColor=#808080; cornerRadius=5; fillColor=#ffff00; fillOpacity=0.1);
@figure[applicationLayer.title](type=text; pos=1245,11; anchor=ne; text="application layer");

submodules:
app[numApps]: <> like IApp {
parameters:
@display("p=375,76,row,150");
@display("p=313.425,29.925,row,150");
}
at: MessageDispatcher {
parameters:
@display("p=750,146;b=1000,5,,,,1");
}

truMeterApp[numApps*2]: ThruputMeter if numApps != 0 && hasThrugmeter {
parameters:
@display("p=406.34998,91.35");
}
connections allowunconnected:
for i=0..numApps-1 {

for i=0..numApps-1, if !hasThrugmeter {
app[i].socketOut --> at.in++;
app[i].socketIn <-- at.out++;
}

for i=0..numApps-1, if hasThrugmeter {
app[i].socketOut --> truMeterApp[2*i].in;
truMeterApp[2*i].out --> at.in++;
truMeterApp[2*i+1].in <-- at.out++;
app[i].socketIn <-- truMeterApp[2*i+1].out;
}

at.out++ --> udp.appIn if hasUdp;
at.in++ <-- udp.appOut if hasUdp;

Expand Down

0 comments on commit 1255643

Please sign in to comment.