Skip to content
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

paho: use GNRC instead of lwip #18982

Merged
merged 1 commit into from
Dec 1, 2022
Merged

Conversation

OlegHahm
Copy link
Member

Contribution description

The example application for Paho MQTT is using lwip instead of GNRC because at the time of writing no TCP support for GNRC was available. However, in the meantime the situation has changed and with a tiny tweak of the adapter code Paho works like charm on GNRC TCP sockets.

Testing procedure

Start a MQTT broker, e.g., mosquitto.

On native:

  1. Start the example application and add the tab bridge as default route via nib route add 7 :: <link-local address of the bridge>

On iotlab-m3 (or similar):

  1. Setup a border router (for instance in IoT-Lab following https://www.iot-lab.info/learn/tutorials/riot/riot-public-ipv6-m3/)
  2. Start the example application on a second node

Finally, call con <Broker IPv6 address> followed by sub <TOPIC> and `pub .

@OlegHahm OlegHahm added Area: network Area: Networking Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Area: pkg Area: External package ports Area: examples Area: Example Applications labels Nov 27, 2022
@OlegHahm OlegHahm requested a review from miri64 November 27, 2022 00:43
Comment on lines 36 to 45
USEMODULE += auto_init_gnrc_netif
# Activate ICMPv6 error messages
USEMODULE += gnrc_icmpv6_error
# Specify the mandatory networking module for a IPv6 routing node
USEMODULE += gnrc_ipv6_router_default
# Add a routing protocol
USEMODULE += gnrc_rpl
USEMODULE += auto_init_gnrc_rpl
# Additional networking modules that can be dropped if not needed
USEMODULE += gnrc_icmpv6_echo
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not support both?
e.g. examples/gcoap and examples/telnet_server can be compiled with either GNRC or LWIP.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure it would, but what would be the advantage? In my understanding the example applications should be easy to use (and as simple as possible). I think having one example that demonstrates how to build a network application for different stacks is sufficient.

# Activate ICMPv6 error messages
USEMODULE += gnrc_icmpv6_error
# Specify the mandatory networking module for a IPv6 routing node
USEMODULE += gnrc_ipv6_router_default
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
USEMODULE += gnrc_ipv6_router_default
USEMODULE += gnrc_ipv6_default

should be enough here

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually thought about which GNRC modules are required and which are optional and came to the conclusion that for the ease-of-use requirement adding routing support is beneficial. Same goes for ICMP. If someone wants to the test the application in the IoT-Lab, for instance, having RPL and routing active might be helpful to actually get a route towards the 6lbr - and having ICMP enabled is beneficial to check the connectivity first.

Of course, we could also remove the modules and try to keep the example application as slim as possible.

Both options have their pros and cons IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

The thing is that this will actually make it harder to use. When the node is a router, it will not send router solicitations. That means you’ll have to wait for the next unsolicited router advertisement to get a global address.

Copy link
Member Author

Choose a reason for hiding this comment

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

Valid point. So, how about keeping RPL, but switching to host, i.e., RPL leaf node?

Copy link
Contributor

Choose a reason for hiding this comment

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

tbh I'm not sure if RPL actually is used much at all, at appears to be rather abandoned.

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you talking about usage or maintenance? As far as I can tell, it is working well.

Copy link
Member

Choose a reason for hiding this comment

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

If @benpicco isn't using it, it is abandoned ;) I use it regularly in my setups.

Copy link
Member

Choose a reason for hiding this comment

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

(and it is used with gnrc_networking, so most people using that example will use it)

Copy link
Contributor

@benpicco benpicco Nov 28, 2022

Choose a reason for hiding this comment

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

@miri64 are you only using it with static topologies? It appears that repairing the DODAG when a node vanishes just doesn't happen, which is kinda crucial in real-world scenarios. (#17327) Or maybe I'm just under-estimating the time this takes?
When I asked about it more than a year ago I couldn't find anyone who used it outside simple / short lived test scenarios and nobody who maintains the module.

Copy link
Member Author

Choose a reason for hiding this comment

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

If this bug is still present basically the same arguments from below (whether to enable LWIP as an alternative or not) apply. If RPL works in some scenarios it is nice to have for this application, but it may get frustrating for users using it an dynamically changing topology. I used RPL on real hardware with bigger topologies only in the IoT-LAB so far, so I've observed the bug myself.

Comment on lines 41 to 43
# Add a routing protocol
USEMODULE += gnrc_rpl
USEMODULE += auto_init_gnrc_rpl
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Add a routing protocol
USEMODULE += gnrc_rpl
USEMODULE += auto_init_gnrc_rpl

Not really needed here

@@ -33,25 +33,20 @@ USEMODULE += ps
USEMODULE += netdev_default
USEPKG += paho-mqtt

# paho-mqtt depends on TCP support, choose which stacks you want
LWIP_IPV4 ?= 0
Copy link
Contributor

@aabadie aabadie Nov 27, 2022

Choose a reason for hiding this comment

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

Switching to GNRC will drop support for IPv4 from this example. I think the use of LwIP stack was not only motivated by the missing TCP support in GNRC but also by the missing IPv4 support.

Copy link
Member Author

Choose a reason for hiding this comment

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

To be honest, the main motivation for this PR was that the LWIP version in the IoT-Lab on IPv6 doesn't work for some reason. (The TCP connection is not established.) Since I didn't want to debug LWIP, I tried with GNRC instead.

In the end, the question remains: what is the main use case we want to support here. My idea is that all networking examples use GNRC whenever possible. Of course, that limits the use case to IPv6 (and 6LoWPAN) only. The other option would be to use LWIP for all networking examples wherever possible to allow for both, IPv4 and IPv6.

Copy link
Contributor

Choose a reason for hiding this comment

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

But with the sock API we can support both stacks without any changes to the code.
So the Makefile only needs to select different modules, depending on the desired stack.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, first of all that would require that this application actually works with both stacks which I couldn't verify (LWIP with 6lbr doesn't seem to work). Second, if we go with this reasoning we should update all networking applications which use sock.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can use LWIP without 6lbr, it also supports non-6lo interfaces.

It's not unreasonable to try to build with both stacks to ensure they work the same. The changes to the Makefile are really small.

Copy link
Member Author

Choose a reason for hiding this comment

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

You can use LWIP without 6lbr, it also supports non-6lo interfaces.

I would prefer an example that works in all scenarios. Having an example application that is known to be broken in a certain configuration may get frustrating for a user.

It's not unreasonable to try to build with both stacks to ensure they work the same. The changes to the Makefile are really small.

I'm not per se against this, but what would be the rationale to enable both stacks for this application, but, for instance, not for the MQTT-SN examples?

@OlegHahm
Copy link
Member Author

Okay, I removed RPL, configure RIOT as a host (instead of router) and let the user select a network stack.

Copy link
Contributor

@benpicco benpicco 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 to me, please squash

examples/paho-mqtt/main.c Outdated Show resolved Hide resolved
@github-actions github-actions bot added Area: cpu Area: CPU/MCU ports Platform: AVR Platform: This PR/issue effects AVR-based platforms labels Nov 29, 2022
@github-actions github-actions bot removed Area: cpu Area: CPU/MCU ports Platform: AVR Platform: This PR/issue effects AVR-based platforms labels Nov 29, 2022
@OlegHahm OlegHahm added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 29, 2022
@riot-ci
Copy link

riot-ci commented Nov 29, 2022

Murdock results

✔️ PASSED

ef2b581 paho: use GNRC instead of lwip

Success Failures Total Runtime
117858 0 117858 01h:54m:32s

Artifacts

@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer labels Nov 30, 2022
@benpicco
Copy link
Contributor

If you change the default, Makefile.ci will need an update since GNRC is generally bigger than LWIP.

@OlegHahm OlegHahm merged commit df0c04e into RIOT-OS:master Dec 1, 2022
@OlegHahm OlegHahm deleted the pr/paho_on_gnrc branch December 1, 2022 07:47
@kaspar030 kaspar030 added this to the Release 2023.01 milestone Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: examples Area: Example Applications Area: network Area: Networking Area: pkg Area: External package ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants