Skip to content

Commit

Permalink
Merge branch 'non-det-alle/master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
non-det-alle committed Jul 23, 2024
2 parents 469b9b3 + fcce6bb commit 2f5ea20
Show file tree
Hide file tree
Showing 78 changed files with 388 additions and 329 deletions.
2 changes: 1 addition & 1 deletion .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at `[email protected]`. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

Expand Down
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ guidelines:
2. Make sure that unit tests pass
3. Write tests for the new behavior
4. Make sure the code is documented and styled according to the [ns-3
guidelines](https://www.nsnam.org/developers/contributing-code/coding-style
guidelines](https://www.nsnam.org/docs/contributing/html/coding-style.html
"ns-3 documentation and style guidelines")
5. Write an example illustrating how to use the new feature
6. Update the documentation in the `doc/lorawan.rst` file
Expand Down
2 changes: 1 addition & 1 deletion NS3-VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release ns-3.39
release ns-3.42
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

>**If you just want to create scenarios using the emulator, and you are not interested in tinkering with it, we refer you to a quicker installation running the [emulator image with Docker Compose](https://github.com/non-det-alle/elora-docker).**
This is a traffic emulator for the [Chirpstack server stack](https://www.chirpstack.io/ "ChirpStack, open-source LoRaWAN® Network Server").
This is a traffic emulator for the [Chirpstack server stack](https://www.chirpstack.io/ "ChirpStack, open-source LoRaWAN® Network Server").

This software can be used to simulate in real-time multiple devices and gateways sharing a radio channel with very high flexibility in terms of possible configurations. LoRaWAN traffic is then UDP-encapsulated by gateways and forwarded outside the simulation. If a Chirpstack network server is in place, it will think the traffic is coming from a real network. All Class A MAC primitives used in the UE868 region are supported: radio transmission parameters of simulated devices can be changed by the downlink LoRaWAN traffic of the real server.
This software can be used to simulate in real-time multiple devices and gateways sharing a radio channel with very high flexibility in terms of possible configurations. LoRaWAN traffic is then UDP-encapsulated by gateways and forwarded outside the simulation. If a Chirpstack network server is in place, it will think the traffic is coming from a real network. All Class A MAC primitives used in the UE868 region are supported: radio transmission parameters of simulated devices can be changed by the downlink LoRaWAN traffic of the real server.

The code is an extension of the ns-3 [LoRaWAN module](https://github.com/signetlabdei/lorawan "LoRaWAN ns-3 module"). In addition to what is provided by the original LoRaWAN module, the following changes/additions were made:

Expand All @@ -14,70 +14,70 @@ The code is an extension of the ns-3 [LoRaWAN module](https://github.com/signetl
* The `elora-example` to show a complete usage of the traffic generator
* Many improvements and corrections of features of the original module, such that traffic could be transparently be accepted by the server

## Prerequisites ##
## Prerequisites

To use this simulator you need to know the following:

* The ChirpStack server needs to be running somewhere (reachable by the simulation via network)
* The simulator works as is with the default configuration of Chirpstark v4 on `localhost:8080`. It has been tested with the [docker-compose installation](https://www.chirpstack.io/docs/getting-started/docker.html "Chirpstack docs: Quickstart Docker Compose") of the server. To test a distributed version of the setup, the server/port address needs to be changed in `elora-example`, and ChirpStack needs to be set up such that a Gateway Bridge container remains co-located on the same machine of the ELoRa process
* An authentification token needs to be generated in the server (API keys section), and needs to be copy-pasted in `elora-example`

## Installation ##
## Installation

If not already, install the `libcurl` development library in your linux distribution (`libcurl4-gnutls-dev` on Ubuntu, `curl-dev` on Alpine).

Clone [ns-3](https://www.nsnam.org "ns-3 Website"), checkout the right commit, clone this repository inside the `contrib` directory, and patch ns-3 using the provided [patch file](ns-3-dev.patch) as follows:
Clone [ns-3](https://www.nsnam.org "ns-3 Website"), clone this repository inside the `contrib` directory, checkout the right commit, and patch ns-3 using the provided [patch file](ns-3-dev.patch) with the following all-in-one command:

```bash
git clone https://gitlab.com/nsnam/ns-3-dev.git
cd ns-3-dev/
git checkout ns-3.40
git clone https://github.com/non-det-alle/elora.git contrib/elora
git clone https://gitlab.com/nsnam/ns-3-dev.git && cd ns-3-dev &&
git clone https://github.com/Orange-OpenSource/elora.git contrib/elora &&
tag=$(< contrib/elora/NS3-VERSION) && tag=${tag#release } && git checkout $tag -b $tag &&
patch -p1 -s < contrib/elora/ns-3-dev.patch
```

Make sure you are in the `ns-3-dev` folder, configure and then build ns-3:
Make sure you are in the `ns-3-dev` directory, then configure and build ns-3 with the following all-in-one command:

```bash
./ns3 configure -d debug --enable-examples
./ns3 configure -d debug --enable-examples &&
./ns3 build
```

The `elora` module extends the code of the original `lorawan` ns-3 module, thus the two modules are in conflict if they are built together. If you also have the original `lorawan` module installed (either in the `contrib` or `src` directory), run `./ns3 clean` and add the `--enable-modules elora` option to the `./ns3 configure` command above to avoid building both.

## Usage examples ##
## Usage examples

The module includes the following example:

- `elora-example`
* `elora-example`

Examples can be run via the `./ns3 run --enable-sudo "elora-example [options]"` command.

Options can be retrived with `./ns3 run "elora-example --help"`.

## Documentation ##
## Documentation

For a description of the module, refer to `doc/lorawan.rst` (currently not up to date with all functionalities).

For more information on how to use the underlying LoRaWAN module refer also to the [original module readme](https://github.com/signetlabdei/lorawan/blob/e8f7a21044418e92759d5c7c4bcab147cdaf05b3/README.md "LoRaWAN ns-3 module README").
For more information on how to use the underlying LoRaWAN module refer also to the [original ns-3 repository](https://github.com/signetlabdei/lorawan "LoRaWAN ns-3 module").

- [ns-3 tutorial](https://www.nsnam.org/docs/tutorial/html "ns-3 Tutorial")
- [ns-3 manual](https://www.nsnam.org/docs/manual/html "ns-3 Manual")
- The LoRaWAN specification can be found on the [LoRa Alliance
* [ns-3 tutorial](https://www.nsnam.org/docs/tutorial/html "ns-3 Tutorial")
* [ns-3 manual](https://www.nsnam.org/docs/manual/html "ns-3 Manual")
* The LoRaWAN specification can be found on the [LoRa Alliance
website](http://www.lora-alliance.org)

## Copyright ##
## Copyright

Code copyright 2022-2023 Orange.
Code copyright 2022-2023 Orange.

## License ##
## License

This software is licensed under the terms of the GNU GPLv2 (the same license
that is used by ns-3). See the LICENSE.md file for more details.

## Getting help ##
## Getting help

If you need any help, feel free to open an issue here.

## Cite us ##
## Cite us

[A. Aimi, S. Rovedakis, F. Guillemin, and S. Secci, “ELoRa: End-to-end Emulation of Massive IoT LoRaWAN Infrastructures,” 2023 IEEE/IFIP Network Operations and Management Symposium (NOMS), May 2023, Miami, FL, United States.](https://hal.science/hal-04025834)
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.1
0.1.1
14 changes: 7 additions & 7 deletions doc/lorawan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ To represent these two models, the module features two generic ``LoraPhy`` and
model the peculiarities of the two wireless network devices: the End Device (ED)
and the Gateway (GW). So, the PHY layers can be modeled by use of
``EndDeviceLoraPhy`` and ``GatewayLoraPhy`` classes, while objects of class
``BaseEndDeviceLorawanMac``, ``ClassAEndDeviceLorawanMac``, and ``GatewayLorawanMac``
``BaseEndDeviceLorawanMac``, ``ClassAEndDeviceLorawanMac``, and ``GatewayLorawanMac``
are used to represent the MAC layer. A ``NetworkServer`` application can also be
installed on a node that will then administer the wireless network through the
GW's forwarding application, ``Forwarder``, which leverages the gateway's LoRa
Expand Down Expand Up @@ -187,12 +187,12 @@ and forwarded to the MAC layer.
\begin{matrix}
& \scriptstyle{\rm SF7 } & \scriptstyle{\rm SF8 }& \scriptstyle{\rm SF9 }& \scriptstyle{\rm SF10} & \scriptstyle{\rm SF11} & \scriptstyle{\rm SF12}\\
\scriptstyle{\rm SF7 }& 6 &-16 &-18 &-19 &-19 &-20\\
\scriptstyle{\rm SF8 }& -24 &6 &-20 &-22 &-22 &-22\\
\scriptstyle{\rm SF9 }& -27 &-27 &6 &-23 &-25 &-25\\
\scriptstyle{\rm SF10} & -30 &-30 &-30 &6 &-26 &-28\\
\scriptstyle{\rm SF11} & -33 &-33 &-33 &-33 &6 &-29\\
\scriptstyle{\rm SF12} & -36 &-36 &-36 &-36 &-36 &6\\
\scriptstyle{\rm SF7 } & 6 & -16 & -18 & -19 &-19 & -20 \\
\scriptstyle{\rm SF8 } & -24 & 6 & -20 & -22 &-22 & -22 \\
\scriptstyle{\rm SF9 } & -27 & -27 & 6 & -23 &-25 & -25 \\
\scriptstyle{\rm SF10} & -30 & -30 & -30 & 6 &-26 & -28 \\
\scriptstyle{\rm SF11} & -33 & -33 & -33 & -33 & 6 & -29 \\
\scriptstyle{\rm SF12} & -36 & -36 & -36 & -36 &-36 & 6 \\
\end{matrix}
A full description of the link layer model can also be found in
Expand Down
20 changes: 10 additions & 10 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,77 @@ build_lib_example(
SOURCE_FILES simple-network-example.cc
LIBRARIES_TO_LINK
${libcore}
${liblorawan}
${libelora}
)

build_lib_example(
NAME network-server-example
SOURCE_FILES network-server-example.cc
LIBRARIES_TO_LINK
${libcore}
${liblorawan}
${libelora}
)

build_lib_example(
NAME complete-network-example
SOURCE_FILES complete-network-example.cc
LIBRARIES_TO_LINK
${libcore}
${liblorawan}
${libelora}
)

build_lib_example(
NAME adr-example
SOURCE_FILES adr-example.cc
LIBRARIES_TO_LINK
${libcore}
${liblorawan}
${libelora}
)

build_lib_example(
NAME lorawan-energy-model-example
SOURCE_FILES lorawan-energy-model-example.cc
LIBRARIES_TO_LINK
${libcore}
${liblorawan}
${libelora}
)

build_lib_example(
NAME aloha-throughput
SOURCE_FILES aloha-throughput.cc
LIBRARIES_TO_LINK
${libcore}
${liblorawan}
${libelora}
)

build_lib_example(
NAME parallel-reception-example
SOURCE_FILES parallel-reception-example.cc
LIBRARIES_TO_LINK
${libcore}
${liblorawan}
${libelora}
)

build_lib_example(
NAME frame-counter-update
SOURCE_FILES frame-counter-update.cc
LIBRARIES_TO_LINK
${libcore}
${liblorawan}
${libelora}
)

build_lib_example(
NAME pcap-example
SOURCE_FILES pcap-example.cc
LIBRARIES_TO_LINK
${libcore}
${liblorawan}
${libelora}
)

build_lib_example(
NAME elora-example
SOURCE_FILES elora-example.cc
LIBRARIES_TO_LINK
${libcore}
${liblorawan}
${libelora}
)
2 changes: 1 addition & 1 deletion examples/adr-example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ main(int argc, char* argv[])
// Do not set spreading factors up: we will wait for the NS to do this
if (initializeSF)
{
macHelper.SetSpreadingFactorsUp(endDevices, gateways, channel);
LorawanMacHelper::SetSpreadingFactorsUp(endDevices, gateways, channel);
}

////////////
Expand Down
21 changes: 11 additions & 10 deletions examples/aloha-throughput.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "utilities.cc"

#include "ns3/base-end-device-lorawan-mac.h"
#include "ns3/building-allocator.h"
#include "ns3/building-penetration-loss.h"
Expand Down Expand Up @@ -33,8 +35,7 @@
using namespace ns3;
using namespace lorawan;

NS_LOG_COMPONENT_DEFINE("AlohaThroughput");
#include "utilities.cc"
NS_LOG_COMPONENT_DEFINE_EXAMPLE_WITH_UTILITIES("AlohaThroughput");

// Network settings
int nDevices = 200;
Expand Down Expand Up @@ -145,7 +146,7 @@ main(int argc, char* argv[])
mobility.Install(endDevices);

// Make it so that nodes are at a certain height > 0
for (NodeContainer::Iterator j = endDevices.Begin(); j != endDevices.End(); ++j)
for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
{
Ptr<MobilityModel> mobility = (*j)->GetObject<MobilityModel>();
Vector position = mobility->GetPosition();
Expand All @@ -168,7 +169,7 @@ main(int argc, char* argv[])
// Now end devices are connected to the channel

// Connect trace sources
for (NodeContainer::Iterator j = endDevices.Begin(); j != endDevices.End(); ++j)
for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
{
Ptr<Node> node = *j;
Ptr<LoraNetDevice> loraNetDevice = DynamicCast<LoraNetDevice>(node->GetDevice(0));
Expand Down Expand Up @@ -217,20 +218,20 @@ main(int argc, char* argv[])
{
LoraPhyTxParameters txParams;
txParams.sf = sf;
txParams.headerDisabled = 0;
txParams.headerDisabled = false;
txParams.codingRate = 1;
txParams.bandwidthHz = 125000;
txParams.nPreamble = 8;
txParams.crcEnabled = 1;
txParams.crcEnabled = true;
txParams.lowDataRateOptimizationEnabled = LoraPhy::GetTSym(txParams) > MilliSeconds(16);
Ptr<Packet> pkt = Create<Packet>(packetSize);

LoraFrameHeader fHdr = LoraFrameHeader();
fHdr.SetAsUplink();
fHdr.SetFPort(1);
fHdr.SetAddress(LoraDeviceAddress());
fHdr.SetAdr(0);
fHdr.SetAdrAckReq(0);
fHdr.SetAdr(false);
fHdr.SetAdrAckReq(false);
fHdr.SetFCnt(0);
pkt->AddHeader(fHdr);

Expand Down Expand Up @@ -268,15 +269,15 @@ main(int argc, char* argv[])
forHelper.Install(gateways);

// Install trace sources
for (NodeContainer::Iterator node = gateways.Begin(); node != gateways.End(); node++)
for (auto node = gateways.Begin(); node != gateways.End(); node++)
{
DynamicCast<LoraNetDevice>((*node)->GetDevice(0))
->GetPhy()
->TraceConnectWithoutContext("ReceivedPacket", MakeCallback(OnPacketReceptionCallback));
}

// Install trace sources
for (NodeContainer::Iterator node = endDevices.Begin(); node != endDevices.End(); node++)
for (auto node = endDevices.Begin(); node != endDevices.End(); node++)
{
DynamicCast<LoraNetDevice>((*node)->GetDevice(0))
->GetPhy()
Expand Down
4 changes: 2 additions & 2 deletions examples/complete-network-example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ main(int argc, char* argv[])
mobility.Install(endDevices);

// Make it so that nodes are at a certain height > 0
for (NodeContainer::Iterator j = endDevices.Begin(); j != endDevices.End(); ++j)
for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
{
Ptr<MobilityModel> mobility = (*j)->GetObject<MobilityModel>();
Vector position = mobility->GetPosition();
Expand All @@ -190,7 +190,7 @@ main(int argc, char* argv[])
// Now end devices are connected to the channel

// Connect trace sources
for (NodeContainer::Iterator j = endDevices.Begin(); j != endDevices.End(); ++j)
for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
{
Ptr<Node> node = *j;
Ptr<LoraNetDevice> loraNetDevice = DynamicCast<LoraNetDevice>(node->GetDevice(0));
Expand Down
11 changes: 7 additions & 4 deletions examples/elora-example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Key elements are preceded by a comment with lots of dashes ( ///////////// )
*/

#include "utilities.cc"

// ns3 imports
#include "ns3/core-module.h"
#include "ns3/csma-helper.h"
Expand All @@ -29,8 +31,7 @@
using namespace ns3;
using namespace lorawan;

NS_LOG_COMPONENT_DEFINE("EloraExample");
#include "utilities.cc"
NS_LOG_COMPONENT_DEFINE_EXAMPLE_WITH_UTILITIES("EloraExample");

/* Global declaration of connection helper for signal handling */
ChirpstackHelper csHelper;
Expand All @@ -47,8 +48,8 @@ main(int argc, char* argv[])
uint16_t apiPort = 8090;
std::string token =
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9."
"eyJhdWQiOiJjaGlycHN0YWNrIiwiaXNzIjoiY2hpcnBzdGFjayIsInN1YiI6IjZlMjQ4NjljLWQxMjItNDZkOS04Nz"
"E0LTM5Yzc4Nzg4OTRhZCIsInR5cCI6ImtleSJ9.IB20o6Jrcwj5qZ9mPEuthzzqMyc3YNSl8by_ZXrjqhw";
"eyJhdWQiOiJjaGlycHN0YWNrIiwiaXNzIjoiY2hpcnBzdGFjayIsInN1YiI6ImQ2ZGQ4OGFiLTNmN2MtNGJlZi1hZW"
"U1LWVmZGRkNWEyZmE3MSIsInR5cCI6ImtleSJ9.UJmVOv2Chbh1T5xjUSBF9jZuGmmLg3xu7Dg_77otxkA";
uint16_t destPort = 1700;

double periods = 24; // H * D
Expand Down Expand Up @@ -88,6 +89,8 @@ main(int argc, char* argv[])
GlobalValue::Bind("ChecksumEnabled", BooleanValue(true));
Config::SetDefault("ns3::BaseEndDeviceLorawanMac::ADRBackoff", BooleanValue(true));
Config::SetDefault("ns3::BaseEndDeviceLorawanMac::EnableCryptography", BooleanValue(true));
Config::SetDefault("ns3::BaseEndDeviceLorawanMac::FType",
EnumValue(LorawanMacHeader::CONFIRMED_DATA_UP));
///////////////// Needed to manage the variance introduced by real world interaction
Config::SetDefault("ns3::ClassAEndDeviceLorawanMac::RecvWinSymb", UintegerValue(16));

Expand Down
Loading

0 comments on commit 2f5ea20

Please sign in to comment.