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

Implement implicit field size alignment #77

Merged
merged 4 commits into from
Mar 9, 2020

Conversation

pavel-kirienko
Copy link
Member

@pavel-kirienko pavel-kirienko self-assigned this Mar 6, 2020
@pavel-kirienko pavel-kirienko changed the title Implement implicit field size alignment [WIP] Implement implicit field size alignment Mar 8, 2020
This is a tentative fix. A proper long-term solution is described in #68.
@pavel-kirienko pavel-kirienko changed the title [WIP] Implement implicit field size alignment Implement implicit field size alignment Mar 9, 2020
@pavel-kirienko
Copy link
Member Author

@thirtytwobits the build is green and I think it's ready for a review.

@@ -6,18 +6,18 @@
#
# The motivation for the difference between this small-MTU case and the general case is that the full 128-bit
# unique-ID can't be accommodated in a small-MTU single-frame anonymous message transfer. The solution is to replace
# the full 128-bit ID with a smaller 55-bit hash of it, and remove support for preferred node-ID value in the
# the full 128-bit ID with a smaller 48-bit hash of it, and remove support for preferred node-ID value in the
Copy link
Member

Choose a reason for hiding this comment

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

So we're increasing the chances of collisions just to ensure we can use the length property of the variable length array as a "is present" flag. Why not just add a bool has_valid_id flag and make the id a plan int type. You can keep your 55-bit hash that way.

Copy link
Member Author

Choose a reason for hiding this comment

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

But remember, the message shall fit into a single-frame transfer over Classic CAN. With the variable-length array, the bit length set is {56, 72}. The case of 56 bits is used with request transfers so it works. If we remove the variable-length array, we'd have to squeeze both cases into a single-frame transfer, which would leave even fewer bits for the unique ID hash.

With 48-bit, assuming uniformly distributed hashes, the probability of collision for a network with 128 participants is still negligible.

Copy link
Member

@thirtytwobits thirtytwobits left a comment

Choose a reason for hiding this comment

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

Ah, I see it now. Okay.

@pavel-kirienko pavel-kirienko merged commit ad2ea81 into master Mar 9, 2020
@pavel-kirienko pavel-kirienko deleted the implicit-field-size-alignment branch March 9, 2020 20:00
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.

2 participants