contiki-ng / contiki-ng

Contiki-NG: The OS for Next Generation IoT Devices
https://www.contiki-ng.org/
BSD 3-Clause "New" or "Revised" License
1.3k stars 698 forks source link

Border Router with RPL_CLASSIC config assigns local IP prefixes #1568

Closed fkerem closed 2 years ago

fkerem commented 3 years ago

Hi,

Even though I try to assign a public IP prefix, the border router with the configuration MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSIC assigns local prefixes (fd00::xxx). I don't have the same issue with RPL_LITE, it assigns the public prefix correctly. How can I fix this?

Here is the tunslip6 command:

./tunslip6 2001:0660:3207:421::33/64 -v2 -L -s /dev/ttyA8_M3 -B 500000

BR with RPL_CLASSIC:

image

BR with RPL_LITE:

image

Appreciate your help.

fkerem commented 3 years ago

Found the same case in other issue which was closed without a proper response: contiki-ng/contiki-ng#779

tinstructor commented 3 years ago

First of all, your BR is likely also the RPL root, which is the entity that distributes routable prefixes (such as Unique Local Address prefixes, i.e., fd00::/8, or global address prefixes, i.e., 2000::/3). Now, a node becomes root when rpl_dag_root_start() is called, in which the prefix to be distributed in DIOs is set via rpl_dag_root_set_prefix() as follows:

https://github.com/contiki-ng/contiki-ng/blob/f608483c5c32ff36807ef562486feb2bfd8ce89a/os/net/routing/rpl-classic/rpl-dag-root.c#L99-L106

Then you just follow the function calls through rpl_dag_root_set_prefix(), which is pretty uneventful:

https://github.com/contiki-ng/contiki-ng/blob/f608483c5c32ff36807ef562486feb2bfd8ce89a/os/net/routing/rpl-classic/rpl-dag-root.c#L87-L96

And finally you arrive at set_global_address():

https://github.com/contiki-ng/contiki-ng/blob/f608483c5c32ff36807ef562486feb2bfd8ce89a/os/net/routing/rpl-classic/rpl-dag-root.c#L54-L59

If you were to look further into the default prefix to be distributed you'd see that the ULA prefix is default, which makes sense because that ensures global-like routing behavior within your organization without conflicting with the true global address space (because the routers at the border of your organization MUST NOT route ULAs). Now, I'd wager the problem lies somewhere in the difference in implementation between rpl_dag_root_start() in RPL-lite and RPL-classic but you'd have to look into it yourself.

nvt commented 2 years ago

Thanks for the comments -- we have merged PR #1666.