Skip to content

Commit

Permalink
Revert "Improved transmission in high traffic (ARMmbed#2511)" (ARMmbe…
Browse files Browse the repository at this point in the history
…d#2512)

This reverts commit 01749c2.
  • Loading branch information
Jarkko Paso committed Dec 8, 2020
1 parent 01749c2 commit b956d9e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 57 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* Added trace for mbed TLS errors
* Optimized medium size network MPL parameters for 40 seconds multicast interval
* Added traces to EAPOL TX failure
* Improved handling of packet transmissions under heavy load
* Added traces to Adaptation layer for Direct TX queue level decrease or increase by 20
* New Network statitis info for Randon early detetction dropped packet at Adaptation layer.

Expand Down
3 changes: 1 addition & 2 deletions source/MAC/IEEE802_15_4/mac_mcps_sap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2321,9 +2321,8 @@ static mac_pre_build_frame_t *mcps_sap_pd_req_queue_read(protocol_interface_rf_m
// With FHSS, check TX conditions
if (rf_mac_setup->fhss_api) {
while (buffer) {
uint16_t frame_length = buffer->mac_payload_length + buffer->headerIeLength + buffer->payloadsIeLength;
if (buffer->asynch_request || (flush == true) || (rf_mac_setup->fhss_api->check_tx_conditions(rf_mac_setup->fhss_api, !mac_is_ack_request_set(buffer),
buffer->msduHandle, mac_convert_frame_type_to_fhss(buffer->fcf_dsn.frametype), frame_length,
buffer->msduHandle, mac_convert_frame_type_to_fhss(buffer->fcf_dsn.frametype), buffer->mac_payload_length,
rf_mac_setup->dev_driver->phy_driver->phy_header_length, rf_mac_setup->dev_driver->phy_driver->phy_tail_length) == true)) {
break;
}
Expand Down
78 changes: 28 additions & 50 deletions source/Service_Libs/fhss/fhss_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@ void fhss_set_txrx_slot_length(fhss_structure_t *fhss_structure)

static uint32_t fhss_get_number_of_tx_slots(fhss_structure_t *fhss_structure)
{
if (!fhss_structure->ws->txrx_slot_length_ms) {
return 0;
}
return ((fhss_structure->ws->fhss_configuration.fhss_broadcast_interval - fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval) / fhss_structure->ws->txrx_slot_length_ms) / 2;
}

Expand Down Expand Up @@ -367,40 +364,23 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
next_channel = fhss_structure->rx_channel;
/* Start timer with random timeout to trigger unicast TX queue poll event.
* For hops 0,1,4,5,8,9,...
* In high traffic:
* Min random is 1/1000 of the TX slot length.
* Max random is 1/100 of the TX slot length.
* Otherwise:
* Min random is 1/100 of the TX slot length.
* Max random is 1/5 of the TX slot length.
*
* For hops 2,3,6,7,10,11,...
* Min random is 1/1000 of the TX slot length plus 0.5*TX slot length.
* Max random is 1/100 of the TX slot length plus 0.5*TX slot length.
* Min random is 1/100 of the TX slot length plus 0.5*TX slot length.
* Max random is 1/10 of the TX slot length plus 0.5*TX slot length.
* Event timer resolution is 50us.
*/
// returns 1 if polling of TX queue is done on latter half of the TX slot
uint8_t own_tx_trig_slot = calc_own_tx_trig_slot(fhss_structure->own_hop);
uint32_t txrx_slot_length_us = MS_TO_US(fhss_structure->ws->txrx_slot_length_ms);
uint16_t queue_size = fhss_structure->callbacks.read_tx_queue_size(fhss_structure->fhss_api, false);
uint16_t uc_min_random, uc_max_random;
uint32_t tx_slot_shift_us = (txrx_slot_length_us) / 50;
uint32_t half_tx_slot_shift_us = tx_slot_shift_us / 2;
// For busy or latter half of the TX slot polling devices, use short random
if (queue_size >= QUEUE_SIZE_HIGH || calc_own_tx_trig_slot(fhss_structure->own_hop)) {
uc_min_random = ((txrx_slot_length_us / 1000) / 50);
uc_max_random = ((txrx_slot_length_us / 100) / 50);
} else {
uc_min_random = ((txrx_slot_length_us / 100) / 50);
uc_max_random = ((txrx_slot_length_us / 5) / 50);
}
// Shift for latter half of the TX slot
if (calc_own_tx_trig_slot(fhss_structure->own_hop)) {
uc_min_random += half_tx_slot_shift_us;
uc_max_random += half_tx_slot_shift_us;
}
// Shift for own TX slot
if (!fhss_ws_check_tx_allowed(fhss_structure)) {
uc_min_random += tx_slot_shift_us;
uc_max_random += tx_slot_shift_us;
uint16_t uc_min_random = (((txrx_slot_length_us / 2) * own_tx_trig_slot) / 50) + ((txrx_slot_length_us / 100) / 50);
uint16_t uc_max_random = (((txrx_slot_length_us / 2) * own_tx_trig_slot) / 50) + ((txrx_slot_length_us / 5) / 50);
bool tx_allowed = fhss_ws_check_tx_allowed(fhss_structure);
if (!tx_allowed) {
uc_min_random += (txrx_slot_length_us) / 50;
uc_max_random += (txrx_slot_length_us) / 50;
}
eventOS_callback_timer_start(fhss_structure->fhss_event_timer, randLIB_get_random_in_range(uc_min_random, uc_max_random));

Expand Down Expand Up @@ -730,28 +710,26 @@ static bool fhss_ws_check_tx_allowed(fhss_structure_t *fhss_structure)

static bool fhss_ws_check_tx_time(fhss_structure_t *fhss_structure, uint16_t tx_length, uint8_t phy_header_length, uint8_t phy_tail_length)
{
bool retval = true;
if (fhss_structure->own_hop != 0xff && fhss_structure->ws->fhss_configuration.fhss_broadcast_interval && fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval && fhss_get_number_of_tx_slots(fhss_structure)) {
uint32_t tx_time_ms = US_TO_MS(fhss_get_tx_time(fhss_structure, tx_length, phy_header_length, phy_tail_length));
// Check if there is enough time for transmitting before the next RX slot. Check only for devices which are polling TX queue in the beginning of TX slot.
if (!calc_own_tx_trig_slot(fhss_structure->own_hop)) {
uint32_t remaining_time_ms = get_remaining_slots_us(fhss_structure, fhss_broadcast_handler, MS_TO_US(fhss_structure->ws->fhss_configuration.fhss_broadcast_interval)) / 1000;
uint32_t tx_slot_begin_ms = (fhss_structure->ws->fhss_configuration.fhss_broadcast_interval - fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval) - (fhss_structure->ws->txrx_slot_length_ms * (fhss_structure->own_hop & 1));
tx_slot_begin_ms = tx_slot_begin_ms - (((tx_slot_begin_ms - remaining_time_ms) / (2 * fhss_structure->ws->txrx_slot_length_ms)) * (2 * fhss_structure->ws->txrx_slot_length_ms));
uint32_t rx_slot_begin_ms = tx_slot_begin_ms - fhss_structure->ws->txrx_slot_length_ms;
if ((remaining_time_ms < rx_slot_begin_ms) || ((remaining_time_ms - rx_slot_begin_ms) < tx_time_ms)) {
retval = false;
}
}
// Check if there is enough time for transmitting before the next multicast slot.
/*
* Check if there is enough time for transmitting before the next multicast slot.
*/
#ifdef FHSS_WS_PROTECT_MC_SLOTS
uint32_t time_to_bc_channel_ms = US_TO_MS(get_remaining_slots_us(fhss_structure, fhss_broadcast_handler, MS_TO_US(fhss_structure->ws->fhss_configuration.fhss_broadcast_interval)));
if (tx_time_ms > time_to_bc_channel_ms) {
retval = false;
}
#endif
if (!fhss_structure->ws->fhss_configuration.fhss_broadcast_interval || !fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval) {
return true;
}
return retval;
uint32_t tx_time = fhss_get_tx_time(fhss_structure, tx_length, phy_header_length, phy_tail_length);
uint32_t time_to_bc_channel_us = get_remaining_slots_us(fhss_structure, fhss_broadcast_handler, MS_TO_US(fhss_structure->ws->fhss_configuration.fhss_broadcast_interval));
if (tx_time > time_to_bc_channel_us) {
return false;
}
return true;
#else
(void) fhss_structure;
(void) tx_length;
(void) phy_header_length;
(void) phy_tail_length;
return true;
#endif
}

static bool fhss_ws_check_tx_conditions_callback(const fhss_api_t *api, bool is_broadcast_addr, uint8_t handle, int frame_type, uint16_t frame_length, uint8_t phy_header_length, uint8_t phy_tail_length)
Expand Down
6 changes: 2 additions & 4 deletions source/Service_Libs/fhss/fhss_ws.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@
#define FHSS_WS_H_

// TX slot length is optimised to this packet length
#define OPTIMAL_PACKET_LENGTH 700
#define OPTIMAL_PACKET_LENGTH 500
// Default TX/RX slot length in milliseconds. Is used when datarate is not given by PHY.
#define WS_TXRX_SLOT_LEN_MS 205
#define WS_TXRX_SLOT_LEN_MS 100
// Default minimum broadcast synchronization interval in seconds
#define DEFAULT_MIN_SYNCH_INTERVAL 60
// Drift compensation allowed if at least SYNCH_COMPENSATION_MIN_INTERVAL (seconds) since last synchronization
#define SYNCH_COMPENSATION_MIN_INTERVAL 60
// MAX compensation per received synchronization info in ns
#define MAX_DRIFT_COMPENSATION_STEP 10
// Goes to more rapid transmission mode when this limit is exceeded
#define QUEUE_SIZE_HIGH 5
typedef struct fhss_ws fhss_ws_t;

struct fhss_ws {
Expand Down

0 comments on commit b956d9e

Please sign in to comment.