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

net/gnrc_lorawan: implement unconfirmed uplink redundancy #15946

Merged
merged 3 commits into from
Sep 17, 2021

Conversation

jia200x
Copy link
Member

@jia200x jia200x commented Feb 8, 2021

Contribution description

This PR implements uplink redundancy for GNRC LoRaWAN.

Uplink redundancy is used to retransmit unconfirmed uplink frames. The retransmission stops when either a downlink message is received or the number of uplink retransmissions is reached. This functionality doesn't affect confirmed uplinks.

Although this functionality is intended to be used by the upcoming implementation of ADR, this can be also set at compile time by the user.

Testing procedure

  • Configure the LORAMAC_DEFAULT_REDUNDANCY parameter using Kconfig (e.g to 3). Then, please check the following stuff:
  • Check that the MAC layer sends the configured number of redundancy retransmissions when sending an unconfirmed message
diff --git a/sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c b/sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c
index 963e1197e9..2865b74748 100644
--- a/sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c
+++ b/sys/net/gnrc/link_layer/lorawan/gnrc_lorawan.c
@@ -64,7 +64,8 @@ static inline void gnrc_lorawan_mcps_reset(gnrc_lorawan_t *mac)
     mac->mcps.waiting_for_ack = false;
     mac->mcps.fcnt = 0;
     mac->mcps.fcnt_down = 0;
-    mac->mcps.redundancy = CONFIG_LORAMAC_DEFAULT_REDUNDANCY;
+    assert(gnrc_lorawan_set_redundancy(mac, 15) == -EINVAL);
+    assert(gnrc_lorawan_set_redundancy(mac, CONFIG_LORAMAC_DEFAULT_REDUNDANCY) == 0);
 }
 
 void gnrc_lorawan_set_rx2_dr(gnrc_lorawan_t *mac, uint8_t rx2_dr)

  • Check that confirmed uplink messages are not affected by this value. This can be tested using ABP and fake keys (in such case the NS won't reply with an ACK)
  • For both tests, check that the retransmissions are sent in different channels (e.g 868.1, 868.5, etc).

Issues/PRs references

None so far, but required for implementing ADR

@jia200x
Copy link
Member Author

jia200x commented Feb 8, 2021

@akshaim might be interested in this feature

@jia200x jia200x changed the title Pr/gnrc lorawan redundancy gnrc_lorawan: implement unconfirmed uplink redundancy Feb 8, 2021
@jia200x jia200x changed the title gnrc_lorawan: implement unconfirmed uplink redundancy net/gnrc_lorawan: implement unconfirmed uplink redundancy Feb 8, 2021
@jia200x jia200x added Area: LoRa Area: LoRa radio support Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Feb 8, 2021
* not affect confirmed uplinks. By default, uplinks
* are sent without retransmissions (this means, the
* device sends only one uplink packet)
*
Copy link
Member

Choose a reason for hiding this comment

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

++ This value is usually configured by the network to control the redundancy of the node uplinks to achieve a given Quality of Service.

Maybe one more line to give a bit more context.

Copy link
Member Author

@jia200x jia200x Feb 17, 2021

Choose a reason for hiding this comment

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

This is used by ADR, but it's not directly related. Therefore I don't think these lines add to much for the documentation

Copy link
Member Author

Choose a reason for hiding this comment

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

Otherwise this would be also for DR, TX Power, channels, etc

Copy link
Member

Choose a reason for hiding this comment

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

Redundancy is only used when ADR is enabled right ?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, it is not :). You can also configure the node to do redundancy, as described in the "help" section.
In fact, if the ADRReq command sets the redundancy to 0, the standard specifies that the redundancy should be the device's default.

Copy link
Member Author

Choose a reason for hiding this comment

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

alternatively we can avoid using redundancy when ADR is off. In fact, this is a gray zone in the standard IMO (it doesn't specifies what to do with the default value or when the redundancy is on)

Copy link
Member

Choose a reason for hiding this comment

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

As discussed offline, lets try to avoid the grey area :)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Member Author

Choose a reason for hiding this comment

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

I adapted it to indicate it's for ADR

not affect confirmed uplinks. By default, uplinks
are sent without retransmissions (this means, the
device sends only one uplink packet)

Copy link
Member

Choose a reason for hiding this comment

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

Same here.

Copy link
Member

Choose a reason for hiding this comment

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

Can you correct the formatting here ?

/**
* @brief Maximum unconfirmed uplink redundancy
*/
#define LORAMAC_REDUNDANCY_MAX (14U)
Copy link
Member

Choose a reason for hiding this comment

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

The valid range in LoRaMAC 1.0.3 spec is 1:15 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

for the number of transmissions, However, here these numbers are defined as "retransmissions" (therefore 15 maps to 14)

Copy link
Member

Choose a reason for hiding this comment

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

Yes. Maybe it makes sense to rename macro to LORAMAC_REDUNDANCY_MAX_RETRANSMISSIONS or something similar ?

Copy link
Member Author

Choose a reason for hiding this comment

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

as discuess offline, I can add the explanation of where the 14 comes from

Copy link
Member

Choose a reason for hiding this comment

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

Perfect. Thanks @jia200x :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed it. I realized it's not needed because ADR already limits this

Copy link
Member

Choose a reason for hiding this comment

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

Yes. Makes sense

@akshaim akshaim added this to the Release 2021.04 milestone Feb 17, 2021
@akshaim
Copy link
Member

akshaim commented Feb 26, 2021

@jia200x Looks good to me. Please squash.

@jia200x jia200x force-pushed the pr/gnrc_lorawan_redundancy branch from 1502ad8 to 3463e5a Compare June 25, 2021 12:19
@github-actions github-actions bot added Area: network Area: Networking Area: sys Area: System labels Jun 25, 2021
@akshaim
Copy link
Member

akshaim commented Jul 9, 2021

Can you rebase to current master ?

@jia200x jia200x force-pushed the pr/gnrc_lorawan_redundancy branch from 3463e5a to a63ce18 Compare July 12, 2021 16:48
@jia200x
Copy link
Member Author

jia200x commented Jul 12, 2021

rebased!

@akshaim
Copy link
Member

akshaim commented Jul 12, 2021

Great, I shall test it tomorrow :)

@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Jul 13, 2021
@jia200x
Copy link
Member Author

jia200x commented Jul 13, 2021

rebased on top of #16640

@jia200x
Copy link
Member Author

jia200x commented Jul 13, 2021

Test results:

2021-07-13 22:41:29,264 # reboot
2021-07-13 22:41:29,308 # NETOPT_RX_END_IRQ not implemented by driver
2021-07-13 22:41:29,317 # main(): This is RIOT! (Version: 2021.10-devel-144-gac94f-pr/gnrc_lorawan_redundancy)
2021-07-13 22:41:29,321 # Initialization successful - starting the shell now
ifconfig 3 set dr 5
2021-07-13 22:41:32,417 # ifconfig 3 set dr 5
2021-07-13 22:41:32,421 # success: set datarate on interface 3 to 5
> ifconfig 3 -ack_req
2021-07-13 22:41:36,809 # ifconfig 3 -ack_req
2021-07-13 22:41:36,811 # success: unset option
> ifconfig 3 up
2021-07-13 22:41:39,359 # ifconfig 3 up
> ifconfig
2021-07-13 22:41:58,838 # ifconfig
2021-07-13 22:41:58,848 # Iface  3  HWaddr: 01:26:96:73  Frequency: 868299987Hz  RSSI: 99  BW: 125kHz  SF: 7  CR: 4/5  Link: up 
2021-07-13 22:41:58,856 #            TX-Power: 14dBm  State: SLEEP  Demod margin.: 0  Num gateways.: 0 
2021-07-13 22:41:58,858 #           IQ_INVERT  
2021-07-13 22:41:58,862 #           RX_SINGLE  OTAA  L2-PDU:767  
2021-07-13 22:41:58,863 #           
> txtsnd 3 01 RIOT
2021-07-13 22:42:06,649 # txtsnd 3 01 RIOT
> txtsnd 3 01 RIOT
2021-07-13 22:42:30,223 # txtsnd 3 01 RIOT
> 

I configured the redundancy to 2. With that, every uplink is sent 3 times.

Here's the output of the network server. As expected, the Unconfirmed uplinks are sent 3 times.

[
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -51,
                    "loRaSNR": 8,
                    "channel": 5,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "W/FeRA==",
                    "uplinkID": "kGd83sM4QNm2mBbdhxEkiA==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867500000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "01269673",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 1,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "Dhawmg=="
                    }
                ]
            },
            "mic": "9523250d"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -54,
                    "loRaSNR": 9.5,
                    "channel": 1,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "W7IZEw==",
                    "uplinkID": "BiMIKdkLSuKf1oWAvla2wA==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868300000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "01269673",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 1,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "Dhawmg=="
                    }
                ]
            },
            "mic": "9523250d"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -51,
                    "loRaSNR": 8,
                    "channel": 5,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "W2IaXA==",
                    "uplinkID": "YwfxnxotTZ6khaREOfZ/aw==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867500000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "01269673",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 1,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "Dhawmg=="
                    }
                ]
            },
            "mic": "9523250d"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -51,
                    "loRaSNR": 7,
                    "channel": 5,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "Woi7xA==",
                    "uplinkID": "D+3Hc2MMTVKAXReusmkDaw==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867500000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "01269673",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "8+adQA=="
                    }
                ]
            },
            "mic": "02113e77"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -57,
                    "loRaSNR": 7,
                    "channel": 2,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "WjqWEw==",
                    "uplinkID": "cPnNyigAQEqWa7orlG2Beg==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868500000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "01269673",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "8+adQA=="
                    }
                ]
            },
            "mic": "02113e77"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -53,
                    "loRaSNR": 9,
                    "channel": 6,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "WfpmhA==",
                    "uplinkID": "HKsZMNwZTsioZya/f8E5ww==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867700000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "01269673",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "8+adQA=="
                    }
                ]
            },
            "mic": "02113e77"
        }
    },
    {
        "downlinkMetaData": {
            "gatewayID": "b827ebfffe1aa415",
            "txInfo": {
                "frequency": 868300000,
                "power": 14,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": true
                },
                "board": 0,
                "antenna": 0,
                "timing": "DELAY",
                "delayTimingInfo": {
                    "delay": "5s"
                },
                "context": "WGtvEw=="
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "JoinAccept",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "bytes": "IXEaSLwUYEJxEpJCDZ1luLNZpnkX4BIdqWclRw=="
            },
            "mic": "8c7fb5ca"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -57,
                    "loRaSNR": 9.75,
                    "channel": 1,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "WGtvEw==",
                    "uplinkID": "dL4QJacTTuW2MxhgVNF33Q==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868300000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "JoinRequest",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "joinEUI": "0000000000000000",
                "devEUI": "488038d49a5a156b",
                "devNonce": 14402
            },
            "mic": "7a69ba7b"
        }
    }
]

@jia200x
Copy link
Member Author

jia200x commented Jul 13, 2021

As described in the test results, a downlink stops the retransmission procedure:

2021-07-13 22:54:19,131 # ifconfig 3 link_check
2021-07-13 22:54:19,133 # success: set option
txtsnd 3 01 RIOT
2021-07-13 22:54:22,123 # txtsnd 3 01 RIOT
> ifconfig
2021-07-13 22:54:35,744 # ifconfig
2021-07-13 22:54:35,754 # Iface  3  HWaddr: 01:26:96:73  Frequency: 867299987Hz  RSSI: 99  BW: 125kHz  SF: 7  CR: 4/5  Link: up 
2021-07-13 22:54:35,761 #            TX-Power: 14dBm  State: SLEEP  Demod margin.: 16  Num gateways.: 1 
2021-07-13 22:54:35,764 #           IQ_INVERT  
2021-07-13 22:54:35,768 #           RX_SINGLE  OTAA  L2-PDU:767  
2021-07-13 22:54:35,769 #           
> 

The node only send one message (the downlink is the result of the Link Check command):

[
    {
        "downlinkMetaData": {
            "gatewayID": "b827ebfffe1aa415",
            "txInfo": {
                "frequency": 867300000,
                "power": 14,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": true
                },
                "board": 0,
                "antenna": 0,
                "timing": "DELAY",
                "delayTimingInfo": {
                    "delay": "1s"
                },
                "context": "hdDdQw=="
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataDown",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "01269673",
                    "fCtrl": {
                        "adr": true,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 1,
                    "fOpts": [
                        {
                            "cid": "LinkCheckReq",
                            "payload": {
                                "margin": 16,
                                "gwCnt": 1
                            }
                        }
                    ]
                },
                "fPort": null,
                "frmPayload": null
            },
            "mic": "6c245b38"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -51,
                    "loRaSNR": 8.75,
                    "channel": 4,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "hdDdQw==",
                    "uplinkID": "FicvObUYQi6GD9LQJcN55w==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867300000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "01269673",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 3,
                    "fOpts": [
                        {
                            "cid": "LinkCheckReq",
                            "payload": null
                        }
                    ]
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "NToABw=="
                    }
                ]
            },
            "mic": "9f62a691"
        }
    }
]

The retransmission procedure of confirmable message also works:

> ifconfig 3 ack_req
2021-07-13 22:56:01,773 # ifconfig 3 ack_req
2021-07-13 22:56:01,775 # success: set option
txtsnd 3 01 RIOT
2021-07-13 22:56:06,858 # txtsnd 3 01 RIOT
> txtsnd 3 01 RIOT

[
    {
        "downlinkMetaData": {
            "gatewayID": "b827ebfffe1aa415",
            "txInfo": {
                "frequency": 868500000,
                "power": 14,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": true
                },
                "board": 0,
                "antenna": 0,
                "timing": "DELAY",
                "delayTimingInfo": {
                    "delay": "1s"
                },
                "context": "jIVSqw=="
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataDown",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "01269673",
                    "fCtrl": {
                        "adr": true,
                        "adrAckReq": false,
                        "ack": true,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 3,
                    "fOpts": null
                },
                "fPort": null,
                "frmPayload": null
            },
            "mic": "90560c42"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -55,
                    "loRaSNR": 8,
                    "channel": 2,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "jIVSqw==",
                    "uplinkID": "GX5kbe4KRFK3PjtaBply7w==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868500000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "ConfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "01269673",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 5,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "FBrlWg=="
                    }
                ]
            },
            "mic": "48fb78a0"
        }
    }
]

And the retransmission value is not affect by the redundancy (retrans is set to 5 -> 6 uplinks):

> ifconfig 3 set dr 5
2021-07-13 23:05:04,462 # ifconfig 3 set dr 5
2021-07-13 23:05:04,467 # success: set datarate on interface 3 to 5
> ifconfig 3 -otaa
2021-07-13 23:05:09,519 # ifconfig 3 -otaa
2021-07-13 23:05:09,521 # success: unset option
> ifconfig 3 up
2021-07-13 23:05:12,182 # ifconfig 3 up
> ifconfig
2021-07-13 23:05:13,333 # ifconfig
2021-07-13 23:05:13,343 # Iface  3  HWaddr: 00:00:00:00  Frequency: 868299987Hz  RSSI: 99  BW: 125kHz  SF: 7  CR: 4/5  Link: up 
2021-07-13 23:05:13,350 #            TX-Power: 14dBm  State: SLEEP  Demod margin.: 0  Num gateways.: 0 
2021-07-13 23:05:13,353 #           L2-PDU:767  
2021-07-13 23:05:13,354 #           
> txtsnd 3 01 RIOT
2021-07-13 23:05:21,215 # txtsnd 3 01 RIOT
[
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -54,
                    "loRaSNR": 10,
                    "channel": 0,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "roDy8w==",
                    "uplinkID": "nOcwwq9mSV+x2M3NFbV7ig==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868100000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "ConfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00000000",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "hzG9WQ=="
                    }
                ]
            },
            "mic": "0b14ecbb"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -55,
                    "loRaSNR": 8.75,
                    "channel": 0,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "rkCoEw==",
                    "uplinkID": "pEahKw/LS7CR+FtZ3QqhFg==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868100000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "ConfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00000000",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "hzG9WQ=="
                    }
                ]
            },
            "mic": "0b14ecbb"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -55,
                    "loRaSNR": 10.75,
                    "channel": 1,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "rfhqEw==",
                    "uplinkID": "+xrFMUWySeCO57LPJjQE/Q==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868300000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "ConfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00000000",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "hzG9WQ=="
                    }
                ]
            },
            "mic": "0b14ecbb"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -57,
                    "loRaSNR": 10.25,
                    "channel": 0,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "rbWigw==",
                    "uplinkID": "dqm42/6cSP+CtY8OeLcTOA==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868100000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "ConfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00000000",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "hzG9WQ=="
                    }
                ]
            },
            "mic": "0b14ecbb"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -54,
                    "loRaSNR": 9.5,
                    "channel": 1,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "rV87gw==",
                    "uplinkID": "A1BhPZyZS3KHrLnqFwgdwA==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868300000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "ConfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00000000",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "hzG9WQ=="
                    }
                ]
            },
            "mic": "0b14ecbb"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -57,
                    "loRaSNR": 10,
                    "channel": 1,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "rRnUEw==",
                    "uplinkID": "EmqmtCaUQ522G0byYFxQQA==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868300000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "ConfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00000000",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "hzG9WQ=="
                    }
                ]
            },
            "mic": "0b14ecbb"
        }
    }
]

@jia200x
Copy link
Member Author

jia200x commented Jul 13, 2021

Last but not least: the proposed patch for testing doesn't make sense any more because the proposed function is now void. I added an assertion to make sure redundancy <= 14 and simply use the function on initialization.

> ifconfig 3 set dr 5
2021-07-13 23:24:43,736 # ifconfig 3 set dr 5
2021-07-13 23:24:43,740 # success: set datarate on interface 3 to 5
> ifconfig 3 -ack_req
2021-07-13 23:24:49,041 # ifconfig 3 -ack_req
2021-07-13 23:24:49,043 # success: unset option
txtsnd 3 01 RIOT
2021-07-13 23:25:18,720 # txtsnd 3 01 RIOT

NS (redundancy configured to 14):

[
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -55,
                    "loRaSNR": 10.25,
                    "channel": 6,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "+KlGrA==",
                    "uplinkID": "nd345NhWRIuD8kPwgt3K8g==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867700000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -55,
                    "loRaSNR": 10,
                    "channel": 6,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "+FaQ/A==",
                    "uplinkID": "zbFwgmuwQwWseqpWTtGNJQ==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867700000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -57,
                    "loRaSNR": 9.5,
                    "channel": 1,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "+BTHUw==",
                    "uplinkID": "Luwc0qf8RgGQxplrf5qeGQ==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868300000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -55,
                    "loRaSNR": 7.5,
                    "channel": 2,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "983RYw==",
                    "uplinkID": "lkQxRaIWRZq5MmnMDMqGzQ==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868500000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -53,
                    "loRaSNR": 10.25,
                    "channel": 4,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "93g1iw==",
                    "uplinkID": "/jrBpFd6Ti+34PNmwKpIqg==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867300000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -57,
                    "loRaSNR": 7.25,
                    "channel": 2,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "9yQoCw==",
                    "uplinkID": "VvbByh1bRnKPZLRk/cVNlg==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868500000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -57,
                    "loRaSNR": 10,
                    "channel": 0,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "9t7now==",
                    "uplinkID": "TVGqb0qRQLCCd08PWTXYCQ==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868100000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -53,
                    "loRaSNR": 9.5,
                    "channel": 4,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "9pznQw==",
                    "uplinkID": "OdDx43TQR7CAle/9KaDcjA==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867300000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -53,
                    "loRaSNR": 9.25,
                    "channel": 6,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "9lXGZA==",
                    "uplinkID": "aARC9XyrRsqFruQbu+YqwA==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867700000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -55,
                    "loRaSNR": 9.5,
                    "channel": 6,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "9hNsJA==",
                    "uplinkID": "7R1liRPXSJCnP9d+X3Cz1A==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867700000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -54,
                    "loRaSNR": 8.75,
                    "channel": 0,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "9b9eqw==",
                    "uplinkID": "yKSHDCpsQyep2Ti+I0TXNg==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868100000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -55,
                    "loRaSNR": 8.75,
                    "channel": 6,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "9WS5zA==",
                    "uplinkID": "l6cfXwfiSSOXiSWaAnZw2g==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867700000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -54,
                    "loRaSNR": 8.5,
                    "channel": 1,
                    "rfChain": 1,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "9RxQww==",
                    "uplinkID": "aTnNZw+fS7SkcJfo5mYfVg==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 868300000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -51,
                    "loRaSNR": 9.75,
                    "channel": 4,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "9MhS6w==",
                    "uplinkID": "V+CLwpnuQsiW5ELWiNsDfw==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867300000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    },
    {
        "uplinkMetaData": {
            "rxInfo": [
                {
                    "gatewayID": "uCfr//4apBU=",
                    "time": null,
                    "timeSinceGPSEpoch": null,
                    "rssi": -55,
                    "loRaSNR": 10.25,
                    "channel": 6,
                    "rfChain": 0,
                    "board": 0,
                    "antenna": 0,
                    "location": {
                        "latitude": 0,
                        "longitude": 0,
                        "altitude": 0,
                        "source": "UNKNOWN",
                        "accuracy": 0
                    },
                    "fineTimestampType": "NONE",
                    "context": "9HpcFA==",
                    "uplinkID": "7B0qJpyiTlioIyCwdjPs6g==",
                    "crcStatus": "CRC_OK"
                }
            ],
            "txInfo": {
                "frequency": 867700000,
                "modulation": "LORA",
                "loRaModulationInfo": {
                    "bandwidth": 125,
                    "spreadingFactor": 7,
                    "codeRate": "4/5",
                    "polarizationInversion": false
                }
            }
        },
        "phyPayload": {
            "mhdr": {
                "mType": "UnconfirmedDataUp",
                "major": "LoRaWANR1"
            },
            "macPayload": {
                "fhdr": {
                    "devAddr": "00c10887",
                    "fCtrl": {
                        "adr": false,
                        "adrAckReq": false,
                        "ack": false,
                        "fPending": false,
                        "classB": false
                    },
                    "fCnt": 0,
                    "fOpts": null
                },
                "fPort": 1,
                "frmPayload": [
                    {
                        "bytes": "aOX1hQ=="
                    }
                ]
            },
            "mic": "374460aa"
        }
    }
]

I also dropped 9948072 since it's not used anymore after the request changes by @akshaim

@akshaim
Copy link
Member

akshaim commented Jul 13, 2021

@jia200x I think we can proceed ahead :)

@akshaim
Copy link
Member

akshaim commented Jul 14, 2021

@jia200x Can you squash ?

@MrKevinWeiss MrKevinWeiss removed this from the Release 2021.07 milestone Jul 15, 2021
@leandrolanzieri leandrolanzieri added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jul 20, 2021
@leandrolanzieri leandrolanzieri added this to the Release 2021.10 milestone Jul 20, 2021
@leandrolanzieri
Copy link
Contributor

This needs rebasing and squashing

@akshaim
Copy link
Member

akshaim commented Jul 20, 2021

Tested with Chirspstack and it seems to fail. Here are the results.

  1. OTAA/ Unconfirimed Messages / Redundancy set to 3.
    Result : Node retransmits on different frequencies but occasionally on the same frequency. This seems to against the standard which states

Line 681 : The end-device performs frequency hopping as usual between repeated transmissions, it does wait after each repetition until the receive windows have expired

  1. ✔️ Link Check option set / Redundancy set to 3.
    Result : No retries.

![no_retries](https://user-images.githubusercontent.com/5170658/126322896-9426b046-e246-4247-a4c7-745f0446a176.png

  1. ❌ ABP Mode ( fake keys) / Redundancy set to 3/ Unconfirmed uplinks

The device sends uplinks on the same channel

redundancy_ABP

  1. ABP Mode ( fake keys) / Redundancy set to 3/ Confirmed uplinks

The device continues to retry uplinks on the same channel ?

unconfirmed_abp

@jia200x
Copy link
Member Author

jia200x commented Jul 21, 2021

Tested with Chirspstack and it seems to fail. Here are the results.

Please note the tests above were using the same Chirpstack instance and hardware.

OTAA/ Unconfirimed Messages / Redundancy set to 3.
Result : Node retransmits on different frequencies but occasionally on the same frequency. This seems to against the standard which states

Line 681 : The end-device performs frequency hopping as usual between repeated transmissions, it does wait after each repetition until the receive windows have expired

This standard "frequency hopping" is described here:

The end-device changes channel in a pseudo-random fashion for every transmission. The resulting frequency diversity makes the system more robust to interferences.

The implementation is doing that. Just picking a pseudo-random number. The only exceptions are bands that require to implement FHSS, such as US915. In this case the channel must not repeat.

In fact, this is the Semtech LoRaMAC implementation for EU868.

  23     if( nbEnabledChannels > 0 )                                                 
  22     {                                                                           
  21         // We found a valid channel                                             
  20         *channel = enabledChannels[randr( 0, nbEnabledChannels - 1 )];          
  19                                                                                 
  18         *time = 0;                                                              
  17         return LORAMAC_STATUS_OK;                                               
  16     }                                                                           
  15     el

Therefore, this is not against the standard. Since there are only 3 channels in ABP, there are high chances you will see the same channel on retransmissions.

The device continues to retry uplinks.

Of course, since redundancy is not applied to confirmed uplinks.

This commit implements uplink redundancy in GNRC LoRaWAN. Uplink
redundancy is used to retransmit unconfirmed uplink frames. The
retransmission stops when either a downlink message is received or the
number of uplink retransmissions is reached.

This functionality doesn't affect confirmed uplinks.
@jia200x jia200x force-pushed the pr/gnrc_lorawan_redundancy branch from 2762998 to df97f34 Compare July 21, 2021 01:52
@jia200x
Copy link
Member Author

jia200x commented Jul 21, 2021

squashed!

@github-actions github-actions bot removed Area: tests Area: tests and testing framework Area: drivers Area: Device drivers Area: pkg Area: External package ports labels Jul 21, 2021
@benpicco
Copy link
Contributor

Is there anything left here to do?

@jia200x
Copy link
Member Author

jia200x commented Sep 17, 2021

Is there anything left here to do?

I don't think so. This PR should be ready to merge

Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

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

Code looks good and I trust your testing

@miri64 miri64 added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Sep 17, 2021
@miri64
Copy link
Member

miri64 commented Sep 17, 2021

Last build was a bit stale, so let's do one more before merging.

@miri64 miri64 merged commit 75c9aac into RIOT-OS:master Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: LoRa Area: LoRa radio support Area: network Area: Networking Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants