Hello,
I have followed suggestions on how to do UDP broadcast in OMNET on this link http://groups.google.com/group/omnetpp/browse_thread/thread/4dc2feef3ce53f85/2435092169557472?q=broadcast&lnk=ol& . However, it still does not work even I put only 3 host one is brocast host (host[0]) and the other two (host[1], host[2]) as receivers. The below is my code, but I am not sure whether there is something wrong or not. Could you give me a hint? One more doubt is when I am runing this code, what is the value of *.host[0].udpApp[0].destAddresses I should set in .ini file? I cannot leave it either blank or "255.255.255.255". Thus, I set it to "host[1]". Consequently, host[0] only unicast UDP packet to host[1] only. Pakcets arriving to host[2] are considered as noise. Could anyone give me suggestions?
void UDPBasicApp::sendPacket()
{
cPacket *payload = createPacket();
IPvXAddress destAddr = IPAddress::ALLONES_ADDRESS;
sendToUDP(payload, localPort, destAddr, destPort);
numSent++;
}
void UDPAppBase::sendToUDP(cPacket *msg, int srcPort, const IPvXAddress& destAddr, int destPort)
{
msg->setKind(UDP_C_DATA);
UDPControlInfo *ctrl = new UDPControlInfo();
ctrl->setSrcPort(srcPort);
ctrl->setDestAddr(destAddr);
ctrl->setDestPort(destPort);
ctrl->setInterfaceId(101);
msg->setControlInfo(ctrl);
EV << "***tor*** Sending packet: ";
printPacket(msg);
send(msg, "udpOut");
}
I will really appreciate your help.
Regards,
Chakky
thankyou very much.
Include in the configuration this
**.forceBroadcast = true
In other case the IP module implements limited broadcast (it is not enough to set the address to the address broadcast, it is necessary also to include the ports that the broadcast must be emitted).
-----Mensaje original-----
De: omn...@googlegroups.com [mailto:omn...@googlegroups.com] En nombre de ferra adelinna
Enviado el: lunes, 05 de junio de 2017 8:42
Para: OMNeT++ Users <omn...@googlegroups.com>
Asunto: RE: [Omnetpp-l] UDP broadcast in OMNET
i've been using ipv4addrees allones and allmcast host but it doesnt work. server send message to ip 255.255.255.255 but the car cannt receive the broadcast message. please help me.
--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omn...@googlegroups.com.