Skip to content

Commit eb6a4f7

Browse files
Mika TervonenMika Tervonen
authored andcommitted
Change stagger calculation to give more bandwidth to application
75% of the usable bandwidth is now allocated to the application Usable data rate function created that is used in stagger calculation OFDM modes are now supported with stagger calculation prevent division by zero if no data rate set and use minimum of 25kbs
1 parent 82f1d54 commit eb6a4f7

File tree

5 files changed

+52
-5
lines changed

5 files changed

+52
-5
lines changed

source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
#define TRACE_GROUP "6lo"
8484

8585
/* Data rate for application used in Stagger calculation */
86-
#define STAGGER_DATARATE_FOR_APPL(n) ((n)*25/100)
86+
#define STAGGER_DATARATE_FOR_APPL(n) ((n)*75/100)
8787

8888
#ifdef HAVE_RPL
8989
rpl_domain_t *protocol_6lowpan_rpl_domain;
@@ -839,7 +839,7 @@ bool protocol_6lowpan_stagger_estimate_get(int8_t interface_id, uint32_t data_am
839839
datarate = 250000;
840840
} else if (ws_info(cur_interface)) {
841841
network_size = ws_common_network_size_estimate_get(cur_interface);
842-
datarate = ws_common_datarate_get(cur_interface);
842+
datarate = ws_common_usable_application_datarate_get(cur_interface);
843843
} else {
844844
// 6LoWPAN ND
845845
network_size = 1000;
@@ -850,6 +850,10 @@ bool protocol_6lowpan_stagger_estimate_get(int8_t interface_id, uint32_t data_am
850850
// If no data amount given, use 1kB
851851
data_amount = 1;
852852
}
853+
if (datarate < 25000) {
854+
// Minimum data rate used in calculations is 25kbs to prevent invalid values
855+
datarate = 25000;
856+
}
853857

854858
/*
855859
* Do not occupy whole bandwidth, leave space for network formation etc...

source/6LoWPAN/ws/ws_cfg_settings.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ cfg_network_size_type_e ws_cfg_network_config_get(protocol_interface_info_entry_
405405
return CONFIG_SMALL;
406406
}
407407

408-
uint32_t data_rate = ws_get_datarate_using_operating_mode(phy_cfg.operating_mode);
408+
uint32_t data_rate = ws_common_datarate_get_from_phy_mode(phy_cfg.phy_mode_id, phy_cfg.operating_mode);
409+
409410
uint8_t index;
410411
if (data_rate < 150000) {
411412
index = 0;

source/6LoWPAN/ws/ws_common.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ phy_modulation_index_e ws_get_modulation_index_using_operating_mode(uint8_t oper
223223
int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur, ws_hopping_schedule_t *hopping_schdule)
224224
{
225225
(void)cur;
226-
if (ws_get_datarate_using_operating_mode(hopping_schdule->operating_mode) == 0) {
226+
if (ws_common_datarate_get_from_phy_mode(hopping_schdule->phy_mode_id, hopping_schdule->operating_mode) == 0) {
227227
//Unsupported operation mode
228228
return -1;
229229
}
@@ -663,11 +663,37 @@ uint32_t ws_common_latency_estimate_get(protocol_interface_info_entry_t *cur)
663663
return latency;
664664
}
665665

666+
uint32_t ws_common_datarate_get_from_phy_mode(uint8_t phy_mode_id, uint8_t operating_mode)
667+
{
668+
if (((phy_mode_id >= 34) && (phy_mode_id <= 38)) ||
669+
((phy_mode_id >= 51) && (phy_mode_id <= 54)) ||
670+
((phy_mode_id >= 68) && (phy_mode_id <= 70)) ||
671+
((phy_mode_id >= 84) && (phy_mode_id <= 86))) {
672+
return ws_get_datarate_using_phy_mode_id(phy_mode_id);
673+
}
674+
return ws_get_datarate_using_operating_mode(operating_mode);
675+
}
676+
666677
uint32_t ws_common_datarate_get(protocol_interface_info_entry_t *cur)
667678
{
668-
return ws_get_datarate_using_operating_mode(cur->ws_info->hopping_schdule.operating_mode);
679+
return ws_common_datarate_get_from_phy_mode(cur->ws_info->hopping_schdule.phy_mode_id, cur->ws_info->hopping_schdule.operating_mode);
669680
}
670681

682+
uint32_t ws_common_usable_application_datarate_get(protocol_interface_info_entry_t *cur)
683+
{
684+
/* Usable data rate is a available data rate when removed ACK and wait times required to send a packet
685+
*
686+
* Estimated to be around 70% with following assumptions with 150kbs data rate
687+
* Average ACK size 48 bytes
688+
* Average tACK 2ms
689+
* Average CCA check time + processing 7ms
690+
* Delays in bytes with 150kbs data rate 168 + 48 bytes for ACK 216 bytes
691+
* Usable data rate is 1 - 216/(216 + 500) about 70%
692+
*/
693+
return 70 * ws_common_datarate_get_from_phy_mode(cur->ws_info->hopping_schdule.phy_mode_id, cur->ws_info->hopping_schdule.operating_mode) / 100;
694+
}
695+
696+
671697
uint32_t ws_common_network_size_estimate_get(protocol_interface_info_entry_t *cur)
672698
{
673699
uint32_t network_size_estimate = 100;

source/6LoWPAN/ws/ws_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,12 @@ uint32_t ws_common_version_timeout_get(uint8_t config);
164164

165165
uint32_t ws_common_latency_estimate_get(protocol_interface_info_entry_t *cur);
166166

167+
uint32_t ws_common_datarate_get_from_phy_mode(uint8_t phy_mode_id, uint8_t operating_mode);
168+
167169
uint32_t ws_common_datarate_get(protocol_interface_info_entry_t *cur);
168170

171+
uint32_t ws_common_usable_application_datarate_get(protocol_interface_info_entry_t *cur);
172+
169173
uint32_t ws_common_network_size_estimate_get(protocol_interface_info_entry_t *cur);
170174

171175
void ws_common_primary_parent_update(protocol_interface_info_entry_t *interface, mac_neighbor_table_entry_t *neighbor);
@@ -187,7 +191,9 @@ void ws_common_border_router_alive_update(protocol_interface_info_entry_t *inter
187191
#define ws_common_allow_child_registration(cur, eui64, aro_timeout) (2)
188192
#define ws_common_negative_aro_mark(interface, eui64)(false)
189193
#define ws_common_latency_estimate_get(cur) 0
194+
#define ws_common_datarate_get_from_phy_mode(phy_mode_id, operating_mode) 0
190195
#define ws_common_datarate_get(cur) 0
196+
#define ws_common_usable_application_datarate_get(cur) 0
191197
#define ws_common_network_size_estimate_get(cur) 0
192198
#define ws_common_primary_parent_update(interface, neighbor)
193199
#define ws_common_secondary_parent_update(interface)

test/nanostack/unittest/stub/ws_common_stub.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ uint32_t ws_common_datarate_get(protocol_interface_info_entry_t *cur)
102102
return 0;
103103
}
104104

105+
uint32_t ws_common_usable_application_datarate_get(protocol_interface_info_entry_t *cur)
106+
{
107+
return 0;
108+
}
109+
110+
uint32_t ws_common_datarate_get_from_phy_mode(uint8_t phy_mode_id, uint8_t operating_mode)
111+
{
112+
return 150000;
113+
}
114+
105115
uint32_t ws_get_datarate_using_operating_mode(uint8_t operating_mode)
106116
{
107117
return 150000;

0 commit comments

Comments
 (0)