I want to send a broadcast message to neighbours.... I'm having a problem
because the nodes are not receiving the message if I put ih->daddr() =
IP_BROADCAST;
I have tested it by putting ih->daddr() = 1; and it worked... ie. node 1 was
able to receive the message.. Below is my code for sending and also for
receiving
void ReQuest::sendREQUEST()
{
Packet* p = Packet::alloc();
struct hdr_cmn* ch = HDR_CMN(p);
struct hdr_ip* ih = HDR_IP(p);
struct hdr_MyPacket* ah = HDR_MyPacket(p);
ch->size() = IP_HDR_LEN + ah->size();
ch->addr_type() = NS_AF_NONE;
ih->daddr() = IP_BROADCAST;
ih->saddr() = index;
ah->MyPacket_type = ReQ;
Scheduler::instance().schedule(target_, p, 0.0);
}
My receive function is as follows:
void ReQuest::recv(Packet* p, Handler*)
{
struct hdr_cmn* ch = HDR_CMN(p);
struct hdr_ip* ih = HDR_IP(p);
struct hdr_MyPacket* ah = HDR_MyPacket(p);
nsaddr_t src = ih->saddr();
printf("Node %d receiving data packet from %d \n", index, src);
// processing packet
}
like i said, nodes can only receive messages if i put the IP address of the
receipient but when i use IP_BROADCAST, nothing is received...
Thank you in advance