signetlabdei / lorawan

An ns-3 module for simulation of LoRaWAN networks
GNU General Public License v2.0
182 stars 130 forks source link

Are the max packet sizes correct? #130

Open marianofino opened 1 year ago

marianofino commented 1 year ago

Hi,

The max packet sizes allowed to be sent for each DR in EU region don't seem to match the ones defined in the official docs. For example, DR0 has a max payload of 51 plus the minimum 13 bytes header. In total it's a max packet size of 64 bytes. However in this module, the maximum packet size for DR0 is 59 bytes. In fact, every DR packet size seems to be 5 bytes less that the correct ones.

This is the line of code that defines the max packet sizes: https://github.com/signetlabdei/lorawan/blob/2340df18f88132f2e8603ed2138e27429b7d2007/helper/lorawan-mac-helper.cc#L230

And here, in the first table of this docs, it is defined the maximum payload size for EU region (it's missing the 13 bytes header): https://lora-developers.semtech.com/documentation/tech-papers-and-guides/the-book/packet-size-considerations/

Is there a reason why the sizes are 5 bytes less?

non-det-alle commented 1 year ago

The max packet sizes in lorawan-mac-helper.cc are the ones for the MACPayload as defined in regional parameter specs (section 2.4.6). These are the ones that must be respected, payload + MAC header. The 51B at DR0 that you mention is "The maximum application payload length in the absence of the OPTIONAL FOpts control field (N) is also given for information only". I agree that the naming is deceiving (maxAPPpayload), but the check in end-device-lorawan-mac.cc is after the addition of the frame header so it should be correct.

Edit: I noticed you are referring to an old commit. This has been corrected as I described above in more recent versions.