Skip to content

Wi-SUN interface implementation. #8600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 22, 2018

Conversation

KariHaapalehto
Copy link
Contributor

This is a initial version of Wi-SUN interface implementation.
To get Wi-SUN mesh network working, also nanostack with Wi-Sun support is needed. ws_empty_functions.c and ws_management_api.h are temporary included here,
so that wisun_tasklet will compiled without problems.
They will replaced with the official versions with next nanostack release.

Description

Tested locally with Nucleo_F429ZI

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[X] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

@0xc0170 0xc0170 requested a review from a team October 31, 2018 10:35
@0xc0170
Copy link
Contributor

0xc0170 commented Oct 31, 2018

travis-ci/astyle — Passed, 547 files (+2 files)

@KariHaapalehto Can you run astyle on the changes (features are currently being updated so would like avoiding new styling issues) ?

To get Wi-Sun mesh network working, also nanostack with Wi-Sun support
is needed. ws_empty_functions.c and ws_management_api.h are temporary
included here, so that wisun_tasklet will compiled without problems.
They will replaced with the official versions with next nanostack release.
@0xc0170 0xc0170 requested a review from a team October 31, 2018 13:49
@KariHaapalehto
Copy link
Contributor Author

AStyle fixes done

@KariHaapalehto
Copy link
Contributor Author

@artokin @juhhei01 @mikter @JarkkoPaso for your information

"value": 0
},
"wisun-device-type": {
"help": "Device mode (NET_6LOWPAN_ROUTER or NET_6LOWPAN_HOST). Router is routing packets from other device, creating a mesh network.",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently supported modes are border router and router. but through mesh API I don't know if border router is wanted at all

@mikter
Copy link

mikter commented Nov 2, 2018

@JarkkoPaso please check

"help": "Device mode (NET_6LOWPAN_ROUTER or NET_6LOWPAN_HOST). Router is routing packets from other device, creating a mesh network.",
"value": "NET_6LOWPAN_ROUTER"
},
"wisun-nd-channel-mask": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channel mask in wish goes from 0 to maximum amount of channels defined by regulatory domain and class. the maximum amount possible is 8* uint32

"help": "Channel mask, bit-mask of channels to use. [0-0x07fff800]",
"value": "0x7fff800"
},
"wisun-nd-channel-page": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channel page is not needed in wi-SUN

"value": 0
},
"wisun-nd-channel": {
"help": "RF channel to use when `channel_mask` is not defined. [0-26].",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed in wi-SUN

"value": 0
},
"wisun-nd-panid-filter": {
"help": "Beacon PAN ID filter, 0xffff means no filtering. [0-0xffff]",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed in Wi-SUN

wisun_tasklet_data_ptr->channel_list.channel_page = (channel_page_e)MBED_CONF_MBED_MESH_API_WISUN_ND_CHANNEL_PAGE;
wisun_tasklet_data_ptr->channel_list.channel_mask[0] = MBED_CONF_MBED_MESH_API_WISUN_ND_CHANNEL_MASK;

if (channel > 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Channel mask and channel selection is not needed to Wi-SUN

arm_nwk_6lowpan_link_nwk_id_filter_for_nwk_scan(wisun_tasklet_data_ptr->network_interface_id, NULL);

arm_nwk_6lowpan_link_panid_filter_for_nwk_scan(
wisun_tasklet_data_ptr->network_interface_id,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed for Wi-SUN


// Enable MPL by default
const uint8_t all_mpl_forwarders[16] = {0xff, 0x03, [15] = 0xfc};
multicast_mpl_domain_subscribe(wisun_tasklet_data_ptr->network_interface_id,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not Needed for Wi-SUN

tr_error("MAC Address read fail\n");
} else {
uint8_t temp[2];
common_write_16_bit(app_link_address_info.mac_short, temp);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mac16 not used in wi-SUN

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is true

tr_debug("IID (Based on MAC 64-bit address): %s", trace_array(app_link_address_info.iid_eui64, 8));
}

tr_debug("Channel: %d", arm_net_get_current_channel(wisun_tasklet_data_ptr->network_interface_id));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Channel is meaningless in channel hopping network do you really need this?

network_layer_address_s app_nd_address_info;
link_layer_address_s app_link_address_info;
uint8_t temp_ipv6[16];
if (arm_nwk_nd_address_read(wisun_tasklet_data_ptr->network_interface_id, &app_nd_address_info) != 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know do these give meaningless information ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove these

Copy link
Contributor

@juhhei01 juhhei01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for me.

"value": 0
},
"wisun-bc-dwell-interval": {
"help": "Broadcast dwell interval. Range: 15-250 milliseconds",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They have changed the dwell time range to 15-255ms in new spec. I know, it is still wrong in nanostack api also. Same thing in wisun-uc-dwell-interval.

Copy link
Contributor

@jarlamsa jarlamsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the typo now to prevent issues later

"help": "default network name for wisun network",
"value": "\"NETWORK_NAME\""
},
"wisun-regulator-domain": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix typo: regulatory domain, also need to change to the tasklet code.

wisun_tasklet_data_ptr->operating_mode_extension);

ws_management_node_init(wisun_tasklet_data_ptr->network_interface_id,
MBED_CONF_MBED_MESH_API_WISUN_REGULATOR_DOMAIN,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regulatory

fhss_timer_ptr);

tr_debug("Domain: %d, mode: %d, class: %d, network name: %s",
MBED_CONF_MBED_MESH_API_WISUN_REGULATOR_DOMAIN,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regulatory


tr_debug("Domain: %d, mode: %d, class: %d, network name: %s",
MBED_CONF_MBED_MESH_API_WISUN_REGULATORY_DOMAIN,
MBED_CONF_MBED_MESH_API_WISUN_OPERATING_MODE,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tracing mode and class is incorrect as those are not set really.

if those values are different from default use for example following way to configure

if (ws_conf.operating_mode != 255 ||
    ws_conf.operating_class != 255 ) {
    ret = ws_management_regulatory_domain_set(mesh->net_rf_id, ws_conf.regulatory_domain, ws_conf.operating_class, ws_conf.operating_mode);
    if (ret != 0) {
        cmd_printf("Regulatory domain configuration failed %"PRIi32"\r\n", ret);
        return CMDLINE_RETCODE_FAIL;
    }
}

@@ -0,0 +1,233 @@
/*
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is public API and is now on wrong place. is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move it to mbed-os\features\nanostack\sal-stack-nanostack\nanostack

char *Nanostack::WisunInterface::get_gateway(char *buf, nsapi_size_t buflen)
{
NanostackLockGuard lock;
if (wisun_tasklet_get_router_ip_address(buf, buflen) == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_gateway is calling wisun_tasklet_get_router_ip_address and getRouterIpAddress is calling get_gateway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implemented just like LOWPANNDInterface.
and WisunInterface::getRouterIpAddress is a api for wisun


// For tracing we need to define flag, have include and define group
//#define HAVE_DEBUG
#define TRACE_GROUP "wisuND"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we want to keep trace group max 4 characters long?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change it for 4 char

@KariHaapalehto
Copy link
Contributor Author

@mikter Any other comments/change request?

// TODO, read interface name from configuration
mac_description_storage_size_t storage_sizes;
storage_sizes.device_decription_table_size = 32;
storage_sizes.key_description_table_size = 6;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 4

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 12, 2018

@jarlamsa Can you rereview?

They will replaced with the official versions with next nanostack release.

@KariHaapalehto When is this happening? for 5.11 or later?

if (wisun_tasklet_data_ptr->tasklet_state != TASKLET_STATE_BOOTSTRAP_READY) {
tr_info("Wi-SUN bootstrap ready");
wisun_tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_READY;
wisun_tasklet_network_state_changed(MESH_CONNECTED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The local ula prefix needs probably to be checked similar to thread_tasklet.c to prevent reporting NSAPI_GLOBAL_UP with only ula prefix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juhhei01 @mikter please comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any comments about this? 6lowpan isn't doing it....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kjbracey-arm can you comment on this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe Wi-SUN has any inherent concept analogous to the "mesh-local" address. Thread only says "local" if it has specifically only the Thread mesh-local address, not any ULA.

I believe the logic was that a standard ULA could equally represent a connection tunnel to a cloud server as well as a site-specific ULA, so we treat ULAs as "global" - we've no idea how many networks we can get with them. There could even be NAT going on, so we have a ULA but NATted global connectivity.

Apps can check to see if "get_ip_address" returns a ULA themselves if they want to distinguish between a ULA or need a real global address.

However, all the IPv6 things should be saying "local" if they only have a link-local address. The Thread stuff is just stretching that to also cover the thread mesh-local link.

Maybe if there was some other was to detect definitely local connectivity? Both 6LoWPAN-ND and Wi-SUN could maybe look at the "grounded" flag of the DODAG. If that was exposed via API, you would be local if clear. But then you'd need an event mechanism for it changing. Would be an extension.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In IPv4, the global is actualy "We have a router and DHCP somewhere" so I think equal state should be indicated here.
I don't know how...

Do we have any API to ask that "is border router alive and does it have a backbone"

Because, the whole distinction between GLOBAL and LOCAL should not be about IP address scope. It should be answer to the question whether there is a route to "somewhere"
yes -> global
no -> local

And that information can be used in Mbed Client: "Should I try the TLS handshake again?" and the answer is the same.
GLOBAL -> yes
other states -> no

So there will most probably be cases where ULA prefix satisfies the requirement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we have any existing logic about route existence, or at least don't recall seeing it.

I think maybe it's just convenient that having an IPv4 address implies a DHCPv4 server, and one assumes that a DHCPv4 server is a router. We assume we don't auto-assign ourselves a "link-local" 169.254.x.x address.

So, IPv6 for LwIP checks for non-link-local IPv6 addresses. As does MeshInterfaceNanostack. "MESH_CONNECTED" is turned into either LOCAL_UP or GLOBAL_UP depending on if we only have a link-local address.

The Thread special case is stopping the mesh-local ULA from being reported as global, as any other ULA is.

So I think this is correct for now - it's plausible to assume if you have a ULA you at least have a router giving out SLAAC prefixes, even if it's not connected to anywhere, just like you assume the same for DHCPv4.

Do we have any API to ask that "is border router alive and does it have a backbone"

Not sure whether it's easily or at all findable via public APIs, but RPL Grounded flag would be it, if the border router is maintaining it correctly. I think that's a general extension for 6LoWPAN-ND and Wi-SUN though - not something for this PR.

Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve - main reservation is on the name capitalisation, but I can live with this is others prefer it this way.

Not inspected the bulk of the code in detail, but I'm assuming it's faithfully cloned from the 6LoWPAN-ND stuff. At some point we should try to reduce the duplication, but this will do for starters.

*
* Configure Nanostack to use Wi-SUN protocol.
*/
class WisunInterface : public MeshInterfaceNanostack {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not WiSUNInterface? We have LoWPANNDInterface with full silly capitalisation for 6LoWPAN-ND. Seems inconsistent, but maybe there's another factor.

if (wisun_tasklet_data_ptr->tasklet_state != TASKLET_STATE_BOOTSTRAP_READY) {
tr_info("Wi-SUN bootstrap ready");
wisun_tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_READY;
wisun_tasklet_network_state_changed(MESH_CONNECTED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe Wi-SUN has any inherent concept analogous to the "mesh-local" address. Thread only says "local" if it has specifically only the Thread mesh-local address, not any ULA.

I believe the logic was that a standard ULA could equally represent a connection tunnel to a cloud server as well as a site-specific ULA, so we treat ULAs as "global" - we've no idea how many networks we can get with them. There could even be NAT going on, so we have a ULA but NATted global connectivity.

Apps can check to see if "get_ip_address" returns a ULA themselves if they want to distinguish between a ULA or need a real global address.

However, all the IPv6 things should be saying "local" if they only have a link-local address. The Thread stuff is just stretching that to also cover the thread mesh-local link.

Maybe if there was some other was to detect definitely local connectivity? Both 6LoWPAN-ND and Wi-SUN could maybe look at the "grounded" flag of the DODAG. If that was exposed via API, you would be local if clear. But then you'd need an event mechanism for it changing. Would be an extension.

#endif

/* Regulatory domain values*/
#define REG_DOMAIN_WW 0x00 // World wide
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obviously for Nanostack, but really all these defines should have WS_ prefixes.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 19, 2018

@KariHaapalehto Can you review latest comments ? Is this targeting 5.11 ? (not yet labeled!)

@KariHaapalehto
Copy link
Contributor Author

Yes, this can be targeted to 5.11.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 20, 2018

@KariHaapalehto @jarlamsa All review comments addressed ? @jarlamsa CAn you update your review feedback here?

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 20, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 20, 2018

Build : SUCCESS

Build number : 3689
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8600/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Nov 20, 2018

@mbed-ci
Copy link

mbed-ci commented Nov 20, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 21, 2018

/morph export-build

@mbed-ci
Copy link

mbed-ci commented Nov 21, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 21, 2018

Exporters failure ^^ pipeline closed, will restart or goes to rollup (most probably rollup )

@cmonr
Copy link
Contributor

cmonr commented Nov 22, 2018

CI started.

@mbed-ci
Copy link

mbed-ci commented Nov 22, 2018

Test run: SUCCESS

Summary: 4 of 4 test jobs passed
Build number : 9
Build artifacts
Build logs

@0xc0170 0xc0170 merged commit f1f6426 into ARMmbed:master Nov 22, 2018
@KariHaapalehto KariHaapalehto deleted the wisuninterface_created branch November 23, 2018 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.