Skip to content

Commit 7443362

Browse files
committed
Fix relax frame-counter mode fCntDown reset on retransmit.
Closes #179.
1 parent f656852 commit 7443362

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

docs/changelog.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 0.17.2
4+
5+
**Bugfixes:**
6+
7+
* Do not reset downlink frame-counter in case of relax frame-counter mode as
8+
this would also reset the downlink counter on a re-transmit.
9+
310
## 0.17.1
411

512
**Features:**

internal/session/session.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,15 @@ func GetNodeSessionForPHYPayload(p *redis.Pool, phy lorawan.PHYPayload) (NodeSes
152152
// get full FCnt
153153
fullFCnt, ok := ValidateAndGetFullFCntUp(ns, macPL.FHDR.FCnt)
154154
if !ok {
155-
// if RelaxFCnt is turned on, just trust the uplink FCnt
155+
// If RelaxFCnt is turned on, just trust the uplink FCnt
156156
// this is insecure, but has been requested by many people for
157-
// debugging purposes
157+
// debugging purposes.
158+
// Note that we do not reset the FCntDown as this would reset the
159+
// downlink frame-counter on a re-transmit, which is not what we
160+
// want.
158161
if ns.RelaxFCnt {
159162
fullFCnt = macPL.FHDR.FCnt
160163
ns.FCntUp = macPL.FHDR.FCnt
161-
ns.FCntDown = 0
162164

163165
// validate if the mic is valid given the FCnt reset
164166
micOK, err := phy.ValidateMIC(ns.NwkSKey)

internal/testsuite/uplink_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ func TestUplinkScenarios(t *testing.T) {
427427
runUplinkTests(ctx, tests)
428428
})
429429

430-
Convey("Given a set of test-scenarios for relaxt frame-counter mode", func() {
430+
Convey("Given a set of test-scenarios for relax frame-counter mode", func() {
431431
expectedApplicationPushDataUpNoData := &as.HandleDataUpRequest{
432432
AppEUI: ns.AppEUI[:],
433433
DevEUI: ns.DevEUI[:],
@@ -461,7 +461,7 @@ func TestUplinkScenarios(t *testing.T) {
461461
AppEUI: ns.AppEUI[:],
462462
DevEUI: ns.DevEUI[:],
463463
MaxPayloadSize: 51,
464-
FCnt: 0,
464+
FCnt: 5,
465465
}
466466

467467
expectedApplicationPushDataUpNoData7 := &as.HandleDataUpRequest{
@@ -497,7 +497,7 @@ func TestUplinkScenarios(t *testing.T) {
497497
AppEUI: ns.AppEUI[:],
498498
DevEUI: ns.DevEUI[:],
499499
MaxPayloadSize: 51,
500-
FCnt: 0,
500+
FCnt: 5,
501501
}
502502

503503
tests := []uplinkTestCase{
@@ -523,7 +523,7 @@ func TestUplinkScenarios(t *testing.T) {
523523
ExpectedApplicationHandleDataUp: expectedApplicationPushDataUpNoData7,
524524
ExpectedApplicationGetDataDown: expectedGetDataDown7,
525525
ExpectedFCntUp: 8,
526-
ExpectedFCntDown: 0,
526+
ExpectedFCntDown: 5,
527527
ExpectedEnabledChannels: []int{0, 1, 2},
528528
},
529529
{
@@ -548,7 +548,7 @@ func TestUplinkScenarios(t *testing.T) {
548548
ExpectedApplicationHandleDataUp: expectedApplicationPushDataUpNoData,
549549
ExpectedApplicationGetDataDown: expectedGetDataDown,
550550
ExpectedFCntUp: 1,
551-
ExpectedFCntDown: 0,
551+
ExpectedFCntDown: 5,
552552
ExpectedEnabledChannels: []int{0, 1, 2},
553553
},
554554
}

mkdocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pages:
1515
- changelog.md
1616

1717
extra:
18-
version: '0.17.1'
18+
version: '0.17.2'
1919
github:
2020
download_release: true
2121

0 commit comments

Comments
 (0)