|
26 | 26 | #include "6LoWPAN/Bootstraps/protocol_6lowpan_interface.h"
|
27 | 27 | #include "6LoWPAN/ws/ws_config.h"
|
28 | 28 | #include "6LoWPAN/ws/ws_common.h"
|
| 29 | +#include "6LoWPAN/ws/ws_bootstrap.h" |
29 | 30 | #include "RPL/rpl_control.h"
|
30 | 31 | #include "RPL/rpl_data.h"
|
31 | 32 | #include "Common_Protocols/icmpv6.h"
|
|
43 | 44 | static void ws_bbr_rpl_root_activate(uint8_t *dodag_prefix, uint8_t *dodag_id)
|
44 | 45 | {
|
45 | 46 | tr_debug("RPL root Activate");
|
46 |
| - rpl_dodag_conf_t new_conf; |
47 |
| - |
48 |
| - // Lifetime values |
49 |
| - new_conf.default_lifetime = 120; |
50 |
| - new_conf.lifetime_unit = 60; |
51 |
| - new_conf.objective_code_point = 1; // MRHOF algorithm used |
52 |
| - new_conf.authentication = 0; |
53 |
| - new_conf.path_control_size = 0; |
54 |
| - |
55 |
| - |
56 |
| - // TODO temporary values spec says 0 |
57 |
| - new_conf.dag_max_rank_increase = 3072; |
58 |
| - new_conf.min_hop_rank_increase = 128;// 24 Hop networks 3072/128 == 24 |
59 |
| - |
60 |
| - |
61 |
| - // DIO configuration |
62 |
| - new_conf.dio_interval_min = WS_RPL_DIO_IMIN; |
63 |
| - new_conf.dio_interval_doublings = WS_RPL_DIO_DOUBLING; |
64 |
| - new_conf.dio_redundancy_constant = WS_RPL_DIO_REDUDANCY; |
| 47 | + rpl_dodag_conf_t new_conf = |
| 48 | + { |
| 49 | + // Lifetime values |
| 50 | + .default_lifetime = 120, |
| 51 | + .lifetime_unit = 60, |
| 52 | + .objective_code_point = 1, // MRHOF algorithm used |
| 53 | + .authentication = 0, |
| 54 | + .path_control_size = 0, |
| 55 | + .dag_max_rank_increase = 0, |
| 56 | + .min_hop_rank_increase = 128, |
| 57 | + // DIO configuration |
| 58 | + .dio_interval_min = WS_RPL_DIO_IMIN, |
| 59 | + .dio_interval_doublings = WS_RPL_DIO_DOUBLING, |
| 60 | + .dio_redundancy_constant = WS_RPL_DIO_REDUNDANCY |
| 61 | + }; |
65 | 62 |
|
66 | 63 | rpl_data_init_root();
|
67 | 64 | protocol_6lowpan_rpl_root_dodag = rpl_control_create_dodag_root(protocol_6lowpan_rpl_domain, RPL_INSTANCE_ID, dodag_id, &new_conf, new_conf.min_hop_rank_increase, RPL_GROUNDED | RPL_MODE_NON_STORING | RPL_DODAG_PREF(0));
|
@@ -118,27 +115,48 @@ void ws_bbr_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds
|
118 | 115 | return;
|
119 | 116 | }
|
120 | 117 |
|
121 |
| - if (protocol_6lowpan_rpl_root_dodag) { |
| 118 | + if (!protocol_6lowpan_rpl_root_dodag) { |
122 | 119 | // RPL configured
|
| 120 | + // 1. Wait for backend connection |
| 121 | + // 2. request own prefix if available |
| 122 | + // 3. check if connected to RPL root |
| 123 | + // 3.1 check if Globally connected root available (Backend with own mesh prefix) |
| 124 | + // 3.2 check if Globally connected root available (ND proxy) |
| 125 | + // 3.3 Check if grounded root available (Backend connectivity to static config in backend) |
| 126 | + // 3.4 only local connectivity (No backend) |
| 127 | + // 4. If I can provide better connectivity start root |
| 128 | + // 4.1. If no other roots or backend start static root |
| 129 | + // 4.2. If backend gets connectivity add global root |
| 130 | + // 4.3. If backend loses connectivity remove global root, leave static |
| 131 | + // 5. if someone has offered better connected root remove own |
| 132 | + // 6. if multiple same level roots |
| 133 | + // 6.1 lower connectivity must drop |
| 134 | + // 6.2 lowest dodag ID remains |
| 135 | + |
| 136 | + ws_bbr_root_start(cur); |
123 | 137 | return;
|
124 | 138 | }
|
125 |
| - // 1. Wait for backend connection |
126 |
| - // 2. request own prefix if available |
127 |
| - // 3. check if connected to RPL root |
128 |
| - // 3.1 check if Globally connected root available (Backend with own mesh prefix) |
129 |
| - // 3.2 check if Globally connected root available (ND proxy) |
130 |
| - // 3.3 Check if grounded root available (Backend connectivity to static config in backend) |
131 |
| - // 3.4 only local connectivity (No backend) |
132 |
| - // 4. If I can provide better connectivity start root |
133 |
| - // 4.1. If no other roots or backend start static root |
134 |
| - // 4.2. If backend gets connectivity add global root |
135 |
| - // 4.3. If backend loses connectivity remove global root, leave static |
136 |
| - // 5. if someone has offered better connected root remove own |
137 |
| - // 6. if multiple same level roots |
138 |
| - // 6.1 lower connectivity must drop |
139 |
| - // 6.2 lowest dodag ID remains |
140 |
| - |
141 |
| - ws_bbr_root_start(cur); |
| 139 | + |
| 140 | + // Normal BBR operation |
| 141 | + if (cur->ws_info->pan_version_timer > seconds ) { |
| 142 | + cur->ws_info->pan_version_timer -= seconds; |
| 143 | + } else { |
| 144 | + // Border router has timed out |
| 145 | + tr_debug("Border router version number update"); |
| 146 | + cur->ws_info->pan_version_timer = PAN_VERSION_LIFETIME; |
| 147 | + cur->ws_info->pan_information.pan_version++; |
| 148 | + // Inconsistent for border router to make information distribute faster |
| 149 | + ws_bootstrap_configuration_trickle_reset(cur); |
| 150 | + |
| 151 | + // We update the RPL version in same time to allow nodes to reselect parent |
| 152 | + // As configuration is made so that devices cant move downward in dodag this allows it |
| 153 | + // TODO think the correct rate for this |
| 154 | + if (cur->ws_info->pan_information.pan_version % 3 == 0) { |
| 155 | + // Third the rate of configuration version change at default 12 minutes |
| 156 | + rpl_control_increment_dodag_version(protocol_6lowpan_rpl_root_dodag); |
| 157 | + } |
| 158 | + } |
| 159 | + |
142 | 160 | }
|
143 | 161 |
|
144 | 162 | uint16_t test_pan_size_override = 0xffff;
|
|
0 commit comments