Skip to content

Various clarifications for NetworkInterface state and connection #957

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 8 commits into from
Feb 27, 2019
Merged

Various clarifications for NetworkInterface state and connection #957

merged 8 commits into from
Feb 27, 2019

Conversation

SeppoTakalo
Copy link
Contributor

@SeppoTakalo SeppoTakalo commented Feb 20, 2019

This PR addresses various issues reported:

  • ONME-4168: Clarify how the network interface behaves for 6LoWPAN networks.
  • ONME-4184: Document multihoming limitations
  • ONME-4165: Clarify Asynchronous operation of NetworkInterface
  • ONME-4185: Clarify network state changes
  • Add missing documentation of Allows multiple network status listeners mbed-os#9424

It should clarify now all network interface state changes, and how different interfaces might implement those. It also addresses how you should use the interface asynchronously(non-blocking) and how return values differ there.

The image supplied should replace existing diagram from here: https://s3-us-west-2.amazonaws.com/mbed-os-docs-images/NetworkinterfaceStates.png

Some of the bundled changes only apply to Mbed OS 5.12, so this is targeting it.

Also, I have code-dependency to ARMmbed/mbed-os#9387 which should be merged soon.

Fixes #936

@SeppoTakalo
Copy link
Contributor Author

@kjbracey-arm Please review the content.

@yogpan01 @teetak01 @anttiylitokola @JanneKiiskila Please review from Client point of view. I have seen that the Client has some assumption on undocumented behaviour of NetworkInterface::connect() APIs, and there has been some uncertainty of network states as well. Please provide feedback whether I have addressed those issues in a sufficient level and whether there are viewpoints that I am still missing.

The content here might affect how the non-blocking operations and network status listeners are going to be implemented.

Thanks.


The interface handles all state changes itself between `Connecting`, `Local connectivity` and `Global route found`. Calling `NetworkInterface::connect()` might return when either local or global connectivity states are reached. This depends on the connectivity. For example, Ethernet and Wi-Fi interfaces return when global connectivity is reached. 6LoWPAN-based mesh networks depend on the standard you're using. 6LoWPAN-ND returns when it connects to a border router that provides global connection. The thread returns when you create a local mesh network and may later get global connection when it finds a border router.
The interface handles all state changes itself between `Connecting`, `Local connectivity` and `Global route found`. Calling `NetworkInterface::connect()` might return when either local or global connectivity states are reached. This depends on the connectivity. For example, Ethernet and Wi-Fi interfaces return when global connectivity is reached. 6LoWPAN-based mesh networks depend on the standard you're using. The `LoWPANNDInterface` returns from `connect()` call when it connects to a border router that provides global connection. The `ThreadInterface` returns from `connect()` call when it joins a local mesh network. It may later get global connection when it finds a border router.
Copy link

Choose a reason for hiding this comment

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

Better some questions though.

"might return" when might it not return?

"This depends on the connectivity" I can assume this is referring to WiFi, Ethernet, 6LoWPAN, Cellular, etc.
However does "connectivity" correlate to a particular network layer and would it be useful to reference said layer?

Copy link

@0Grit 0Grit Feb 20, 2019

Choose a reason for hiding this comment

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

To answer my own connectivity question. No? Because connectivity can sprawl multiple layers and this is TCP/IP.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.
"Connectivity" here refers to L2/L3 combination. In more specifically, it refers to which NetworkInterface subclass you have selected as those examples show.

@SeppoTakalo
Copy link
Contributor Author

Code dependency merged in.

@AnotherButler
Copy link
Contributor

@SeppoTakalo Are all of the reviewers who have not yet reviewed this optional, or are any mandatory?

@SeppoTakalo
Copy link
Contributor Author

@AnotherButler Those are optional.

For me, it is enough that Kevin reviewed from engineering point of view. Then I would like someone from Client side, and I tagged 4 persons. Teemu reviewed, so I think this is OK now.


When using two network interfaces where both use the same IP stacks, there are limitations. Both IP stacks, LwIP and Nanostack, are build using assumption that there is only one active interface.
For the Mbed OS 5.12, the LwIP routing core was modified to support multiple active interfaces, but it has its own limitations as well. When you have more than one active interfaces in LwIP, only one is the default, which all the outgoing traffic flows through.
If you need to force the traffic to only one of the interface, you need to use `Socket::setsockopt(NSAPI_SOCKET, NSAPI_BIND_TO_DEVICE, <interface name>, <interface name length>)` to bind the socket into one interface. Interface name can get fetched from `NetworkInterface::get_interface_name()` call.

Choose a reason for hiding this comment

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

Is there PR for NetworkInterface::get_interface_name()?

Edit file, mostly to remove references to "new" for easier maintenance and to update example to latest version.
@@ -2,7 +2,7 @@

This interface informs you about connection state changes asynchronously. Providing a method to register a callback function to a socket accomplishes this. Each time the network interface's state changes, it triggers the callback.

<span class="images">![](https://s3-us-west-2.amazonaws.com/mbed-os-docs-images/NetworkinterfaceStates.png)<span>Network states</span></span>
<span class="images">![](../../images/NetworkinterfaceStates.png)<span>Network states</span></span>
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 know if this format will render nicely, but I'm interested to try it and see.

Edit file, mostly for active voice and minor wording changes.
@AnotherButler
Copy link
Contributor

Please review my edits to make sure I didn't accidentally change the meaning of anything.

"usually reconnects" -> "reconnects" because it is not optional.
"active interface is active in ..." -> "interface is active in.."
@SeppoTakalo
Copy link
Contributor Author

Edits look OK.
I changed two sentences:

"usually reconnects" -> "reconnects" because it is not optional to do so in the mentioned states.
"active interface is active in LwIP" -> "interface is active in.."

Now it makes more sense.

@AnotherButler
Copy link
Contributor

Thanks, @SeppoTakalo

@AnotherButler AnotherButler merged commit afb85ad into ARMmbed:development Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants