1

I am trying to calculate the message delivery ratio using TraCIDemo.

In sendBeacon I am incrementing messageDeliverySend every time I send a message and in processBeacon I increment the messageDeliveryReceive parameter based on the sending node.

In processBeacon I do a string compare with node[0], but I want to check this parameter dynamically. How do I do the dynamic check part for this code?

My scenario will be if there are multiple nodes transmitting to node[1] for example I want to record values only from node[0].

void ROAMER::sendBeacon(ROAMERBeacon * beacon, double delay) {
    ROAMER_EV << "Sending beacon: address = " << beacon->getAddress()
                     << ", position = " << beacon->getPosition() << endl;
    IPv4ControlInfo * networkProtocolControlInfo = new IPv4ControlInfo();
    networkProtocolControlInfo->setProtocol(IP_PROT_MANET);
    networkProtocolControlInfo->setTimeToLive(255);
    networkProtocolControlInfo->setDestAddr(IPv4Address::LL_MANET_ROUTERS);
    networkProtocolControlInfo->setSrcAddr(getSelfAddress().get4());
    messageDeliverySend++;
    delayTime = simTime();
    UDPPacket * udpPacket = new UDPPacket(beacon->getName());
    udpPacket->encapsulate(beacon);
    udpPacket->setSourcePort(ROAMER_UDP_PORT);
    udpPacket->setDestinationPort(ROAMER_UDP_PORT);
    udpPacket->setControlInfo(networkProtocolControlInfo);
    sendUDPPacket(udpPacket, delay);
}

void ROAMER::processBeacon(ROAMERBeacon * beacon) {
if(strcmp(beacon->getSenderAddress(),"node[0]") == 0){
        messageDeliveryReceive++;
    }
}

void ROAMER::finish(){
    messageDeliveryRatio = messageDeliveryReceive/messageDeliverySend;
    recordScalar("Message Delivery Ratio",messageDeliveryVecRatio);
}
code11
  • 1,986
  • 5
  • 29
  • 37
Sanjeeth
  • 11
  • 2
  • I think a good way to solve this is to define a source parameter for your node, and then put the associated source in your `omnetpp.ini` file (e.g., `node[*].source = 'node[0]' if you want all nodes to record from that source). I'm not sure how that would extend to multiple receivers, though, assuming you ever want to increment the same value for more than one receiver. – Rens van der Heijden Nov 15 '16 at 16:58
  • Thank you Rens van der Heijden. I am wanting to calculate the message delivery ratio with respect to every transmitting and receiving node without considering the broadcast messages. For eg, if I have 20 nodes, node 0 is the sender and node 1 is the receiver, node 0 would broadcast to every node. I would want to calculate only the messages received by node 1 against the messages sent by node 0 only. All the other broadcast messages should not be part of my end result. Similarly for every other node. The end result will be a scalar with total received/total sent. Hope I am not confusing you. – Sanjeeth Nov 15 '16 at 19:12
  • 2
    in that case you can typically just include a check for the local node ID at the if statement in your `processBeacon`, i.e., if the receiver is 1, then increment if the sender is 0. – Rens van der Heijden Nov 16 '16 at 12:42

0 Answers0