Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release_internal' into release_e…
Browse files Browse the repository at this point in the history
…xternal

* 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
  ...
  • Loading branch information
Arto Kinnunen committed Apr 15, 2021
2 parents 25b9124 + 51429c9 commit 0903b81
Show file tree
Hide file tree
Showing 70 changed files with 1,791 additions and 371 deletions.
9 changes: 9 additions & 0 deletions nanostack/dhcp_service_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ uint16_t dhcp_service_init(int8_t interface_id, dhcp_instance_type_e instance_ty
*/
void dhcp_service_relay_instance_enable(uint16_t instance, uint8_t *server_address);

/**
* \brief Enable DHCPv6 Relay Agent to add interface ID option to relay frame. Default is disabled.
*
*
* \param instance The instance ID of the registered server.
* \param enable true add interface option
*/
void dhcp_service_relay_interface_id_option_enable(uint16_t instance, bool enable);

/**
* \brief Get DHCPv6 Relay Agent address pointer.
*
Expand Down
1 change: 1 addition & 0 deletions nanostack/fhss_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ typedef struct fhss_callback fhss_callback_t;
typedef enum {
FHSS_UNSYNCHRONIZED,
FHSS_SYNCHRONIZED,
FHSS_EXPEDITED_FORWARDING
} fhss_states;

/**
Expand Down
21 changes: 21 additions & 0 deletions nanostack/fhss_ws_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,27 @@ extern int ns_fhss_set_neighbor_info_fp(const fhss_api_t *fhss_api, fhss_get_nei
*/
extern int ns_fhss_ws_set_hop_count(const fhss_api_t *fhss_api, const uint8_t hop_count);

/**
* @brief WS TX allowance levels.
*/
typedef enum {
/** Allow transmitting only on TX slots. */
WS_TX_SLOT,
/** Allow transmitting only on TX and RX slots. */
WS_TX_AND_RX_SLOT,
/** Allow transmitting always. Also unicast on broadcast channel. */
WS_TX_ALWAYS
} fhss_ws_tx_allow_level;

/**
* @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.
* @param fhss_api FHSS instance.
* @param global_level Level of TX allowance in normal mode.
* @param ef_level Level of TX allowance in expedited forwarding mode.
* @return 0 on success, -1 on fail.
*/
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);

#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion nanostack/mac_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ typedef void mcps_data_request(const mac_api_t *api, const mcps_data_req_t *data
* @param data MCPS-DATA.request specific values
* @param ie_ext Information element list to MCPS-DATA.request
* @param asynch_channel_list Optional channel list to asynch data request. Give NULL when normal data request.
* @param priority Data request priority level
*
* Asynch data request is mac standard extension. asynch_channel_list include channel mask which channel message is requested to send.
*/
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);
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);

/**
* @brief mcps_purge_request MCPS_PURGE request call
Expand Down
12 changes: 12 additions & 0 deletions nanostack/mac_mcps.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,17 @@ typedef struct mcps_edfe_response_s {
bool use_message_handle_to_discover: 1; /**< EDFE Data request message ID is valid at message_handle. */
} mcps_edfe_response_t;

/**
* @brief enum mac_data_priority_t Data request priority level
*
* Data request priority level may affect CCA process and MAC queue process
*/
typedef enum mac_data_priority_e {
MAC_DATA_NORMAL_PRIORITY = 0, /**< Normal MCPS DATA REQ */
MAC_DATA_MEDIUM_PRIORITY = 1, /**< Indirect Data which is polled */
MAC_DATA_HIGH_PRIORITY = 2, /**< MAC command usually use this and beacon */
MAC_DATA_EXPEDITE_FORWARD = 3 /**< Expedite forward level give highest priority */
} mac_data_priority_t;


#endif // MAC_MCPS_H
13 changes: 13 additions & 0 deletions nanostack/mlme.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ typedef enum {
macAutoRequestKeyIndex = 0x7b, /*<The index of the key used for automatic data*/
macDefaultKeySource = 0x7c, /*<Default key source*/
//NON standard extension
macRequestRestart = 0xf1, /*< Configure failed packet data request restart */
macEdfeForceStop = 0xf2, /*< Use this command for Data wait timeout at LLC: Mac stop Edfe session data wait and enable normal FHSS mode */
macSetDataWhitening = 0xf3, /*< Enable or disable data whitening, boolean true for enable, false for disable */
macCCAThresholdStart = 0xf4, /*< Start automatic CCA threshold */
Expand Down Expand Up @@ -517,4 +518,16 @@ typedef struct mlme_multi_csma_ca_s {
uint16_t multi_cca_interval; /**< Length of the additional CSMA-CA period(s) in microseconds */
} mlme_multi_csma_ca_param_t;

/**
* @brief struct mlme_request_restart_config_s Set failed packet request restart configuration
*
* Non standard extension to restart data request after failed CCA or TX attempts
*/
typedef struct mlme_request_restart_config_s {
uint8_t cca_failure_restart_max; /**< Max number of restarts after CCA failure */
uint8_t tx_failure_restart_max; /**< Max number of restarts after TX failure */
uint16_t blacklist_min_ms; /**< Blacklist min, which is doubled by every restart */
uint16_t blacklist_max_ms; /**< Blacklist max, largest allowed blacklist time */
} mlme_request_restart_config_t;

#endif /* MLME_H_ */
1 change: 1 addition & 0 deletions nanostack/platform/arm_hal_phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ typedef enum {
PHY_LINK_TX_SUCCESS, /**< MAC TX complete. MAC will a make decision to enter wait ACK or TX done state. */
PHY_LINK_TX_FAIL, /**< Link TX process fail. */
PHY_LINK_CCA_FAIL, /**< RF link CCA process fail. */
PHY_LINK_CCA_FAIL_RX, /**< RF link CCA process failed because of packet reception. */
PHY_LINK_CCA_OK, /**< RF link CCA process ok. */
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 */
} phy_link_tx_status_e;
Expand Down
49 changes: 49 additions & 0 deletions nanostack/socket_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,41 @@ extern "C" {
* After the successful state change, data can be sent using socket_send().
* The connection can be shut down in either direction with socket_shutdown() function - shutting down write signals end-of-data to the peer.
*
*
* \section socket-udpicmp How to use UDP and RAW socket:
*
* 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.
* Data can be transmitted with the socket_sendto() function. An ICMP socket works with same function call.
*
* \section socket-trafficpriority How to set socket message priority to improve Quality of Service (QoS):
*
* IPv6 header has a field traffic class that contains a 6-bit Differentiated Services Code Point (DSCP) field that is used for packet
* classification. By default the packet class level is set to 0 NS_DSCP_DEFAULT.
*
* Recommend QoS levels:
*
* | Level |Description |
* | :--------------: | :-------------------------------------------------------------------------------------------------: |
* | NS_DSCP_DEFAULT | Default level for normal data usage |
* | NS_DSCP_AF11 | Higher Application data service for prioritize packet forwarding. |
* | NS_DSCP_EF | Expedited Forwarding (EF) for short messages. Allows low loss, low delay, and low jitter services. |
* | | This is meant for very important messages like alerts. EF packet length should be kept in |
* | | minimum. This should not be used for any other purpose as it will block other network traffic |
* | NS_DSCP_CS6 | Network protocol message Priority. Application should not use this. |
*
* High priority messages can be set to use higher than default class by using socket_setsockopt() and
* socket_option_traffic_class_dsc_set() helper.
*
* Example to send a message using Expedited Forwarding class:
*
* //Set EF class to high priority messages
* int16_t traffic_class = socket_option_traffic_class_dsc_set(NS_DSCP_EF);
* socket_setsockopt(socket_id, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_TCLASS, &traffic_class, sizeof traffic_class);
*
* //Set traffic class back to default
* traffic_class = socket_option_traffic_class_dsc_set(NS_DSCP_DEFAULT);
* socket_setsockopt(socket_id, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_TCLASS, &traffic_class, sizeof traffic_class);
*
*/

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

/** \name Socket DSCP (Differentiated Services Code Point) QoS level examples.
* \anchor MSG_QOS_LEVELS
*/
///@{
/** Standard priority and it is socket default */
#define NS_DSCP_DEFAULT 0
/** Application high priority service: Stack priorities these messages over the default priority messages */
#define NS_DSCP_AF11 10
/** Expedited Forwarding (EF) QoS level enable high priority state: low loss, low delay, and low jitter services */
#define NS_DSCP_EF 46
/** Network protocol traffic allocated QoS level stack may internally use that */
#define NS_DSCP_CS6 48
///@}

/** Helper Traffic class Differentiated Services Code for QoS 0-63. 0 is default which define Lowest Priority
*
* */
#define socket_option_traffic_class_dsc_set(x) (uint8_t)((x & 63) << 2)

/** \name Alignment macros for control message headers
* \anchor CMSG_ALIGN_FLAGS
Expand Down
95 changes: 95 additions & 0 deletions nanostack/ws_management_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ extern "C" {
#define NETWORK_SIZE_XLARGE 0x19 /**< 2500+ devices */
#define NETWORK_SIZE_AUTOMATIC 0xFF /**< Automatic network size */

/**
* \brief Neighbor type to differentiate the Role of the neighbor.
*/

typedef enum {
WS_OTHER = 0, /**< temporary or soon to be removed neighbor*/
WS_PRIMARY_PARENT, /**< Primary parent used for upward packets and used from Border router downwards*/
WS_SECONDARY_PARENT, /**< Secondary parent reported to border router and might be used as alternate route*/
WS_CANDIDATE_PARENT, /**< Candidate neighbor that is considered as parent if there is problem with active parents*/
WS_CHILD /**< Child with registered address*/
} ws_management_neighbor_type_e;


/** Temporary API change flag. this will be removed when new version of API is implemented on applications
*
*/
Expand Down Expand Up @@ -127,6 +140,47 @@ typedef struct ws_statistics {
uint32_t asynch_tx_count;
/** Asynch RX counter */
uint32_t asynch_rx_count;


/** Time spent in individual Wi-SUN join state 1 Discovery*/
uint32_t join_state_1;
/** Time spent in individual Wi-SUN join state 2 Authentication*/
uint32_t join_state_2;
/** Time spent in individual Wi-SUN join state 3 Configuration learn*/
uint32_t join_state_3;
/** Time spent in individual Wi-SUN join state 4 RPL parent discovery*/
uint32_t join_state_4;
/** Time spent in individual Wi-SUN join state 5 Active state*/
uint32_t join_state_5;


/** Amount of Wi-SUN Pan Advertisement Solicit Message sent*/
uint32_t sent_PAS;
/** Amount of Wi-SUN Pan Advertisement Message sent*/
uint32_t sent_PA;
/** Amount of Wi-SUN Pan Configuration Solicit Message sent*/
uint32_t sent_PCS;
/** Amount of Wi-SUN Pan Configuration Message sent*/
uint32_t sent_PC;

/** Amount of Wi-SUN Pan Advertisement Solicit Message sent*/
uint32_t recv_PAS;
/** Amount of Wi-SUN Pan Advertisement Message sent*/
uint32_t recv_PA;
/** Amount of Wi-SUN Pan Configuration Solicit Message sent*/
uint32_t recv_PCS;
/** Amount of Wi-SUN Pan Configuration Message sent*/
uint32_t recv_PC;

/** New Neighbours found */
uint32_t Neighbour_add;
/** New Neighbours Removed */
uint32_t Neighbour_remove;
/** New Child added */
uint32_t Child_add;
/** Child lost */
uint32_t child_remove;

} ws_statistics_t;

/**
Expand All @@ -149,6 +203,28 @@ typedef struct ws_stack_info {
uint8_t join_state;
} ws_stack_info_t;

/**
* \brief Struct ws_neighbour_info_t Gives the neighbour information.
*/
typedef struct ws_neighbour_info {
/** Link local address*/
uint8_t link_local_address[16];
/** Global address if it is known set to 0 if not available*/
uint8_t global_address[16];
/** parent RSSI Out measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
uint8_t rsl_out;
/** parent RSSI in measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
uint8_t rsl_in;
/** RPL Rank value for parents 0xffff for neighbors RANK is unknown*/
uint16_t rpl_rank;
/** Measured ETX value if known set to 0xFFFF if not known or Child*/
uint16_t etx;
/** Remaining lifetime Link lifetime for parents and ARO lifetime for children*/
uint32_t lifetime;
/** Neighbour type (Primary Parent, Secondary Parent, Candidate parent, child, other(Temporary neighbours))*/
ws_management_neighbor_type_e type;
} ws_neighbour_info_t;

/**
* Initialize Wi-SUN stack.
*
Expand Down Expand Up @@ -752,6 +828,25 @@ int ws_stack_info_get(
int8_t interface_id,
ws_stack_info_t *info_ptr);

/**
* Get Neighbor table information from stack.
*
* To allocate correct amount of memory first use the API with NULL to get current amount
* of neighbors. Then Allocate the memory and call the function to fill the table.
*
* \param interface_id Network interface ID.
* \param neighbor_ptr Pointer to memory where Neighbor table entries can be written.
* \param count amount of neighbor table entries allocated to memory.
*
* \return >=0 Success with amount of entries written in table.
* \return >=0 if neighbor_ptr is NULL returns the amount of neighbors currently.
* \return <0 Failure.
*/
int ws_neighbor_info_get(
int8_t interface_id,
ws_neighbour_info_t *neighbor_ptr,
uint16_t count);

/**
* Set minimum RF sensitivity acceptable for the parent selection
*
Expand Down
21 changes: 18 additions & 3 deletions source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@
#define TRACE_GROUP "6lo"

/* Data rate for application used in Stagger calculation */
#define STAGGER_DATARATE_FOR_APPL(n) ((n)*25/100)
#define STAGGER_DATARATE_FOR_APPL(n) ((n)*75/100)

/* Time after network is considered stable and smaller stagger values can be given*/
#define STAGGER_STABLE_NETWORK_TIME 3600*4

#ifdef HAVE_RPL
rpl_domain_t *protocol_6lowpan_rpl_domain;
Expand Down Expand Up @@ -839,7 +842,7 @@ bool protocol_6lowpan_stagger_estimate_get(int8_t interface_id, uint32_t data_am
datarate = 250000;
} else if (ws_info(cur_interface)) {
network_size = ws_common_network_size_estimate_get(cur_interface);
datarate = ws_common_datarate_get(cur_interface);
datarate = ws_common_usable_application_datarate_get(cur_interface);
} else {
// 6LoWPAN ND
network_size = 1000;
Expand All @@ -850,11 +853,23 @@ bool protocol_6lowpan_stagger_estimate_get(int8_t interface_id, uint32_t data_am
// If no data amount given, use 1kB
data_amount = 1;
}
if (datarate < 25000) {
// Minimum data rate used in calculations is 25kbs to prevent invalid values
datarate = 25000;
}

/*
* Do not occupy whole bandwidth, leave space for network formation etc...
*/
datarate = STAGGER_DATARATE_FOR_APPL(datarate);
if (ws_info(cur_interface) &&
(ws_common_connected_time_get(cur_interface) > STAGGER_STABLE_NETWORK_TIME || ws_common_authentication_time_get(cur_interface) == 0)) {
// After four hours of network connected full bandwidth is given to application
// Authentication has not been required during bootstrap so network load is much smaller
} else {
// Smaller data rate allowed as we have just joined to the network and Authentication was made
datarate = STAGGER_DATARATE_FOR_APPL(datarate);
}

stagger_value = 1 + ((data_amount * 1024 * 8 * network_size) / datarate);
/**
* Example:
Expand Down
Loading

0 comments on commit 0903b81

Please sign in to comment.