[英]How can I send message from one node to multiple nodes in OMNET++?
I have a network where I want a node to broadcast a messages to 5 nodes at once.. but I can't do it because there's one output gate and one input gate only.我有一个网络,我希望一个节点一次向 5 个节点广播消息。但我不能这样做,因为只有一个 output 门和一个输入门。
secondly, I want to send multiple messages simultaneously, Like in this picture I want messages to be sent in the two subnetworks.其次,我想同时发送多条消息,就像这张图片中我希望在两个子网中发送消息。
Here's my NED file这是我的 NED 文件
package simulationnetwork;
network my_network
{
@display("bgb=757,458,#80FF00;bgi=background/terrain,s");
types:
simple Node
{
gates:
input innerport;
output outerport;
}
submodules:
node1: Node {
@display("p=30,58");
}
node2: Node {
@display("p=249,58");
}
node3: Node {
@display("p=330,165");
}
node4: Node {
@display("p=182,193");
}
node: Node {
@display("p=155,377");
}
node5: Node {
@display("p=275,291");
}
node6: Node {
@display("p=451,311");
}
connections:
node1.outerport --> node2.innerport;
node2.outerport --> node3.innerport;
node3.outerport --> node4.innerport;
node4.outerport --> node1.innerport;
node5.outerport --> node6.innerport;
node6.outerport --> node.innerport;
node.outerport --> node5.innerport;
}
and here's my CC file这是我的 CC 文件
#include <omnetpp.h>
using namespace omnetpp;
class Node: public cSimpleModule
{
protected:
void initialize() override;
void handleMessage(cMessage *msg) override;
};
Define_Module(Node);
void Node:: initialize()
{
if(strcmp("node1",getName())==0)
{
cMessage *msg = new cMessage("nodetable!,location");
send(msg,"outerport");
}
}
void Node::handleMessage(cMessage *msg)
{
send(msg,"outerport");
}
input innerport[]
input innerport[]
dup()
) and send them out on different gates using a for loop.dup()
)并使用 for 循环将它们发送到不同的门。 As you are a beginner, I highly recommend going through the Tictoc tutorial which covers exactly the topic you are interested here.由于您是初学者,我强烈建议您阅读 Tictoc 教程,该教程涵盖了您感兴趣的主题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.