Updated ruc to send ACKs before notifying applications, and API support for the etx-based tree code
This commit is contained in:
parent
6845d2a1aa
commit
c40dde1209
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: ruc.c,v 1.13 2007/10/23 14:00:36 nifi Exp $
|
* $Id: ruc.c,v 1.14 2007/11/13 20:58:46 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +78,7 @@ sent_by_suc(struct suc_conn *suc)
|
||||||
if(c->rxmit >= c->max_rxmit) {
|
if(c->rxmit >= c->max_rxmit) {
|
||||||
RIMESTATS_ADD(timedout);
|
RIMESTATS_ADD(timedout);
|
||||||
suc_cancel(&c->c);
|
suc_cancel(&c->c);
|
||||||
c->u->timedout(c);
|
c->u->timedout(c, suc_receiver(&c->c), c->rxmit);
|
||||||
PRINTF("%d.%d: ruc: packet %d timed out\n",
|
PRINTF("%d.%d: ruc: packet %d timed out\n",
|
||||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
||||||
c->sndnxt);
|
c->sndnxt);
|
||||||
|
@ -108,10 +108,9 @@ recv_from_suc(struct suc_conn *suc, rimeaddr_t *from)
|
||||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
||||||
hdr->seqno);
|
hdr->seqno);
|
||||||
++c->sndnxt;
|
++c->sndnxt;
|
||||||
c->rxmit = 0;
|
|
||||||
suc_cancel(&c->c);
|
suc_cancel(&c->c);
|
||||||
if(c->u->sent != NULL) {
|
if(c->u->sent != NULL) {
|
||||||
c->u->sent(c);
|
c->u->sent(c, suc_receiver(&c->c), c->rxmit);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PRINTF("%d.%d: ruc: received bad ACK %d for %d\n",
|
PRINTF("%d.%d: ruc: received bad ACK %d for %d\n",
|
||||||
|
@ -121,8 +120,9 @@ recv_from_suc(struct suc_conn *suc, rimeaddr_t *from)
|
||||||
RIMESTATS_ADD(badackrx);
|
RIMESTATS_ADD(badackrx);
|
||||||
}
|
}
|
||||||
} else if(hdr->type == TYPE_DATA) {
|
} else if(hdr->type == TYPE_DATA) {
|
||||||
int send_ack = 1;
|
/* int send_ack = 1;*/
|
||||||
u16_t packet_seqno;
|
u16_t packet_seqno;
|
||||||
|
struct queuebuf *q;
|
||||||
|
|
||||||
RIMESTATS_ADD(reliablerx);
|
RIMESTATS_ADD(reliablerx);
|
||||||
|
|
||||||
|
@ -133,27 +133,35 @@ recv_from_suc(struct suc_conn *suc, rimeaddr_t *from)
|
||||||
packet_seqno = hdr->seqno;
|
packet_seqno = hdr->seqno;
|
||||||
|
|
||||||
rimebuf_hdrreduce(sizeof(struct ruc_hdr));
|
rimebuf_hdrreduce(sizeof(struct ruc_hdr));
|
||||||
|
|
||||||
|
q = queuebuf_new_from_rimebuf();
|
||||||
|
|
||||||
|
PRINTF("%d.%d: ruc: Sending ACK to %d.%d for %d\n",
|
||||||
|
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
||||||
|
from->u8[0], from->u8[1],
|
||||||
|
packet_seqno);
|
||||||
|
rimebuf_clear();
|
||||||
|
rimebuf_hdralloc(sizeof(struct ruc_hdr));
|
||||||
|
hdr = rimebuf_hdrptr();
|
||||||
|
hdr->type = TYPE_ACK;
|
||||||
|
hdr->seqno = packet_seqno;
|
||||||
|
suc_send(&c->c, from);
|
||||||
|
RIMESTATS_ADD(acktx);
|
||||||
|
|
||||||
|
queuebuf_to_rimebuf(q);
|
||||||
|
queuebuf_free(q);
|
||||||
|
|
||||||
if(c->u->recv != NULL) {
|
if(c->u->recv != NULL) {
|
||||||
send_ack = c->u->recv(c, from, packet_seqno);
|
c->u->recv(c, from, packet_seqno);
|
||||||
|
/* send_ack = c->u->recv(c, from, packet_seqno);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if(send_ack) {
|
/* if(send_ack) {*/
|
||||||
PRINTF("%d.%d: ruc: Sending ACK to %d.%d for %d\n",
|
/* } else {
|
||||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
|
||||||
from->u8[0], from->u8[1],
|
|
||||||
packet_seqno);
|
|
||||||
rimebuf_clear();
|
|
||||||
rimebuf_hdralloc(sizeof(struct ruc_hdr));
|
|
||||||
hdr = rimebuf_hdrptr();
|
|
||||||
hdr->type = TYPE_ACK;
|
|
||||||
hdr->seqno = packet_seqno;
|
|
||||||
suc_send(&c->c, from);
|
|
||||||
RIMESTATS_ADD(acktx);
|
|
||||||
} else {
|
|
||||||
RIMESTATS_ADD(noacktx);
|
RIMESTATS_ADD(noacktx);
|
||||||
PRINTF("%d.%d: Not sending ACK\n",
|
PRINTF("%d.%d: Not sending ACK\n",
|
||||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
|
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: ruc.h,v 1.8 2007/05/22 20:56:52 adamdunkels Exp $
|
* $Id: ruc.h,v 1.9 2007/11/13 20:58:46 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,8 +47,8 @@ struct ruc_conn;
|
||||||
|
|
||||||
struct ruc_callbacks {
|
struct ruc_callbacks {
|
||||||
int (* recv)(struct ruc_conn *c, rimeaddr_t *from, u8_t seqno);
|
int (* recv)(struct ruc_conn *c, rimeaddr_t *from, u8_t seqno);
|
||||||
void (* sent)(struct ruc_conn *c);
|
void (* sent)(struct ruc_conn *c, rimeaddr_t *to, u8_t retransmissions);
|
||||||
void (* timedout)(struct ruc_conn *c);
|
void (* timedout)(struct ruc_conn *c, rimeaddr_t *to, u8_t retransmissions);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ruc_conn {
|
struct ruc_conn {
|
||||||
|
@ -65,4 +65,4 @@ void ruc_close(struct ruc_conn *c);
|
||||||
|
|
||||||
int ruc_send(struct ruc_conn *c, rimeaddr_t *receiver, u8_t max_retransmissions);
|
int ruc_send(struct ruc_conn *c, rimeaddr_t *receiver, u8_t max_retransmissions);
|
||||||
|
|
||||||
#endif /* __RRUC_H__ */
|
#endif /* __RUC_H__ */
|
||||||
|
|
Loading…
Reference in a new issue