Amount of retransmissions now configurable on a per-packet basis

This commit is contained in:
adamdunkels 2007-05-22 20:57:44 +00:00
parent c0d3b9111a
commit e18b609039
2 changed files with 21 additions and 17 deletions

View file

@ -33,7 +33,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: tree.c,v 1.11 2007/05/15 08:09:21 adamdunkels Exp $ * $Id: tree.c,v 1.12 2007/05/22 20:57:44 adamdunkels Exp $
*/ */
/** /**
@ -70,6 +70,7 @@ struct hdr {
u8_t originator_seqno; u8_t originator_seqno;
u8_t hopcount; u8_t hopcount;
u8_t hoplim; u8_t hoplim;
u8_t rexmits;
}; };
#define SINK 0 #define SINK 0
@ -80,8 +81,6 @@ struct hdr {
#define MAX_INTERVAL CLOCK_SECOND * 10 #define MAX_INTERVAL CLOCK_SECOND * 10
#define MIN_INTERVAL CLOCK_SECOND * 2 #define MIN_INTERVAL CLOCK_SECOND * 2
#define MAX_RETRANSMISSIONS 3
#define DEBUG 0 #define DEBUG 0
#if DEBUG #if DEBUG
#include <stdio.h> #include <stdio.h>
@ -230,7 +229,7 @@ node_packet_received(struct ruc_conn *c, rimeaddr_t *from, u8_t seqno)
tc->forwarding = 1; tc->forwarding = 1;
n = neighbor_best(); n = neighbor_best();
if(n != NULL) { if(n != NULL) {
ruc_send(c, &n->addr, MAX_RETRANSMISSIONS); ruc_send(c, &n->addr, hdr->rexmits);
} }
return 1; return 1;
} else { } else {
@ -299,14 +298,11 @@ tree_set_sink(struct tree_conn *tc, int should_be_sink)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
tree_send(struct tree_conn *tc) tree_send(struct tree_conn *tc, int rexmits)
{ {
struct neighbor *n; struct neighbor *n;
struct hdr *hdr; struct hdr *hdr;
if(tc->hops_from_sink == 0) {
return;
}
if(rimebuf_hdralloc(sizeof(struct hdr))) { if(rimebuf_hdralloc(sizeof(struct hdr))) {
hdr = rimebuf_hdrptr(); hdr = rimebuf_hdrptr();
@ -314,14 +310,22 @@ tree_send(struct tree_conn *tc)
rimeaddr_copy(&hdr->originator, &rimeaddr_node_addr); rimeaddr_copy(&hdr->originator, &rimeaddr_node_addr);
hdr->hopcount = tc->hops_from_sink; hdr->hopcount = tc->hops_from_sink;
hdr->hoplim = MAX_HOPLIM; hdr->hoplim = MAX_HOPLIM;
n = neighbor_best(); hdr->rexmits = rexmits;
if(n != NULL) { if(tc->hops_from_sink == 0) {
/* printf("Sending to best neighbor\n");*/ if(tc->cb->recv != NULL) {
ruc_send(&tc->ruc_conn, &n->addr, MAX_RETRANSMISSIONS); tc->cb->recv(&hdr->originator, hdr->originator_seqno,
hdr->hopcount);
}
} else { } else {
/* printf("Didn't find any neighbor\n");*/ n = neighbor_best();
PRINTF("%d.%d: did not find any neighbor to send to\n", if(n != NULL) {
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]); /* printf("Sending to best neighbor\n");*/
ruc_send(&tc->ruc_conn, &n->addr, rexmits);
} else {
/* printf("Didn't find any neighbor\n");*/
PRINTF("%d.%d: did not find any neighbor to send to\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
}
} }
} }
} }

View file

@ -47,7 +47,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: tree.h,v 1.7 2007/05/15 08:09:21 adamdunkels Exp $ * $Id: tree.h,v 1.8 2007/05/22 20:57:44 adamdunkels Exp $
*/ */
/** /**
@ -82,7 +82,7 @@ void tree_open(struct tree_conn *c, u16_t channels,
const struct tree_callbacks *callbacks); const struct tree_callbacks *callbacks);
void tree_close(struct tree_conn *c); void tree_close(struct tree_conn *c);
void tree_send(struct tree_conn *c); void tree_send(struct tree_conn *c, int rexmits);
void tree_set_sink(struct tree_conn *c, int should_be_sink); void tree_set_sink(struct tree_conn *c, int should_be_sink);