Knight KE / Mbed OS Game_Master
Embed: (wiki syntax)

« Back to documentation index

load_balance_api.h File Reference

load_balance_api.h File Reference

A API class to support 6lowpan network load balance which based on RPL routing. More...

Go to the source code of this file.

Data Structures

struct  load_balance_api
 Struct load_balance_api_s defines functions for two-way communications between load balance and user. More...

Typedefs

typedef void load_balance_beacon_notify (const load_balance_api_t *api, const struct mlme_beacon_ind_s *beacon_ind, uint8_t priority)
 Application which want enable load balance must first create load balance class, e.g 'load_balance_api_t* load_balance_create()' In the function external Nanostack needs to fill necessary function pointers so that Upper layer can use it.
typedef void load_balance_second_ticks (const load_balance_api_t *api)
 load_balance_second_ticks update load balance state timer
typedef void load_balance_enable (const load_balance_api_t *api, bool active_state, uint32_t network_triggle_max_period, uint32_t network_route_life_time)
 load_balance_enabled handler for enabled or disable beacon notify
typedef uint8_t load_balance_priority_get (const void *load_balance_user)
 load_balance_priority_get function for load balance to get current advertisement priority
typedef void load_balance_beacon_tx (const void *load_balance_user)
 load_balance_beacon_tx function for trig periodically beacon
typedef bool load_balance_network_switch_notify (const void *load_balance_user, load_balance_nwk_switch_operation operation, uint16_t *timeout)
 load_balance_network_switch_notify this function will be called by load balance when it have detected better network to switch change state
typedef bool load_balance_network_switch_req (void *load_balance_user, struct mlme_pan_descriptor_s *PANDescriptor, const uint8_t *beacon_payload, uint16_t beacon_payload_length)
 load_balance_network_switch_req this function will be called by load balance when it have detected better network to switch
typedef int8_t load_balance_api_get_node_count (void *lb_user, uint16_t *node_count)
 load_balance_api_get_node_count Get border router registered node count
typedef int8_t load_balance_api_set_load_level (void *lb_user, uint8_t load_level)
 load_balance_api_set_load_level Update new load level to network
typedef int8_t load_balance_api_initialize (load_balance_api_t *api, load_balance_beacon_tx *lb_beacon_tx, load_balance_priority_get *priority_get_cb, load_balance_network_switch_req *lb_nwk_switch_cb, uint16_t beacon_max_payload_length, void *lb_user)
 load_balance_api_initialize Initialises load balancer needed callback.

Functions

load_balance_api_tload_balance_create (load_balance_network_switch_notify *lb_notify_cb, bool activate_periodic_beacon)
 Create load balance class.
int load_balance_delete (load_balance_api_t *api)
 Delete load balance class and free memory.
int load_balance_network_threshold_set (load_balance_api_t *api, uint8_t threshold_min, uint8_t threshold_max)
 Set load balance threshold min and max.
int load_balance_network_load_monitor_enable (load_balance_api_t *api, uint16_t expected_node_count, uint8_t network_load_scaler, load_balance_api_get_node_count *get_count_cb, load_balance_api_set_load_level *set_new_load_cb)
 Enable load balance load monitor and update feature.
int load_balance_network_load_monitor_disable (load_balance_api_t *api)
 Disable load balance load monitor and update feature.
int load_balance_set_max_probability (load_balance_api_t *api, uint8_t max_p)
 Set network probability percent when new network is better than threshold max.
int load_balance_network_switch_cb_set (load_balance_api_t *api, net_load_balance_network_switch_notify *network_switch_notify)
 Set user callback for accepting the network switch.

Detailed Description

A API class to support 6lowpan network load balance which based on RPL routing.

Definition in file load_balance_api.h.


Typedef Documentation

typedef int8_t load_balance_api_get_node_count(void *lb_user, uint16_t *node_count)

load_balance_api_get_node_count Get border router registered node count

Parameters:
lb_userLoad balancing user defined unique data.
node_countPointer where node count is stored
Returns:
-1 Get fail, 0 node_count include current node count

Definition at line 127 of file load_balance_api.h.

typedef int8_t load_balance_api_initialize(load_balance_api_t *api, load_balance_beacon_tx *lb_beacon_tx, load_balance_priority_get *priority_get_cb, load_balance_network_switch_req *lb_nwk_switch_cb, uint16_t beacon_max_payload_length, void *lb_user)

load_balance_api_initialize Initialises load balancer needed callback.

Parameters:
apiload_balance_api_t pointer, which is created by application.
lb_beacon_tx_period_set_cbUpper layer function to handle MCPS confirmations
priority_get_cbUpper layer function to handle MCPS indications
lb_nwk_switch_cb
beacon_max_payload_lengthSet 0 if network switch is disabled otherwise give max supported beacon payload.
lb_userLoad balancing user defined unique data
Returns:
-1 if error, -2 if Out of Memory, 0 otherwise

Definition at line 147 of file load_balance_api.h.

typedef int8_t load_balance_api_set_load_level(void *lb_user, uint8_t load_level)

load_balance_api_set_load_level Update new load level to network

Parameters:
lb_userLoad balancing user defined unique data.
load_levelload level which could be [0,CONFIGURED_SCALER -1]
Returns:
-1 Set fail, 0 New Network Load is updated

Definition at line 135 of file load_balance_api.h.

typedef void load_balance_beacon_notify(const load_balance_api_t *api, const struct mlme_beacon_ind_s *beacon_ind, uint8_t priority)

Application which want enable load balance must first create load balance class, e.g 'load_balance_api_t* load_balance_create()' In the function external Nanostack needs to fill necessary function pointers so that Upper layer can use it.

For load balance user define:

  • load_balance_beacon_notify: Beacon notify should call this api
  • load_balance_api_initialize: Initialise load balance class with next function pointer
  • load_balance_enable Load Balance requested function pointers
  • load_balance_priority_get
  • load_balance_network_switch_req
  • load_balance_beacon_interval_set load_balance_beacon_notify
    Parameters:
    apiload_balance_api_t pointer
    beacon_indstandard beacon indication structure
    priorityBeacon parsed network priority

Definition at line 63 of file load_balance_api.h.

typedef void load_balance_beacon_tx(const void *load_balance_user)

load_balance_beacon_tx function for trig periodically beacon

Parameters:
load_balance_userpointer to load balancer user initialised data

Definition at line 95 of file load_balance_api.h.

typedef void load_balance_enable(const load_balance_api_t *api, bool active_state, uint32_t network_triggle_max_period, uint32_t network_route_life_time)

load_balance_enabled handler for enabled or disable beacon notify

Parameters:
load_balance_api_tpointer
active_statetrue enable load balancer and false disable
network_triggle_max_periodtime that load balance will send periodic beacon
network_route_life_timetime for device route lifetime

Definition at line 78 of file load_balance_api.h.

typedef bool load_balance_network_switch_notify(const void *load_balance_user, load_balance_nwk_switch_operation operation, uint16_t *timeout)

load_balance_network_switch_notify this function will be called by load balance when it have detected better network to switch change state

Parameters:
load_balance_userpointer to load balancer user initialised data
operationnetwork switch operation
timeoutpointer where operation time must be define NULL when load balance not need time out or user set 0
Returns:
true Network switching can be performed immediately
false Network switching will be performed later

Definition at line 106 of file load_balance_api.h.

typedef bool load_balance_network_switch_req(void *load_balance_user, struct mlme_pan_descriptor_s *PANDescriptor, const uint8_t *beacon_payload, uint16_t beacon_payload_length)

load_balance_network_switch_req this function will be called by load balance when it have detected better network to switch

Parameters:
load_balance_userpointer to load balancer user initialised data
PANDescriptorpointer to link and coordinator info
beacon_payloadbeacon payload pointer for new network
beacon_payload_lengthpayload length
Returns:
true network switch started
false network switch fail

Definition at line 118 of file load_balance_api.h.

typedef uint8_t load_balance_priority_get(const void *load_balance_user)

load_balance_priority_get function for load balance to get current advertisement priority

Parameters:
load_balance_userpointer to load balancer user initialised data
Returns:
priority

Definition at line 88 of file load_balance_api.h.

load_balance_second_ticks update load balance state timer

Parameters:
load_balance_api_tpointer

Definition at line 69 of file load_balance_api.h.


Function Documentation

load_balance_api_t* load_balance_create ( load_balance_network_switch_notify lb_notify_cb,
bool  activate_periodic_beacon 
)

Create load balance class.

Parameters:
lb_notify_cbuser callback for accept network switch
activate_periodic_beaconTrue define that load balance will generate periodic beacon based configured value at enable
Returns:
Pointer to load balance class

Definition at line 489 of file load_balance.c.

int load_balance_delete ( load_balance_api_t api )

Delete load balance class and free memory.

Parameters:
apiClass pointer to deleted class
Returns:
0 process ok -1 Unknown class

Definition at line 508 of file load_balance.c.

int load_balance_network_load_monitor_disable ( load_balance_api_t api )

Disable load balance load monitor and update feature.

Parameters:
apiClass pointer to deleted class
Returns:
0 process ok -1 Unknown class

Definition at line 558 of file load_balance.c.

int load_balance_network_load_monitor_enable ( load_balance_api_t api,
uint16_t  expected_node_count,
uint8_t  network_load_scaler,
load_balance_api_get_node_count get_count_cb,
load_balance_api_set_load_level set_new_load_cb 
)

Enable load balance load monitor and update feature.

This feature is for border router's defined function for give network scale and load parameter what load balancer will follow automatically.

Parameters:
apiClass pointer to deleted class
expected_node_countnode which define max load to network
network_load_scalerDefine max load value
get_count_cbfunction pointer for read current node count
set_new_load_cbfunction pointer what is called when load level must be update
Returns:
0 process ok -1 Unknown class or unsupported parameter

Definition at line 531 of file load_balance.c.

int load_balance_network_switch_cb_set ( load_balance_api_t api,
net_load_balance_network_switch_notify network_switch_notify 
)

Set user callback for accepting the network switch.

Parameters:
apiClass pointer to deleted class.
network_switch_notifyUser callback.
Returns:
0 Set OK.
-1 unknown Interface.

Definition at line 583 of file load_balance.c.

int load_balance_network_threshold_set ( load_balance_api_t api,
uint8_t  threshold_min,
uint8_t  threshold_max 
)

Set load balance threshold min and max.

Nework switch will work next diff_priority >= randLIB_get_random_in_range(threshold_min, threshold_max) --> switch network if true For border router Disable Network compare set threshold_min and threshold_max to 0.

Parameters:
apiClass pointer to deleted class
threshold_minminimal threshold value for network switch
threshold_maxmax threshold value for network switch
Returns:
0 process ok -1 Unknown class or unsupported threshold

Definition at line 519 of file load_balance.c.

int load_balance_set_max_probability ( load_balance_api_t api,
uint8_t  max_p 
)

Set network probability percent when new network is better than threshold max.

Parameters:
apiClass pointer to deleted class
max_pis percent probability to switch network. Default is 25%. Accepted values are [1,100] recommend values are 10-25.
Returns:
0 process ok -1 Unknown class or unsupported parameter

Definition at line 567 of file load_balance.c.