In omnet ++ while programing tic toc , if there are three nodes and all are connected to one another then how to send tic toc message to a specific node. for example i want to send message first to node A and then Node B and then Node C ; how would i code this.
#include <string.h>
#include <omnetpp.h>
int x=0;
class computerf : public cSimpleModule
{
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg);virtual void forwardMessage(cMessage *msg);
};
Define_Module(computerf);
void computerf::initialize()
{
if (strcmp("computer1", getName()) == 0)
{
cMessage *msg = new cMessage("tictocMsg");
forwardMessage(msg);
}
}
void computerf::handleMessage(cMessage *msg)
{
{
forwardMessage(msg);
}
}
void computerf::forwardMessage(cMessage *msg)
{
// In this example, we just pick a random gate to send it on.
// We draw a random number between 0 and the size of gate `out[]'.
int n = gateSize("out");
int k = intuniform(0,n-1);
EV << "Forwarding message " << msg << " on port out[" << k << "]\n";
send(msg, "out", 1);
EV <<"n is "<<n;
}
here in this code forwardMessage function sends message on random gate but i want to send message on specific gate.
this is the .ned file
simple computer
{
gates:
input in[2];
output out[2];
}
//
// TODO documentation
//
network Network
{
@display("bgb=545,242");
submodules:
A: computer {
@display("p=52,86");
}
B: computer {
@display("p=311,83");
}
C: computer {
@display("p=175,189");
}
connections:
A.out[0] --> B.in[0];
B.out[0] --> A.in[0];
A.out[1] --> C.in[1];
C.out[1] --> A.in[1];
C.out[0] --> B.in[1];
B.out[1] --> C.in[0];
}
basically i want node A to send message to node C and Node A to send message to node B simultaneously if i use the hanlde message function void computer::handleMessage(cMessage *msg) {
send(msg, "out",0); //send(msg, "out",0);
} now here in out send(msg, "out",0); i want to specify which "out" i want send message to node C and then to Node B but how?