-
Notifications
You must be signed in to change notification settings - Fork 204
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
Auto Increment Telemetry Sequence Count Overflow #1419
Comments
I just did a quick check, I think the issue lies here: cFE/modules/msg/fsw/src/cfe_msg_ccsdspri.c Line 309 in 73c338d
For something like sequence count the MSG shouldn't enforce the sequence is within its range, the caller is not supposed to know the range of the underlying encapsulation (it is supposed to be abstract). My recommendation would be to remove this extra check and it should work as expected, masking off the lower 14 bits to put into the message. |
If I'm following correctly, couldn't that be potentially misleading? If you mask off the lower 14 bits to put into the message, and the SB API just continues to auto-increment, your receiver may get two (or many) packets in quick succession with the same sequence count (equal to the max value that fits in the 14-bits). |
No, because it is the least significant bits that are masked off. It will just become a "mod 16384" counter at that point. (Upper bits just reflect the number of times its rolled over back to 0, which isn't that important). It does suggest, however, that the MSG module also needs an API to compare/diff two sequence numbers, since a "Set" followed by "Get" won't return the same value after the roll over point. This means that if a receiver actually wants to check/verify the sequence, they'll have to account for a rollover themselves, which is not ideal. |
Oh right. Binary operations are confusing for me late on a Friday afternoon... I don't think I have enough insight into how these sequence counters are intended to be used in practice to know whether that's the right approach or not. |
How about keeping the check, since it could cause a strange rollover when the input value overflows and to solve this issue w/ minimum changes add an inline CFE_MSG_GetNextSequenceCounter API, just pass in a sequence count and it returns the next (rolling over appropriately). Could be used for testing for gaps, incrementing correctly in an abstract sense, etc. I'd prefer to put off any additional new functionality (beyond just what's needed to fix this) to the next development cycle if possible. |
I'd be fine with that. |
Fix #1419, Resolve sequence count auto-increment rollover bug
Describe the bug
The API (called by CFE_SB_TransmitMsg) CFE_SBR_IncrementSequenceCounter has no protection to ensure the sequence counter doesn't exceed the maximum value dictated by the size of the field in the CCSDS primary header (14-bits w/ max value 16384.
To Reproduce
Create a for-loop that calls CFE_SB_TransmitMsg with the IncrementSequenceCount flag set to true. Have the loop repeat this at least 16385 times. View the resultant messages and verify that the sequence count stops incrementing and is stuck at the maximum value.
Expected behavior
CFE_SBR_IncrementSequenceCounter (or the caller CFE_SB_TransmitMsg) should check that the sequence counter does not exceed the maximum value dictated by the size in the header (16384). The sequence counter should be reset to 0 when it reaches the maximum.
Code snips
In CFE_SB_TransmitMsg:
In CFE_SBR_IncrementSequenceCounter:
System observed on:
Additional context
N/A
Reporter Info
PJ Chapates
Gateway VSM Flight Software Production
JSC, ER6
The text was updated successfully, but these errors were encountered: