Skip to content

Update for downlink sequence counter rollover #10137

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

Closed
wants to merge 8 commits into from

Conversation

itziardelatorre
Copy link
Contributor

Description

Fix issue related to downlink sequence counter rollover in LoRaWAN.
For the test, the downlink sequence counter of the downlink messages has been incremented by 1600 (< MAX_FCNT_GAP) several times. For example, until 64005 and following situation was shown:

  1. Downlink sequence counter increased to 64005 (by 1600 steps)
    The radio module accepts this, as expected.
  2. After that, downlink sequence counter increased to 65536 (rollover for 32 bits sequence counter)
    The radio module rejects this frame

With the change everything works fine.

Pull request type

[ x ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

Release Notes

Teppo Järvelin and others added 3 commits March 18, 2019 08:10
Current implementation did call AT+CGEREP before sim was ready
and it was failing in most modems.
Cellular: call AT+CGEREP after sim is ready
Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

Expand the commit msg (you provided details in the comment) - about the fix. It's bugfix rather "Bug"

@itziardelatorre
Copy link
Contributor Author

itziardelatorre commented Mar 18, 2019 via email

@0xc0170
Copy link
Contributor

0xc0170 commented Mar 18, 2019

Yes. Your current commit msg is "Bug related to downlink sequence counter rollover".

You provided good description in the first comment:

Fix issue related to downlink sequence counter rollover in LoRaWAN.
For the test, the downlink sequence counter of the downlink messages has been incremented by 1600 (< MAX_FCNT_GAP) several times. For example, until 64005 and following situation was shown:

Downlink sequence counter increased to 64005 (by 1600 steps)
The radio module accepts this, as expected.
After that, downlink sequence counter increased to 65536 (rollover for 32 bits sequence counter)
The radio module rejects this frame
With the change everything works fine.

Please edit your commit message to add details about the bug fix. You can actually replace the current commit message by this above quoted text.

For the test, the downlink sequence counter of the downlink messages has been incremented by 1600 (< MAX_FCNT_GAP) several times. For example, until 64005 and following situation was shown:

Downlink sequence counter increased to 64005 (by 1600 steps)
The radio module accepts this, as expected.
After that, downlink sequence counter increased to 65536 (rollover for 32 bits sequence counter)
The radio module rejects this frame
With the change everything works fine.
Copy link
Contributor Author

@itziardelatorre itziardelatorre left a comment

Choose a reason for hiding this comment

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

Fix issue related to downlink sequence counter rollover in LoRaWAN.
For the test, the downlink sequence counter of the downlink messages has been incremented by 1600 (< MAX_FCNT_GAP) several times. For example, until 64005 and following situation was shown:

Downlink sequence counter increased to 64005 (by 1600 steps)
The radio module accepts this, as expected.
After that, downlink sequence counter increased to 65536 (rollover for 32 bits sequence counter)
The radio module rejects this frame
With the change everything works fine.

@cmonr cmonr requested a review from a team March 19, 2019 00:06
@cmonr
Copy link
Contributor

cmonr commented Mar 19, 2019

@itziardelatorre A minor and major nit.

Major nit: Merges of ARMmbed/mbed-os master into PR head branches don't work. Please remove your merge commit and instead do a fetch + rebase to update your PR head branch.

Minor nit: Please take a look at the travis-ci/astyle job. If you'd like, feel free to run the below code for an automatic fix:

git apply -3 <<'PATCH' && git commit -am "Applied suggested astyle fix(es)" && git push
diff --git a/features/lorawan/lorastack/mac/LoRaMac.cpp b/features/lorawan/lorastack/mac/LoRaMac.cpp
index 032094d9df..1b6768cd9e 100644
--- a/features/lorawan/lorastack/mac/LoRaMac.cpp
+++ b/features/lorawan/lorastack/mac/LoRaMac.cpp
@@ -319,13 +319,13 @@ bool LoRaMac::message_integrity_check(const uint8_t *const payload,
     sequence_counter_prev = (uint16_t) * downlink_counter;
     sequence_counter_diff = sequence_counter - sequence_counter_prev;
     *downlink_counter += sequence_counter_diff;
-    
+
     if (sequence_counter_diff >= _lora_phy->get_maximum_frame_counter_gap()) {
         _mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOST;
         _mcps_indication.dl_frame_counter = *downlink_counter;
         return false;
     }
-    
+
     // sizeof nws_skey must be the same as _params.keys.nwk_skey,
     _lora_crypto.compute_mic(payload, size - LORAMAC_MFR_LEN,
                              nwk_skey,
@@ -335,7 +335,7 @@ bool LoRaMac::message_integrity_check(const uint8_t *const payload,
     if (mic_rx != mic) {
         _mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_MIC_FAIL;
         return false;
-    }   
+    }
 
     return true;
 }
PATCH

For the test, the downlink sequence counter of the downlink messages has been incremented by 1600 (< MAX_FCNT_GAP) several times. For example, until 64005 and following situation was shown:

- Downlink sequence counter increased to 64005 (by 1600 steps)
The radio module accepts this, as expected.
- After that, downlink sequence counter increased to 65536 (rollover for 32 bits sequence counter)
The radio module rejects this frame

With the change everything works fine.
@itziardelatorre
Copy link
Contributor Author

itziardelatorre commented Mar 19, 2019 via email

@itziardelatorre
Copy link
Contributor Author

This PR could be closed. New PR #10154

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.

4 participants