From 2ac91d53b573de66e6d473f0a8a74ea8ccc5e013 Mon Sep 17 00:00:00 2001 From: Vincent Brillault Date: Mon, 11 Jul 2011 14:19:14 +0200 Subject: [PATCH] Add (dangerous) feature : use layer 2 acks instead of NUD in the IPv6 layer. (Decrease packet numbers but dangerous if neighbors change their ips (not a problem in standard RPL with EUI-64 based addresses)) --- core/net/neighbor-info.c | 20 ++++++++++++++++++++ core/net/uip-ds6.c | 18 ++++++++++++++++++ core/net/uip-ds6.h | 8 ++++++++ 3 files changed, 46 insertions(+) diff --git a/core/net/neighbor-info.c b/core/net/neighbor-info.c index c36a2b8a5..f704073a1 100644 --- a/core/net/neighbor-info.c +++ b/core/net/neighbor-info.c @@ -39,6 +39,8 @@ #include "net/neighbor-info.h" #include "net/neighbor-attr.h" +#include "net/uip-ds6.h" +#include "net/uip-nd6.h" #define DEBUG DEBUG_NONE #include "net/uip-debug.h" @@ -104,6 +106,9 @@ neighbor_info_packet_sent(int status, int numtx) { const rimeaddr_t *dest; link_metric_t packet_metric; +#if UIP_DS6_LL_NUD + uip_ds6_nbr_t * nbr; +#endif /* UIP_DS6_LL_NUD */ dest = packetbuf_addr(PACKETBUF_ADDR_RECEIVER); if(rimeaddr_cmp(dest, &rimeaddr_null)) { @@ -118,6 +123,21 @@ neighbor_info_packet_sent(int status, int numtx) case MAC_TX_OK: packet_metric = numtx; add_neighbor(dest); +#if UIP_DS6_LL_NUD + nbr=uip_ds6_nbr_ll_lookup((uip_lladdr_t *) dest); + if (nbr!=NULL) { + PRINTF("neighbor-info : nbr state = %u\n",nbr->state); + } else { + PRINTF("neighbor-info : no nbr\n"); + } + if (nbr!=NULL && (nbr->state == STALE || nbr->state == DELAY || nbr->state == PROBE)) { + nbr->state = REACHABLE; + stimer_set(&nbr->reachable, UIP_ND6_REACHABLE_TIME / 1000); + PRINTF("neighbor-info : received a linklayer ack : "); + PRINTLLADDR((uip_lladdr_t *)dest); + PRINTF(" is reachable.\n"); + } +#endif /* UIP_DS6_LL_NUD */ break; case MAC_TX_COLLISION: packet_metric = numtx; diff --git a/core/net/uip-ds6.c b/core/net/uip-ds6.c index cea431612..6f11a5297 100644 --- a/core/net/uip-ds6.c +++ b/core/net/uip-ds6.c @@ -369,6 +369,24 @@ uip_ds6_nbr_lookup(uip_ipaddr_t *ipaddr) return NULL; } +/*---------------------------------------------------------------------------*/ +uip_ds6_nbr_t * +uip_ds6_nbr_ll_lookup(uip_lladdr_t *lladdr) +{ + uip_ds6_nbr_t *fin; + + for( locnbr=uip_ds6_nbr_cache, fin=locnbr + UIP_DS6_NBR_NB; + locnbrisused) { + if(!memcmp(lladdr,&locnbr->lladdr,UIP_LLADDR_LEN)) { + return locnbr; + } + } + } + return NULL; +} + /*---------------------------------------------------------------------------*/ uip_ds6_defrt_t * uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval) diff --git a/core/net/uip-ds6.h b/core/net/uip-ds6.h index 3b31d8315..dc608ef16 100644 --- a/core/net/uip-ds6.h +++ b/core/net/uip-ds6.h @@ -124,6 +124,13 @@ #endif #define UIP_DS6_AADDR_NB UIP_DS6_AADDR_NBS + UIP_DS6_AADDR_NBU +/*--------------------------------------------------*/ +/* Should we use LinkLayer acks in NUD ?*/ +#ifndef UIP_CONF_DS6_LL_NUD +#define UIP_DS6_LL_NUD 0 +#else +#define UIP_DS6_LL_NUD UIP_CONF_DS6_LL_NUD +#endif /*--------------------------------------------------*/ /** \brief Possible states for the nbr cache entries */ @@ -312,6 +319,7 @@ uip_ds6_nbr_t *uip_ds6_nbr_add(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr, uint8_t isrouter, uint8_t state); void uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr); uip_ds6_nbr_t *uip_ds6_nbr_lookup(uip_ipaddr_t *ipaddr); +uip_ds6_nbr_t *uip_ds6_nbr_ll_lookup(uip_lladdr_t *lladdr); /** @} */