From b9339f3736390ee1bf5a745aa35176f1ab917d08 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Tue, 1 Nov 2022 15:49:49 -0700 Subject: [PATCH 001/494] Start RELEASE_NOTES.md and CHANGES.md sections for new release --- CHANGES.md | 11 +++++++++++ RELEASE_NOTES.md | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 044b398d0..dfdbfb9f5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,17 @@ Note that users who upgrade the simulator across versions, or who work directly This file is a best-effort approach to solving this issue; we will do our best but can guarantee that there will be things that fall through the cracks, unfortunately. If you, as a user, can suggest improvements to this file based on your experience, please contribute a patch or drop us a note on ns-developers mailing list. +Changes from ns-3.37 to ns-3.38 +------------------------------- + +### New API + +### Changes to existing API + +### Changes to build system + +### Changed behavior + Changes from ns-3.36 to ns-3.37 ------------------------------- diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 46f2b1de4..9b0031168 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -13,6 +13,13 @@ a [GitLab.com issue tracker](https://gitlab.com/nsnam/ns-3-dev/-/issues) number, and references prefixed by '!' refer to a [GitLab.com merge request](https://gitlab.com/nsnam/ns-3-dev/-/merge_requests) number. +Release 3-dev +------------- + +### New user-visible features + +### Bugs fixed + Release 3.37 ------------ From ad43a52197b4c3620618eb3cacd978a6a65de02f Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Wed, 2 Nov 2022 07:00:14 -0700 Subject: [PATCH 002/494] doc: Update release steps for version.cache --- doc/release_steps.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/release_steps.txt b/doc/release_steps.txt index 673066001..43ecc9d73 100644 --- a/doc/release_steps.txt +++ b/doc/release_steps.txt @@ -124,16 +124,16 @@ bake commit ba47854c (July 14, 2021). Make sure that the version.cache file included in the source archive looks something like the below example: -CLOSEST_TAG = '"ns-3.36.1"' -VERSION_COMMIT_HASH = '"g7004d1a66"' +CLOSEST_TAG = '"ns-3.37"' +VERSION_COMMIT_HASH = '"g4407a9528"' VERSION_DIRTY_FLAG = '0' VERSION_MAJOR = '3' -VERSION_MINOR = '36' -VERSION_PATCH = '1' +VERSION_MINOR = '37' +VERSION_PATCH = '0' VERSION_RELEASE_CANDIDATE = '""' -VERSION_TAG = '"ns-3.36.1"' +VERSION_TAG = '"ns-3.37"' VERSION_TAG_DISTANCE = '0' -VERSION_BUILD_PROFILE = 'relwithdebinfo +VERSION_BUILD_PROFILE = 'default' 4. Test this tarball on at least one system - check that ns-3-allinone build.py works From 65fa318a0cd7d1cfafbcf6fa1432a1dbda403465 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Wed, 2 Nov 2022 07:01:09 -0700 Subject: [PATCH 003/494] doc: Update documentation about making releases --- doc/manual/source/working-with-git.rst | 32 ++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/doc/manual/source/working-with-git.rst b/doc/manual/source/working-with-git.rst index da6f4c98c..3cefb456e 100644 --- a/doc/manual/source/working-with-git.rst +++ b/doc/manual/source/working-with-git.rst @@ -359,17 +359,19 @@ We change the VERSION field from '3-dev' to '3.34':: $ cat VERSION 3.34 -We next change the file conf.py in the tutorial, manual, and models directories +We next change the file conf.py in the contributing, tutorial, manual, and models directories to change the strings 'ns-3-dev' to ns-3.34. -When you are done, the 'git status' command should show: +When you are done, the 'git diff --stat' command should show: :: - VERSION | 2 +- - doc/manual/source/conf.py | 4 ++-- - doc/models/source/conf.py | 4 ++-- - doc/tutorial/source/conf.py | 4 ++-- + VERSION | 2 +- + doc/contributing/source/conf.py | 4 ++-- + doc/manual/source/conf.py | 4 ++-- + doc/models/source/conf.py | 4 ++-- + doc/tutorial/source/conf.py | 4 ++-- + 5 files changed, 9 insertions(+), 9 deletions(-) Make a commit of these files: @@ -377,17 +379,23 @@ Make a commit of these files: $ git commit -a -m"Update VERSION and documentation tags for ns-3.34 release" -Next, make the following change to RELEASE_NOTES and commit it: +Next, make the following change to RELEASE_NOTES.md and commit it: :: - Availability - ------------ - -This release is not yet available. + -Release 3-dev + -------------- + +Release 3.34 + +------------ + + + +### Availability + + +This release is available from: - +https://www.nsnam.org/release/ns-allinone-3.34.tar.bz2 + + - $ git commit -m"Update availability in RELEASE_NOTES" RELEASE_NOTES +Commit this change: + + $ git commit -m"Update availability in RELEASE_NOTES.md" RELEASE_NOTES.md Finally, add a git annotated tag: From 89a6e7f370e78cd0ad0aa9be5eb725984bb2aecc Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Wed, 2 Nov 2022 07:02:14 -0700 Subject: [PATCH 004/494] core: add deprecated for ns-3.37 --- src/core/model/deprecated.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/model/deprecated.h b/src/core/model/deprecated.h index c67431341..9c9b2c2f5 100644 --- a/src/core/model/deprecated.h +++ b/src/core/model/deprecated.h @@ -65,6 +65,13 @@ */ #define NS_DEPRECATED(msg) [[deprecated(msg)]] +/** + * \ingroup core + * \def NS_DEPRECATED_3_38 + * Tag for things deprecated in version ns-3.38. + */ +#define NS_DEPRECATED_3_38(msg) NS_DEPRECATED(msg) + /** * \ingroup core * \def NS_DEPRECATED_3_37 From 94210b5fafdeaf5ba97e34a89892eece6b65420a Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Wed, 2 Nov 2022 07:07:54 -0700 Subject: [PATCH 005/494] Update link to ns-developers --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3b43000a7..8e869dfd2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -61,7 +61,7 @@ ns-3 is intentionally very modular, and it's possible that a feature you need or ### Design Decisions -When we make a significant decision in how we maintain the project and what we can or cannot support, we will document it through the [ns-developers mailing list](https://mailman.isi.edu/mailman/listinfo/ns-developers). If you have a question around how we do things, please subscribe and lurk around to see how we proceed. If you have a development problem, please open a new topic and ask your question. +When we make a significant decision in how we maintain the project and what we can or cannot support, we will document it through the [ns-developers mailing list](https://groups.google.com/g/ns-developers). If you have a question around how we do things, please subscribe and lurk around to see how we proceed. If you have a development problem, please open a new topic and ask your question. ## How Can I Contribute? From 9c391961b2084c22ec69dcbef88db9413c6de2d0 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Wed, 2 Nov 2022 23:44:38 +0100 Subject: [PATCH 006/494] lte: remove deprecated sprintf from test --- src/lte/test/test-asn1-encoding.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lte/test/test-asn1-encoding.cc b/src/lte/test/test-asn1-encoding.cc index 0a0cb78a3..5c60c9294 100644 --- a/src/lte/test/test-asn1-encoding.cc +++ b/src/lte/test/test-asn1-encoding.cc @@ -50,13 +50,13 @@ class TestUtils { uint32_t psize = pkt->GetSize(); uint8_t buffer[psize]; - char sbuffer[psize * 3]; + std::ostringstream oss(std::ostringstream::out); pkt->CopyData(buffer, psize); for (uint32_t i = 0; i < psize; i++) { - sprintf(&sbuffer[i * 3], "%02x ", buffer[i]); + oss << std::setfill('0') << std::setw(2) << std::hex << +(buffer[i]) << " "; } - return std::string(sbuffer); + return std::string(oss.str() + "\n"); } /** From e8c0c7036f05daceab51d5259d64432ce2a156c9 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Thu, 3 Nov 2022 09:21:17 +0100 Subject: [PATCH 007/494] lte: fix missing header in test --- src/lte/test/test-asn1-encoding.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lte/test/test-asn1-encoding.cc b/src/lte/test/test-asn1-encoding.cc index 5c60c9294..f76e90333 100644 --- a/src/lte/test/test-asn1-encoding.cc +++ b/src/lte/test/test-asn1-encoding.cc @@ -28,6 +28,8 @@ #include "ns3/string.h" #include "ns3/test.h" +#include + using namespace ns3; NS_LOG_COMPONENT_DEFINE("Asn1EncodingTest"); From a736c7a09d34fda3260148ad247794325b4c9137 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Sat, 5 Nov 2022 22:37:00 +0000 Subject: [PATCH 008/494] ci: downgrade doxygen 1.9.5 (bugged) to 1.9.3 --- utils/tests/gitlab-ci-doc.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/tests/gitlab-ci-doc.yml b/utils/tests/gitlab-ci-doc.yml index bf4c3e28f..2c15444d8 100644 --- a/utils/tests/gitlab-ci-doc.yml +++ b/utils/tests/gitlab-ci-doc.yml @@ -7,9 +7,11 @@ - pacman-key --init - pacman -Syu --noconfirm base-devel ninja cmake python ccache gsl gtk3 boost - doxygen graphviz imagemagick texlive-core texlive-bin texlive-latexextra python-sphinx + graphviz imagemagick texlive-core texlive-bin texlive-latexextra python-sphinx # dia is self-hosted - pacman --noconfirm -U https://www.nsnam.org/wp-content/uploads/2022/dia-0.97.3-9-x86_64.pkg.tar.zst + # doxygen 1.9.5 is bugged. Keep it at 1.9.3 until the bug is resolved (hopefully in 1.9.6) + - pacman --noconfirm -U https://archive.archlinux.org/packages/d/doxygen/doxygen-1.9.3-1-x86_64.pkg.tar.zst # no policy is a good policy. - mv /etc/ImageMagick-7/policy.xml /etc/ImageMagick-7/policy.xml.bak # - sed -i "s/EPS,PDF,//g" /etc/ImageMagick-7/policy.xml From acab6a38e8f8eb193ab2b20c67da5caf6a43f194 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Mon, 10 Oct 2022 15:55:23 +0000 Subject: [PATCH 009/494] lte: Mark deleted constructors as deleted --- src/lte/model/epc-enb-s1-sap.h | 18 +++++---------- src/lte/model/epc-s11-sap.h | 18 +++++---------- src/lte/model/epc-s1ap-sap.h | 18 +++++---------- src/lte/model/epc-x2-sap.h | 18 +++++---------- src/lte/model/ff-mac-csched-sap.h | 9 +++----- src/lte/model/ff-mac-sched-sap.h | 9 +++----- src/lte/model/lte-as-sap.h | 18 +++++---------- src/lte/model/lte-enb-cphy-sap.h | 18 +++++---------- src/lte/model/lte-pdcp-sap.h | 18 +++++---------- src/lte/model/lte-rlc-sap.h | 18 +++++---------- src/lte/model/lte-rrc-sap.h | 38 ++++++++++--------------------- src/lte/model/lte-ue-cphy-sap.h | 18 +++++---------- 12 files changed, 72 insertions(+), 146 deletions(-) diff --git a/src/lte/model/epc-enb-s1-sap.h b/src/lte/model/epc-enb-s1-sap.h index 66a97ab07..431098566 100644 --- a/src/lte/model/epc-enb-s1-sap.h +++ b/src/lte/model/epc-enb-s1-sap.h @@ -163,6 +163,9 @@ class MemberEpcEnbS1SapProvider : public EpcEnbS1SapProvider */ MemberEpcEnbS1SapProvider(C* owner); + // Delete default constructor to avoid misuse + MemberEpcEnbS1SapProvider() = delete; + // inherited from EpcEnbS1SapProvider void InitialUeMessage(uint64_t imsi, uint16_t rnti) override; void DoSendReleaseIndication(uint64_t imsi, uint16_t rnti, uint8_t bearerId) override; @@ -171,7 +174,6 @@ class MemberEpcEnbS1SapProvider : public EpcEnbS1SapProvider void UeContextRelease(uint16_t rnti) override; private: - MemberEpcEnbS1SapProvider(); C* m_owner; ///< owner class }; @@ -181,11 +183,6 @@ MemberEpcEnbS1SapProvider::MemberEpcEnbS1SapProvider(C* owner) { } -template -MemberEpcEnbS1SapProvider::MemberEpcEnbS1SapProvider() -{ -} - template void MemberEpcEnbS1SapProvider::InitialUeMessage(uint64_t imsi, uint16_t rnti) @@ -231,13 +228,15 @@ class MemberEpcEnbS1SapUser : public EpcEnbS1SapUser */ MemberEpcEnbS1SapUser(C* owner); + // Delete default constructor to avoid misuse + MemberEpcEnbS1SapUser() = delete; + // inherited from EpcEnbS1SapUser void InitialContextSetupRequest(InitialContextSetupRequestParameters params) override; void DataRadioBearerSetupRequest(DataRadioBearerSetupRequestParameters params) override; void PathSwitchRequestAcknowledge(PathSwitchRequestAcknowledgeParameters params) override; private: - MemberEpcEnbS1SapUser(); C* m_owner; ///< owner class }; @@ -247,11 +246,6 @@ MemberEpcEnbS1SapUser::MemberEpcEnbS1SapUser(C* owner) { } -template -MemberEpcEnbS1SapUser::MemberEpcEnbS1SapUser() -{ -} - template void MemberEpcEnbS1SapUser::InitialContextSetupRequest(InitialContextSetupRequestParameters params) diff --git a/src/lte/model/epc-s11-sap.h b/src/lte/model/epc-s11-sap.h index a85cb8e20..2a65c3c23 100644 --- a/src/lte/model/epc-s11-sap.h +++ b/src/lte/model/epc-s11-sap.h @@ -257,13 +257,15 @@ class MemberEpcS11SapMme : public EpcS11SapMme */ MemberEpcS11SapMme(C* owner); + // Delete default constructor to avoid misuse + MemberEpcS11SapMme() = delete; + // inherited from EpcS11SapMme void CreateSessionResponse(CreateSessionResponseMessage msg) override; void ModifyBearerResponse(ModifyBearerResponseMessage msg) override; void DeleteBearerRequest(DeleteBearerRequestMessage msg) override; private: - MemberEpcS11SapMme(); C* m_owner; ///< owner class }; @@ -278,11 +280,6 @@ MemberEpcS11SapMme::MemberEpcS11SapMme(C* owner) { } -template -MemberEpcS11SapMme::MemberEpcS11SapMme() -{ -} - template void MemberEpcS11SapMme::CreateSessionResponse(CreateSessionResponseMessage msg) @@ -319,6 +316,9 @@ class MemberEpcS11SapSgw : public EpcS11SapSgw */ MemberEpcS11SapSgw(C* owner); + // Delete default constructor to avoid misuse + MemberEpcS11SapSgw() = delete; + // inherited from EpcS11SapSgw void CreateSessionRequest(CreateSessionRequestMessage msg) override; void ModifyBearerRequest(ModifyBearerRequestMessage msg) override; @@ -326,7 +326,6 @@ class MemberEpcS11SapSgw : public EpcS11SapSgw void DeleteBearerResponse(DeleteBearerResponseMessage msg) override; private: - MemberEpcS11SapSgw(); C* m_owner; ///< owner class }; @@ -341,11 +340,6 @@ MemberEpcS11SapSgw::MemberEpcS11SapSgw(C* owner) { } -template -MemberEpcS11SapSgw::MemberEpcS11SapSgw() -{ -} - template void MemberEpcS11SapSgw::CreateSessionRequest(CreateSessionRequestMessage msg) diff --git a/src/lte/model/epc-s1ap-sap.h b/src/lte/model/epc-s1ap-sap.h index 3fbce8f80..46f5bcbea 100644 --- a/src/lte/model/epc-s1ap-sap.h +++ b/src/lte/model/epc-s1ap-sap.h @@ -202,6 +202,9 @@ class MemberEpcS1apSapMme : public EpcS1apSapMme */ MemberEpcS1apSapMme(C* owner); + // Delete default constructor to avoid misuse + MemberEpcS1apSapMme() = delete; + // inherited from EpcS1apSapMme /** * Initial UE Message function @@ -248,7 +251,6 @@ class MemberEpcS1apSapMme : public EpcS1apSapMme std::list erabToBeSwitchedInDownlinkList) override; private: - MemberEpcS1apSapMme(); C* m_owner; ///< owner class }; @@ -258,11 +260,6 @@ MemberEpcS1apSapMme::MemberEpcS1apSapMme(C* owner) { } -template -MemberEpcS1apSapMme::MemberEpcS1apSapMme() -{ -} - template void MemberEpcS1apSapMme::InitialUeMessage(uint64_t mmeUeS1Id, @@ -318,6 +315,9 @@ class MemberEpcS1apSapEnb : public EpcS1apSapEnb */ MemberEpcS1apSapEnb(C* owner); + // Delete default constructor to avoid misuse + MemberEpcS1apSapEnb() = delete; + // inherited from EpcS1apSapEnb /** * Initial context setup request function @@ -342,7 +342,6 @@ class MemberEpcS1apSapEnb : public EpcS1apSapEnb std::list erabToBeSwitchedInUplinkList) override; private: - MemberEpcS1apSapEnb(); C* m_owner; ///< owner class }; @@ -352,11 +351,6 @@ MemberEpcS1apSapEnb::MemberEpcS1apSapEnb(C* owner) { } -template -MemberEpcS1apSapEnb::MemberEpcS1apSapEnb() -{ -} - template void MemberEpcS1apSapEnb::InitialContextSetupRequest(uint64_t mmeUeS1Id, diff --git a/src/lte/model/epc-x2-sap.h b/src/lte/model/epc-x2-sap.h index a99c71796..0b20118ef 100644 --- a/src/lte/model/epc-x2-sap.h +++ b/src/lte/model/epc-x2-sap.h @@ -503,6 +503,9 @@ class EpcX2SpecificEpcX2SapProvider : public EpcX2SapProvider */ EpcX2SpecificEpcX2SapProvider(C* x2); + // Delete default constructor to avoid misuse + EpcX2SpecificEpcX2SapProvider() = delete; + // // Interface implemented from EpcX2SapProvider // @@ -562,7 +565,6 @@ class EpcX2SpecificEpcX2SapProvider : public EpcX2SapProvider void SendHandoverCancel(HandoverCancelParams params) override; private: - EpcX2SpecificEpcX2SapProvider(); C* m_x2; ///< owner class }; @@ -572,11 +574,6 @@ EpcX2SpecificEpcX2SapProvider::EpcX2SpecificEpcX2SapProvider(C* x2) { } -template -EpcX2SpecificEpcX2SapProvider::EpcX2SpecificEpcX2SapProvider() -{ -} - template void EpcX2SpecificEpcX2SapProvider::SendHandoverRequest(HandoverRequestParams params) @@ -655,6 +652,9 @@ class EpcX2SpecificEpcX2SapUser : public EpcX2SapUser */ EpcX2SpecificEpcX2SapUser(C* rrc); + // Delete default constructor to avoid misuse + EpcX2SpecificEpcX2SapUser() = delete; + // // Interface implemented from EpcX2SapUser // @@ -715,7 +715,6 @@ class EpcX2SpecificEpcX2SapUser : public EpcX2SapUser void RecvHandoverCancel(HandoverCancelParams params) override; private: - EpcX2SpecificEpcX2SapUser(); C* m_rrc; ///< owner class }; @@ -725,11 +724,6 @@ EpcX2SpecificEpcX2SapUser::EpcX2SpecificEpcX2SapUser(C* rrc) { } -template -EpcX2SpecificEpcX2SapUser::EpcX2SpecificEpcX2SapUser() -{ -} - template void EpcX2SpecificEpcX2SapUser::RecvHandoverRequest(HandoverRequestParams params) diff --git a/src/lte/model/ff-mac-csched-sap.h b/src/lte/model/ff-mac-csched-sap.h index 6d32a6360..44e393126 100644 --- a/src/lte/model/ff-mac-csched-sap.h +++ b/src/lte/model/ff-mac-csched-sap.h @@ -470,6 +470,9 @@ class MemberCschedSapProvider : public FfMacCschedSapProvider */ MemberCschedSapProvider(C* scheduler); + // Delete default constructor to avoid misuse + MemberCschedSapProvider() = delete; + // inherited from FfMacCschedSapProvider void CschedCellConfigReq(const struct CschedCellConfigReqParameters& params) override; void CschedUeConfigReq(const struct CschedUeConfigReqParameters& params) override; @@ -478,15 +481,9 @@ class MemberCschedSapProvider : public FfMacCschedSapProvider void CschedUeReleaseReq(const struct CschedUeReleaseReqParameters& params) override; private: - MemberCschedSapProvider(); C* m_scheduler; ///< scheduler class }; -template -MemberCschedSapProvider::MemberCschedSapProvider() -{ -} - template MemberCschedSapProvider::MemberCschedSapProvider(C* scheduler) : m_scheduler(scheduler) diff --git a/src/lte/model/ff-mac-sched-sap.h b/src/lte/model/ff-mac-sched-sap.h index b5e4e25ab..9e6f6a87a 100644 --- a/src/lte/model/ff-mac-sched-sap.h +++ b/src/lte/model/ff-mac-sched-sap.h @@ -360,6 +360,9 @@ class MemberSchedSapProvider : public FfMacSchedSapProvider */ MemberSchedSapProvider(C* scheduler); + // Delete default constructor to avoid misuse + MemberSchedSapProvider() = delete; + // inherited from FfMacSchedSapProvider void SchedDlRlcBufferReq(const struct SchedDlRlcBufferReqParameters& params) override; void SchedDlPagingBufferReq(const struct SchedDlPagingBufferReqParameters& params) override; @@ -375,15 +378,9 @@ class MemberSchedSapProvider : public FfMacSchedSapProvider void SchedUlCqiInfoReq(const struct SchedUlCqiInfoReqParameters& params) override; private: - MemberSchedSapProvider(); C* m_scheduler; ///< the scheduler class }; -template -MemberSchedSapProvider::MemberSchedSapProvider() -{ -} - template MemberSchedSapProvider::MemberSchedSapProvider(C* scheduler) : m_scheduler(scheduler) diff --git a/src/lte/model/lte-as-sap.h b/src/lte/model/lte-as-sap.h index 05e9fea56..680278540 100644 --- a/src/lte/model/lte-as-sap.h +++ b/src/lte/model/lte-as-sap.h @@ -137,6 +137,9 @@ class MemberLteAsSapProvider : public LteAsSapProvider */ MemberLteAsSapProvider(C* owner); + // Delete default constructor to avoid misuse + MemberLteAsSapProvider() = delete; + // inherited from LteAsSapProvider void SetCsgWhiteList(uint32_t csgId) override; void StartCellSelection(uint32_t dlEarfcn) override; @@ -146,7 +149,6 @@ class MemberLteAsSapProvider : public LteAsSapProvider void Disconnect() override; private: - MemberLteAsSapProvider(); C* m_owner; ///< the owner class }; @@ -156,11 +158,6 @@ MemberLteAsSapProvider::MemberLteAsSapProvider(C* owner) { } -template -MemberLteAsSapProvider::MemberLteAsSapProvider() -{ -} - template void MemberLteAsSapProvider::SetCsgWhiteList(uint32_t csgId) @@ -218,6 +215,9 @@ class MemberLteAsSapUser : public LteAsSapUser */ MemberLteAsSapUser(C* owner); + // Delete default constructor to avoid misuse + MemberLteAsSapUser() = delete; + // inherited from LteAsSapUser void NotifyConnectionSuccessful() override; void NotifyConnectionFailed() override; @@ -225,7 +225,6 @@ class MemberLteAsSapUser : public LteAsSapUser void NotifyConnectionReleased() override; private: - MemberLteAsSapUser(); C* m_owner; ///< the owner class }; @@ -235,11 +234,6 @@ MemberLteAsSapUser::MemberLteAsSapUser(C* owner) { } -template -MemberLteAsSapUser::MemberLteAsSapUser() -{ -} - template void MemberLteAsSapUser::NotifyConnectionSuccessful() diff --git a/src/lte/model/lte-enb-cphy-sap.h b/src/lte/model/lte-enb-cphy-sap.h index d1bb52090..2f09ebab9 100644 --- a/src/lte/model/lte-enb-cphy-sap.h +++ b/src/lte/model/lte-enb-cphy-sap.h @@ -158,6 +158,9 @@ class MemberLteEnbCphySapProvider : public LteEnbCphySapProvider */ MemberLteEnbCphySapProvider(C* owner); + // Delete default constructor to avoid misuse + MemberLteEnbCphySapProvider() = delete; + // inherited from LteEnbCphySapProvider void SetCellId(uint16_t cellId) override; void SetBandwidth(uint16_t ulBandwidth, uint16_t dlBandwidth) override; @@ -172,7 +175,6 @@ class MemberLteEnbCphySapProvider : public LteEnbCphySapProvider int8_t GetReferenceSignalPower() override; private: - MemberLteEnbCphySapProvider(); C* m_owner; ///< the owner class }; @@ -182,11 +184,6 @@ MemberLteEnbCphySapProvider::MemberLteEnbCphySapProvider(C* owner) { } -template -MemberLteEnbCphySapProvider::MemberLteEnbCphySapProvider() -{ -} - template void MemberLteEnbCphySapProvider::SetCellId(uint16_t cellId) @@ -280,10 +277,12 @@ class MemberLteEnbCphySapUser : public LteEnbCphySapUser */ MemberLteEnbCphySapUser(C* owner); + // Delete default constructor to avoid misuse + MemberLteEnbCphySapUser() = delete; + // methods inherited from LteEnbCphySapUser go here private: - MemberLteEnbCphySapUser(); C* m_owner; ///< the owner class }; @@ -293,11 +292,6 @@ MemberLteEnbCphySapUser::MemberLteEnbCphySapUser(C* owner) { } -template -MemberLteEnbCphySapUser::MemberLteEnbCphySapUser() -{ -} - } // namespace ns3 #endif // LTE_ENB_CPHY_SAP_H diff --git a/src/lte/model/lte-pdcp-sap.h b/src/lte/model/lte-pdcp-sap.h index 56d57e777..545c5c2d7 100644 --- a/src/lte/model/lte-pdcp-sap.h +++ b/src/lte/model/lte-pdcp-sap.h @@ -100,11 +100,13 @@ class LtePdcpSpecificLtePdcpSapProvider : public LtePdcpSapProvider */ LtePdcpSpecificLtePdcpSapProvider(C* pdcp); + // Delete default constructor to avoid misuse + LtePdcpSpecificLtePdcpSapProvider() = delete; + // Interface implemented from LtePdcpSapProvider void TransmitPdcpSdu(TransmitPdcpSduParameters params) override; private: - LtePdcpSpecificLtePdcpSapProvider(); C* m_pdcp; ///< the PDCP }; @@ -114,11 +116,6 @@ LtePdcpSpecificLtePdcpSapProvider::LtePdcpSpecificLtePdcpSapProvider(C* pdcp) { } -template -LtePdcpSpecificLtePdcpSapProvider::LtePdcpSpecificLtePdcpSapProvider() -{ -} - template void LtePdcpSpecificLtePdcpSapProvider::TransmitPdcpSdu(TransmitPdcpSduParameters params) @@ -138,11 +135,13 @@ class LtePdcpSpecificLtePdcpSapUser : public LtePdcpSapUser */ LtePdcpSpecificLtePdcpSapUser(C* rrc); + // Delete default constructor to avoid misuse + LtePdcpSpecificLtePdcpSapUser() = delete; + // Interface implemented from LtePdcpSapUser void ReceivePdcpSdu(ReceivePdcpSduParameters params) override; private: - LtePdcpSpecificLtePdcpSapUser(); C* m_rrc; ///< RRC }; @@ -152,11 +151,6 @@ LtePdcpSpecificLtePdcpSapUser::LtePdcpSpecificLtePdcpSapUser(C* rrc) { } -template -LtePdcpSpecificLtePdcpSapUser::LtePdcpSpecificLtePdcpSapUser() -{ -} - template void LtePdcpSpecificLtePdcpSapUser::ReceivePdcpSdu(ReceivePdcpSduParameters params) diff --git a/src/lte/model/lte-rlc-sap.h b/src/lte/model/lte-rlc-sap.h index af6d21092..f451c3fcf 100644 --- a/src/lte/model/lte-rlc-sap.h +++ b/src/lte/model/lte-rlc-sap.h @@ -88,6 +88,9 @@ class LteRlcSpecificLteRlcSapProvider : public LteRlcSapProvider */ LteRlcSpecificLteRlcSapProvider(C* rlc); + // Delete default constructor to avoid misuse + LteRlcSpecificLteRlcSapProvider() = delete; + /** * Interface implemented from LteRlcSapProvider * \param params the TransmitPdcpPduParameters @@ -95,7 +98,6 @@ class LteRlcSpecificLteRlcSapProvider : public LteRlcSapProvider void TransmitPdcpPdu(TransmitPdcpPduParameters params) override; private: - LteRlcSpecificLteRlcSapProvider(); C* m_rlc; ///< the RLC }; @@ -105,11 +107,6 @@ LteRlcSpecificLteRlcSapProvider::LteRlcSpecificLteRlcSapProvider(C* rlc) { } -template -LteRlcSpecificLteRlcSapProvider::LteRlcSpecificLteRlcSapProvider() -{ -} - template void LteRlcSpecificLteRlcSapProvider::TransmitPdcpPdu(TransmitPdcpPduParameters params) @@ -129,11 +126,13 @@ class LteRlcSpecificLteRlcSapUser : public LteRlcSapUser */ LteRlcSpecificLteRlcSapUser(C* pdcp); + // Delete default constructor to avoid misuse + LteRlcSpecificLteRlcSapUser() = delete; + // Interface implemented from LteRlcSapUser void ReceivePdcpPdu(Ptr p) override; private: - LteRlcSpecificLteRlcSapUser(); C* m_pdcp; ///< the PDCP }; @@ -143,11 +142,6 @@ LteRlcSpecificLteRlcSapUser::LteRlcSpecificLteRlcSapUser(C* pdcp) { } -template -LteRlcSpecificLteRlcSapUser::LteRlcSpecificLteRlcSapUser() -{ -} - template void LteRlcSpecificLteRlcSapUser::ReceivePdcpPdu(Ptr p) diff --git a/src/lte/model/lte-rrc-sap.h b/src/lte/model/lte-rrc-sap.h index 3289f1f01..22c0e2a97 100644 --- a/src/lte/model/lte-rrc-sap.h +++ b/src/lte/model/lte-rrc-sap.h @@ -1336,6 +1336,9 @@ class MemberLteUeRrcSapUser : public LteUeRrcSapUser */ MemberLteUeRrcSapUser(C* owner); + // Delete default constructor to avoid misuse + MemberLteUeRrcSapUser() = delete; + // inherited from LteUeRrcSapUser void Setup(SetupParameters params) override; void SendRrcConnectionRequest(RrcConnectionRequest msg) override; @@ -1349,7 +1352,6 @@ class MemberLteUeRrcSapUser : public LteUeRrcSapUser void SendIdealUeContextRemoveRequest(uint16_t rnti) override; private: - MemberLteUeRrcSapUser(); C* m_owner; ///< the owner class }; @@ -1359,11 +1361,6 @@ MemberLteUeRrcSapUser::MemberLteUeRrcSapUser(C* owner) { } -template -MemberLteUeRrcSapUser::MemberLteUeRrcSapUser() -{ -} - template void MemberLteUeRrcSapUser::Setup(SetupParameters params) @@ -1438,6 +1435,9 @@ class MemberLteUeRrcSapProvider : public LteUeRrcSapProvider */ MemberLteUeRrcSapProvider(C* owner); + // Delete default constructor to avoid misuse + MemberLteUeRrcSapProvider() = delete; + // methods inherited from LteUeRrcSapProvider go here void CompleteSetup(CompleteSetupParameters params) override; void RecvSystemInformation(SystemInformation msg) override; @@ -1449,7 +1449,6 @@ class MemberLteUeRrcSapProvider : public LteUeRrcSapProvider void RecvRrcConnectionReject(RrcConnectionReject msg) override; private: - MemberLteUeRrcSapProvider(); C* m_owner; ///< the owner class }; @@ -1459,11 +1458,6 @@ MemberLteUeRrcSapProvider::MemberLteUeRrcSapProvider(C* owner) { } -template -MemberLteUeRrcSapProvider::MemberLteUeRrcSapProvider() -{ -} - template void MemberLteUeRrcSapProvider::CompleteSetup(CompleteSetupParameters params) @@ -1537,8 +1531,10 @@ class MemberLteEnbRrcSapUser : public LteEnbRrcSapUser */ MemberLteEnbRrcSapUser(C* owner); - // inherited from LteEnbRrcSapUser + // Delete default constructor to avoid misuse + MemberLteEnbRrcSapUser() = delete; + // inherited from LteEnbRrcSapUser void SetupUe(uint16_t rnti, SetupUeParameters params) override; void RemoveUe(uint16_t rnti) override; void SendSystemInformation(uint16_t cellId, SystemInformation msg) override; @@ -1555,7 +1551,6 @@ class MemberLteEnbRrcSapUser : public LteEnbRrcSapUser RrcConnectionReconfiguration DecodeHandoverCommand(Ptr p) override; private: - MemberLteEnbRrcSapUser(); C* m_owner; ///< the owner class }; @@ -1565,11 +1560,6 @@ MemberLteEnbRrcSapUser::MemberLteEnbRrcSapUser(C* owner) { } -template -MemberLteEnbRrcSapUser::MemberLteEnbRrcSapUser() -{ -} - template void MemberLteEnbRrcSapUser::SetupUe(uint16_t rnti, SetupUeParameters params) @@ -1680,8 +1670,10 @@ class MemberLteEnbRrcSapProvider : public LteEnbRrcSapProvider */ MemberLteEnbRrcSapProvider(C* owner); - // methods inherited from LteEnbRrcSapProvider go here + // Delete default constructor to avoid misuse + MemberLteEnbRrcSapProvider() = delete; + // methods inherited from LteEnbRrcSapProvider go here void CompleteSetupUe(uint16_t rnti, CompleteSetupUeParameters params) override; void RecvRrcConnectionRequest(uint16_t rnti, RrcConnectionRequest msg) override; void RecvRrcConnectionSetupCompleted(uint16_t rnti, RrcConnectionSetupCompleted msg) override; @@ -1697,7 +1689,6 @@ class MemberLteEnbRrcSapProvider : public LteEnbRrcSapProvider void RecvIdealUeContextRemoveRequest(uint16_t rnti) override; private: - MemberLteEnbRrcSapProvider(); C* m_owner; ///< the owner class }; @@ -1707,11 +1698,6 @@ MemberLteEnbRrcSapProvider::MemberLteEnbRrcSapProvider(C* owner) { } -template -MemberLteEnbRrcSapProvider::MemberLteEnbRrcSapProvider() -{ -} - template void MemberLteEnbRrcSapProvider::CompleteSetupUe(uint16_t rnti, CompleteSetupUeParameters params) diff --git a/src/lte/model/lte-ue-cphy-sap.h b/src/lte/model/lte-ue-cphy-sap.h index 78d28fd53..c8af203ce 100644 --- a/src/lte/model/lte-ue-cphy-sap.h +++ b/src/lte/model/lte-ue-cphy-sap.h @@ -307,6 +307,9 @@ class MemberLteUeCphySapProvider : public LteUeCphySapProvider */ MemberLteUeCphySapProvider(C* owner); + // Delete default constructor to avoid misuse + MemberLteUeCphySapProvider() = delete; + // inherited from LteUeCphySapProvider void Reset() override; void StartCellSearch(uint32_t dlEarfcn) override; @@ -328,7 +331,6 @@ class MemberLteUeCphySapProvider : public LteUeCphySapProvider void SetImsi(uint64_t imsi) override; private: - MemberLteUeCphySapProvider(); C* m_owner; ///< the owner class }; @@ -338,11 +340,6 @@ MemberLteUeCphySapProvider::MemberLteUeCphySapProvider(C* owner) { } -template -MemberLteUeCphySapProvider::MemberLteUeCphySapProvider() -{ -} - template void MemberLteUeCphySapProvider::Reset() @@ -484,6 +481,9 @@ class MemberLteUeCphySapUser : public LteUeCphySapUser */ MemberLteUeCphySapUser(C* owner); + // Delete default constructor to avoid misuse + MemberLteUeCphySapUser() = delete; + // methods inherited from LteUeCphySapUser go here void RecvMasterInformationBlock(uint16_t cellId, LteRrcSap::MasterInformationBlock mib) override; @@ -495,7 +495,6 @@ class MemberLteUeCphySapUser : public LteUeCphySapUser void ResetSyncIndicationCounter() override; private: - MemberLteUeCphySapUser(); C* m_owner; ///< the owner class }; @@ -505,11 +504,6 @@ MemberLteUeCphySapUser::MemberLteUeCphySapUser(C* owner) { } -template -MemberLteUeCphySapUser::MemberLteUeCphySapUser() -{ -} - template void MemberLteUeCphySapUser::RecvMasterInformationBlock(uint16_t cellId, From a1b2f2a22c9c0485ecc4828ff6cd303df3fa159b Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Thu, 10 Nov 2022 19:05:15 +0100 Subject: [PATCH 010/494] wifi: Reduce collision probability in wifi-mac-ofdma test --- src/wifi/test/wifi-mac-ofdma-test.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wifi/test/wifi-mac-ofdma-test.cc b/src/wifi/test/wifi-mac-ofdma-test.cc index 162f1d5d5..23bc04775 100644 --- a/src/wifi/test/wifi-mac-ofdma-test.cc +++ b/src/wifi/test/wifi-mac-ofdma-test.cc @@ -598,6 +598,7 @@ OfdmaAckSequenceTest::Transmit(std::string context, { // the AP is starting the transmission of the Basic Trigger frame, so generate // the configured number of packets at STAs, which are sent in HE TB PPDUs + Time txDuration = WifiPhy::CalculateTxDuration(psduMap, txVector, WIFI_PHY_BAND_5GHZ); for (uint16_t i = 0; i < m_nStations; i++) { Ptr client = CreateObject(); @@ -607,7 +608,7 @@ OfdmaAckSequenceTest::Transmit(std::string context, client->SetAttribute("Priority", UintegerValue(i * 2)); // 0, 2, 4 and 6 client->SetRemote(m_sockets[i]); m_staDevices.Get(i)->GetNode()->AddApplication(client); - client->SetStartTime(Seconds(0)); // start now + client->SetStartTime(txDuration); // start when TX ends client->SetStopTime(Seconds(1.0)); // stop in a second client->Initialize(); } From 03461793722d8de82ef06d49471f8554ec834074 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Sun, 23 Oct 2022 01:23:58 +0200 Subject: [PATCH 011/494] network: allow graceful failure on creation of Ipv[4,6]Address from string --- CHANGES.md | 2 + RELEASE_NOTES.md | 2 + src/network/utils/ipv4-address.cc | 85 +++------ src/network/utils/ipv6-address.cc | 290 ++++-------------------------- 4 files changed, 66 insertions(+), 313 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index dfdbfb9f5..65072456d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,8 @@ Changes from ns-3.37 to ns-3.38 ### New API ### Changes to existing API +* (network) **Ipv4Address** and **Ipv6Address** now do not raise an exception if built from an invalid string. Instead the address is marked as not initialized. + ### Changes to build system diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9b0031168..ebcfa4b76 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -17,6 +17,8 @@ Release 3-dev ------------- ### New user-visible features +- (network) !1163 Initializing an Ipv[4,6]Address from an invalid string do not raise an exception anymore. Instead the address is marked as not initialized. + ### Bugs fixed diff --git a/src/network/utils/ipv4-address.cc b/src/network/utils/ipv4-address.cc index 4ea4cc868..5c48d8a12 100644 --- a/src/network/utils/ipv4-address.cc +++ b/src/network/utils/ipv4-address.cc @@ -24,63 +24,17 @@ #include +#ifdef __WIN32__ +#include +#else +#include +#endif + namespace ns3 { NS_LOG_COMPONENT_DEFINE("Ipv4Address"); -#define ASCII_DOT (0x2e) -#define ASCII_ZERO (0x30) -#define ASCII_SLASH (0x2f) - -/** - * \brief Converts a string representing an IP address into the address - * \param address the address string - * \returns the address - */ -static uint32_t -AsciiToIpv4Host(const char* address) -{ - NS_LOG_FUNCTION(&address); - uint32_t host = 0; - uint8_t numberOfDots = 0; - const char* ptr = address; - - NS_ASSERT_MSG(*ptr != ASCII_DOT, - "Error, can not build an IPv4 address from an invalid string: " << address); - while (true) - { - uint8_t byte = 0; - while (*ptr != ASCII_DOT && *ptr != 0) - { - byte *= 10; - byte += *ptr - ASCII_ZERO; - ptr++; - } - host <<= 8; - host |= byte; - if (*ptr == 0) - { - break; - } - ptr++; - NS_ASSERT_MSG(*ptr != ASCII_DOT, - "Error, can not build an IPv4 address from an invalid string: " << address); - numberOfDots++; - } - NS_ASSERT_MSG(*(ptr - 1) != ASCII_DOT, - "Error, can not build an IPv4 address from an invalid string: " << address); - NS_ASSERT_MSG(numberOfDots == 3, - "Error, can not build an IPv4 address from an invalid string: " << address); - - return host; -} - -} // namespace ns3 - -namespace ns3 -{ - Ipv4Mask::Ipv4Mask() : m_mask(0x66666666) { @@ -96,7 +50,7 @@ Ipv4Mask::Ipv4Mask(uint32_t mask) Ipv4Mask::Ipv4Mask(const char* mask) { NS_LOG_FUNCTION(this << mask); - if (*mask == ASCII_SLASH) + if (*mask == '/') { uint32_t plen = static_cast(std::atoi(++mask)); NS_ASSERT(plen <= 32); @@ -111,7 +65,11 @@ Ipv4Mask::Ipv4Mask(const char* mask) } else { - m_mask = AsciiToIpv4Host(mask); + if (inet_pton(AF_INET, mask, &m_mask) <= 0) + { + NS_ABORT_MSG("Error, can not build an IPv4 mask from an invalid string: " << mask); + } + m_mask = ntohl(m_mask); } } @@ -219,8 +177,16 @@ Ipv4Address::Ipv4Address(uint32_t address) Ipv4Address::Ipv4Address(const char* address) { NS_LOG_FUNCTION(this << address); - m_address = AsciiToIpv4Host(address); + + if (inet_pton(AF_INET, address, &m_address) <= 0) + { + NS_LOG_LOGIC("Error, can not build an IPv4 address from an invalid string: " << address); + m_address = 0; + m_initialized = false; + return; + } m_initialized = true; + m_address = ntohl(m_address); } uint32_t @@ -242,8 +208,15 @@ void Ipv4Address::Set(const char* address) { NS_LOG_FUNCTION(this << address); - m_address = AsciiToIpv4Host(address); + if (inet_pton(AF_INET, address, &m_address) <= 0) + { + NS_LOG_LOGIC("Error, can not build an IPv4 address from an invalid string: " << address); + m_address = 0; + m_initialized = false; + return; + } m_initialized = true; + m_address = ntohl(m_address); } Ipv4Address diff --git a/src/network/utils/ipv6-address.cc b/src/network/utils/ipv6-address.cc index dfc0b0a53..8c160fd59 100644 --- a/src/network/utils/ipv6-address.cc +++ b/src/network/utils/ipv6-address.cc @@ -17,28 +17,6 @@ * Author: Sebastien Vincent */ -// Part of the Ipv6Address::Print function has been adapted from inet_ntop6 Linux function. -// See http://www.net-snmp.org/dev/agent/inet__ntop_8c_source.html -// Author: Paul Vixie, 1996. -// The inet_ntop6 function was under the copyright below, which is -// compatible with GPLv2, see http://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses. - -/* Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - #include "ipv6-address.h" #include "mac16-address.h" @@ -49,7 +27,13 @@ #include "ns3/log.h" #include -#include +#include + +#ifdef __WIN32__ +#include +#else +#include +#endif namespace ns3 { @@ -165,151 +149,6 @@ extern "C" } #endif -/** - * \brief Convert an IPv6 C-string into a 128-bit representation. - * - * \param address pointer to the char buffer with the address ascii representation - * \param addr the buffer to store the IPv6 address - * - * \return true if success, false otherwise (bad format, ...) - * - * \note This function is strongly inspired by inet_pton6() from Paul Vixie. - * \todo Handle IPv6 address with decimal value for last four bytes. - */ -static bool -AsciiToIpv6Host(const char* address, uint8_t addr[16]) -{ - NS_LOG_FUNCTION(address << &addr); - static const char xdigits_l[] = "0123456789abcdef"; - static const char xdigits_u[] = "0123456789ABCDEF"; - unsigned char tmp[16]; - unsigned char* tp = tmp; - unsigned char* const endp = tp + 16; - unsigned char* colonp = nullptr; - const char* xdigits = nullptr; -#if 0 - const char* curtok = 0; -#endif - int ch = 0; - int seen_xdigits = 0; - unsigned int val = 0; - - memset(tp, 0x00, 16); - - /* Leading :: requires some special handling. */ - if (*address == ':') - { - if (*++address != ':') - { - return (0); - } - } -#if 0 - curtok = address; -#endif - while ((ch = *address++) != '\0') - { - const char* pch = nullptr; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == nullptr) - { - pch = strchr((xdigits = xdigits_u), ch); - } - - if (pch != nullptr) - { - val <<= 4; - val |= (pch - xdigits); - - if (++seen_xdigits > 4) - { - return (0); - } - continue; - } - if (ch == ':') - { -#if 0 - curtok = address; -#endif - - if (!seen_xdigits) - { - if (colonp) - { - return (0); - } - colonp = tp; - continue; - } - - if (endp - tp < 2) - { - return (0); - } - - *tp++ = (unsigned char)(val >> 8) & 0xff; - *tp++ = (unsigned char)val & 0xff; - seen_xdigits = 0; - val = 0; - continue; - } - - /* \todo Handle IPv4 mapped address (2001::192.168.0.1) */ -#if 0 - if (ch == '.' && (endp - tp > 3 /* NS_INADDRSZ - 1 */)) && - inet_pton4 (curtok, tp) > 0) - { - tp += 4 /*NS_INADDRSZ*/; - seen_xdigits = 0; - break; /* '\0' was seen by inet_pton4(). */ - } -#endif - return (0); - } - - if (seen_xdigits) - { - if (endp - tp < 2) - { - return (0); - } - *tp++ = (unsigned char)(val >> 8) & 0xff; - *tp++ = (unsigned char)val & 0xff; - } - - if (colonp != nullptr) - { - /* - * Since some memmove ()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const int n = tp - colonp; - int i = 0; - - if (tp == endp) - { - return (0); - } - - for (i = 1; i <= n; i++) - { - endp[-i] = colonp[n - i]; - colonp[n - i] = 0; - } - - tp = endp; - } - - if (tp != endp) - { - return (0); - } - - memcpy(addr, tmp, 16); - return (1); -} - Ipv6Address::Ipv6Address() { NS_LOG_FUNCTION(this); @@ -334,7 +173,14 @@ Ipv6Address::Ipv6Address(const Ipv6Address* addr) Ipv6Address::Ipv6Address(const char* address) { NS_LOG_FUNCTION(this << address); - AsciiToIpv6Host(address, m_address); + + if (inet_pton(AF_INET6, address, m_address) <= 0) + { + memset(m_address, 0x00, 16); + NS_LOG_LOGIC("Error, can not build an IPv6 address from an invalid string: " << address); + m_initialized = false; + return; + } m_initialized = true; } @@ -356,7 +202,13 @@ void Ipv6Address::Set(const char* address) { NS_LOG_FUNCTION(this << address); - AsciiToIpv6Host(address, m_address); + if (inet_pton(AF_INET6, address, m_address) <= 0) + { + memset(m_address, 0x00, 16); + NS_LOG_LOGIC("Error, can not build an IPv6 address from an invalid string: " << address); + m_initialized = false; + return; + } m_initialized = true; } @@ -678,93 +530,12 @@ Ipv6Address::Print(std::ostream& os) const { NS_LOG_FUNCTION(this << &os); - // note: part of this function has been adapted from inet_ntop6 Linux function. - // See http://www.net-snmp.org/dev/agent/inet__ntop_8c_source.html - // Author: Paul Vixie, 1996. + char str[INET6_ADDRSTRLEN]; - if (IsIpv4MappedAddress()) + if (inet_ntop(AF_INET6, m_address, str, INET6_ADDRSTRLEN)) { - os << "::ffff:" << (unsigned int)m_address[12] << "." << (unsigned int)m_address[13] << "." - << (unsigned int)m_address[14] << "." << (unsigned int)m_address[15]; - return; + os << str; } - - uint16_t address[8]; - uint8_t i; - - for (i = 0; i < 8; i++) - { - address[i] = (uint16_t(m_address[2 * i]) << 8) | uint16_t(m_address[2 * i + 1]); - } - - int8_t bestBase = -1; - int8_t bestLen = 0; - int8_t curBase = -1; - int8_t curLen = 0; - - for (i = 0; i < 8; i++) - { - if (address[i] == 0) - { - if (curBase == -1) - { - curBase = i; - curLen = 1; - } - else - { - curLen++; - } - } - else - { - if (curBase != -1) - { - if (bestBase == -1 || curLen > bestLen) - { - bestBase = curBase; - bestLen = curLen; - } - curBase = -1; - } - } - } - if (curBase != -1) - { - if (bestBase == -1 || curLen > bestLen) - { - bestBase = curBase; - bestLen = curLen; - } - } - if (bestBase != -1 && bestLen < 2) - { - bestBase = -1; - } - - for (i = 0; i < 8;) - { - // Are we inside the best run of 0x00's? - if (i == bestBase) - { - os << ':'; - i += bestLen; - continue; - } - // Are we following an initial run of 0x00s or any real hex? - if (i != 0) - { - os << ':'; - } - os << std::hex << (unsigned int)address[i]; - i++; - } - // Was it a trailing run of 0x00's? - if (bestBase != -1 && (bestBase + bestLen) == 8) - { - os << ':'; - } - os << std::dec; } bool @@ -1044,7 +815,10 @@ Ipv6Prefix::Ipv6Prefix() Ipv6Prefix::Ipv6Prefix(const char* prefix) { NS_LOG_FUNCTION(this << prefix); - AsciiToIpv6Host(prefix, m_prefix); + if (inet_pton(AF_INET6, prefix, m_prefix) <= 0) + { + NS_ABORT_MSG("Error, can not build an IPv6 prefix from an invalid string: " << prefix); + } m_prefixLength = GetMinimumPrefixLength(); } @@ -1058,8 +832,10 @@ Ipv6Prefix::Ipv6Prefix(uint8_t prefix[16]) Ipv6Prefix::Ipv6Prefix(const char* prefix, uint8_t prefixLength) { NS_LOG_FUNCTION(this << prefix); - AsciiToIpv6Host(prefix, m_prefix); - + if (inet_pton(AF_INET6, prefix, m_prefix) <= 0) + { + NS_ABORT_MSG("Error, can not build an IPv6 prefix from an invalid string: " << prefix); + } uint8_t autoLength = GetMinimumPrefixLength(); NS_ASSERT_MSG(autoLength <= prefixLength, "Ipv6Prefix: address and prefix are not compatible: " << Ipv6Address(prefix) From 3773bc6de3533c1c6e89900bbe97438a2a2a8939 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Fri, 11 Nov 2022 12:58:32 +0000 Subject: [PATCH 012/494] Fix formatting of CHANGES.md and RELEASE_NOTES.md --- CHANGES.md | 2 +- RELEASE_NOTES.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 65072456d..840a8597b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,8 +19,8 @@ Changes from ns-3.37 to ns-3.38 ### New API ### Changes to existing API -* (network) **Ipv4Address** and **Ipv6Address** now do not raise an exception if built from an invalid string. Instead the address is marked as not initialized. +* (network) **Ipv4Address** and **Ipv6Address** now do not raise an exception if built from an invalid string. Instead the address is marked as not initialized. ### Changes to build system diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index ebcfa4b76..ee3ebb1c7 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -17,8 +17,8 @@ Release 3-dev ------------- ### New user-visible features -- (network) !1163 Initializing an Ipv[4,6]Address from an invalid string do not raise an exception anymore. Instead the address is marked as not initialized. +- (network) !1163 Initializing an Ipv[4,6]Address from an invalid string do not raise an exception anymore. Instead the address is marked as not initialized. ### Bugs fixed From fe15c39d5266c75fba3f1340a134c129d2715cff Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Thu, 3 Nov 2022 19:02:45 +0000 Subject: [PATCH 013/494] Remove Emacs line from version-defines-template.h --- build-support/version-defines-template.h | 1 - 1 file changed, 1 deletion(-) diff --git a/build-support/version-defines-template.h b/build-support/version-defines-template.h index ea19eccf8..5018cc68f 100644 --- a/build-support/version-defines-template.h +++ b/build-support/version-defines-template.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2018 Lawrence Livermore National Laboratory * From db839d13e5d2276cd91a979912f324c7cbf22cda Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Thu, 3 Nov 2022 19:09:24 +0000 Subject: [PATCH 014/494] ci: Add emacs-line job to code-linting --- utils/tests/gitlab-ci-code-linting.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils/tests/gitlab-ci-code-linting.yml b/utils/tests/gitlab-ci-code-linting.yml index 2171431ef..7d87a2d00 100644 --- a/utils/tests/gitlab-ci-code-linting.yml +++ b/utils/tests/gitlab-ci-code-linting.yml @@ -34,3 +34,12 @@ clang-tidy: - clang-tidy-errors.log when: on_failure timeout: 3h + +emacs-line: + stage: code-linting + image: ubuntu:latest + script: + - (! grep -rn --include="*.h" --include="*.cc" "c-file-style:\"gnu\"" ) || + (echo "Found Emacs lines on the above C++ files" && exit 1) + - echo "No Emacs lines found on C++ files" + timeout: 1h From 829e5869f851e5603e79f6d0783a5dc71ef98b9a Mon Sep 17 00:00:00 2001 From: Gabriel Arrobo Date: Wed, 2 Nov 2022 19:10:12 +0000 Subject: [PATCH 015/494] network: Add TimestampTag --- src/network/CMakeLists.txt | 2 + src/network/utils/timestamp-tag.cc | 90 ++++++++++++++++++++++++++++++ src/network/utils/timestamp-tag.h | 82 +++++++++++++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100755 src/network/utils/timestamp-tag.cc create mode 100755 src/network/utils/timestamp-tag.h diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index 88e357fd7..ba912ee3a 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -68,6 +68,7 @@ set(source_files utils/simple-channel.cc utils/simple-net-device.cc utils/sll-header.cc + utils/timestamp-tag.cc ) set(header_files @@ -146,6 +147,7 @@ set(header_files utils/simple-channel.h utils/simple-net-device.h utils/sll-header.h + utils/timestamp-tag.h ) build_lib( diff --git a/src/network/utils/timestamp-tag.cc b/src/network/utils/timestamp-tag.cc new file mode 100755 index 000000000..c8e4e2f33 --- /dev/null +++ b/src/network/utils/timestamp-tag.cc @@ -0,0 +1,90 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Joe Kopena + */ + +#include "timestamp-tag.h" + +#include "ns3/nstime.h" +#include "ns3/tag-buffer.h" +#include "ns3/tag.h" +#include "ns3/type-id.h" +#include "ns3/uinteger.h" + +namespace ns3 +{ + +NS_OBJECT_ENSURE_REGISTERED(TimestampTag); + +TimestampTag::TimestampTag() = default; + +TimestampTag::TimestampTag(Time timestamp) + : m_timestamp(timestamp) +{ +} + +TypeId +TimestampTag::GetTypeId() +{ + static TypeId tid = TypeId("ns3::TimestampTag") + .SetParent() + .SetGroupName("Network") + .AddConstructor(); + return tid; +} + +TypeId +TimestampTag::GetInstanceTypeId() const +{ + return GetTypeId(); +} + +uint32_t +TimestampTag::GetSerializedSize() const +{ + return 8; +} + +void +TimestampTag::Serialize(TagBuffer i) const +{ + i.WriteU64(m_timestamp.GetTimeStep()); +} + +void +TimestampTag::Deserialize(TagBuffer i) +{ + m_timestamp = TimeStep(i.ReadU64()); +} + +void +TimestampTag::Print(std::ostream& os) const +{ + os << "timestamp=" << m_timestamp.As(Time::S); +} + +Time +TimestampTag::GetTimestamp() const +{ + return m_timestamp; +} + +void +TimestampTag::SetTimestamp(Time timestamp) +{ + m_timestamp = timestamp; +} + +} // namespace ns3 diff --git a/src/network/utils/timestamp-tag.h b/src/network/utils/timestamp-tag.h new file mode 100755 index 000000000..7eeda23d4 --- /dev/null +++ b/src/network/utils/timestamp-tag.h @@ -0,0 +1,82 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Joe Kopena + */ + +#ifndef TIMESTAMP_TAG_H +#define TIMESTAMP_TAG_H + +#include "ns3/nstime.h" +#include "ns3/tag-buffer.h" +#include "ns3/tag.h" +#include "ns3/type-id.h" + +#include + +namespace ns3 +{ + +/** + * Timestamp tag for associating a timestamp with a packet. + * + * It would have been more realistic to include this info in + * a header. Here we show how to avoid the extra overhead in + * a simulation. + */ +class TimestampTag : public Tag +{ + public: + /** + * \brief Get the type ID. + * \return the object TypeId + */ + static TypeId GetTypeId(); + TypeId GetInstanceTypeId() const override; + + /** + * \brief Construct a new TimestampTag object + */ + TimestampTag(); + + /** + * \brief Construct a new TimestampTag object with the given timestamp + * \param timestamp The timestamp + */ + TimestampTag(Time timestamp); + + void Serialize(TagBuffer i) const override; + void Deserialize(TagBuffer i) override; + uint32_t GetSerializedSize() const override; + void Print(std::ostream& os) const override; + + /** + * \brief Get the Timestamp object + * \return Time for this tag + */ + Time GetTimestamp() const; + + /** + * \brief Set the Timestamp object + * \param timestamp Timestamp to assign to tag + */ + void SetTimestamp(Time timestamp); + + private: + Time m_timestamp{0}; //!< Timestamp +}; + +} // namespace ns3 + +#endif // TIMESTAMP_TAG_H From 28e4d6d8a97121aaab0a06e10f22027ecdef8fc2 Mon Sep 17 00:00:00 2001 From: Gabriel Arrobo Date: Wed, 2 Nov 2022 19:22:39 +0000 Subject: [PATCH 016/494] network, examples: Use TimestampTag from network module --- examples/stats/wifi-example-apps.cc | 62 ---------- examples/stats/wifi-example-apps.h | 40 ------- src/network/helper/delay-jitter-estimation.cc | 109 ++---------------- src/network/helper/delay-jitter-estimation.h | 4 +- 4 files changed, 10 insertions(+), 205 deletions(-) diff --git a/examples/stats/wifi-example-apps.cc b/examples/stats/wifi-example-apps.cc index 9d07a8b34..4f78f14f0 100644 --- a/examples/stats/wifi-example-apps.cc +++ b/examples/stats/wifi-example-apps.cc @@ -278,65 +278,3 @@ Receiver::Receive(Ptr socket) // end Receiver::Receive } - -//---------------------------------------------------------------------- -//-- TimestampTag -//------------------------------------------------------ -TypeId -TimestampTag::GetTypeId() -{ - static TypeId tid = TypeId("TimestampTag") - .SetParent() - .AddConstructor() - .AddAttribute("Timestamp", - "Some momentous point in time!", - EmptyAttributeValue(), - MakeTimeAccessor(&TimestampTag::GetTimestamp), - MakeTimeChecker()); - return tid; -} - -TypeId -TimestampTag::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -uint32_t -TimestampTag::GetSerializedSize() const -{ - return 8; -} - -void -TimestampTag::Serialize(TagBuffer i) const -{ - int64_t t = m_timestamp.GetNanoSeconds(); - i.Write((const uint8_t*)&t, 8); -} - -void -TimestampTag::Deserialize(TagBuffer i) -{ - int64_t t; - i.Read((uint8_t*)&t, 8); - m_timestamp = NanoSeconds(t); -} - -void -TimestampTag::SetTimestamp(Time time) -{ - m_timestamp = time; -} - -Time -TimestampTag::GetTimestamp() const -{ - return m_timestamp; -} - -void -TimestampTag::Print(std::ostream& os) const -{ - os << "t=" << m_timestamp; -} diff --git a/examples/stats/wifi-example-apps.h b/examples/stats/wifi-example-apps.h index 2e8e1488e..5dc301880 100644 --- a/examples/stats/wifi-example-apps.h +++ b/examples/stats/wifi-example-apps.h @@ -121,43 +121,3 @@ class Receiver : public Application // end class Receiver }; - -/** - * Timestamp tag - it carries when the packet has been sent. - * - * It would have been more realistic to include this info in - * a header. Here we show how to avoid the extra overhead in - * a simulation. - */ -class TimestampTag : public Tag -{ - public: - /** - * \brief Get the type ID. - * \return The object TypeId. - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - - uint32_t GetSerializedSize() const override; - void Serialize(TagBuffer i) const override; - void Deserialize(TagBuffer i) override; - - /** - * Set the timestamp. - * \param time The timestamp. - */ - void SetTimestamp(Time time); - /** - * Get the timestamp. - * \return the timestamp. - */ - Time GetTimestamp() const; - - void Print(std::ostream& os) const override; - - private: - Time m_timestamp; //!< Timestamp. - - // end class TimestampTag -}; diff --git a/src/network/helper/delay-jitter-estimation.cc b/src/network/helper/delay-jitter-estimation.cc index 04d034a76..9a31b99e5 100644 --- a/src/network/helper/delay-jitter-estimation.cc +++ b/src/network/helper/delay-jitter-estimation.cc @@ -21,120 +21,28 @@ #include "ns3/simulator.h" #include "ns3/string.h" -#include "ns3/tag.h" +#include "ns3/timestamp-tag.h" namespace ns3 { -/** - * Tag to perform Delay and Jitter estimations - * - * The tag holds the packet's creation timestamp - */ -class DelayJitterEstimationTimestampTag : public Tag -{ - public: - DelayJitterEstimationTimestampTag(); - - /** - * \brief Get the type ID. - * \return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - - uint32_t GetSerializedSize() const override; - void Serialize(TagBuffer i) const override; - void Deserialize(TagBuffer i) override; - void Print(std::ostream& os) const override; - - /** - * \brief Get the Transmission time stored in the tag - * \return the transmission time - */ - Time GetTxTime() const; - - private: - Time m_creationTime; //!< The time stored in the tag -}; - -DelayJitterEstimationTimestampTag::DelayJitterEstimationTimestampTag() - : m_creationTime(Simulator::Now()) -{ -} - -TypeId -DelayJitterEstimationTimestampTag::GetTypeId() -{ - static TypeId tid = - TypeId("anon::DelayJitterEstimationTimestampTag") - .SetParent() - .SetGroupName("Network") - .AddConstructor() - .AddAttribute("CreationTime", - "The time at which the timestamp was created", - TimeValue(Time(0)), - MakeTimeAccessor(&DelayJitterEstimationTimestampTag::m_creationTime), - MakeTimeChecker()); - return tid; -} - -TypeId -DelayJitterEstimationTimestampTag::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -uint32_t -DelayJitterEstimationTimestampTag::GetSerializedSize() const -{ - return 8; -} - -void -DelayJitterEstimationTimestampTag::Serialize(TagBuffer i) const -{ - i.WriteU64(m_creationTime.GetTimeStep()); -} - -void -DelayJitterEstimationTimestampTag::Deserialize(TagBuffer i) -{ - m_creationTime = TimeStep(i.ReadU64()); -} - -void -DelayJitterEstimationTimestampTag::Print(std::ostream& os) const -{ - os << "CreationTime=" << m_creationTime; -} - -Time -DelayJitterEstimationTimestampTag::GetTxTime() const -{ - return m_creationTime; -} - DelayJitterEstimation::DelayJitterEstimation() - : m_jitter(Time(0)), - m_transit(Time(0)) { } void DelayJitterEstimation::PrepareTx(Ptr packet) { - DelayJitterEstimationTimestampTag tag; + TimestampTag tag(Simulator::Now()); packet->AddByteTag(tag); } void DelayJitterEstimation::RecordRx(Ptr packet) { - DelayJitterEstimationTimestampTag tag; - bool found; - found = packet->FindFirstMatchingByteTag(tag); - if (!found) + TimestampTag tag; + + if (!packet->FindFirstMatchingByteTag(tag)) { return; } @@ -142,15 +50,14 @@ DelayJitterEstimation::RecordRx(Ptr packet) // Variable names from // RFC 1889 Appendix A.8 ,p. 71, // RFC 3550 Appendix A.8, p. 94 - - Time r_ts = tag.GetTxTime(); + Time r_ts = tag.GetTimestamp(); Time arrival = Simulator::Now(); Time transit = arrival - r_ts; Time delta = transit - m_transit; m_transit = transit; // floating jitter version - // m_jitter += (Abs (delta) - m_jitter) / 16; + // m_jitter += (Abs (delta) - m_jitter) / 16; // int variant m_jitter += Abs(delta) - ((m_jitter + TimeStep(8)) / 16); @@ -166,7 +73,7 @@ uint64_t DelayJitterEstimation::GetLastJitter() const { // floating jitter version - // return m_jitter.GetTimeStep (); + // return m_jitter.GetTimeStep(); // int variant return (m_jitter / 16).GetTimeStep(); diff --git a/src/network/helper/delay-jitter-estimation.h b/src/network/helper/delay-jitter-estimation.h index 8c1096f71..2587e278c 100644 --- a/src/network/helper/delay-jitter-estimation.h +++ b/src/network/helper/delay-jitter-estimation.h @@ -74,8 +74,8 @@ class DelayJitterEstimation uint64_t GetLastJitter() const; private: - Time m_jitter; //!< Jitter estimation - Time m_transit; //!< Relative transit time for the previous packet + Time m_jitter{0}; //!< Jitter estimation + Time m_transit{0}; //!< Relative transit time for the previous packet }; } // namespace ns3 From 095313c9cb62d114a360460c53a3d02d10d63c3d Mon Sep 17 00:00:00 2001 From: Gabriel Arrobo Date: Wed, 2 Nov 2022 19:27:06 +0000 Subject: [PATCH 017/494] network: Improve Doxygen in delay-jitter-estimation.h --- src/network/helper/delay-jitter-estimation.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/network/helper/delay-jitter-estimation.h b/src/network/helper/delay-jitter-estimation.h index 2587e278c..6db42e371 100644 --- a/src/network/helper/delay-jitter-estimation.h +++ b/src/network/helper/delay-jitter-estimation.h @@ -42,34 +42,38 @@ class DelayJitterEstimation DelayJitterEstimation(); /** - * \param packet the packet to send over a wire - * * This method should be invoked once on each packet to * record within the packet the tx time which is used upon * packet reception to calculate the delay and jitter. The * tx time is stored in the packet as an ns3::Tag which means * that it does not use any network resources and is not * taken into account in transmission delay calculations. + * + * \param packet the packet to send over a wire */ static void PrepareTx(Ptr packet); + /** - * \param packet the packet received - * * Invoke this method to update the delay and jitter calculations * After a call to this method, \ref GetLastDelay and \ref GetLastJitter * will return an updated delay and jitter. + * + * \param packet the packet received */ void RecordRx(Ptr packet); /** - * \returns the updated delay. + * Get the Last Delay object. + * + * \return the updated delay. */ Time GetLastDelay() const; + /** * The jitter is calculated using the \RFC{1889} (RTP) jitter * definition. * - * \returns the updated jitter. + * \return the updated jitter. */ uint64_t GetLastJitter() const; From fa90164e443855d97470ba430749ce22fb553026 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Wed, 2 Nov 2022 19:35:31 +0000 Subject: [PATCH 018/494] examples: Clean wifi-example-apps and wifi-example-sim --- examples/stats/wifi-example-apps.cc | 40 ++++++++---------------- examples/stats/wifi-example-apps.h | 41 +++++++++++++----------- examples/stats/wifi-example-sim.cc | 48 +++++++++++++---------------- 3 files changed, 58 insertions(+), 71 deletions(-) diff --git a/examples/stats/wifi-example-apps.cc b/examples/stats/wifi-example-apps.cc index 4f78f14f0..ff5e1e2e7 100644 --- a/examples/stats/wifi-example-apps.cc +++ b/examples/stats/wifi-example-apps.cc @@ -37,6 +37,10 @@ using namespace ns3; NS_LOG_COMPONENT_DEFINE("WiFiDistanceApps"); +// ============================================== +// SENDER +// ============================================== + TypeId Sender::GetTypeId() { @@ -46,7 +50,7 @@ Sender::GetTypeId() .AddAttribute("PacketSize", "The size of packets transmitted.", UintegerValue(64), - MakeUintegerAccessor(&Sender::m_pktSize), + MakeUintegerAccessor(&Sender::m_packetSize), MakeUintegerChecker(1)) .AddAttribute("Destination", "Target host address.", @@ -61,7 +65,7 @@ Sender::GetTypeId() .AddAttribute("NumPackets", "Total number of packets to send.", UintegerValue(30), - MakeUintegerAccessor(&Sender::m_numPkts), + MakeUintegerAccessor(&Sender::m_nPackets), MakeUintegerChecker(1)) .AddAttribute("Interval", "Delay between transmissions.", @@ -79,7 +83,6 @@ Sender::Sender() { NS_LOG_FUNCTION_NOARGS(); m_interval = CreateObject(); - m_socket = nullptr; } Sender::~Sender() @@ -114,8 +117,6 @@ Sender::StartApplication() Simulator::Cancel(m_sendEvent); m_sendEvent = Simulator::ScheduleNow(&Sender::SendPacket, this); - - // end Sender::StartApplication } void @@ -123,16 +124,15 @@ Sender::StopApplication() { NS_LOG_FUNCTION_NOARGS(); Simulator::Cancel(m_sendEvent); - // end Sender::StopApplication } void Sender::SendPacket() { - // NS_LOG_FUNCTION_NOARGS (); + // NS_LOG_FUNCTION_NOARGS(); NS_LOG_INFO("Sending packet at " << Simulator::Now() << " to " << m_destAddr); - Ptr packet = Create(m_pktSize); + Ptr packet = Create(m_packetSize); TimestampTag timestamp; timestamp.SetTimestamp(Simulator::Now()); @@ -145,18 +145,17 @@ Sender::SendPacket() // Report the event to the trace. m_txTrace(packet); - if (++m_count < m_numPkts) + if (++m_count < m_nPackets) { m_sendEvent = Simulator::Schedule(Seconds(m_interval->GetValue()), &Sender::SendPacket, this); } - - // end Sender::SendPacket } -//---------------------------------------------------------------------- -//-- Receiver -//------------------------------------------------------ +// ============================================== +// RECEIVER +// ============================================== + TypeId Receiver::GetTypeId() { @@ -172,11 +171,8 @@ Receiver::GetTypeId() } Receiver::Receiver() - : m_calc(nullptr), - m_delay(nullptr) { NS_LOG_FUNCTION_NOARGS(); - m_socket = nullptr; } Receiver::~Receiver() @@ -209,8 +205,6 @@ Receiver::StartApplication() } m_socket->SetRecvCallback(MakeCallback(&Receiver::Receive, this)); - - // end Receiver::StartApplication } void @@ -222,22 +216,18 @@ Receiver::StopApplication() { m_socket->SetRecvCallback(MakeNullCallback>()); } - - // end Receiver::StopApplication } void Receiver::SetCounter(Ptr> calc) { m_calc = calc; - // end Receiver::SetCounter } void Receiver::SetDelayTracker(Ptr delay) { m_delay = delay; - // end Receiver::SetDelayTracker } void @@ -272,9 +262,5 @@ Receiver::Receive(Ptr socket) { m_calc->Update(); } - - // end receiving packets } - - // end Receiver::Receive } diff --git a/examples/stats/wifi-example-apps.h b/examples/stats/wifi-example-apps.h index 5dc301880..e65a2c2c0 100644 --- a/examples/stats/wifi-example-apps.h +++ b/examples/stats/wifi-example-apps.h @@ -31,6 +31,10 @@ using namespace ns3; +// ============================================== +// SENDER +// ============================================== + /** * Sender application. */ @@ -42,6 +46,7 @@ class Sender : public Application * \return The object TypeId. */ static TypeId GetTypeId(); + Sender(); ~Sender() override; @@ -57,23 +62,24 @@ class Sender : public Application */ void SendPacket(); - uint32_t m_pktSize; //!< The packet size. - Ipv4Address m_destAddr; //!< Destination address. - uint32_t m_destPort; //!< Destination port. - Ptr m_interval; //!< Rng for sending packets. - uint32_t m_numPkts; //!< Number of packets to send. + Ipv4Address m_destAddr; //!< Destination address + uint32_t m_destPort{0}; //!< Destination port + uint32_t m_packetSize{0}; //!< The packet size + Ptr m_interval; //!< Rng for sending packets + uint32_t m_nPackets{0}; //!< Number of packets to send + uint32_t m_count{0}; //!< Number of packets sent - Ptr m_socket; //!< Sending socket. - EventId m_sendEvent; //!< Send packet event. + Ptr m_socket; //!< Sending socket + EventId m_sendEvent; //!< Send packet event - /// Tx TracedCallback. + /// Tx TracedCallback TracedCallback> m_txTrace; - - uint32_t m_count; //!< Number of packets sent. - - // end class Sender }; +// ============================================== +// RECEIVER +// ============================================== + /** * Receiver application. */ @@ -85,6 +91,7 @@ class Receiver : public Application * \return The object TypeId. */ static TypeId GetTypeId(); + Receiver(); ~Receiver() override; @@ -113,11 +120,9 @@ class Receiver : public Application */ void Receive(Ptr socket); - Ptr m_socket; //!< Receiving socket. - uint32_t m_port; //!< Listening port. + Ptr m_socket; //!< Receiving socket + uint32_t m_port{0}; //!< Listening port - Ptr> m_calc; //!< Counter of the number of received packets. - Ptr m_delay; //!< Delay calculator. - - // end class Receiver + Ptr> m_calc; //!< Counter of the number of received packets + Ptr m_delay; //!< Delay calculator }; diff --git a/examples/stats/wifi-example-sim.cc b/examples/stats/wifi-example-sim.cc index 6fbe90632..d2238254b 100644 --- a/examples/stats/wifi-example-sim.cc +++ b/examples/stats/wifi-example-sim.cc @@ -36,7 +36,7 @@ #include "ns3/mobility-module.h" #include "ns3/network-module.h" #include "ns3/stats-module.h" -#include "ns3/yans-wifi-helper.h" +#include "ns3/wifi-module.h" #include #include @@ -49,20 +49,16 @@ NS_LOG_COMPONENT_DEFINE("WiFiDistanceExperiment"); * Function called when a packet is transmitted. * * \param datac The counter of the number of transmitted packets. - * \param path The callback context - * \param packet The transmsiotted packet. + * \param path The callback context. + * \param packet The transmitted packet. */ void TxCallback(Ptr> datac, std::string path, Ptr packet) { NS_LOG_INFO("Sent frame counted in " << datac->GetKey()); datac->Update(); - // end TxCallback } -//---------------------------------------------------------------------- -//-- main -//---------------------------------------------- int main(int argc, char* argv[]) { @@ -109,7 +105,7 @@ main(int argc, char* argv[]) input = sstr.str(); } - //------------------------------------------------------------ + //-------------------------------------------- //-- Create nodes and network stacks //-------------------------------------------- NS_LOG_INFO("Creating nodes."); @@ -131,7 +127,7 @@ main(int argc, char* argv[]) ipAddrs.SetBase("192.168.0.0", "255.255.255.0"); ipAddrs.Assign(nodeDevices); - //------------------------------------------------------------ + //-------------------------------------------- //-- Setup physical layout //-------------------------------------------- NS_LOG_INFO("Installing static mobility; distance " << distance << " ."); @@ -142,7 +138,7 @@ main(int argc, char* argv[]) mobility.SetPositionAllocator(positionAlloc); mobility.Install(nodes); - //------------------------------------------------------------ + //-------------------------------------------- //-- Create a custom traffic source and sink //-------------------------------------------- NS_LOG_INFO("Create traffic source & sink."); @@ -159,7 +155,7 @@ main(int argc, char* argv[]) Config::Set("/NodeList/*/ApplicationList/*/$Sender/Destination", Ipv4AddressValue("192.168.0.2")); - //------------------------------------------------------------ + //-------------------------------------------- //-- Setup stats and data collection //-------------------------------------------- @@ -212,23 +208,24 @@ main(int argc, char* argv[]) receiver->SetCounter(appRx); data.AddDataCalculator(appRx); - /** - * Just to show this is here... - Ptr > test = - CreateObject >(); - test->SetKey("test-dc"); - data.AddDataCalculator(test); + // Just to show this is here... - test->Update(4); - test->Update(8); - test->Update(24); - test->Update(12); - **/ + /* + Ptr> test = + CreateObject>(); + test->SetKey("test-dc"); + data.AddDataCalculator(test); + + test->Update(4); + test->Update(8); + test->Update(24); + test->Update(12); + */ // This DataCalculator connects directly to the transmit trace // provided by our Sender Application. It records some basic // statistics about the sizes of the packets received (min, max, - // avg, total # bytes), although in this scenaro they're fixed. + // avg, total # bytes), although in this scenario they're fixed. Ptr appTxPkts = CreateObject(); appTxPkts->SetKey("tx-pkt-size"); @@ -247,13 +244,13 @@ main(int argc, char* argv[]) receiver->SetDelayTracker(delayStat); data.AddDataCalculator(delayStat); - //------------------------------------------------------------ + //-------------------------------------------- //-- Run the simulation //-------------------------------------------- NS_LOG_INFO("Run Simulation."); Simulator::Run(); - //------------------------------------------------------------ + //-------------------------------------------- //-- Generate statistics output. //-------------------------------------------- @@ -286,6 +283,5 @@ main(int argc, char* argv[]) // Free any memory here at the end of this example. Simulator::Destroy(); - // end main return 0; } From 495a1bb0c80e4b8189501050f3729dd4b525126f Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Thu, 3 Nov 2022 18:51:08 +0000 Subject: [PATCH 019/494] Update RELEASE_NOTES.md and CHANGES.md --- CHANGES.md | 2 ++ RELEASE_NOTES.md | 1 + 2 files changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 840a8597b..986ba493a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,6 +18,8 @@ Changes from ns-3.37 to ns-3.38 ### New API +* (network) Add class `TimestampTag` for associating a timestamp with a packet. + ### Changes to existing API * (network) **Ipv4Address** and **Ipv6Address** now do not raise an exception if built from an invalid string. Instead the address is marked as not initialized. diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index ee3ebb1c7..adf8499da 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -18,6 +18,7 @@ Release 3-dev ### New user-visible features +- (network) !938 - Add class `TimestampTag` for associating a timestamp with a packet. - (network) !1163 Initializing an Ipv[4,6]Address from an invalid string do not raise an exception anymore. Instead the address is marked as not initialized. ### Bugs fixed From 6d4eff6961266a9e10066d9b826c61a53ddc2c46 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Wed, 2 Nov 2022 17:01:33 -0700 Subject: [PATCH 020/494] Remove NS_DEPRECATED_3_34 methods --- src/core/model/deprecated.h | 7 ------- src/internet/model/icmpv6-header.cc | 13 ------------- src/internet/model/icmpv6-header.h | 14 -------------- src/olsr/model/olsr-routing-protocol.cc | 6 ------ src/olsr/model/olsr-routing-protocol.h | 5 ----- 5 files changed, 45 deletions(-) diff --git a/src/core/model/deprecated.h b/src/core/model/deprecated.h index 9c9b2c2f5..c091556f5 100644 --- a/src/core/model/deprecated.h +++ b/src/core/model/deprecated.h @@ -93,11 +93,4 @@ */ #define NS_DEPRECATED_3_35 NS_DEPRECATED("") -/** - * \ingroup core - * \def NS_DEPRECATED_3_34 - * Tag for things deprecated in version ns-3.34. - */ -#define NS_DEPRECATED_3_34 NS_DEPRECATED("") - #endif /* NS3_DEPRECATED_H */ diff --git a/src/internet/model/icmpv6-header.cc b/src/internet/model/icmpv6-header.cc index 928a95624..e119d8eb9 100644 --- a/src/internet/model/icmpv6-header.cc +++ b/src/internet/model/icmpv6-header.cc @@ -657,19 +657,6 @@ Icmpv6RA::SetFlagH(bool h) m_flagH = h; } -uint8_t -Icmpv6RA::GetFlags() const -{ - NS_LOG_FUNCTION(this); - return 0; -} - -void -Icmpv6RA::SetFlags(uint8_t f) -{ - NS_LOG_FUNCTION(this << static_cast(f)); -} - void Icmpv6RA::Print(std::ostream& os) const { diff --git a/src/internet/model/icmpv6-header.h b/src/internet/model/icmpv6-header.h index a26a31145..dfd25c57c 100644 --- a/src/internet/model/icmpv6-header.h +++ b/src/internet/model/icmpv6-header.h @@ -682,20 +682,6 @@ class Icmpv6RA : public Icmpv6Header */ void Print(std::ostream& os) const override; - /** - * \brief Getflags. - * \return the flags value - */ - NS_DEPRECATED_3_34 - uint8_t GetFlags() const; - - /** - * \brief Setflags. - * \param f the flags value - */ - NS_DEPRECATED_3_34 - void SetFlags(uint8_t f); - /** * \brief Get the serialized size. * \return serialized size diff --git a/src/olsr/model/olsr-routing-protocol.cc b/src/olsr/model/olsr-routing-protocol.cc index 5bf417f92..89adf7f6e 100644 --- a/src/olsr/model/olsr-routing-protocol.cc +++ b/src/olsr/model/olsr-routing-protocol.cc @@ -248,12 +248,6 @@ RoutingProtocol::SetIpv4(Ptr ipv4) m_hnaRoutingTable->SetIpv4(ipv4); } -Ptr -RoutingProtocol::GetIpv4() const -{ - return m_ipv4; -} - void RoutingProtocol::DoDispose() { diff --git a/src/olsr/model/olsr-routing-protocol.h b/src/olsr/model/olsr-routing-protocol.h index d99a342dc..0ee7adbc7 100644 --- a/src/olsr/model/olsr-routing-protocol.h +++ b/src/olsr/model/olsr-routing-protocol.h @@ -356,11 +356,6 @@ class RoutingProtocol : public Ipv4RoutingProtocol ErrorCallback ecb) override; void SetIpv4(Ptr ipv4) override; - /** - * \returns the ipv4 object this routing protocol is associated with - */ - NS_DEPRECATED_3_34 - virtual Ptr GetIpv4() const; void PrintRoutingTable(Ptr stream, Time::Unit unit = Time::S) const override; From 40ec1d7a21fd3ee60cc99664d2d08d565edeb1d3 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Wed, 2 Nov 2022 17:14:48 -0700 Subject: [PATCH 021/494] Remove NS_DEPRECATED_3_35 methods --- src/core/model/deprecated.h | 7 ---- src/internet/model/ipv6-header.cc | 24 -------------- src/internet/model/ipv6-header.h | 32 ------------------- .../helper/ipv4-nix-vector-helper.h | 23 ------------- .../model/ipv4-nix-vector-routing.h | 24 -------------- 5 files changed, 110 deletions(-) delete mode 100644 src/nix-vector-routing/helper/ipv4-nix-vector-helper.h delete mode 100644 src/nix-vector-routing/model/ipv4-nix-vector-routing.h diff --git a/src/core/model/deprecated.h b/src/core/model/deprecated.h index c091556f5..d0cb303b8 100644 --- a/src/core/model/deprecated.h +++ b/src/core/model/deprecated.h @@ -86,11 +86,4 @@ */ #define NS_DEPRECATED_3_36(msg) NS_DEPRECATED(msg) -/** - * \ingroup core - * \def NS_DEPRECATED_3_35 - * Tag for things deprecated in version ns-3.35. - */ -#define NS_DEPRECATED_3_35 NS_DEPRECATED("") - #endif /* NS3_DEPRECATED_H */ diff --git a/src/internet/model/ipv6-header.cc b/src/internet/model/ipv6-header.cc index 901bba070..94f500e3a 100644 --- a/src/internet/model/ipv6-header.cc +++ b/src/internet/model/ipv6-header.cc @@ -108,48 +108,24 @@ Ipv6Header::SetSource(Ipv6Address src) m_sourceAddress = src; } -void -Ipv6Header::SetSourceAddress(Ipv6Address src) -{ - SetSource(src); -} - Ipv6Address Ipv6Header::GetSource() const { return m_sourceAddress; } -Ipv6Address -Ipv6Header::GetSourceAddress() const -{ - return GetSource(); -} - void Ipv6Header::SetDestination(Ipv6Address dst) { m_destinationAddress = dst; } -void -Ipv6Header::SetDestinationAddress(Ipv6Address dst) -{ - SetDestination(dst); -} - Ipv6Address Ipv6Header::GetDestination() const { return m_destinationAddress; } -Ipv6Address -Ipv6Header::GetDestinationAddress() const -{ - return GetDestination(); -} - TypeId Ipv6Header::GetTypeId() { diff --git a/src/internet/model/ipv6-header.h b/src/internet/model/ipv6-header.h index 8bcb8ad13..8f1dfc5df 100644 --- a/src/internet/model/ipv6-header.h +++ b/src/internet/model/ipv6-header.h @@ -228,56 +228,24 @@ class Ipv6Header : public Header */ void SetSource(Ipv6Address src); - /** - * \brief Set the "Source address" field. - * \deprecated Use SetSource () function instead (same functionality) - * \param src the source address - */ - NS_DEPRECATED_3_35 - void SetSourceAddress(Ipv6Address src); - /** * \brief Get the "Source address" field. * \return the source address */ Ipv6Address GetSource() const; - /** - * \brief Get the "Source address" field. - * \deprecated Use GetSource () function instead (same functionality) - * \return the source address - */ - NS_DEPRECATED_3_35 - Ipv6Address GetSourceAddress() const; - /** * \brief Set the "Destination address" field. * \param dst the destination address */ void SetDestination(Ipv6Address dst); - /** - * \brief Set the "Destination address" field. - * \deprecated Use SetDestination () function instead (same functionality) - * \param dst the destination address - */ - NS_DEPRECATED_3_35 - void SetDestinationAddress(Ipv6Address dst); - /** * \brief Get the "Destination address" field. * \return the destination address */ Ipv6Address GetDestination() const; - /** - * \brief Get the "Destination address" field. - * \deprecated Use GetDestination () function instead (same functionality) - * \return the destination address - */ - NS_DEPRECATED_3_35 - Ipv6Address GetDestinationAddress() const; - /** * \brief Print some information about the packet. * \param os output stream diff --git a/src/nix-vector-routing/helper/ipv4-nix-vector-helper.h b/src/nix-vector-routing/helper/ipv4-nix-vector-helper.h deleted file mode 100644 index 94e4afefe..000000000 --- a/src/nix-vector-routing/helper/ipv4-nix-vector-helper.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2021 NITK Surathkal - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * The purpose of this file is to have backwards compatibility with previous - * IPv4 Nix Vector Routing examples and usages. - * - * Authors: Ameya Deshpande - */ -#pragma GCC warning "NS_DEPRECATED_3_35 - Deprecated header, please use nix-vector-helper.h instead" -#include "nix-vector-helper.h" diff --git a/src/nix-vector-routing/model/ipv4-nix-vector-routing.h b/src/nix-vector-routing/model/ipv4-nix-vector-routing.h deleted file mode 100644 index 9dd617fc5..000000000 --- a/src/nix-vector-routing/model/ipv4-nix-vector-routing.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2021 NITK Surathkal - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * The purpose of this file is to have backwards compatibility with previous - * IPv4 Nix Vector Routing examples and usages. - * - * Authors: Ameya Deshpande - */ -#pragma GCC warning \ - "NS_DEPRECATED_3_35 - Deprecated header, please use nix-vector-routing.h instead" -#include "nix-vector-routing.h" From adcc13e93c41fcfa4c4013fa5f598cb300bd0a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Mon, 20 Jun 2022 18:00:56 +0200 Subject: [PATCH 022/494] applications: (merges !995) Unify handling of 'MaxPackets attribute is zero' Treat zero max packets as infinite as PacketSocketClient already does. --- CHANGES.md | 2 + src/applications/model/udp-client.cc | 13 ++--- src/applications/model/udp-echo-client.cc | 13 ++--- src/internet-apps/model/ping6.cc | 62 ++++++++++++----------- src/lte/test/epc-test-s1u-uplink.cc | 13 ++--- 5 files changed, 55 insertions(+), 48 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 986ba493a..d80e4479c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -28,6 +28,8 @@ Changes from ns-3.37 to ns-3.38 ### Changed behavior +* (applications) **UdpClient** and **UdpEchoClient** MaxPackets attribute is aligned with other applications, in that the value zero means infinite packets. + Changes from ns-3.36 to ns-3.37 ------------------------------- diff --git a/src/applications/model/udp-client.cc b/src/applications/model/udp-client.cc index a1e002e5a..f5b4c9379 100644 --- a/src/applications/model/udp-client.cc +++ b/src/applications/model/udp-client.cc @@ -50,11 +50,12 @@ UdpClient::GetTypeId() .SetParent() .SetGroupName("Applications") .AddConstructor() - .AddAttribute("MaxPackets", - "The maximum number of packets the application will send", - UintegerValue(100), - MakeUintegerAccessor(&UdpClient::m_count), - MakeUintegerChecker()) + .AddAttribute( + "MaxPackets", + "The maximum number of packets the application will send (zero means infinite)", + UintegerValue(100), + MakeUintegerAccessor(&UdpClient::m_count), + MakeUintegerChecker()) .AddAttribute("Interval", "The time to wait between packets", TimeValue(Seconds(1.0)), @@ -223,7 +224,7 @@ UdpClient::Send() } #endif // NS3_LOG_ENABLE - if (m_sent < m_count) + if (m_sent < m_count || m_count == 0) { m_sendEvent = Simulator::Schedule(m_interval, &UdpClient::Send, this); } diff --git a/src/applications/model/udp-echo-client.cc b/src/applications/model/udp-echo-client.cc index 70cd095cb..ef7531d57 100644 --- a/src/applications/model/udp-echo-client.cc +++ b/src/applications/model/udp-echo-client.cc @@ -44,11 +44,12 @@ UdpEchoClient::GetTypeId() .SetParent() .SetGroupName("Applications") .AddConstructor() - .AddAttribute("MaxPackets", - "The maximum number of packets the application will send", - UintegerValue(100), - MakeUintegerAccessor(&UdpEchoClient::m_count), - MakeUintegerChecker()) + .AddAttribute( + "MaxPackets", + "The maximum number of packets the application will send (zero means infinite)", + UintegerValue(100), + MakeUintegerAccessor(&UdpEchoClient::m_count), + MakeUintegerChecker()) .AddAttribute("Interval", "The time to wait between packets", TimeValue(Seconds(1.0)), @@ -391,7 +392,7 @@ UdpEchoClient::Send() << Inet6SocketAddress::ConvertFrom(m_peerAddress).GetPort()); } - if (m_sent < m_count) + if (m_sent < m_count || m_count == 0) { ScheduleTransmit(m_interval); } diff --git a/src/internet-apps/model/ping6.cc b/src/internet-apps/model/ping6.cc index 55addfde6..90064669e 100644 --- a/src/internet-apps/model/ping6.cc +++ b/src/internet-apps/model/ping6.cc @@ -42,35 +42,37 @@ NS_OBJECT_ENSURE_REGISTERED(Ping6); TypeId Ping6::GetTypeId() { - static TypeId tid = TypeId("ns3::Ping6") - .SetParent() - .SetGroupName("Internet-Apps") - .AddConstructor() - .AddAttribute("MaxPackets", - "The maximum number of packets the application will send", - UintegerValue(100), - MakeUintegerAccessor(&Ping6::m_count), - MakeUintegerChecker()) - .AddAttribute("Interval", - "The time to wait between packets", - TimeValue(Seconds(1.0)), - MakeTimeAccessor(&Ping6::m_interval), - MakeTimeChecker()) - .AddAttribute("RemoteIpv6", - "The Ipv6Address of the outbound packets", - Ipv6AddressValue(), - MakeIpv6AddressAccessor(&Ping6::m_peerAddress), - MakeIpv6AddressChecker()) - .AddAttribute("LocalIpv6", - "Local Ipv6Address of the sender", - Ipv6AddressValue(), - MakeIpv6AddressAccessor(&Ping6::m_localAddress), - MakeIpv6AddressChecker()) - .AddAttribute("PacketSize", - "Size of packets generated", - UintegerValue(100), - MakeUintegerAccessor(&Ping6::m_size), - MakeUintegerChecker()); + static TypeId tid = + TypeId("ns3::Ping6") + .SetParent() + .SetGroupName("Internet-Apps") + .AddConstructor() + .AddAttribute( + "MaxPackets", + "The maximum number of packets the application will send (zero means infinite)", + UintegerValue(100), + MakeUintegerAccessor(&Ping6::m_count), + MakeUintegerChecker()) + .AddAttribute("Interval", + "The time to wait between packets", + TimeValue(Seconds(1.0)), + MakeTimeAccessor(&Ping6::m_interval), + MakeTimeChecker()) + .AddAttribute("RemoteIpv6", + "The Ipv6Address of the outbound packets", + Ipv6AddressValue(), + MakeIpv6AddressAccessor(&Ping6::m_peerAddress), + MakeIpv6AddressChecker()) + .AddAttribute("LocalIpv6", + "Local Ipv6Address of the sender", + Ipv6AddressValue(), + MakeIpv6AddressAccessor(&Ping6::m_localAddress), + MakeIpv6AddressChecker()) + .AddAttribute("PacketSize", + "Size of packets generated", + UintegerValue(100), + MakeUintegerAccessor(&Ping6::m_size), + MakeUintegerChecker()); return tid; } @@ -246,7 +248,7 @@ Ping6::Send() NS_LOG_INFO("Sent " << p->GetSize() << " bytes to " << m_peerAddress); - if (m_sent < m_count) + if (m_sent < m_count || m_count == 0) { ScheduleTransmit(m_interval); } diff --git a/src/lte/test/epc-test-s1u-uplink.cc b/src/lte/test/epc-test-s1u-uplink.cc index 5c4ae74aa..f4f2961e9 100644 --- a/src/lte/test/epc-test-s1u-uplink.cc +++ b/src/lte/test/epc-test-s1u-uplink.cc @@ -125,11 +125,12 @@ EpsBearerTagUdpClient::GetTypeId() TypeId("ns3::EpsBearerTagUdpClient") .SetParent() .AddConstructor() - .AddAttribute("MaxPackets", - "The maximum number of packets the application will send", - UintegerValue(100), - MakeUintegerAccessor(&EpsBearerTagUdpClient::m_count), - MakeUintegerChecker()) + .AddAttribute( + "MaxPackets", + "The maximum number of packets the application will send (zero means infinite)", + UintegerValue(100), + MakeUintegerAccessor(&EpsBearerTagUdpClient::m_count), + MakeUintegerChecker()) .AddAttribute("Interval", "The time to wait between packets", TimeValue(Seconds(1.0)), @@ -241,7 +242,7 @@ EpsBearerTagUdpClient::Send() NS_LOG_INFO("Error while sending " << m_size << " bytes to " << m_peerAddress); } - if (m_sent < m_count) + if (m_sent < m_count || m_count == 0) { m_sendEvent = Simulator::Schedule(m_interval, &EpsBearerTagUdpClient::Send, this); } From c41057b47edd94cea6a11bb57c32e57fc15dfc32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Thu, 10 Nov 2022 09:41:07 +0100 Subject: [PATCH 023/494] netanim: Add helper function to update the size of a node This function allows passing a pointer to update the size of a node, like it is already available for updating the color or description of a node. --- src/netanim/model/animation-interface.cc | 6 ++++++ src/netanim/model/animation-interface.h | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/netanim/model/animation-interface.cc b/src/netanim/model/animation-interface.cc index a9192ec1f..2e5a2af85 100644 --- a/src/netanim/model/animation-interface.cc +++ b/src/netanim/model/animation-interface.cc @@ -376,6 +376,12 @@ AnimationInterface::SetBackgroundImage(std::string fileName, WriteXmlUpdateBackground(fileName, x, y, scaleX, scaleY, opacity); } +void +AnimationInterface::UpdateNodeSize(Ptr n, double width, double height) +{ + UpdateNodeSize(n->GetId(), width, height); +} + void AnimationInterface::UpdateNodeSize(uint32_t nodeId, double width, double height) { diff --git a/src/netanim/model/animation-interface.h b/src/netanim/model/animation-interface.h index 8149a9980..65610cf2b 100644 --- a/src/netanim/model/animation-interface.h +++ b/src/netanim/model/animation-interface.h @@ -284,6 +284,15 @@ class AnimationInterface */ void UpdateNodeImage(uint32_t nodeId, uint32_t resourceId); + /** + * \brief Helper function to update the size of a node + * \param n Ptr to the node + * \param width Width of the node + * \param height Height of the node + * + */ + void UpdateNodeSize(Ptr n, double width, double height); + /** * \brief Helper function to update the size of a node * \param nodeId Id of the node From d0197e11479e9c1175b96132647101c1fa8bd023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Wed, 9 Nov 2022 17:33:53 +0100 Subject: [PATCH 024/494] wifi: Fix 10 MHz offset in center frequencies for 6 GHz channels --- src/wifi/examples/wifi-phy-configuration.cc | 4 +- src/wifi/model/wifi-phy-operating-channel.cc | 218 +++++++++---------- src/wifi/test/wifi-test.cc | 2 +- 3 files changed, 112 insertions(+), 112 deletions(-) diff --git a/src/wifi/examples/wifi-phy-configuration.cc b/src/wifi/examples/wifi-phy-configuration.cc index 5a4865400..fcd7c5c29 100644 --- a/src/wifi/examples/wifi-phy-configuration.cc +++ b/src/wifi/examples/wifi-phy-configuration.cc @@ -225,10 +225,10 @@ main(int argc, char* argv[]) staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0)); apDevice = wifi.Install(phy, macAp, wifiApNode.Get(0)); phySta = GetYansWifiPhyPtr(staDevice); - // We expect channel 7, width 80, frequency 5975 + // We expect channel 7, width 80, frequency 5985 NS_ASSERT(phySta->GetChannelNumber() == 7); NS_ASSERT(phySta->GetChannelWidth() == 80); - NS_ASSERT(phySta->GetFrequency() == 5975); + NS_ASSERT(phySta->GetFrequency() == 5985); PrintAttributesIfEnabled(printAttributes); break; case 10: diff --git a/src/wifi/model/wifi-phy-operating-channel.cc b/src/wifi/model/wifi-phy-operating-channel.cc index 356711361..ae1c76080 100644 --- a/src/wifi/model/wifi-phy-operating-channel.cc +++ b/src/wifi/model/wifi-phy-operating-channel.cc @@ -152,118 +152,118 @@ const std::set WifiPhyOperatingChannel::m_frequencyChannel // Now the 6 GHz channels for 802.11ax/be // 20 MHz channels - {std::make_tuple(1, 5945, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(5, 5965, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(9, 5985, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(13, 6005, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(17, 6025, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(21, 6045, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(25, 6065, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(29, 6085, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(33, 6105, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(37, 6125, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(41, 6145, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(45, 6165, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(49, 6185, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(53, 6205, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(57, 6225, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(61, 6245, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(65, 6265, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(69, 6285, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(73, 6305, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(77, 6325, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(81, 6345, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(85, 6365, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(89, 6385, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(93, 6405, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(97, 6425, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(101, 6445, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(105, 6465, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(109, 6485, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(113, 6505, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(117, 6525, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(121, 6545, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(125, 6565, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(129, 6585, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(133, 6605, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(137, 6625, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(141, 6645, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(145, 6665, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(149, 6685, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(153, 6705, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(157, 6725, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(161, 6745, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(165, 6765, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(169, 6785, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(173, 6805, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(177, 6825, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(181, 6845, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(185, 6865, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(189, 6885, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(193, 6905, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(197, 6925, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(201, 6945, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(205, 6965, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(209, 6985, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(213, 7005, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(217, 7025, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(221, 7045, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(225, 7065, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(229, 7085, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(233, 7105, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(1, 5955, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(5, 5975, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(9, 5995, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(13, 6015, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(17, 6035, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(21, 6055, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(25, 6075, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(29, 6095, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(33, 6115, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(37, 6135, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(41, 6155, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(45, 6175, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(49, 6195, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(53, 6215, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(57, 6235, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(61, 6255, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(65, 6275, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(69, 6295, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(73, 6315, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(77, 6335, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(81, 6355, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(85, 6375, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(89, 6395, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(93, 6415, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(97, 6435, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(101, 6455, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(105, 6475, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(109, 6495, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(113, 6515, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(117, 6535, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(121, 6555, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(125, 6575, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(129, 6595, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(133, 6615, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(137, 6635, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(141, 6655, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(145, 6675, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(149, 6695, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(153, 6715, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(157, 6735, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(161, 6755, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(165, 6775, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(169, 6795, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(173, 6815, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(177, 6835, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(181, 6855, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(185, 6875, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(189, 6895, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(193, 6915, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(197, 6935, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(201, 6955, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(205, 6975, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(209, 6995, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(213, 7015, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(217, 7035, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(221, 7055, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(225, 7075, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(229, 7095, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(233, 7115, 20, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, // 40 MHz channels - {std::make_tuple(3, 5955, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(11, 5995, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(19, 6035, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(27, 6075, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(35, 6115, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(43, 6155, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(51, 6195, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(59, 6235, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(67, 6275, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(75, 6315, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(83, 6355, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(91, 6395, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(99, 6435, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(107, 6475, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(115, 6515, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(123, 6555, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(131, 6595, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(139, 6635, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(147, 6675, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(155, 6715, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(163, 6755, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(171, 6795, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(179, 6835, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(187, 6875, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(195, 6915, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(203, 6955, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(211, 6995, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(219, 7035, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(227, 7075, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(3, 5965, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(11, 6005, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(19, 6045, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(27, 6085, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(35, 6125, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(43, 6165, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(51, 6205, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(59, 6245, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(67, 6285, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(75, 6325, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(83, 6365, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(91, 6405, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(99, 6445, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(107, 6485, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(115, 6525, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(123, 6565, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(131, 6605, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(139, 6645, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(147, 6685, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(155, 6725, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(163, 6765, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(171, 6805, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(179, 6845, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(187, 6885, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(195, 6925, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(203, 6965, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(211, 7005, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(219, 7045, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(227, 7085, 40, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, // 80 MHz channels - {std::make_tuple(7, 5975, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(23, 6055, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(39, 6135, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(55, 6215, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(71, 6295, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(87, 6375, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(103, 6455, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(119, 6535, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(135, 6615, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(151, 6695, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(167, 6775, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(183, 6855, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(199, 6935, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(215, 7015, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(7, 5985, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(23, 6065, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(39, 6145, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(55, 6225, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(71, 6305, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(87, 6385, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(103, 6465, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(119, 6585, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(135, 6625, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(151, 6705, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(167, 6785, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(183, 6865, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(199, 6945, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(215, 7025, 80, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, // 160 MHz channels - {std::make_tuple(15, 6015, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(47, 6175, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(79, 6335, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(111, 6495, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(143, 6655, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(175, 6815, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, - {std::make_tuple(207, 6975, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}}; + {std::make_tuple(15, 6025, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(47, 6185, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(79, 6345, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(111, 6505, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(143, 6665, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(175, 6825, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}, + {std::make_tuple(207, 6985, 160, WIFI_PHY_OFDM_CHANNEL, WIFI_PHY_BAND_6GHZ)}}; WifiPhyOperatingChannel::WifiPhyOperatingChannel() : WifiPhyOperatingChannel(m_frequencyChannels.end()) diff --git a/src/wifi/test/wifi-test.cc b/src/wifi/test/wifi-test.cc index 6f7d2b395..c3b617522 100644 --- a/src/wifi/test/wifi-test.cc +++ b/src/wifi/test/wifi-test.cc @@ -1095,7 +1095,7 @@ SetChannelFrequencyTest::DoRun() phySta = GetYansWifiPhyPtr(staDevice); NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 7, "802.11ax-6GHz configuration"); NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 80, "802.11ax-6GHz configuration"); - NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5975, "802.11ax-6GHz configuration"); + NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5985, "802.11ax-6GHz configuration"); phy.Set("ChannelSettings", StringValue("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default } { From c71b7be77377889e31fc81216e58e1aff3ef3ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Mon, 24 Oct 2022 21:25:49 +0200 Subject: [PATCH 025/494] wifi: Remove log in getter --- src/wifi/model/wifi-spectrum-phy-interface.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wifi/model/wifi-spectrum-phy-interface.cc b/src/wifi/model/wifi-spectrum-phy-interface.cc index 7124fbb8d..46c2727cc 100644 --- a/src/wifi/model/wifi-spectrum-phy-interface.cc +++ b/src/wifi/model/wifi-spectrum-phy-interface.cc @@ -101,7 +101,6 @@ WifiSpectrumPhyInterface::GetRxSpectrumModel() const Ptr WifiSpectrumPhyInterface::GetAntenna() const { - NS_LOG_FUNCTION(this); return m_spectrumWifiPhy->GetAntenna(); } From 77a583ef08186de63f6f0c710323f2ec37a8435d Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Fri, 11 Nov 2022 21:39:24 -0300 Subject: [PATCH 026/494] build: (fixes #808) handle profile setting changes in the first ns3 run --- ns3 | 5 +++++ utils/tests/test-ns3.py | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ns3 b/ns3 index a83212791..925f2e6c1 100755 --- a/ns3 +++ b/ns3 @@ -595,6 +595,11 @@ def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_gener for (cmake_flag, option_name) in options: arg = on_off_condition(args, cmake_flag, option_name) if arg: + is_on = "=ON" in arg + reverse = arg.replace("=ON" if is_on else "=OFF", + "=OFF" if is_on else "=ON") + if reverse in cmake_args: + cmake_args.remove(reverse) cmake_args.append(arg) if args.lcov_zerocounters is not None: diff --git a/utils/tests/test-ns3.py b/utils/tests/test-ns3.py index ca9db15d6..6e9377add 100755 --- a/utils/tests/test-ns3.py +++ b/utils/tests/test-ns3.py @@ -596,6 +596,30 @@ class NS3ConfigureBuildProfileTestCase(unittest.TestCase): self.assertEqual(return_code, 2) self.assertIn("invalid choice: 'OPTIMIZED'", stderr) + def test_06_OverwriteDefaultSettings(self): + """! + Replace settings set by default (e.g. ASSERT/LOGs enabled in debug builds and disabled in default ones) + @return None + """ + return_code, _, _ = run_ns3("clean") + self.assertEqual(return_code, 0) + + return_code, stdout, stderr = run_ns3("configure -G \"{generator}\" --dry-run -d debug") + self.assertEqual(return_code, 0) + self.assertIn("-DCMAKE_BUILD_TYPE=debug -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=ON -DNS3_NATIVE_OPTIMIZATIONS=OFF", stdout) + + return_code, stdout, stderr = run_ns3("configure -G \"{generator}\" --dry-run -d debug --disable-asserts --disable-logs --disable-werror") + self.assertEqual(return_code, 0) + self.assertIn("-DCMAKE_BUILD_TYPE=debug -DNS3_NATIVE_OPTIMIZATIONS=OFF -DNS3_ASSERT=OFF -DNS3_LOG=OFF -DNS3_WARNINGS_AS_ERRORS=OFF", stdout) + + return_code, stdout, stderr = run_ns3("configure -G \"{generator}\" --dry-run") + self.assertEqual(return_code, 0) + self.assertIn("-DCMAKE_BUILD_TYPE=default -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=OFF -DNS3_NATIVE_OPTIMIZATIONS=OFF", stdout) + + return_code, stdout, stderr = run_ns3("configure -G \"{generator}\" --dry-run --enable-asserts --enable-logs --enable-werror") + self.assertEqual(return_code, 0) + self.assertIn("-DCMAKE_BUILD_TYPE=default -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_NATIVE_OPTIMIZATIONS=OFF -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=ON", stdout) + class NS3BaseTestCase(unittest.TestCase): """! From 52bb99f81fdc5557c7f79735fb41990cd4a23e9b Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Wed, 2 Nov 2022 15:35:57 -0300 Subject: [PATCH 027/494] build: replace find_package(Doxygen) with the result from check_deps --- build-support/macros-and-definitions.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 3b962bdfc..2d314cb93 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -975,7 +975,7 @@ macro(process_options) add_custom_target(doxygen-no-build COMMAND ${doxygen_missing_msg}) else() # We checked this already exists, but we need the path to the executable - find_package(Doxygen QUIET) + set(DOXYGEN_EXECUTABLE ${DOXYGEN}) # Get introspected doxygen add_custom_target( From 5473752af83315fd8abe424a49b5c0d607575b1a Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Fri, 11 Nov 2022 23:18:53 -0300 Subject: [PATCH 028/494] build: skip full python checks unless bindings are enabled --- build-support/macros-and-definitions.cmake | 44 +++++++++++++--------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 2d314cb93..54eded8a0 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -755,25 +755,35 @@ macro(process_options) set(Python3_EXECUTABLE) set(Python3_FOUND FALSE) set(Python3_INCLUDE_DIRS) - if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0") - find_package(Python3 COMPONENTS Interpreter Development) - else() - # cmake-format: off - set(Python_ADDITIONAL_VERSIONS 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9) - # cmake-format: on - find_package(PythonInterp) - find_package(PythonLibs) + if(${NS3_PYTHON_BINDINGS}) + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0") + find_package(Python3 COMPONENTS Interpreter Development) + else() + # cmake-format: off + set(Python_ADDITIONAL_VERSIONS 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9) + # cmake-format: on + find_package(PythonInterp) + find_package(PythonLibs) - # Move deprecated results into the FindPython3 resulting variables - set(Python3_Interpreter_FOUND ${PYTHONINTERP_FOUND}) - set(Python3_Development_FOUND ${PYTHONLIBS_FOUND}) - if(${PYTHONINTERP_FOUND}) - set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) - set(Python3_FOUND TRUE) + # Move deprecated results into the FindPython3 resulting variables + set(Python3_Interpreter_FOUND ${PYTHONINTERP_FOUND}) + set(Python3_Development_FOUND ${PYTHONLIBS_FOUND}) + if(${PYTHONINTERP_FOUND}) + set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) + set(Python3_FOUND TRUE) + endif() + if(${PYTHONLIBS_FOUND}) + set(Python3_LIBRARIES ${PYTHON_LIBRARIES}) + set(Python3_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) + endif() endif() - if(${PYTHONLIBS_FOUND}) - set(Python3_LIBRARIES ${PYTHON_LIBRARIES}) - set(Python3_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) + else() + # If Python was not set yet, use the version found by check_deps + check_deps("" "python3" python3_deps) + if(python3_deps) + message(FATAL_ERROR "Python3 was not found") + else() + set(Python3_EXECUTABLE ${PYTHON3}) endif() endif() From 87c85c815667248513b9dacb35eb4763508cadb6 Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Sat, 12 Nov 2022 12:27:47 -0300 Subject: [PATCH 029/494] build: add Ninjatracing support --- CMakeLists.txt | 5 ++++ build-support/macros-and-definitions.cmake | 31 ++++++++++++++++++++++ ns3 | 3 +++ 3 files changed, 39 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 650352690..f79f1e5b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,11 @@ option(NS3_MONOLIB ) option(NS3_MPI "Build with MPI support" OFF) option(NS3_NATIVE_OPTIMIZATIONS "Build with -march=native -mtune=native" OFF) +option( + NS3_NINJA_TRACING + "Use ninjatracing to convert Ninja's build log to the about://tracing format" + OFF +) set(NS3_OUTPUT_DIRECTORY "" CACHE STRING "Directory to store built artifacts") option(NS3_PRECOMPILE_HEADERS "Precompile module headers to speed up compilation" ON diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 54eded8a0..f62125ef0 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -876,6 +876,37 @@ macro(process_options) endif() endif() + if(${NS3_NINJA_TRACING}) + if(${CMAKE_GENERATOR} STREQUAL Ninja) + include(ExternalProject) + ExternalProject_Add( + NinjaTracing + GIT_REPOSITORY "https://github.com/nico/ninjatracing.git" + GIT_TAG "f9d21e973cfdeafa913b83a927fef56258f70b9a" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) + ExternalProject_Get_Property(NinjaTracing SOURCE_DIR) + set(embed_time_trace) + if(${NS3_CLANG_TIMETRACE} AND ${CLANG}) + set(embed_time_trace --embed-time-trace) + endif() + add_custom_target( + ninjaTrace + COMMAND + ${Python3_EXECUTABLE} ${SOURCE_DIR}/ninjatracing -a + ${embed_time_trace} ${PROJECT_BINARY_DIR}/.ninja_log > + ${PROJECT_SOURCE_DIR}/ninja_performance_trace.json + DEPENDS NinjaTracing + ) + unset(embed_time_trace) + unset(SOURCE_DIR) + else() + message(FATAL_ERROR "Ninjatracing requires the Ninja generator") + endif() + endif() + # Disable the below warning from bindings built in debug mode with clang++: # "expression with side effects will be evaluated despite being used as an # operand to 'typeid'" diff --git a/ns3 b/ns3 index 925f2e6c1..a11662a6d 100755 --- a/ns3 +++ b/ns3 @@ -142,6 +142,7 @@ def parse_args(argv): ("logs", "the logs regardless of the compile mode"), ("monolib", "a single shared library with all ns-3 modules"), ("mpi", "the MPI support for distributed simulation"), + ("ninja-tracing", "the conversion of the Ninja generator log file into about://tracing format"), ("precompiled-headers", "precompiled headers"), ("python-bindings", "python bindings"), ("tests", "the ns-3 tests"), @@ -583,6 +584,7 @@ def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_gener ("LOG", "logs"), ("MONOLIB", "monolib"), ("MPI", "mpi"), + ("NINJA_TRACING", "ninja_tracing"), ("PRECOMPILE_HEADERS", "precompiled_headers"), ("PYTHON_BINDINGS", "python_bindings"), ("SANITIZE", "sanitizers"), @@ -979,6 +981,7 @@ def build_step(args, "sphinx", "manual", "models", + "ninjaTrace", "timeTraceReport", "tutorial", "contributing", From c5aa4dbd3431686fa4f6d5a5a607d587a1207d0b Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Sat, 12 Nov 2022 14:11:15 -0300 Subject: [PATCH 030/494] ci: do not reuse Ubuntu job cache in CodeQL job --- .github/workflows/per_commit.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/per_commit.yml b/.github/workflows/per_commit.yml index deffd3c79..0911a8e32 100644 --- a/.github/workflows/per_commit.yml +++ b/.github/workflows/per_commit.yml @@ -77,8 +77,8 @@ jobs: uses: actions/cache@v3 with: path: .ccache - key: ubuntu-ci-${{env.time}} - restore-keys: ubuntu-ci- + key: ubuntu-codeql-${{env.time}} + restore-keys: ubuntu-codeql- - name: Setup ccache run: | ccache --set-config=cache_dir="$GITHUB_WORKSPACE/.ccache" From 0e7a8ebb31b9e2e64bb27da76d1995839d4446aa Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Sat, 12 Nov 2022 15:16:51 -0300 Subject: [PATCH 031/494] build: check ccache version before enabling precompiled headers --- build-support/macros-and-definitions.cmake | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index f62125ef0..16b7e6cfe 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -1319,8 +1319,34 @@ macro(process_options) "Clang-tidy is incompatible with precompiled headers. Continuing without them." ) elseif(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0") - set(PRECOMPILE_HEADERS_ENABLED ON) - message(STATUS "Precompiled headers were enabled") + # If ccache was not found, we can continue with precompiled headers + if("${CCACHE}" STREQUAL "CCACHE-NOTFOUND") + set(PRECOMPILE_HEADERS_ENABLED ON) + message(STATUS "Precompiled headers were enabled") + else() + # If ccache was found, we need to check if it is ccache >= 4 + execute_process(COMMAND ${CCACHE} -V OUTPUT_VARIABLE CCACHE_OUT) + # Extract ccache version + if(CCACHE_OUT MATCHES "ccache version ([0-9\.]*)") + # If an incompatible version is found, do not enable precompiled + # headers + if("${CMAKE_MATCH_1}" VERSION_LESS "4.0.0") + set(PRECOMPILE_HEADERS_ENABLED OFF) + message( + ${HIGHLIGHTED_STATUS} + "Precompiled headers are incompatible with ccache ${CMAKE_MATCH_1} and will be disabled." + ) + else() + set(PRECOMPILE_HEADERS_ENABLED ON) + message(STATUS "Precompiled headers were enabled.") + endif() + else() + message( + FATAL_ERROR + "Failed to extract the ccache version while enabling precompiled headers." + ) + endif() + endif() else() message( STATUS From 10a61ca1020e8e58a67417796d275438cb76a868 Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Sat, 12 Nov 2022 17:02:49 -0300 Subject: [PATCH 032/494] test: refactor Docker-based tests in test-ns3.py --- utils/tests/test-ns3.py | 150 +++++++++++++++++++++++----------------- 1 file changed, 85 insertions(+), 65 deletions(-) diff --git a/utils/tests/test-ns3.py b/utils/tests/test-ns3.py index 6e9377add..86087fcb4 100755 --- a/utils/tests/test-ns3.py +++ b/utils/tests/test-ns3.py @@ -180,6 +180,71 @@ def get_enabled_modules(): return read_lock_entry("NS3_ENABLED_MODULES") +class DockerContainerManager: + """! + Python-on-whales wrapper for Docker-based ns-3 tests + """ + + def __init__(self, currentTestCase: unittest.TestCase, containerName: str = "ubuntu:latest"): + """! + Create and start container with containerName in the current ns-3 directory + @param self: the current DockerContainerManager instance + @param currentTestCase: the test case instance creating the DockerContainerManager + @param containerName: name of the container image to be used + """ + global DockerException + try: + from python_on_whales import docker + from python_on_whales.exceptions import DockerException + except ModuleNotFoundError: + docker = None # noqa + DockerException = None # noqa + currentTestCase.skipTest("python-on-whales was not found") + + # Import rootless docker settings from .bashrc + with open(os.path.expanduser("~/.bashrc"), "r") as f: + docker_settings = re.findall("(DOCKER_.*=.*)", f.read()) + for setting in docker_settings: + key, value = setting.split("=") + os.environ[key] = value + del docker_settings, setting, key, value + + # Create Docker client instance and start it + ## The Python-on-whales container instance + self.container = docker.run(containerName, + interactive=True, detach=True, + tty=False, + volumes=[(ns3_path, "/ns-3-dev")] + ) + + # Redefine the execute command of the container + def split_exec(docker_container, cmd): + return docker_container._execute(cmd.split(), workdir="/ns-3-dev") + + self.container._execute = self.container.execute + self.container.execute = partial(split_exec, self.container) + + def __enter__(self): + """! + Return the managed container when entiring the block "with DockerContainerManager() as container" + @param self: the current DockerContainerManager instance + @return container managed by DockerContainerManager. + """ + return self.container + + def __exit__(self, exc_type, exc_val, exc_tb): + """! + Clean up the managed container at the end of the block "with DockerContainerManager() as container" + @param self: the current DockerContainerManager instance + @param exc_type: unused parameter + @param exc_val: unused parameter + @param exc_tb: unused parameter + @return None + """ + self.container.stop() + self.container.remove() + + class NS3UnusedSourcesTestCase(unittest.TestCase): """! ns-3 tests related to checking if source files were left behind, not being used by CMake @@ -606,19 +671,29 @@ class NS3ConfigureBuildProfileTestCase(unittest.TestCase): return_code, stdout, stderr = run_ns3("configure -G \"{generator}\" --dry-run -d debug") self.assertEqual(return_code, 0) - self.assertIn("-DCMAKE_BUILD_TYPE=debug -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=ON -DNS3_NATIVE_OPTIMIZATIONS=OFF", stdout) + self.assertIn( + "-DCMAKE_BUILD_TYPE=debug -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=ON -DNS3_NATIVE_OPTIMIZATIONS=OFF", + stdout) - return_code, stdout, stderr = run_ns3("configure -G \"{generator}\" --dry-run -d debug --disable-asserts --disable-logs --disable-werror") + return_code, stdout, stderr = run_ns3( + "configure -G \"{generator}\" --dry-run -d debug --disable-asserts --disable-logs --disable-werror") self.assertEqual(return_code, 0) - self.assertIn("-DCMAKE_BUILD_TYPE=debug -DNS3_NATIVE_OPTIMIZATIONS=OFF -DNS3_ASSERT=OFF -DNS3_LOG=OFF -DNS3_WARNINGS_AS_ERRORS=OFF", stdout) + self.assertIn( + "-DCMAKE_BUILD_TYPE=debug -DNS3_NATIVE_OPTIMIZATIONS=OFF -DNS3_ASSERT=OFF -DNS3_LOG=OFF -DNS3_WARNINGS_AS_ERRORS=OFF", + stdout) return_code, stdout, stderr = run_ns3("configure -G \"{generator}\" --dry-run") self.assertEqual(return_code, 0) - self.assertIn("-DCMAKE_BUILD_TYPE=default -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=OFF -DNS3_NATIVE_OPTIMIZATIONS=OFF", stdout) + self.assertIn( + "-DCMAKE_BUILD_TYPE=default -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=OFF -DNS3_NATIVE_OPTIMIZATIONS=OFF", + stdout) - return_code, stdout, stderr = run_ns3("configure -G \"{generator}\" --dry-run --enable-asserts --enable-logs --enable-werror") + return_code, stdout, stderr = run_ns3( + "configure -G \"{generator}\" --dry-run --enable-asserts --enable-logs --enable-werror") self.assertEqual(return_code, 0) - self.assertIn("-DCMAKE_BUILD_TYPE=default -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_NATIVE_OPTIMIZATIONS=OFF -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=ON", stdout) + self.assertIn( + "-DCMAKE_BUILD_TYPE=default -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_NATIVE_OPTIMIZATIONS=OFF -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=ON", + stdout) class NS3BaseTestCase(unittest.TestCase): @@ -1419,35 +1494,8 @@ class NS3ConfigureTestCase(NS3BaseTestCase): @return None """ - try: - from python_on_whales import docker - from python_on_whales.exceptions import DockerException - except ModuleNotFoundError: - docker = None # noqa - DockerException = None # noqa - self.skipTest("python-on-whales was not found") - - # Import rootless docker settings from .bashrc - with open(os.path.expanduser("~/.bashrc"), "r") as f: - docker_settings = re.findall("(DOCKER_.*=.*)", f.read()) - for setting in docker_settings: - key, value = setting.split("=") - os.environ[key] = value - del docker_settings, setting, key, value - # Create Docker client instance and start it - with docker.run("ubuntu:22.04", - interactive=True, detach=True, - tty=False, - volumes=[(ns3_path, "/ns-3-dev")] - ) as container: - # Redefine the execute command of the container - def split_exec(docker_container, cmd): - return docker_container._execute(cmd.split(), workdir="/ns-3-dev") - - container._execute = container.execute - container.execute = partial(split_exec, container) - + with DockerContainerManager(self, "ubuntu:22.04") as container: # Install basic packages container.execute("apt-get update") container.execute("apt-get install -y python3 ninja-build cmake g++") @@ -1572,37 +1620,8 @@ class NS3ConfigureTestCase(NS3BaseTestCase): @return None """ - try: - from python_on_whales import docker - from python_on_whales.exceptions import DockerException - except ModuleNotFoundError: - docker = None # noqa - DockerException = None # noqa - self.skipTest("python-on-whales was not found") - run_ns3("clean") - - # Import rootless docker settings from .bashrc - with open(os.path.expanduser("~/.bashrc"), "r") as f: - docker_settings = re.findall("(DOCKER_.*=.*)", f.read()) - for setting in docker_settings: - key, value = setting.split("=") - os.environ[key] = value - del docker_settings, setting, key, value - - # Create Docker client instance and start it - with docker.run("gcc:12.1", # Debian with minimum supported version of GCC for Mold - interactive=True, detach=True, - tty=False, - volumes=[(ns3_path, "/ns-3-dev")], - ) as container: - # Redefine the execute command of the container - def split_exec(docker_container, cmd): - return docker_container._execute(cmd.split(), workdir="/ns-3-dev") - - container._execute = container.execute - container.execute = partial(split_exec, container) - + with DockerContainerManager(self, "gcc:12.1") as container: # Install basic packages container.execute("apt-get update") container.execute("apt-get install -y python3 ninja-build cmake g++ lld") @@ -2663,7 +2682,8 @@ class NS3QualityControlTestCase(unittest.TestCase): # User agent string to make ACM and Elsevier let us check if links to papers are working headers = { - 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36' # noqa + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36' + # noqa } def test_file_url(args): From 1ccd8ed0b657e935ddc60ffd407c71237a7e3329 Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Sat, 12 Nov 2022 18:21:32 -0300 Subject: [PATCH 033/494] test: add NS3_CLANG_TIMETRACE test case in test-ns3.py --- build-support/macros-and-definitions.cmake | 1 + utils/tests/test-ns3.py | 56 ++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 16b7e6cfe..245cbc31d 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -479,6 +479,7 @@ macro(process_options) ClangBuildAnalyzer GIT_REPOSITORY "https://github.com/aras-p/ClangBuildAnalyzer.git" GIT_TAG "47406981a1c5a89e8f8c62802b924c3e163e7cb4" + CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} INSTALL_COMMAND cmake -E copy_if_different ClangBuildAnalyzer ${PROJECT_BINARY_DIR} ) diff --git a/utils/tests/test-ns3.py b/utils/tests/test-ns3.py index 86087fcb4..b075ce664 100755 --- a/utils/tests/test-ns3.py +++ b/utils/tests/test-ns3.py @@ -1667,6 +1667,62 @@ class NS3ConfigureTestCase(NS3BaseTestCase): # Clean leftovers before proceeding run_ns3("clean") + def test_21_ClangTimeTrace(self): + """! + Check if NS3_CLANG_TIMETRACE feature is working + Clang's -ftime-trace plus ClangAnalyzer report + @return None + """ + + run_ns3("clean") + with DockerContainerManager(self, "ubuntu:20.04") as container: + container.execute("apt-get update") + container.execute("apt-get install -y python3 ninja-build cmake clang-10") + + # Enable ClangTimeTrace without git (it should fail) + try: + container.execute( + "./ns3 configure -G Ninja --enable-modules=core --enable-examples --enable-tests -- -DCMAKE_CXX_COMPILER=/usr/bin/clang++-10 -DNS3_CLANG_TIMETRACE=ON") + except DockerException as e: + self.assertIn("could not find git for clone of ClangBuildAnalyzer", e.stderr) + + container.execute("apt-get install -y git") + + # Enable ClangTimeTrace without git (it should succeed) + try: + container.execute( + "./ns3 configure -G Ninja --enable-modules=core --enable-examples --enable-tests -- -DCMAKE_CXX_COMPILER=/usr/bin/clang++-10 -DNS3_CLANG_TIMETRACE=ON") + except DockerException as e: + self.assertIn("could not find git for clone of ClangBuildAnalyzer", e.stderr) + + # Clean leftover time trace report + time_trace_report_path = os.path.join(ns3_path, "ClangBuildAnalyzerReport.txt") + if os.path.exists(time_trace_report_path): + os.remove(time_trace_report_path) + + # Build new time trace report + try: + container.execute("./ns3 build timeTraceReport") + except DockerException as e: + self.assertTrue(False, "Failed to build the ClangAnalyzer's time trace report") + + # Check if the report exists + self.assertTrue(os.path.exists(time_trace_report_path)) + + # Now try with GCC, which should fail during the configuration + run_ns3("clean") + container.execute("apt-get install -y g++") + container.execute("apt-get remove -y clang-10") + + try: + container.execute( + "./ns3 configure -G Ninja --enable-modules=core --enable-examples --enable-tests -- -DNS3_CLANG_TIMETRACE=ON") + self.assertTrue(False, "ClangTimeTrace requires Clang, but GCC just passed the checks too") + except DockerException as e: + self.assertIn("TimeTrace is a Clang feature", e.stderr) + + # Clean leftovers before proceeding + run_ns3("clean") class NS3BuildBaseTestCase(NS3BaseTestCase): """! From abaf9fecbc7564786f7cb9b9f76e320dc1d1c5d0 Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Sat, 12 Nov 2022 18:45:55 -0300 Subject: [PATCH 034/494] test: add NS3_NINJA_TRACE test case in test-ns3.py --- utils/tests/test-ns3.py | 87 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/utils/tests/test-ns3.py b/utils/tests/test-ns3.py index b075ce664..e4b123d33 100755 --- a/utils/tests/test-ns3.py +++ b/utils/tests/test-ns3.py @@ -1724,6 +1724,93 @@ class NS3ConfigureTestCase(NS3BaseTestCase): # Clean leftovers before proceeding run_ns3("clean") + def test_22_NinjaTrace(self): + """! + Check if NS3_NINJA_TRACE feature is working + Ninja's .ninja_log conversion to about://tracing + json format conversion with Ninjatracing + @return None + """ + + run_ns3("clean") + with DockerContainerManager(self, "ubuntu:20.04") as container: + container.execute("apt-get update") + container.execute("apt-get install -y python3 cmake clang-10") + + # Enable Ninja tracing without using the Ninja generator + try: + container.execute( + "./ns3 configure --enable-modules=core --enable-ninja-tracing -- -DCMAKE_CXX_COMPILER=/usr/bin/clang++-10") + except DockerException as e: + self.assertIn("Ninjatracing requires the Ninja generator", e.stderr) + + # Clean build system leftovers + run_ns3("clean") + + container.execute("apt-get install -y ninja-build") + # Enable Ninjatracing support without git (should fail) + try: + container.execute( + "./ns3 configure -G Ninja --enable-modules=core --enable-ninja-tracing -- -DCMAKE_CXX_COMPILER=/usr/bin/clang++-10") + except DockerException as e: + self.assertIn("could not find git for clone of NinjaTracing", e.stderr) + + container.execute("apt-get install -y git") + # Enable Ninjatracing support with git (it should succeed) + try: + container.execute( + "./ns3 configure -G Ninja --enable-modules=core --enable-ninja-tracing -- -DCMAKE_CXX_COMPILER=/usr/bin/clang++-10") + except DockerException as e: + self.assertTrue(False, "Failed to configure with Ninjatracing") + + # Clean leftover ninja trace + ninja_trace_path = os.path.join(ns3_path, "ninja_performance_trace.json") + if os.path.exists(ninja_trace_path): + os.remove(ninja_trace_path) + + # Build the core module + container.execute("./ns3 build core") + + # Build new ninja trace + try: + container.execute("./ns3 build ninjaTrace") + except DockerException as e: + self.assertTrue(False, "Failed to run Ninjatracing's tool to build the trace") + + # Check if the report exists + self.assertTrue(os.path.exists(ninja_trace_path)) + trace_size = os.stat(ninja_trace_path).st_size + os.remove(ninja_trace_path) + + run_ns3("clean") + + # Enable Clang TimeTrace feature for more detailed traces + try: + container.execute( + "./ns3 configure -G Ninja --enable-modules=core --enable-ninja-tracing -- -DCMAKE_CXX_COMPILER=/usr/bin/clang++-10 -DNS3_CLANG_TIMETRACE=ON") + except DockerException as e: + self.assertTrue(False, "Failed to configure Ninjatracing with Clang's TimeTrace") + + # Build the core module + container.execute("./ns3 build core") + + # Build new ninja trace + try: + container.execute("./ns3 build ninjaTrace") + except DockerException as e: + self.assertTrue(False, "Failed to run Ninjatracing's tool to build the trace") + + self.assertTrue(os.path.exists(ninja_trace_path)) + timetrace_size = os.stat(ninja_trace_path).st_size + os.remove(ninja_trace_path) + + # Check if timetrace's trace is bigger than the original trace (it should be) + self.assertGreater(timetrace_size, trace_size) + + # Clean leftovers before proceeding + run_ns3("clean") + + class NS3BuildBaseTestCase(NS3BaseTestCase): """! Tests ns3 regarding building the project From 789967fbc4c6afbaaee0ee1d9eb9376fa745043d Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Sat, 12 Nov 2022 19:22:26 -0300 Subject: [PATCH 035/494] test: add test case for precompiled header checks in test-ns3.py --- utils/tests/test-ns3.py | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/utils/tests/test-ns3.py b/utils/tests/test-ns3.py index e4b123d33..5006bd8c3 100755 --- a/utils/tests/test-ns3.py +++ b/utils/tests/test-ns3.py @@ -1810,6 +1810,51 @@ class NS3ConfigureTestCase(NS3BaseTestCase): # Clean leftovers before proceeding run_ns3("clean") + def test_23_PrecompiledHeaders(self): + """! + Check if precompiled headers are being enabled correctly. + @return None + """ + + run_ns3("clean") + # Ubuntu 18.04 ships with: + # - cmake 3.10: does not support PCH + # - ccache 3.4: incompatible with pch + with DockerContainerManager(self, "ubuntu:18.04") as container: + container.execute("apt-get update") + container.execute("apt-get install -y python3 cmake ccache clang-10") + try: + container.execute("./ns3 configure -- -DCMAKE_CXX_COMPILER=/usr/bin/clang++-10") + except DockerException as e: + self.assertIn("does not support precompiled headers", e.stderr) + run_ns3("clean") + + # Ubuntu 20.04 ships with: + # - cmake 3.16: does support PCH + # - ccache 3.7: incompatible with pch + with DockerContainerManager(self, "ubuntu:20.04") as container: + container.execute("apt-get update") + container.execute("apt-get install -y python3 cmake ccache g++") + try: + container.execute("./ns3 configure") + except DockerException as e: + self.assertIn("incompatible with ccache", e.stderr) + run_ns3("clean") + + # Ubuntu 22.04 ships with: + # - cmake 3.22: does support PCH + # - ccache 4.5: compatible with pch + with DockerContainerManager(self, "ubuntu:22.04") as container: + container.execute("apt-get update") + container.execute("apt-get install -y python3 cmake ccache g++") + try: + container.execute("./ns3 configure") + except DockerException as e: + self.assertTrue(False, "Precompiled headers should have been enabled") + + # Clean build system leftovers + run_ns3("clean") + class NS3BuildBaseTestCase(NS3BaseTestCase): """! From 5bf6e4d642452d50475ef194009c98698570c564 Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Mon, 14 Nov 2022 14:49:14 -0300 Subject: [PATCH 036/494] Update README.md to display coverage and CI badges --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 0c6ca92d1..f0ab483ed 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # The Network Simulator, Version 3 + +[![codecov](https://codecov.io/gh/nsnam/ns-3-dev-git/branch/master/graph/badge.svg)](https://codecov.io/gh/nsnam/ns-3-dev-git/branch/master/) +[![Gitlab CI](https://gitlab.com/nsnam/ns-3-dev/badges/master/pipeline.svg)](https://gitlab.com/nsnam/ns-3-dev/-/pipelines) +[![Github CI](https://github.com/nsnam/ns-3-dev-git/actions/workflows/per_commit.yml/badge.svg)](https://github.com/nsnam/ns-3-dev-git/actions) + + ## Table of Contents 1) [An overview](#an-open-source-project) From 7714b2d201b96969f5837871fc238ad02d5ce627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Wed, 28 Sep 2022 07:35:38 +0200 Subject: [PATCH 037/494] wifi: Cleanup unused parameter in WifiSpectrumSignalParameters --- src/wifi/model/phy-entity.cc | 1 - src/wifi/model/wifi-spectrum-signal-parameters.cc | 2 -- src/wifi/model/wifi-spectrum-signal-parameters.h | 1 - 3 files changed, 4 deletions(-) diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index 6b3ecfc8c..3cde20667 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -1301,7 +1301,6 @@ PhyEntity::Transmit(Time txDuration, txParams->duration = txDuration; txParams->psd = txPowerSpectrum; txParams->ppdu = ppdu; - txParams->txCenterFreq = GetCenterFrequencyForChannelWidth(txVector); NS_LOG_DEBUG("Starting " << type << " with power " << WToDbm(txPowerWatts) << " dBm on channel " << +m_wifiPhy->GetChannelNumber() << " for " << txParams->duration.As(Time::MS)); diff --git a/src/wifi/model/wifi-spectrum-signal-parameters.cc b/src/wifi/model/wifi-spectrum-signal-parameters.cc index 3e067e2fc..542cb6682 100644 --- a/src/wifi/model/wifi-spectrum-signal-parameters.cc +++ b/src/wifi/model/wifi-spectrum-signal-parameters.cc @@ -30,7 +30,6 @@ namespace ns3 NS_LOG_COMPONENT_DEFINE("WifiSpectrumSignalParameters"); WifiSpectrumSignalParameters::WifiSpectrumSignalParameters() - : txCenterFreq(0) { NS_LOG_FUNCTION(this); } @@ -40,7 +39,6 @@ WifiSpectrumSignalParameters::WifiSpectrumSignalParameters(const WifiSpectrumSig { NS_LOG_FUNCTION(this << &p); ppdu = p.ppdu; - txCenterFreq = p.txCenterFreq; } Ptr diff --git a/src/wifi/model/wifi-spectrum-signal-parameters.h b/src/wifi/model/wifi-spectrum-signal-parameters.h index 1aa602d4e..5a5411e8b 100644 --- a/src/wifi/model/wifi-spectrum-signal-parameters.h +++ b/src/wifi/model/wifi-spectrum-signal-parameters.h @@ -50,7 +50,6 @@ struct WifiSpectrumSignalParameters : public SpectrumSignalParameters WifiSpectrumSignalParameters(const WifiSpectrumSignalParameters& p); Ptr ppdu; ///< The PPDU being transmitted - uint16_t txCenterFreq; ///< the center frequency of the transmitted signal in MHz }; } // namespace ns3 From f834a6e3891e8af10eccc2d63023e9d14651700a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Wed, 28 Sep 2022 07:43:34 +0200 Subject: [PATCH 038/494] wifi: Simplify Copy functions in PPDU classes --- src/wifi/model/eht/eht-ppdu.cc | 2 +- src/wifi/model/he/he-ppdu.cc | 2 +- src/wifi/model/ht/ht-ppdu.cc | 2 +- src/wifi/model/non-ht/dsss-ppdu.cc | 2 +- src/wifi/model/non-ht/erp-ofdm-ppdu.cc | 2 +- src/wifi/model/non-ht/ofdm-ppdu.cc | 2 +- src/wifi/model/vht/vht-ppdu.cc | 7 +------ src/wifi/model/wifi-ppdu.cc | 2 +- 8 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/wifi/model/eht/eht-ppdu.cc b/src/wifi/model/eht/eht-ppdu.cc index f207a0e1c..078f7b664 100644 --- a/src/wifi/model/eht/eht-ppdu.cc +++ b/src/wifi/model/eht/eht-ppdu.cc @@ -102,7 +102,7 @@ EhtPpdu::DoGetTxVector() const Ptr EhtPpdu::Copy() const { - return ns3::Copy(Ptr(this)); + return Ptr(new EhtPpdu(*this)); } } // namespace ns3 diff --git a/src/wifi/model/he/he-ppdu.cc b/src/wifi/model/he/he-ppdu.cc index a25af9050..46dc8a6f7 100644 --- a/src/wifi/model/he/he-ppdu.cc +++ b/src/wifi/model/he/he-ppdu.cc @@ -193,7 +193,7 @@ HePpdu::GetTxDuration() const Ptr HePpdu::Copy() const { - return ns3::Copy(Ptr(this)); + return Ptr(new HePpdu(*this)); } WifiPpduType diff --git a/src/wifi/model/ht/ht-ppdu.cc b/src/wifi/model/ht/ht-ppdu.cc index 4d86f5945..1bfc49728 100644 --- a/src/wifi/model/ht/ht-ppdu.cc +++ b/src/wifi/model/ht/ht-ppdu.cc @@ -95,7 +95,7 @@ HtPpdu::GetTxDuration() const Ptr HtPpdu::Copy() const { - return Create(GetPsdu(), GetTxVector(), m_txCenterFreq, GetTxDuration(), m_band, m_uid); + return Ptr(new HtPpdu(*this)); } HtPpdu::HtSigHeader::HtSigHeader() diff --git a/src/wifi/model/non-ht/dsss-ppdu.cc b/src/wifi/model/non-ht/dsss-ppdu.cc index 2d8575727..acab31d27 100644 --- a/src/wifi/model/non-ht/dsss-ppdu.cc +++ b/src/wifi/model/non-ht/dsss-ppdu.cc @@ -72,7 +72,7 @@ DsssPpdu::GetTxDuration() const Ptr DsssPpdu::Copy() const { - return Create(GetPsdu(), GetTxVector(), m_txCenterFreq, GetTxDuration(), m_uid); + return Ptr(new DsssPpdu(*this)); } DsssPpdu::DsssSigHeader::DsssSigHeader() diff --git a/src/wifi/model/non-ht/erp-ofdm-ppdu.cc b/src/wifi/model/non-ht/erp-ofdm-ppdu.cc index 757569eaf..f6a13e3f5 100644 --- a/src/wifi/model/non-ht/erp-ofdm-ppdu.cc +++ b/src/wifi/model/non-ht/erp-ofdm-ppdu.cc @@ -58,7 +58,7 @@ ErpOfdmPpdu::DoGetTxVector() const Ptr ErpOfdmPpdu::Copy() const { - return Create(GetPsdu(), GetTxVector(), m_txCenterFreq, m_band, m_uid); + return Ptr(new ErpOfdmPpdu(*this)); } } // namespace ns3 diff --git a/src/wifi/model/non-ht/ofdm-ppdu.cc b/src/wifi/model/non-ht/ofdm-ppdu.cc index acc79a905..79b27ba04 100644 --- a/src/wifi/model/non-ht/ofdm-ppdu.cc +++ b/src/wifi/model/non-ht/ofdm-ppdu.cc @@ -78,7 +78,7 @@ OfdmPpdu::GetTxDuration() const Ptr OfdmPpdu::Copy() const { - return Create(GetPsdu(), GetTxVector(), m_txCenterFreq, m_band, m_uid); + return Ptr(new OfdmPpdu(*this)); } OfdmPpdu::LSigHeader::LSigHeader() diff --git a/src/wifi/model/vht/vht-ppdu.cc b/src/wifi/model/vht/vht-ppdu.cc index 84c8b41ad..fdd7fdc86 100644 --- a/src/wifi/model/vht/vht-ppdu.cc +++ b/src/wifi/model/vht/vht-ppdu.cc @@ -107,12 +107,7 @@ VhtPpdu::GetTxDuration() const Ptr VhtPpdu::Copy() const { - return Create(GetPsdu(), - GetTxVector(), - m_txCenterFreq, - GetTxDuration(), - m_band, - m_uid); + return Ptr(new VhtPpdu(*this)); } WifiPpduType diff --git a/src/wifi/model/wifi-ppdu.cc b/src/wifi/model/wifi-ppdu.cc index 8f43d1d9a..dd71386ca 100644 --- a/src/wifi/model/wifi-ppdu.cc +++ b/src/wifi/model/wifi-ppdu.cc @@ -227,7 +227,7 @@ WifiPpdu::Copy() const { NS_FATAL_ERROR("This method should not be called for the base WifiPpdu class. Use the " "overloaded version in the amendment-specific PPDU subclasses instead!"); - return Create(GetPsdu(), GetTxVector(), m_txCenterFreq); + return Ptr(new WifiPpdu(*this)); } std::ostream& From 343d37778f4eb917f6de2ba443b3adbb2027f187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Mon, 7 Nov 2022 20:03:00 +0100 Subject: [PATCH 039/494] wifi: Do not longer copy the WifiPpdu for each RX PHY (for now we can always use the WifiPpdu from the TX PHY) --- src/wifi/model/spectrum-wifi-phy.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index c0db1decc..da51c1b52 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -421,8 +421,7 @@ SpectrumWifiPhy::StartRx(Ptr rxParams) } NS_LOG_INFO("Received Wi-Fi signal"); - Ptr ppdu = wifiRxParams->ppdu->Copy(); - StartReceivePreamble(ppdu, rxPowerW, rxDuration); + StartReceivePreamble(wifiRxParams->ppdu, rxPowerW, rxDuration); } Ptr From ea8860e75fff36ee5188d6207e4be58f2c2eea8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Wed, 2 Nov 2022 20:01:59 +0100 Subject: [PATCH 040/494] wifi: Do no longer copy WifiPpdu for HE portion of MU transmissions --- src/wifi/model/he/he-phy.cc | 19 ++++++++++++------- src/wifi/model/he/he-phy.h | 13 +++++++++++-- src/wifi/model/he/he-ppdu.cc | 2 +- src/wifi/model/he/he-ppdu.h | 6 +++--- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index 515f207b3..49b274468 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -1378,17 +1378,13 @@ HePhy::StartTx(Ptr ppdu, const WifiTxVector& txVector) Transmit(nonOfdmaDuration, ppdu, txVector, "non-OFDMA transmission"); // OFDMA part - auto hePpdu = DynamicCast(ppdu->Copy()); // since flag will be modified - NS_ASSERT(hePpdu); - hePpdu->SetTxPsdFlag(HePpdu::PSD_HE_PORTION); Time ofdmaDuration = ppdu->GetTxDuration() - nonOfdmaDuration; Simulator::Schedule(nonOfdmaDuration, - &PhyEntity::Transmit, + &HePhy::StartTxOfdma, this, - ofdmaDuration, - hePpdu, + ppdu, txVector, - "OFDMA transmission"); + ofdmaDuration); } else { @@ -1396,6 +1392,15 @@ HePhy::StartTx(Ptr ppdu, const WifiTxVector& txVector) } } +void +HePhy::StartTxOfdma(Ptr ppdu, const WifiTxVector& txVector, Time ofdmaDuration) +{ + auto hePpdu = DynamicCast(ppdu); + NS_ASSERT(hePpdu); + hePpdu->SetTxPsdFlag(HePpdu::PSD_HE_PORTION); + Transmit(ofdmaDuration, ppdu, txVector, "OFDMA transmission"); +} + Time HePhy::CalculateTxDuration(WifiConstPsduMap psduMap, const WifiTxVector& txVector, diff --git a/src/wifi/model/he/he-phy.h b/src/wifi/model/he/he-phy.h index 68dbd11c4..5c38bc927 100644 --- a/src/wifi/model/he/he-phy.h +++ b/src/wifi/model/he/he-phy.h @@ -475,9 +475,9 @@ class HePhy : public VhtPhy virtual PhyFieldRxStatus ProcessSigB(Ptr event, PhyFieldRxStatus status); /** - * Start receiving the PSDU (i.e. the first symbol of the PSDU has arrived) of an UL-OFDMA + * Start receiving the PSDU (i.e. the first symbol of the PSDU has arrived) of an OFDMA * transmission. This function is called upon the RX event corresponding to the OFDMA part of - * the UL MU PPDU. + * the MU PPDU. * * \param event the event holding incoming OFDMA part of the PPDU's information */ @@ -527,6 +527,15 @@ class HePhy : public VhtPhy uint8_t GetNumberBccEncoders(const WifiTxVector& txVector) const override; Time GetSymbolDuration(const WifiTxVector& txVector) const override; + /** + * Start the transmission of the OFDMA part of the MU PPDU. + * + * \param ppdu the PPDU + * \param txVector the TXVECTOR + * \param ofdmaDuration the duration of the OFDMA part + */ + void StartTxOfdma(Ptr ppdu, const WifiTxVector& txVector, Time ofdmaDuration); + /** * Notify PHY state helper to switch to CCA busy state, * diff --git a/src/wifi/model/he/he-ppdu.cc b/src/wifi/model/he/he-ppdu.cc index 46dc8a6f7..37a76d361 100644 --- a/src/wifi/model/he/he-ppdu.cc +++ b/src/wifi/model/he/he-ppdu.cc @@ -303,7 +303,7 @@ HePpdu::GetTxPsdFlag() const } void -HePpdu::SetTxPsdFlag(TxPsdFlag flag) +HePpdu::SetTxPsdFlag(TxPsdFlag flag) const { NS_LOG_FUNCTION(this << flag); m_txPsdFlag = flag; diff --git a/src/wifi/model/he/he-ppdu.h b/src/wifi/model/he/he-ppdu.h index 8efefcb5a..76f1777d1 100644 --- a/src/wifi/model/he/he-ppdu.h +++ b/src/wifi/model/he/he-ppdu.h @@ -230,7 +230,7 @@ class HePpdu : public OfdmPpdu * * \see TxPsdFlag */ - void SetTxPsdFlag(TxPsdFlag flag); + void SetTxPsdFlag(TxPsdFlag flag) const; /** * Check if STA ID is in HE SIG-B Content Channel ID @@ -275,8 +275,8 @@ class HePpdu : public OfdmPpdu */ virtual void SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration); - HeSigHeader m_heSig; //!< the HE-SIG PHY header - TxPsdFlag m_txPsdFlag; //!< the transmit power spectral density flag + HeSigHeader m_heSig; //!< the HE-SIG PHY header + mutable TxPsdFlag m_txPsdFlag; //!< the transmit power spectral density flag WifiTxVector::HeMuUserInfoMap m_muUserInfos; //!< HE MU specific per-user information (to be //!< removed once HE-SIG-B headers are implemented) From d58ecd42b421571d74bfe6fad979d547b0ddd141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sat, 5 Nov 2022 15:57:19 +0100 Subject: [PATCH 041/494] wifi: Do no longer hold RU PHY index in HeRu --- src/wifi/model/eht/eht-phy.cc | 3 +-- src/wifi/model/eht/eht-ppdu.cc | 9 +++---- src/wifi/model/eht/eht-ppdu.h | 4 +-- src/wifi/model/he/he-phy.cc | 37 ++++++++++++++++------------ src/wifi/model/he/he-ppdu.cc | 7 ++---- src/wifi/model/he/he-ppdu.h | 4 +-- src/wifi/model/he/he-ru.cc | 33 ++++++------------------- src/wifi/model/he/he-ru.h | 33 +++++++++---------------- src/wifi/model/spectrum-wifi-phy.cc | 5 ++-- src/wifi/test/wifi-phy-ofdma-test.cc | 7 +----- 10 files changed, 53 insertions(+), 89 deletions(-) diff --git a/src/wifi/model/eht/eht-phy.cc b/src/wifi/model/eht/eht-phy.cc index 77be185bb..94607339e 100644 --- a/src/wifi/model/eht/eht-phy.cc +++ b/src/wifi/model/eht/eht-phy.cc @@ -133,8 +133,7 @@ EhtPhy::BuildPpdu(const WifiConstPsduMap& psdus, const WifiTxVector& txVector, T ppduDuration, m_wifiPhy->GetPhyBand(), ObtainNextUid(txVector), - HePpdu::PSD_NON_HE_PORTION, - m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)); + HePpdu::PSD_NON_HE_PORTION); } PhyEntity::PhyFieldRxStatus diff --git a/src/wifi/model/eht/eht-ppdu.cc b/src/wifi/model/eht/eht-ppdu.cc index 078f7b664..7eaa34d61 100644 --- a/src/wifi/model/eht/eht-ppdu.cc +++ b/src/wifi/model/eht/eht-ppdu.cc @@ -35,12 +35,11 @@ EhtPpdu::EhtPpdu(const WifiConstPsduMap& psdus, Time ppduDuration, WifiPhyBand band, uint64_t uid, - TxPsdFlag flag, - uint8_t p20Index) - : HePpdu(psdus, txVector, txCenterFreq, ppduDuration, band, uid, flag, p20Index) + TxPsdFlag flag) + : HePpdu(psdus, txVector, txCenterFreq, ppduDuration, band, uid, flag) { - NS_LOG_FUNCTION(this << psdus << txVector << txCenterFreq << ppduDuration << band << uid << flag - << p20Index); + NS_LOG_FUNCTION(this << psdus << txVector << txCenterFreq << ppduDuration << band << uid + << flag); } EhtPpdu::~EhtPpdu() diff --git a/src/wifi/model/eht/eht-ppdu.h b/src/wifi/model/eht/eht-ppdu.h index 656509f28..ee288157f 100644 --- a/src/wifi/model/eht/eht-ppdu.h +++ b/src/wifi/model/eht/eht-ppdu.h @@ -52,7 +52,6 @@ class EhtPpdu : public HePpdu * \param band the WifiPhyBand used for the transmission of this PPDU * \param uid the unique ID of this PPDU or of the triggering PPDU if this is an EHT TB PPDU * \param flag the flag indicating the type of Tx PSD to build - * \param p20Index the index of the primary 20 MHz channel */ EhtPpdu(const WifiConstPsduMap& psdus, const WifiTxVector& txVector, @@ -60,8 +59,7 @@ class EhtPpdu : public HePpdu Time ppduDuration, WifiPhyBand band, uint64_t uid, - TxPsdFlag flag, - uint8_t p20Index); + TxPsdFlag flag); /** * Destructor for EhtPpdu. */ diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index 49b274468..47cff923c 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -338,8 +338,7 @@ HePhy::BuildPpdu(const WifiConstPsduMap& psdus, const WifiTxVector& txVector, Ti ppduDuration, m_wifiPhy->GetPhyBand(), ObtainNextUid(txVector), - HePpdu::PSD_NON_HE_PORTION, - m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)); + HePpdu::PSD_NON_HE_PORTION); } void @@ -952,8 +951,10 @@ HePhy::GetRuBandForTx(const WifiTxVector& txVector, uint16_t staId) const HeRu::RuSpec ru = txVector.GetRu(staId); uint16_t channelWidth = txVector.GetChannelWidth(); NS_ASSERT(channelWidth <= m_wifiPhy->GetChannelWidth()); - HeRu::SubcarrierGroup group = - HeRu::GetSubcarrierGroup(channelWidth, ru.GetRuType(), ru.GetPhyIndex()); + HeRu::SubcarrierGroup group = HeRu::GetSubcarrierGroup( + channelWidth, + ru.GetRuType(), + ru.GetPhyIndex(channelWidth, m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20))); HeRu::SubcarrierRange range = std::make_pair(group.front().first, group.back().second); // for a TX spectrum, the guard bandwidth is a function of the transmission channel width // and the spectrum width equals the transmission channel width (hence bandIndex equals 0) @@ -970,8 +971,10 @@ HePhy::GetRuBandForRx(const WifiTxVector& txVector, uint16_t staId) const HeRu::RuSpec ru = txVector.GetRu(staId); uint16_t channelWidth = txVector.GetChannelWidth(); NS_ASSERT(channelWidth <= m_wifiPhy->GetChannelWidth()); - HeRu::SubcarrierGroup group = - HeRu::GetSubcarrierGroup(channelWidth, ru.GetRuType(), ru.GetPhyIndex()); + HeRu::SubcarrierGroup group = HeRu::GetSubcarrierGroup( + channelWidth, + ru.GetRuType(), + ru.GetPhyIndex(channelWidth, m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20))); HeRu::SubcarrierRange range = std::make_pair(group.front().first, group.back().second); // for an RX spectrum, the guard bandwidth is a function of the operating channel width // and the spectrum width equals the operating channel width @@ -996,11 +999,12 @@ HePhy::GetNonOfdmaBand(const WifiTxVector& txVector, uint16_t staId) const // Find the RU that encompasses the non-OFDMA part of the HE TB PPDU for the STA-ID HeRu::RuSpec nonOfdmaRu = HeRu::FindOverlappingRu(channelWidth, ru, HeRu::GetRuType(nonOfdmaWidth)); - nonOfdmaRu.SetPhyIndex(channelWidth, - m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)); - HeRu::SubcarrierGroup groupPreamble = - HeRu::GetSubcarrierGroup(channelWidth, nonOfdmaRu.GetRuType(), nonOfdmaRu.GetPhyIndex()); + HeRu::SubcarrierGroup groupPreamble = HeRu::GetSubcarrierGroup( + channelWidth, + nonOfdmaRu.GetRuType(), + nonOfdmaRu.GetPhyIndex(channelWidth, + m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20))); HeRu::SubcarrierRange range = std::make_pair(groupPreamble.front().first, groupPreamble.back().second); return m_wifiPhy->ConvertHeRuSubcarriers( @@ -1288,9 +1292,7 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW, else { const auto band = - GetRuBandForTx(ppdu->GetTxVector(), - GetStaId(hePpdu)); // Use TXVECTOR from PPDU since the one passed by - // the MAC does not have PHY index set + GetRuBandForTx(ppdu->GetTxVector(), GetStaId(hePpdu)); return WifiSpectrumValueHelper::CreateHeMuOfdmTxPowerSpectralDensity( centerFrequency, channelWidth, @@ -1355,12 +1357,15 @@ HePhy::GetCenterFrequencyForNonOfdmaPart(const WifiTxVector& txVector, uint16_t // Obtain the index of the non-OFDMA portion HeRu::RuSpec nonOfdmaRu = HeRu::FindOverlappingRu(currentWidth, ru, HeRu::GetRuType(nonOfdmaWidth)); - nonOfdmaRu.SetPhyIndex(currentWidth, - m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)); uint16_t startingFrequency = centerFrequency - (currentWidth / 2); centerFrequency = - startingFrequency + nonOfdmaWidth * (nonOfdmaRu.GetPhyIndex() - 1) + nonOfdmaWidth / 2; + startingFrequency + + nonOfdmaWidth * (nonOfdmaRu.GetPhyIndex( + currentWidth, + m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)) - + 1) + + nonOfdmaWidth / 2; } return centerFrequency; } diff --git a/src/wifi/model/he/he-ppdu.cc b/src/wifi/model/he/he-ppdu.cc index 37a76d361..21dbde3ef 100644 --- a/src/wifi/model/he/he-ppdu.cc +++ b/src/wifi/model/he/he-ppdu.cc @@ -54,8 +54,7 @@ HePpdu::HePpdu(const WifiConstPsduMap& psdus, Time ppduDuration, WifiPhyBand band, uint64_t uid, - TxPsdFlag flag, - uint8_t p20Index) + TxPsdFlag flag) : OfdmPpdu(psdus.begin()->second, txVector, txCenterFreq, @@ -72,10 +71,8 @@ HePpdu::HePpdu(const WifiConstPsduMap& psdus, m_psdus = psdus; if (txVector.IsMu()) { - for (auto heMuUserInfo : txVector.GetHeMuUserInfoMap()) + for (const auto& heMuUserInfo : txVector.GetHeMuUserInfoMap()) { - // Set RU PHY index - heMuUserInfo.second.ru.SetPhyIndex(txVector.GetChannelWidth(), p20Index); auto [it, ret] = m_muUserInfos.emplace(heMuUserInfo); NS_ABORT_MSG_IF(!ret, "STA-ID " << heMuUserInfo.first << " already present"); } diff --git a/src/wifi/model/he/he-ppdu.h b/src/wifi/model/he/he-ppdu.h index 76f1777d1..8fed46e28 100644 --- a/src/wifi/model/he/he-ppdu.h +++ b/src/wifi/model/he/he-ppdu.h @@ -187,7 +187,6 @@ class HePpdu : public OfdmPpdu * \param band the WifiPhyBand used for the transmission of this PPDU * \param uid the unique ID of this PPDU or of the triggering PPDU if this is an HE TB PPDU * \param flag the flag indicating the type of Tx PSD to build - * \param p20Index the index of the primary 20 MHz channel */ HePpdu(const WifiConstPsduMap& psdus, const WifiTxVector& txVector, @@ -195,8 +194,7 @@ class HePpdu : public OfdmPpdu Time ppduDuration, WifiPhyBand band, uint64_t uid, - TxPsdFlag flag, - uint8_t p20Index); + TxPsdFlag flag); /** * Destructor for HePpdu. */ diff --git a/src/wifi/model/he/he-ru.cc b/src/wifi/model/he/he-ru.cc index e6a61cd7f..0e1c96428 100644 --- a/src/wifi/model/he/he-ru.cc +++ b/src/wifi/model/he/he-ru.cc @@ -425,8 +425,7 @@ HeRu::RuSpec::RuSpec() HeRu::RuSpec::RuSpec(RuType ruType, std::size_t index, bool primary80MHz) : m_ruType(ruType), m_index(index), - m_primary80MHz(primary80MHz), - m_phyIndex(0) + m_primary80MHz(primary80MHz) { NS_ABORT_MSG_IF(index == 0, "Index cannot be zero"); } @@ -452,35 +451,22 @@ HeRu::RuSpec::GetPrimary80MHz() const return m_primary80MHz; } -void -HeRu::RuSpec::SetPhyIndex(uint16_t bw, uint8_t p20Index) +std::size_t +HeRu::RuSpec::GetPhyIndex(uint16_t bw, uint8_t p20Index) const { bool primary80IsLower80 = (p20Index < bw / 40); if (bw < 160 || m_ruType == HeRu::RU_2x996_TONE || (primary80IsLower80 && m_primary80MHz) || (!primary80IsLower80 && !m_primary80MHz)) { - m_phyIndex = m_index; + return m_index; } else { - m_phyIndex = m_index + GetNRus(bw, m_ruType) / 2; + return m_index + GetNRus(bw, m_ruType) / 2; } } -bool -HeRu::RuSpec::IsPhyIndexSet() const -{ - return (m_phyIndex != 0); -} - -std::size_t -HeRu::RuSpec::GetPhyIndex() const -{ - NS_ABORT_MSG_IF(m_phyIndex == 0, "RU PHY index not set"); - return m_phyIndex; -} - std::size_t HeRu::GetNRus(uint16_t bw, RuType ruType) { @@ -653,7 +639,7 @@ HeRu::DoesOverlap(uint16_t bw, RuSpec ru, const std::vector& v) } bool -HeRu::DoesOverlap(uint16_t bw, RuSpec ru, const SubcarrierGroup& toneRanges) +HeRu::DoesOverlap(uint16_t bw, RuSpec ru, const SubcarrierGroup& toneRanges, uint8_t p20Index) { for (const auto& range : toneRanges) { @@ -662,7 +648,8 @@ HeRu::DoesOverlap(uint16_t bw, RuSpec ru, const SubcarrierGroup& toneRanges) return true; } - SubcarrierGroup rangesRu = GetSubcarrierGroup(bw, ru.GetRuType(), ru.GetPhyIndex()); + SubcarrierGroup rangesRu = + GetSubcarrierGroup(bw, ru.GetRuType(), ru.GetPhyIndex(bw, p20Index)); for (auto& r : rangesRu) { if (range.second >= r.first && r.second >= range.first) @@ -748,10 +735,6 @@ operator<<(std::ostream& os, const HeRu::RuSpec& ru) { os << "RU{" << ru.GetRuType() << "/" << ru.GetIndex() << "/" << (ru.GetPrimary80MHz() ? "primary80MHz" : "secondary80MHz"); - if (ru.IsPhyIndexSet()) - { - os << "[" << ru.GetPhyIndex() << "]"; - } os << "}"; return os; } diff --git a/src/wifi/model/he/he-ru.h b/src/wifi/model/he/he-ru.h index a7e1ac5dd..36be62e08 100644 --- a/src/wifi/model/he/he-ru.h +++ b/src/wifi/model/he/he-ru.h @@ -97,24 +97,13 @@ class HeRu */ bool GetPrimary80MHz() const; /** - * Set the RU PHY index + * Get the RU PHY index * * \param bw the width of the channel of which the RU is part (in MHz) * \param p20Index the index of the primary20 channel - */ - void SetPhyIndex(uint16_t bw, uint8_t p20Index); - /** - * Return true if the RU PHY index has been set, false otherwise - * - * \return true if the RU PHY index has been set, false otherwise - */ - bool IsPhyIndexSet() const; - /** - * Get the RU PHY index - * * \return the RU PHY index */ - std::size_t GetPhyIndex() const; + std::size_t GetPhyIndex(uint16_t bw, uint8_t p20Index) const; /** * Compare this RU to the given RU. @@ -132,14 +121,10 @@ class HeRu bool operator!=(const RuSpec& other) const; private: - RuType m_ruType; //!< RU type - std::size_t m_index; /**< RU index (starting at 1) as defined by Tables 27-7 - to 27-9 of 802.11ax D8.0 */ - bool m_primary80MHz; //!< true if the RU is allocated in the primary 80MHz channel - std::size_t m_phyIndex; /**< the RU PHY index, which is used to indicate whether an - RU is located in the lower half or the higher half of - a 160MHz channel. For channel widths less than 160MHz, - the RU PHY index equals the RU index */ + RuType m_ruType; //!< RU type + std::size_t m_index; /**< RU index (starting at 1) as defined by Tables 27-7 + to 27-9 of 802.11ax D8.0 */ + bool m_primary80MHz; //!< true if the RU is allocated in the primary 80MHz channel }; /** @@ -208,9 +193,13 @@ class HeRu * \param bw the bandwidth (MHz) of the HE PPDU (20, 40, 80, 160) * \param ru the given RU allocation * \param toneRanges the given set of tone ranges + * \param p20Index the index of the primary20 channel * \return true if the given RU overlaps with the given set of tone ranges. */ - static bool DoesOverlap(uint16_t bw, RuSpec ru, const SubcarrierGroup& toneRanges); + static bool DoesOverlap(uint16_t bw, + RuSpec ru, + const SubcarrierGroup& toneRanges, + uint8_t p20Index); /** * Find the RU allocation of the given RU type overlapping the given diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index da51c1b52..1988e21af 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -210,8 +210,9 @@ SpectrumWifiPhy::UpdateInterferenceHelperBands() (primary80IsLower80 && phyIndex <= nRus / 2) || (!primary80IsLower80 && phyIndex > nRus / 2)); HeRu::RuSpec ru(ruType, index, primary80); - ru.SetPhyIndex(bw, GetOperatingChannel().GetPrimaryChannelIndex(20)); - NS_ABORT_IF(ru.GetPhyIndex() != phyIndex); + NS_ABORT_IF(ru.GetPhyIndex(bw, + GetOperatingChannel().GetPrimaryChannelIndex( + 20)) != phyIndex); m_ruBands[channelWidth].insert({band, ru}); } } diff --git a/src/wifi/test/wifi-phy-ofdma-test.cc b/src/wifi/test/wifi-phy-ofdma-test.cc index e0a95a21f..f6c8f0576 100644 --- a/src/wifi/test/wifi-phy-ofdma-test.cc +++ b/src/wifi/test/wifi-phy-ofdma-test.cc @@ -2408,7 +2408,6 @@ TestMultipleHeTbPreambles::RxHeTbPpdu(uint64_t uid, false); HeRu::RuSpec ru(HeRu::RU_106_TONE, staId, false); - ru.SetPhyIndex(DEFAULT_CHANNEL_WIDTH, 0); txVector.SetRu(ru, staId); txVector.SetMode(HePhy::GetHeMcs7(), staId); txVector.SetNss(1, staId); @@ -2432,8 +2431,7 @@ TestMultipleHeTbPreambles::RxHeTbPpdu(uint64_t uid, ppduDuration, WIFI_PHY_BAND_5GHZ, uid, - HePpdu::PSD_NON_HE_PORTION, - 0); + HePpdu::PSD_NON_HE_PORTION); // Send non-OFDMA part Time nonOfdmaDuration = m_phy->GetHePhy()->CalculateNonOfdmaDurationForHeTb(txVector); @@ -3316,7 +3314,6 @@ TestUlOfdmaPhyTransmission::GetTxVectorForHeTbPpdu(uint16_t txStaId, index = 1; } HeRu::RuSpec ru(ruType, index, primary80MHz); - ru.SetPhyIndex(m_channelWidth, 0); txVector.SetRu(ru, txStaId); txVector.SetMode(HePhy::GetHeMcs7(), txStaId); txVector.SetNss(1, txStaId); @@ -3371,13 +3368,11 @@ TestUlOfdmaPhyTransmission::SetTrigVector(uint8_t bssColor, TrigVectorInfo error uint16_t aid2 = (error == AID ? 4 : 2); HeRu::RuSpec ru1(ruType, 1, true); - ru1.SetPhyIndex(channelWidth, 0); txVector.SetRu(ru1, aid1); txVector.SetMode((error == MCS ? HePhy::GetHeMcs5() : HePhy::GetHeMcs7()), aid1); txVector.SetNss(1, aid1); HeRu::RuSpec ru2(ruType, (channelWidth == 160 ? 1 : 2), (channelWidth == 160 ? false : true)); - ru2.SetPhyIndex(channelWidth, 0); txVector.SetRu(ru2, aid2); txVector.SetMode((error == MCS ? HePhy::GetHeMcs5() : HePhy::GetHeMcs7()), aid2); txVector.SetNss(1, aid2); From 39e045573551a20c1de85a72d5208fccbf057347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Mon, 7 Nov 2022 21:36:25 +0100 Subject: [PATCH 042/494] wifi: Prepare OFDMA TX power power and PSD before scheduling HE portion of MU PPDUs --- src/wifi/model/he/he-phy.cc | 64 ++++++++++++++++++++++++++++-------- src/wifi/model/he/he-phy.h | 26 +++++++++++++-- src/wifi/model/phy-entity.cc | 20 +++++------ src/wifi/model/phy-entity.h | 6 +++- 4 files changed, 90 insertions(+), 26 deletions(-) diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index 47cff923c..d9326459d 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -22,7 +22,6 @@ #include "he-phy.h" #include "he-configuration.h" -#include "he-ppdu.h" #include "obss-pd-algorithm.h" #include "ns3/ap-wifi-mac.h" @@ -1251,10 +1250,22 @@ Ptr HePhy::GetTxPowerSpectralDensity(double txPowerW, Ptr ppdu, const WifiTxVector& txVector) const +{ + auto hePpdu = DynamicCast(ppdu); + NS_ASSERT(hePpdu); + HePpdu::TxPsdFlag flag = hePpdu->GetTxPsdFlag(); + return GetTxPowerSpectralDensity(txPowerW, ppdu, txVector, flag); +} + +Ptr +HePhy::GetTxPowerSpectralDensity(double txPowerW, + Ptr ppdu, + const WifiTxVector& txVector, + HePpdu::TxPsdFlag flag) const { uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector); uint16_t channelWidth = txVector.GetChannelWidth(); - NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW); + NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW << txVector); const auto& puncturedSubchannels = txVector.GetInactiveSubchannels(); if (!puncturedSubchannels.empty()) { @@ -1265,9 +1276,6 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW, NS_ASSERT( !puncturedSubchannels.at(p20IndexInBitmap)); // the primary channel cannot be punctured } - auto hePpdu = DynamicCast(ppdu); - NS_ASSERT(hePpdu); - HePpdu::TxPsdFlag flag = hePpdu->GetTxPsdFlag(); const auto& txMaskRejectionParams = GetTxMaskRejectionParams(); switch (ppdu->GetType()) { @@ -1275,7 +1283,7 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW, if (flag == HePpdu::PSD_NON_HE_PORTION) { // non-OFDMA portion is sent only on the 20 MHz channels covering the RU - const uint16_t staId = GetStaId(hePpdu); + const uint16_t staId = GetStaId(ppdu); centerFrequency = GetCenterFrequencyForNonOfdmaPart(txVector, staId); const uint16_t ruWidth = HeRu::GetBandwidth(txVector.GetRu(staId).GetRuType()); channelWidth = (ruWidth < 20) ? 20 : ruWidth; @@ -1291,8 +1299,7 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW, } else { - const auto band = - GetRuBandForTx(ppdu->GetTxVector(), GetStaId(hePpdu)); + const auto band = GetRuBandForTx(txVector, GetStaId(ppdu)); return WifiSpectrumValueHelper::CreateHeMuOfdmTxPowerSpectralDensity( centerFrequency, channelWidth, @@ -1376,19 +1383,45 @@ HePhy::StartTx(Ptr ppdu, const WifiTxVector& txVector) NS_LOG_FUNCTION(this << ppdu); if (ppdu->GetType() == WIFI_PPDU_TYPE_UL_MU || ppdu->GetType() == WIFI_PPDU_TYPE_DL_MU) { + auto nonOfdmaTxPowerDbm = + m_wifiPhy->GetTxPowerForTransmission(ppdu) + m_wifiPhy->GetTxGain(); + + // temporarily set WifiPpdu flag to PSD_HE_PORTION for correct calculation of the OFDMA TX + // power + auto hePpdu = DynamicCast(ppdu); + NS_ASSERT(hePpdu); + hePpdu->SetTxPsdFlag(HePpdu::PSD_HE_PORTION); + auto ofdmaTxPowerDbm = m_wifiPhy->GetTxPowerForTransmission(ppdu) + m_wifiPhy->GetTxGain(); + hePpdu->SetTxPsdFlag(HePpdu::PSD_NON_HE_PORTION); + // non-OFDMA part - Time nonOfdmaDuration = ppdu->GetType() == WIFI_PPDU_TYPE_UL_MU + auto nonOfdmaDuration = ppdu->GetType() == WIFI_PPDU_TYPE_UL_MU ? CalculateNonOfdmaDurationForHeTb(txVector) : CalculateNonOfdmaDurationForHeMu(txVector); - Transmit(nonOfdmaDuration, ppdu, txVector, "non-OFDMA transmission"); + auto nonOfdmaTxPowerSpectrum = GetTxPowerSpectralDensity(DbmToW(nonOfdmaTxPowerDbm), + ppdu, + txVector, + HePpdu::PSD_NON_HE_PORTION); + Transmit(nonOfdmaDuration, + ppdu, + txVector, + nonOfdmaTxPowerDbm, + nonOfdmaTxPowerSpectrum, + "non-OFDMA transmission"); // OFDMA part - Time ofdmaDuration = ppdu->GetTxDuration() - nonOfdmaDuration; + auto ofdmaDuration = ppdu->GetTxDuration() - nonOfdmaDuration; + auto ofdmaTxPowerSpectrum = GetTxPowerSpectralDensity(DbmToW(ofdmaTxPowerDbm), + ppdu, + txVector, + HePpdu::PSD_HE_PORTION); Simulator::Schedule(nonOfdmaDuration, &HePhy::StartTxOfdma, this, ppdu, txVector, + ofdmaTxPowerDbm, + ofdmaTxPowerSpectrum, ofdmaDuration); } else @@ -1398,12 +1431,17 @@ HePhy::StartTx(Ptr ppdu, const WifiTxVector& txVector) } void -HePhy::StartTxOfdma(Ptr ppdu, const WifiTxVector& txVector, Time ofdmaDuration) +HePhy::StartTxOfdma(Ptr ppdu, + const WifiTxVector& txVector, + double txPowerDbm, + Ptr txPowerSpectrum, + Time ofdmaDuration) { + NS_LOG_FUNCTION(this << ppdu << txPowerDbm << ofdmaDuration); auto hePpdu = DynamicCast(ppdu); NS_ASSERT(hePpdu); hePpdu->SetTxPsdFlag(HePpdu::PSD_HE_PORTION); - Transmit(ofdmaDuration, ppdu, txVector, "OFDMA transmission"); + Transmit(ofdmaDuration, ppdu, txVector, txPowerDbm, txPowerSpectrum, "OFDMA transmission"); } Time diff --git a/src/wifi/model/he/he-phy.h b/src/wifi/model/he/he-phy.h index 5c38bc927..07ebcc978 100644 --- a/src/wifi/model/he/he-phy.h +++ b/src/wifi/model/he/he-phy.h @@ -22,6 +22,8 @@ #ifndef HE_PHY_H #define HE_PHY_H +#include "he-ppdu.h" + #include "ns3/callback.h" #include "ns3/vht-phy.h" #include "ns3/wifi-phy-band.h" @@ -527,14 +529,34 @@ class HePhy : public VhtPhy uint8_t GetNumberBccEncoders(const WifiTxVector& txVector) const override; Time GetSymbolDuration(const WifiTxVector& txVector) const override; + /** + * This is a helper function to create the TX PSD of the non-HE and HE portions. + * + * \param txPowerW power in W to spread across the bands + * \param ppdu the PPDU that will be transmitted + * \param txVector the transmission parameters + * \param flag flag indicating whether the PSD is for non-HE portion or HE portion + * \return Pointer to SpectrumValue + */ + Ptr GetTxPowerSpectralDensity(double txPowerW, + Ptr ppdu, + const WifiTxVector& txVector, + HePpdu::TxPsdFlag flag) const; + /** * Start the transmission of the OFDMA part of the MU PPDU. * * \param ppdu the PPDU - * \param txVector the TXVECTOR + * \param txVector the TXVECTOR used for the transmission of the PPDU + * \param txPowerDbm the total TX power in dBm + * \param txPowerSpectrum the TX PSD * \param ofdmaDuration the duration of the OFDMA part */ - void StartTxOfdma(Ptr ppdu, const WifiTxVector& txVector, Time ofdmaDuration); + void StartTxOfdma(Ptr ppdu, + const WifiTxVector& txVector, + double txPowerDbm, + Ptr txPowerSpectrum, + Time ofdmaDuration); /** * Notify PHY state helper to switch to CCA busy state, diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index 3cde20667..6aae2c6ee 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -1282,26 +1282,26 @@ void PhyEntity::StartTx(Ptr ppdu, const WifiTxVector& txVector) { NS_LOG_FUNCTION(this << ppdu << txVector); - Transmit(ppdu->GetTxDuration(), ppdu, txVector, "transmission"); + auto txPowerDbm = m_wifiPhy->GetTxPowerForTransmission(ppdu) + m_wifiPhy->GetTxGain(); + auto txPowerSpectrum = GetTxPowerSpectralDensity(DbmToW(txPowerDbm), ppdu, txVector); + Transmit(ppdu->GetTxDuration(), ppdu, txVector, txPowerDbm, txPowerSpectrum, "transmission"); } void PhyEntity::Transmit(Time txDuration, Ptr ppdu, const WifiTxVector& txVector, - std::string type) + double txPowerDbm, + Ptr txPowerSpectrum, + const std::string& type) { - NS_LOG_FUNCTION(this << txDuration << ppdu << txVector << type); - double txPowerWatts = - DbmToW(m_wifiPhy->GetTxPowerForTransmission(ppdu) + m_wifiPhy->GetTxGain()); - NS_LOG_DEBUG("Start " << type << ": signal power before antenna gain=" << WToDbm(txPowerWatts) - << "dBm"); - Ptr txPowerSpectrum = GetTxPowerSpectralDensity(txPowerWatts, ppdu, txVector); - Ptr txParams = Create(); + NS_LOG_FUNCTION(this << txDuration << ppdu << txVector << txPowerDbm << type); + NS_LOG_DEBUG("Start " << type << ": signal power before antenna gain=" << txPowerDbm << "dBm"); + auto txParams = Create(); txParams->duration = txDuration; txParams->psd = txPowerSpectrum; txParams->ppdu = ppdu; - NS_LOG_DEBUG("Starting " << type << " with power " << WToDbm(txPowerWatts) << " dBm on channel " + NS_LOG_DEBUG("Starting " << type << " with power " << txPowerDbm << " dBm on channel " << +m_wifiPhy->GetChannelNumber() << " for " << txParams->duration.As(Time::MS)); NS_LOG_DEBUG("Starting " << type << " with integrated spectrum power " diff --git a/src/wifi/model/phy-entity.h b/src/wifi/model/phy-entity.h index 4ee8979f5..9031329de 100644 --- a/src/wifi/model/phy-entity.h +++ b/src/wifi/model/phy-entity.h @@ -488,12 +488,16 @@ class PhyEntity : public SimpleRefCount * \param txDuration the duration of the transmission * \param ppdu the PPDU to send * \param txVector the TXVECTOR used for the transmission of the PPDU + * \param txPowerDbm the total TX power in dBm + * \param txPowerSpectrum the TX PSD * \param type the type of transmission (for logging) */ void Transmit(Time txDuration, Ptr ppdu, const WifiTxVector& txVector, - std::string type); + double txPowerDbm, + Ptr txPowerSpectrum, + const std::string& type); /** * \param psduMap the PSDU(s) to transmit indexed by STA-ID From 558587e166cb1b6536a462863b14ff5aaf5eae94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Mon, 7 Nov 2022 23:28:58 +0100 Subject: [PATCH 043/494] wifi: Reconstruct TXVECTOR from received PPDU only once --- src/wifi/model/spectrum-wifi-phy.cc | 20 ++++++++------------ src/wifi/model/wifi-phy.cc | 1 + src/wifi/model/wifi-ppdu.cc | 26 +++++++++++++++++++------- src/wifi/model/wifi-ppdu.h | 14 ++++++++++++-- src/wifi/test/wifi-phy-ofdma-test.cc | 1 + 5 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index 1988e21af..46cb090b0 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -386,14 +386,13 @@ SpectrumWifiPhy::StartRx(Ptr rxParams) // Do no further processing if signal is too weak // Current implementation assumes constant RX power over the PPDU duration // Compare received TX power per MHz to normalized RX sensitivity - uint16_t txWidth = wifiRxParams->ppdu->GetTransmissionChannelWidth(); + const auto& ppdu = wifiRxParams->ppdu; + const auto& txVector = ppdu->GetTxVector(); + uint16_t txWidth = ppdu->GetTransmissionChannelWidth(); if (totalRxPowerW < DbmToW(GetRxSensitivity()) * (txWidth / 20.0)) { NS_LOG_INFO("Received signal too weak to process: " << WToDbm(totalRxPowerW) << " dBm"); - m_interference->Add(wifiRxParams->ppdu, - wifiRxParams->ppdu->GetTxVector(), - rxDuration, - rxPowerW); + m_interference->Add(ppdu, txVector, rxDuration, rxPowerW); SwitchMaybeToCcaBusy(nullptr); return; } @@ -409,20 +408,17 @@ SpectrumWifiPhy::StartRx(Ptr rxParams) uint16_t p20MaxFreq = GetOperatingChannel().GetPrimaryChannelCenterFrequency(width) + width / 2; - if (!wifiRxParams->ppdu->CanBeReceived(p20MinFreq, p20MaxFreq)) + if (!ppdu->CanBeReceived(p20MinFreq, p20MaxFreq)) { NS_LOG_INFO("Cannot receive the PPDU, consider it as interference"); - m_interference->Add(wifiRxParams->ppdu, - wifiRxParams->ppdu->GetTxVector(), - rxDuration, - rxPowerW); - SwitchMaybeToCcaBusy(wifiRxParams->ppdu); + m_interference->Add(ppdu, txVector, rxDuration, rxPowerW); + SwitchMaybeToCcaBusy(ppdu); return; } } NS_LOG_INFO("Received Wi-Fi signal"); - StartReceivePreamble(wifiRxParams->ppdu, rxPowerW, rxDuration); + StartReceivePreamble(ppdu, rxPowerW, rxDuration); } Ptr diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 1baf05d30..dd185160c 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -1728,6 +1728,7 @@ WifiPhy::Send(WifiConstPsduMap psdus, const WifiTxVector& txVector) Simulator::Schedule(txDuration, &WifiPhy::NotifyTxEnd, this, psdus); // TODO: fix for MU StartTx(ppdu, txVector); + ppdu->ResetTxVector(); m_channelAccessRequested = false; m_powerRestricted = false; diff --git a/src/wifi/model/wifi-ppdu.cc b/src/wifi/model/wifi-ppdu.cc index dd71386ca..9dbfe15d5 100644 --- a/src/wifi/model/wifi-ppdu.cc +++ b/src/wifi/model/wifi-ppdu.cc @@ -38,7 +38,8 @@ WifiPpdu::WifiPpdu(Ptr psdu, m_txCenterFreq(txCenterFreq), m_uid(uid), m_truncatedTx(false), - m_txPowerLevel(txVector.GetTxPowerLevel()) + m_txPowerLevel(txVector.GetTxPowerLevel()), + m_txVector(txVector) { NS_LOG_FUNCTION(this << *psdu << txVector << txCenterFreq << uid); m_psdus.insert(std::make_pair(SU_STA_ID, psdu)); @@ -55,7 +56,8 @@ WifiPpdu::WifiPpdu(const WifiConstPsduMap& psdus, m_uid(uid), m_truncatedTx(false), m_txPowerLevel(txVector.GetTxPowerLevel()), - m_txAntennas(txVector.GetNTx()) + m_txAntennas(txVector.GetNTx()), + m_txVector(txVector) { NS_LOG_FUNCTION(this << psdus << txVector << txCenterFreq << uid); m_psdus = psdus; @@ -70,13 +72,16 @@ WifiPpdu::~WifiPpdu() m_psdus.clear(); } -WifiTxVector +const WifiTxVector& WifiPpdu::GetTxVector() const { - WifiTxVector txVector = DoGetTxVector(); - txVector.SetTxPowerLevel(m_txPowerLevel); - txVector.SetNTx(m_txAntennas); - return txVector; + if (!m_txVector.has_value()) + { + m_txVector = DoGetTxVector(); + m_txVector->SetTxPowerLevel(m_txPowerLevel); + m_txVector->SetNTx(m_txAntennas); + } + return m_txVector.value(); } WifiTxVector @@ -87,6 +92,13 @@ WifiPpdu::DoGetTxVector() const return WifiTxVector(); // should be overloaded } +void +WifiPpdu::ResetTxVector() +{ + NS_LOG_FUNCTION(this); + m_txVector.reset(); +} + Ptr WifiPpdu::GetPsdu() const { diff --git a/src/wifi/model/wifi-ppdu.h b/src/wifi/model/wifi-ppdu.h index 1f83026e1..fd2c81093 100644 --- a/src/wifi/model/wifi-ppdu.h +++ b/src/wifi/model/wifi-ppdu.h @@ -25,6 +25,7 @@ #include "ns3/nstime.h" #include +#include #include /** @@ -87,7 +88,12 @@ class WifiPpdu : public SimpleRefCount * * \return the TXVECTOR of the PPDU. */ - WifiTxVector GetTxVector() const; + const WifiTxVector& GetTxVector() const; + + /** + * Reset the TXVECTOR. + */ + void ResetTxVector(); /** * Get the payload of the PPDU. @@ -209,7 +215,11 @@ class WifiPpdu : public SimpleRefCount uint8_t m_txPowerLevel; //!< the transmission power level (used only for TX and initializing the //!< returned WifiTxVector) uint8_t m_txAntennas; //!< the number of antennas used to transmit this PPDU -}; // class WifiPpdu + + mutable std::optional + m_txVector; //!< the TXVECTOR at TX PHY or the reconstructed TXVECTOR at RX PHY (or + //!< std::nullopt if TXVECTOR has not been reconstructed yet) +}; // class WifiPpdu /** * \brief Stream insertion operator. diff --git a/src/wifi/test/wifi-phy-ofdma-test.cc b/src/wifi/test/wifi-phy-ofdma-test.cc index f6c8f0576..a409d8893 100644 --- a/src/wifi/test/wifi-phy-ofdma-test.cc +++ b/src/wifi/test/wifi-phy-ofdma-test.cc @@ -2457,6 +2457,7 @@ TestMultipleHeTbPreambles::RxHeTbPpdu(uint64_t uid, m_trigVector.SetLength(length); auto hePhy = DynamicCast(m_phy->GetPhyEntity(WIFI_MOD_CLASS_HE)); hePhy->SetTrigVector(m_trigVector, ppduDuration); + ppdu->ResetTxVector(); m_phy->StartRx(rxParams); // Schedule OFDMA part From 9ac4410af2c4ac250a8da08c5474913a4d6072a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sun, 6 Nov 2022 17:35:40 +0100 Subject: [PATCH 044/494] wifi: WifiTxVector does no longer need to be passed together with WifiPpdu --- src/wifi/model/he/he-phy.cc | 38 +++++++++++----------------- src/wifi/model/he/he-phy.h | 9 ++----- src/wifi/model/ht/ht-phy.cc | 5 ++-- src/wifi/model/ht/ht-phy.h | 3 +-- src/wifi/model/non-ht/dsss-phy.cc | 5 ++-- src/wifi/model/non-ht/dsss-phy.h | 3 +-- src/wifi/model/non-ht/ofdm-phy.cc | 5 ++-- src/wifi/model/non-ht/ofdm-phy.h | 3 +-- src/wifi/model/phy-entity.cc | 12 ++++----- src/wifi/model/phy-entity.h | 9 ++----- src/wifi/model/spectrum-wifi-phy.cc | 4 +-- src/wifi/model/spectrum-wifi-phy.h | 2 +- src/wifi/model/wifi-phy.cc | 4 +-- src/wifi/model/wifi-phy.h | 3 +-- src/wifi/model/yans-wifi-phy.cc | 4 +-- src/wifi/model/yans-wifi-phy.h | 2 +- src/wifi/test/wifi-phy-ofdma-test.cc | 11 +++----- 17 files changed, 46 insertions(+), 76 deletions(-) diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index d9326459d..f41257cd4 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -346,7 +346,7 @@ HePhy::StartReceivePreamble(Ptr ppdu, Time rxDuration) { NS_LOG_FUNCTION(this << ppdu << rxDuration); - const WifiTxVector& txVector = ppdu->GetTxVector(); + const auto& txVector = ppdu->GetTxVector(); auto hePpdu = DynamicCast(ppdu); NS_ASSERT(hePpdu); HePpdu::TxPsdFlag psdFlag = hePpdu->GetTxPsdFlag(); @@ -447,7 +447,7 @@ HePhy::DoGetEvent(Ptr ppdu, RxPowerWattPerChannelBand& rxPowersW if (ppdu->GetType() == WIFI_PPDU_TYPE_UL_MU) { auto uidPreamblePair = std::make_pair(ppdu->GetUid(), ppdu->GetPreamble()); - const WifiTxVector& txVector = ppdu->GetTxVector(); + const auto& txVector = ppdu->GetTxVector(); Time rxDuration = CalculateNonOfdmaDurationForHeTb( txVector); // the OFDMA part of the transmission will be added later on const auto& currentPreambleEvents = GetCurrentPreambleEvents(); @@ -505,7 +505,7 @@ HePhy::DoGetEvent(Ptr ppdu, RxPowerWattPerChannelBand& rxPowersW } else if (ppdu->GetType() == WIFI_PPDU_TYPE_DL_MU) { - const WifiTxVector& txVector = ppdu->GetTxVector(); + const auto& txVector = ppdu->GetTxVector(); Time rxDuration = CalculateNonOfdmaDurationForHeMu( txVector); // the OFDMA part of the transmission will be added later on event = CreateInterferenceEvent(ppdu, ppdu->GetTxVector(), rxDuration, rxPowersW); @@ -747,7 +747,7 @@ Time HePhy::DoStartReceivePayload(Ptr event) { NS_LOG_FUNCTION(this << *event); - const WifiTxVector& txVector = event->GetTxVector(); + const auto& txVector = event->GetTxVector(); if (!txVector.IsMu()) { @@ -1247,22 +1247,20 @@ HePhy::ObtainNextUid(const WifiTxVector& txVector) } Ptr -HePhy::GetTxPowerSpectralDensity(double txPowerW, - Ptr ppdu, - const WifiTxVector& txVector) const +HePhy::GetTxPowerSpectralDensity(double txPowerW, Ptr ppdu) const { auto hePpdu = DynamicCast(ppdu); NS_ASSERT(hePpdu); HePpdu::TxPsdFlag flag = hePpdu->GetTxPsdFlag(); - return GetTxPowerSpectralDensity(txPowerW, ppdu, txVector, flag); + return GetTxPowerSpectralDensity(txPowerW, ppdu, flag); } Ptr HePhy::GetTxPowerSpectralDensity(double txPowerW, Ptr ppdu, - const WifiTxVector& txVector, HePpdu::TxPsdFlag flag) const { + const auto& txVector = ppdu->GetTxVector(); uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector); uint16_t channelWidth = txVector.GetChannelWidth(); NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW << txVector); @@ -1378,7 +1376,7 @@ HePhy::GetCenterFrequencyForNonOfdmaPart(const WifiTxVector& txVector, uint16_t } void -HePhy::StartTx(Ptr ppdu, const WifiTxVector& txVector) +HePhy::StartTx(Ptr ppdu) { NS_LOG_FUNCTION(this << ppdu); if (ppdu->GetType() == WIFI_PPDU_TYPE_UL_MU || ppdu->GetType() == WIFI_PPDU_TYPE_DL_MU) @@ -1395,44 +1393,38 @@ HePhy::StartTx(Ptr ppdu, const WifiTxVector& txVector) hePpdu->SetTxPsdFlag(HePpdu::PSD_NON_HE_PORTION); // non-OFDMA part + const auto& txVector = ppdu->GetTxVector(); auto nonOfdmaDuration = ppdu->GetType() == WIFI_PPDU_TYPE_UL_MU ? CalculateNonOfdmaDurationForHeTb(txVector) : CalculateNonOfdmaDurationForHeMu(txVector); - auto nonOfdmaTxPowerSpectrum = GetTxPowerSpectralDensity(DbmToW(nonOfdmaTxPowerDbm), - ppdu, - txVector, - HePpdu::PSD_NON_HE_PORTION); + auto nonOfdmaTxPowerSpectrum = + GetTxPowerSpectralDensity(DbmToW(nonOfdmaTxPowerDbm), ppdu, HePpdu::PSD_NON_HE_PORTION); Transmit(nonOfdmaDuration, ppdu, - txVector, nonOfdmaTxPowerDbm, nonOfdmaTxPowerSpectrum, "non-OFDMA transmission"); // OFDMA part auto ofdmaDuration = ppdu->GetTxDuration() - nonOfdmaDuration; - auto ofdmaTxPowerSpectrum = GetTxPowerSpectralDensity(DbmToW(ofdmaTxPowerDbm), - ppdu, - txVector, - HePpdu::PSD_HE_PORTION); + auto ofdmaTxPowerSpectrum = + GetTxPowerSpectralDensity(DbmToW(ofdmaTxPowerDbm), ppdu, HePpdu::PSD_HE_PORTION); Simulator::Schedule(nonOfdmaDuration, &HePhy::StartTxOfdma, this, ppdu, - txVector, ofdmaTxPowerDbm, ofdmaTxPowerSpectrum, ofdmaDuration); } else { - PhyEntity::StartTx(ppdu, txVector); + PhyEntity::StartTx(ppdu); } } void HePhy::StartTxOfdma(Ptr ppdu, - const WifiTxVector& txVector, double txPowerDbm, Ptr txPowerSpectrum, Time ofdmaDuration) @@ -1441,7 +1433,7 @@ HePhy::StartTxOfdma(Ptr ppdu, auto hePpdu = DynamicCast(ppdu); NS_ASSERT(hePpdu); hePpdu->SetTxPsdFlag(HePpdu::PSD_HE_PORTION); - Transmit(ofdmaDuration, ppdu, txVector, txPowerDbm, txPowerSpectrum, "OFDMA transmission"); + Transmit(ofdmaDuration, ppdu, txPowerDbm, txPowerSpectrum, "OFDMA transmission"); } Time diff --git a/src/wifi/model/he/he-phy.h b/src/wifi/model/he/he-phy.h index 07ebcc978..97355bf04 100644 --- a/src/wifi/model/he/he-phy.h +++ b/src/wifi/model/he/he-phy.h @@ -104,7 +104,7 @@ class HePhy : public VhtPhy void CancelAllEvents() override; uint16_t GetStaId(const Ptr ppdu) const override; uint16_t GetMeasurementChannelWidth(const Ptr ppdu) const override; - void StartTx(Ptr ppdu, const WifiTxVector& txVector) override; + void StartTx(Ptr ppdu) override; Time CalculateTxDuration(WifiConstPsduMap psduMap, const WifiTxVector& txVector, WifiPhyBand band) const override; @@ -448,8 +448,7 @@ class HePhy : public VhtPhy void DoAbortCurrentReception(WifiPhyRxfailureReason reason) override; uint64_t ObtainNextUid(const WifiTxVector& txVector) override; Ptr GetTxPowerSpectralDensity(double txPowerW, - Ptr ppdu, - const WifiTxVector& txVector) const override; + Ptr ppdu) const override; uint32_t GetMaxPsduSize() const override; WifiConstPsduMap GetWifiConstPsduMap(Ptr psdu, const WifiTxVector& txVector) const override; @@ -534,26 +533,22 @@ class HePhy : public VhtPhy * * \param txPowerW power in W to spread across the bands * \param ppdu the PPDU that will be transmitted - * \param txVector the transmission parameters * \param flag flag indicating whether the PSD is for non-HE portion or HE portion * \return Pointer to SpectrumValue */ Ptr GetTxPowerSpectralDensity(double txPowerW, Ptr ppdu, - const WifiTxVector& txVector, HePpdu::TxPsdFlag flag) const; /** * Start the transmission of the OFDMA part of the MU PPDU. * * \param ppdu the PPDU - * \param txVector the TXVECTOR used for the transmission of the PPDU * \param txPowerDbm the total TX power in dBm * \param txPowerSpectrum the TX PSD * \param ofdmaDuration the duration of the OFDMA part */ void StartTxOfdma(Ptr ppdu, - const WifiTxVector& txVector, double txPowerDbm, Ptr txPowerSpectrum, Time ofdmaDuration); diff --git a/src/wifi/model/ht/ht-phy.cc b/src/wifi/model/ht/ht-phy.cc index 50531b98f..f28bcfa73 100644 --- a/src/wifi/model/ht/ht-phy.cc +++ b/src/wifi/model/ht/ht-phy.cc @@ -459,10 +459,9 @@ HtPhy::IsConfigSupported(Ptr ppdu) const } Ptr -HtPhy::GetTxPowerSpectralDensity(double txPowerW, - Ptr /* ppdu */, - const WifiTxVector& txVector) const +HtPhy::GetTxPowerSpectralDensity(double txPowerW, Ptr ppdu) const { + const auto& txVector = ppdu->GetTxVector(); uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector); uint16_t channelWidth = txVector.GetChannelWidth(); NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW); diff --git a/src/wifi/model/ht/ht-phy.h b/src/wifi/model/ht/ht-phy.h index 5047536a9..948b6df9c 100644 --- a/src/wifi/model/ht/ht-phy.h +++ b/src/wifi/model/ht/ht-phy.h @@ -464,8 +464,7 @@ class HtPhy : public OfdmPhy bool IsAllConfigSupported(WifiPpduField field, Ptr ppdu) const override; bool IsConfigSupported(Ptr ppdu) const override; Ptr GetTxPowerSpectralDensity(double txPowerW, - Ptr ppdu, - const WifiTxVector& txVector) const override; + Ptr ppdu) const override; uint32_t GetMaxPsduSize() const override; CcaIndication GetCcaIndication(const Ptr ppdu) override; diff --git a/src/wifi/model/non-ht/dsss-phy.cc b/src/wifi/model/non-ht/dsss-phy.cc index a58363dd5..de71465e4 100644 --- a/src/wifi/model/non-ht/dsss-phy.cc +++ b/src/wifi/model/non-ht/dsss-phy.cc @@ -265,10 +265,9 @@ DsssPhy::GetMeasurementChannelWidth(const Ptr ppdu) const } Ptr -DsssPhy::GetTxPowerSpectralDensity(double txPowerW, - Ptr /* ppdu */, - const WifiTxVector& txVector) const +DsssPhy::GetTxPowerSpectralDensity(double txPowerW, Ptr ppdu) const { + const auto& txVector = ppdu->GetTxVector(); uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector); uint16_t channelWidth = txVector.GetChannelWidth(); NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW); diff --git a/src/wifi/model/non-ht/dsss-phy.h b/src/wifi/model/non-ht/dsss-phy.h index a2cceed12..39ee45724 100644 --- a/src/wifi/model/non-ht/dsss-phy.h +++ b/src/wifi/model/non-ht/dsss-phy.h @@ -161,8 +161,7 @@ class DsssPhy : public PhyEntity private: PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr event) override; Ptr GetTxPowerSpectralDensity(double txPowerW, - Ptr ppdu, - const WifiTxVector& txVector) const override; + Ptr ppdu) const override; uint16_t GetRxChannelWidth(const WifiTxVector& txVector) const override; uint16_t GetMeasurementChannelWidth(const Ptr ppdu) const override; diff --git a/src/wifi/model/non-ht/ofdm-phy.cc b/src/wifi/model/non-ht/ofdm-phy.cc index a041ab757..501183a05 100644 --- a/src/wifi/model/non-ht/ofdm-phy.cc +++ b/src/wifi/model/non-ht/ofdm-phy.cc @@ -361,10 +361,9 @@ OfdmPhy::IsAllConfigSupported(WifiPpduField /* field */, Ptr ppd } Ptr -OfdmPhy::GetTxPowerSpectralDensity(double txPowerW, - Ptr /* ppdu */, - const WifiTxVector& txVector) const +OfdmPhy::GetTxPowerSpectralDensity(double txPowerW, Ptr ppdu) const { + const auto& txVector = ppdu->GetTxVector(); uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector); uint16_t channelWidth = txVector.GetChannelWidth(); NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW); diff --git a/src/wifi/model/non-ht/ofdm-phy.h b/src/wifi/model/non-ht/ofdm-phy.h index bbd5274d2..5fdc32c09 100644 --- a/src/wifi/model/non-ht/ofdm-phy.h +++ b/src/wifi/model/non-ht/ofdm-phy.h @@ -324,8 +324,7 @@ class OfdmPhy : public PhyEntity protected: PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr event) override; Ptr GetTxPowerSpectralDensity(double txPowerW, - Ptr ppdu, - const WifiTxVector& txVector) const override; + Ptr ppdu) const override; uint32_t GetMaxPsduSize() const override; uint16_t GetMeasurementChannelWidth(const Ptr ppdu) const override; diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index 6aae2c6ee..0acfc4c47 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -1279,23 +1279,23 @@ PhyEntity::NotifyPayloadBegin(const WifiTxVector& txVector, const Time& payloadD } void -PhyEntity::StartTx(Ptr ppdu, const WifiTxVector& txVector) +PhyEntity::StartTx(Ptr ppdu) { - NS_LOG_FUNCTION(this << ppdu << txVector); + NS_LOG_FUNCTION(this << ppdu); auto txPowerDbm = m_wifiPhy->GetTxPowerForTransmission(ppdu) + m_wifiPhy->GetTxGain(); - auto txPowerSpectrum = GetTxPowerSpectralDensity(DbmToW(txPowerDbm), ppdu, txVector); - Transmit(ppdu->GetTxDuration(), ppdu, txVector, txPowerDbm, txPowerSpectrum, "transmission"); + auto txVector = ppdu->GetTxVector(); + auto txPowerSpectrum = GetTxPowerSpectralDensity(DbmToW(txPowerDbm), ppdu); + Transmit(ppdu->GetTxDuration(), ppdu, txPowerDbm, txPowerSpectrum, "transmission"); } void PhyEntity::Transmit(Time txDuration, Ptr ppdu, - const WifiTxVector& txVector, double txPowerDbm, Ptr txPowerSpectrum, const std::string& type) { - NS_LOG_FUNCTION(this << txDuration << ppdu << txVector << txPowerDbm << type); + NS_LOG_FUNCTION(this << txDuration << ppdu << txPowerDbm << type); NS_LOG_DEBUG("Start " << type << ": signal power before antenna gain=" << txPowerDbm << "dBm"); auto txParams = Create(); txParams->duration = txDuration; diff --git a/src/wifi/model/phy-entity.h b/src/wifi/model/phy-entity.h index 9031329de..53ac84fa5 100644 --- a/src/wifi/model/phy-entity.h +++ b/src/wifi/model/phy-entity.h @@ -476,9 +476,8 @@ class PhyEntity : public SimpleRefCount * \see SpectrumWifiPhy::StartTx * * \param ppdu the PPDU to send - * \param txVector the TXVECTOR used for the transmission of the PPDU */ - virtual void StartTx(Ptr ppdu, const WifiTxVector& txVector); + virtual void StartTx(Ptr ppdu); /** * This function prepares most of the WifiSpectrumSignalParameters @@ -487,14 +486,12 @@ class PhyEntity : public SimpleRefCount * * \param txDuration the duration of the transmission * \param ppdu the PPDU to send - * \param txVector the TXVECTOR used for the transmission of the PPDU * \param txPowerDbm the total TX power in dBm * \param txPowerSpectrum the TX PSD * \param type the type of transmission (for logging) */ void Transmit(Time txDuration, Ptr ppdu, - const WifiTxVector& txVector, double txPowerDbm, Ptr txPowerSpectrum, const std::string& type); @@ -833,15 +830,13 @@ class PhyEntity : public SimpleRefCount /** * \param txPowerW power in W to spread across the bands * \param ppdu the PPDU that will be transmitted - * \param txVector the transmission parameters * \return Pointer to SpectrumValue * * This is a helper function to create the right TX PSD corresponding * to the amendment of this PHY. */ virtual Ptr GetTxPowerSpectralDensity(double txPowerW, - Ptr ppdu, - const WifiTxVector& txVector) const = 0; + Ptr ppdu) const = 0; /** * Get the center frequency of the channel corresponding the current TxVector rather than diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index 46cb090b0..efda74cf1 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -444,10 +444,10 @@ SpectrumWifiPhy::CreateWifiSpectrumPhyInterface(Ptr device) } void -SpectrumWifiPhy::StartTx(Ptr ppdu, const WifiTxVector& txVector) +SpectrumWifiPhy::StartTx(Ptr ppdu) { NS_LOG_FUNCTION(this << ppdu); - GetPhyEntity(ppdu->GetModulation())->StartTx(ppdu, txVector); + GetPhyEntity(ppdu->GetModulation())->StartTx(ppdu); } void diff --git a/src/wifi/model/spectrum-wifi-phy.h b/src/wifi/model/spectrum-wifi-phy.h index 174ec482c..ac3616cc6 100644 --- a/src/wifi/model/spectrum-wifi-phy.h +++ b/src/wifi/model/spectrum-wifi-phy.h @@ -69,7 +69,7 @@ class SpectrumWifiPhy : public WifiPhy ~SpectrumWifiPhy() override; // Implementation of pure virtual method. - void StartTx(Ptr ppdu, const WifiTxVector& txVector) override; + void StartTx(Ptr ppdu) override; Ptr GetChannel() const override; uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override; std::tuple GetTxMaskRejectionParams() const override; diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index dd185160c..1cefc6332 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -1727,7 +1727,7 @@ WifiPhy::Send(WifiConstPsduMap psdus, const WifiTxVector& txVector) m_endTxEvent = Simulator::Schedule(txDuration, &WifiPhy::NotifyTxEnd, this, psdus); // TODO: fix for MU - StartTx(ppdu, txVector); + StartTx(ppdu); ppdu->ResetTxVector(); m_channelAccessRequested = false; @@ -2073,7 +2073,7 @@ double WifiPhy::GetTxPowerForTransmission(Ptr ppdu) const { NS_LOG_FUNCTION(this << m_powerRestricted << ppdu); - const WifiTxVector& txVector = ppdu->GetTxVector(); + const auto& txVector = ppdu->GetTxVector(); // Get transmit power before antenna gain double txPowerDbm; if (!m_powerRestricted) diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 7881994b4..0d6ff0521 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -151,9 +151,8 @@ class WifiPhy : public Object /** * \param ppdu the PPDU to send - * \param txVector the TXVECTOR to use to send the PPDU */ - virtual void StartTx(Ptr ppdu, const WifiTxVector& txVector) = 0; + virtual void StartTx(Ptr ppdu) = 0; /** * Put in sleep mode. diff --git a/src/wifi/model/yans-wifi-phy.cc b/src/wifi/model/yans-wifi-phy.cc index 410d78ffc..9d4d789fd 100644 --- a/src/wifi/model/yans-wifi-phy.cc +++ b/src/wifi/model/yans-wifi-phy.cc @@ -87,11 +87,11 @@ YansWifiPhy::SetChannel(const Ptr channel) } void -YansWifiPhy::StartTx(Ptr ppdu, const WifiTxVector& txVector) +YansWifiPhy::StartTx(Ptr ppdu) { NS_LOG_FUNCTION(this << ppdu); NS_LOG_DEBUG("Start transmission: signal power before antenna gain=" - << GetPowerDbm(txVector.GetTxPowerLevel()) << "dBm"); + << GetPowerDbm(ppdu->GetTxVector().GetTxPowerLevel()) << "dBm"); m_channel->Send(this, ppdu, GetTxPowerForTransmission(ppdu) + GetTxGain()); } diff --git a/src/wifi/model/yans-wifi-phy.h b/src/wifi/model/yans-wifi-phy.h index 5183ca48f..0cbdc7802 100644 --- a/src/wifi/model/yans-wifi-phy.h +++ b/src/wifi/model/yans-wifi-phy.h @@ -57,7 +57,7 @@ class YansWifiPhy : public WifiPhy ~YansWifiPhy() override; void SetInterferenceHelper(const Ptr helper) override; - void StartTx(Ptr ppdu, const WifiTxVector& txVector) override; + void StartTx(Ptr ppdu) override; Ptr GetChannel() const override; uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override; std::tuple GetTxMaskRejectionParams() const override; diff --git a/src/wifi/test/wifi-phy-ofdma-test.cc b/src/wifi/test/wifi-phy-ofdma-test.cc index a409d8893..8bbb973a6 100644 --- a/src/wifi/test/wifi-phy-ofdma-test.cc +++ b/src/wifi/test/wifi-phy-ofdma-test.cc @@ -149,6 +149,7 @@ class OfdmaSpectrumWifiPhy : public SpectrumWifiPhy void DoDispose() override; using WifiPhy::Reset; + void StartTx(Ptr ppdu) override; /** * TracedCallback signature for UID of transmitted PPDU. @@ -157,12 +158,6 @@ class OfdmaSpectrumWifiPhy : public SpectrumWifiPhy */ typedef void (*TxPpduUidCallback)(uint64_t uid); - /** - * \param ppdu the PPDU to send - * \param txVector the TXVECTOR used for the transmission of the PPDU - */ - void StartTx(Ptr ppdu, const WifiTxVector& txVector) override; - /** * Set the global PPDU UID counter. * @@ -263,10 +258,10 @@ OfdmaSpectrumWifiPhy::SetTriggerFrameUid(uint64_t uid) } void -OfdmaSpectrumWifiPhy::StartTx(Ptr ppdu, const WifiTxVector& txVector) +OfdmaSpectrumWifiPhy::StartTx(Ptr ppdu) { m_phyTxPpduUidTrace(ppdu->GetUid()); - SpectrumWifiPhy::StartTx(ppdu, txVector); + SpectrumWifiPhy::StartTx(ppdu); } std::map, Ptr>& From f9eb5a7327a748db15f8db3750b0b46baed0ef28 Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Wed, 16 Nov 2022 02:23:47 -0300 Subject: [PATCH 045/494] bindings: improve search of linked libraries and include directories --- bindings/python/ns__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bindings/python/ns__init__.py b/bindings/python/ns__init__.py index 473f05803..e7ffccf4b 100644 --- a/bindings/python/ns__init__.py +++ b/bindings/python/ns__init__.py @@ -74,6 +74,10 @@ def _search_libraries() -> dict: library_search_paths += [os.path.dirname(library_search_paths[-1])] library_search_paths += [os.path.dirname(library_search_paths[-1])] + # Filter unique search paths and those that are not part of system directories + library_search_paths = list(filter(lambda x: x not in SYSTEM_LIBRARY_DIRECTORIES, + set(library_search_paths))) + # Search for the core library in the search paths libraries = [] for search_path in library_search_paths: @@ -82,6 +86,7 @@ def _search_libraries() -> dict: # Search system library directories (too slow for recursive search) for search_path in SYSTEM_LIBRARY_DIRECTORIES: libraries += glob.glob("%s/**/*.%s*" % (search_path, LIBRARY_EXTENSION), recursive=False) + libraries += glob.glob("%s/*.%s*" % (search_path, LIBRARY_EXTENSION), recursive=False) del search_path, library_search_paths @@ -343,7 +348,8 @@ def load_modules(): for linked_lib_include_dir in extract_library_include_dirs(library, prefix): if linked_lib_include_dir not in known_include_dirs: known_include_dirs.add(linked_lib_include_dir) - cppyy.add_include_path(linked_lib_include_dir) + if os.path.isdir(linked_lib_include_dir): + cppyy.add_include_path(linked_lib_include_dir) for module in modules: cppyy.include("ns3/%s-module.h" % module) From 3f3c3583d2e35a699e2927aaf17f4d83a26ab4b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Wed, 16 Nov 2022 21:36:01 +0100 Subject: [PATCH 046/494] wifi: Fix valgrind issues --- src/wifi/model/.DS_Store | Bin 0 -> 28676 bytes src/wifi/model/eht/eht-ppdu.cc | 2 +- src/wifi/model/he/he-ppdu.cc | 2 +- src/wifi/model/ht/ht-ppdu.cc | 2 +- src/wifi/model/non-ht/dsss-ppdu.cc | 2 +- src/wifi/model/non-ht/erp-ofdm-ppdu.cc | 2 +- src/wifi/model/non-ht/ofdm-ppdu.cc | 2 +- src/wifi/model/vht/vht-ppdu.cc | 2 +- src/wifi/model/wifi-ppdu.cc | 2 +- 9 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 src/wifi/model/.DS_Store diff --git a/src/wifi/model/.DS_Store b/src/wifi/model/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..14b6cc0d7acb3027e69f5dad6a252ef3ed27a040 GIT binary patch literal 28676 zcmeHQ4RBo7Rla8>*}Kn{{3Oe(U0Jf_ICf&$vgPOD~JfqD|iZJ`iCuB zVwjd4hGEr$En6a(Po`Mu$*?U;IrGW*a#m?@UWU9loYe`lr5toZ+UBJ3geYCy%)&O!1 zn4z_qcnH-tg`;`Ele5Q>@^VBhsSDWFQG9L%{6{uS3~N^FW&b1blzWyp_R7Ej6upv_8646N@t%VrRDgbrKhoE zvbKD9`Ay_uBtksU4*>+!8bU+;w`LDG=V;0aj}m-3VOXR|Z?lk)PZ&tSUNw=dej#3A z$j?=i@k(tXuV5er^~9=HkR|=d@%4ucIbBt9E3`23os7o0;KOH8U`9mR5yh)rPFtKygD+ zDspDx{f7LKS>>(L$%+kWp0J1fS&P?N@foIY9+F3^?h`shWAZ5KUSLi_gY}3H&s0q)i9oeUWw%9Jlz-7;#sw$vDQFq!8T1+rzK>MhHP_1S*uhU zNe#(3>O+?G^C2vov{E0(P)E}EkFZTwg%)WbwTB|vOg3OWWSa)g z(yDN*+R!L#ptOdf%*53K^o-WHL&&X&KD=WsQK@WOlC91 zQh)znL!_axX~Dv1G`cAI)}!P3^G8d=rK#fH;lllNb}XOIj`*L4M^0qY=g+$BL-|~3 zIFm~kSRj*1<1J@SW^$?g`Mvq6T&l>jNA(xcSS)td?RfOj{tZ1lwmr6?=h4kOZrZt_ zXLEo5*2f-;MVGDKwCmop4`nBE`Jck(;S0RAG}Wxn%YWaEpS&h#i_=58F_Aa?#(cqV zOw3u7IClJmbJlH}#v0!0`9f)kZ#GsVnEHhuhjCRG|gJzN}3=Te#6 z*nQY-xl-m_CS8cRPsfhsh9}aO+?FNH@s32|)YM4k;i*jN5qEVos-e0PD`M^o(K9J5 z{;qtA1XKJ?qAPJ-GA1b8rufFW8N!$=~hoi@e*a8jF>uiX*#n`cj@DXa!P0r@1 zn~ELJ4v(a>`qEZsd(^!nc5+&GqrN!c?25L+hS;gm{KN!SyQnYkP7Frf7o!hQ*>?^X zOZQBsbAGLc68od>OVRs^X15vwlj&| z_r2M8Y6^)dAc^=b7v^+okJ>Pza&>Z|Hs)qkq*sQ*&`4FC~ngeGW%<!8hPP;G6IU{11E=-i)+GmPWcFt0G<_BECVKGPNtR9?xeC z!n5wkWSBv8A2@jE+AxSOE+!LbZCl#DYz5iH_FaQz_0bCF>zLGCR#!vGSzY=0+IohT zlI&dWbRS23PG7JM%r`uDA!%;(65YMB$LV&PP~-LK^=t5S0cyKGUDw;)?MBeZ^y$V; z-HzLUCKO}YExmXO-pP)gj^j3>G3oDaxfM?pnz26JvloHLGNQF>==17D^(pm|x`Z0~ zHPp>-s5c=BEzk}tU@hDT>tO@*p+@e6n^7xoVXZt2x5FK93^nr!=COsvU7l1FZ{Zm81Bkc*RUa;9;C^ruj|Wf>;#QdkUFPrTHe#5Dnbr^TM@j zi=5LyjT>`d-HRox7tML*h^!FbG_XunnmJpJACpEo^!$7#No!kGtaK4~G)ha}rfOuEDhi_Z_~AiAB|1>lu%0(dZQKh$o}S zvC4c)Lv_WGYdsgjwc=gzaIO`flWWC;Tq_>Nwc_Di3roH&8p^cro1tiQhBh&i+J7J( z7t{;sQvWjjckkPO;4108O{uoseB1X2rFt%$QpJ!`d4y{F4ueqbx`heV zGajKDBxZ(es&+;Eu=*|ay!r$6r>KaZM-}`E5~|mcQZ>O6=zt{C{1vEp>#8JHDWq08 zRKkL%hD5A1@qYrIL~8Xj@XJW6p0SkekgsO?2*2qon?q-80p5*f|Gq7X88fM<*wbY-|*mHb}0dQ-r9*A?0%wIGo0z_1f0#j9`Dj7Ys ztZFQa08nVfKyo=?N6QlhUND|O? ztdyTAJxtyzok^>dZo#^bA*HS&3`c=bkh0AcW$jXld`ihSl+?*m6q+2vf20Xx95$`6 z@XMrAVzkbQVby|ynt@vQOBYqvg2|{|i`g-(S}^^T2nn zk0jaxMANB6LEnXeOrt-Id#?o_rURAQhwbd2hYvGaG((vilD=1#lsS3w)ak219YUj( z-Pf&M-;WFe3G`c-_O?1p9TAnB303OIiXTs53K(-=;ZR3&vNPG`e`7~rOlD27O()s2 zDi(ELFakVGOq0o;HC7Z;3#{u!fngoRL?~%Njh7$Mq_Tui(=|aI|uO6 z9e#vK7vbExI~v1aP?t# z2!=?9t05Th=@1&_wO1Kx-6%MV}#^H(@3^ejAwaZEpg`7(R~ zdG%M}@8R1Xvvx3oxi)fRWL=~;vOcmkG7#CT2mUh8zF(jFe}&?+;WtoexRHN>L;R36bmC#Wo8iTy%wQ4s!RhUYUeyqt(r1DkeJKW z!`S;24V!tMI%Y@prQAMRF`Zc{4UO4R-UCR~&Uv6(HDxLxF}ur{GB0Evu_~q*61i)h z$X1P+c1YYsWn3bCv_~OC=a_0pDJMkADv9ZYlv!Msk-1xe^?oJ}Qf{V(QqC@oD1?++ zjJoabU7%egly^aSUs*Fg$97(ooS-4W_0sQk%ucVDZXb~ArJHRYQq6j4#cr`2Y7e`H zQ8cVcd~25^%}*x+RGr?!?oM{|%FDvH9zMCm$OFP9b}~8z$7x1L!F}3bLut$7=tBJD zKU(mk&!LO-$llARX+p_Q2!-sjYGKtYT zCx%rEwmONhlKb4JNVK7mQhUg&%wsu|El;AaxD0fw=4^cudktcbvv(=t5eGl6^%bCf zY_qbY>#tBrR*TruWjPD6oLOm#@$46fyDen4T8Z3%n`MKM35=>5h~8a-41C`%;8mHe zRG+}B{uc%$U`F{`2|2@;g;F-Vf7Mj`A`9ql5R4KBiGoCml&t1sbNu52;b(G5I zHtEwf&JC2t=PuBvy`38{>=tz+eCllK+)TNFZi7DU?c9bzHqa+Kotr63&~4PGw>q~` zexj@Rv~zFgK1yuD#kiVt@4_>iT!=#tul@Go5*%eV?ZDOFn>n-T0Os2r=FFz!m~(du z*MUbNg{#10oY_R{z?9i^kr&`7v*}4(etSP>Ha*4b!nI{K@i1Xcm*lSo_<8?x=0?-r z8Dnsf`=l$OSi=~TJUNWXU2GbI!tUpJ!jQrV&@6ipnDj|3xp!=KEUQ*T0ULG;3TPq` zJ=VK;=IkS)ga(q_g+@fI5|ULTntT~Ja_2J`jA4-y62Qgr%{G%#r(>!T0zk>qXenv)s+x3r6W&eph`Wj z7S*aLc`gG}dOtm>HJ6e@>O~&Qz>vFu!!fK{u%~)fcq-XnK7!1=^ka#`IKlUS4JKe| z?6oAS?5}E3t(vk2lbF)ehhh4<8Pad``$1}>XtnguvtwDcVx*@8(n=g_W`3oKJZT@s zeP_#DrTtDiq!rwgPaaFQd9J5ZRbDLnD~USS(+NYh`hoqE#0=BKnSKa)ChUJCg53EX zd?tauV&5X=B`5LaDF#lOTQO&t{f9&evq~Gq>I?Q35<~uiimpjW``I6qrMw^Ws?Yze z%~Mw}fww;Y$CQBj`u{b*{vW}yihe$m-ph=P{n?g0ET2R^-$=D>6*!l(QChOkrk?w_~b%J?@yI$O1WgS7?ERw_|EudB@a1 zdB@bD@{TFJmydQ#oeS)kdb_t{iV}NuT;W3)SEy~r6#mZ?BEmK6X4d#My_vPO&5`M0 zcCwcrs^au8-U&wuRN)&emUqP+BLxfo}YO#(VJS%EnDjT&IBX{yw_2WvdhSQ^0taA6?uz;Ka)rV0vpHUA}d9JZ`0ckv4Mi zdxy;36fb$#590NTyD4yA#$9F_7?yI+5t0aOvACQxus>5e4eT{94ea04*VVuCX4V!= z18e2YtT*7sLE6l!Lu<5|mBMOw@@CdExUu3aZ)Sa%bJ}S$>pS7y@E+dG`VsgIc$zn} zejGjlpX5}qzlAUHX4Zd%f1=H-xVgfOwAQqlbs-vs{1HZYY#0(SPCfi}V>7fsQPOM;5~) mi{VlKivJb=PXOxUKR&7T_yp?XKPMT@w#Hzwm>;zG|NjB7o7HFl literal 0 HcmV?d00001 diff --git a/src/wifi/model/eht/eht-ppdu.cc b/src/wifi/model/eht/eht-ppdu.cc index 7eaa34d61..c5afc7e26 100644 --- a/src/wifi/model/eht/eht-ppdu.cc +++ b/src/wifi/model/eht/eht-ppdu.cc @@ -101,7 +101,7 @@ EhtPpdu::DoGetTxVector() const Ptr EhtPpdu::Copy() const { - return Ptr(new EhtPpdu(*this)); + return Ptr(new EhtPpdu(*this), false); } } // namespace ns3 diff --git a/src/wifi/model/he/he-ppdu.cc b/src/wifi/model/he/he-ppdu.cc index 21dbde3ef..dc1022878 100644 --- a/src/wifi/model/he/he-ppdu.cc +++ b/src/wifi/model/he/he-ppdu.cc @@ -190,7 +190,7 @@ HePpdu::GetTxDuration() const Ptr HePpdu::Copy() const { - return Ptr(new HePpdu(*this)); + return Ptr(new HePpdu(*this), false); } WifiPpduType diff --git a/src/wifi/model/ht/ht-ppdu.cc b/src/wifi/model/ht/ht-ppdu.cc index 1bfc49728..b61e5d880 100644 --- a/src/wifi/model/ht/ht-ppdu.cc +++ b/src/wifi/model/ht/ht-ppdu.cc @@ -95,7 +95,7 @@ HtPpdu::GetTxDuration() const Ptr HtPpdu::Copy() const { - return Ptr(new HtPpdu(*this)); + return Ptr(new HtPpdu(*this), false); } HtPpdu::HtSigHeader::HtSigHeader() diff --git a/src/wifi/model/non-ht/dsss-ppdu.cc b/src/wifi/model/non-ht/dsss-ppdu.cc index acab31d27..6980e88d9 100644 --- a/src/wifi/model/non-ht/dsss-ppdu.cc +++ b/src/wifi/model/non-ht/dsss-ppdu.cc @@ -72,7 +72,7 @@ DsssPpdu::GetTxDuration() const Ptr DsssPpdu::Copy() const { - return Ptr(new DsssPpdu(*this)); + return Ptr(new DsssPpdu(*this), false); } DsssPpdu::DsssSigHeader::DsssSigHeader() diff --git a/src/wifi/model/non-ht/erp-ofdm-ppdu.cc b/src/wifi/model/non-ht/erp-ofdm-ppdu.cc index f6a13e3f5..b58abe55e 100644 --- a/src/wifi/model/non-ht/erp-ofdm-ppdu.cc +++ b/src/wifi/model/non-ht/erp-ofdm-ppdu.cc @@ -58,7 +58,7 @@ ErpOfdmPpdu::DoGetTxVector() const Ptr ErpOfdmPpdu::Copy() const { - return Ptr(new ErpOfdmPpdu(*this)); + return Ptr(new ErpOfdmPpdu(*this), false); } } // namespace ns3 diff --git a/src/wifi/model/non-ht/ofdm-ppdu.cc b/src/wifi/model/non-ht/ofdm-ppdu.cc index 79b27ba04..bfdf9753b 100644 --- a/src/wifi/model/non-ht/ofdm-ppdu.cc +++ b/src/wifi/model/non-ht/ofdm-ppdu.cc @@ -78,7 +78,7 @@ OfdmPpdu::GetTxDuration() const Ptr OfdmPpdu::Copy() const { - return Ptr(new OfdmPpdu(*this)); + return Ptr(new OfdmPpdu(*this), false); } OfdmPpdu::LSigHeader::LSigHeader() diff --git a/src/wifi/model/vht/vht-ppdu.cc b/src/wifi/model/vht/vht-ppdu.cc index fdd7fdc86..2b9c6cbda 100644 --- a/src/wifi/model/vht/vht-ppdu.cc +++ b/src/wifi/model/vht/vht-ppdu.cc @@ -107,7 +107,7 @@ VhtPpdu::GetTxDuration() const Ptr VhtPpdu::Copy() const { - return Ptr(new VhtPpdu(*this)); + return Ptr(new VhtPpdu(*this), false); } WifiPpduType diff --git a/src/wifi/model/wifi-ppdu.cc b/src/wifi/model/wifi-ppdu.cc index 9dbfe15d5..48beddd32 100644 --- a/src/wifi/model/wifi-ppdu.cc +++ b/src/wifi/model/wifi-ppdu.cc @@ -239,7 +239,7 @@ WifiPpdu::Copy() const { NS_FATAL_ERROR("This method should not be called for the base WifiPpdu class. Use the " "overloaded version in the amendment-specific PPDU subclasses instead!"); - return Ptr(new WifiPpdu(*this)); + return Ptr(new WifiPpdu(*this), false); } std::ostream& From 99fc2390c47440b8e21057f13cbc4b1eee0ccb33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Wed, 16 Nov 2022 21:47:19 +0100 Subject: [PATCH 047/494] wifi: Fix wrongly committed file --- src/wifi/model/.DS_Store | Bin 28676 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/wifi/model/.DS_Store diff --git a/src/wifi/model/.DS_Store b/src/wifi/model/.DS_Store deleted file mode 100644 index 14b6cc0d7acb3027e69f5dad6a252ef3ed27a040..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 28676 zcmeHQ4RBo7Rla8>*}Kn{{3Oe(U0Jf_ICf&$vgPOD~JfqD|iZJ`iCuB zVwjd4hGEr$En6a(Po`Mu$*?U;IrGW*a#m?@UWU9loYe`lr5toZ+UBJ3geYCy%)&O!1 zn4z_qcnH-tg`;`Ele5Q>@^VBhsSDWFQG9L%{6{uS3~N^FW&b1blzWyp_R7Ej6upv_8646N@t%VrRDgbrKhoE zvbKD9`Ay_uBtksU4*>+!8bU+;w`LDG=V;0aj}m-3VOXR|Z?lk)PZ&tSUNw=dej#3A z$j?=i@k(tXuV5er^~9=HkR|=d@%4ucIbBt9E3`23os7o0;KOH8U`9mR5yh)rPFtKygD+ zDspDx{f7LKS>>(L$%+kWp0J1fS&P?N@foIY9+F3^?h`shWAZ5KUSLi_gY}3H&s0q)i9oeUWw%9Jlz-7;#sw$vDQFq!8T1+rzK>MhHP_1S*uhU zNe#(3>O+?G^C2vov{E0(P)E}EkFZTwg%)WbwTB|vOg3OWWSa)g z(yDN*+R!L#ptOdf%*53K^o-WHL&&X&KD=WsQK@WOlC91 zQh)znL!_axX~Dv1G`cAI)}!P3^G8d=rK#fH;lllNb}XOIj`*L4M^0qY=g+$BL-|~3 zIFm~kSRj*1<1J@SW^$?g`Mvq6T&l>jNA(xcSS)td?RfOj{tZ1lwmr6?=h4kOZrZt_ zXLEo5*2f-;MVGDKwCmop4`nBE`Jck(;S0RAG}Wxn%YWaEpS&h#i_=58F_Aa?#(cqV zOw3u7IClJmbJlH}#v0!0`9f)kZ#GsVnEHhuhjCRG|gJzN}3=Te#6 z*nQY-xl-m_CS8cRPsfhsh9}aO+?FNH@s32|)YM4k;i*jN5qEVos-e0PD`M^o(K9J5 z{;qtA1XKJ?qAPJ-GA1b8rufFW8N!$=~hoi@e*a8jF>uiX*#n`cj@DXa!P0r@1 zn~ELJ4v(a>`qEZsd(^!nc5+&GqrN!c?25L+hS;gm{KN!SyQnYkP7Frf7o!hQ*>?^X zOZQBsbAGLc68od>OVRs^X15vwlj&| z_r2M8Y6^)dAc^=b7v^+okJ>Pza&>Z|Hs)qkq*sQ*&`4FC~ngeGW%<!8hPP;G6IU{11E=-i)+GmPWcFt0G<_BECVKGPNtR9?xeC z!n5wkWSBv8A2@jE+AxSOE+!LbZCl#DYz5iH_FaQz_0bCF>zLGCR#!vGSzY=0+IohT zlI&dWbRS23PG7JM%r`uDA!%;(65YMB$LV&PP~-LK^=t5S0cyKGUDw;)?MBeZ^y$V; z-HzLUCKO}YExmXO-pP)gj^j3>G3oDaxfM?pnz26JvloHLGNQF>==17D^(pm|x`Z0~ zHPp>-s5c=BEzk}tU@hDT>tO@*p+@e6n^7xoVXZt2x5FK93^nr!=COsvU7l1FZ{Zm81Bkc*RUa;9;C^ruj|Wf>;#QdkUFPrTHe#5Dnbr^TM@j zi=5LyjT>`d-HRox7tML*h^!FbG_XunnmJpJACpEo^!$7#No!kGtaK4~G)ha}rfOuEDhi_Z_~AiAB|1>lu%0(dZQKh$o}S zvC4c)Lv_WGYdsgjwc=gzaIO`flWWC;Tq_>Nwc_Di3roH&8p^cro1tiQhBh&i+J7J( z7t{;sQvWjjckkPO;4108O{uoseB1X2rFt%$QpJ!`d4y{F4ueqbx`heV zGajKDBxZ(es&+;Eu=*|ay!r$6r>KaZM-}`E5~|mcQZ>O6=zt{C{1vEp>#8JHDWq08 zRKkL%hD5A1@qYrIL~8Xj@XJW6p0SkekgsO?2*2qon?q-80p5*f|Gq7X88fM<*wbY-|*mHb}0dQ-r9*A?0%wIGo0z_1f0#j9`Dj7Ys ztZFQa08nVfKyo=?N6QlhUND|O? ztdyTAJxtyzok^>dZo#^bA*HS&3`c=bkh0AcW$jXld`ihSl+?*m6q+2vf20Xx95$`6 z@XMrAVzkbQVby|ynt@vQOBYqvg2|{|i`g-(S}^^T2nn zk0jaxMANB6LEnXeOrt-Id#?o_rURAQhwbd2hYvGaG((vilD=1#lsS3w)ak219YUj( z-Pf&M-;WFe3G`c-_O?1p9TAnB303OIiXTs53K(-=;ZR3&vNPG`e`7~rOlD27O()s2 zDi(ELFakVGOq0o;HC7Z;3#{u!fngoRL?~%Njh7$Mq_Tui(=|aI|uO6 z9e#vK7vbExI~v1aP?t# z2!=?9t05Th=@1&_wO1Kx-6%MV}#^H(@3^ejAwaZEpg`7(R~ zdG%M}@8R1Xvvx3oxi)fRWL=~;vOcmkG7#CT2mUh8zF(jFe}&?+;WtoexRHN>L;R36bmC#Wo8iTy%wQ4s!RhUYUeyqt(r1DkeJKW z!`S;24V!tMI%Y@prQAMRF`Zc{4UO4R-UCR~&Uv6(HDxLxF}ur{GB0Evu_~q*61i)h z$X1P+c1YYsWn3bCv_~OC=a_0pDJMkADv9ZYlv!Msk-1xe^?oJ}Qf{V(QqC@oD1?++ zjJoabU7%egly^aSUs*Fg$97(ooS-4W_0sQk%ucVDZXb~ArJHRYQq6j4#cr`2Y7e`H zQ8cVcd~25^%}*x+RGr?!?oM{|%FDvH9zMCm$OFP9b}~8z$7x1L!F}3bLut$7=tBJD zKU(mk&!LO-$llARX+p_Q2!-sjYGKtYT zCx%rEwmONhlKb4JNVK7mQhUg&%wsu|El;AaxD0fw=4^cudktcbvv(=t5eGl6^%bCf zY_qbY>#tBrR*TruWjPD6oLOm#@$46fyDen4T8Z3%n`MKM35=>5h~8a-41C`%;8mHe zRG+}B{uc%$U`F{`2|2@;g;F-Vf7Mj`A`9ql5R4KBiGoCml&t1sbNu52;b(G5I zHtEwf&JC2t=PuBvy`38{>=tz+eCllK+)TNFZi7DU?c9bzHqa+Kotr63&~4PGw>q~` zexj@Rv~zFgK1yuD#kiVt@4_>iT!=#tul@Go5*%eV?ZDOFn>n-T0Os2r=FFz!m~(du z*MUbNg{#10oY_R{z?9i^kr&`7v*}4(etSP>Ha*4b!nI{K@i1Xcm*lSo_<8?x=0?-r z8Dnsf`=l$OSi=~TJUNWXU2GbI!tUpJ!jQrV&@6ipnDj|3xp!=KEUQ*T0ULG;3TPq` zJ=VK;=IkS)ga(q_g+@fI5|ULTntT~Ja_2J`jA4-y62Qgr%{G%#r(>!T0zk>qXenv)s+x3r6W&eph`Wj z7S*aLc`gG}dOtm>HJ6e@>O~&Qz>vFu!!fK{u%~)fcq-XnK7!1=^ka#`IKlUS4JKe| z?6oAS?5}E3t(vk2lbF)ehhh4<8Pad``$1}>XtnguvtwDcVx*@8(n=g_W`3oKJZT@s zeP_#DrTtDiq!rwgPaaFQd9J5ZRbDLnD~USS(+NYh`hoqE#0=BKnSKa)ChUJCg53EX zd?tauV&5X=B`5LaDF#lOTQO&t{f9&evq~Gq>I?Q35<~uiimpjW``I6qrMw^Ws?Yze z%~Mw}fww;Y$CQBj`u{b*{vW}yihe$m-ph=P{n?g0ET2R^-$=D>6*!l(QChOkrk?w_~b%J?@yI$O1WgS7?ERw_|EudB@a1 zdB@bD@{TFJmydQ#oeS)kdb_t{iV}NuT;W3)SEy~r6#mZ?BEmK6X4d#My_vPO&5`M0 zcCwcrs^au8-U&wuRN)&emUqP+BLxfo}YO#(VJS%EnDjT&IBX{yw_2WvdhSQ^0taA6?uz;Ka)rV0vpHUA}d9JZ`0ckv4Mi zdxy;36fb$#590NTyD4yA#$9F_7?yI+5t0aOvACQxus>5e4eT{94ea04*VVuCX4V!= z18e2YtT*7sLE6l!Lu<5|mBMOw@@CdExUu3aZ)Sa%bJ}S$>pS7y@E+dG`VsgIc$zn} zejGjlpX5}qzlAUHX4Zd%f1=H-xVgfOwAQqlbs-vs{1HZYY#0(SPCfi}V>7fsQPOM;5~) mi{VlKivJb=PXOxUKR&7T_yp?XKPMT@w#Hzwm>;zG|NjB7o7HFl From fbe0786cd96bbbf6c12ea2361ea401e72248eabf Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Wed, 16 Nov 2022 17:09:48 -0800 Subject: [PATCH 048/494] internet: Remove obsolete PendingData model --- src/internet/CMakeLists.txt | 1 - src/internet/model/pending-data.cc | 270 ----------------------------- src/internet/model/pending-data.h | 194 --------------------- 3 files changed, 465 deletions(-) delete mode 100644 src/internet/model/pending-data.cc delete mode 100644 src/internet/model/pending-data.h diff --git a/src/internet/CMakeLists.txt b/src/internet/CMakeLists.txt index b4b294417..bd2840e7c 100644 --- a/src/internet/CMakeLists.txt +++ b/src/internet/CMakeLists.txt @@ -79,7 +79,6 @@ set(source_files model/ipv6.cc model/loopback-net-device.cc model/ndisc-cache.cc - model/pending-data.cc model/rip-header.cc model/rip.cc model/ripng-header.cc diff --git a/src/internet/model/pending-data.cc b/src/internet/model/pending-data.cc deleted file mode 100644 index 437414000..000000000 --- a/src/internet/model/pending-data.cc +++ /dev/null @@ -1,270 +0,0 @@ -// -// Copyright (c) 2006 Georgia Tech Research Corporation -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as -// published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// Author: Rajib Bhattacharjea -// - -// This is a port of Data PDU Headers from: -// Georgia Tech Network Simulator -// George F. Riley. Georgia Tech, Spring 2002 - -#include "pending-data.h" - -#include "ns3/fatal-error.h" -#include "ns3/log.h" - -#include -#include -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("PendingData"); - -PendingData::PendingData() - : size(0), - data(0), - msgSize(0), - responseSize(0) -{ - NS_LOG_FUNCTION(this); -} - -PendingData::PendingData(uint32_t s, uint8_t* d, uint32_t msg, uint32_t resp) - : size(s), - data(0), - msgSize(msg), - responseSize(resp) -{ - NS_LOG_FUNCTION(this << s); - if (d) - { - data.push_back(Create(d, size)); - } -} - -PendingData::PendingData(const std::string& s) - : size(s.length() + 1), - data(0), - msgSize(0), - responseSize(0) -{ - NS_LOG_FUNCTION(this << s.length() + 1); - data.push_back(Create((uint8_t*)s.c_str(), size)); -} - -PendingData::PendingData(const PendingData& c) - : size(c.Size()), - data(c.data), - msgSize(c.msgSize), - responseSize(c.responseSize) -{ - NS_LOG_FUNCTION(this << c.Size()); -} - -PendingData::~PendingData() -{ - NS_LOG_FUNCTION(this); -} - -PendingData* -PendingData::Copy() const -{ - NS_LOG_FUNCTION(this); - return new PendingData(*this); -}; - -PendingData* -PendingData::CopyS(uint32_t s) -{ // Copy, but with new size (assumes no associated data); - NS_LOG_FUNCTION(this << s); - return new PendingData(s, nullptr, msgSize, responseSize); -} - -PendingData* -PendingData::CopySD(uint32_t s, uint8_t* d) -{ // Copy, but with new size (assumes no associated data); - NS_LOG_FUNCTION(this << s); - return new PendingData(s, d, msgSize, responseSize); -} - -void -PendingData::Clear() -{ // Remove all pending data - NS_LOG_FUNCTION(this); - data.clear(); - size = 0; -} - -void -PendingData::Add(uint32_t s, const uint8_t* d) -{ - NS_LOG_FUNCTION(this << s); - data.push_back(Create(d, s)); - size += s; -} - -void -PendingData::Add(Ptr p) -{ - NS_LOG_FUNCTION(this); - data.push_back(p); - size += p->GetSize(); -} - -uint32_t -PendingData::SizeFromSeq(const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset) -{ - NS_LOG_FUNCTION(this << seqFront << seqOffset); - uint32_t o1 = OffsetFromSeq(seqFront, seqOffset); // Offset to start of unused data - return SizeFromOffset(o1); // Amount of data after offset -} - -uint32_t -PendingData::SizeFromOffset(uint32_t offset) -{ // Find out how much data is available from offset - NS_LOG_FUNCTION(this << offset); - /// \todo should this return zero, or error out? - if (offset > size) - { - return 0; // No data at requested offset - } - return size - offset; // Available data after offset -} - -uint32_t -PendingData::OffsetFromSeq(const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset) -{ // f is the first sequence number in this data, o is offset sequence - NS_LOG_FUNCTION(this << seqFront << seqOffset); - if (seqOffset < seqFront) - { - return 0; // HuH? Shouldn't happen - } - return seqOffset - seqFront; -} - -Ptr -PendingData::CopyFromOffset(uint32_t s, uint32_t o) -{ // Make a copy of data from starting position "o" for "s" bytes - // Return NULL if results in zero length data - NS_LOG_FUNCTION(this << s << o); - uint32_t s1 = std::min(s, SizeFromOffset(o)); // Insure not beyond end of data - if (s1 == 0) - { - return Create(); // No data requested - } - if (data.size() != 0) - { // Actual data exists, make copy and return it - uint32_t count = 0; - std::vector>::size_type begin = 0; - bool beginFound = false; - std::vector>::size_type end = 0; - Ptr outPacket; - Ptr endFragment; - for (std::vector>::size_type i = 0; i < data.size(); ++i) - { - count += data[i]->GetSize(); - if (!beginFound) - { - if (count > o) - { - if (count >= o + s1) // then just copy within this packet - { - Ptr toFragment = data[i]; - uint32_t packetStart = count - toFragment->GetSize(); - uint32_t packetOffset = o - packetStart; - outPacket = toFragment->CreateFragment(packetOffset, s1); - return outPacket; - } - begin = i; - beginFound = true; - Ptr toFragment = data[begin]; - uint32_t packetStart = count - toFragment->GetSize(); - uint32_t packetOffset = o - packetStart; - uint32_t fragmentLength = count - o; - outPacket = toFragment->CreateFragment(packetOffset, fragmentLength); - } - } - else - { - if (count >= o + s1) - { - end = i; - Ptr toFragment = data[end]; - uint32_t packetStart = count - toFragment->GetSize(); - uint32_t fragmentLength = o + s1 - packetStart; - endFragment = toFragment->CreateFragment(0, fragmentLength); - break; - } - } - } - for (std::vector>::size_type i = begin + 1; i < end; ++i) - { - outPacket->AddAtEnd(data[i]); - } - if (endFragment) - { - outPacket->AddAtEnd(endFragment); - } - NS_ASSERT(outPacket->GetSize() == s1); - return outPacket; - } - else - { // No actual data, just return dummy-data packet of correct size - return Create(s1); - } -} - -Ptr -PendingData::CopyFromSeq(uint32_t s, const SequenceNumber32& f, const SequenceNumber32& o) -{ - NS_LOG_FUNCTION(this << s << f << o); - return CopyFromOffset(s, OffsetFromSeq(f, o)); -} - -uint32_t -PendingData::RemoveToSeq(const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset) -{ - NS_LOG_FUNCTION(this << seqFront << seqOffset); - uint32_t count = OffsetFromSeq(seqFront, seqOffset); - NS_ASSERT_MSG(count <= size, "Trying to remove more data than in the buffer"); - if (count == size) - { - Clear(); - return size; - } - // Remove whole packets, if possible, from the front of the data - // Do not perform buffer manipulations within packet; if a whole packet - // cannot be removed, leave it alone - std::vector>::iterator endI = data.begin(); - uint32_t current = 0; - // Any packet whose data has been completely acked can be removed - for (std::vector>::iterator dataI = data.begin(); dataI < data.end(); dataI++) - { - if (current + (*dataI)->GetSize() > count) - { - break; - } - current += (*dataI)->GetSize(); - ++endI; - } - data.erase(data.begin(), endI); - size -= current; - return current; -} - -} // namespace ns3 diff --git a/src/internet/model/pending-data.h b/src/internet/model/pending-data.h deleted file mode 100644 index 3bdf3544c..000000000 --- a/src/internet/model/pending-data.h +++ /dev/null @@ -1,194 +0,0 @@ -// -// Copyright (c) 2006 Georgia Tech Research Corporation -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as -// published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// Author: Rajib Bhattacharjea -// - -// Georgia Tech Network Simulator - Data Descriptors -// George F. Riley. Georgia Tech, Spring 2002 - -#ifndef PENDING_DATA_H -#define PENDING_DATA_H - -#include "pending-data.h" - -#include "ns3/packet.h" -#include "ns3/ptr.h" -#include "ns3/sequence-number.h" - -namespace ns3 -{ -class Packet; - -/** - * \ingroup tcp - * - * \brief class for managing I/O between applications and TCP - */ -class PendingData -{ - public: - PendingData(); - /** - * Constructor - * \param s size - * \param d data - * \param msg message size - * \param resp response size - */ - PendingData(uint32_t s, uint8_t* d = nullptr, uint32_t msg = 0, uint32_t resp = 0); - /** - * Constructor from string - * \param s string - */ - PendingData(const std::string& s); // Construct from string - - /** - * Copy constructor - * \param o object to copy - */ - PendingData(const PendingData& o); // Copy constructor - virtual ~PendingData(); // Destructor - - /** - * Returns the size of the pending data - * \returns size of pending data - */ - uint32_t Size() const - { - return size; - } - - /** - * \brief Remove all associated data - */ - virtual void Clear(); - - /** - * \brief Add some data to end - * \param s the data size. - * \param d the data to store. - */ - virtual void Add(uint32_t s, const uint8_t* d = nullptr); // - /** - * \brief Add some data to end - * \param p packet containing the data. - */ - virtual void Add(Ptr p); - /** - * This method returns the number of bytes in the PendingData buffer - * beyond the sequence number specified by seqOffset. - * - * The variables seqFront and seqOffset correspond to a sequence number - * space in use by the user. What is significant in this method is the - * difference between them; i.e. the quantity (seqOffset - seqFront). - * This difference is subtracted from Size(), yielding the number of - * bytes beyond seqOffset, from the user perspective, in the PendingData - * buffer. - * - * If the first number specified is not a sequence number that corresponds - * to the first data byte in the PendingData buffer, the computation - * returned will be in error. - * - * \return number of bytes - * \param seqFront sequence number of assumed first byte in the PendingData - * \param seqOffset sequence number of offset - */ - virtual uint32_t SizeFromSeq(const SequenceNumber32& seqFront, - const SequenceNumber32& seqOffset); - // Inquire available data from offset - /** - * \return number of bytes in the data buffer beyond the offset specified - * \param offset offset (from zero) - */ - virtual uint32_t SizeFromOffset(uint32_t offset); - // Available size from sequence difference - /** - * Subtracts seqFront from seqOffset after enforcing seqFront is less - * than seqOffset - * - * \param seqFront sequence number to be subtracted from seqOffset - * \param seqOffset higher sequence number - * \return seqOffset-seqFront - */ - virtual uint32_t OffsetFromSeq(const SequenceNumber32& seqFront, - const SequenceNumber32& seqOffset); - - /** - * \brief Copy data starting from a give offset - * \param s size of data to copy - * \param o offset - * \returns a packet containing the requested data - */ - virtual Ptr CopyFromOffset(uint32_t s, uint32_t o); // Size, offset, ret packet - /** - * \brief Copy data starting from a give offset - * \param s size of data to copy - * \param f Front sequence - * \param o Offset sequence - * - * \see PendingData::OffsetFromSeq() - * \returns a packet containing the requested data - */ - virtual Ptr CopyFromSeq(uint32_t s, - const SequenceNumber32& f, - const SequenceNumber32& o); - /** - * Permits object to clear any pending data between seqFront and - * seqOffset - 1). Callers should check the return value to determine - * whether any data was removed from the front. - * - * \param seqFront sequence number to start to try to remove from - * \param seqOffset first sequence number in buffer that should be retained - * \return number of bytes from the front that were removed from the buffer - */ - virtual uint32_t RemoveToSeq(const SequenceNumber32& seqFront, - const SequenceNumber32& seqOffset); - - /** - * \brief Create a copy of self - * \returns copy of pending data - */ - PendingData* Copy() const; - /** - * \brief Create a copy of self with new size - * - * Assumes no associated data - * \param s new size - * \returns copy of pending data - */ - PendingData* CopyS(uint32_t s); // Copy - /** - * \brief Create a copy of self with new size, new data - * - * Assumes no associated data - * \param s new size - * \param d new data - * \returns copy of pending data - */ - PendingData* CopySD(uint32_t s, uint8_t* d); - - public: - uint32_t size; //!< Number of data bytes - std::vector> data; //!< Corresponding data (may be null) - // The next two fields allow simulated applications to exchange some info - uint32_t msgSize; //!< Total size of message - uint32_t responseSize; //!< Size of response requested -}; - -} // namespace ns3 - -#endif /* PENDING_DATA_H */ From 5db180c609fe2e35def360b4a6ebdae93df0095e Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Sat, 19 Nov 2022 23:27:22 +0100 Subject: [PATCH 049/494] internet: Fix IPv6 src address glitch when receiving redirects --- src/internet/model/ipv6-static-routing.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internet/model/ipv6-static-routing.cc b/src/internet/model/ipv6-static-routing.cc index 38b4e399b..a0dcf074f 100644 --- a/src/internet/model/ipv6-static-routing.cc +++ b/src/internet/model/ipv6-static-routing.cc @@ -458,7 +458,7 @@ Ipv6StaticRouting::LookupStatic(Ipv6Address dst, Ptr interface) else { rtentry->SetSource( - m_ipv6->SourceAddressSelection(interfaceIdx, route->GetGateway())); + m_ipv6->SourceAddressSelection(interfaceIdx, route->GetDest())); } rtentry->SetDestination(route->GetDest()); From c71b0de4a4352e6f90f4739ac8ef7ef0a9f1f051 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Fri, 7 Oct 2022 16:21:57 +0200 Subject: [PATCH 050/494] wifi: Make GetMaximumChannelWidth() a function of the modulation class instead of standard Also, move it to wifi-phy-common --- src/wifi/model/wifi-phy-common.cc | 24 +++++++++++++++ src/wifi/model/wifi-phy-common.h | 8 +++++ src/wifi/model/wifi-phy-operating-channel.cc | 4 ++- src/wifi/model/wifi-standards.h | 32 -------------------- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/wifi/model/wifi-phy-common.cc b/src/wifi/model/wifi-phy-common.cc index 5535c76a3..3784ff167 100644 --- a/src/wifi/model/wifi-phy-common.cc +++ b/src/wifi/model/wifi-phy-common.cc @@ -252,4 +252,28 @@ GetModulationClassForStandard(WifiStandard standard) return modulationClass; } +uint16_t +GetMaximumChannelWidth(WifiModulationClass modulation) +{ + switch (modulation) + { + case WIFI_MOD_CLASS_DSSS: + case WIFI_MOD_CLASS_HR_DSSS: + return 22; + case WIFI_MOD_CLASS_OFDM: + case WIFI_MOD_CLASS_ERP_OFDM: + return 20; + case WIFI_MOD_CLASS_HT: + return 40; + case WIFI_MOD_CLASS_VHT: + case WIFI_MOD_CLASS_HE: + return 160; + case WIFI_MOD_CLASS_EHT: + return 160; // TODO update when 320 MHz channels are supported + default: + NS_ABORT_MSG("Unknown modulation class: " << modulation); + return 0; + } +} + } // namespace ns3 diff --git a/src/wifi/model/wifi-phy-common.h b/src/wifi/model/wifi-phy-common.h index c051e27de..d7111a07c 100644 --- a/src/wifi/model/wifi-phy-common.h +++ b/src/wifi/model/wifi-phy-common.h @@ -556,6 +556,14 @@ bool IsUlMu(WifiPreamble preamble); */ WifiModulationClass GetModulationClassForStandard(WifiStandard standard); +/** + * Get the maximum channel width in MHz allowed for the given modulation class. + * + * \param modulation the modulation class + * \return the maximum channel width in MHz allowed for the given modulation class + */ +uint16_t GetMaximumChannelWidth(WifiModulationClass modulation); + } // namespace ns3 #endif /* WIFI_PHY_COMMON_H */ diff --git a/src/wifi/model/wifi-phy-operating-channel.cc b/src/wifi/model/wifi-phy-operating-channel.cc index ae1c76080..23ad62551 100644 --- a/src/wifi/model/wifi-phy-operating-channel.cc +++ b/src/wifi/model/wifi-phy-operating-channel.cc @@ -20,6 +20,8 @@ #include "wifi-phy-operating-channel.h" +#include "wifi-phy-common.h" + #include "ns3/assert.h" #include "ns3/log.h" @@ -381,7 +383,7 @@ WifiPhyOperatingChannel::FindFirst(uint8_t number, standardIt != wifiStandards.cend() && (std::find(standardIt->second.cbegin(), standardIt->second.cend(), band) == standardIt->second.cend() || - width > GetMaximumChannelWidth(standard))) + width > GetMaximumChannelWidth(GetModulationClassForStandard(standard)))) { return m_frequencyChannels.cend(); } diff --git a/src/wifi/model/wifi-standards.h b/src/wifi/model/wifi-standards.h index 8e1311a0f..fcf6283c4 100644 --- a/src/wifi/model/wifi-standards.h +++ b/src/wifi/model/wifi-standards.h @@ -128,38 +128,6 @@ GetFrequencyChannelType(WifiStandard standard) } } -/** - * Get the maximum channel width in MHz allowed for the given standard. - * - * \param standard the standard - * \return the maximum channel width in MHz allowed for the given standard - */ -inline uint16_t -GetMaximumChannelWidth(WifiStandard standard) -{ - switch (standard) - { - case WIFI_STANDARD_80211b: - return 22; - case WIFI_STANDARD_80211p: - return 10; - case WIFI_STANDARD_80211a: - case WIFI_STANDARD_80211g: - return 20; - case WIFI_STANDARD_80211n: - return 40; - case WIFI_STANDARD_80211ac: - case WIFI_STANDARD_80211ax: - case WIFI_STANDARD_80211be: - return 160; - case WIFI_STANDARD_80211ad: - return 2160; - default: - NS_ABORT_MSG("Unknown standard: " << standard); - return 0; - } -} - /** * Get the default channel width for the given PHY standard and band. * From c50240c097296945c80f90a8c7f81977235e5a74 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Fri, 7 Oct 2022 17:06:22 +0200 Subject: [PATCH 051/494] wifi: Add a PHY method to get the bandwidth of a transmission ...which takes into account the width of the operating channel, the maximum width resulting from the selected modulation class and an additional maximum allowed bandwidth provided as argument. --- src/wifi/model/wifi-phy.cc | 12 ++++++++++++ src/wifi/model/wifi-phy.h | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 1cefc6332..fc5b45aa6 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -1000,6 +1000,18 @@ WifiPhy::HasFixedPhyBand() const return m_fixedPhyBand; } +uint16_t +WifiPhy::GetTxBandwidth(WifiMode mode, uint16_t maxAllowedWidth) +{ + auto modulation = mode.GetModulationClass(); + if (modulation == WIFI_MOD_CLASS_DSSS || modulation == WIFI_MOD_CLASS_HR_DSSS) + { + return 22; + } + + return std::min({GetChannelWidth(), GetMaximumChannelWidth(modulation), maxAllowedWidth}); +} + void WifiPhy::SetOperatingChannel(const ChannelTuple& channelTuple) { diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 0d6ff0521..7836b6e5e 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -28,6 +28,8 @@ #include "ns3/error-model.h" +#include + namespace ns3 { @@ -896,6 +898,17 @@ class WifiPhy : public Object * \return the index of the primary 20 MHz channel */ uint8_t GetPrimary20Index() const; + /** + * Get the bandwidth for a transmission occurring on the current operating channel and + * using the given WifiMode, subject to the constraint that the TX bandwidth cannot exceed + * the given maximum allowed value. + * + * \param mode the given WifiMode + * \param maxAllowedBandWidth the maximum allowed TX bandwidth + * \return the bandwidth for the transmission + */ + uint16_t GetTxBandwidth(WifiMode mode, + uint16_t maxAllowedBandWidth = std::numeric_limits::max()); /** * \param antennas the number of antennas on this node. */ From de079ece9e8a04ca5c390646463918d4bf36278b Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Fri, 7 Oct 2022 17:08:21 +0200 Subject: [PATCH 052/494] wifi: Rate managers use the new WifiPhy::GetTxBandWidth() method --- .../rate-control/constant-rate-wifi-manager.cc | 8 ++++---- src/wifi/model/rate-control/ideal-wifi-manager.cc | 2 +- .../model/rate-control/minstrel-ht-wifi-manager.cc | 6 ++---- .../rate-control/thompson-sampling-wifi-manager.cc | 5 ++--- src/wifi/model/wifi-remote-station-manager.cc | 14 +++++++------- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/wifi/model/rate-control/constant-rate-wifi-manager.cc b/src/wifi/model/rate-control/constant-rate-wifi-manager.cc index 928d1701b..b80d3b33d 100644 --- a/src/wifi/model/rate-control/constant-rate-wifi-manager.cc +++ b/src/wifi/model/rate-control/constant-rate-wifi-manager.cc @@ -25,7 +25,7 @@ #include "ns3/wifi-tx-vector.h" #include "ns3/wifi-utils.h" -#define Min(a, b) ((a < b) ? a : b) +#include namespace ns3 { @@ -127,7 +127,7 @@ WifiTxVector ConstantRateWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - uint8_t nss = Min(GetMaxNumberOfTransmitStreams(), GetNumberOfSupportedStreams(st)); + uint8_t nss = std::min(GetMaxNumberOfTransmitStreams(), GetNumberOfSupportedStreams(st)); if (m_dataMode.GetModulationClass() == WIFI_MOD_CLASS_HT) { nss = 1 + (m_dataMode.GetMcsValue() / 8); @@ -142,7 +142,7 @@ ConstantRateWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allow GetNumberOfAntennas(), nss, 0, - GetChannelWidthForTransmission(m_dataMode, allowedWidth, GetChannelWidth(st)), + GetPhy()->GetTxBandwidth(m_dataMode, std::min(allowedWidth, GetChannelWidth(st))), GetAggregation(st)); } @@ -160,7 +160,7 @@ ConstantRateWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) 1, 1, 0, - GetChannelWidthForTransmission(m_ctlMode, GetPhy()->GetChannelWidth(), GetChannelWidth(st)), + GetPhy()->GetTxBandwidth(m_ctlMode, GetChannelWidth(st)), GetAggregation(st)); } diff --git a/src/wifi/model/rate-control/ideal-wifi-manager.cc b/src/wifi/model/rate-control/ideal-wifi-manager.cc index 47498916a..17ecfd23c 100644 --- a/src/wifi/model/rate-control/ideal-wifi-manager.cc +++ b/src/wifi/model/rate-control/ideal-wifi-manager.cc @@ -571,7 +571,7 @@ IdealWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth GetNumberOfAntennas(), selectedNss, 0, - GetChannelWidthForTransmission(maxMode, channelWidth), + GetPhy()->GetTxBandwidth(maxMode, channelWidth), GetAggregation(station)}; uint64_t maxDataRate = maxMode.GetDataRate(bestTxVector); if (m_currentRate != maxDataRate) diff --git a/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc b/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc index 4682d4236..9086ee810 100644 --- a/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc +++ b/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc @@ -1091,7 +1091,7 @@ MinstrelHtWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowed GetNumberOfAntennas(), group.streams, GetNess(station), - GetChannelWidthForTransmission(mode, group.chWidth), + GetPhy()->GetTxBandwidth(mode, group.chWidth), GetAggregation(station) && !station->m_isSampling}; uint64_t dataRate = mode.GetDataRate(txVector); if (m_currentRate != dataRate && !station->m_isSampling) @@ -1181,9 +1181,7 @@ MinstrelHtWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) 1, 1, 0, - GetChannelWidthForTransmission(rtsRate, - GetPhy()->GetChannelWidth(), - GetChannelWidth(station)), + GetPhy()->GetTxBandwidth(rtsRate, GetChannelWidth(station)), GetAggregation(station)); } } diff --git a/src/wifi/model/rate-control/thompson-sampling-wifi-manager.cc b/src/wifi/model/rate-control/thompson-sampling-wifi-manager.cc index a85d0ca9f..7da0ee9e8 100644 --- a/src/wifi/model/rate-control/thompson-sampling-wifi-manager.cc +++ b/src/wifi/model/rate-control/thompson-sampling-wifi-manager.cc @@ -350,7 +350,7 @@ ThompsonSamplingWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t a GetNumberOfAntennas(), nss, 0, // NESS - GetChannelWidthForTransmission(mode, channelWidth), + GetPhy()->GetTxBandwidth(mode, channelWidth), GetAggregation(station), false); } @@ -365,7 +365,6 @@ ThompsonSamplingWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) // Use the most robust MCS for the control channel. auto& stats = station->m_mcsStats.at(0); WifiMode mode = stats.mode; - uint16_t channelWidth = std::min(stats.channelWidth, GetPhy()->GetChannelWidth()); uint8_t nss = stats.nss; // Make sure control frames are sent using 1 spatial stream. @@ -379,7 +378,7 @@ ThompsonSamplingWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) GetNumberOfAntennas(), nss, 0, // NESS - GetChannelWidthForTransmission(mode, channelWidth), + GetPhy()->GetTxBandwidth(mode, stats.channelWidth), GetAggregation(station), false); } diff --git a/src/wifi/model/wifi-remote-station-manager.cc b/src/wifi/model/wifi-remote-station-manager.cc index 3c7d8907e..0d5a69e14 100644 --- a/src/wifi/model/wifi-remote-station-manager.cc +++ b/src/wifi/model/wifi-remote-station-manager.cc @@ -598,7 +598,7 @@ WifiRemoteStationManager::GetDataTxVector(const WifiMacHeader& header, uint16_t v.SetPreambleType( GetPreambleForTransmission(mode.GetModulationClass(), GetShortPreambleEnabled())); v.SetTxPowerLevel(m_defaultTxPowerLevel); - v.SetChannelWidth(GetChannelWidthForTransmission(mode, allowedWidth)); + v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(mode, allowedWidth)); v.SetGuardInterval(ConvertGuardIntervalToNanoSeconds(mode, m_wifiPhy->GetDevice())); v.SetNTx(GetNumberOfAntennas()); v.SetNss(1); @@ -632,7 +632,7 @@ WifiRemoteStationManager::GetDataTxVector(const WifiMacHeader& header, uint16_t } } - txVector.SetChannelWidth(GetChannelWidthForTransmission(mgtMode, channelWidth)); + txVector.SetChannelWidth(m_wifiPhy->GetTxBandwidth(mgtMode, channelWidth)); txVector.SetGuardInterval( ConvertGuardIntervalToNanoSeconds(mgtMode, m_wifiPhy->GetDevice())); } @@ -691,7 +691,7 @@ WifiRemoteStationManager::GetCtsToSelfTxVector() GetNumberOfAntennas(), 1, 0, - GetChannelWidthForTransmission(defaultMode, m_wifiPhy->GetChannelWidth()), + m_wifiPhy->GetTxBandwidth(defaultMode), false); } @@ -707,7 +707,7 @@ WifiRemoteStationManager::GetRtsTxVector(Mac48Address address) v.SetPreambleType( GetPreambleForTransmission(mode.GetModulationClass(), GetShortPreambleEnabled())); v.SetTxPowerLevel(m_defaultTxPowerLevel); - v.SetChannelWidth(GetChannelWidthForTransmission(mode, m_wifiPhy->GetChannelWidth())); + v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(mode)); v.SetGuardInterval(ConvertGuardIntervalToNanoSeconds(mode, m_wifiPhy->GetDevice())); v.SetNTx(GetNumberOfAntennas()); v.SetNss(1); @@ -727,7 +727,7 @@ WifiRemoteStationManager::GetCtsTxVector(Mac48Address to, WifiMode rtsTxMode) co v.SetPreambleType( GetPreambleForTransmission(ctsMode.GetModulationClass(), GetShortPreambleEnabled())); v.SetTxPowerLevel(GetDefaultTxPowerLevel()); - v.SetChannelWidth(GetChannelWidthForTransmission(ctsMode, m_wifiPhy->GetChannelWidth())); + v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(ctsMode)); uint16_t ctsTxGuardInterval = ConvertGuardIntervalToNanoSeconds(ctsMode, m_wifiPhy->GetDevice()); v.SetGuardInterval(ctsTxGuardInterval); @@ -745,7 +745,7 @@ WifiRemoteStationManager::GetAckTxVector(Mac48Address to, const WifiTxVector& da v.SetPreambleType( GetPreambleForTransmission(ackMode.GetModulationClass(), GetShortPreambleEnabled())); v.SetTxPowerLevel(GetDefaultTxPowerLevel()); - v.SetChannelWidth(GetChannelWidthForTransmission(ackMode, m_wifiPhy->GetChannelWidth())); + v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(ackMode)); uint16_t ackTxGuardInterval = ConvertGuardIntervalToNanoSeconds(ackMode, m_wifiPhy->GetDevice()); v.SetGuardInterval(ackTxGuardInterval); @@ -764,7 +764,7 @@ WifiRemoteStationManager::GetBlockAckTxVector(Mac48Address to, v.SetPreambleType( GetPreambleForTransmission(blockAckMode.GetModulationClass(), GetShortPreambleEnabled())); v.SetTxPowerLevel(GetDefaultTxPowerLevel()); - v.SetChannelWidth(GetChannelWidthForTransmission(blockAckMode, m_wifiPhy->GetChannelWidth())); + v.SetChannelWidth(m_wifiPhy->GetTxBandwidth(blockAckMode)); uint16_t blockAckTxGuardInterval = ConvertGuardIntervalToNanoSeconds(blockAckMode, m_wifiPhy->GetDevice()); v.SetGuardInterval(blockAckTxGuardInterval); From 4705aa9f3b8d54abf44585e9c4f0c6e56a62ee0b Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Fri, 7 Oct 2022 17:09:18 +0200 Subject: [PATCH 053/494] wifi: Remove unused GetChannelWidthForTransmission functions --- src/wifi/model/wifi-phy-common.cc | 32 ------------------------------- src/wifi/model/wifi-phy-common.h | 25 ------------------------ 2 files changed, 57 deletions(-) diff --git a/src/wifi/model/wifi-phy-common.cc b/src/wifi/model/wifi-phy-common.cc index 3784ff167..6253fa942 100644 --- a/src/wifi/model/wifi-phy-common.cc +++ b/src/wifi/model/wifi-phy-common.cc @@ -70,38 +70,6 @@ ConvertGuardIntervalToNanoSeconds(WifiMode mode, bool htShortGuardInterval, Time return gi; } -uint16_t -GetChannelWidthForTransmission(WifiMode mode, uint16_t maxAllowedChannelWidth) -{ - WifiModulationClass modulationClass = mode.GetModulationClass(); - if (maxAllowedChannelWidth > 20 && - (modulationClass == WifiModulationClass::WIFI_MOD_CLASS_OFDM // all non-HT OFDM control and - // management frames - || modulationClass == - WifiModulationClass::WIFI_MOD_CLASS_ERP_OFDM)) // special case of beacons at 2.4 GHz - { - return 20; - } - // at 2.4 GHz basic rate can be non-ERP DSSS - if (modulationClass == WifiModulationClass::WIFI_MOD_CLASS_DSSS || - modulationClass == WifiModulationClass::WIFI_MOD_CLASS_HR_DSSS) - { - return 22; - } - return maxAllowedChannelWidth; -} - -uint16_t -GetChannelWidthForTransmission(WifiMode mode, - uint16_t operatingChannelWidth, - uint16_t maxSupportedChannelWidth) -{ - return GetChannelWidthForTransmission(mode, - (operatingChannelWidth < maxSupportedChannelWidth) - ? operatingChannelWidth - : maxSupportedChannelWidth); -} - WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble) { diff --git a/src/wifi/model/wifi-phy-common.h b/src/wifi/model/wifi-phy-common.h index d7111a07c..6b043fd3e 100644 --- a/src/wifi/model/wifi-phy-common.h +++ b/src/wifi/model/wifi-phy-common.h @@ -475,31 +475,6 @@ uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, */ WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble); -/** - * Return the channel width that is allowed based on the selected mode and the given - * maximum channel width. This is especially useful when using non-HT modes with - * HT/VHT/HE capable stations (with default width above 20 MHz). - * - * \param mode selected WifiMode - * \param maxAllowedChannelWidth maximum channel width allowed for the transmission - * \return channel width adapted to the selected mode - */ -uint16_t GetChannelWidthForTransmission(WifiMode mode, uint16_t maxAllowedChannelWidth); -/** - * Return the channel width that is allowed based on the selected mode, the current - * width of the operating channel and the maximum channel width supported by the - * receiver. This is especially useful when using non-HT modes with HT/VHT/HE - * capable stations (with default width above 20 MHz). - * - * \param mode selected WifiMode - * \param operatingChannelWidth operating channel width - * \param maxSupportedChannelWidth maximum channel width supported by the receiver - * \return channel width adapted to the selected mode - */ -uint16_t GetChannelWidthForTransmission(WifiMode mode, - uint16_t operatingChannelWidth, - uint16_t maxSupportedChannelWidth); - /** * Return whether the modulation class of the selected mode for the * control answer frame is allowed. From b1bf40f4093529b0c3b1c509ed2936a88ac22bc8 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Wed, 2 Nov 2022 11:51:50 +0100 Subject: [PATCH 054/494] wifi: Fix guard interval for BlockAck frames sent in TB PPDUs --- src/wifi/model/wifi-default-ack-manager.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wifi/model/wifi-default-ack-manager.cc b/src/wifi/model/wifi-default-ack-manager.cc index be58047ae..e4049b914 100644 --- a/src/wifi/model/wifi-default-ack-manager.cc +++ b/src/wifi/model/wifi-default-ack-manager.cc @@ -518,7 +518,9 @@ WifiDefaultAckManager::GetAckInfoIfTfMuBar(Ptr mpdu, WifiTxVector blockAckTxVector; blockAckTxVector.SetPreambleType(WifiPreamble::WIFI_PREAMBLE_HE_TB); blockAckTxVector.SetChannelWidth(txParams.m_txVector.GetChannelWidth()); - blockAckTxVector.SetGuardInterval(txParams.m_txVector.GetGuardInterval()); + // 800ns GI is not allowed for HE TB + blockAckTxVector.SetGuardInterval( + std::max(txParams.m_txVector.GetGuardInterval(), 1600)); const auto& userInfo = txParams.m_txVector.GetHeMuUserInfo(staId); blockAckTxVector.SetHeMuUserInfo( staId, @@ -602,7 +604,9 @@ WifiDefaultAckManager::GetAckInfoIfAggregatedMuBar(Ptr mpdu, WifiTxVector blockAckTxVector; blockAckTxVector.SetPreambleType(WifiPreamble::WIFI_PREAMBLE_HE_TB); blockAckTxVector.SetChannelWidth(txParams.m_txVector.GetChannelWidth()); - blockAckTxVector.SetGuardInterval(txParams.m_txVector.GetGuardInterval()); + // 800ns GI is not allowed for HE TB + blockAckTxVector.SetGuardInterval( + std::max(txParams.m_txVector.GetGuardInterval(), 1600)); const auto& userInfo = txParams.m_txVector.GetHeMuUserInfo(staId); blockAckTxVector.SetHeMuUserInfo( staId, From 6f67d61683b35312bfc04709b9b9552ecb9bff90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Tue, 27 Sep 2022 22:50:10 +0200 Subject: [PATCH 055/494] wifi: Do not allow HE TB with 800ns guard interval --- src/wifi/model/he/he-phy.cc | 3 +++ src/wifi/test/wifi-phy-ofdma-test.cc | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index f41257cd4..995144281 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -321,6 +321,9 @@ HePhy::GetSymbolDuration(const WifiTxVector& txVector) const void HePhy::SetTrigVector(const WifiTxVector& trigVector, Time validity) { + NS_LOG_FUNCTION(this << trigVector << validity); + NS_ASSERT_MSG(trigVector.GetGuardInterval() > 800, + "Invalid guard interval " << trigVector.GetGuardInterval()); m_trigVector = trigVector; m_trigVectorExpirationTime = Simulator::Now() + validity; NS_LOG_FUNCTION(this << m_trigVector << m_trigVectorExpirationTime.As(Time::US)); diff --git a/src/wifi/test/wifi-phy-ofdma-test.cc b/src/wifi/test/wifi-phy-ofdma-test.cc index 8bbb973a6..1eccf9767 100644 --- a/src/wifi/test/wifi-phy-ofdma-test.cc +++ b/src/wifi/test/wifi-phy-ofdma-test.cc @@ -2109,7 +2109,7 @@ TestUlOfdmaPpduUid::SendTbPpdu() WifiTxVector txVector1 = WifiTxVector(HePhy::GetHeMcs7(), 0, WIFI_PREAMBLE_HE_TB, - 800, + 1600, 1, 1, 0, @@ -2329,7 +2329,7 @@ TestMultipleHeTbPreambles::TestMultipleHeTbPreambles() m_trigVector(HePhy::GetHeMcs7(), 0, WIFI_PREAMBLE_HE_TB, - 800, + 1600, 1, 1, 0, @@ -2394,7 +2394,7 @@ TestMultipleHeTbPreambles::RxHeTbPpdu(uint64_t uid, WifiTxVector txVector = WifiTxVector(HePhy::GetHeMcs7(), 0, WIFI_PREAMBLE_HE_TB, - 800, + 1600, 1, 1, 0, @@ -3271,7 +3271,7 @@ TestUlOfdmaPhyTransmission::GetTxVectorForHeTbPpdu(uint16_t txStaId, WifiTxVector txVector = WifiTxVector(HePhy::GetHeMcs7(), 0, WIFI_PREAMBLE_HE_TB, - 800, + 1600, 1, 1, 0, @@ -3328,7 +3328,7 @@ TestUlOfdmaPhyTransmission::SetTrigVector(uint8_t bssColor, TrigVectorInfo error WifiTxVector txVector(HePhy::GetHeMcs7(), 0, WIFI_PREAMBLE_HE_TB, - 800, + 1600, 1, 1, 0, @@ -4755,25 +4755,25 @@ TestUlOfdmaPhyTransmission::DoRun() { m_frequency = 5180; m_channelWidth = 20; - m_expectedPpduDuration = NanoSeconds(279200); + m_expectedPpduDuration = NanoSeconds(292800); NS_LOG_DEBUG("Run UL OFDMA PHY transmission test for " << m_channelWidth << " MHz"); RunOne(); m_frequency = 5190; m_channelWidth = 40; - m_expectedPpduDuration = NanoSeconds(156800); + m_expectedPpduDuration = NanoSeconds(163200); NS_LOG_DEBUG("Run UL OFDMA PHY transmission test for " << m_channelWidth << " MHz"); RunOne(); m_frequency = 5210; m_channelWidth = 80; - m_expectedPpduDuration = NanoSeconds(102400); + m_expectedPpduDuration = NanoSeconds(105600); NS_LOG_DEBUG("Run UL OFDMA PHY transmission test for " << m_channelWidth << " MHz"); RunOne(); m_frequency = 5250; m_channelWidth = 160; - m_expectedPpduDuration = NanoSeconds(75200); + m_expectedPpduDuration = NanoSeconds(76800); NS_LOG_DEBUG("Run UL OFDMA PHY transmission test for " << m_channelWidth << " MHz"); RunOne(); @@ -4924,7 +4924,7 @@ TestPhyPaddingExclusion::SendHeTbPpdu(uint16_t txStaId, WifiTxVector txVector = WifiTxVector(HePhy::GetHeMcs7(), 0, WIFI_PREAMBLE_HE_TB, - 800, + 1600, 1, 1, 0, @@ -5223,7 +5223,7 @@ TestPhyPaddingExclusion::SetTrigVector(Time ppduDuration) WifiTxVector trigVector(HePhy::GetHeMcs7(), 0, WIFI_PREAMBLE_HE_TB, - 800, + 1600, 1, 1, 0, @@ -5248,9 +5248,9 @@ TestPhyPaddingExclusion::SetTrigVector(Time ppduDuration) void TestPhyPaddingExclusion::DoRun() { - Time expectedPpduDuration = NanoSeconds(279200); + Time expectedPpduDuration = NanoSeconds(292800); Time ppduWithPaddingDuration = - expectedPpduDuration + 10 * NanoSeconds(12800 + 800 /* GI */); // add 10 extra OFDM symbols + expectedPpduDuration + 10 * NanoSeconds(12800 + 1600 /* GI */); // add 10 extra OFDM symbols Simulator::Schedule(Seconds(0.0), &TestPhyPaddingExclusion::Reset, this); From 68200622ef0d4ef1233666cdcb24f6ed10dddcf4 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Fri, 18 Nov 2022 09:17:30 +0100 Subject: [PATCH 056/494] wifi: Fix 6 GHz band starting frequency for RNR element --- src/wifi/model/reduced-neighbor-report.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wifi/model/reduced-neighbor-report.cc b/src/wifi/model/reduced-neighbor-report.cc index 04da04b4b..991500513 100644 --- a/src/wifi/model/reduced-neighbor-report.cc +++ b/src/wifi/model/reduced-neighbor-report.cc @@ -179,7 +179,7 @@ ReducedNeighborReport::SetOperatingChannel(std::size_t nbrApInfoId, startingFreq = 5000; break; case WIFI_PHY_BAND_6GHZ: - startingFreq = 5940; + startingFreq = 5950; break; case WIFI_PHY_BAND_UNSPECIFIED: default: @@ -267,7 +267,7 @@ ReducedNeighborReport::GetOperatingChannel(std::size_t nbrApInfoId) const startingFreq = 5000; break; case WIFI_PHY_BAND_6GHZ: - startingFreq = 5940; + startingFreq = 5950; break; case WIFI_PHY_BAND_UNSPECIFIED: default: From 83f6edb44e38174dfcc5e9986c0f8b69393fcebd Mon Sep 17 00:00:00 2001 From: Wouter Overmeire Date: Fri, 18 Nov 2022 14:28:41 +0100 Subject: [PATCH 057/494] tcp: Fix documentation typo --- src/internet/doc/tcp.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internet/doc/tcp.rst b/src/internet/doc/tcp.rst index 5e27ef941..dbb6530c1 100644 --- a/src/internet/doc/tcp.rst +++ b/src/internet/doc/tcp.rst @@ -2158,7 +2158,7 @@ and then, hit "Run". .. note:: This code magically runs without any reported errors; however, in real cases, when you discover a bug you should expect the existing test to fail (this - could indicate a well-written test and a bad-writted model, or a bad-written + could indicate a well-written test and a bad-written model, or a bad-written test; hopefully the first situation). Correcting bugs is an iterative process. For instance, commits created to make this test case running without errors are 11633:6b74df04cf44, (others to be merged). From 33b9f5fe7a1b6e2a03fd2c9a63d86dd52dabfac2 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Sat, 19 Nov 2022 23:53:25 +0000 Subject: [PATCH 058/494] internet: Fix non-standard use of ternary operator --- src/internet/model/tcp-bbr.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/internet/model/tcp-bbr.cc b/src/internet/model/tcp-bbr.cc index 47c5868f5..d8aba806d 100644 --- a/src/internet/model/tcp-bbr.cc +++ b/src/internet/model/tcp-bbr.cc @@ -409,7 +409,9 @@ void TcpBbr::HandleProbeRTT(Ptr tcb) { NS_LOG_FUNCTION(this << tcb); - m_appLimited = (m_delivered + tcb->m_bytesInFlight.Get()) ?: 1; + + uint32_t totalBytes = m_delivered + tcb->m_bytesInFlight.Get(); + m_appLimited = (totalBytes > 0 ? totalBytes : 1); if (m_probeRttDoneStamp == Seconds(0) && tcb->m_bytesInFlight <= m_minPipeCwnd) { From 00771216497ba886f333de72c3a2b1745784ad21 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Sun, 13 Nov 2022 11:21:42 +0100 Subject: [PATCH 059/494] internet: (fixes #579) remove TcpWestwood model --- CHANGES.md | 1 + RELEASE_NOTES.md | 1 + examples/tcp/tcp-linux-reno.cc | 20 ++--- examples/tcp/tcp-variants-comparison.cc | 24 ++--- examples/wireless/wifi-tcp.cc | 22 ++--- src/internet/CMakeLists.txt | 4 +- src/internet/doc/tcp.rst | 6 ++ .../{tcp-westwood.cc => tcp-westwood-plus.cc} | 90 +++++++------------ .../{tcp-westwood.h => tcp-westwood-plus.h} | 26 ++---- src/internet/test/tcp-fast-retr-test.cc | 4 +- src/test/ns3tcp/ns3tcp-loss-test-suite.cc | 22 +---- 11 files changed, 72 insertions(+), 148 deletions(-) rename src/internet/model/{tcp-westwood.cc => tcp-westwood-plus.cc} (54%) rename src/internet/model/{tcp-westwood.h => tcp-westwood-plus.h} (86%) diff --git a/CHANGES.md b/CHANGES.md index d80e4479c..dec7c4482 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -23,6 +23,7 @@ Changes from ns-3.37 to ns-3.38 ### Changes to existing API * (network) **Ipv4Address** and **Ipv6Address** now do not raise an exception if built from an invalid string. Instead the address is marked as not initialized. +* (internet) TCP Westwood model has been removed due to a bug in BW estimation documented in https://gitlab.com/nsnam/ns-3-dev/-/issues/579. The TCP Westwood+ model is now named **TcpWestwoodPlus** and can be instantiated like all the other TCP flavors. ### Changes to build system diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index adf8499da..c70d57bd4 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -20,6 +20,7 @@ Release 3-dev - (network) !938 - Add class `TimestampTag` for associating a timestamp with a packet. - (network) !1163 Initializing an Ipv[4,6]Address from an invalid string do not raise an exception anymore. Instead the address is marked as not initialized. +- (internet) !1186 `TcpWestwood` model has been removed, and the class has been renamed `TcpWestwoodPlus`. ### Bugs fixed diff --git a/examples/tcp/tcp-linux-reno.cc b/examples/tcp/tcp-linux-reno.cc index e617b6aee..96978f00c 100644 --- a/examples/tcp/tcp-linux-reno.cc +++ b/examples/tcp/tcp-linux-reno.cc @@ -152,21 +152,11 @@ main(int argc, char* argv[]) // Set recovery algorithm and TCP variant Config::SetDefault("ns3::TcpL4Protocol::RecoveryType", TypeIdValue(TypeId::LookupByName(recovery))); - if (tcpTypeId == "ns3::TcpWestwoodPlus") - { - // TcpWestwoodPlus is not an actual TypeId name; we need TcpWestwood here - Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue(TcpWestwood::GetTypeId())); - // the default protocol type in ns3::TcpWestwood is WESTWOOD - Config::SetDefault("ns3::TcpWestwood::ProtocolType", EnumValue(TcpWestwood::WESTWOODPLUS)); - } - else - { - TypeId tcpTid; - NS_ABORT_MSG_UNLESS(TypeId::LookupByNameFailSafe(tcpTypeId, &tcpTid), - "TypeId " << tcpTypeId << " not found"); - Config::SetDefault("ns3::TcpL4Protocol::SocketType", - TypeIdValue(TypeId::LookupByName(tcpTypeId))); - } + TypeId tcpTid; + NS_ABORT_MSG_UNLESS(TypeId::LookupByNameFailSafe(tcpTypeId, &tcpTid), + "TypeId " << tcpTypeId << " not found"); + Config::SetDefault("ns3::TcpL4Protocol::SocketType", + TypeIdValue(TypeId::LookupByName(tcpTypeId))); // Create nodes NodeContainer leftNodes; diff --git a/examples/tcp/tcp-variants-comparison.cc b/examples/tcp/tcp-variants-comparison.cc index e987a7b08..e35ed8433 100644 --- a/examples/tcp/tcp-variants-comparison.cc +++ b/examples/tcp/tcp-variants-comparison.cc @@ -342,7 +342,7 @@ TraceNextRx(std::string& next_rx_seq_file_name, uint32_t nodeId) int main(int argc, char* argv[]) { - std::string transport_prot = "TcpWestwood"; + std::string transport_prot = "TcpWestwoodPlus"; double error_p = 0.0; std::string bandwidth = "2Mbps"; std::string delay = "0.01ms"; @@ -365,7 +365,7 @@ main(int argc, char* argv[]) cmd.AddValue("transport_prot", "Transport protocol to use: TcpNewReno, TcpLinuxReno, " "TcpHybla, TcpHighSpeed, TcpHtcp, TcpVegas, TcpScalable, TcpVeno, " - "TcpBic, TcpYeah, TcpIllinois, TcpWestwood, TcpWestwoodPlus, TcpLedbat, " + "TcpBic, TcpYeah, TcpIllinois, TcpWestwoodPlus, TcpLedbat, " "TcpLp, TcpDctcp, TcpCubic, TcpBbr", transport_prot); cmd.AddValue("error_p", "Packet error rate", error_p); @@ -423,21 +423,11 @@ main(int argc, char* argv[]) Config::SetDefault("ns3::TcpL4Protocol::RecoveryType", TypeIdValue(TypeId::LookupByName(recovery))); // Select TCP variant - if (transport_prot == "ns3::TcpWestwoodPlus") - { - // TcpWestwoodPlus is not an actual TypeId name; we need TcpWestwood here - Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue(TcpWestwood::GetTypeId())); - // the default protocol type in ns3::TcpWestwood is WESTWOOD - Config::SetDefault("ns3::TcpWestwood::ProtocolType", EnumValue(TcpWestwood::WESTWOODPLUS)); - } - else - { - TypeId tcpTid; - NS_ABORT_MSG_UNLESS(TypeId::LookupByNameFailSafe(transport_prot, &tcpTid), - "TypeId " << transport_prot << " not found"); - Config::SetDefault("ns3::TcpL4Protocol::SocketType", - TypeIdValue(TypeId::LookupByName(transport_prot))); - } + TypeId tcpTid; + NS_ABORT_MSG_UNLESS(TypeId::LookupByNameFailSafe(transport_prot, &tcpTid), + "TypeId " << transport_prot << " not found"); + Config::SetDefault("ns3::TcpL4Protocol::SocketType", + TypeIdValue(TypeId::LookupByName(transport_prot))); // Create gateways, sources, and sinks NodeContainer gateways; diff --git a/examples/wireless/wifi-tcp.cc b/examples/wireless/wifi-tcp.cc index 125e8f476..38c2f0847 100644 --- a/examples/wireless/wifi-tcp.cc +++ b/examples/wireless/wifi-tcp.cc @@ -44,7 +44,7 @@ #include "ns3/packet-sink.h" #include "ns3/ssid.h" #include "ns3/string.h" -#include "ns3/tcp-westwood.h" +#include "ns3/tcp-westwood-plus.h" #include "ns3/yans-wifi-channel.h" #include "ns3/yans-wifi-helper.h" @@ -95,21 +95,11 @@ main(int argc, char* argv[]) tcpVariant = std::string("ns3::") + tcpVariant; // Select TCP variant - if (tcpVariant == "ns3::TcpWestwoodPlus") - { - // TcpWestwoodPlus is not an actual TypeId name; we need TcpWestwood here - Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue(TcpWestwood::GetTypeId())); - // the default protocol type in ns3::TcpWestwood is WESTWOOD - Config::SetDefault("ns3::TcpWestwood::ProtocolType", EnumValue(TcpWestwood::WESTWOODPLUS)); - } - else - { - TypeId tcpTid; - NS_ABORT_MSG_UNLESS(TypeId::LookupByNameFailSafe(tcpVariant, &tcpTid), - "TypeId " << tcpVariant << " not found"); - Config::SetDefault("ns3::TcpL4Protocol::SocketType", - TypeIdValue(TypeId::LookupByName(tcpVariant))); - } + TypeId tcpTid; + NS_ABORT_MSG_UNLESS(TypeId::LookupByNameFailSafe(tcpVariant, &tcpTid), + "TypeId " << tcpVariant << " not found"); + Config::SetDefault("ns3::TcpL4Protocol::SocketType", + TypeIdValue(TypeId::LookupByName(tcpVariant))); /* Configure TCP Options */ Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(payloadSize)); diff --git a/src/internet/CMakeLists.txt b/src/internet/CMakeLists.txt index bd2840e7c..35ac7691b 100644 --- a/src/internet/CMakeLists.txt +++ b/src/internet/CMakeLists.txt @@ -118,7 +118,7 @@ set(source_files model/tcp-tx-item.cc model/tcp-vegas.cc model/tcp-veno.cc - model/tcp-westwood.cc + model/tcp-westwood-plus.cc model/tcp-yeah.cc model/udp-header.cc model/udp-l4-protocol.cc @@ -243,7 +243,7 @@ set(header_files model/tcp-tx-item.h model/tcp-vegas.h model/tcp-veno.h - model/tcp-westwood.h + model/tcp-westwood-plus.h model/tcp-yeah.h model/udp-header.h model/udp-l4-protocol.h diff --git a/src/internet/doc/tcp.rst b/src/internet/doc/tcp.rst index dbb6530c1..f2cc4e4e5 100644 --- a/src/internet/doc/tcp.rst +++ b/src/internet/doc/tcp.rst @@ -554,6 +554,12 @@ bandwidth and use the estimated value to adjust the cwnd. While Westwood performs the bandwidth sampling every ACK reception, Westwood+ samples the bandwidth every RTT. +The TCP Westwood model has been removed in ns-3.38 due to bugs that are impossible +to fix without modifying the original Westwood model as presented in the published papers. +For further info refer to https://gitlab.com/nsnam/ns-3-dev/-/issues/579 + +The Westwood+ model does not have such issues, and is still available. + WARNING: this TCP model lacks validation and regression tests; use with caution. More information at: http://dl.acm.org/citation.cfm?id=381704 and diff --git a/src/internet/model/tcp-westwood.cc b/src/internet/model/tcp-westwood-plus.cc similarity index 54% rename from src/internet/model/tcp-westwood.cc rename to src/internet/model/tcp-westwood-plus.cc index 47d19711c..353bd3a76 100644 --- a/src/internet/model/tcp-westwood.cc +++ b/src/internet/model/tcp-westwood-plus.cc @@ -30,7 +30,7 @@ * US Department of Defense (DoD), and ITTC at The University of Kansas. */ -#include "tcp-westwood.h" +#include "tcp-westwood-plus.h" #include "rtt-estimator.h" #include "tcp-socket-base.h" @@ -38,42 +38,35 @@ #include "ns3/log.h" #include "ns3/simulator.h" -NS_LOG_COMPONENT_DEFINE("TcpWestwood"); +NS_LOG_COMPONENT_DEFINE("TcpWestwoodPlus"); namespace ns3 { -NS_OBJECT_ENSURE_REGISTERED(TcpWestwood); +NS_OBJECT_ENSURE_REGISTERED(TcpWestwoodPlus); TypeId -TcpWestwood::GetTypeId() +TcpWestwoodPlus::GetTypeId() { static TypeId tid = - TypeId("ns3::TcpWestwood") + TypeId("ns3::TcpWestwoodPlus") .SetParent() .SetGroupName("Internet") - .AddConstructor() - .AddAttribute("FilterType", - "Use this to choose no filter or Tustin's approximation filter", - EnumValue(TcpWestwood::TUSTIN), - MakeEnumAccessor(&TcpWestwood::m_fType), - MakeEnumChecker(TcpWestwood::NONE, "None", TcpWestwood::TUSTIN, "Tustin")) - .AddAttribute("ProtocolType", - "Use this to let the code run as Westwood or WestwoodPlus", - EnumValue(TcpWestwood::WESTWOOD), - MakeEnumAccessor(&TcpWestwood::m_pType), - MakeEnumChecker(TcpWestwood::WESTWOOD, - "Westwood", - TcpWestwood::WESTWOODPLUS, - "WestwoodPlus")) + .AddConstructor() + .AddAttribute( + "FilterType", + "Use this to choose no filter or Tustin's approximation filter", + EnumValue(TcpWestwoodPlus::TUSTIN), + MakeEnumAccessor(&TcpWestwoodPlus::m_fType), + MakeEnumChecker(TcpWestwoodPlus::NONE, "None", TcpWestwoodPlus::TUSTIN, "Tustin")) .AddTraceSource("EstimatedBW", "The estimated bandwidth", - MakeTraceSourceAccessor(&TcpWestwood::m_currentBW), + MakeTraceSourceAccessor(&TcpWestwoodPlus::m_currentBW), "ns3::TracedValueCallback::DataRate"); return tid; } -TcpWestwood::TcpWestwood() +TcpWestwoodPlus::TcpWestwoodPlus() : TcpNewReno(), m_currentBW(0), m_lastSampleBW(0), @@ -85,12 +78,11 @@ TcpWestwood::TcpWestwood() NS_LOG_FUNCTION(this); } -TcpWestwood::TcpWestwood(const TcpWestwood& sock) +TcpWestwoodPlus::TcpWestwoodPlus(const TcpWestwoodPlus& sock) : TcpNewReno(sock), m_currentBW(sock.m_currentBW), m_lastSampleBW(sock.m_lastSampleBW), m_lastBW(sock.m_lastBW), - m_pType(sock.m_pType), m_fType(sock.m_fType), m_IsCount(sock.m_IsCount) { @@ -98,12 +90,12 @@ TcpWestwood::TcpWestwood(const TcpWestwood& sock) NS_LOG_LOGIC("Invoked the copy constructor"); } -TcpWestwood::~TcpWestwood() +TcpWestwoodPlus::~TcpWestwoodPlus() { } void -TcpWestwood::PktsAcked(Ptr tcb, uint32_t packetsAcked, const Time& rtt) +TcpWestwoodPlus::PktsAcked(Ptr tcb, uint32_t packetsAcked, const Time& rtt) { NS_LOG_FUNCTION(this << tcb << packetsAcked << rtt); @@ -115,45 +107,23 @@ TcpWestwood::PktsAcked(Ptr tcb, uint32_t packetsAcked, const Tim m_ackedSegments += packetsAcked; - if (m_pType == TcpWestwood::WESTWOOD) + if (!(rtt.IsZero() || m_IsCount)) { - EstimateBW(rtt, tcb); - } - else if (m_pType == TcpWestwood::WESTWOODPLUS) - { - if (!(rtt.IsZero() || m_IsCount)) - { - m_IsCount = true; - m_bwEstimateEvent.Cancel(); - m_bwEstimateEvent = Simulator::Schedule(rtt, &TcpWestwood::EstimateBW, this, rtt, tcb); - } + m_IsCount = true; + m_bwEstimateEvent.Cancel(); + m_bwEstimateEvent = Simulator::Schedule(rtt, &TcpWestwoodPlus::EstimateBW, this, rtt, tcb); } } void -TcpWestwood::EstimateBW(const Time& rtt, Ptr tcb) +TcpWestwoodPlus::EstimateBW(const Time& rtt, Ptr tcb) { NS_LOG_FUNCTION(this); NS_ASSERT(!rtt.IsZero()); - if (m_pType == TcpWestwood::WESTWOOD) - { - Time currentAck = Simulator::Now(); - - NS_ABORT_MSG_IF(currentAck == m_lastAck, - "This violates a model assumption and would lead to divide-by-zero; please " - "report to ns-3 maintainers if this occurs."); - - m_currentBW = DataRate(m_ackedSegments * tcb->m_segmentSize * 8.0 / - (currentAck - m_lastAck).GetSeconds()); - m_lastAck = currentAck; - } - else if (m_pType == TcpWestwood::WESTWOODPLUS) - { - m_currentBW = DataRate(m_ackedSegments * tcb->m_segmentSize * 8.0 / rtt.GetSeconds()); - m_IsCount = false; - } + m_currentBW = DataRate(m_ackedSegments * tcb->m_segmentSize * 8.0 / rtt.GetSeconds()); + m_IsCount = false; m_ackedSegments = 0; @@ -161,12 +131,12 @@ TcpWestwood::EstimateBW(const Time& rtt, Ptr tcb) // Filter the BW sample - constexpr double alpha = 0.9; + constexpr double ALPHA = 0.9; - if (m_fType == TcpWestwood::TUSTIN) + if (m_fType == TcpWestwoodPlus::TUSTIN) { DataRate sample_bwe = m_currentBW; - m_currentBW = (m_lastBW * alpha) + (((sample_bwe + m_lastSampleBW) * 0.5) * (1 - alpha)); + m_currentBW = (m_lastBW * ALPHA) + (((sample_bwe + m_lastSampleBW) * 0.5) * (1 - ALPHA)); m_lastSampleBW = sample_bwe; m_lastBW = m_currentBW; } @@ -175,7 +145,7 @@ TcpWestwood::EstimateBW(const Time& rtt, Ptr tcb) } uint32_t -TcpWestwood::GetSsThresh(Ptr tcb, uint32_t bytesInFlight [[maybe_unused]]) +TcpWestwoodPlus::GetSsThresh(Ptr tcb, uint32_t bytesInFlight [[maybe_unused]]) { uint32_t ssThresh = static_cast((m_currentBW * tcb->m_minRtt) / 8.0); @@ -186,9 +156,9 @@ TcpWestwood::GetSsThresh(Ptr tcb, uint32_t bytesInFlight [ } Ptr -TcpWestwood::Fork() +TcpWestwoodPlus::Fork() { - return CreateObject(*this); + return CreateObject(*this); } } // namespace ns3 diff --git a/src/internet/model/tcp-westwood.h b/src/internet/model/tcp-westwood-plus.h similarity index 86% rename from src/internet/model/tcp-westwood.h rename to src/internet/model/tcp-westwood-plus.h index 69cc5a73f..0518d196b 100644 --- a/src/internet/model/tcp-westwood.h +++ b/src/internet/model/tcp-westwood-plus.h @@ -47,9 +47,9 @@ class Time; /** * \ingroup congestionOps * - * \brief An implementation of TCP Westwood and Westwood+. + * \brief An implementation of TCP Westwood+. * - * Westwood and Westwood+ employ the AIAD (Additive Increase/Adaptive Decrease) + * Westwood+ employ the AIAD (Additive Increase/Adaptive Decrease) * congestion control paradigm. When a congestion episode happens, * instead of halving the cwnd, these protocols try to estimate the network's * bandwidth and use the estimated value to adjust the cwnd. @@ -60,11 +60,11 @@ class Time; * and the EstimateBW (int, const, Time). The CountAck method calculates * the number of acknowledged segments on the receipt of an ACK. * The EstimateBW estimates the bandwidth based on the value returned by CountAck - * and the sampling interval (last ACK inter-arrival time for Westwood and last RTT for Westwood+). + * and the sampling interval (last RTT). * * WARNING: this TCP model lacks validation and regression tests; use with caution. */ -class TcpWestwood : public TcpNewReno +class TcpWestwoodPlus : public TcpNewReno { public: /** @@ -73,22 +73,13 @@ class TcpWestwood : public TcpNewReno */ static TypeId GetTypeId(); - TcpWestwood(); + TcpWestwoodPlus(); /** * \brief Copy constructor * \param sock the object to copy */ - TcpWestwood(const TcpWestwood& sock); - ~TcpWestwood() override; - - /** - * \brief Protocol variant (Westwood or Westwood+) - */ - enum ProtocolType - { - WESTWOOD, - WESTWOODPLUS - }; + TcpWestwoodPlus(const TcpWestwoodPlus& sock); + ~TcpWestwoodPlus() override; /** * \brief Filter type (None or Tustin) @@ -125,8 +116,7 @@ class TcpWestwood : public TcpNewReno TracedValue m_currentBW; //!< Current value of the estimated BW DataRate m_lastSampleBW; //!< Last bandwidth sample DataRate m_lastBW; //!< Last bandwidth sample after being filtered - enum ProtocolType m_pType; //!< 0 for Westwood, 1 for Westwood+ - enum FilterType m_fType; //!< 0 for none, 1 for Tustin + FilterType m_fType; //!< 0 for none, 1 for Tustin uint32_t m_ackedSegments; //!< The number of segments ACKed between RTTs bool m_IsCount; //!< Start keeping track of m_ackedSegments for Westwood+ if TRUE diff --git a/src/internet/test/tcp-fast-retr-test.cc b/src/internet/test/tcp-fast-retr-test.cc index 233ff9f03..2c03103f7 100644 --- a/src/internet/test/tcp-fast-retr-test.cc +++ b/src/internet/test/tcp-fast-retr-test.cc @@ -21,7 +21,7 @@ #include "ns3/log.h" #include "ns3/node.h" #include "ns3/simple-channel.h" -#include "ns3/tcp-westwood.h" +#include "ns3/tcp-westwood-plus.h" using namespace ns3; @@ -442,7 +442,7 @@ class TcpFastRetrTestSuite : public TestSuite : TestSuite("tcp-fast-retr-test", UNIT) { std::list types; - types.insert(types.begin(), TcpWestwood::GetTypeId()); + types.insert(types.begin(), TcpWestwoodPlus::GetTypeId()); types.insert(types.begin(), TcpNewReno::GetTypeId()); for (std::list::iterator it = types.begin(); it != types.end(); ++it) diff --git a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc b/src/test/ns3tcp/ns3tcp-loss-test-suite.cc index f7f82bd60..22514f685 100644 --- a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc +++ b/src/test/ns3tcp/ns3tcp-loss-test-suite.cc @@ -35,7 +35,7 @@ #include "ns3/string.h" #include "ns3/tcp-header.h" #include "ns3/tcp-socket-factory.h" -#include "ns3/tcp-westwood.h" +#include "ns3/tcp-westwood-plus.h" #include "ns3/test.h" #include "ns3/uinteger.h" @@ -146,7 +146,7 @@ Ns3TcpLossTestCase::Ns3TcpLossTestCase() m_writeResults(WRITE_PCAP), m_writeLogging(WRITE_LOGGING), m_needToClose(true), - m_tcpModel("ns3::TcpWestwood") + m_tcpModel("ns3::TcpWestwoodPlus") { } @@ -351,15 +351,7 @@ Ns3TcpLossTestCase::DoRun() std::ostringstream tcpModel; tcpModel << "ns3::Tcp" << m_tcpModel; - if (m_tcpModel == "WestwoodPlus") - { - Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue(TcpWestwood::GetTypeId())); - Config::SetDefault("ns3::TcpWestwood::ProtocolType", EnumValue(TcpWestwood::WESTWOODPLUS)); - } - else - { - Config::SetDefault("ns3::TcpL4Protocol::SocketType", StringValue(tcpModel.str())); - } + Config::SetDefault("ns3::TcpL4Protocol::SocketType", StringValue(tcpModel.str())); Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(1000)); Config::SetDefault("ns3::TcpSocket::DelAckCount", UintegerValue(1)); @@ -370,7 +362,7 @@ Ns3TcpLossTestCase::DoRun() LogComponentEnableAll(LOG_PREFIX_FUNC); LogComponentEnable("Ns3TcpLossTest", LOG_LEVEL_ALL); LogComponentEnable("ErrorModel", LOG_LEVEL_DEBUG); - LogComponentEnable("TcpWestwood", LOG_LEVEL_ALL); + LogComponentEnable("TcpWestwoodPlus", LOG_LEVEL_ALL); LogComponentEnable("TcpCongestionOps", LOG_LEVEL_INFO); LogComponentEnable("TcpSocketBase", LOG_LEVEL_INFO); } @@ -530,12 +522,6 @@ Ns3TcpLossTestSuite::Ns3TcpLossTestSuite() AddTestCase(new Ns3TcpLossTestCase("NewReno", 3), TestCase::QUICK); AddTestCase(new Ns3TcpLossTestCase("NewReno", 4), TestCase::QUICK); - AddTestCase(new Ns3TcpLossTestCase("Westwood", 0), TestCase::QUICK); - AddTestCase(new Ns3TcpLossTestCase("Westwood", 1), TestCase::QUICK); - AddTestCase(new Ns3TcpLossTestCase("Westwood", 2), TestCase::QUICK); - AddTestCase(new Ns3TcpLossTestCase("Westwood", 3), TestCase::QUICK); - AddTestCase(new Ns3TcpLossTestCase("Westwood", 4), TestCase::QUICK); - AddTestCase(new Ns3TcpLossTestCase("WestwoodPlus", 0), TestCase::QUICK); AddTestCase(new Ns3TcpLossTestCase("WestwoodPlus", 1), TestCase::QUICK); AddTestCase(new Ns3TcpLossTestCase("WestwoodPlus", 2), TestCase::QUICK); From fd6188871dc4688b721b458555a000cc08077d8c Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Sat, 19 Nov 2022 20:31:18 +0000 Subject: [PATCH 060/494] traffic-control: Remove the protocol parameter from cobalt test suite Defaults to 0, similarly to the other test suites --- .../test/cobalt-queue-disc-test-suite.cc | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/traffic-control/test/cobalt-queue-disc-test-suite.cc b/src/traffic-control/test/cobalt-queue-disc-test-suite.cc index f7c313cb4..58693077d 100644 --- a/src/traffic-control/test/cobalt-queue-disc-test-suite.cc +++ b/src/traffic-control/test/cobalt-queue-disc-test-suite.cc @@ -46,10 +46,9 @@ class CobaltQueueDiscTestItem : public QueueDiscItem * * \param p packet * \param addr address - * \param protocol protocol * \param ecnCapable ECN capable */ - CobaltQueueDiscTestItem(Ptr p, const Address& addr, uint16_t protocol, bool ecnCapable); + CobaltQueueDiscTestItem(Ptr p, const Address& addr, bool ecnCapable); ~CobaltQueueDiscTestItem() override; // Delete default constructor, copy constructor and assignment operator to avoid misuse @@ -66,9 +65,8 @@ class CobaltQueueDiscTestItem : public QueueDiscItem CobaltQueueDiscTestItem::CobaltQueueDiscTestItem(Ptr p, const Address& addr, - uint16_t protocol, bool ecnCapable) - : QueueDiscItem(p, addr, ecnCapable), + : QueueDiscItem(p, addr, 0), m_ecnCapablePacket(ecnCapable) { } @@ -177,27 +175,27 @@ CobaltQueueDiscBasicEnqueueDequeue::DoRun() NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(), 0 * modeSize, "There should be no packets in queue"); - queue->Enqueue(Create(p1, dest, 0, false)); + queue->Enqueue(Create(p1, dest, false)); NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(), 1 * modeSize, "There should be one packet in queue"); - queue->Enqueue(Create(p2, dest, 0, false)); + queue->Enqueue(Create(p2, dest, false)); NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(), 2 * modeSize, "There should be two packets in queue"); - queue->Enqueue(Create(p3, dest, 0, false)); + queue->Enqueue(Create(p3, dest, false)); NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(), 3 * modeSize, "There should be three packets in queue"); - queue->Enqueue(Create(p4, dest, 0, false)); + queue->Enqueue(Create(p4, dest, false)); NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(), 4 * modeSize, "There should be four packets in queue"); - queue->Enqueue(Create(p5, dest, 0, false)); + queue->Enqueue(Create(p5, dest, false)); NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(), 5 * modeSize, "There should be five packets in queue"); - queue->Enqueue(Create(p6, dest, 0, false)); + queue->Enqueue(Create(p6, dest, false)); NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(), 6 * modeSize, "There should be six packets in queue"); @@ -372,7 +370,7 @@ CobaltQueueDiscDropTest::Enqueue(Ptr queue, uint32_t size, uint Address dest; for (uint32_t i = 0; i < nPkt; i++) { - queue->Enqueue(Create(Create(size), dest, 0, true)); + queue->Enqueue(Create(Create(size), dest, true)); } } @@ -632,7 +630,7 @@ CobaltQueueDiscMarkTest::Enqueue(Ptr queue, Address dest; for (uint32_t i = 0; i < nPkt; i++) { - queue->Enqueue(Create(Create(size), dest, 0, ecnCapable)); + queue->Enqueue(Create(Create(size), dest, ecnCapable)); } } @@ -905,7 +903,7 @@ CobaltQueueDiscCeThresholdTest::Enqueue(Ptr queue, uint32_t siz Address dest; for (uint32_t i = 0; i < nPkt; i++) { - queue->Enqueue(Create(Create(size), dest, 0, true)); + queue->Enqueue(Create(Create(size), dest, true)); } } @@ -1176,7 +1174,7 @@ CobaltQueueDiscEnhancedBlueTest::Enqueue(Ptr queue, uint32_t si Address dest; for (uint32_t i = 0; i < nPkt; i++) { - queue->Enqueue(Create(Create(size), dest, 0, true)); + queue->Enqueue(Create(Create(size), dest, true)); } } From cfcf8c0c5c641d65a147d3119f2cfefcd5009707 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Sat, 19 Nov 2022 20:32:13 +0000 Subject: [PATCH 061/494] traffic-control: Fix implicit bool conversion in CodelQueueDiscTestItem ctor Defaults to 0, similarly to the other test suites --- src/traffic-control/test/codel-queue-disc-test-suite.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/traffic-control/test/codel-queue-disc-test-suite.cc b/src/traffic-control/test/codel-queue-disc-test-suite.cc index f901737bc..0a51fb5ed 100644 --- a/src/traffic-control/test/codel-queue-disc-test-suite.cc +++ b/src/traffic-control/test/codel-queue-disc-test-suite.cc @@ -88,7 +88,7 @@ class CodelQueueDiscTestItem : public QueueDiscItem }; CodelQueueDiscTestItem::CodelQueueDiscTestItem(Ptr p, const Address& addr, bool ecnCapable) - : QueueDiscItem(p, addr, ecnCapable), + : QueueDiscItem(p, addr, 0), m_ecnCapablePacket(ecnCapable) { } From d7249607a2095c612bfa7b886b1d3200cc1d5635 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Sat, 19 Nov 2022 20:03:53 +0000 Subject: [PATCH 062/494] wifi: Fix InterferenceHelper::CalculatePhyHeaderPer() --- src/wifi/model/interference-helper.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wifi/model/interference-helper.cc b/src/wifi/model/interference-helper.cc index 1c1ec2604..ce2d8aecd 100644 --- a/src/wifi/model/interference-helper.cc +++ b/src/wifi/model/interference-helper.cc @@ -628,7 +628,7 @@ InterferenceHelper::CalculatePhyHeaderPer(Ptr event, } double psr = 1.0; - if (!sections.empty() > 0) + if (!sections.empty()) { psr = CalculatePhyHeaderSectionPsr(event, nis, channelWidth, band, sections); } From e66a50f8435b93838dd18f69ce6d6053f030a596 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Fri, 7 Oct 2022 23:26:22 +0200 Subject: [PATCH 063/494] topology-read: (fixes #762) Automatically add names to the nodes read from topology files --- src/topology-read/doc/topology.rst | 16 ++++++++++++++++ src/topology-read/model/inet-topology-reader.cc | 6 +++++- src/topology-read/model/orbis-topology-reader.cc | 5 +++++ .../model/rocketfuel-topology-reader.cc | 9 +++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/topology-read/doc/topology.rst b/src/topology-read/doc/topology.rst index 2b75d47bc..d29e448e2 100644 --- a/src/topology-read/doc/topology.rst +++ b/src/topology-read/doc/topology.rst @@ -20,6 +20,22 @@ Currently there are three models: An helper ``ns3::TopologyReaderHelper`` is provided to assist on trivial tasks. +In some cases it might not be simple to identify which |ns3| node corresponds to a given node in the +topology file. To simplify this task, each node created by ``ns3::TopologyReaderHelper`` has a name. +The name format is "/NodeName/