Skip to content

Commit

Permalink
AODV: Disruption detection (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniele Lacamera committed Feb 20, 2015
1 parent 7748280 commit de73846
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
36 changes: 36 additions & 0 deletions modules/pico_aodv.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,33 @@ static int aodv_send_req(struct pico_aodv_node *node)
return n;
}

static void pico_aodv_expired(struct pico_aodv_node *node)
{
node->flags |= PICO_AODV_NODE_UNREACH;
node->flags &= (~PICO_AODV_NODE_ROUTE_UP);
node->flags &= (~PICO_AODV_NODE_ROUTE_DOWN);
pico_ipv4_route_del(node->dest.ip4, HOST_NETMASK, node->metric);
node->ring_ttl = 0;
/* TODO: send err */

}

static void pico_aodv_collector(pico_time now, void *arg)
{
struct pico_tree_node *index;
struct pico_aodv_node *node;
(void)arg;
pico_tree_foreach(index, &aodv_nodes){
node = index->keyValue;
if (PICO_AODV_ACTIVE(node)) {
uint32_t lifetime = aodv_lifetime(node);
if (lifetime == 0)
pico_aodv_expired(node);
}
}
pico_timer_add(AODV_HELLO_INTERVAL, pico_aodv_collector, NULL);
}

int pico_aodv_init(void)
{
struct pico_ip4 any = { .addr = 0u};
Expand All @@ -549,6 +576,7 @@ int pico_aodv_init(void)
return -1;
}
pico_aodv_local_id = pico_rand();
pico_timer_add(AODV_HELLO_INTERVAL, pico_aodv_collector, NULL);
return 0;
}

Expand All @@ -558,6 +586,14 @@ int pico_aodv_add(struct pico_device *dev)
return (pico_tree_insert(&aodv_devices, dev))?(0):(-1);
}

void pico_aodv_refresh(const union pico_address *addr)
{
struct pico_aodv_node *node = get_node_by_addr(addr);
if (node) {
node->last_seen = PICO_TIME_MS();
}
}

int pico_aodv_lookup(const union pico_address *addr)
{
struct pico_aodv_node *node = get_node_by_addr(addr);
Expand Down
5 changes: 3 additions & 2 deletions modules/pico_aodv.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
#define PICO_AODV_PORT (654)

/* RFC3561 $10 */
#define AODV_ACTIVE_ROUTE_TIMEOUT (5000u) /* Conservative value for link breakage detection */
#define AODV_ACTIVE_ROUTE_TIMEOUT (8000u) /* Conservative value for link breakage detection */
#define AODV_DELETE_PERIOD (5 * AODV_ACTIVE_ROUTE_TIMEOUT) /* Recommended value K = 5 */
#define AODV_ALLOWED_HELLO_LOSS (4) /* conservative */
#define AODV_NET_DIAMETER ((uint8_t)(35))
#define AODV_RREQ_RETRIES (2)
#define AODV_NODE_TRAVERSAL_TIME (40)
#define AODV_HELLO_INTERVAL (1)
#define AODV_HELLO_INTERVAL (1000)
#define AODV_LOCAL_ADD_TTL 2
#define AODV_RREQ_RATELIMIT (10)
#define AODV_TIMEOUT_BUFFER (2)
Expand Down Expand Up @@ -127,4 +127,5 @@ PACKED_STRUCT_DEF pico_aodv_rack
int pico_aodv_init(void);
int pico_aodv_add(struct pico_device *dev);
int pico_aodv_lookup(const union pico_address *addr);
void pico_aodv_refresh(const union pico_address *addr);
#endif
6 changes: 6 additions & 0 deletions modules/pico_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ int pico_ipv4_is_valid_src(uint32_t address, struct pico_device *dev)
return 0;
}
else {
#ifdef PICO_SUPPORT_AODV
union pico_address src;
src.ip4.addr = address;
pico_aodv_refresh(&src);
#endif
return 1;
}
}
Expand Down Expand Up @@ -697,6 +702,7 @@ static int pico_ipv4_process_in(struct pico_protocol *self, struct pico_frame *f

#endif


/* ret == 1 indicates to continue the function */
ret = pico_ipv4_crc_check(f);
if (ret < 1)
Expand Down

0 comments on commit de73846

Please sign in to comment.