signetlabdei / lorawan

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

Frame control (fCtrl) Serialization: Stealing/forgetting one bit in m_fOptsLen? #115

Closed renzoe closed 3 years ago

renzoe commented 3 years ago

Hi! I believe the Serialization of the fCtrl is not proper (I realized sniffing on wireshark). But as long as the Deserialization agrees, everything work as expected :). So this message is for the record.

FCtrl is 8bits. But check the serialization: https://github.com/signetlabdei/lorawan/blob/159cc5e8c62430ee2fb15f6ebcda916202004298/model/lora-frame-header.cc#L87

ADR bit for instance is the "leftmost" bit in the standard (8th; or 7th if we count from 0), but we serialize as the 7th (or 6th if we count 0-7).

Basically m_fOptsLen that should be 4 bits, but here its only using 3 bits. The rest is fitted accordingly, and we have the leftmost bit always zero. Again this has no impact on simulations because the deserializator agrees :). (... maybe only affects people that are using m_fOptsLen with size that needs the 4th bit.)

I do not dare to modify and pull, because that will involve testing (I have currently no spare time, I am using as is).

Does all this make sense --just by watching the code--, or am I mistaken? (Maybe I am too tired)

DvdMgr commented 3 years ago

Looks like you are right! The change was pretty easy to implement: I pushed it in 9f373c23076c3e821e6a6104bde8409e1a24a9fe. Tests pass and the output of examples does not seem to change. Closing for now, let me know if it still looks wrong to you in Wireshark!