signetlabdei / lorawan

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

Improving NbTrans support for class A #114

Open JacoTuks opened 3 years ago

JacoTuks commented 3 years ago

This request improves NbTrans support by causing both unconfirmed and confirmed traffic to be transmitting NbTrans times.

This code was written for class A devices and whilst NbTrans is supported fully the LinkADRReq command does not update NbTrans. I assumed that most people aren't using ADR and those that do would have noticed that this command never supported NbTrans updates and would have implemented it themselves if required.

Furthermore, the code doesn't test if you provided a NbTrans value between 1 and 15. It will simply attempt to transmit the packet's the provided number of times.

This pull request fixes issues #110 and #112

Proposed Changes

JacoTuks commented 3 years ago

I have made some of the smaller changed. I haven't split it into separate commits yet. I will wait for that once you have written more tests.

The last commit was to change numberOfTransmissions to an int complete-network-example. I noticed that when you pass a value using sem, the passed value will be different if this variable was a uint8_t.

DvdMgr commented 3 years ago

The last commit was to change numberOfTransmissions to an int complete-network-example. I noticed that when you pass a value using sem, the passed value will be different if this variable was a uint8_t.

Can you expand on this? Is sem/the ns-3 script distorting the value?

JacoTuks commented 3 years ago

The last commit was to change numberOfTransmissions to an int complete-network-example. I noticed that when you pass a value using sem, the passed value will be different if this variable was a uint8_t.

Can you expand on this? Is sem/the ns-3 script distorting the value?

This is how I understand it.

In my sem script, numberOfTransmissions is a Python int. If the ns-3 script expects an uint8_t and not an int it will receive a different value as Python doesn't have the concept of a uint8_t.

For example, if the sem script passes 3 it gives you 51 when you print with std::cout<< (unsigned) numberOfTransmissions :: std::endl;

An easy way to see the impact of this is when running a confirmed sim.

Adding the following to RequiredTransmissionsCallback() will allow the sim output to show if(reqTx > 3) std::cout<< "More than 3: " << (unsigned) reqTx << std::endl;

More than 3: 6 More than 3: 5 More than 3: 4 More than 3: 6 More than 3: 7 More than 3: 4 ... 200.000000 200.000000

Changing to an int from uint8_t allows the value to be safely passed and then the conversion from int to uin8_t happens inside the ns-3 script rather than Python -> C++.