Merge pull request #4770 from Yonezawa-T2/rbuf_usec
rbuf: change arrival time unit from seconds to microseconds
This commit is contained in:
commit
0a65d8c558
@ -240,7 +240,7 @@ static bool _rbuf_update_ints(rbuf_t *entry, uint16_t offset, size_t frag_size)
|
|||||||
static void _rbuf_gc(void)
|
static void _rbuf_gc(void)
|
||||||
{
|
{
|
||||||
rbuf_t *oldest = NULL;
|
rbuf_t *oldest = NULL;
|
||||||
uint32_t now_sec = xtimer_now() / SEC_IN_USEC;
|
uint32_t now_usec = xtimer_now();
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < RBUF_SIZE; i++) {
|
for (i = 0; i < RBUF_SIZE; i++) {
|
||||||
@ -248,7 +248,7 @@ static void _rbuf_gc(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ((rbuf[i].pkt != NULL) &&
|
else if ((rbuf[i].pkt != NULL) &&
|
||||||
((now_sec - rbuf[i].arrival) > RBUF_TIMEOUT)) {
|
((now_usec - rbuf[i].arrival) > RBUF_TIMEOUT)) {
|
||||||
DEBUG("6lo rfrag: entry (%s, ", gnrc_netif_addr_to_str(l2addr_str,
|
DEBUG("6lo rfrag: entry (%s, ", gnrc_netif_addr_to_str(l2addr_str,
|
||||||
sizeof(l2addr_str), rbuf[i].src, rbuf[i].src_len));
|
sizeof(l2addr_str), rbuf[i].src, rbuf[i].src_len));
|
||||||
DEBUG("%s, %u, %u) timed out\n",
|
DEBUG("%s, %u, %u) timed out\n",
|
||||||
@ -259,7 +259,7 @@ static void _rbuf_gc(void)
|
|||||||
gnrc_pktbuf_release(rbuf[i].pkt);
|
gnrc_pktbuf_release(rbuf[i].pkt);
|
||||||
_rbuf_rem(&(rbuf[i]));
|
_rbuf_rem(&(rbuf[i]));
|
||||||
}
|
}
|
||||||
else if ((oldest == NULL) || (rbuf[i].arrival < oldest->arrival)) {
|
else if ((oldest == NULL) || ((oldest->arrival - rbuf[i].arrival) < (UINT32_MAX / 2))) {
|
||||||
oldest = &(rbuf[i]);
|
oldest = &(rbuf[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,7 +276,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
|
|||||||
size_t size, uint16_t tag)
|
size_t size, uint16_t tag)
|
||||||
{
|
{
|
||||||
rbuf_t *res = NULL;
|
rbuf_t *res = NULL;
|
||||||
uint32_t now_sec = xtimer_now() / SEC_IN_USEC;
|
uint32_t now_usec = xtimer_now();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < RBUF_SIZE; i++) {
|
for (unsigned int i = 0; i < RBUF_SIZE; i++) {
|
||||||
/* check first if entry already available */
|
/* check first if entry already available */
|
||||||
@ -292,7 +292,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
|
|||||||
gnrc_netif_addr_to_str(l2addr_str, sizeof(l2addr_str),
|
gnrc_netif_addr_to_str(l2addr_str, sizeof(l2addr_str),
|
||||||
rbuf[i].dst, rbuf[i].dst_len),
|
rbuf[i].dst, rbuf[i].dst_len),
|
||||||
(unsigned)rbuf[i].pkt->size, rbuf[i].tag);
|
(unsigned)rbuf[i].pkt->size, rbuf[i].tag);
|
||||||
rbuf[i].arrival = now_sec;
|
rbuf[i].arrival = now_usec;
|
||||||
return &(rbuf[i]);
|
return &(rbuf[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
|
|||||||
|
|
||||||
*((uint64_t *)res->pkt->data) = 0; /* clean first few bytes for later
|
*((uint64_t *)res->pkt->data) = 0; /* clean first few bytes for later
|
||||||
* look-ups */
|
* look-ups */
|
||||||
res->arrival = now_sec;
|
res->arrival = now_usec;
|
||||||
memcpy(res->src, src, src_len);
|
memcpy(res->src, src, src_len);
|
||||||
memcpy(res->dst, dst, dst_len);
|
memcpy(res->dst, dst, dst_len);
|
||||||
res->src_len = src_len;
|
res->src_len = src_len;
|
||||||
|
|||||||
@ -32,7 +32,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define RBUF_L2ADDR_MAX_LEN (8U) /**< maximum length for link-layer addresses */
|
#define RBUF_L2ADDR_MAX_LEN (8U) /**< maximum length for link-layer addresses */
|
||||||
#define RBUF_SIZE (4U) /**< size of the reassembly buffer */
|
#define RBUF_SIZE (4U) /**< size of the reassembly buffer */
|
||||||
#define RBUF_TIMEOUT (3U) /**< timeout for reassembly in seconds */
|
#define RBUF_TIMEOUT (3U * SEC_IN_USEC) /**< timeout for reassembly in microseconds */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fragment intervals to identify limits of fragments.
|
* @brief Fragment intervals to identify limits of fragments.
|
||||||
@ -73,8 +73,8 @@ typedef struct rbuf_int {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
rbuf_int_t *ints; /**< intervals of the fragment */
|
rbuf_int_t *ints; /**< intervals of the fragment */
|
||||||
gnrc_pktsnip_t *pkt; /**< the reassembled packet in packet buffer */
|
gnrc_pktsnip_t *pkt; /**< the reassembled packet in packet buffer */
|
||||||
uint32_t arrival; /**< time in seconds of arrival of last
|
uint32_t arrival; /**< time in microseconds of arrival of
|
||||||
* received fragment */
|
* last received fragment */
|
||||||
uint8_t src[RBUF_L2ADDR_MAX_LEN]; /**< source address */
|
uint8_t src[RBUF_L2ADDR_MAX_LEN]; /**< source address */
|
||||||
uint8_t dst[RBUF_L2ADDR_MAX_LEN]; /**< destination address */
|
uint8_t dst[RBUF_L2ADDR_MAX_LEN]; /**< destination address */
|
||||||
uint8_t src_len; /**< length of source address */
|
uint8_t src_len; /**< length of source address */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user