Skip to content

Commit 0903b81

Browse files
author
Arto Kinnunen
committed
Merge remote-tracking branch 'origin/release_internal' into release_external
* origin/release_internal: (40 commits) FHSS WS: api function to set TX allowance level (ARMmbed#2612) Fix Child NUD with long ARO registrations Optimize out of memory handler to remove more memory in EF mode FHSS WS: Allow transmitting unicast frames on broadcast channel for 1st hop node in EF mode (ARMmbed#2609) Generic forwarding callback and EF state enabler for Wi-SUN BBR. Allow transmitting on RX slot for 1st hop device in expedited forwarding mode (ARMmbed#2607) Implemented FHSS expedited forwarding mode (ARMmbed#2606) QoS traffic class documentation update. Fix warnings found by cppcheck (ARMmbed#2605) MPX and MAC API update MAC: "CCA fail on RX" event for TX done callback (ARMmbed#2602) Clear Ack tx and tx process in MAC reset (ARMmbed#2601) Optimize stagger based on uptime and startup type Iotthd 4584 (ARMmbed#2599) Fixed blacklisting overflow (ARMmbed#2597) Added support for High Priority forward state Corrected freed memory access on incoming EAPOL handling Fixed delayed interrupt (ARMmbed#2596) CCA backoffs max to 9 (ARMmbed#2595) Added API function to get neighbor table information from Wi-SUN ...
2 parents 25b9124 + 51429c9 commit 0903b81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1791
-371
lines changed

nanostack/dhcp_service_api.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ uint16_t dhcp_service_init(int8_t interface_id, dhcp_instance_type_e instance_ty
142142
*/
143143
void dhcp_service_relay_instance_enable(uint16_t instance, uint8_t *server_address);
144144

145+
/**
146+
* \brief Enable DHCPv6 Relay Agent to add interface ID option to relay frame. Default is disabled.
147+
*
148+
*
149+
* \param instance The instance ID of the registered server.
150+
* \param enable true add interface option
151+
*/
152+
void dhcp_service_relay_interface_id_option_enable(uint16_t instance, bool enable);
153+
145154
/**
146155
* \brief Get DHCPv6 Relay Agent address pointer.
147156
*

nanostack/fhss_api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ typedef struct fhss_callback fhss_callback_t;
4949
typedef enum {
5050
FHSS_UNSYNCHRONIZED,
5151
FHSS_SYNCHRONIZED,
52+
FHSS_EXPEDITED_FORWARDING
5253
} fhss_states;
5354

5455
/**

nanostack/fhss_ws_extension.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,27 @@ extern int ns_fhss_set_neighbor_info_fp(const fhss_api_t *fhss_api, fhss_get_nei
118118
*/
119119
extern int ns_fhss_ws_set_hop_count(const fhss_api_t *fhss_api, const uint8_t hop_count);
120120

121+
/**
122+
* @brief WS TX allowance levels.
123+
*/
124+
typedef enum {
125+
/** Allow transmitting only on TX slots. */
126+
WS_TX_SLOT,
127+
/** Allow transmitting only on TX and RX slots. */
128+
WS_TX_AND_RX_SLOT,
129+
/** Allow transmitting always. Also unicast on broadcast channel. */
130+
WS_TX_ALWAYS
131+
} fhss_ws_tx_allow_level;
132+
133+
/**
134+
* @brief Set node unicast TX allowance level. Allows device to use the unicast and broadcast channel for unicast transmission as described by fhss_ws_tx_allow_level.
135+
* @param fhss_api FHSS instance.
136+
* @param global_level Level of TX allowance in normal mode.
137+
* @param ef_level Level of TX allowance in expedited forwarding mode.
138+
* @return 0 on success, -1 on fail.
139+
*/
140+
extern int ns_fhss_ws_set_tx_allowance_level(const fhss_api_t *fhss_api, const fhss_ws_tx_allow_level global_level, const fhss_ws_tx_allow_level ef_level);
141+
121142
#ifdef __cplusplus
122143
}
123144
#endif

nanostack/mac_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,11 @@ typedef void mcps_data_request(const mac_api_t *api, const mcps_data_req_t *data
128128
* @param data MCPS-DATA.request specific values
129129
* @param ie_ext Information element list to MCPS-DATA.request
130130
* @param asynch_channel_list Optional channel list to asynch data request. Give NULL when normal data request.
131+
* @param priority Data request priority level
131132
*
132133
* Asynch data request is mac standard extension. asynch_channel_list include channel mask which channel message is requested to send.
133134
*/
134-
typedef void mcps_data_request_ext(const mac_api_t *api, const mcps_data_req_t *data, const mcps_data_req_ie_list_t *ie_ext, const struct channel_list_s *asynch_channel_list);
135+
typedef void mcps_data_request_ext(const mac_api_t *api, const mcps_data_req_t *data, const mcps_data_req_ie_list_t *ie_ext, const struct channel_list_s *asynch_channel_list, mac_data_priority_t priority);
135136

136137
/**
137138
* @brief mcps_purge_request MCPS_PURGE request call

nanostack/mac_mcps.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,17 @@ typedef struct mcps_edfe_response_s {
192192
bool use_message_handle_to_discover: 1; /**< EDFE Data request message ID is valid at message_handle. */
193193
} mcps_edfe_response_t;
194194

195+
/**
196+
* @brief enum mac_data_priority_t Data request priority level
197+
*
198+
* Data request priority level may affect CCA process and MAC queue process
199+
*/
200+
typedef enum mac_data_priority_e {
201+
MAC_DATA_NORMAL_PRIORITY = 0, /**< Normal MCPS DATA REQ */
202+
MAC_DATA_MEDIUM_PRIORITY = 1, /**< Indirect Data which is polled */
203+
MAC_DATA_HIGH_PRIORITY = 2, /**< MAC command usually use this and beacon */
204+
MAC_DATA_EXPEDITE_FORWARD = 3 /**< Expedite forward level give highest priority */
205+
} mac_data_priority_t;
206+
195207

196208
#endif // MAC_MCPS_H

nanostack/mlme.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ typedef enum {
264264
macAutoRequestKeyIndex = 0x7b, /*<The index of the key used for automatic data*/
265265
macDefaultKeySource = 0x7c, /*<Default key source*/
266266
//NON standard extension
267+
macRequestRestart = 0xf1, /*< Configure failed packet data request restart */
267268
macEdfeForceStop = 0xf2, /*< Use this command for Data wait timeout at LLC: Mac stop Edfe session data wait and enable normal FHSS mode */
268269
macSetDataWhitening = 0xf3, /*< Enable or disable data whitening, boolean true for enable, false for disable */
269270
macCCAThresholdStart = 0xf4, /*< Start automatic CCA threshold */
@@ -517,4 +518,16 @@ typedef struct mlme_multi_csma_ca_s {
517518
uint16_t multi_cca_interval; /**< Length of the additional CSMA-CA period(s) in microseconds */
518519
} mlme_multi_csma_ca_param_t;
519520

521+
/**
522+
* @brief struct mlme_request_restart_config_s Set failed packet request restart configuration
523+
*
524+
* Non standard extension to restart data request after failed CCA or TX attempts
525+
*/
526+
typedef struct mlme_request_restart_config_s {
527+
uint8_t cca_failure_restart_max; /**< Max number of restarts after CCA failure */
528+
uint8_t tx_failure_restart_max; /**< Max number of restarts after TX failure */
529+
uint16_t blacklist_min_ms; /**< Blacklist min, which is doubled by every restart */
530+
uint16_t blacklist_max_ms; /**< Blacklist max, largest allowed blacklist time */
531+
} mlme_request_restart_config_t;
532+
520533
#endif /* MLME_H_ */

nanostack/platform/arm_hal_phy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ typedef enum {
5050
PHY_LINK_TX_SUCCESS, /**< MAC TX complete. MAC will a make decision to enter wait ACK or TX done state. */
5151
PHY_LINK_TX_FAIL, /**< Link TX process fail. */
5252
PHY_LINK_CCA_FAIL, /**< RF link CCA process fail. */
53+
PHY_LINK_CCA_FAIL_RX, /**< RF link CCA process failed because of packet reception. */
5354
PHY_LINK_CCA_OK, /**< RF link CCA process ok. */
5455
PHY_LINK_CCA_PREPARE, /**< Prepare for CCA after CSMA-CA: changes to CCA channel and gives permission to TX. See PHY_LINK_CCA_PREPARE status definitions for return values */
5556
} phy_link_tx_status_e;

nanostack/socket_api.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,41 @@ extern "C" {
138138
* After the successful state change, data can be sent using socket_send().
139139
* The connection can be shut down in either direction with socket_shutdown() function - shutting down write signals end-of-data to the peer.
140140
*
141+
*
141142
* \section socket-udpicmp How to use UDP and RAW socket:
142143
*
143144
* A UDP socket is ready to receive and send data immediately after a successful call of socket_open() and a NET_READY event is received.
144145
* Data can be transmitted with the socket_sendto() function. An ICMP socket works with same function call.
146+
*
147+
* \section socket-trafficpriority How to set socket message priority to improve Quality of Service (QoS):
148+
*
149+
* IPv6 header has a field traffic class that contains a 6-bit Differentiated Services Code Point (DSCP) field that is used for packet
150+
* classification. By default the packet class level is set to 0 NS_DSCP_DEFAULT.
151+
*
152+
* Recommend QoS levels:
153+
*
154+
* | Level |Description |
155+
* | :--------------: | :-------------------------------------------------------------------------------------------------: |
156+
* | NS_DSCP_DEFAULT | Default level for normal data usage |
157+
* | NS_DSCP_AF11 | Higher Application data service for prioritize packet forwarding. |
158+
* | NS_DSCP_EF | Expedited Forwarding (EF) for short messages. Allows low loss, low delay, and low jitter services. |
159+
* | | This is meant for very important messages like alerts. EF packet length should be kept in |
160+
* | | minimum. This should not be used for any other purpose as it will block other network traffic |
161+
* | NS_DSCP_CS6 | Network protocol message Priority. Application should not use this. |
162+
*
163+
* High priority messages can be set to use higher than default class by using socket_setsockopt() and
164+
* socket_option_traffic_class_dsc_set() helper.
165+
*
166+
* Example to send a message using Expedited Forwarding class:
167+
*
168+
* //Set EF class to high priority messages
169+
* int16_t traffic_class = socket_option_traffic_class_dsc_set(NS_DSCP_EF);
170+
* socket_setsockopt(socket_id, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_TCLASS, &traffic_class, sizeof traffic_class);
171+
*
172+
* //Set traffic class back to default
173+
* traffic_class = socket_option_traffic_class_dsc_set(NS_DSCP_DEFAULT);
174+
* socket_setsockopt(socket_id, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_TCLASS, &traffic_class, sizeof traffic_class);
175+
*
145176
*/
146177

147178
#include "ns_address.h"
@@ -250,6 +281,24 @@ typedef struct ns_in6_pktinfo {
250281
int8_t ipi6_ifindex; /**< send/recv interface index */
251282
} ns_in6_pktinfo_t;
252283

284+
/** \name Socket DSCP (Differentiated Services Code Point) QoS level examples.
285+
* \anchor MSG_QOS_LEVELS
286+
*/
287+
///@{
288+
/** Standard priority and it is socket default */
289+
#define NS_DSCP_DEFAULT 0
290+
/** Application high priority service: Stack priorities these messages over the default priority messages */
291+
#define NS_DSCP_AF11 10
292+
/** Expedited Forwarding (EF) QoS level enable high priority state: low loss, low delay, and low jitter services */
293+
#define NS_DSCP_EF 46
294+
/** Network protocol traffic allocated QoS level stack may internally use that */
295+
#define NS_DSCP_CS6 48
296+
///@}
297+
298+
/** Helper Traffic class Differentiated Services Code for QoS 0-63. 0 is default which define Lowest Priority
299+
*
300+
* */
301+
#define socket_option_traffic_class_dsc_set(x) (uint8_t)((x & 63) << 2)
253302

254303
/** \name Alignment macros for control message headers
255304
* \anchor CMSG_ALIGN_FLAGS

nanostack/ws_management_api.h

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ extern "C" {
9090
#define NETWORK_SIZE_XLARGE 0x19 /**< 2500+ devices */
9191
#define NETWORK_SIZE_AUTOMATIC 0xFF /**< Automatic network size */
9292

93+
/**
94+
* \brief Neighbor type to differentiate the Role of the neighbor.
95+
*/
96+
97+
typedef enum {
98+
WS_OTHER = 0, /**< temporary or soon to be removed neighbor*/
99+
WS_PRIMARY_PARENT, /**< Primary parent used for upward packets and used from Border router downwards*/
100+
WS_SECONDARY_PARENT, /**< Secondary parent reported to border router and might be used as alternate route*/
101+
WS_CANDIDATE_PARENT, /**< Candidate neighbor that is considered as parent if there is problem with active parents*/
102+
WS_CHILD /**< Child with registered address*/
103+
} ws_management_neighbor_type_e;
104+
105+
93106
/** Temporary API change flag. this will be removed when new version of API is implemented on applications
94107
*
95108
*/
@@ -127,6 +140,47 @@ typedef struct ws_statistics {
127140
uint32_t asynch_tx_count;
128141
/** Asynch RX counter */
129142
uint32_t asynch_rx_count;
143+
144+
145+
/** Time spent in individual Wi-SUN join state 1 Discovery*/
146+
uint32_t join_state_1;
147+
/** Time spent in individual Wi-SUN join state 2 Authentication*/
148+
uint32_t join_state_2;
149+
/** Time spent in individual Wi-SUN join state 3 Configuration learn*/
150+
uint32_t join_state_3;
151+
/** Time spent in individual Wi-SUN join state 4 RPL parent discovery*/
152+
uint32_t join_state_4;
153+
/** Time spent in individual Wi-SUN join state 5 Active state*/
154+
uint32_t join_state_5;
155+
156+
157+
/** Amount of Wi-SUN Pan Advertisement Solicit Message sent*/
158+
uint32_t sent_PAS;
159+
/** Amount of Wi-SUN Pan Advertisement Message sent*/
160+
uint32_t sent_PA;
161+
/** Amount of Wi-SUN Pan Configuration Solicit Message sent*/
162+
uint32_t sent_PCS;
163+
/** Amount of Wi-SUN Pan Configuration Message sent*/
164+
uint32_t sent_PC;
165+
166+
/** Amount of Wi-SUN Pan Advertisement Solicit Message sent*/
167+
uint32_t recv_PAS;
168+
/** Amount of Wi-SUN Pan Advertisement Message sent*/
169+
uint32_t recv_PA;
170+
/** Amount of Wi-SUN Pan Configuration Solicit Message sent*/
171+
uint32_t recv_PCS;
172+
/** Amount of Wi-SUN Pan Configuration Message sent*/
173+
uint32_t recv_PC;
174+
175+
/** New Neighbours found */
176+
uint32_t Neighbour_add;
177+
/** New Neighbours Removed */
178+
uint32_t Neighbour_remove;
179+
/** New Child added */
180+
uint32_t Child_add;
181+
/** Child lost */
182+
uint32_t child_remove;
183+
130184
} ws_statistics_t;
131185

132186
/**
@@ -149,6 +203,28 @@ typedef struct ws_stack_info {
149203
uint8_t join_state;
150204
} ws_stack_info_t;
151205

206+
/**
207+
* \brief Struct ws_neighbour_info_t Gives the neighbour information.
208+
*/
209+
typedef struct ws_neighbour_info {
210+
/** Link local address*/
211+
uint8_t link_local_address[16];
212+
/** Global address if it is known set to 0 if not available*/
213+
uint8_t global_address[16];
214+
/** parent RSSI Out measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
215+
uint8_t rsl_out;
216+
/** parent RSSI in measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
217+
uint8_t rsl_in;
218+
/** RPL Rank value for parents 0xffff for neighbors RANK is unknown*/
219+
uint16_t rpl_rank;
220+
/** Measured ETX value if known set to 0xFFFF if not known or Child*/
221+
uint16_t etx;
222+
/** Remaining lifetime Link lifetime for parents and ARO lifetime for children*/
223+
uint32_t lifetime;
224+
/** Neighbour type (Primary Parent, Secondary Parent, Candidate parent, child, other(Temporary neighbours))*/
225+
ws_management_neighbor_type_e type;
226+
} ws_neighbour_info_t;
227+
152228
/**
153229
* Initialize Wi-SUN stack.
154230
*
@@ -752,6 +828,25 @@ int ws_stack_info_get(
752828
int8_t interface_id,
753829
ws_stack_info_t *info_ptr);
754830

831+
/**
832+
* Get Neighbor table information from stack.
833+
*
834+
* To allocate correct amount of memory first use the API with NULL to get current amount
835+
* of neighbors. Then Allocate the memory and call the function to fill the table.
836+
*
837+
* \param interface_id Network interface ID.
838+
* \param neighbor_ptr Pointer to memory where Neighbor table entries can be written.
839+
* \param count amount of neighbor table entries allocated to memory.
840+
*
841+
* \return >=0 Success with amount of entries written in table.
842+
* \return >=0 if neighbor_ptr is NULL returns the amount of neighbors currently.
843+
* \return <0 Failure.
844+
*/
845+
int ws_neighbor_info_get(
846+
int8_t interface_id,
847+
ws_neighbour_info_t *neighbor_ptr,
848+
uint16_t count);
849+
755850
/**
756851
* Set minimum RF sensitivity acceptable for the parent selection
757852
*

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@
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)
87+
88+
/* Time after network is considered stable and smaller stagger values can be given*/
89+
#define STAGGER_STABLE_NETWORK_TIME 3600*4
8790

8891
#ifdef HAVE_RPL
8992
rpl_domain_t *protocol_6lowpan_rpl_domain;
@@ -839,7 +842,7 @@ bool protocol_6lowpan_stagger_estimate_get(int8_t interface_id, uint32_t data_am
839842
datarate = 250000;
840843
} else if (ws_info(cur_interface)) {
841844
network_size = ws_common_network_size_estimate_get(cur_interface);
842-
datarate = ws_common_datarate_get(cur_interface);
845+
datarate = ws_common_usable_application_datarate_get(cur_interface);
843846
} else {
844847
// 6LoWPAN ND
845848
network_size = 1000;
@@ -850,11 +853,23 @@ bool protocol_6lowpan_stagger_estimate_get(int8_t interface_id, uint32_t data_am
850853
// If no data amount given, use 1kB
851854
data_amount = 1;
852855
}
856+
if (datarate < 25000) {
857+
// Minimum data rate used in calculations is 25kbs to prevent invalid values
858+
datarate = 25000;
859+
}
853860

854861
/*
855862
* Do not occupy whole bandwidth, leave space for network formation etc...
856863
*/
857-
datarate = STAGGER_DATARATE_FOR_APPL(datarate);
864+
if (ws_info(cur_interface) &&
865+
(ws_common_connected_time_get(cur_interface) > STAGGER_STABLE_NETWORK_TIME || ws_common_authentication_time_get(cur_interface) == 0)) {
866+
// After four hours of network connected full bandwidth is given to application
867+
// Authentication has not been required during bootstrap so network load is much smaller
868+
} else {
869+
// Smaller data rate allowed as we have just joined to the network and Authentication was made
870+
datarate = STAGGER_DATARATE_FOR_APPL(datarate);
871+
}
872+
858873
stagger_value = 1 + ((data_amount * 1024 * 8 * network_size) / datarate);
859874
/**
860875
* Example:

0 commit comments

Comments
 (0)