at86rf2xx: fix EUI64 computation#2963
Conversation
|
I'd prefer to keep it completely independent from |
|
Ok, I agree. Here's another approach, that's mostly taken from OpenWSN. It seems a little bit arbitrary, but at least we will have the same EUI-64 addresses on the IoT-LAB. |
|
Why not the XOR method you had earlier? |
sys/include/net/ng_ieee802154.h
Outdated
There was a problem hiding this comment.
I'd prefer some sort of enforced byteorder here... Either le_uintX_t (to keep the spirit of IEEE 802.15.4) or network_uintX_t (to be compatible with everything else).
There was a problem hiding this comment.
But IEEE 802.15.4 addresses are little-endian, right?
There was a problem hiding this comment.
With the EUI-64 I'm never sure 😕
There was a problem hiding this comment.
Shouldn't the EUI-64 in the driver be a data type with enforced endianess, too?
I think it makes things easier if we have the same UIDs at least in OpenWSN and RIOT. |
|
Then you maybe should adapt the xbee driver, too (if you want to make it dependent on the EUI-64) |
I cannot test this device and I don't understand the parts in brackets. |
Currently the short address for this device is generated from CPU ID, too. However, if we take the scheme you proposed to take bytes of the EUI-64 for that, we should do that on the xbee device too (where the EUI-64 is preinitialized by the vendor). |
|
Ah, okay. Yes, I'm much in favor of this. |
|
Updated. Endianess not yet addressed, because a) I'm not sure what the right endianess and b) I think the driver should reflect this, too. Maybe another PR for that? |
drivers/ng_at86rf2xx/ng_at86rf2xx.c
Outdated
There was a problem hiding this comment.
I just realized, that this is not really an OUI, right? Maybe for the platforms that OpenWSN supports, but we support way more boards than them.
There was a problem hiding this comment.
but we support way more boards than them.
Actually, I think they support more boards with 802.15.4 support than RIOT. But this code is taken from the iot-lab implementation. We could make it iot-lab specific, but wanted to avoid this.
There was a problem hiding this comment.
You think we should that the first three bytes to 000425, Atmels OUI here?
There was a problem hiding this comment.
You think we should that the first three bytes to 000425, Atmels OUI here?
no, I think that is a bad idea… I'd prefer the XOR solution above this solution actually :/
There was a problem hiding this comment.
no, I think that is a bad idea…
Why? It is an Atmel device.
I'd prefer the XOR solution above this solution actually :/
Why?
There was a problem hiding this comment.
Because Atmel is handling its device identifiers => a collision is bound to happen. And I don't know how the legal situation is. Also: since it is still a pseudo EUI-64 this way the correct prefix would be 020425, since the universal/local-bit must be set.
There was a problem hiding this comment.
Do you see a way to make sure not collide with any vendor's ID?
There was a problem hiding this comment.
No, but I don't see the benefit in making some pseudo-Atmel (actually not) sanctioned EUI-64 over a completely "randomised" one out of the whole range of the CPU ID.
There was a problem hiding this comment.
Ok, so, I leave the PR as is.
|
@cladmi, do you have some insights how to sensibly compute an EUI64 for the at86rf2xx? |
|
And what is @haukepetersen's opinion on this? |
|
@OlegHahm I would prefer a method that can be generally applied for ALL IEEE 802.15.4 devices (as long as they allow for that), not just the at86rf2xx ones. |
drivers/ng_at86rf2xx/ng_at86rf2xx.c
Outdated
There was a problem hiding this comment.
This + https://github.com/RIOT-OS/RIOT/pull/2963/files#diff-1042c565e8e083247b2102811d2f02ecR137 will result in the short address always being 0 ;-)
Apparently, that's not possible if weird devices as the XBEE not even allow to set the EUI-64. |
|
That's why I wrote "(as long as they allow for that)". |
|
Exceptions gonna except... let's at least have a general case for non-exceptions is all I'm saying. |
|
Do you have a proposal? |
|
As I proposed yesterday and you seem to ignore since then 😒: using "sliding XOR" #if CPUID_ID_LEN
uint8_t cpuid[CPU_ID_LEN];
cpuid_get(cpuid);
#if CPUID_ID_LEN < 8
/* in case CPUID_ID_LEN < 8, lead with zeros */
for (int i = 0; i < (8 - CPUID_ID_LEN); i++) {
addr_long[i] = 0;
}
for (int i = 0; i < CPUID_ID_LEN; i++) {
addr_long[i + (8 - CPUID_ID_LEN)] = cpuid[i];
}
#else
memset(addr_long, 0, 8);
for (int i = 0; i < (CPUID_ID_LEN - 8); i++) {
for (int j = i; j < 8; j++) {
addr_long[j] ^= cpuid[i + j];
}
}
#endif
#endif
addr_long[0] &= ~0x01; /* Ensure that address is unicast */
addr_long[0] |= 0x02; /* Ensure that address is local */[edit: Set the EUI-64 unicast/group and local/universal bits accordingly] |
|
I'm not ignoring it, but you haven't answered why you prefer this solution. I don't see how this is more generic. The CPUID is vendor specific anyway. |
|
Oh… sorry somehow your question slipped through my radar. I prefer it, since it uses the entire CPUID compared to just parts of it. |
|
Edit: never mind, byte ordering is not my strength... |
|
Looks good to me know, ACK when squashed and Travis is happy. |
|
Too bad, just found a duplicate long address with this scheme on IoT-LAB. :( |
|
Without the last commit but puting /* make sure we mark the address as non-multicast and not globally unique */
cpuid[0] &= ~(0x01);
cpuid[0] |= 0x02;in the right place the duplicate is gone... Tested with 150 nodes on IoT-Lab. Don't have time to check for duplicates on all nodes. |
|
What do you mean with right place? Isn't it in the right place in the current code? |
|
Yes, but not in the version before the last commit. |
|
Ah, I understand :-) Do you want to squash? |
|
This code definitely result in duplicate EUI64 addresses on IoT-LAB. I have a somewhat weird patch that doesn't reveal duplicates on the 160 nodes I tested, but I'm not sure, what's the better approach. |
|
Hm, are the CPUIDs on IoT-Lab nodes definitely unique? |
|
You should probably ask ST, but I think, yes, they are. It's impossible to guarantee any uniqueness here if we don't know the exact nature of the CPUID. What I propose for the IoT-Lab case: we leave the calculation in this driver as it is with the current state of this PR and add something to the netif auto_init that set different addresses if required (indicated by, e.g., the board or the user). |
|
sounds good. What I do not quite understand is the duplicate EUIs in the IoT-Lab, as XORed results from unique CPUIDs should acutally lead to unique EUIs. But anyhow, lets merge and improve afterwards. ACK |
The EUI64 for the at86rfxx is computed from the full CPUID by using sliding xor.
Dependency two CPUID and hard coded default short address are superfluous now.
|
Rebased without merge conflicts. |
We're basically mapping a (probably unique) 12 bit value to a an 8 bit value. Collisions may occur with every mapping scheme. |
|
@OlegHahm: I can run my UID scripts to provide you all the CPUIDs of the working IoT-Lab nodes. I hope to give it by tomorrow evening, ping me on IRC if I don't. |
|
Almost every nodes. However half of grenoble,m3 nodes are missing because an experiment is currently run. The UID is printed in the uid8[0]->uid8[11] order and it also includes Paris that should be deployed "soon". |
|
When looking at these numbers, I get the feeling that i does make sense, to make the EUI creation platform dependent (-> then we can use known characteristics of the CPUIDs). So I am thinking, that it could make sense, to extend the cpuid module by a second function, maybe something like void cpuid_get_unique_token(uint8_t res, sizte_t len);In the implementation of that function we can than focus on known relevant bytes (e.g. bytes 3,9,10 for the iot-lab). |
|
I think I like the idea. But should we merge this for now and make follow-up PR? Some duplicate EUI64s are less bad than identical EUI64s for all. 😉 |
|
Agreed. re-ACK and go. |
at86rf2xx: fix EUI64 computation
fixes #2962