83
83
#define TRACE_GROUP_LOWPAN "6lo"
84
84
#define TRACE_GROUP "6lo"
85
85
86
+ /* Data rate for application used in Stagger calculation */
87
+ #define STAGGER_DATARATE_FOR_APPL (n ) ((n)*25/100)
88
+
86
89
#ifdef HAVE_RPL
87
90
rpl_domain_t * protocol_6lowpan_rpl_domain ;
88
91
/* Having to sidestep old rpl_dodag_t type for the moment */
@@ -800,7 +803,7 @@ bool protocol_6lowpan_latency_estimate_get(int8_t interface_id, uint32_t *latenc
800
803
latency_estimate = 100 ;
801
804
} else if (thread_info (cur_interface )) {
802
805
// thread network
803
- latency_estimate = 1000 ;
806
+ latency_estimate = 2000 ;
804
807
} else if (ws_info (cur_interface )) {
805
808
latency_estimate = ws_common_latency_estimate_get (cur_interface );
806
809
} else {
@@ -820,14 +823,13 @@ bool protocol_6lowpan_stagger_estimate_get(int8_t interface_id, uint32_t data_am
820
823
{
821
824
size_t network_size ;
822
825
uint32_t datarate ;
826
+ uint32_t stagger_value ;
823
827
protocol_interface_info_entry_t * cur_interface = protocol_stack_interface_info_get_by_id (interface_id );
824
828
825
829
if (!cur_interface ) {
826
830
return false;
827
831
}
828
832
829
- * stagger_min = 1 ;
830
-
831
833
if (cur_interface -> eth_mac_api ) {
832
834
// either PPP or Ethernet interface.
833
835
network_size = 1 ;
@@ -849,16 +851,25 @@ bool protocol_6lowpan_stagger_estimate_get(int8_t interface_id, uint32_t data_am
849
851
// If no data amount given, use 1kB
850
852
data_amount = 1 ;
851
853
}
852
- /**Example:
853
- * Maximum stagger value to send 1kB on 50 devices network using datarate 50000 kb/:
854
- * (1 * 1024 * 8 * 50) / (50000/4)) = ~ 32s
855
- *
856
- * devices: 50, datarate: 250kbps => stagger ~ 6s
857
- * devices: 1000, datarate: 50kbps => stagger ~ 655s
854
+
855
+ /*
856
+ * Do not occupy whole bandwidth, leave space for network formation etc...
857
+ */
858
+ datarate = STAGGER_DATARATE_FOR_APPL (datarate );
859
+ stagger_value = 1 + ((data_amount * 1024 * 8 * network_size ) / datarate );
860
+ /**
861
+ * Example:
862
+ * Maximum stagger value to send 1kB to 100 device network using data rate of 50kbs:
863
+ * 1 + (1 * 1024 * 8 * 100) / (50000*0.25) = 66s
858
864
*/
859
- /* Do not occupy whole bandwidth, halve the theoretical datarate and reserve room for other channel usage */
860
- datarate = datarate / 4 ;
861
- * stagger_max = (uint16_t ) * stagger_min + ((data_amount * 1024 * 8 * network_size ) / datarate );
865
+
866
+ * stagger_min = stagger_value / 5 ; // Minimum stagger value is 1/5 of the max
867
+
868
+ if (stagger_value > 0xFFFF ) {
869
+ * stagger_max = 0xFFFF ;
870
+ } else {
871
+ * stagger_max = (uint16_t )stagger_value ;
872
+ }
862
873
863
874
// Randomize stagger value
864
875
* stagger_rand = randLIB_get_random_in_range (* stagger_min , * stagger_max );
0 commit comments