From febdbb31d05f7dead3b1729cc516d71fe5d1ba2e Mon Sep 17 00:00:00 2001 From: Alessandro Aimi Date: Fri, 26 Jul 2024 16:52:22 +0200 Subject: [PATCH] Update supported ns-3 version to 3.42 (#169) * Change deprecated EventId::IsRunning to IsPending * Import nested energy namespace where necessary * Refactor to Duration and Type enums in tests * Fix compilation error caused by a 'Schedule' of a 'Callback' type function - Introduce TxFinished function in LoraPhy for signaling transmission end. - Probably related to: https://gitlab.com/nsnam/ns-3-dev/-/issues/1060#note_1847298087 (matching error) * Bump supported ns-3 version to 3.42 * Fix spelling * Fix linting * Fix cmake formatting + add related job to the CI * CI: update per-commit pipeline to ns-3.42 * CI: add ns-3 version disclaimer to logs * CI: simplify dependencies where possible * CI: rename tests placeholder file * CI: produce doxygen warning artifact only on failure * CI: fix workflow code formatting and make all dispatchable * CI: try github pages --- .github/actions/build/action.yml | 2 +- .github/actions/checkout-in-ns3/action.yml | 4 ++ .github/actions/install-analysis/action.yml | 1 - .github/actions/install-doc/action.yml | 4 +- .github/actions/install-linting/action.yml | 5 +-- .github/actions/install-per-commit/action.yml | 9 ++--- .github/workflows/deploy-doc.yml | 32 ++++++++++----- .../{.formatting.yml => formatting.yml} | 25 +++++++++++- .../workflows/{.linting.yml => linting.yml} | 6 ++- .github/workflows/per-commit.yml | 26 ++++++++----- .../workflows/{.test-doc.yml => test-doc.yml} | 6 ++- NS3-VERSION | 2 +- examples/CMakeLists.txt | 39 ++++++++----------- examples/aloha-throughput.cc | 2 +- examples/complete-network-example.cc | 2 +- model/class-a-end-device-lorawan-mac.cc | 2 - model/end-device-lora-phy.cc | 14 +++++++ model/end-device-lora-phy.h | 7 ++++ model/end-device-lorawan-mac.cc | 16 +++----- model/end-device-status.cc | 2 +- model/gateway-lora-phy.cc | 2 +- model/gateway-lora-phy.h | 14 +++---- model/lora-phy.h | 9 +++++ model/lora-radio-energy-model.h | 2 + model/simple-end-device-lora-phy.cc | 17 +------- test/lorawan-test-suite.cc | 16 ++++---- test/network-scheduler-test-suite.cc | 4 +- test/network-server-test-suite.cc | 8 ++-- test/network-status-test-suite.cc | 6 +-- 29 files changed, 165 insertions(+), 119 deletions(-) rename .github/workflows/{.formatting.yml => formatting.yml} (77%) rename .github/workflows/{.linting.yml => linting.yml} (95%) rename .github/workflows/{.test-doc.yml => test-doc.yml} (96%) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 43c4f12aa2..da1f23ac5e 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -42,7 +42,7 @@ runs: echo "CACHE_MISS=`./utils/ccache-miss-rate.py`" >> $GITHUB_ENV echo "REF_NAME=`echo $GITHUB_REF_NAME | sed -r 's/[/]+/-/g'`" >> $GITHUB_ENV echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV - touch build/tests-base.txt + touch build/tests-base-artifact-placeholder.txt - if: env.CACHE_MISS != '0' name: "Create tests placeholder" shell: bash diff --git a/.github/actions/checkout-in-ns3/action.yml b/.github/actions/checkout-in-ns3/action.yml index 54bba04361..33f0b9c2a8 100644 --- a/.github/actions/checkout-in-ns3/action.yml +++ b/.github/actions/checkout-in-ns3/action.yml @@ -15,4 +15,8 @@ runs: tag=$(< src/lorawan/NS3-VERSION) && tag=${tag#release } wget -nv -O ns-3-dev.tar https://gitlab.com/api/v4/projects/nsnam%2Fns-3-dev/repository/archive.tar?sha=$tag tar -xf ns-3-dev.tar && cp -a ns-3-dev-$tag-*/. . && rm -R ns-3-dev.tar ns-3-dev-$tag* + echo + echo "###################################################" + echo "###### WARNING! CURRENT NS-3 VERSION: $tag ######" + echo "###################################################" shell: bash diff --git a/.github/actions/install-analysis/action.yml b/.github/actions/install-analysis/action.yml index 8a31ac022a..ad0ce8e6ac 100644 --- a/.github/actions/install-analysis/action.yml +++ b/.github/actions/install-analysis/action.yml @@ -12,7 +12,6 @@ runs: sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y apt-utils git gcc g++ cmake python3 make ninja-build - tcpdump libgsl-dev libxml2-dev curl unzip tar ccache lcov diff --git a/.github/actions/install-doc/action.yml b/.github/actions/install-doc/action.yml index bbf9a3f6d8..4c0dcc74db 100644 --- a/.github/actions/install-doc/action.yml +++ b/.github/actions/install-doc/action.yml @@ -10,9 +10,9 @@ runs: shell: bash run: > pacman-key --init && pacman -Syu --noconfirm - base-devel ninja cmake python ccache gsl gtk3 boost openssh + base-devel ninja cmake python ccache graphviz imagemagick texlive-basic texlive-bin texlive-binextra texlive-latexextra - texlive-fontutils texlive-fontsrecommended python-sphinx + texlive-fontutils texlive-fontsrecommended python-sphinx wget && pacman --noconfirm -U https://archive.archlinux.org/packages/d/dia/dia-0.97.3-9-x86_64.pkg.tar.zst && pacman --noconfirm -U https://archive.archlinux.org/packages/d/doxygen/doxygen-1.9.6-1-x86_64.pkg.tar.zst && diff --git a/.github/actions/install-linting/action.yml b/.github/actions/install-linting/action.yml index 0fd4759148..ed4756eaa4 100644 --- a/.github/actions/install-linting/action.yml +++ b/.github/actions/install-linting/action.yml @@ -12,9 +12,6 @@ runs: apt update && DEBIAN_FRONTEND=noninteractive apt install -y clang cmake clang-tidy clang-tidy-17 - libboost-all-dev libeigen3-dev libgtk-3-dev libsqlite3-dev - gsl-bin libgsl-dev libgsl27 - git ssh - wget + git wget - name: "Checkout this repository as ns-3 module" uses: ./.github/actions/checkout-in-ns3 diff --git a/.github/actions/install-per-commit/action.yml b/.github/actions/install-per-commit/action.yml index f2d962cb56..c88986ee53 100644 --- a/.github/actions/install-per-commit/action.yml +++ b/.github/actions/install-per-commit/action.yml @@ -1,5 +1,5 @@ # Note: this action requires an archlinux container, specific inputs and access to the repos's actions! -# (see .base-per-commit.yml) +# (see per-commit.yml) name: "install-per-commit" description: "Installs required archlinux packages and checks-out the repo in ns-3" @@ -10,9 +10,7 @@ runs: shell: bash run: > pacman-key --init && pacman -Syu --noconfirm - base-devel gcc clang cmake ninja ccache - boost gsl gtk3 - openssh + base-devel gcc clang libc++ cmake ninja ccache python wget - name: "Checkout this repository as ns-3 module" @@ -21,4 +19,5 @@ runs: shell: bash run: | EXTRA_ID=`echo $EXTRA_OPTIONS | sed 's/--/-/g' | sed 's/ //g'` - echo "BUILD_ID=per-commit-$COMPILER-$MODE$EXTRA_ID" >> $GITHUB_ENV + FLAGS_ID=`echo $CXXFLAGS | sed 's/--/-/g' | sed 's/-\?[a-zA-Z0-9+-.]\+=/-/g' | sed 's/ //g'` + echo "BUILD_ID=per-commit-$COMPILER-$MODE$EXTRA_ID$FLAGS_ID" >> $GITHUB_ENV diff --git a/.github/workflows/deploy-doc.yml b/.github/workflows/deploy-doc.yml index a4419b6189..cb18ed8288 100644 --- a/.github/workflows/deploy-doc.yml +++ b/.github/workflows/deploy-doc.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: jobs: - deploy-doc: + build: runs-on: ubuntu-latest container: image: archlinux @@ -32,13 +32,25 @@ jobs: store-artifacts: "false" - name: "Build documentation" run: ./ns3 docs all - - name: "Deploy documentation" - env: - SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} - uses: cpina/github-action-push-to-another-repository@main + - name: "Upload pages artifact" + uses: actions/upload-pages-artifact@v3 with: - source-directory: "doc/" - destination-github-username: "signetlabdei" - destination-repository-name: "lorawan-docs" - user-email: paginmatte@dei.unipd.it - target-branch: master + path: "doc/html/" + + deploy: + # Add a dependency to the build job + needs: build + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + # Specify runner + deployment step + runs-on: ubuntu-latest + steps: + - name: "Deploy to GitHub Pages" + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/.formatting.yml b/.github/workflows/formatting.yml similarity index 77% rename from .github/workflows/.formatting.yml rename to .github/workflows/formatting.yml index 0122064d59..5b0f003b1c 100644 --- a/.github/workflows/.formatting.yml +++ b/.github/workflows/formatting.yml @@ -4,7 +4,9 @@ name: "Check code formatting" run-name: "formatting" -on: workflow_call +on: + workflow_call: + workflow_dispatch: jobs: # Clang-format @@ -24,7 +26,7 @@ jobs: sparse-checkout: .github/actions - name: "Install required system packages" run: > - apt update && DEBIAN_FRONTEND=noninteractive apt install -y + apt update && DEBIAN_FRONTEND=noninteractive apt install -y python3 clang-format-${{ matrix.version }} wget @@ -68,3 +70,22 @@ jobs: - run: git log --pretty=%B HEAD...upstream/develop ^upstream/develop > git_messages.txt # Check source code and commit messages - run: codespell -f -C0 --skip="./experiments" ./ + + # CMake formatting + cmake-format: + runs-on: ubuntu-latest + container: + image: python:latest + timeout-minutes: 60 + steps: + # The following step is required in all jobs that use this repo's actions + - name: "Retrieve actions from repository" + uses: actions/checkout@v4 + with: + sparse-checkout: .github/actions + - run: pip install pyyaml cmake cmake-format ninja wget + - name: "Checkout this repository as ns-3 module" + uses: ./.github/actions/checkout-in-ns3 + - run: | + ./ns3 configure --enable-modules=core + ./ns3 build cmake-format-check diff --git a/.github/workflows/.linting.yml b/.github/workflows/linting.yml similarity index 95% rename from .github/workflows/.linting.yml rename to .github/workflows/linting.yml index bccc661160..80ab4d2a3d 100644 --- a/.github/workflows/.linting.yml +++ b/.github/workflows/linting.yml @@ -4,7 +4,9 @@ name: "Check code linting" run-name: "linting" -on: workflow_call +on: + workflow_call: + workflow_dispatch: jobs: # Clang-tidy @@ -34,7 +36,7 @@ jobs: shell: bash run: > git -C src/lorawan/ tag empty $(git hash-object -t tree /dev/null) && - git -C src/lorawan/ diff -U0 empty + git -C src/lorawan/ diff -U0 empty --src-prefix=a/src/lorawan/ --dst-prefix=b/src/lorawan/ | clang-tidy-diff-17.py -path cmake-cache/ -p1 -quiet -use-color -iregex "src\/lorawan\/.+\.(cpp|cc|cxx|c|h|hpp)" diff --git a/.github/workflows/per-commit.yml b/.github/workflows/per-commit.yml index 2e72ae9ef4..d30b4079e6 100644 --- a/.github/workflows/per-commit.yml +++ b/.github/workflows/per-commit.yml @@ -10,7 +10,7 @@ on: jobs: code-formatting: - uses: ./.github/workflows/.formatting.yml + uses: ./.github/workflows/formatting.yml compile: needs: code-formatting @@ -20,24 +20,30 @@ jobs: timeout-minutes: 720 strategy: matrix: - compiler: [g++] - mode: [default, optimized] - stage: [test] include: - compiler: clang++ - mode: debug + mode: optimized + cxxflags: -stdlib=libc++ + stage: test - compiler: g++ mode: debug - - compiler: g++ # this job is the longest (~ 30 min) + - compiler: g++ + mode: default + stage: test + - compiler: g++ + mode: optimized + stage: test + - compiler: g++ mode: debug extra_options: --disable-precompiled-headers - - compiler: g++ + - compiler: clang++ mode: debug - extra_options: --disable-asserts + extra_options: --disable-asserts --disable-logs env: COMPILER: ${{ matrix.compiler }} MODE: ${{ matrix.mode }} EXTRA_OPTIONS: ${{ matrix.extra_options }} + CXXFLAGS: ${{ matrix.cxxflags }} steps: # The following step is required in all jobs that use this repo's actions - name: "Retrieve actions from repository" @@ -54,11 +60,11 @@ jobs: code-linting: needs: compile - uses: ./.github/workflows/.linting.yml + uses: ./.github/workflows/linting.yml documentation: needs: code-linting - uses: ./.github/workflows/.test-doc.yml + uses: ./.github/workflows/test-doc.yml code-analysis: needs: documentation diff --git a/.github/workflows/.test-doc.yml b/.github/workflows/test-doc.yml similarity index 96% rename from .github/workflows/.test-doc.yml rename to .github/workflows/test-doc.yml index 4fbb040712..446c1a1dfb 100644 --- a/.github/workflows/.test-doc.yml +++ b/.github/workflows/test-doc.yml @@ -2,7 +2,9 @@ name: "Test documentation" run-name: "test-doc" -on: workflow_call +on: + workflow_call: + workflow_dispatch: jobs: doxygen: @@ -36,7 +38,7 @@ jobs: ./ns3 clean doxygen -v - name: "Upload doxygen warnings as artifact" - if: always() + if: failure() uses: actions/upload-artifact@v4 with: name: doxygen.warnings.log diff --git a/NS3-VERSION b/NS3-VERSION index c554e3a957..93fc2f1bf4 100644 --- a/NS3-VERSION +++ b/NS3-VERSION @@ -1 +1 @@ -release ns-3.41 \ No newline at end of file +release ns-3.42 \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index bfe442476a..fb74a3170d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,62 +1,55 @@ build_lib_example( NAME simple-network-example SOURCE_FILES simple-network-example.cc - LIBRARIES_TO_LINK - ${libcore} ${liblorawan} + LIBRARIES_TO_LINK ${libcore} + ${liblorawan} ) build_lib_example( NAME network-server-example SOURCE_FILES network-server-example.cc - LIBRARIES_TO_LINK - ${libcore} - ${liblorawan} + LIBRARIES_TO_LINK ${libcore} + ${liblorawan} ) build_lib_example( NAME complete-network-example SOURCE_FILES complete-network-example.cc - LIBRARIES_TO_LINK - ${libcore} - ${liblorawan} + LIBRARIES_TO_LINK ${libcore} + ${liblorawan} ) build_lib_example( NAME adr-example SOURCE_FILES adr-example.cc - LIBRARIES_TO_LINK - ${libcore} - ${liblorawan} + LIBRARIES_TO_LINK ${libcore} + ${liblorawan} ) build_lib_example( NAME lorawan-energy-model-example SOURCE_FILES lorawan-energy-model-example.cc - LIBRARIES_TO_LINK - ${libcore} - ${liblorawan} + LIBRARIES_TO_LINK ${libcore} + ${liblorawan} ) build_lib_example( NAME aloha-throughput SOURCE_FILES aloha-throughput.cc - LIBRARIES_TO_LINK - ${libcore} - ${liblorawan} + LIBRARIES_TO_LINK ${libcore} + ${liblorawan} ) build_lib_example( NAME parallel-reception-example SOURCE_FILES parallel-reception-example.cc - LIBRARIES_TO_LINK - ${libcore} - ${liblorawan} + LIBRARIES_TO_LINK ${libcore} + ${liblorawan} ) build_lib_example( NAME frame-counter-update SOURCE_FILES frame-counter-update.cc - LIBRARIES_TO_LINK - ${libcore} - ${liblorawan} + LIBRARIES_TO_LINK ${libcore} + ${liblorawan} ) diff --git a/examples/aloha-throughput.cc b/examples/aloha-throughput.cc index d893046c90..df605fb6e6 100644 --- a/examples/aloha-throughput.cc +++ b/examples/aloha-throughput.cc @@ -57,7 +57,7 @@ NS_LOG_COMPONENT_DEFINE("AlohaThroughput"); // Network settings int nDevices = 200; //!< Number of end device nodes to create int nGateways = 1; //!< Number of gateway nodes to create -double radiusMeters = 1000; //!< Radius (m) of the deplyoment +double radiusMeters = 1000; //!< Radius (m) of the deployment double simulationTimeSeconds = 100; //!< Scenario duration (s) in simulated time // Channel model diff --git a/examples/complete-network-example.cc b/examples/complete-network-example.cc index 85655934ff..7e803e6554 100644 --- a/examples/complete-network-example.cc +++ b/examples/complete-network-example.cc @@ -57,7 +57,7 @@ NS_LOG_COMPONENT_DEFINE("ComplexLorawanNetworkExample"); // Network settings int nDevices = 200; //!< Number of end device nodes to create int nGateways = 1; //!< Number of gateway nodes to create -double radiusMeters = 6400; //!< Radius (m) of the deplyoment +double radiusMeters = 6400; //!< Radius (m) of the deployment double simulationTimeSeconds = 600; //!< Scenario duration (s) in simulated time // Channel model diff --git a/model/class-a-end-device-lorawan-mac.cc b/model/class-a-end-device-lorawan-mac.cc index 6a835efdd9..6b1c2204f1 100644 --- a/model/class-a-end-device-lorawan-mac.cc +++ b/model/class-a-end-device-lorawan-mac.cc @@ -336,7 +336,6 @@ ClassAEndDeviceLorawanMac::CloseFirstReceiveWindow() break; case EndDeviceLoraPhy::RX: // PHY is receiving: let it finish. The Receive method will switch it back to SLEEP. - break; case EndDeviceLoraPhy::SLEEP: // PHY has received, and the MAC's Receive already put the device to sleep break; @@ -400,7 +399,6 @@ ClassAEndDeviceLorawanMac::CloseSecondReceiveWindow() switch (phy->GetState()) { case EndDeviceLoraPhy::TX: - break; case EndDeviceLoraPhy::SLEEP: break; case EndDeviceLoraPhy::RX: diff --git a/model/end-device-lora-phy.cc b/model/end-device-lora-phy.cc index 31e3b12a1d..c486a79f28 100644 --- a/model/end-device-lora-phy.cc +++ b/model/end-device-lora-phy.cc @@ -117,6 +117,20 @@ EndDeviceLoraPhy::SetFrequency(double frequencyMHz) m_frequency = frequencyMHz; } +void +EndDeviceLoraPhy::TxFinished(Ptr packet) +{ + NS_LOG_FUNCTION(this << packet); + // Switch back to STANDBY mode. + // For reference see SX1272 datasheet, section 4.1.6 + SwitchToStandby(); + // Forward packet to the upper layer (if the callback was set). + if (!m_txFinishedCallback.IsNull()) + { + m_txFinishedCallback(packet); + } +} + void EndDeviceLoraPhy::SwitchToStandby() { diff --git a/model/end-device-lora-phy.h b/model/end-device-lora-phy.h index 847e39a839..f6a1ece3d0 100644 --- a/model/end-device-lora-phy.h +++ b/model/end-device-lora-phy.h @@ -237,6 +237,13 @@ class EndDeviceLoraPhy : public LoraPhy static const double sensitivity[6]; //!< The sensitivity vector of this device to different SFs protected: + /** + * Signals the end of a transmission by the EndDeviceLoraPhy. + * + * \param packet A pointer to the Packet transmitted. + */ + void TxFinished(Ptr packet) override; + /** * Switch to the RX state. */ diff --git a/model/end-device-lorawan-mac.cc b/model/end-device-lorawan-mac.cc index c569c5e435..a4299cad0d 100644 --- a/model/end-device-lorawan-mac.cc +++ b/model/end-device-lorawan-mac.cc @@ -445,17 +445,11 @@ EndDeviceLorawanMac::ParseCommands(LoraFrameHeader frameHeader) break; } - case (RX_TIMING_SETUP_REQ): { - break; - } - case (TX_PARAM_SETUP_REQ): { - break; - } - case (DL_CHANNEL_REQ): { - break; - } + case (RX_TIMING_SETUP_REQ): + case (TX_PARAM_SETUP_REQ): + case (DL_CHANNEL_REQ): default: { - NS_LOG_ERROR("CID not recognized"); + NS_LOG_ERROR("CID not recognized or supported"); break; } } @@ -545,7 +539,7 @@ EndDeviceLorawanMac::GetNextTransmissionDelay() waitingTime = std::min(waitingTime, m_channelHelper.GetWaitingTime(logicalChannel)); - NS_LOG_DEBUG("Waiting time before the next transmission in channel with frequecy " + NS_LOG_DEBUG("Waiting time before the next transmission in channel with frequency " << frequency << " is = " << waitingTime.GetSeconds() << "."); } diff --git a/model/end-device-status.cc b/model/end-device-status.cc index 7e5414f50c..b545b39681 100644 --- a/model/end-device-status.cc +++ b/model/end-device-status.cc @@ -369,7 +369,7 @@ EndDeviceStatus::AddMACCommand(Ptr macCommand) bool EndDeviceStatus::HasReceiveWindowOpportunityScheduled() { - return m_receiveWindowEvent.IsRunning(); + return m_receiveWindowEvent.IsPending(); } void diff --git a/model/gateway-lora-phy.cc b/model/gateway-lora-phy.cc index 1a75706248..fb78a31d88 100644 --- a/model/gateway-lora-phy.cc +++ b/model/gateway-lora-phy.cc @@ -158,7 +158,7 @@ GatewayLoraPhy::ResetReceptionPaths() } void -GatewayLoraPhy::TxFinished(Ptr packet) +GatewayLoraPhy::TxFinished(Ptr packet) { m_isTransmitting = false; } diff --git a/model/gateway-lora-phy.h b/model/gateway-lora-phy.h index 57d47e2bd0..66dd032d66 100644 --- a/model/gateway-lora-phy.h +++ b/model/gateway-lora-phy.h @@ -75,13 +75,6 @@ class GatewayLoraPhy : public LoraPhy double frequencyMHz, double txPowerDbm) override = 0; - /** - * Signals the end of a transmission by the GatewayLoraPhy. - * - * \param packet A pointer to the Packet transmitted. - */ - virtual void TxFinished(Ptr packet); - bool IsTransmitting() override; /** @@ -115,6 +108,13 @@ class GatewayLoraPhy : public LoraPhy //!< correctly decode different spreading factors. protected: + /** + * Signals the end of a transmission by the GatewayLoraPhy. + * + * \param packet A pointer to the Packet transmitted. + */ + void TxFinished(Ptr packet) override; + /** * This class represents a configurable reception path. * diff --git a/model/lora-phy.h b/model/lora-phy.h index 241d7a63bd..6823816181 100644 --- a/model/lora-phy.h +++ b/model/lora-phy.h @@ -268,6 +268,15 @@ class LoraPhy : public Object static Time GetOnAirTime(Ptr packet, LoraTxParameters txParams); private: + /** + * Internal call when transmission of a packet finishes. + * + * Calls to this function are typically scheduled by the Send function. + * + * \param packet A pointer to the packet that has been transmitted. + */ + virtual void TxFinished(Ptr packet) = 0; + Ptr m_mobility; //!< The mobility model associated to this PHY. protected: diff --git a/model/lora-radio-energy-model.h b/model/lora-radio-energy-model.h index 933639432b..376f5dd527 100644 --- a/model/lora-radio-energy-model.h +++ b/model/lora-radio-energy-model.h @@ -32,6 +32,8 @@ namespace ns3 namespace lorawan { +using namespace energy; + /** * \ingroup lorawan * diff --git a/model/simple-end-device-lora-phy.cc b/model/simple-end-device-lora-phy.cc index cc2d7f8644..60a44620ac 100644 --- a/model/simple-end-device-lora-phy.cc +++ b/model/simple-end-device-lora-phy.cc @@ -89,21 +89,8 @@ SimpleEndDeviceLoraPhy::Send(Ptr packet, NS_LOG_INFO("Sending the packet in the channel"); m_channel->Send(this, packet, txPowerDbm, txParams, duration, frequencyMHz); - // Schedule the switch back to STANDBY mode. - // For reference see SX1272 datasheet, section 4.1.6 - Simulator::Schedule(duration, &EndDeviceLoraPhy::SwitchToStandby, this); - - // Schedule the txFinished callback, if it was set - // The call is scheduled just after the switch to standby in case the upper - // layer wishes to change the state. This ensures that it will find a PHY in - // STANDBY mode. - if (!m_txFinishedCallback.IsNull()) - { - Simulator::Schedule(duration + NanoSeconds(10), - &SimpleEndDeviceLoraPhy::m_txFinishedCallback, - this, - packet); - } + // Schedule a call to signal the transmission end. + Simulator::Schedule(duration, &SimpleEndDeviceLoraPhy::TxFinished, this, packet); // Call the trace source if (m_device) diff --git a/test/lorawan-test-suite.cc b/test/lorawan-test-suite.cc index 30eef8a865..6a037aaab8 100644 --- a/test/lorawan-test-suite.cc +++ b/test/lorawan-test-suite.cc @@ -1627,17 +1627,17 @@ class LorawanTestSuite : public TestSuite }; LorawanTestSuite::LorawanTestSuite() - : TestSuite("lorawan", UNIT) + : TestSuite("lorawan", Type::UNIT) { LogComponentEnable("LorawanTestSuite", LOG_LEVEL_DEBUG); // TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER - AddTestCase(new InterferenceTest, TestCase::QUICK); - AddTestCase(new AddressTest, TestCase::QUICK); - AddTestCase(new HeaderTest, TestCase::QUICK); - AddTestCase(new ReceivePathTest, TestCase::QUICK); - AddTestCase(new LogicalLoraChannelTest, TestCase::QUICK); - AddTestCase(new TimeOnAirTest, TestCase::QUICK); - AddTestCase(new PhyConnectivityTest, TestCase::QUICK); + AddTestCase(new InterferenceTest, Duration::QUICK); + AddTestCase(new AddressTest, Duration::QUICK); + AddTestCase(new HeaderTest, Duration::QUICK); + AddTestCase(new ReceivePathTest, Duration::QUICK); + AddTestCase(new LogicalLoraChannelTest, Duration::QUICK); + AddTestCase(new TimeOnAirTest, Duration::QUICK); + AddTestCase(new PhyConnectivityTest, Duration::QUICK); } // Do not forget to allocate an instance of this TestSuite diff --git a/test/network-scheduler-test-suite.cc b/test/network-scheduler-test-suite.cc index 85bc148663..9c61a6cf8f 100644 --- a/test/network-scheduler-test-suite.cc +++ b/test/network-scheduler-test-suite.cc @@ -79,11 +79,11 @@ class NetworkSchedulerTestSuite : public TestSuite }; NetworkSchedulerTestSuite::NetworkSchedulerTestSuite() - : TestSuite("network-scheduler", UNIT) + : TestSuite("network-scheduler", Type::UNIT) { LogComponentEnable("NetworkSchedulerTestSuite", LOG_LEVEL_DEBUG); // TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER - AddTestCase(new NetworkSchedulerTest, TestCase::QUICK); + AddTestCase(new NetworkSchedulerTest, Duration::QUICK); } // Do not forget to allocate an instance of this TestSuite diff --git a/test/network-server-test-suite.cc b/test/network-server-test-suite.cc index f365df0cd3..3bb9c62de2 100644 --- a/test/network-server-test-suite.cc +++ b/test/network-server-test-suite.cc @@ -361,7 +361,7 @@ class NetworkServerTestSuite : public TestSuite }; NetworkServerTestSuite::NetworkServerTestSuite() - : TestSuite("network-server", UNIT) + : TestSuite("network-server", Type::UNIT) { LogComponentEnable("NetworkServerTestSuite", LOG_LEVEL_DEBUG); @@ -381,9 +381,9 @@ NetworkServerTestSuite::NetworkServerTestSuite() LogComponentEnableAll(LOG_PREFIX_TIME); // TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER - AddTestCase(new UplinkPacketTest, TestCase::QUICK); - AddTestCase(new DownlinkPacketTest, TestCase::QUICK); - AddTestCase(new LinkCheckTest, TestCase::QUICK); + AddTestCase(new UplinkPacketTest, Duration::QUICK); + AddTestCase(new DownlinkPacketTest, Duration::QUICK); + AddTestCase(new LinkCheckTest, Duration::QUICK); } // Do not forget to allocate an instance of this TestSuite diff --git a/test/network-status-test-suite.cc b/test/network-status-test-suite.cc index a220e8618a..1e888c9443 100644 --- a/test/network-status-test-suite.cc +++ b/test/network-status-test-suite.cc @@ -135,12 +135,12 @@ class NetworkStatusTestSuite : public TestSuite }; NetworkStatusTestSuite::NetworkStatusTestSuite() - : TestSuite("network-status", UNIT) + : TestSuite("network-status", Type::UNIT) { LogComponentEnable("NetworkStatusTestSuite", LOG_LEVEL_DEBUG); // TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER - AddTestCase(new EndDeviceStatusTest, TestCase::QUICK); - AddTestCase(new NetworkStatusTest, TestCase::QUICK); + AddTestCase(new EndDeviceStatusTest, Duration::QUICK); + AddTestCase(new NetworkStatusTest, Duration::QUICK); } // Do not forget to allocate an instance of this TestSuite