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))
This commit is contained in:
Vincent Brillault 2011-07-11 14:19:14 +02:00
parent 6ddd0bb190
commit 2ac91d53b5
3 changed files with 46 additions and 0 deletions

View file

@ -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;

View file

@ -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;
locnbr<fin;
++locnbr) {
if(locnbr->isused) {
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)

View file

@ -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);
/** @} */