From 3788b08780975c2bd5a02a14ed437efd33695f34 Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Fri, 22 Nov 2013 15:10:44 +0100 Subject: [PATCH 1/2] Added a way to get the RSSI of the last received packet --- core/net/sicslowpan.c | 11 +++++++++++ core/net/sicslowpan.h | 1 + 2 files changed, 12 insertions(+) diff --git a/core/net/sicslowpan.c b/core/net/sicslowpan.c index 9fbc9baaa..7e0200418 100644 --- a/core/net/sicslowpan.c +++ b/core/net/sicslowpan.c @@ -257,6 +257,8 @@ static struct timer reass_timer; #define sicslowpan_len uip_len #endif /* SICSLOWPAN_CONF_FRAG */ +static int last_rssi; + /*-------------------------------------------------------------------------*/ /* Rime Sniffer support for one single listener to enable powertrace of IP */ /*-------------------------------------------------------------------------*/ @@ -1604,6 +1606,9 @@ input(void) /* The MAC puts the 15.4 payload inside the RIME data buffer */ rime_ptr = packetbuf_dataptr(); + /* Save the RSSI of the incoming packet in case the upper layer will + want to query us for it later. */ + last_rssi = (signed short)packetbuf_attr(PACKETBUF_ATTR_RSSI); #if SICSLOWPAN_CONF_FRAG /* if reassembly timed out, cancel it */ if(timer_expired(&reass_timer)) { @@ -1900,6 +1905,12 @@ sicslowpan_init(void) #endif /* SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_HC06 */ } /*--------------------------------------------------------------------*/ +int +sicslowpan_get_last_rssi(void) +{ + return last_rssi; +} +/*--------------------------------------------------------------------*/ const struct network_driver sicslowpan_driver = { "sicslowpan", sicslowpan_init, diff --git a/core/net/sicslowpan.h b/core/net/sicslowpan.h index f4a3bc562..4f12e9fe4 100644 --- a/core/net/sicslowpan.h +++ b/core/net/sicslowpan.h @@ -317,6 +317,7 @@ struct sicslowpan_nh_compressor { }; +int sicslowpan_get_last_rssi(void); extern const struct network_driver sicslowpan_driver; From b31e84649a3139f546f9b5148d886d3a07a63d7e Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Fri, 22 Nov 2013 15:12:02 +0100 Subject: [PATCH 2/2] If the 6lowpan layer is currently reassembling a packet, and a non-fragmented packet comes along, this is a sign that one of the fragments were lost (as they normally would arrive back-to-back, in sequence). So we'll grab the non-fragmented packet instead of dropping it. --- core/net/sicslowpan.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/net/sicslowpan.c b/core/net/sicslowpan.c index 7e0200418..844064cae 100644 --- a/core/net/sicslowpan.c +++ b/core/net/sicslowpan.c @@ -1671,7 +1671,12 @@ input(void) */ #define PRIORITIZE_NEW_PACKETS 1 #if PRIORITIZE_NEW_PACKETS - if(processed_ip_in_len > 0 && first_fragment + + if(!is_fragment) { + /* Prioritize non-fragment packets too. */ + sicslowpan_len = 0; + processed_ip_in_len = 0; + } else if(processed_ip_in_len > 0 && first_fragment && !rimeaddr_cmp(&frag_sender, packetbuf_addr(PACKETBUF_ADDR_SENDER))) { sicslowpan_len = 0; processed_ip_in_len = 0;