Hello,
I implemented a function to forward data packets in my routing protocol
and I noticed
that the data packet is forwarded from a node to another and when it arrives
to the destination node, the destination address changes automatically
to the source address, so every packet, goes to the destination node, and after
that it returns to the source, but I want that the procedure will
finish when it just arrives to the destination.
the code is below:
void
Protocol::forward_data(Packet* p) {
struct hdr_cmn* ch = HDR_CMN(p);
struct hdr_ip* ih = HDR_IP(p);
if (ih->daddr() == ra_addr()) {
tcl.evalf("puts \" (forward_data)data packet arrived to destination\"");
dmux_->recv(p, 0);
return;
}
else
{ch->direction() = hdr_cmn::DOWN;
ch->addr_type() = NS_AF_INET;
if ((u_int32_t)ih->daddr() == IP_BROADCAST)
ch->next_hop() = IP_BROADCAST;
else {
nsaddr_t next_hop = rtable_.lookup(ih->daddr());
ch->next_hop() = next_hop;
}
Scheduler::instance().schedule(target_, p, 0.0);
}
Any suggestions please?
Thank you.