signetlabdei / lorawan

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

How to run a simple scenario in aloha , slotted aloha and tdma? #161

Closed Vidushi0001 closed 4 months ago

Vidushi0001 commented 5 months ago

Hello! I expect to get a comparison between these MAC protocols and compare their throughputs but being new to ns3 I don't know how to operate which scenario to use for my research and how to change the mac protocols to aloha , slotted aloha and TDMA.

Being a newbie to this any suggestion would be helpful! Thankyou!

non-det-alle commented 5 months ago

Hi, you question has some non-trivial assumptions left implicit. I think before trying to answer, we need to establish some background.

While the LoRaWAN MAC protocol has often been compared to unslotted ALOHA, they are not the same thing. For example, in both unslotted and slotted ALOHA, the central station receiving a packet on the main channel would use a second dedicated channel for re-broadcasting the transmission, providing a reliable acknowledgment mechanism to the sender[^1]. You could consider LoRaWAN's confirmed traffic to be comparable to unslotted ALOHA, but keep in mind that that would still be a minor stretch because LoRaWAN acknowledgments are not completely immune to collisions from uplink transmissions[^2]. Also, quasi-orthogonal Spreading Factors (SFs) enable more parallelism than ALOHA on a single channel, while rendering collisions among uplink frames less straightforward to model[^3]. That's why LoRaWAN has been most often called ALOHA-like in the literature.

That said, let's say you consider LoRaWAN's confirmed traffic to be your unslotted ALOHA equivalent. You can use this module to test its throughput performance. It even provides the possibility to adopt an ideal interference matrix makes different SF completely orthogonal and same-SF collisions always lose both packets (mind that this makes it more similar to ALOHA but reduces realism!)

In a next step, you would probably need to come up with a definition for slotted ALOHA and TDMA in LoRaWAN, or take it from existing literature. This will most likely require the definition of new MAC primitives to place in the header of packets. Now comes the implementation part: you will need to create alternative/extended versions of the C++ classes implementing the LoRaWAN MAC layer in this module (LorawanMac, EndDeviceLorawanMac and ClassAEndDeviceLorawanMac, LoraFrameHeader, LorawanMacHeader, etc.) and implement a NetworkServerComponent that takes care of adding your new MAC primitives into downlink packets based on you slotting / time division policy. Mind that this is just a sketch to help you out, I may be missing something.

In summary, you cannot just simply "change" the MAC protocol to something else. Ns-3's mission - and also this module's for that matter - is to provide simulations as close as possible to the reality of a technology in order to produce high quality research results. Thus, a discrete amount of effort will be required to implement other MAC protocols using the physical LoRa layer provided in this module. As I suggest to most new people looking for help here, I'd start from completing ns-3's tutorial, especially getting acquainted with ns-3's key abstractions, and only then checking out the code of this module to understand what it does (start from the examples and dig down from there).

Hope I was able to help you, let me know if you have more specific questions.

[^1]: J. J. Metzner, “ALOHA Protocols,” in Wiley Encyclopedia of Telecommunications, J. G. Proakis, Ed. Hoboken, NJ, USA: Wiley, 2003, doi: 10.1002/0471219282.eot275. [^2]: R. Saroui, A. Guitton, O. Iova, and F. Valois, “Uplink and downlink are not orthogonal in LoRaWAN!” in Proc. 96th IEEE Veh. Technol. Conf. (VTC2022-Fall), 2022, pp. 1–4, doi: 10.1109/VTC2022-Fall57202.2022.10012754. [^3]: A. Mahmood, E. Sisinni, L. Guntupalli, R. Rondón, S. A. Hassan, and M. Gidlund, “Scalability analysis of a LoRa network under imperfect orthogonality,” IEEE Trans. Ind. Inform., vol. 15, no. 3, pp. 1425–1436, Aug. 2018, doi: 10.1109/TII.2018.2864681.