How to send an Anycast message #7465
Replies: 7 comments
-
The Commissioner Anycast Address is 0xfc30 + Commissioner Session ID mod 8. The Commissioner Session ID can be found in the Thread Network Data. Unfortunately, OpenThread does not currently have an API to make this easily accessible, but you can parse it from Thread Network Data. After starting the commissioner, you should see network data similar to below:
The information is encoded a TLVs. The Commissioner Session ID TLV is the
If you look at the IPv6 addresses on the leader, that should match the lower 16 bits of one of the addresses. In the example below, it is the first one.
You can find detailed information in the Thread 1.1 Specification:
We could probably add an API to provide the Commissioner Anycast Address. |
Beta Was this translation helpful? Give feedback.
-
Hi Jonathan, In my case, the Commissioner is an Android app and doesn't have a CLI. Maybe that my first question was not clear enough: This is on the Joiner device (freshly connected to the thread network) that I want to send an anycast message to the Commissioner. Is there a way to get the Commissioner Anycast Address? I have seen this commit (#4707) which adds GetLocator(). Could it help me to retrieve the Commissioner Anycast Address? My Commissioner is in the Wifi network and not in the Thread network. Is it possible, in that case, to reach it with an Anycast Address? Thank you |
Beta Was this translation helpful? Give feedback.
-
As mentioned in #7291 (comment), after attaching to the Thread network, a Thread device can determine the Commissioner Anycast Address using the Commissioner Session ID contained within the Thread Network Data.
Yes. Thread should route packets with a Commissioner Anycast destination to the Thread border router that the commissioner is attached to. |
Beta Was this translation helpful? Give feedback.
-
Ok, thank you Jonathan. On the device that freshly joined the Thread network, is it possible to determine the Commissioner Anycast address? (programmatically)
IMO, that would be useful. |
Beta Was this translation helpful? Give feedback.
-
I can explain the reason of my question: When I have started working on Thread, I have focused on trying to echange data between the Android phone (the commissioner) and the freshly commissioned device. Thanks to the help obtained on this forum, I have been able to configure the BR and to send UDP packets between the Android phone (connected to the wifi) and the Thread device. In another issue, you advised me to implement a SRP service. I will not get that in a short time so I was looking for an alternate solution. From the Thread device, is it possible to determine the Commissioner Anycast address? I have thought to a workaround that seems to work. On the thread device, I'm allocating a static IPV6 Address starting from OMR prefix and finishing by some bytes arbitrary chosen. By this way the Android phone can guess the IP Address of the Thread device. They can then talk to each other and possibly switch to the IP address dynamically allocated. In Openthread Android Commissining App, is there a way to determine the OMR prefix? Thank you |
Beta Was this translation helpful? Give feedback.
-
You can exchange data between an Android phone and a commissioned device without a commissioner. You can use Android socket to send/recv IP traffics as if you are talking to a WiFi device, as long as you have the IPv6 address of the end device. Even if you can get the Commissioner Anycast address, packets sent to this address is not routed directly to the mobile phone but to the border router and then relayed to the commissioner app via the DTLS connection between the commissioner app and the border router. That said, the packets sent from the end device will not be received by other network applications on the mobile phone but as I said, you don't need (and shouldn't use) the commissioner app to exchange data between mobile phone and Thread device. The SRP service solution is the recommended way to discover a specific Thread device from WiFi network. On your Android phone, you just need to subscribe to and resolve your registered SRP/mDNS service to get the IPv6 address of your Thread device with NsdManager.
Setting up a SRP service on a Thread end device seems pretty simple per https://openthread.io/codelabs/openthread-border-router#4 and you can make a script on the end device to automate this process for demo purpose. Could you share the specific blocker that stops you from using SRP? |
Beta Was this translation helpful? Give feedback.
-
Yes, I have that working. I'm able to send UDP packets between the Android phone and the commissioned device. It is working both ways. I indeed need the IPV6 address of the end device.
The HW that I use is under development and SRP is not available yet. |
Beta Was this translation helpful? Give feedback.
-
Anycast addresses are described on https://openthread.io/guides/thread-primer/ipv6-addressing#anycast
I have a Thread device freshly connected to a Thread network thanks to an Android phone commissioner. I would like to send an Anycast message to the Commissioner. It is said to use ALOC16 0xfc30 – 0xfc37 for the Commissioner but I don't know how to use it.
Would you have indications about how to send such Anycast message to the Commissioner?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions