Commit 78b7a7a9a8634a78d5cd60dcfcb8f54c253dfd10

Authored by vrobic
1 parent 0c314053

affectation rang selon rssi et lqi

RIOT/examples/dynamic_app/Makefile
1 # name of your application 1 # name of your application
2 -APPLICATION = real_time_app 2 +APPLICATION = dynamic_app
3 3
4 # If no BOARD is found in the environment, use this default: 4 # If no BOARD is found in the environment, use this default:
5 BOARD ?= native 5 BOARD ?= native
RIOT/sys/include/net/gnrc/rpl/structs.h
@@ -74,7 +74,14 @@ extern "C" { @@ -74,7 +74,14 @@ extern "C" {
74 * RFC6550, section 6.7.1, RPL Control Message Option Generic Format 74 * RFC6550, section 6.7.1, RPL Control Message Option Generic Format
75 * </a> 75 * </a>
76 */ 76 */
77 - 77 +/*******************************************************************/
  78 +//ADDED BY PFE7 2017
  79 +typedef struct __attribute__((packed)) {
  80 + uint8_t rssi; /*Received Signal Strength Indication*/
  81 + uint8_t lqi; /*Link Quality Indicator*/
  82 +} rpl_metric_container;
  83 +//\ADDED BY PFE7 2017
  84 +/*******************************************************************/
78 85
79 86
80 typedef struct __attribute__((packed)) { 87 typedef struct __attribute__((packed)) {
@@ -97,6 +104,11 @@ typedef struct __attribute__((packed)) { @@ -97,6 +104,11 @@ typedef struct __attribute__((packed)) {
97 uint8_t flags; /**< unused */ 104 uint8_t flags; /**< unused */
98 uint8_t reserved; /**< reserved */ 105 uint8_t reserved; /**< reserved */
99 ipv6_addr_t dodag_id; /**< id of the dodag */ 106 ipv6_addr_t dodag_id; /**< id of the dodag */
  107 + /*******************************************************************/
  108 + //ADDED BY PFE7 2017
  109 + rpl_metric_container mc;
  110 + //\ADDED BY PFE7 2017
  111 + /*******************************************************************/
100 } gnrc_rpl_dio_t; 112 } gnrc_rpl_dio_t;
101 113
102 /** 114 /**
@@ -218,8 +230,13 @@ struct gnrc_rpl_parent { @@ -218,8 +230,13 @@ struct gnrc_rpl_parent {
218 uint16_t rank; /**< rank of the parent */ 230 uint16_t rank; /**< rank of the parent */
219 gnrc_rpl_dodag_t *dodag; /**< DODAG the parent belongs to */ 231 gnrc_rpl_dodag_t *dodag; /**< DODAG the parent belongs to */
220 uint32_t lifetime; /**< lifetime of this parent in seconds */ 232 uint32_t lifetime; /**< lifetime of this parent in seconds */
221 - double link_metric; /**< metric of the link */  
222 - uint8_t link_metric_type; /**< type of the metric */ 233 + /*******************************************************************/
  234 + //ADDED BY PFE7 2017
  235 + rpl_metric_container mc;
  236 + //double link_metric; /**< metric of the link */
  237 + //uint8_t link_metric_type; /**< type of the metric */
  238 + //\ADDED BY PFE7 2017
  239 + /*******************************************************************/
223 }; 240 };
224 241
225 /** 242 /**
@@ -278,7 +295,11 @@ struct gnrc_rpl_instance { @@ -278,7 +295,11 @@ struct gnrc_rpl_instance {
278 uint16_t max_rank_inc; /**< max increase in the rank */ 295 uint16_t max_rank_inc; /**< max increase in the rank */
279 int8_t cleanup; /**< cleanup time in seconds */ 296 int8_t cleanup; /**< cleanup time in seconds */
280 }; 297 };
281 - 298 +/*******************************************************************/
  299 +//ADDED BY PFE7 2017
  300 +static uint8_t dodag_insert;
  301 +//\ADDED BY PFE7 2017
  302 +/*******************************************************************/
282 #ifdef __cplusplus 303 #ifdef __cplusplus
283 } 304 }
284 #endif 305 #endif
RIOT/sys/net/gnrc/routing/rpl/gnrc_rpl.c
@@ -25,7 +25,13 @@ @@ -25,7 +25,13 @@
25 #include "net/gnrc/rpl/p2p.h" 25 #include "net/gnrc/rpl/p2p.h"
26 #include "net/gnrc/rpl/p2p_dodag.h" 26 #include "net/gnrc/rpl/p2p_dodag.h"
27 #endif 27 #endif
  28 +/*******************************************************************/
  29 +//ADDED BY PFE7 2017
  30 +//#include "../../boards/stm32f4discovery/include/board.h"
  31 +//#include "../../boards/stm32f4discovery/include/periph_conf.h"
28 32
  33 +//\ADDED BY PFE7 2017
  34 +/*******************************************************************/
29 #define ENABLE_DEBUG (0) 35 #define ENABLE_DEBUG (0)
30 #include "debug.h" 36 #include "debug.h"
31 37
@@ -103,7 +109,7 @@ gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_ @@ -103,7 +109,7 @@ gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_
103 } 109 }
104 110
105 dodag = &inst->dodag; 111 dodag = &inst->dodag;
106 - 112 +
107 dodag->dtsn = 1; 113 dodag->dtsn = 1;
108 dodag->prf = 0; 114 dodag->prf = 0;
109 dodag->dio_interval_doubl = GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS; 115 dodag->dio_interval_doubl = GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS;
@@ -119,7 +125,6 @@ gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_ @@ -119,7 +125,6 @@ gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_
119 #ifndef GNRC_RPL_WITHOUT_PIO 125 #ifndef GNRC_RPL_WITHOUT_PIO
120 dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO; 126 dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO;
121 #endif 127 #endif
122 -  
123 trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL, 128 trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL,
124 GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min), 129 GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min),
125 dodag->dio_interval_doubl, dodag->dio_redun); 130 dodag->dio_interval_doubl, dodag->dio_redun);
@@ -133,12 +138,11 @@ static void _receive(gnrc_pktsnip_t *icmpv6) @@ -133,12 +138,11 @@ static void _receive(gnrc_pktsnip_t *icmpv6)
133 ipv6_hdr_t *ipv6_hdr; 138 ipv6_hdr_t *ipv6_hdr;
134 icmpv6_hdr_t *icmpv6_hdr; 139 icmpv6_hdr_t *icmpv6_hdr;
135 kernel_pid_t iface = KERNEL_PID_UNDEF; 140 kernel_pid_t iface = KERNEL_PID_UNDEF;
136 - 141 +
137 assert(icmpv6 != NULL); 142 assert(icmpv6 != NULL);
138 143
139 ipv6 = gnrc_pktsnip_search_type(icmpv6, GNRC_NETTYPE_IPV6); 144 ipv6 = gnrc_pktsnip_search_type(icmpv6, GNRC_NETTYPE_IPV6);
140 netif = gnrc_pktsnip_search_type(icmpv6, GNRC_NETTYPE_NETIF); 145 netif = gnrc_pktsnip_search_type(icmpv6, GNRC_NETTYPE_NETIF);
141 -  
142 assert(ipv6 != NULL); 146 assert(ipv6 != NULL);
143 147
144 if (netif) { 148 if (netif) {
@@ -156,6 +160,14 @@ static void _receive(gnrc_pktsnip_t *icmpv6) @@ -156,6 +160,14 @@ static void _receive(gnrc_pktsnip_t *icmpv6)
156 break; 160 break;
157 case GNRC_RPL_ICMPV6_CODE_DIO: 161 case GNRC_RPL_ICMPV6_CODE_DIO:
158 DEBUG("RPL: DIO received\n"); 162 DEBUG("RPL: DIO received\n");
  163 + /*******************************************************************/
  164 + //ADDED BY PFE7 2017
  165 + gnrc_netif_hdr_t* header=(gnrc_netif_hdr_t*)netif->data;
  166 + gnrc_rpl_dio_t * dio_msg=(gnrc_rpl_dio_t *)(icmpv6_hdr + 1);
  167 + dio_msg->mc.rssi=header->rssi;
  168 + dio_msg->mc.lqi=header->lqi;
  169 + //\ADDED BY PFE7 2017
  170 + /*******************************************************************/
159 gnrc_rpl_recv_DIO((gnrc_rpl_dio_t *)(icmpv6_hdr + 1), iface, &ipv6_hdr->src, 171 gnrc_rpl_recv_DIO((gnrc_rpl_dio_t *)(icmpv6_hdr + 1), iface, &ipv6_hdr->src,
160 &ipv6_hdr->dst, byteorder_ntohs(ipv6_hdr->len)); 172 &ipv6_hdr->dst, byteorder_ntohs(ipv6_hdr->len));
161 break; 173 break;
RIOT/sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c
@@ -477,7 +477,7 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src @@ -477,7 +477,7 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
477 /* new instance and DODAG */ 477 /* new instance and DODAG */
478 478
479 if (byteorder_ntohs(dio->rank) == GNRC_RPL_INFINITE_RANK) { 479 if (byteorder_ntohs(dio->rank) == GNRC_RPL_INFINITE_RANK) {
480 - DEBUG("RPL: ignore INFINITE_RANK DIO when we are not yet part of this DODAG\n"); 480 + puts("RPL: ignore INFINITE_RANK DIO when we are not yet part of this DODAG\n");
481 gnrc_rpl_instance_remove(inst); 481 gnrc_rpl_instance_remove(inst);
482 return; 482 return;
483 } 483 }
@@ -500,7 +500,7 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src @@ -500,7 +500,7 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
500 gnrc_rpl_parent_t *parent = NULL; 500 gnrc_rpl_parent_t *parent = NULL;
501 501
502 if (!gnrc_rpl_parent_add_by_addr(dodag, src, &parent) && (parent == NULL)) { 502 if (!gnrc_rpl_parent_add_by_addr(dodag, src, &parent) && (parent == NULL)) {
503 - DEBUG("RPL: Could not allocate new parent.\n"); 503 + puts("RPL: Could not allocate new parent.\n");
504 gnrc_rpl_instance_remove(inst); 504 gnrc_rpl_instance_remove(inst);
505 return; 505 return;
506 } 506 }
@@ -508,7 +508,14 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src @@ -508,7 +508,14 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
508 dodag->version = dio->version_number; 508 dodag->version = dio->version_number;
509 dodag->grounded = dio->g_mop_prf >> GNRC_RPL_GROUNDED_SHIFT; 509 dodag->grounded = dio->g_mop_prf >> GNRC_RPL_GROUNDED_SHIFT;
510 dodag->prf = dio->g_mop_prf & GNRC_RPL_PRF_MASK; 510 dodag->prf = dio->g_mop_prf & GNRC_RPL_PRF_MASK;
511 - 511 + /*******************************************************************/
  512 + //ADDED BY PFE7 2017
  513 + parent->mc.rssi=dio->mc.rssi;
  514 + parent->mc.lqi=dio->mc.lqi;
  515 + //\ADDED BY PFE7 2017
  516 + /*******************************************************************/
  517 +
  518 +
512 parent->rank = byteorder_ntohs(dio->rank); 519 parent->rank = byteorder_ntohs(dio->rank);
513 520
514 uint32_t included_opts = 0; 521 uint32_t included_opts = 0;
@@ -625,7 +632,12 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src @@ -625,7 +632,12 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
625 632
626 /* gnrc_rpl_parent_add_by_addr should have set this already */ 633 /* gnrc_rpl_parent_add_by_addr should have set this already */
627 assert(parent != NULL); 634 assert(parent != NULL);
628 - 635 + /*******************************************************************/
  636 + //ADDED BY PFE7 2017
  637 + parent->mc.rssi=dio->mc.rssi;
  638 + parent->mc.lqi=dio->mc.lqi;
  639 + //\ADDED BY PFE7 2017
  640 + /*******************************************************************/
629 parent->rank = byteorder_ntohs(dio->rank); 641 parent->rank = byteorder_ntohs(dio->rank);
630 642
631 gnrc_rpl_parent_update(dodag, parent); 643 gnrc_rpl_parent_update(dodag, parent);
RIOT/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c
@@ -288,6 +288,7 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent) @@ -288,6 +288,7 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent)
288 } 288 }
289 289
290 if (_gnrc_rpl_find_preferred_parent(dodag) == NULL) { 290 if (_gnrc_rpl_find_preferred_parent(dodag) == NULL) {
  291 + puts("local repair");
291 gnrc_rpl_local_repair(dodag); 292 gnrc_rpl_local_repair(dodag);
292 } 293 }
293 } 294 }
@@ -308,6 +309,7 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda @@ -308,6 +309,7 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda
308 gnrc_rpl_parent_t *elt, *tmp; 309 gnrc_rpl_parent_t *elt, *tmp;
309 310
310 if (dodag->parents == NULL) { 311 if (dodag->parents == NULL) {
  312 + puts("NULL 1");
311 return NULL; 313 return NULL;
312 } 314 }
313 315
@@ -316,6 +318,7 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda @@ -316,6 +318,7 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda
316 } 318 }
317 319
318 if (new_best->rank == GNRC_RPL_INFINITE_RANK) { 320 if (new_best->rank == GNRC_RPL_INFINITE_RANK) {
  321 + puts("NULL 2");
319 return NULL; 322 return NULL;
320 } 323 }
321 324
@@ -346,8 +349,9 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda @@ -346,8 +349,9 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda
346 #endif 349 #endif
347 350
348 } 351 }
349 - 352 + printf("AVmy_rank : %d\n",dodag->my_rank);
350 dodag->my_rank = dodag->instance->of->calc_rank(dodag->parents, 0); 353 dodag->my_rank = dodag->instance->of->calc_rank(dodag->parents, 0);
  354 + printf("my_rank : %d\n",dodag->my_rank);
351 if (dodag->my_rank != old_rank) { 355 if (dodag->my_rank != old_rank) {
352 trickle_reset_timer(&dodag->trickle); 356 trickle_reset_timer(&dodag->trickle);
353 } 357 }
RIOT/sys/net/gnrc/routing/rpl/of0.c
@@ -54,25 +54,39 @@ uint16_t calc_rank(gnrc_rpl_parent_t *parent, uint16_t base_rank) @@ -54,25 +54,39 @@ uint16_t calc_rank(gnrc_rpl_parent_t *parent, uint16_t base_rank)
54 { 54 {
55 if (base_rank == 0) { 55 if (base_rank == 0) {
56 if (parent == NULL) { 56 if (parent == NULL) {
  57 + puts("pas parent");
57 return GNRC_RPL_INFINITE_RANK; 58 return GNRC_RPL_INFINITE_RANK;
58 } 59 }
59 - 60 + puts("if1");
60 base_rank = parent->rank; 61 base_rank = parent->rank;
  62 +
61 } 63 }
62 64
63 uint16_t add; 65 uint16_t add;
64 66
65 if (parent != NULL) { 67 if (parent != NULL) {
66 - add = parent->dodag->instance->min_hop_rank_inc; 68 + puts("if2");
  69 + //add = parent->dodag->instance->min_hop_rank_inc;
  70 + /*******************************************************************/
  71 + //ADDED BY PFE7 2017
  72 +
  73 + add = 256 - (parent->mc.rssi + parent->mc.lqi)/10;
  74 + parent->dodag->instance->min_hop_rank_inc=add;
  75 + printf("add= %u\n",add);
  76 +
  77 + //\ADDED BY PFE7 2017
  78 + /*******************************************************************/
67 } 79 }
68 else { 80 else {
  81 + puts("else1");
69 add = GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE; 82 add = GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE;
  83 +
70 } 84 }
71 85
72 if ((base_rank + add) < base_rank) { 86 if ((base_rank + add) < base_rank) {
  87 + puts("b_r + add < br");
73 return GNRC_RPL_INFINITE_RANK; 88 return GNRC_RPL_INFINITE_RANK;
74 } 89 }
75 -  
76 return base_rank + add; 90 return base_rank + add;
77 } 91 }
78 92