Improved multihop/mesh route discovery.

Packetbuffer is now saved before route discovery and resent when a
route is found.

This solves the following problems:
- First packet sent to a certain node is corrupted.
- Packet to be forwarded that triggers route discovery is lost.
This commit is contained in:
Niko Pollner 2011-08-30 13:31:26 +02:00 committed by nvt
parent 7397e86f9c
commit 84105f4e47
3 changed files with 28 additions and 16 deletions

View file

@ -94,11 +94,10 @@ data_packet_received(struct unicast_conn *uc, const rimeaddr_t *from)
} else {
nexthop = NULL;
if(c->cb->forward) {
nexthop = c->cb->forward(c, &sender, &receiver,
from, packetbuf_attr(PACKETBUF_ATTR_HOPS));
packetbuf_set_attr(PACKETBUF_ATTR_HOPS,
packetbuf_attr(PACKETBUF_ATTR_HOPS) + 1);
nexthop = c->cb->forward(c, &sender, &receiver,
from, packetbuf_attr(PACKETBUF_ATTR_HOPS) - 1);
}
if(nexthop) {
PRINTF("forwarding to %d.%d\n", nexthop->u8[0], nexthop->u8[1]);
@ -133,6 +132,9 @@ multihop_send(struct multihop_conn *c, const rimeaddr_t *to)
return 0;
}
packetbuf_compact();
packetbuf_set_addr(PACKETBUF_ADDR_ERECEIVER, to);
packetbuf_set_addr(PACKETBUF_ADDR_ESENDER, &rimeaddr_node_addr);
packetbuf_set_attr(PACKETBUF_ATTR_HOPS, 1);
nexthop = c->cb->forward(c, &rimeaddr_node_addr, to, NULL, 0);
if(nexthop == NULL) {
@ -141,12 +143,15 @@ multihop_send(struct multihop_conn *c, const rimeaddr_t *to)
} else {
PRINTF("multihop_send: sending data towards %d.%d\n",
nexthop->u8[0], nexthop->u8[1]);
packetbuf_set_addr(PACKETBUF_ADDR_ERECEIVER, to);
packetbuf_set_addr(PACKETBUF_ADDR_ESENDER, &rimeaddr_node_addr);
packetbuf_set_attr(PACKETBUF_ATTR_HOPS, 1);
unicast_send(&c->c, nexthop);
return 1;
}
}
/*---------------------------------------------------------------------------*/
void
multihop_resend(const struct multihop_conn *const c, const rimeaddr_t *const nexthop)
{
unicast_send(&c->c, nexthop);
}
/*---------------------------------------------------------------------------*/
/** @} */