diff --git a/CHANGES.md b/CHANGES.md index 5a3eb0fb7..a1b4e827b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,6 +20,8 @@ This file is a best-effort approach to solving this issue; we will do our best b ### Changes to existing API +The wimax module was removed and moved to the ns-3 App Store. + * (antenna) Reformatted documentation. * (documentation) Improve models documentation look and feel * (internet) Added check for longest prefix match in GlobalRouting. diff --git a/CMakeLists.txt b/CMakeLists.txt index e75e3080b..69d660d37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,7 @@ set(NS3_ENABLED_MODULES "" CACHE STRING "List of modules to enable (e.g. core;network;internet)" ) set(NS3_DISABLED_MODULES "" CACHE STRING - "List of modules to disable (e.g. lte;wimax)" + "List of modules to disable (e.g. lte;wifi)" ) # Filter in the modules from which examples and tests will be built diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6c4cf91a8..24ef1780d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -286,4 +286,3 @@ Please open an issue on `infrastructure` if you have suggestions for new labels, | `visualizer` | Any issue related to this module | | `wave module` | Any issue related to this module | | `wifi` | Any issue related to this module | -| `wimax` | Any issue related to this module | diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4aac48d15..a2a08e972 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -32,6 +32,8 @@ been tested on Linux. As of this release, the latest known version to work with ns-3 has switched to the C++23 standard by default. +The wimax module was removed and moved to the ns-3 App Store. + - (antenna) !2516 - Reformatted documentation - (documentation) !2519 - Improve models documentation look and feel - (core) A stacktrace will now be printed on fatal errors in supported platforms. diff --git a/build-support/custom-modules/ns3-configtable.cmake b/build-support/custom-modules/ns3-configtable.cmake index 2a6e987c3..6c04189c0 100644 --- a/build-support/custom-modules/ns3-configtable.cmake +++ b/build-support/custom-modules/ns3-configtable.cmake @@ -44,7 +44,7 @@ # sixlowpan spectrum stats # tap-bridge test (no Python) topology-read # traffic-control uan virtual-net-device -# wave wifi wimax +# wave wifi # # Modules not built (see ns-3 tutorial for explanation): # brite click dpdk-net-device diff --git a/doc/installation/source/quick-start.rst b/doc/installation/source/quick-start.rst index 591f35804..3ed177fe5 100644 --- a/doc/installation/source/quick-start.rst +++ b/doc/installation/source/quick-start.rst @@ -139,7 +139,7 @@ You should see some output such as below, if successful:: sixlowpan spectrum stats tap-bridge test topology-read traffic-control uan virtual-net-device - wifi wimax + wifi Modules that cannot be built: brite click mpi diff --git a/doc/manual/source/documentation.rst b/doc/manual/source/documentation.rst index 0a55c9771..bfb7e2150 100644 --- a/doc/manual/source/documentation.rst +++ b/doc/manual/source/documentation.rst @@ -403,7 +403,6 @@ script: Count Directory ----- ---------------------------------- 3414 src/lte/model - 1532 src/wimax/model 825 src/lte/test .... 1 src/applications/test @@ -434,7 +433,6 @@ script: 272 src/core/model/simulator.h 221 src/netanim/model/animation-interface.h .... - 1 src/wimax/model/ul-job.cc ---------------------------------------- 771 files with warnings diff --git a/doc/manual/source/profiling.rst b/doc/manual/source/profiling.rst index 7a4b41aa6..c5a21e08a 100644 --- a/doc/manual/source/profiling.rst +++ b/doc/manual/source/profiling.rst @@ -172,7 +172,7 @@ Sanitizers were used to find issues in multiple occasions: * The adopted solution in merge request `MR703`_ was to fix one of the schedulers that could produce the index value of -1, and updating the asserts to catch the illegal index value. -* A wrong downcast in the Wimax module: +* A wrong downcast in the wimax module (note: wimax is no longer a module within the ns-3 mainline): * The pointer was casted incorrectly to U16TlvValue instead of U8TvlValue, which could have different sizes in memory leading to the program reading the wrong memory address. diff --git a/doc/manual/source/test-framework.rst b/doc/manual/source/test-framework.rst index 5d435bda3..7df596144 100644 --- a/doc/manual/source/test-framework.rst +++ b/doc/manual/source/test-framework.rst @@ -281,10 +281,11 @@ will result in a list of the test suite being displayed, similar to system devices-mesh-flame-regression system epc-gtpu ... - unit wimax-phy-layer - unit wimax-service-flow - unit wimax-ss-mac-layer - unit wimax-tlv + unit wifi-primary-channels + unit wifi-ru-allocation + unit wifi-spectrum-wifi-phy + unit wifi-transmit-mask + unit wifi-txop example adhoc-aloha-ideal-phy example adhoc-aloha-ideal-phy-matrix-propagation-loss-model example adhoc-aloha-ideal-phy-with-microwave-oven diff --git a/doc/manual/source/working-with-cmake.rst b/doc/manual/source/working-with-cmake.rst index 63c278d6e..4732ca563 100644 --- a/doc/manual/source/working-with-cmake.rst +++ b/doc/manual/source/working-with-cmake.rst @@ -122,7 +122,6 @@ Now we run it for real: -- Detecting CXX compile features - done ... -- Processing src/wifi - -- Processing src/wimax -- ---- Summary of optional ns-3 features: Build profile : release Build directory : /ns-3-dev/build @@ -138,7 +137,7 @@ Now we run it for real: bridge buildings config-store core csma csma-layout ... - wifi wimax + wifi Modules that cannot be built: brite click openflow @@ -453,7 +452,6 @@ You should have a source tree like the following: │ │ ├── antenna │ │ ├── ... │ │ ├── wifi - │ │ └── wimax │ ├── third-party │ └── utils │ ├── perf diff --git a/doc/models/Makefile b/doc/models/Makefile index e609d8a57..a83cb0cb9 100644 --- a/doc/models/Makefile +++ b/doc/models/Makefile @@ -73,7 +73,6 @@ SOURCES = \ $(SRC)/wifi/doc/source/wifi-testing.rst \ $(SRC)/wifi/doc/source/wifi-changelog.rst \ $(SRC)/wifi/doc/source/wifi-references.rst \ - $(SRC)/wimax/doc/wimax.rst \ $(SRC)/uan/doc/uan.rst \ $(SRC)/topology-read/doc/topology.rst \ $(SRC)/traffic-control/doc/traffic-control-layer.rst \ @@ -168,7 +167,6 @@ SOURCEFIGS = \ $(SRC)/wifi/doc/source/figures/spectrum-wifi-phy-multiple-interfaces.png \ $(SRC)/wifi/doc/source/figures/cca-channel-switching-multiple-interfaces.pdf \ $(SRC)/wifi/doc/source/figures/cca-channel-switching-multiple-interfaces.png \ - $(SRC)/wimax/doc/WimaxArchitecture.dia \ $(SRC)/lte/doc/source/figures/epc-ctrl-arch.dia \ $(SRC)/lte/doc/source/figures/epc-data-flow-dl.dia \ $(SRC)/lte/doc/source/figures/epc-data-flow-dl-with-split.dia \ @@ -399,7 +397,6 @@ IMAGES_EPS = \ $(FIGURES)/FemHierarchy.eps \ $(FIGURES)/wifi-phy-rx-trace-helper.eps \ $(FIGURES)/snir.eps \ - $(FIGURES)/WimaxArchitecture.eps \ $(FIGURES)/epc-ctrl-arch.eps \ $(FIGURES)/epc-data-flow-dl.eps \ $(FIGURES)/epc-data-flow-dl-with-split.eps \ diff --git a/doc/models/source/index.rst b/doc/models/source/index.rst index fd5ad66c8..4bc7f4a3f 100644 --- a/doc/models/source/index.rst +++ b/doc/models/source/index.rst @@ -61,5 +61,4 @@ from the ``doc/`` directory of each module. Source file column width is 100 col traffic-control uan wifi - wimax zigbee diff --git a/doc/tutorial/source/getting-started.rst b/doc/tutorial/source/getting-started.rst index 18d1589b0..e9d6e6fd4 100644 --- a/doc/tutorial/source/getting-started.rst +++ b/doc/tutorial/source/getting-started.rst @@ -325,7 +325,6 @@ output that looks similar to the following: -- Processing src/uan -- Processing src/virtual-net-device -- Processing src/wifi - -- Processing src/wimax -- ---- Summary of optional NS-3 features: Build profile : optimized Build directory : /mnt/dev/tools/source/ns-3-dev/build @@ -363,7 +362,7 @@ output that looks similar to the following: sixlowpan spectrum stats tap-bridge test topology-read traffic-control uan virtual-net-device - wifi wimax + wifi Modules that cannot be built: diff --git a/ns3 b/ns3 index cc0d64ae6..6ef6ca109 100755 --- a/ns3 +++ b/ns3 @@ -236,7 +236,7 @@ def parse_args(argv): ) parser_configure.add_argument( "--disable-modules", - help='List of modules not to build (e.g. "lte;wimax")', + help='List of modules not to build (e.g. "lte;wifi")', action="store", type=str, default=None, diff --git a/src/buildings/doc/source/buildings-design.rst b/src/buildings/doc/source/buildings-design.rst index acc410ed9..5be8dba18 100644 --- a/src/buildings/doc/source/buildings-design.rst +++ b/src/buildings/doc/source/buildings-design.rst @@ -19,7 +19,7 @@ The Buildings module provides: #. a channel condition model (``BuildingsChannelConditionModel``) which determined the LOS/NLOS channel condition based on the ``Building`` objects deployed in the scenario. #. hybrid channel condition models (``ThreeGppV2vUrbanChannelConditionModel`` and ``ThreeGppV2vHighwayChannelConditionModel``) specifically designed to model vehicular environments (more information can be found in the :ref:`documentation of the propagation module `) -The models have been designed with LTE in mind, though their implementation is in fact independent from any LTE-specific code, and can be used with other ns-3 wireless technologies as well (e.g., wifi, wimax). +The models have been designed with LTE in mind, though their implementation is in fact independent from any LTE-specific code, and can be used with other ns-3 wireless technologies as well (e.g., wifi). The ``HybridBuildingsPropagationLossModel`` pathloss model included is obtained through a combination of several well known pathloss models in order to mimic different environmental scenarios such as urban, suburban and open areas. Moreover, the model considers both outdoor and indoor indoor and outdoor communication has to be included since HeNB might be installed either within building and either outside. In case of indoor communication, the model has to consider also the type of building in outdoor <-> indoor communication according to some general criteria such as the wall penetration losses of the common materials; moreover it includes some general configuration for the internal walls in indoor communications. diff --git a/src/buildings/doc/source/buildings-user.rst b/src/buildings/doc/source/buildings-user.rst index 92b0e8f9f..fa2ea06e6 100644 --- a/src/buildings/doc/source/buildings-user.rst +++ b/src/buildings/doc/source/buildings-user.rst @@ -184,7 +184,7 @@ Building-aware pathloss model After you placed buildings and nodes in a simulation, you can use a building-aware pathloss model in a simulation exactly in the same way you would use any regular path loss model. How to do this is specific -for the wireless module that you are considering (lte, wifi, wimax, +for the wireless module that you are considering (lte, wifi, etc.), so please refer to the documentation of that model for specific instructions. diff --git a/src/netanim/CMakeLists.txt b/src/netanim/CMakeLists.txt index 9d5ec7b6f..865d31032 100644 --- a/src/netanim/CMakeLists.txt +++ b/src/netanim/CMakeLists.txt @@ -3,7 +3,6 @@ build_lib( SOURCE_FILES model/animation-interface.cc HEADER_FILES model/animation-interface.h LIBRARIES_TO_LINK - ${libwimax} ${libwifi} ${liblte} ${libuan} diff --git a/src/netanim/doc/animation.rst b/src/netanim/doc/animation.rst index cacfd1330..c46e8a475 100644 --- a/src/netanim/doc/animation.rst +++ b/src/netanim/doc/animation.rst @@ -203,7 +203,6 @@ Using the above constructor ensures that each animation XML trace file has only With the above statement, AnimationInterface records the meta-data of each packet in the xml trace file. Metadata can be used by NetAnim to provide better statistics and filter, along with providing some brief information about the packet such as TCP sequence number or source & destination IP address during packet animation. CAUTION: Enabling this feature will result in larger XML trace files. -Please do NOT enable this feature when using Wimax links. :: diff --git a/src/netanim/model/animation-interface.cc b/src/netanim/model/animation-interface.cc index fe4be1caa..d9f68d90c 100644 --- a/src/netanim/model/animation-interface.cc +++ b/src/netanim/model/animation-interface.cc @@ -49,7 +49,6 @@ #include "ns3/wifi-mac.h" #include "ns3/wifi-net-device.h" #include "ns3/wifi-psdu.h" -#include "ns3/wimax-mac-header.h" namespace ns3 { @@ -95,7 +94,7 @@ AnimationInterface::AnimationInterface(const std::string fn) * The .dll.a/.lib however, only gets linked if we instantiate at * least one symbol exported by the .dll. * - * To ensure TypeIds from the Csma, Uan, Wifi and Wimax + * To ensure TypeIds from the Csma, Uan, and Wifi * modules are registered during runtime, we need to instantiate * at least one symbol exported by each of these module libraries. */ @@ -477,7 +476,6 @@ AnimationInterface::MobilityAutoCheck() if (!Simulator::IsFinished()) { PurgePendingPackets(AnimationInterface::WIFI); - PurgePendingPackets(AnimationInterface::WIMAX); PurgePendingPackets(AnimationInterface::LTE); PurgePendingPackets(AnimationInterface::CSMA); PurgePendingPackets(AnimationInterface::LRWPAN); @@ -1068,20 +1066,6 @@ AnimationInterface::LrWpanPhyRxBeginTrace(std::string context, Ptr OutputWirelessPacketRxInfo(p, m_pendingLrWpanPackets[animUid], animUid); } -void -AnimationInterface::WimaxTxTrace(std::string context, Ptr p, const Mac48Address& m) -{ - NS_LOG_FUNCTION(this); - return GenericWirelessTxTrace(context, p, AnimationInterface::WIMAX); -} - -void -AnimationInterface::WimaxRxTrace(std::string context, Ptr p, const Mac48Address& m) -{ - NS_LOG_FUNCTION(this); - return GenericWirelessRxTrace(context, p, AnimationInterface::WIMAX); -} - void AnimationInterface::LteTxTrace(std::string context, Ptr p, const Mac48Address& m) { @@ -1346,10 +1330,6 @@ AnimationInterface::ProtocolTypeToPendingPackets(AnimationInterface::ProtocolTyp pendingPackets = &m_pendingCsmaPackets; break; } - case AnimationInterface::WIMAX: { - pendingPackets = &m_pendingWimaxPackets; - break; - } case AnimationInterface::LTE: { pendingPackets = &m_pendingLtePackets; break; @@ -1380,10 +1360,6 @@ AnimationInterface::ProtocolTypeToString(AnimationInterface::ProtocolType protoc result = "CSMA"; break; } - case AnimationInterface::WIMAX: { - result = "WIMAX"; - break; - } case AnimationInterface::LTE: { result = "LTE"; break; @@ -1614,10 +1590,6 @@ AnimationInterface::ConnectCallbacks() Config::ConnectWithoutContextFailSafe( "/NodeList/*/$ns3::MobilityModel/CourseChange", MakeCallback(&AnimationInterface::MobilityCourseChangeTrace, this)); - Config::ConnectFailSafe("/NodeList/*/DeviceList/*/$ns3::WimaxNetDevice/Tx", - MakeCallback(&AnimationInterface::WimaxTxTrace, this)); - Config::ConnectFailSafe("/NodeList/*/DeviceList/*/$ns3::WimaxNetDevice/Rx", - MakeCallback(&AnimationInterface::WimaxRxTrace, this)); Config::ConnectFailSafe("/NodeList/*/DeviceList/*/$ns3::LteNetDevice/Tx", MakeCallback(&AnimationInterface::LteTxTrace, this)); Config::ConnectFailSafe("/NodeList/*/DeviceList/*/$ns3::LteNetDevice/Rx", diff --git a/src/netanim/model/animation-interface.h b/src/netanim/model/animation-interface.h index db8395b9f..fb4b65fda 100644 --- a/src/netanim/model/animation-interface.h +++ b/src/netanim/model/animation-interface.h @@ -531,7 +531,6 @@ class AnimationInterface UAN, LTE, WIFI, - WIMAX, CSMA, LRWPAN }; @@ -652,7 +651,6 @@ class AnimationInterface uint32_t m_wifiPhyRxDropCounterId; ///< wifi Phy receive drop counter ID AnimUidPacketInfoMap m_pendingWifiPackets; ///< pending wifi packets - AnimUidPacketInfoMap m_pendingWimaxPackets; ///< pending wimax packets AnimUidPacketInfoMap m_pendingLrWpanPackets; ///< pending LR-WPAN packets AnimUidPacketInfoMap m_pendingLtePackets; ///< pending LTE packets AnimUidPacketInfoMap m_pendingCsmaPackets; ///< pending CSMA packets @@ -1078,20 +1076,6 @@ class AnimationInterface * @param p the packet */ void LrWpanPhyRxBeginTrace(std::string context, Ptr p); - /** - * WIMax transmit trace function - * @param context the context - * @param p the packet - * @param m the MAC address - */ - void WimaxTxTrace(std::string context, Ptr p, const Mac48Address& m); - /** - * WIMax receive trace function - * @param context the context - * @param p the packet - * @param m the MAC address - */ - void WimaxRxTrace(std::string context, Ptr p, const Mac48Address& m); /** * CSMA Phy transmit begin trace function * @param context the context diff --git a/src/visualizer/model/pyviz.cc b/src/visualizer/model/pyviz.cc index 1bfc3ecf5..ed268e6c2 100644 --- a/src/visualizer/model/pyviz.cc +++ b/src/visualizer/model/pyviz.cc @@ -154,13 +154,6 @@ PyViz::PyViz() Config::ConnectFailSafe("/NodeList/*/DeviceList/*/$ns3::PointToPointNetDevice/MacRx", MakeCallback(&PyViz::TraceNetDevRxPointToPoint, this)); - // WiMax - Config::ConnectFailSafe("/NodeList/*/DeviceList/*/$ns3::WimaxNetDevice/Tx", - MakeCallback(&PyViz::TraceNetDevTxWimax, this)); - - Config::ConnectFailSafe("/NodeList/*/DeviceList/*/$ns3::WimaxNetDevice/Rx", - MakeCallback(&PyViz::TraceNetDevRxWimax, this)); - // LTE Config::ConnectFailSafe("/NodeList/*/DeviceList/*/$ns3::LteNetDevice/Tx", MakeCallback(&PyViz::TraceNetDevTxLte, this)); @@ -631,7 +624,7 @@ PyViz::TraceNetDevRxCommon(const std::string& context, else { // NS_ASSERT (0); - NS_LOG_WARN("Packet has no byte tag; wimax link?"); + NS_LOG_WARN("Packet has no byte tag"); uid = packet->GetUid(); } @@ -796,22 +789,6 @@ PyViz::TraceNetDevPromiscRxCsma(std::string context, Ptr packet) } } -void -PyViz::TraceNetDevTxWimax(std::string context, - Ptr packet, - const Mac48Address& destination) -{ - NS_LOG_FUNCTION(context); - TraceNetDevTxCommon(context, packet, destination); -} - -void -PyViz::TraceNetDevRxWimax(std::string context, Ptr packet, const Mac48Address& source) -{ - NS_LOG_FUNCTION(context); - TraceNetDevRxCommon(context, packet, source); -} - void PyViz::TraceNetDevTxLte(std::string context, Ptr packet, diff --git a/src/visualizer/model/pyviz.h b/src/visualizer/model/pyviz.h index c8aac6bd7..5ab95a0cf 100644 --- a/src/visualizer/model/pyviz.h +++ b/src/visualizer/model/pyviz.h @@ -392,25 +392,6 @@ class PyViz */ void TraceNetDevRxPointToPoint(std::string context, Ptr packet); - /** - * WiMax transmit trace callback function - * @param context the context - * @param packet the packet - * @param destination the destination MAC address - */ - void TraceNetDevTxWimax(std::string context, - Ptr packet, - const Mac48Address& destination); - /** - * WiMax transmit trace callback function - * @param context the context - * @param packet the packet - * @param source the source MAC address - */ - void TraceNetDevRxWimax(std::string context, - Ptr packet, - const Mac48Address& source); - /** * LTE transmit trace callback function * @param context the context diff --git a/src/wimax/AUTHORS b/src/wimax/AUTHORS deleted file mode 100644 index f51c428af..000000000 --- a/src/wimax/AUTHORS +++ /dev/null @@ -1,54 +0,0 @@ -Jahanzeb Farooq -=============== -Module manager and main developer -2007,2008 -INRIA -Jahanzeb.Farooq@sophia.inria.fr -Fahanzeb.Farooq@gmail.com - -Mohamed Amine Ismail -==================== -Module manager and main developer -2008,2010 -INRIA, UDcast -Amine.Ismail@sophia.inria.fr -Amine.Ismail@udcast.com -Amine.Ismail@gmail.com - -Giuseppe Piro -============= -Development and Integration of the rtps uplink scheduler -2009-2010 -TELEMATICS LAB, Politecnico di Bari -G.Piro@poliba.it - -Flavio Kubota, Juliana Freitag Borin, Nelson L. S. da Fonseca -============================================================== -Development and Integration of the mbqos uplink scheduler -2009 -LRC - Computer Networks Laboratory -FlavioKubota@gmail.com -juliana.freitag@gmail.com -wimaxgroup@lrc.ic.unicamp.br - -Thierry Turletti -================ -Project supervisor -2007,2008,2009 -INRIA -Thierry.Turletti@sophia.inria.fr - -Walid Dabbous -============= -Planete Project Manager -2007,2008,2009 -INRIA -Walid.Dabbous@sophia.inria.fr - -Mathieu Lacage -============== -Project supervisor -2007,2008,2009 -INRIA -Mathieu.Lacage@sophia.inria.fr - diff --git a/src/wimax/CMakeLists.txt b/src/wimax/CMakeLists.txt deleted file mode 100644 index e718ccc60..000000000 --- a/src/wimax/CMakeLists.txt +++ /dev/null @@ -1,113 +0,0 @@ -set(source_files - helper/wimax-helper.cc - model/cid.cc - model/cid-factory.cc - model/wimax-net-device.cc - model/bs-net-device.cc - model/ss-net-device.cc - model/wimax-mac-header.cc - model/wimax-phy.cc - model/wimax-channel.cc - model/ofdm-downlink-frame-prefix.cc - model/wimax-connection.cc - model/ss-record.cc - model/mac-messages.cc - model/dl-mac-messages.cc - model/ul-mac-messages.cc - model/simple-ofdm-wimax-phy.cc - model/simple-ofdm-wimax-channel.cc - model/send-params.cc - model/ss-manager.cc - model/connection-manager.cc - model/bs-uplink-scheduler.cc - model/bs-uplink-scheduler-simple.cc - model/bs-uplink-scheduler-mbqos.cc - model/bs-uplink-scheduler-rtps.cc - model/bs-scheduler.cc - model/bs-scheduler-simple.cc - model/bs-scheduler-rtps.cc - model/wimax-mac-queue.cc - model/burst-profile-manager.cc - model/ss-scheduler.cc - model/service-flow.cc - model/service-flow-manager.cc - model/service-flow-record.cc - model/ss-link-manager.cc - model/bs-link-manager.cc - model/bandwidth-manager.cc - model/crc8.cc - model/ul-job.cc - model/snr-to-block-error-rate-record.cc - model/snr-to-block-error-rate-manager.cc - model/simple-ofdm-send-param.cc - model/ss-service-flow-manager.cc - model/bs-service-flow-manager.cc - model/ipcs-classifier.cc - model/ipcs-classifier-record.cc - model/wimax-tlv.cc - model/cs-parameters.cc - model/wimax-mac-to-mac-header.cc -) - -set(header_files - helper/wimax-helper.h - model/wimax-channel.h - model/wimax-net-device.h - model/bs-net-device.h - model/ss-net-device.h - model/cid.h - model/cid-factory.h - model/ofdm-downlink-frame-prefix.h - model/wimax-connection.h - model/ss-record.h - model/mac-messages.h - model/dl-mac-messages.h - model/ul-mac-messages.h - model/wimax-phy.h - model/simple-ofdm-wimax-phy.h - model/simple-ofdm-wimax-channel.h - model/send-params.h - model/service-flow.h - model/ss-manager.h - model/connection-manager.h - model/wimax-mac-header.h - model/wimax-mac-queue.h - model/crc8.h - model/service-flow-manager.h - model/bs-uplink-scheduler.h - model/bs-uplink-scheduler-simple.h - model/bs-uplink-scheduler-mbqos.h - model/bs-uplink-scheduler-rtps.h - model/ul-job.h - model/bs-scheduler.h - model/bs-scheduler-simple.h - model/bs-scheduler-rtps.h - model/service-flow-record.h - model/snr-to-block-error-rate-record.h - model/snr-to-block-error-rate-manager.h - model/simple-ofdm-send-param.h - model/ss-service-flow-manager.h - model/bs-service-flow-manager.h - model/cs-parameters.h - model/ipcs-classifier-record.h - model/wimax-tlv.h - model/ipcs-classifier.h - model/bvec.h - model/wimax-mac-to-mac-header.h -) - -build_lib( - LIBNAME wimax - SOURCE_FILES ${source_files} - HEADER_FILES ${header_files} - LIBRARIES_TO_LINK ${libinternet} - ${libpropagation} - TEST_SOURCES - test/mac-messages-test.cc - test/phy-test.cc - test/qos-test.cc - test/ss-mac-test.cc - test/wimax-fragmentation-test.cc - test/wimax-service-flow-test.cc - test/wimax-tlv-test.cc -) diff --git a/src/wimax/doc/WimaxArchitecture.dia b/src/wimax/doc/WimaxArchitecture.dia deleted file mode 100644 index d68d960fe..000000000 Binary files a/src/wimax/doc/WimaxArchitecture.dia and /dev/null differ diff --git a/src/wimax/doc/wimax.rst b/src/wimax/doc/wimax.rst deleted file mode 100644 index 58116d6a3..000000000 --- a/src/wimax/doc/wimax.rst +++ /dev/null @@ -1,516 +0,0 @@ -.. include:: replace.txt -.. highlight:: cpp - -Wimax NetDevice ---------------- - -This chapter describes the |ns3| WimaxNetDevice and related models. By -adding WimaxNetDevice objects to |ns3| nodes, one can create models of -802.16-based networks. Below, we list some more details about what -the |ns3| WiMAX models cover but, in summary, the most important features -of the |ns3| model are: - -* a scalable and realistic physical layer and channel model -* a packet classifier for the IP convergence sublayer -* efficient uplink and downlink schedulers -* support for Multicast and Broadcast Service (MBS), and -* packet tracing functionality - -The source code for the WiMAX models lives in the directory -``src/wimax``. - -There have been two academic papers published on this model: - -* M.A. Ismail, G. Piro, L.A. Grieco, and T. Turletti, "An Improved IEEE 802.16 - WiMAX Module for the NS-3 Simulator", SIMUTools 2010 Conference, March 2010. -* J. Farooq and T. Turletti, "An IEEE 802.16 WiMAX module for the NS-3 - Simulator," SIMUTools 2009 Conference, March 2009. - - -Scope of the model -****************** - -From a MAC perspective, there are two basic modes of operation, that of a -Subscriber Station (SS) or a Base Station (BS). These are implemented as two -subclasses of the base class :cpp:class:`ns3::NetDevice`, class -:cpp:class:`SubscriberStationNetDevice` and class -:cpp:class:`BaseStationNetDevice`. As is typical in |ns3|, there is also a -physical layer class :cpp:class:`WimaxPhy` and a channel class -:cpp:class:`WimaxChannel` which serves to hold the references to all of the -attached Phy devices. The main physical layer class is the -:cpp:class:`SimpleOfdmWimaxChannel` class. - -Another important aspect of WiMAX is the uplink and downlink scheduler, and -there are three primary scheduler types implemented: - -* SIMPLE: a simple priority based FCFS scheduler -* RTPS: a real-time polling service (rtPS) scheduler -* MBQOS: a migration-based uplink scheduler - -The following additional aspects of the 802.16 specifications, as well as -physical layer and channel models, are modelled: - -* leverages existing |ns3| wireless propagation loss and delay models, as well - as |ns3| mobility models -* Point-to-Multipoint (PMP) mode and the WirelessMAN-OFDM PHY layer -* Initial Ranging -* Service Flow Initialization -* Management Connection -* Transport Initialization -* UGS, rtPS, nrtPS, and BE connections - -The following aspects are not presently modelled but would be good topics for -future extensions: - -* OFDMA PHY layer -* Link adaptation -* Mesh topologies -* ARQ -* ertPS connection -* packet header suppression - -Using the Wimax models -********************** - -The main way that users who write simulation scripts will typically interact -with the Wimax models is through the helper API and through the publicly visible -attributes of the model. - -The helper API is defined in ``src/wimax/helper/wimax-helper.{cc,h}``. - -The example ``src/wimax/examples/wimax-simple.cc`` contains some basic code that -shows how to set up the model:: - - switch (schedType) - { - case 0: - scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - break; - case 1: - scheduler = WimaxHelper::SCHED_TYPE_MBQOS; - break; - case 2: - scheduler = WimaxHelper::SCHED_TYPE_RTPS; - break; - default: - scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - } - - NodeContainer ssNodes; - NodeContainer bsNodes; - - ssNodes.Create(2); - bsNodes.Create(1); - - WimaxHelper wimax; - - NetDeviceContainer ssDevs, bsDevs; - - ssDevs = wimax.Install(ssNodes, - WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - bsDevs = wimax.Install(bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler); - -This example shows that there are two subscriber stations and one base station -created. The helper method ``Install`` allows the user to specify the scheduler -type, the physical layer type, and the device type. - -Different variants of ``Install`` are available; for instance, the example -``src/wimax/examples/wimax-multicast.cc`` shows how to specify a non-default channel -or propagation model:: - - channel = CreateObject(); - channel->SetPropagationModel(SimpleOfdmWimaxChannel::COST231_PROPAGATION); - ssDevs = wimax.Install(ssNodes, - WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - channel, - scheduler); - Ptr dev = wimax.Install(bsNodes.Get(0), - WimaxHelper::DEVICE_TYPE_BASE_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - channel, - scheduler); - -Mobility is also supported in the same way as in Wifi models; see the -``src/wimax/examples/wimax-multicast.cc``. - -Another important concept in WiMAX is that of a service flow. This is a -unidirectional flow of packets with a set of QoS parameters such as traffic -priority, rate, scheduling type, etc. The base station is responsible for -issuing service flow identifiers and mapping them to WiMAX connections. The -following code from ``src/wimax/examples/wimax-multicast.cc`` shows how this is -configured from a helper level:: - - ServiceFlow MulticastServiceFlow = wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_DOWN, - ServiceFlow::SF_TYPE_UGS, - MulticastClassifier); - - bs->GetServiceFlowManager()->AddMulticastServiceFlow(MulticastServiceFlow, WimaxPhy::MODULATION_TYPE_QPSK_12); - - -Wimax Attributes -**************** - -The WimaxNetDevice makes heavy use of the |ns3| attributes subsystem for -configuration and default value management. Presently, approximately 60 values -are stored in this system. - -For instance, class ``ns-3::SimpleOfdmWimaxPhy`` exports these -attributes: - -* NoiseFigure: Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver. -* TxPower: Transmission power (dB) -* G: The ratio of CP time to useful time -* txGain: Transmission gain (dB) -* RxGain: Reception gain (dB) -* Nfft: FFT size -* TraceFilePath: Path to the directory containing SNR to block error rate files - - -For a full list of attributes in these models, consult the Doxygen page that -lists all attributes for |ns3|. - -Wimax Tracing -************* - -|ns3| has a sophisticated tracing infrastructure that allows users to hook into -existing trace sources, or to define and export new ones. - -Many |ns3| users use the built-in Pcap or Ascii tracing, and the -WimaxHelper has similar APIs:: - - AsciiTraceHelper ascii; - WimaxHelper wimax; - wimax.EnablePcap("wimax-program", false); - wimax.EnableAsciiAll(ascii.CreateFileStream("wimax-program.tr"); - -Unlike other helpers, there is also a special ``EnableAsciiForConnection()`` -method that limits the ascii tracing to a specific device and connection. - -These helpers access the low level trace sources that exist in the WiMAX -physical layer, net device, and queue models. Like other |ns3| trace sources, -users may hook their own functions to these trace sources if they want to do -customized things based on the packet events. See the Doxygen List of trace -sources for a complete list of these sources. - -Wimax MAC model -*************** - -The 802.16 model provided in |ns3| attempts to provide an accurate MAC and PHY -level implementation of the 802.16 specification with the Point-to-Multipoint -(PMP) mode and the WirelessMAN-OFDM PHY layer. The model is mainly composed of -three layers: - -* The convergence sublayer (CS) -* The MAC CP Common Part Sublayer (MAC-CPS) -* Physical (PHY) layer - - -The following figure :ref:`wimax-architecture` shows the relationships of these -models. - -.. _wimax-architecture: - -.. figure:: figures/WimaxArchitecture.* - - WiMAX architecture - -Convergence Sublayer -++++++++++++++++++++ - -The Convergence sublayer (CS) provided with this module implements the Packet -CS, designed to work with the packet-based protocols at higher layers. The CS is -responsible of receiving packet from the higher layer and from peer stations, -classifying packets to appropriate connections (or service flows) and processing -packets. It keeps a mapping of transport connections to service flows. This -enables the MAC CPS identifying the Quality of Service (QoS) parameters -associated to a transport connection and ensuring the QoS requirements. The CS -currently employs an IP classifier. - -IP Packet Classifier -++++++++++++++++++++ - -An IP packet classifier is used to map incoming packets to appropriate -connections based on a set of criteria. The classifier maintains a list of -mapping rules which associate an IP flow (src IP address and mask, dst IP -address and mask, src port range, dst port range and protocol) to one of the -service flows. By analyzing the IP and the TCP/UDP headers the classifier will -append the incoming packet (from the upper layer) to the queue of the -appropriate WiMAX connection. Class :cpp:class:`IpcsClassifier` and class -:cpp:class:`IpcsClassifierRecord` implement the classifier module for both SS -and BS - -MAC Common Part Sublayer -++++++++++++++++++++++++ - -The MAC Common Part Sublayer (CPS) is the main sublayer of the IEEE 802.16 MAC -and performs the fundamental functions of the MAC. The module implements the -Point-Multi-Point (PMP) mode. In PMP mode BS is responsible of managing -communication among multiple SSs. The key functionalities of the MAC CPS include -framing and addressing, generation of MAC management messages, SS initialization -and registration, service flow management, bandwidth management and scheduling -services. Class :cpp:class:`WimaxNetDevice` represents the MAC layer of a WiMAX -network device. This class extends the class :cpp:class:`NetDevice` of the |ns3| -API that provides abstraction of a network device. Class -:cpp:class:`WimaxNetDevice` is further extended by class -:cpp:class:`BaseStationNetDevice` and class -:cpp:class:`SubscriberStationNetDevice`, defining MAC layers of BS and SS, -respectively. Besides these main classes, the key functions of MAC are -distributed to several other classes. - -Framing and Management Messages -+++++++++++++++++++++++++++++++ - -The module implements a frame as a fixed duration of time, i.e., frame -boundaries are defined with respect to time. Each frame is further subdivided -into downlink (DL) and uplink (UL) subframes. The module implements the Time -Division Duplex (TDD) mode where DL and UL operate on same frequency but are -separated in time. A number of DL and UL bursts are then allocated in DL and UL -subframes, respectively. Since the standard allows sending and receiving bursts -of packets in a given DL or UL burst, the unit of transmission at the MAC layer -is a packet burst. The module implements a special PacketBurst data structure -for this purpose. A packet burst is essentially a list of packets. The BS -downlink and uplink schedulers, implemented by class :cpp:class:`BSScheduler` -and class :cpp:class:`UplinkScheduler`, are responsible of generating DL and UL -subframes, respectively. In the case of DL, the subframe is simulated by -transmitting consecutive bursts (instances PacketBurst). In case of UL, the -subframe is divided, with respect to time, into a number of slots. The bursts -transmitted by the SSs in these slots are then aligned to slot boundaries. The -frame is divided into integer number of symbols and Physical Slots (PS) which -helps in managing bandwidth more effectively. The number of symbols per frame -depends on the underlying implementation of the PHY layer. The size of a DL or -UL burst is specified in units of symbols. - -Network Entry and Initialization -++++++++++++++++++++++++++++++++ - -The network entry and initialization phase is basically divided into two -sub-phases, (1) scanning and synchronization and (2) initial ranging. The entire -phase is performed by the LinkManager component of SS and BS. Once an SS wants -to join the network, it first scans the downlink frequencies to search for a -suitable channel. The search is complete as soon as it detects a PHY frame. The -next step is to establish synchronization with the BS. Once SS receives a -Downlink-MAP (DL-MAP) message the synchronization phase is complete and it -remains synchronized as long as it keeps receiving DL-MAP and Downlink Channel -Descriptor (DCD) messages. After the synchronization is established, SS waits -for a Uplink Channel Descriptor (UCD) message to acquire uplink channel -parameters. Once acquired, the first sub-phase of the network entry and -initialization is complete. Once synchronization is achieved, the SS waits for a -UL-MAP message to locate a special grant, called initial ranging interval, in -the UL subframe. This grant is allocated by the BS Uplink Scheduler at regular -intervals. Currently this interval is set to 0.5 ms, however the user is enabled -to modify its value from the simulation script. - -Connections and Addressing -++++++++++++++++++++++++++ - -All communication at the MAC layer is carried in terms of connections. The -standard defines a connection as a unidirectional mapping between the SS and -BS's MAC entities for the transmission of traffic. The standard defines two -types of connections: management connections for transmitting control messages -and transport connections for data transmission. A connection is identified by a -16-bit Connection Identifier (CID). Class :cpp:class:`WimaxConnection` and -class :cpp:class:`Cid` implement the connection and CID, respectively. Note that -each connection maintains its own transmission queue where packets to transmit -on that connection are queued. The ConnectionManager component of BS is -responsible of creating and managing connections for all SSs. - -The two key management connections defined by the standard, namely the Basic and -Primary management connections, are created and allocated to the SS during the -ranging process. Basic connection plays an important role throughout the -operation of SS also because all (unicast) DL and UL grants are directed towards -SS's Basic CID. In addition to management connections, an SS may have one or -more transport connections to send data packets. The Connection Manager -component of SS manages the connections associated to SS. As defined by the -standard, a management connection is bidirectional, i.e., a pair of downlink and -uplink connections is represented by the same CID. This feature is implemented -in a way that one connection (in DL direction) is created by the BS and upon -receiving the CID the SS then creates an identical connection (in UL direction) -with the same CID. - -Scheduling Services -+++++++++++++++++++ - -The module supports the four scheduling services defined by the 802.16-2004 -standard: - -* Unsolicited Grant Service (UGS) -* Real-Time Polling Services (rtPS) -* Non Real-Time Polling Services (nrtPS) -* Best Effort (BE) - -These scheduling services behave differently with respect to how they request -bandwidth as well as how the it is granted. Each service flow is associated to -exactly one scheduling service, and the QoS parameter set associated to a -service flow actually defines the scheduling service it belongs to. When a -service flow is created the UplinkScheduler calculates necessary parameters such -as grant size and grant interval based on QoS parameters associated to it. - -WiMAX Uplink Scheduler Model -++++++++++++++++++++++++++++ - -Uplink Scheduler at the BS decides which of the SSs will be assigned uplink -allocations based on the QoS parameters associated to a service flow (or -scheduling service) and bandwidth requests from the SSs. Uplink scheduler -together with Bandwidth Manager implements the complete scheduling service -functionality. The standard defines up to four scheduling services (BE, UGS, -rtPS, nrtPS) for applications with different types of QoS requirements. The -service flows of these scheduling services behave differently with respect to -how they request for bandwidth as well as how the bandwidth is granted. The -module supports all four scheduling services. Each service flow is associated to -exactly one transport connection and one scheduling service. The QoS parameters -associated to a service flow actually define the scheduling service it belongs -to. Standard QoS parameters for UGS, rtPS, nrtPS and BE services, as specified -in Tables 111a to 111d of the 802.16e amendment, are supported. When a service -flow is created the uplink scheduler calculates necessary parameters such as -grant size and allocation interval based on QoS parameters associated to it. -The current WiMAX module provides three different versions of schedulers. - -* The first one is a simple priority-based First Come First Serve (FCFS). For - the real-time services (UGS and rtPS) the BS then allocates grants/polls on - regular basis based on the calculated interval. For the non real-time services - (nrtPS and BE) only minimum reserved bandwidth is guaranteed if available - after servicing real-time flows. Note that not all of these parameters are - utilized by the uplink scheduler. Also note that currently only service flow - with fixed-size packet size are supported, as currently set up in simulation - scenario with OnOff application of fixed packet size. This scheduler is - implemented by class :cpp:class:`BSSchedulerSimple` and class - :cpp:class:`UplinkSchedulerSimple`. - -* The second one is similar to first scheduler except by rtPS service flow. All - rtPS Connections are able to transmit all packet in the queue according to the - available bandwidth. The bandwidth saturation control has been implemented to - redistribute the effective available bandwidth to all rtPS that have at least - one packet to transmit. The remaining bandwidth is allocated to nrtPS and BE - Connections. This scheduler is implemented by class - :cpp:class:`BSSchedulerRtps` and class - :cpp:class:`UplinkSchedulerRtps`. - -* The third one is a Migration-based Quality of Service uplink scheduler This - uplink scheduler uses three queues, the low priority queue, the intermediate - queue and the high priority queue. The scheduler serves the requests in - strict priority order from the high priority queue to the low priority queue. - The low priority queue stores the bandwidth requests of the BE service flow. - The intermediate queue holds bandwidth requests sent by rtPS and by nrtPS - connections. rtPS and nrtPS requests can migrate to the high priority queue to - guarantee that their QoS requirements are met. Besides the requests migrated - from the intermediate queue, the high priority queue stores periodic grants - and unicast request opportunities that must be scheduled in the following - frame. To guarantee the maximum delay requirement, the BS assigns a deadline - to each rtPS bandwidth request in the intermediate queue. The minimum - bandwidth requirement of both rtPS and nrtPS connections is guaranteed over a - window of duration T. This scheduler is implemented by class - :cpp:class:`UplinkSchedulerMBQoS`. - -WiMAX Outbound Schedulers Model -+++++++++++++++++++++++++++++++ - -Besides the uplink scheduler these are the outbound schedulers at BS and SS side -(BSScheduler and SSScheduler). The outbound schedulers decide which of the -packets from the outbound queues will be transmitted in a given allocation. The -outbound scheduler at the BS schedules the downlink traffic, i.e., packets to be -transmitted to the SSs in the downlink subframe. Similarly the outbound -scheduler at a SS schedules the packet to be transmitted in the uplink -allocation assigned to that SS in the uplink subframe. All three schedulers have -been implemented to work as FCFS scheduler, as they allocate grants starting -from highest priority scheduling service to the lower priority one (UGS> rtPS> -nrtPS> BE). The standard does not suggest any scheduling algorithm and instead -leaves this decision up to the manufacturers. Of course more sophisticated -algorithms can be added later if required. - -WimaxChannel and WimaxPhy models -******************************** - -The module implements the Wireless MAN OFDM PHY specifications as the more -relevant for implementation as it is the schema chosen by the WiMAX Forum. This -specification is designed for non-light-of-sight (NLOS) including fixed and -mobile broadband wireless access. The proposed model uses a 256 FFT processor, -with 192 data subcarriers. It supports all the seven modulation and coding -schemes specified by Wireless MAN-OFDM. It is composed of two parts: the channel -model and the physical model. - -Channel model -************* - -The channel model we propose is implemented by the class -:cpp:class:`SimpleOFDMWimaxChannel` which extends the class -:cpp:class:`wimaxchannel`. The channel entity has a private structure named -m_phyList which handles all the physical devices connected to it. When a -physical device sends a packet (FEC Block) to the channel, the channel handles -the packet, and then for each physical device connected to it, it calculates the -propagation delay, the path loss according to a given propagation model and -eventually forwards the packet to the receiver device. The channel class uses -the method `GetDistanceFrom()` to calculate the distance between two physical -entities according to their 3D coordinates. The delay is -computed as `delay = distance/C`, where `C` is the speed of the light. - -Physical model -************** - -The physical layer performs two main operations: (i) It receives a burst from a -channel and forwards it to the MAC layer, (ii) it receives a burst from the MAC -layer and transmits it on the channel. In order to reduce the simulation -complexity of the WiMAX physical layer, we have chosen to model offline part of -the physical layer. More specifically we have developed an OFDM simulator to -generate trace files used by the reception process to evaluate if a FEC block -can be correctly decoded or not. - -Transmission Process: A burst is a set of WiMAX MAC PDUs. At the sending -process, a burst is converted into bit-streams and then split into smaller -FEC blocks which are then sent to the channel with a power equal P_tx. - -Reception Process: The reception process includes the following operations: - -#. Receive a FEC block from the channel. -#. Calculate the noise level. -#. Estimate the signal to noise ratio (SNR) with the following formula. -#. Determine if a FEC block can be correctly decoded. -#. Concatenate received FEC blocks to reconstruct the original burst. -#. Forward the burst to the upper layer. - -The developed process to evaluate if a FEC block can be correctly received or -not uses pre-generated traces. The trace files are generated by an external -OFDM simulator (described later). A class named SNRToBlockErrorRateManager -handles a repository containing seven trace files (one for each modulation and -coding scheme). A repository is specific for a particular channel model. - -A trace file is made of 6 columns. The first column provides the SNR value (1), -whereas the other columns give respectively the bit error rate BER (2), the -block error rate BlcER(3), the standard deviation on BlcER, and the confidence -interval (4 and 5). These trace files are loaded into memory by the -SNRToBlockErrorRateManager entity at the beginning of the simulation. - -Currently, The first process uses the first and third columns to determine if a -FEC block is correctly received. When the physical layer receives a packet with -an SNR equal to SNR_rx, it asks the SNRToBlockErrorRateManager to return the -corresponding block error rate BlcER. A random number RAND between 0 and 1 is -then generated. If RAND is greater than BlcER, then the block is correctly -received, otherwise the block is considered erroneous and is ignored. - -The module provides defaults SNR to block error rate traces in default-traces.h. -The traces have been generated by an External WiMAX OFDM simulator. The -simulator is based on an external mathematics and signal processing library IT++ -and includes : a random block generator, a Reed Solomon (RS) coder, a -convolutional coder, an interleaver, a 256 FFT-based OFDM modulator, a -multi-path channel simulator and an equalizer. The multipath channel is -simulated using the TDL_channel class of the IT++ library. - -Users can configure the module to use their own traces generated by another OFDM -simulator or ideally by performing experiments in real environment. For this -purpose, a path to a repository containing trace files should be provided. If -no repository is provided the traces form default-traces.h will be loaded. A -valid repository should contain 7 files, one for each modulation and coding -scheme. - -The names of the files should respect the following format: modulation0.txt for -modulation 0, modulation1.txt for modulation 1 and so on... The file format -should be as follows: - -.. sourcecode:: text - - SNR_value1 BER Blc_ER STANDARD_DEVIATION CONFIDENCE_INTERVAL1 CONFIDENCE_INTERVAL2 - SNR_value2 BER Blc_ER STANDARD_DEVIATION CONFIDENCE_INTERVAL1 CONFIDENCE_INTERVAL2 - ... ... ... ... ... ... - ... ... ... ... ... ... diff --git a/src/wimax/examples/CMakeLists.txt b/src/wimax/examples/CMakeLists.txt deleted file mode 100644 index 69a76237f..000000000 --- a/src/wimax/examples/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -build_lib_example( - NAME wimax-ipv4 - SOURCE_FILES wimax-ipv4.cc - LIBRARIES_TO_LINK - ${libwimax} - ${libinternet} - ${libmobility} - ${libcsma} - ${libapplications} -) - -build_lib_example( - NAME wimax-multicast - SOURCE_FILES wimax-multicast.cc - LIBRARIES_TO_LINK - ${libwimax} - ${libinternet} - ${libcsma} - ${libapplications} -) - -build_lib_example( - NAME wimax-simple - SOURCE_FILES wimax-simple.cc - LIBRARIES_TO_LINK - ${libwimax} - ${libinternet} - ${libmobility} - ${libapplications} -) diff --git a/src/wimax/examples/wimax-ipv4.cc b/src/wimax/examples/wimax-ipv4.cc deleted file mode 100644 index 525a9bd4b..000000000 --- a/src/wimax/examples/wimax-ipv4.cc +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -// -// Default network topology includes a base station (BS) and some number of -// subscriber station (SS) specified by the variable nbSS (defaults to six). -// The SSs are grouped into two groups: senders and receivers. SSs from 0 to -// nbSS/2 are designed as senders and SSs from (nbSS/2 + 1) to nbSS-1 will -// designed as receivers. -// Each SS creates 3 transport connection with the BS. the fist one has as QoS -// scheduling type UGS, the second one rtPS and the third one BE. -// Senders SSs send some stamped IP packets with variable bitrate to receiver SSs -// through the BS station. receiver SSs receive the IP packets analyze them and -// based on a sequence number decide if all the packets are coorectly received - -// +-----+ +-----+ +-----+ -// | SS0 | | SS1 | | SS2 | -// +-----+ +-----+ +-----+ -// 10.1.1.1 10.1.1.2 10.1.1.3 -// -------- -------- ------- -// ((*)) ((*)) ((*)) -// -// 10.1.1.7 -// +------------+ -// |Base Station| ==((*)) -// +------------+ -// -// ((*)) ((*)) ((*)) -// ------- -------- -------- -// 10.1.1.4 10.1.1.5 10.1.1.6 -// +-----+ +-----+ +-----+ -// | SS3 | | SS4 | | SS5 | -// +-----+ +-----+ +-----+ - -#include "ns3/applications-module.h" -#include "ns3/core-module.h" -#include "ns3/global-route-manager.h" -#include "ns3/internet-module.h" -#include "ns3/mobility-module.h" -#include "ns3/network-module.h" -#include "ns3/wimax-module.h" - -#include - -using namespace ns3; - -NS_LOG_COMPONENT_DEFINE("wimaxIpV4Simulation"); - -int -main(int argc, char* argv[]) -{ - // default values - int nbSS = 4; - int duration = 7; - int schedType = 0; - bool verbose = false; - WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - LogComponentEnable("UdpClient", LOG_LEVEL_INFO); - LogComponentEnable("UdpServer", LOG_LEVEL_INFO); - - CommandLine cmd(__FILE__); - cmd.AddValue("nbSS", "number of subscriber station to create", nbSS); - cmd.AddValue("scheduler", "type of scheduler to use with the network devices", schedType); - cmd.AddValue("duration", "duration of the simulation in seconds", duration); - cmd.AddValue("verbose", "turn on all WimaxNetDevice log components", verbose); - cmd.Parse(argc, argv); - - switch (schedType) - { - case 0: - scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - break; - case 1: - scheduler = WimaxHelper::SCHED_TYPE_MBQOS; - break; - case 2: - scheduler = WimaxHelper::SCHED_TYPE_RTPS; - break; - default: - scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - } - - NodeContainer ssNodes; - NodeContainer bsNodes; - - ssNodes.Create(nbSS); - bsNodes.Create(1); - - WimaxHelper wimax; - - NetDeviceContainer ssDevs; - NetDeviceContainer bsDevs; - - ssDevs = wimax.Install(ssNodes, - WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - bsDevs = wimax.Install(bsNodes, - WimaxHelper::DEVICE_TYPE_BASE_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - - auto ss = new Ptr[nbSS]; - - for (int i = 0; i < nbSS; i++) - { - ss[i] = ssDevs.Get(i)->GetObject(); - ss[i]->SetModulationType(WimaxPhy::MODULATION_TYPE_QAM16_12); - } - - Ptr bs; - bs = bsDevs.Get(0)->GetObject(); - - MobilityHelper mobility; - mobility.Install(bsNodes); - mobility.Install(ssNodes); - - InternetStackHelper stack; - stack.Install(bsNodes); - stack.Install(ssNodes); - - Ipv4AddressHelper address; - address.SetBase("10.1.1.0", "255.255.255.0"); - - Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs); - Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs); - if (verbose) - { - WimaxHelper::EnableLogComponents(); // Turn on all wimax logging - } - /*------------------------------*/ - auto udpServer = new UdpServerHelper[nbSS / 2]; - auto serverApps = new ApplicationContainer[nbSS / 2]; - auto udpClient = new UdpClientHelper[nbSS / 2]; - auto clientApps = new ApplicationContainer[nbSS / 2]; - - for (int i = 0; i < nbSS / 2; i++) - { - // set server port to 100+(i*10) - udpServer[i] = UdpServerHelper(100 + (i * 10)); - serverApps[i] = udpServer[i].Install(ssNodes.Get(i)); - serverApps[i].Start(Seconds(6)); - serverApps[i].Stop(Seconds(duration)); - - udpClient[i] = UdpClientHelper(SSinterfaces.GetAddress(i), 100 + (i * 10)); - udpClient[i].SetAttribute("MaxPackets", UintegerValue(1200)); - udpClient[i].SetAttribute("Interval", TimeValue(Seconds(0.12))); - udpClient[i].SetAttribute("PacketSize", UintegerValue(800)); - - clientApps[i] = udpClient[i].Install(ssNodes.Get(i + (nbSS / 2))); - clientApps[i].Start(Seconds(6)); - clientApps[i].Stop(Seconds(duration)); - } - - Simulator::Stop(Seconds(duration + 0.1)); - /* - * Setup 1 transport connections between each SS and the BS - */ - for (int i = 0; i < nbSS / 2; i++) - { - IpcsClassifierRecord DlClassifierBe(Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - SSinterfaces.GetAddress(i), - Ipv4Mask("255.255.255.255"), - 0, - 65000, - 100 + (i * 10), - 100 + (i * 10), - 17, - 1); - ServiceFlow DlServiceFlowBe = wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_DOWN, - ServiceFlow::SF_TYPE_BE, - DlClassifierBe); - ss[i]->AddServiceFlow(DlServiceFlowBe); - IpcsClassifierRecord ulClassifierBe(SSinterfaces.GetAddress(i + (nbSS / 2)), - Ipv4Mask("255.255.255.255"), - Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - 0, - 65000, - 100 + (i * 10), - 100 + (i * 10), - 17, - 1); - ServiceFlow ulServiceFlowBe = wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_UP, - ServiceFlow::SF_TYPE_BE, - ulClassifierBe); - ss[i + (nbSS / 2)]->AddServiceFlow(ulServiceFlowBe); - } - - NS_LOG_INFO("Starting simulation....."); - Simulator::Run(); - - delete[] clientApps; - delete[] udpClient; - delete[] serverApps; - delete[] udpServer; - for (int i = 0; i < nbSS; i++) - { - ss[i] = nullptr; - } - delete[] ss; - - bs = nullptr; - - Simulator::Destroy(); - NS_LOG_INFO("Done."); - - return 0; -} diff --git a/src/wimax/examples/wimax-multicast.cc b/src/wimax/examples/wimax-multicast.cc deleted file mode 100644 index b67d2d407..000000000 --- a/src/wimax/examples/wimax-multicast.cc +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -// Default network topology includes: -// - A base station (BS) -// - Some number of SSs specified by the variable nbSS (defaults to 10) -// - A multicast router (ASNGW) -// - A multicast streamer - -// Two Lans are setup: The first one between the multicast streamer and the -// ASNGW, the second one between the ASNGW (router) and the base station - -// +-----+ +-----+ +-----+ +-----+ +-----+ -// | SS0 | | SS1 | | SS2 | | SS3 | | SS4 | -// +-----+ +-----+ +-----+ +-----+ +-----+ -// 10.1.0.1 10.1.0.2 10.1.0.3 10.1.0.4 10.1.0.5 -// -------- -------- ------- ------- -------- -// ((*)) ((*)) ((*)) ((*)) ((*)) -// -// LAN2 (11.1.1.0) -// =============== -// 10.1.0.11 | | -// +------------+ ASNGW multicast Streamer -// ((*))==|Base Station| | (12.1.1.0) | -// +------------+ ================== -// LAN1 -// -// ((*)) ((*)) ((*)) ((*)) ((*)) -// ------- -------- -------- ------- -------- -// 10.1.0.6 10.1.0.7 10.1.0.8 10.1.0.9 10.1.0.10 -// +-----+ +-----+ +-----+ +-----+ +-----+ -// | SS5 | | SS6 | | SS7 | | SS8 | | SS9 | -// +-----+ +-----+ +-----+ +-----+ +-----+ - -#include "ns3/applications-module.h" -#include "ns3/core-module.h" -#include "ns3/csma-module.h" -#include "ns3/global-route-manager.h" -#include "ns3/internet-module.h" -#include "ns3/mobility-module.h" -#include "ns3/network-module.h" -#include "ns3/vector.h" -#include "ns3/wimax-module.h" - -#include -#include - -using namespace ns3; - -NS_LOG_COMPONENT_DEFINE("WimaxMulticastSimulation"); - -int -main(int argc, char* argv[]) -{ - bool verbose = false; - - NodeContainer ssNodes; - std::vector> ss; - NetDeviceContainer ssDevs; - Ipv4InterfaceContainer SSinterfaces; - - NodeContainer bsNodes; - Ptr bs; - NetDeviceContainer bsDevs; - NetDeviceContainer bsDevsOne; - Ipv4InterfaceContainer BSinterfaces; - - UdpTraceClientHelper udpClient; - ApplicationContainer clientApps; - - Ptr channel; - NodeContainer Streamer_Node; - NodeContainer ASNGW_Node; - - Ptr BSPosition; - std::vector> SSPosition; - std::vector> SSPosAllocator; - - // default values - int nbSS = 10; - int duration = 7; - int schedType = 0; - WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - - CommandLine cmd(__FILE__); - cmd.AddValue("nbSS", "number of subscriber station to create", nbSS); - cmd.AddValue("scheduler", "type of scheduler to use with the netdevices", schedType); - cmd.AddValue("duration", "duration of the simulation in seconds", duration); - cmd.AddValue("verbose", "turn on all WimaxNetDevice log components", verbose); - cmd.Parse(argc, argv); - - LogComponentEnable("UdpTraceClient", LOG_LEVEL_INFO); - LogComponentEnable("UdpServer", LOG_LEVEL_INFO); - - switch (schedType) - { - case 0: - scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - break; - case 1: - scheduler = WimaxHelper::SCHED_TYPE_MBQOS; - break; - case 2: - scheduler = WimaxHelper::SCHED_TYPE_RTPS; - break; - default: - scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - } - - ss.resize(nbSS); - SSPosition.resize(nbSS); - SSPosAllocator.resize(nbSS); - - ssNodes.Create(nbSS); - bsNodes.Create(1); - - Streamer_Node.Create(1); - ASNGW_Node.Create(1); - - WimaxHelper wimax; - - channel = CreateObject(); - channel->SetPropagationModel(SimpleOfdmWimaxChannel::COST231_PROPAGATION); - ssDevs = wimax.Install(ssNodes, - WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - channel, - scheduler); - Ptr dev = wimax.Install(bsNodes.Get(0), - WimaxHelper::DEVICE_TYPE_BASE_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - channel, - scheduler); - - BSPosition = CreateObject(); - - BSPosition->SetPosition(Vector(1000, 0, 0)); - bsNodes.Get(0)->AggregateObject(BSPosition); - bsDevs.Add(dev); - if (verbose) - { - WimaxHelper::EnableLogComponents(); // Turn on all wimax logging - } - - for (int i = 0; i < nbSS; i++) - { - SSPosition[i] = CreateObject(); - SSPosAllocator[i] = CreateObject(); - Ptr xVar = CreateObject(); - xVar->SetAttribute("Min", DoubleValue((i / 40.0) * 2000)); - xVar->SetAttribute("Max", DoubleValue((i / 40.0 + 1) * 2000)); - SSPosAllocator[i]->SetX(xVar); - Ptr yVar = CreateObject(); - yVar->SetAttribute("Min", DoubleValue((i / 40.0) * 2000)); - yVar->SetAttribute("Max", DoubleValue((i / 40.0 + 1) * 2000)); - SSPosAllocator[i]->SetY(yVar); - SSPosition[i]->SetAttribute("PositionAllocator", PointerValue(SSPosAllocator[i])); - SSPosition[i]->SetAttribute("Speed", - StringValue("ns3::UniformRandomVariable[Min=10.3|Max=40.7]")); - SSPosition[i]->SetAttribute("Pause", - StringValue("ns3::ConstantRandomVariable[Constant=0.01]")); - - ss[i] = ssDevs.Get(i)->GetObject(); - ss[i]->SetModulationType(WimaxPhy::MODULATION_TYPE_QAM16_12); - ssNodes.Get(i)->AggregateObject(SSPosition[i]); - } - - bs = bsDevs.Get(0)->GetObject(); - - CsmaHelper csmaASN_BS; - CsmaHelper csmaStreamer_ASN; - - // First LAN BS and ASN - NodeContainer LAN_ASN_BS; - - LAN_ASN_BS.Add(bsNodes.Get(0)); - - LAN_ASN_BS.Add(ASNGW_Node.Get(0)); - - csmaASN_BS.SetChannelAttribute("DataRate", DataRateValue(DataRate(10000000))); - csmaASN_BS.SetChannelAttribute("Delay", TimeValue(MilliSeconds(2))); - csmaASN_BS.SetDeviceAttribute("Mtu", UintegerValue(1500)); - NetDeviceContainer LAN_ASN_BS_Devs = csmaASN_BS.Install(LAN_ASN_BS); - - NetDeviceContainer BS_CSMADevs; - - BS_CSMADevs.Add(LAN_ASN_BS_Devs.Get(0)); - - NetDeviceContainer ASN_Devs1; - ASN_Devs1.Add(LAN_ASN_BS_Devs.Get(1)); - - // Second LAN ASN-GW and Streamer - - NodeContainer LAN_ASN_STREAMER; - LAN_ASN_STREAMER.Add(ASNGW_Node.Get(0)); - LAN_ASN_STREAMER.Add(Streamer_Node.Get(0)); - - csmaStreamer_ASN.SetChannelAttribute("DataRate", DataRateValue(DataRate(10000000))); - csmaStreamer_ASN.SetChannelAttribute("Delay", TimeValue(MilliSeconds(2))); - csmaStreamer_ASN.SetDeviceAttribute("Mtu", UintegerValue(1500)); - - NetDeviceContainer LAN_ASN_STREAMER_Devs = csmaStreamer_ASN.Install(LAN_ASN_STREAMER); - - NetDeviceContainer STREAMER_Devs; - NetDeviceContainer ASN_Devs2; - ASN_Devs2.Add(LAN_ASN_STREAMER_Devs.Get(0)); - STREAMER_Devs.Add(LAN_ASN_STREAMER_Devs.Get(1)); - - MobilityHelper mobility; - InternetStackHelper stack; - mobility.Install(bsNodes); - stack.Install(bsNodes); - mobility.Install(ssNodes); - stack.Install(ssNodes); - stack.Install(Streamer_Node); - stack.Install(ASNGW_Node); - - Ipv4AddressHelper address; - - address.SetBase("10.1.0.0", "255.255.255.0"); - bsDevsOne.Add(bs); - BSinterfaces = address.Assign(bsDevsOne); - SSinterfaces = address.Assign(ssDevs); - - address.SetBase("11.1.1.0", "255.255.255.0"); - Ipv4InterfaceContainer BSCSMAInterfaces = address.Assign(BS_CSMADevs); - Ipv4InterfaceContainer ASNCSMAInterfaces1 = address.Assign(ASN_Devs1); - - address.SetBase("12.1.1.0", "255.255.255.0"); - Ipv4InterfaceContainer ASNCSMAInterfaces2 = address.Assign(ASN_Devs2); - Ipv4InterfaceContainer StreamerCSMAInterfaces = address.Assign(STREAMER_Devs); - - Ipv4Address multicastSource("12.1.1.2"); - Ipv4Address multicastGroup("224.30.10.81"); - - Ipv4StaticRoutingHelper multicast; - // 1) Configure a (static) multicast route on ASNGW (multicastRouter) - Ptr multicastRouter = ASNGW_Node.Get(0); // The node in question - Ptr inputIf = ASN_Devs2.Get(0); // The input NetDevice - - multicast.AddMulticastRoute(multicastRouter, - multicastSource, - multicastGroup, - inputIf, - ASN_Devs1); - - // 2) Set up a default multicast route on the sender n0 - Ptr sender = Streamer_Node.Get(0); - Ptr senderIf = STREAMER_Devs.Get(0); - multicast.SetDefaultMulticastRoute(sender, senderIf); - - // 1) Configure a (static) multicast route on ASNGW (multicastRouter) - multicastRouter = bsNodes.Get(0); // The node in question - inputIf = BS_CSMADevs.Get(0); // The input NetDevice - - multicast.AddMulticastRoute(multicastRouter, - multicastSource, - multicastGroup, - inputIf, - bsDevsOne); - - uint16_t multicast_port = 100; - - UdpServerHelper udpServerHelper = UdpServerHelper(multicast_port); - ApplicationContainer serverApps; - serverApps = udpServerHelper.Install(ssNodes); - serverApps.Start(Seconds(6)); - serverApps.Stop(Seconds(duration)); - - udpClient = UdpTraceClientHelper(multicastGroup, multicast_port, ""); - - clientApps = udpClient.Install(Streamer_Node.Get(0)); - clientApps.Start(Seconds(6)); - clientApps.Stop(Seconds(duration)); - - IpcsClassifierRecord MulticastClassifier(Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - multicastGroup, - Ipv4Mask("255.255.255.255"), - 0, - 65000, - multicast_port, - multicast_port, - 17, - 1); - - ServiceFlow MulticastServiceFlow = wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_DOWN, - ServiceFlow::SF_TYPE_UGS, - MulticastClassifier); - - bs->GetServiceFlowManager()->AddMulticastServiceFlow(MulticastServiceFlow, - WimaxPhy::MODULATION_TYPE_QPSK_12); - - Simulator::Stop(Seconds(duration + 0.1)); - NS_LOG_INFO("Starting simulation....."); - Simulator::Run(); - - for (int i = 0; i < nbSS; i++) - { - ss[i] = nullptr; - SSPosition[i] = nullptr; - SSPosAllocator[i] = nullptr; - } - - bs = nullptr; - - Simulator::Destroy(); - NS_LOG_INFO("Done."); - - return 0; -} diff --git a/src/wimax/examples/wimax-simple.cc b/src/wimax/examples/wimax-simple.cc deleted file mode 100644 index 869bc7740..000000000 --- a/src/wimax/examples/wimax-simple.cc +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -// -// Default network topology includes a base station (BS) and 2 -// subscriber station (SS). - -// +-----+ -// | SS0 | -// +-----+ -// 10.1.1.1 -// ------- -// ((*)) -// -// 10.1.1.7 -// +------------+ -// |Base Station| ==((*)) -// +------------+ -// -// ((*)) -// ------- -// 10.1.1.2 -// +-----+ -// | SS1 | -// +-----+ - -#include "ns3/applications-module.h" -#include "ns3/core-module.h" -#include "ns3/global-route-manager.h" -#include "ns3/internet-module.h" -#include "ns3/ipcs-classifier-record.h" -#include "ns3/mobility-module.h" -#include "ns3/network-module.h" -#include "ns3/service-flow.h" -#include "ns3/wimax-module.h" - -#include - -using namespace ns3; - -NS_LOG_COMPONENT_DEFINE("WimaxSimpleExample"); - -int -main(int argc, char* argv[]) -{ - bool verbose = false; - - int duration = 7; - int schedType = 0; - WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - - CommandLine cmd(__FILE__); - cmd.AddValue("scheduler", "type of scheduler to use with the network devices", schedType); - cmd.AddValue("duration", "duration of the simulation in seconds", duration); - cmd.AddValue("verbose", "turn on all WimaxNetDevice log components", verbose); - cmd.Parse(argc, argv); - LogComponentEnable("UdpClient", LOG_LEVEL_INFO); - LogComponentEnable("UdpServer", LOG_LEVEL_INFO); - switch (schedType) - { - case 0: - scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - break; - case 1: - scheduler = WimaxHelper::SCHED_TYPE_MBQOS; - break; - case 2: - scheduler = WimaxHelper::SCHED_TYPE_RTPS; - break; - default: - scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - } - - NodeContainer ssNodes; - NodeContainer bsNodes; - - ssNodes.Create(2); - bsNodes.Create(1); - - WimaxHelper wimax; - - NetDeviceContainer ssDevs; - NetDeviceContainer bsDevs; - - ssDevs = wimax.Install(ssNodes, - WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - bsDevs = wimax.Install(bsNodes, - WimaxHelper::DEVICE_TYPE_BASE_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - - wimax.EnableAscii("bs-devices", bsDevs); - wimax.EnableAscii("ss-devices", ssDevs); - - Ptr ss[2]; - - for (int i = 0; i < 2; i++) - { - ss[i] = ssDevs.Get(i)->GetObject(); - ss[i]->SetModulationType(WimaxPhy::MODULATION_TYPE_QAM16_12); - } - - Ptr bs; - - bs = bsDevs.Get(0)->GetObject(); - - InternetStackHelper stack; - stack.Install(bsNodes); - stack.Install(ssNodes); - - Ipv4AddressHelper address; - address.SetBase("10.1.1.0", "255.255.255.0"); - - Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs); - Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs); - - if (verbose) - { - WimaxHelper::EnableLogComponents(); // Turn on all wimax logging - } - /*------------------------------*/ - UdpServerHelper udpServer; - ApplicationContainer serverApps; - UdpClientHelper udpClient; - ApplicationContainer clientApps; - - udpServer = UdpServerHelper(100); - - serverApps = udpServer.Install(ssNodes.Get(0)); - serverApps.Start(Seconds(6)); - serverApps.Stop(Seconds(duration)); - - udpClient = UdpClientHelper(SSinterfaces.GetAddress(0), 100); - udpClient.SetAttribute("MaxPackets", UintegerValue(1200)); - udpClient.SetAttribute("Interval", TimeValue(Seconds(0.5))); - udpClient.SetAttribute("PacketSize", UintegerValue(1024)); - - clientApps = udpClient.Install(ssNodes.Get(1)); - clientApps.Start(Seconds(6)); - clientApps.Stop(Seconds(duration)); - - Simulator::Stop(Seconds(duration + 0.1)); - - wimax.EnablePcap("wimax-simple-ss0", ssNodes.Get(0)->GetId(), ss[0]->GetIfIndex()); - wimax.EnablePcap("wimax-simple-ss1", ssNodes.Get(1)->GetId(), ss[1]->GetIfIndex()); - wimax.EnablePcap("wimax-simple-bs0", bsNodes.Get(0)->GetId(), bs->GetIfIndex()); - - IpcsClassifierRecord DlClassifierUgs(Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - SSinterfaces.GetAddress(0), - Ipv4Mask("255.255.255.255"), - 0, - 65000, - 100, - 100, - 17, - 1); - ServiceFlow DlServiceFlowUgs = wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_DOWN, - ServiceFlow::SF_TYPE_RTPS, - DlClassifierUgs); - - IpcsClassifierRecord UlClassifierUgs(SSinterfaces.GetAddress(1), - Ipv4Mask("255.255.255.255"), - Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - 0, - 65000, - 100, - 100, - 17, - 1); - ServiceFlow UlServiceFlowUgs = wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_UP, - ServiceFlow::SF_TYPE_RTPS, - UlClassifierUgs); - ss[0]->AddServiceFlow(DlServiceFlowUgs); - ss[1]->AddServiceFlow(UlServiceFlowUgs); - - NS_LOG_INFO("Starting simulation....."); - Simulator::Run(); - - ss[0] = nullptr; - ss[1] = nullptr; - bs = nullptr; - - Simulator::Destroy(); - NS_LOG_INFO("Done."); - - return 0; -} diff --git a/src/wimax/helper/wimax-helper.cc b/src/wimax/helper/wimax-helper.cc deleted file mode 100644 index f95ba6fdc..000000000 --- a/src/wimax/helper/wimax-helper.cc +++ /dev/null @@ -1,705 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - */ - -#include "wimax-helper.h" - -#include "ns3/bs-net-device.h" -#include "ns3/config.h" -#include "ns3/log.h" -#include "ns3/packet.h" -#include "ns3/pointer.h" -#include "ns3/simple-ofdm-wimax-channel.h" -#include "ns3/simple-ofdm-wimax-phy.h" -#include "ns3/simulator.h" -#include "ns3/ss-net-device.h" -#include "ns3/wimax-channel.h" -#include "ns3/wimax-mac-to-mac-header.h" -#include "ns3/wimax-net-device.h" -#include "ns3/wimax-phy.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("WimaxHelper"); - -WimaxHelper::WimaxHelper() - : m_channel(nullptr) -{ -} - -WimaxHelper::~WimaxHelper() -{ -} - -void -WimaxHelper::EnableAsciiForConnection(Ptr os, - uint32_t nodeid, - uint32_t deviceid, - char* netdevice, - char* connection) -{ - std::ostringstream oss; - oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::" << netdevice << "/" - << connection << "/TxQueue/Enqueue"; - Config::Connect(oss.str(), - MakeBoundCallback(&AsciiTraceHelper::DefaultEnqueueSinkWithContext, os)); - - oss.str(""); - oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::" << netdevice << "/" - << connection << "/TxQueue/Dequeue"; - Config::Connect(oss.str(), - MakeBoundCallback(&AsciiTraceHelper::DefaultDequeueSinkWithContext, os)); - - oss.str(""); - oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::" << netdevice << "/" - << connection << "/TxQueue/Drop"; - Config::Connect(oss.str(), - MakeBoundCallback(&AsciiTraceHelper::DefaultDropSinkWithContext, os)); -} - -Ptr -WimaxHelper::CreatePhy(PhyType phyType) -{ - Ptr phy; - switch (phyType) - { - case SIMPLE_PHY_TYPE_OFDM: - phy = CreateObject(); - if (!m_channel) - { - m_channel = - CreateObject(SimpleOfdmWimaxChannel::COST231_PROPAGATION); - } - break; - default: - NS_FATAL_ERROR("Invalid physical type"); - break; - } - - return phy; -} - -void -WimaxHelper::SetPropagationLossModel(SimpleOfdmWimaxChannel::PropModel propagationModel) -{ - if (!m_channel) - { - m_channel = CreateObject(); - } - m_channel->GetObject()->SetPropagationModel(propagationModel); -} - -Ptr -WimaxHelper::CreatePhy(PhyType phyType, char* SNRTraceFilePath, bool activateLoss) -{ - Ptr phy; - Ptr sphy; - switch (phyType) - { - case SIMPLE_PHY_TYPE_OFDM: - sphy = CreateObject(); - phy = sphy; - sphy->SetSNRToBlockErrorRateTracesPath(SNRTraceFilePath); - sphy->ActivateLoss(activateLoss); - if (!m_channel) - { - m_channel = - CreateObject(SimpleOfdmWimaxChannel::COST231_PROPAGATION); - } - break; - default: - NS_FATAL_ERROR("Invalid physical type"); - break; - } - - return phy; -} - -Ptr -WimaxHelper::CreatePhyWithoutChannel(PhyType phyType) -{ - Ptr phy; - switch (phyType) - { - case SIMPLE_PHY_TYPE_OFDM: - phy = CreateObject(); - break; - default: - NS_FATAL_ERROR("Invalid physical type"); - break; - } - - return phy; -} - -Ptr -WimaxHelper::CreatePhyWithoutChannel(PhyType phyType, char* SNRTraceFilePath, bool activateLoss) -{ - Ptr phy; - Ptr sphy; - switch (phyType) - { - case SIMPLE_PHY_TYPE_OFDM: - sphy = CreateObject(); - phy = sphy; - sphy->SetSNRToBlockErrorRateTracesPath(SNRTraceFilePath); - sphy->ActivateLoss(activateLoss); - break; - default: - NS_FATAL_ERROR("Invalid physical type"); - break; - } - - return phy; -} - -Ptr -WimaxHelper::CreateUplinkScheduler(SchedulerType schedulerType) -{ - Ptr uplinkScheduler; - switch (schedulerType) - { - case SCHED_TYPE_SIMPLE: - uplinkScheduler = CreateObject(); - break; - case SCHED_TYPE_RTPS: - uplinkScheduler = CreateObject(); - break; - case SCHED_TYPE_MBQOS: - uplinkScheduler = CreateObject(Seconds(0.25)); - break; - default: - NS_FATAL_ERROR("Invalid scheduling type"); - break; - } - return uplinkScheduler; -} - -Ptr -WimaxHelper::CreateBSScheduler(SchedulerType schedulerType) -{ - Ptr bsScheduler; - switch (schedulerType) - { - case SCHED_TYPE_SIMPLE: - bsScheduler = CreateObject(); - break; - case SCHED_TYPE_RTPS: - bsScheduler = CreateObject(); - break; - case SCHED_TYPE_MBQOS: - bsScheduler = CreateObject(); - break; - default: - NS_FATAL_ERROR("Invalid scheduling type"); - break; - } - return bsScheduler; -} - -NetDeviceContainer -WimaxHelper::Install(NodeContainer c, - NetDeviceType deviceType, - PhyType phyType, - SchedulerType schedulerType, - double frameDuration) -{ - NetDeviceContainer devices; - for (auto i = c.Begin(); i != c.End(); i++) - { - Ptr node = *i; - Ptr phy = CreatePhy(phyType); - - // Set SuperFrame Duration - phy->SetFrameDuration(Seconds(frameDuration)); - - Ptr device; - Ptr uplinkScheduler = CreateUplinkScheduler(schedulerType); - Ptr bsScheduler = CreateBSScheduler(schedulerType); - - if (deviceType == DEVICE_TYPE_BASE_STATION) - { - // attach phy - Ptr deviceBS; - deviceBS = CreateObject(node, phy, uplinkScheduler, bsScheduler); - device = deviceBS; - uplinkScheduler->SetBs(deviceBS); - bsScheduler->SetBs(deviceBS); - } - else - { - device = CreateObject(node, phy); - } - device->SetAddress(Mac48Address::Allocate()); - phy->SetDevice(device); - device->Start(); - device->Attach(m_channel); // attach channel - - node->AddDevice(device); - - devices.Add(device); - } - return devices; -} - -NetDeviceContainer -WimaxHelper::Install(NodeContainer c, - NetDeviceType deviceType, - PhyType phyType, - SchedulerType schedulerType) -{ - NetDeviceContainer devices; - for (auto i = c.Begin(); i != c.End(); i++) - { - Ptr node = *i; - Ptr phy = CreatePhy(phyType); - Ptr device; - Ptr uplinkScheduler = CreateUplinkScheduler(schedulerType); - Ptr bsScheduler = CreateBSScheduler(schedulerType); - - if (deviceType == DEVICE_TYPE_BASE_STATION) - { - // attach phy - Ptr deviceBS; - deviceBS = CreateObject(node, phy, uplinkScheduler, bsScheduler); - device = deviceBS; - uplinkScheduler->SetBs(deviceBS); - bsScheduler->SetBs(deviceBS); - } - else - { - device = CreateObject(node, phy); - } - device->SetAddress(Mac48Address::Allocate()); - phy->SetDevice(device); - device->Start(); - device->Attach(m_channel); // attach channel - - node->AddDevice(device); - - devices.Add(device); - } - return devices; -} - -NetDeviceContainer -WimaxHelper::Install(NodeContainer c, - NetDeviceType deviceType, - PhyType phyType, - Ptr channel, - SchedulerType schedulerType) -{ - NetDeviceContainer devices; - for (auto i = c.Begin(); i != c.End(); i++) - { - Ptr node = *i; - - Ptr phy = CreatePhyWithoutChannel(phyType, (char*)"dummy", false); - Ptr device; - Ptr uplinkScheduler = CreateUplinkScheduler(schedulerType); - Ptr bsScheduler = CreateBSScheduler(schedulerType); - - if (deviceType == DEVICE_TYPE_BASE_STATION) - { - Ptr deviceBS; - deviceBS = CreateObject(node, phy, uplinkScheduler, bsScheduler); - device = deviceBS; - uplinkScheduler->SetBs(deviceBS); - bsScheduler->SetBs(deviceBS); - } - else - { - device = CreateObject(node, phy); - } - device->SetAddress(Mac48Address::Allocate()); - phy->SetDevice(device); - device->Start(); - device->Attach(channel); - - node->AddDevice(device); - devices.Add(device); - } - return devices; -} - -Ptr -WimaxHelper::Install(Ptr node, - NetDeviceType deviceType, - PhyType phyType, - Ptr channel, - SchedulerType schedulerType) -{ - // Ptr phy = CreatePhyWithoutChannel (phyType); - Ptr phy = CreatePhyWithoutChannel(phyType, (char*)"dummy", false); - Ptr device; - Ptr uplinkScheduler = CreateUplinkScheduler(schedulerType); - Ptr bsScheduler = CreateBSScheduler(schedulerType); - - if (deviceType == DEVICE_TYPE_BASE_STATION) - { - Ptr deviceBS; - deviceBS = CreateObject(node, phy, uplinkScheduler, bsScheduler); - device = deviceBS; - uplinkScheduler->SetBs(deviceBS); - bsScheduler->SetBs(deviceBS); - } - else - { - device = CreateObject(node, phy); - } - device->SetAddress(Mac48Address::Allocate()); - phy->SetDevice(device); - device->Start(); - device->Attach(channel); - - node->AddDevice(device); - - return device; -} - -void -WimaxHelper::EnableLogComponents() -{ - LogComponentEnable("BandwidthManager", LOG_LEVEL_ALL); - LogComponentEnable("BSLinkManager", LOG_LEVEL_ALL); - LogComponentEnable("BaseStationNetDevice", LOG_LEVEL_ALL); - LogComponentEnable("BSSchedulerRtps", LOG_LEVEL_ALL); - LogComponentEnable("BSSchedulerSimple", LOG_LEVEL_ALL); - LogComponentEnable("BSScheduler", LOG_LEVEL_ALL); - LogComponentEnable("BsServiceFlowManager", LOG_LEVEL_ALL); - LogComponentEnable("UplinkSchedulerMBQoS", LOG_LEVEL_ALL); - LogComponentEnable("UplinkSchedulerRtps", LOG_LEVEL_ALL); - LogComponentEnable("UplinkSchedulerSimple", LOG_LEVEL_ALL); - LogComponentEnable("UplinkScheduler", LOG_LEVEL_ALL); - LogComponentEnable("BurstProfileManager", LOG_LEVEL_ALL); - LogComponentEnable("ConnectionManager", LOG_LEVEL_ALL); - LogComponentEnable("IpcsClassifierRecord", LOG_LEVEL_ALL); - LogComponentEnable("IpcsClassifier", LOG_LEVEL_ALL); - LogComponentEnable("MACMESSAGES", LOG_LEVEL_ALL); - LogComponentEnable("PacketBurst", LOG_LEVEL_ALL); - LogComponentEnable("ServiceFlowManager", LOG_LEVEL_ALL); - LogComponentEnable("simpleOfdmWimaxChannel", LOG_LEVEL_ALL); - LogComponentEnable("SimpleOfdmWimaxPhy", LOG_LEVEL_ALL); - LogComponentEnable("SNRToBlockErrorRateManager", LOG_LEVEL_ALL); - LogComponentEnable("SSLinkManager", LOG_LEVEL_ALL); - LogComponentEnable("SSManager", LOG_LEVEL_ALL); - LogComponentEnable("SubscriberStationNetDevice", LOG_LEVEL_ALL); - LogComponentEnable("SSScheduler", LOG_LEVEL_ALL); - LogComponentEnable("SsServiceFlowManager", LOG_LEVEL_ALL); - LogComponentEnable("WimaxChannel", LOG_LEVEL_ALL); - LogComponentEnable("WimaxMacQueue", LOG_LEVEL_ALL); - LogComponentEnable("WimaxNetDevice", LOG_LEVEL_ALL); - LogComponentEnable("WimaxPhy", LOG_LEVEL_ALL); - LogComponentEnable("Tlv", LOG_LEVEL_ALL); - LogComponentEnable("BandwidthManager", LOG_LEVEL_ALL); - LogComponentEnable("BaseStationNetDevice", LOG_LEVEL_ALL); - LogComponentEnable("BSSchedulerRtps", LOG_LEVEL_ALL); - LogComponentEnable("BSSchedulerSimple", LOG_LEVEL_ALL); - LogComponentEnable("BSScheduler", LOG_LEVEL_ALL); - LogComponentEnable("SubscriberStationNetDevice", LOG_LEVEL_ALL); - LogComponentEnable("SSScheduler", LOG_LEVEL_ALL); - LogComponentEnable("WimaxMacQueue", LOG_LEVEL_ALL); -} - -void -WimaxHelper::AsciiRxEvent(Ptr stream, - std::string path, - Ptr packet, - const Mac48Address& source) -{ - *stream->GetStream() << "r " << Simulator::Now().GetSeconds() << " from: " << source << " "; - *stream->GetStream() << path << std::endl; -} - -void -WimaxHelper::AsciiTxEvent(Ptr stream, - std::string path, - Ptr packet, - const Mac48Address& dest) -{ - *stream->GetStream() << "t " << Simulator::Now().GetSeconds() << " to: " << dest << " "; - *stream->GetStream() << path << std::endl; -} - -ServiceFlow -WimaxHelper::CreateServiceFlow(ServiceFlow::Direction direction, - ServiceFlow::SchedulingType schedulingType, - IpcsClassifierRecord classifier) -{ - CsParameters csParam(CsParameters::ADD, classifier); - ServiceFlow serviceFlow = ServiceFlow(direction); - serviceFlow.SetConvergenceSublayerParam(csParam); - serviceFlow.SetCsSpecification(ServiceFlow::IPV4); - serviceFlow.SetServiceSchedulingType(schedulingType); - serviceFlow.SetMaxSustainedTrafficRate(100); - serviceFlow.SetMinReservedTrafficRate(1000000); - serviceFlow.SetMinTolerableTrafficRate(1000000); - serviceFlow.SetMaximumLatency(100); - serviceFlow.SetMaxTrafficBurst(2000); - serviceFlow.SetTrafficPriority(1); - serviceFlow.SetUnsolicitedGrantInterval(1); - serviceFlow.SetMaxSustainedTrafficRate(70); - serviceFlow.SetToleratedJitter(10); - serviceFlow.SetSduSize(49); - serviceFlow.SetRequestTransmissionPolicy(0); - return serviceFlow; -} - -void -WimaxHelper::EnableAsciiInternal(Ptr stream, - std::string prefix, - Ptr nd, - bool explicitFilename) -{ - // - // All of the ascii enable functions vector through here including the ones - // that are wandering through all of devices on perhaps all of the nodes in - // the system. We can only deal with devices of type CsmaNetDevice. - // - Ptr device = nd->GetObject(); - if (!device) - { - NS_LOG_INFO("WimaxHelper::EnableAsciiInternal(): Device " - << device << " not of type ns3::WimaxNetDevice"); - return; - } - - // - // Our default trace sinks are going to use packet printing, so we have to - // make sure that is turned on. - // - Packet::EnablePrinting(); - - // - // If we are not provided an OutputStreamWrapper, we are expected to create - // one using the usual trace filename conventions and do a Hook*WithoutContext - // since there will be one file per context and therefore the context would - // be redundant. - // - if (!stream) - { - // - // Set up an output stream object to deal with private ofstream copy - // constructor and lifetime issues. Let the helper decide the actual - // name of the file given the prefix. - // - AsciiTraceHelper asciiTraceHelper; - std::string filename; - if (explicitFilename) - { - filename = prefix; - } - else - { - filename = asciiTraceHelper.GetFilenameFromDevice(prefix, device); - } - Ptr theStream = asciiTraceHelper.CreateFileStream(filename); - - uint32_t nodeid = nd->GetNode()->GetId(); - uint32_t deviceid = nd->GetIfIndex(); - std::ostringstream oss; - // - // The MacRx trace source provides our "r" event. - // - - oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WimaxNetDevice/Rx"; - Config::Connect(oss.str(), MakeBoundCallback(&WimaxHelper::AsciiRxEvent, theStream)); - oss.str(""); - oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WimaxNetDevice/Tx"; - Config::Connect(oss.str(), MakeBoundCallback(&WimaxHelper::AsciiTxEvent, theStream)); - // - // The "+", '-', and 'd' events are driven by trace sources actually in the - // transmit queue. - // - - EnableAsciiForConnection(theStream, - nodeid, - deviceid, - (char*)"WimaxNetDevice", - (char*)"InitialRangingConnection"); - EnableAsciiForConnection(theStream, - nodeid, - deviceid, - (char*)"WimaxNetDevice", - (char*)"BroadcastConnection"); - - // The following connections can not be made right away because the BasicConnection and the - // PrimaryConnection are created later. We defer the creation to the - // SubscriberStationNetDevice - - // EnableAsciiForConnection (theStream, nodeid, deviceid, (char*) - // "SubscriberStationNetDevice", (char*) "BasicConnection"); EnableAsciiForConnection - // (theStream, nodeid, deviceid, (char*) "SubscriberStationNetDevice", (char*) - // "PrimaryConnection"); - - Ptr ssNetDev = DynamicCast(nd); - if (ssNetDev) - { - SubscriberStationNetDevice::AsciiTraceCallback EnqueueCb = - MakeBoundCallback(&AsciiTraceHelper::DefaultEnqueueSinkWithContext, theStream); - ssNetDev->SetAsciiTxQueueEnqueueCallback(EnqueueCb); - - SubscriberStationNetDevice::AsciiTraceCallback DequeueCb = - MakeBoundCallback(&AsciiTraceHelper::DefaultDequeueSinkWithContext, theStream); - ssNetDev->SetAsciiTxQueueDequeueCallback(DequeueCb); - - SubscriberStationNetDevice::AsciiTraceCallback DropCb = - MakeBoundCallback(&AsciiTraceHelper::DefaultDropSinkWithContext, theStream); - ssNetDev->SetAsciiTxQueueDropCallback(DropCb); - } - - return; - } - - // - // If we are provided an OutputStreamWrapper, we are expected to use it, and - // to provide a context. We are free to come up with our own context if we - // want, and use the AsciiTraceHelper Hook*WithContext functions, but for - // compatibility and simplicity, we just use Config::Connect and let it deal - // with the context. - // - // Note that we are going to use the default trace sinks provided by the - // ascii trace helper. There is actually no AsciiTraceHelper in sight here, - // but the default trace sinks are actually publicly available static - // functions that are always there waiting for just such a case. - // - uint32_t nodeid = nd->GetNode()->GetId(); - uint32_t deviceid = nd->GetIfIndex(); - std::ostringstream oss; - - oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WimaxNetDevice/Rx"; - Config::Connect(oss.str(), MakeBoundCallback(&WimaxHelper::AsciiRxEvent, stream)); - - oss.str(""); - oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WimaxNetDevice/Tx"; - Config::Connect(oss.str(), MakeBoundCallback(&WimaxHelper::AsciiTxEvent, stream)); - - EnableAsciiForConnection(stream, - nodeid, - deviceid, - (char*)"WimaxNetDevice", - (char*)"InitialRangingConnection"); - EnableAsciiForConnection(stream, - nodeid, - deviceid, - (char*)"WimaxNetDevice", - (char*)"BroadcastConnection"); - - // The following connections can not be made right away because the BasicConnection and the - // PrimaryConnection are created later. We defer the creation to the SubscriberStationNetDevice - - // EnableAsciiForConnection (stream, nodeid, deviceid, (char*) "SubscriberStationNetDevice", - // (char*) "BasicConnection"); EnableAsciiForConnection (stream, nodeid, deviceid, (char*) - // "SubscriberStationNetDevice", (char*) "PrimaryConnection"); - - Ptr ssNetDev = DynamicCast(nd); - if (ssNetDev) - { - SubscriberStationNetDevice::AsciiTraceCallback EnqueueCb = - MakeBoundCallback(&AsciiTraceHelper::DefaultEnqueueSinkWithContext, stream); - ssNetDev->SetAsciiTxQueueEnqueueCallback(EnqueueCb); - - SubscriberStationNetDevice::AsciiTraceCallback DequeueCb = - MakeBoundCallback(&AsciiTraceHelper::DefaultDequeueSinkWithContext, stream); - ssNetDev->SetAsciiTxQueueDequeueCallback(DequeueCb); - - SubscriberStationNetDevice::AsciiTraceCallback DropCb = - MakeBoundCallback(&AsciiTraceHelper::DefaultDropSinkWithContext, stream); - ssNetDev->SetAsciiTxQueueDropCallback(DropCb); - } -} - -/** - * @brief print pcap record - * @param file pcap file - * @param burst packet burst to print - */ -static void -PcapSniffTxRxEvent(Ptr file, Ptr burst) -{ - std::list> packets = burst->GetPackets(); - for (auto iter = packets.begin(); iter != packets.end(); ++iter) - { - Ptr p = (*iter)->Copy(); - WimaxMacToMacHeader m2m(p->GetSize()); - p->AddHeader(m2m); - file->Write(Simulator::Now(), p); - } -} - -void -WimaxHelper::EnablePcapInternal(std::string prefix, - Ptr nd, - bool explicitFilename, - bool promiscuous) -{ - // - // All of the Pcap enable functions vector through here including the ones - // that are wandering through all of devices on perhaps all of the nodes in - // the system. We can only deal with devices of type WimaxNetDevice. - // - Ptr device = nd->GetObject(); - if (!device) - { - NS_LOG_INFO("WimaxHelper::EnablePcapInternal(): Device " - << &device << " not of type ns3::WimaxNetDevice"); - return; - } - - Ptr phy = device->GetPhy(); - PcapHelper pcapHelper; - std::string filename; - if (explicitFilename) - { - filename = prefix; - } - else - { - filename = pcapHelper.GetFilenameFromDevice(prefix, device); - } - - Ptr file = - pcapHelper.CreateFile(filename, std::ios::out, PcapHelper::DLT_EN10MB); - - phy->TraceConnectWithoutContext("Tx", MakeBoundCallback(&PcapSniffTxRxEvent, file)); - phy->TraceConnectWithoutContext("Rx", MakeBoundCallback(&PcapSniffTxRxEvent, file)); -} - -int64_t -WimaxHelper::AssignStreams(int64_t stream) -{ - NS_LOG_FUNCTION(this << stream); - return m_channel->AssignStreams(stream); -} - -int64_t -WimaxHelper::AssignStreams(NetDeviceContainer c, int64_t stream) -{ - int64_t currentStream = stream; - Ptr netDevice; - for (auto i = c.Begin(); i != c.End(); ++i) - { - netDevice = (*i); - Ptr wimax = DynamicCast(netDevice); - if (wimax) - { - // Handle any random numbers in the PHY objects. - currentStream += wimax->GetPhy()->AssignStreams(currentStream); - } - } - - // Handle any random numbers in the channel. - currentStream += m_channel->AssignStreams(currentStream); - - return (currentStream - stream); -} - -} // namespace ns3 diff --git a/src/wimax/helper/wimax-helper.h b/src/wimax/helper/wimax-helper.h deleted file mode 100644 index ad000ec92..000000000 --- a/src/wimax/helper/wimax-helper.h +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDCAST - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Amine Ismail - */ - -#ifndef WIMAX_HELPER_H -#define WIMAX_HELPER_H - -#include "ns3/bs-net-device.h" -#include "ns3/bs-scheduler-rtps.h" -#include "ns3/bs-scheduler-simple.h" -#include "ns3/bs-scheduler.h" -#include "ns3/bs-uplink-scheduler-mbqos.h" -#include "ns3/bs-uplink-scheduler-rtps.h" -#include "ns3/bs-uplink-scheduler-simple.h" -#include "ns3/bs-uplink-scheduler.h" -#include "ns3/net-device-container.h" -#include "ns3/node-container.h" -#include "ns3/object-factory.h" -#include "ns3/propagation-loss-model.h" -#include "ns3/service-flow.h" -#include "ns3/simple-ofdm-wimax-channel.h" -#include "ns3/ss-net-device.h" -#include "ns3/trace-helper.h" - -#include - -namespace ns3 -{ - -class WimaxChannel; -class WimaxPhy; -class UplinkScheduler; - -/** - * @brief helps to manage and create WimaxNetDevice objects - * - * This class can help to create a large set of similar - * WimaxNetDevice objects and to configure their attributes - * during creation. - */ - -class WimaxHelper : public PcapHelperForDevice, public AsciiTraceHelperForDevice -{ - public: - /** - * Net Device Type - * Distinguish a subscriber station(SS) device from base station(BS) device - */ - enum NetDeviceType - { - DEVICE_TYPE_SUBSCRIBER_STATION, /**< Subscriber station(SS) device */ - DEVICE_TYPE_BASE_STATION - /**< Base station(BS) device */ - }; - - /** - * WiMAX Physical layer - * WiMAX Physical layers with different levels of detail - */ - enum PhyType - { - SIMPLE_PHY_TYPE_OFDM - }; - - /** - * Scheduler Type - * Different implementations of uplink/downlink scheduler - */ - enum SchedulerType - { - SCHED_TYPE_SIMPLE, /**< A simple priority-based FCFS scheduler */ - SCHED_TYPE_RTPS, /**< A simple scheduler - rtPS based scheduler */ - SCHED_TYPE_MBQOS - /**< An migration-based uplink scheduler */ - }; - - /** - * @brief Create a Wimax helper in an empty state. - */ - WimaxHelper(); - ~WimaxHelper() override; - /** - * @brief Enable ascii trace output on the indicated net device for a given connection - * @param oss The output stream object to use when logging ascii traces. - * @param nodeid the id of the node for which you want to enable tracing. - * @param deviceid the id of the net device for which you want to enable tracing. - * @param netdevice the type of net device for which you want to enable tracing - * (SubscriberStationNetDevice, BaseStationNetDevice or WimaxNetDevice) - * @param connection the connection for which you want to enable tracing - * (InitialRangingConnection, BroadcastConnection, BasicConnection, PrimaryConnection). - */ - static void EnableAsciiForConnection(Ptr oss, - uint32_t nodeid, - uint32_t deviceid, - char* netdevice, - char* connection); - - /** - * @param phyType WiMAX Physical layer type - * @return WiMAX Phy object - * - * Creates a physical layer object to be used in simulation. - */ - Ptr CreatePhy(PhyType phyType); - - /** - * @param schedulerType Scheduling mechanism - * @return Uplink scheduler - * - * Creates a uplink scheduler to be used by base station - * according to selected scheduling mechanism. - */ - Ptr CreateUplinkScheduler(SchedulerType schedulerType); - - /** - * @param schedulerType Scheduling mechanism - * @return Downlink scheduler - * - * Creates a downlink scheduler to be used by base station - * according to selected scheduling mechanism. - */ - Ptr CreateBSScheduler(SchedulerType schedulerType); - - /** - * @param c a set of nodes - * @param type device type to create - * @param phyType a phy to use - * @param schedulerType the type of the scheduling algorithm to install - * @return NetDeviceContainer - * - * For each of the input nodes, a new WiMAX net device (either - * ns3::SubscriberStationNetDevice or ns3::BaseStationNetDevice - * depending on the type parameter) is attached to the shared input channel. - */ - NetDeviceContainer Install(NodeContainer c, - NetDeviceType type, - PhyType phyType, - SchedulerType schedulerType); - - /** - * @param c A set of nodes. - * @param deviceType Device type to create. - * @param phyType PHY type to create. - * @param channel A channel to use. - * @param schedulerType The scheduling mechanism. - * @return NetDeviceContainer - * - * For each of the input nodes, a new WiMAX net device (either - * ns3::SubscriberStationNetDevice or ns3::BaseStationNetDevice - * depending on the type parameter) is attached to the shared input channel. - */ - NetDeviceContainer Install(NodeContainer c, - NetDeviceType deviceType, - PhyType phyType, - Ptr channel, - SchedulerType schedulerType); - /** - * @param c A set of nodes. - * @param deviceType Device type to create. - * @param phyType PHY type to create. - * @param schedulerType The scheduling mechanism. - * @param frameDuration the farme duration in seconds - * @return NetDeviceContainer - * - * For each of the input nodes, a new WiMAX net device (either - * ns3::SubscriberStationNetDevice or ns3::BaseStationNetDevice - * depending on the type parameter) is attached to the shared input channel. - */ - NetDeviceContainer Install(NodeContainer c, - NetDeviceType deviceType, - PhyType phyType, - SchedulerType schedulerType, - double frameDuration); - - /** - * @brief Set the propagation and loss model of the channel. By default the channel - * uses a COST231 propagation and loss model. - * @param propagationModel The propagation and loss model to set - */ - void SetPropagationLossModel(SimpleOfdmWimaxChannel::PropModel propagationModel); - - /** - * @param phyType WiMAX Physical layer type - * @return WiMAX Phy object - * - * Creates a physical layer without a channel - */ - Ptr CreatePhyWithoutChannel(PhyType phyType); - - /** - * @param phyType WiMAX Physical layer type - * @param SNRTraceFilePath of the repository containing the SNR traces files - * @param activateLoss set to 1 to activate losses 0 otherwise - * @return WiMAX Phy object - * - * Creates a physical layer without creating a channel - */ - Ptr CreatePhyWithoutChannel(PhyType phyType, - char* SNRTraceFilePath, - bool activateLoss); - - /** - * @param phyType WiMAX Physical layer type - * @param SNRTraceFilePath the path to the repository containing the SNR traces files - * @param activateLoss set to 1 if you want ton activate losses 0 otherwise - * @return WiMAX Phy object - * - * Creates a physical layer - */ - Ptr CreatePhy(PhyType phyType, char* SNRTraceFilePath, bool activateLoss); - /** - * @param node Node to be installed. - * @param deviceType Device type to create. - * @param phyType PHY type to create. - * @param channel A channel to use. - * @param schedulerType The scheduling mechanism to install on the device. - * @return Ptr - * - * For each of the input nodes, a new WiMAX net device (either - * ns3::SubscriberStationNetDevice or ns3::BaseStationNetDevice - * depending on the type parameter) is attached to the shared input channel. - */ - Ptr Install(Ptr node, - NetDeviceType deviceType, - PhyType phyType, - Ptr channel, - SchedulerType schedulerType); - - /** - * @brief Creates a transport service flow. - * @param direction the direction of the service flow: UP or DOWN. - * @param schedulingType The service scheduling type to be used: UGS, RTPS, NRTPS, BE - * @param classifier The classifier to be used for this service flow - * @return ServiceFlow - * - */ - ServiceFlow CreateServiceFlow(ServiceFlow::Direction direction, - ServiceFlow::SchedulingType schedulingType, - IpcsClassifierRecord classifier); - - /** - * Helper to enable all WimaxNetDevice log components with one statement - */ - static void EnableLogComponents(); - - /** - * Assign a fixed random variable stream number to the random variables - * used by this model. Return the number of streams (possibly zero) that - * have been assigned. - * - * @param stream first stream index to use - * @return the number of stream indices assigned by this model - */ - int64_t AssignStreams(int64_t stream); - - /** - * Assign a fixed random variable stream number to the random variables - * used by this model. Return the number of streams (possibly zero) that - * have been assigned. The Install() method should have previously been - * called by the user. - * - * @param c NetDeviceContainer of the set of net devices for which the - * WimaxNetDevice should be modified to use a fixed stream - * @param stream first stream index to use - * @return the number of stream indices assigned by this helper - */ - int64_t AssignStreams(NetDeviceContainer c, int64_t stream); - - private: - /** - * ASCII trace receive event - * @param stream the output stream - * @param path the path name - * @param packet the packet - * @param source the source MAC address - */ - static void AsciiRxEvent(Ptr stream, - std::string path, - Ptr packet, - const Mac48Address& source); - /** - * ASCII trace transmit event - * @param stream the output stream - * @param path the path - * @param packet the packet - * @param dest the destination MAC address - */ - static void AsciiTxEvent(Ptr stream, - std::string path, - Ptr packet, - const Mac48Address& dest); - /** - * @brief Enable pcap output on the indicated net device. - * - * NetDevice-specific implementation mechanism for hooking the trace and - * writing to the trace file. - * - * @param prefix Filename prefix to use for pcap files. - * @param nd Net device for which you want to enable tracing. - * @param explicitFilename Treat the prefix as an explicit filename if true - * @param promiscuous If true capture all possible packets available at the device. - */ - void EnablePcapInternal(std::string prefix, - Ptr nd, - bool explicitFilename, - bool promiscuous) override; - - /** - * @brief Enable ascii trace output on the indicated net device. - * - * NetDevice-specific implementation mechanism for hooking the trace and - * writing to the trace file. - * - * @param stream The output stream object to use when logging ascii traces. - * @param prefix Filename prefix to use for ascii trace files. - * @param nd Net device for which you want to enable tracing. - * @param explicitFilename Treat the prefix as an explicit filename if true - */ - void EnableAsciiInternal(Ptr stream, - std::string prefix, - Ptr nd, - bool explicitFilename) override; - - Ptr m_channel; ///< wifi channel -}; - -} // namespace ns3 - -#endif /* WIMAX_HELPER_H */ diff --git a/src/wimax/model/bandwidth-manager.cc b/src/wimax/model/bandwidth-manager.cc deleted file mode 100644 index e384bce03..000000000 --- a/src/wimax/model/bandwidth-manager.cc +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "bandwidth-manager.h" - -#include "bs-net-device.h" -#include "burst-profile-manager.h" -#include "connection-manager.h" -#include "service-flow-manager.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-manager.h" -#include "ss-net-device.h" -#include "ss-record.h" - -#include "ns3/node.h" -#include "ns3/simulator.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("BandwidthManager"); - -NS_OBJECT_ENSURE_REGISTERED(BandwidthManager); - -TypeId -BandwidthManager::GetTypeId() -{ - static TypeId tid = TypeId("ns3::BandwidthManager").SetParent().SetGroupName("Wimax"); - return tid; -} - -BandwidthManager::BandwidthManager(Ptr device) - : m_device(device), - m_nrBwReqsSent(0) -{ -} - -BandwidthManager::~BandwidthManager() -{ -} - -void -BandwidthManager::DoDispose() -{ - m_device = nullptr; -} - -uint32_t -BandwidthManager::CalculateAllocationSize(const SSRecord* ssRecord, const ServiceFlow* serviceFlow) -{ - Time currentTime = Simulator::Now(); - Ptr bs = m_device->GetObject(); - uint32_t allocationSize = 0; - - // if SS has a UGS flow then it must set poll-me bit in order to be polled for non-UGS flows - if (serviceFlow->GetSchedulingType() != ServiceFlow::SF_TYPE_UGS && - ssRecord->GetHasServiceFlowUgs() && !ssRecord->GetPollMeBit()) - { - return 0; - } - - switch (serviceFlow->GetSchedulingType()) - { - case ServiceFlow::SF_TYPE_UGS: { - if ((currentTime - serviceFlow->GetRecord()->GetGrantTimeStamp()).GetMilliSeconds() >= - serviceFlow->GetUnsolicitedGrantInterval()) - { - allocationSize = serviceFlow->GetRecord()->GetGrantSize(); - serviceFlow->GetRecord()->SetGrantTimeStamp(currentTime); - } - } - break; - case ServiceFlow::SF_TYPE_RTPS: { - if ((currentTime - serviceFlow->GetRecord()->GetGrantTimeStamp()).GetMilliSeconds() >= - serviceFlow->GetUnsolicitedPollingInterval()) - { - allocationSize = bs->GetBwReqOppSize(); - serviceFlow->GetRecord()->SetGrantTimeStamp(currentTime); - } - } - break; - case ServiceFlow::SF_TYPE_NRTPS: - /* nrtPS shall be serviced only if sufficient bandwidth is available after servicing - UGS and rtPS scheduling types, hence no specific service interval is used */ - case ServiceFlow::SF_TYPE_BE: { - /* BE shall be serviced only if sufficient bandwidth is available after servicing - the rest of three scheduling types, hence no specific service interval is used */ - - allocationSize = bs->GetBwReqOppSize(); - } - break; - default: - NS_FATAL_ERROR("Invalid scheduling type"); - } - - return allocationSize; -} - -ServiceFlow* -BandwidthManager::SelectFlowForRequest(uint32_t& bytesToRequest) -{ - Ptr packet; - ServiceFlow* serviceFlow = nullptr; - - Ptr ss = m_device->GetObject(); - std::vector serviceFlows = - ss->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_ALL); - - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - serviceFlow = *iter; - if (serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_RTPS || - serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_NRTPS || - serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_BE) - { - if (serviceFlow->HasPackets(MacHeaderType::HEADER_TYPE_GENERIC)) - { - // bandwidth is requested for all packets - bytesToRequest = serviceFlow->GetQueue()->GetQueueLengthWithMACOverhead(); - break; - } - } - } - - return serviceFlow; -} - -void -BandwidthManager::SendBandwidthRequest(uint8_t uiuc, uint16_t allocationSize) -{ - Ptr ss = m_device->GetObject(); - - uint32_t bytesToRequest = 0; - ServiceFlow* serviceFlow = SelectFlowForRequest(bytesToRequest); - - if (!serviceFlow || !bytesToRequest) - { - return; - } - BandwidthRequestHeader bwRequestHdr; - - // bytesToRequest is the queue length of Service Flow and so, - // the header type must be HEADER_TYPE_AGGREGATE! - - bwRequestHdr.SetType((uint8_t)BandwidthRequestHeader::HEADER_TYPE_AGGREGATE); - bwRequestHdr.SetCid(serviceFlow->GetConnection()->GetCid()); - bwRequestHdr.SetBr(bytesToRequest); - - Ptr packet = Create(); - packet->AddHeader(bwRequestHdr); - ss->Enqueue(packet, - MacHeaderType(MacHeaderType::HEADER_TYPE_BANDWIDTH), - serviceFlow->GetConnection()); - m_nrBwReqsSent++; - NS_ASSERT_MSG(uiuc == OfdmUlBurstProfile::UIUC_REQ_REGION_FULL, - "Send Bandwidth Request: !UIUC_REQ_REGION_FULL"); - ss->SendBurst(uiuc, - allocationSize, - serviceFlow->GetConnection(), - MacHeaderType::HEADER_TYPE_BANDWIDTH); -} - -void -BandwidthManager::ProcessBandwidthRequest(const BandwidthRequestHeader& bwRequestHdr) -{ - Ptr bs = m_device->GetObject(); - - ServiceFlow* serviceFlow = - bs->GetConnectionManager()->GetConnection(bwRequestHdr.GetCid())->GetServiceFlow(); - if (bwRequestHdr.GetType() == (uint8_t)BandwidthRequestHeader::HEADER_TYPE_INCREMENTAL) - { - serviceFlow->GetRecord()->UpdateRequestedBandwidth(bwRequestHdr.GetBr()); - } - else - { - serviceFlow->GetRecord()->SetRequestedBandwidth(bwRequestHdr.GetBr()); - bs->GetUplinkScheduler()->OnSetRequestedBandwidth(serviceFlow->GetRecord()); - } - bs->GetUplinkScheduler()->ProcessBandwidthRequest(bwRequestHdr); - // update backlogged - serviceFlow->GetRecord()->IncreaseBacklogged(bwRequestHdr.GetBr()); -} - -void -BandwidthManager::SetSubframeRatio() -{ - // sets ratio of the DL and UL subframes - - Ptr bs = m_device->GetObject(); - - uint32_t symbolsPerFrame = bs->GetPhy()->GetSymbolsPerFrame(); - - /* temporarily divided in half (360 symbols each), shall actually be determined based on UL and - * DL traffic*/ - bs->SetNrDlSymbols(symbolsPerFrame / 2); - bs->SetNrUlSymbols(symbolsPerFrame / 2); -} - -uint32_t -BandwidthManager::GetSymbolsPerFrameAllocated() -{ - Ptr bs = m_device->GetObject(); - - uint32_t allocationPerFrame = 0; - - std::vector* ssRecords = bs->GetSSManager()->GetSSRecords(); - for (auto iter1 = ssRecords->begin(); iter1 != ssRecords->end(); ++iter1) - { - std::vector ssServiceFlows = - (*iter1)->GetServiceFlows(ServiceFlow::SF_TYPE_ALL); - for (auto iter2 = ssServiceFlows.begin(); iter2 != ssServiceFlows.end(); ++iter2) - { - allocationPerFrame += (*iter2)->GetRecord()->GetGrantSize(); - } - } - return allocationPerFrame; -} - -} // namespace ns3 diff --git a/src/wimax/model/bandwidth-manager.h b/src/wimax/model/bandwidth-manager.h deleted file mode 100644 index ac4f55268..000000000 --- a/src/wimax/model/bandwidth-manager.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#ifndef BANDWIDTH_MANAGER_H -#define BANDWIDTH_MANAGER_H - -#include "bs-uplink-scheduler.h" -#include "cid.h" -#include "ul-job.h" -#include "wimax-net-device.h" - -#include - -/* - The same bandwidth manager class serves both for BS and SS though some functions are exclusive to - only one of them. - */ - -namespace ns3 -{ - -class SSRecord; -class ServiceFlow; -class UlJob; -class UplinkScheduler; - -/** - * @ingroup wimax - * @brief This class manage the bandwidth request and grant mechanism. - * The bandwidth request and grant mechanism is supported by the Bandwidth - * Manager. Both BS and SS maintain a bandwidth manager. Furthermore BS's - * bandwidth manager works together with the uplink scheduler to determine - * total bandwidth available and allocation size for each service flow. - * Bandwidth request mechanism is a key feature of the WiMAX scheduler - * since all three non-UGS services explicitly request for bandwidth by - * sending a bandwidth request to BS. - */ -class BandwidthManager : public Object -{ - public: - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - /** - * Constructor - * - * @param device WIMAX device - */ - BandwidthManager(Ptr device); - ~BandwidthManager() override; - - // Delete copy constructor and assignment operator to avoid misuse - BandwidthManager(const BandwidthManager&) = delete; - BandwidthManager& operator=(const BandwidthManager&) = delete; - - void DoDispose() override; - - /** - * Calculate allocation size function - * @param ssRecord the SS record - * @param serviceFlow the service flow - * @returns the allocation size - */ - uint32_t CalculateAllocationSize(const SSRecord* ssRecord, const ServiceFlow* serviceFlow); - /** - * Select flow for request function - * @param bytesToRequest bytes to request - * @returns a service flow - */ - ServiceFlow* SelectFlowForRequest(uint32_t& bytesToRequest); - /** - * Send bandwidth request - * @param uiuc the UIUC - * @param allocationSize the allocation size - */ - void SendBandwidthRequest(uint8_t uiuc, uint16_t allocationSize); - /** - * Process bandwidth request - * @param bwRequestHdr the bandwidth request - */ - void ProcessBandwidthRequest(const BandwidthRequestHeader& bwRequestHdr); - /// Set subframe ratio - void SetSubframeRatio(); - /** - * Get symbols per frame allocated - * @returns the symbols per the frame allocated - */ - uint32_t GetSymbolsPerFrameAllocated(); - - private: - Ptr m_device; ///< the device - uint16_t m_nrBwReqsSent; ///< bandwidth requests sent -}; - -} // namespace ns3 - -#endif /* BANDWIDTH_MANAGER_H */ diff --git a/src/wimax/model/bs-link-manager.cc b/src/wimax/model/bs-link-manager.cc deleted file mode 100644 index cc1423b5f..000000000 --- a/src/wimax/model/bs-link-manager.cc +++ /dev/null @@ -1,367 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "bs-link-manager.h" - -#include "bs-uplink-scheduler.h" -#include "burst-profile-manager.h" -#include "connection-manager.h" -#include "ss-manager.h" -#include "ss-record.h" - -#include "ns3/log.h" -#include "ns3/node.h" -#include "ns3/packet.h" -#include "ns3/simulator.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("BSLinkManager"); - -NS_OBJECT_ENSURE_REGISTERED(BSLinkManager); - -TypeId -BSLinkManager::GetTypeId() -{ - static TypeId tid = TypeId("ns3::BSLinkManager").SetParent().SetGroupName("Wimax"); - return tid; -} - -BSLinkManager::BSLinkManager(Ptr bs) - : m_bs(bs), - m_signalQuality(10), - m_signalQualityThreshold(10) // arbitrary value -{ - tries = 0; -} - -BSLinkManager::~BSLinkManager() -{ - m_bs = nullptr; -} - -uint8_t -BSLinkManager::CalculateRangingOppsToAllocate() -{ - // randomly selecting TOs up to 10, shall actually be decided by scheduler - return rand() % 8 + 2; -} - -/* - * Function mainly to avoid duplicate code in DoReceive () - */ -void -BSLinkManager::ProcessRangingRequest(Cid cid, RngReq rngreq) -{ - NS_ASSERT_MSG(m_bs->GetState() == BaseStationNetDevice::BS_STATE_UL_SUB_FRAME, - "Base station: Error while processing ranging request: !BS_STATE_UL_SUB_FRAME"); - - Time irIntervalBoundary; - - if (m_bs->GetUplinkScheduler()->GetIsInvIrIntrvlAllocated()) - { - if (m_bs->GetUplinkScheduler()->GetIsIrIntrvlAllocated()) - { - irIntervalBoundary = - m_bs->GetUlSubframeStartTime() + - Seconds((m_bs->GetUplinkScheduler()->GetNrIrOppsAllocated() + 1) * - m_bs->GetRangReqOppSize() * m_bs->GetSymbolDuration().GetSeconds()); - } - else - { - irIntervalBoundary = - m_bs->GetUlSubframeStartTime() + - Seconds(m_bs->GetRangReqOppSize() * m_bs->GetSymbolDuration().GetSeconds()); - } - } - else - { - NS_ASSERT_MSG( - m_bs->GetUplinkScheduler()->GetIsIrIntrvlAllocated(), - "Base station: Error while processing ranging request: IR interval not allocated"); - - irIntervalBoundary = - m_bs->GetUlSubframeStartTime() + - Seconds(m_bs->GetUplinkScheduler()->GetNrIrOppsAllocated() * m_bs->GetRangReqOppSize() * - m_bs->GetSymbolDuration().GetSeconds()); - } - - tries++; - - if (Simulator::Now() >= m_bs->GetUlSubframeStartTime() && Simulator::Now() < irIntervalBoundary) - { - PerformRanging(cid, rngreq); - } -} - -void -BSLinkManager::PerformRanging(Cid cid, RngReq rngreq) -{ - RngRsp rngrsp; - bool decodable = false; - - // assuming low power, packet lost or undecodable first 2 times - if (tries < 2) - { - return; - } - if (tries >= 3) - { - decodable = true; - } - - NS_LOG_DEBUG("RNG-REQ:"); - rngreq.PrintDebug(); - - if (!decodable) - { - rngrsp.SetFrameNumber(m_bs->GetNrFrames()); - rngrsp.SetInitRangOppNumber(m_bs->GetRangingOppNumber()); - - SetParametersToAdjust(&rngrsp); - rngrsp.SetRangStatus(WimaxNetDevice::RANGING_STATUS_CONTINUE); // see Figure 64 - ScheduleRngRspMessage(cid, &rngrsp); - } - else - { - if (cid.IsInitialRanging()) - { - PerformInitialRanging(cid, &rngreq, &rngrsp); - } - else - { - // invited initial ranging or periodic ranging - PerformInvitedRanging(cid, &rngrsp); - } - } -} - -void -BSLinkManager::PerformInitialRanging(Cid cid, RngReq* rngreq, RngRsp* rngrsp) -{ - SSRecord* ssRecord = nullptr; - bool isOldSS = m_bs->GetSSManager()->IsInRecord(rngreq->GetMacAddress()); - if (isOldSS) - { - ssRecord = m_bs->GetSSManager()->GetSSRecord(rngreq->GetMacAddress()); - // if this fails it would mean the RNG-RSP with success status was not received by the SS - } - else - { - ssRecord = m_bs->GetSSManager()->CreateSSRecord(rngreq->GetMacAddress()); - } - - if (ChangeDlChannel()) - { - rngrsp->SetDlFreqOverride(GetNewDlChannel()); - AbortRanging(cid, rngrsp, ssRecord, isOldSS); - return; - } - - if (isOldSS) - { - // CIDs already assigned, e.g., RNG-REQ was lost and resent after timeout. reusing old CIDs - ssRecord->ResetRangingCorrectionRetries(); - ssRecord->ResetInvitedRangingRetries(); - } - else - { - m_bs->GetConnectionManager()->AllocateManagementConnections(ssRecord, rngrsp); - - WimaxPhy::ModulationType modulationType; - uint8_t diuc = - m_bs->GetBurstProfileManager()->GetBurstProfileForSS(ssRecord, rngreq, modulationType); - ssRecord->SetModulationType(modulationType); - - // specify in RNG-RSP only if different than what SS requested - if (rngreq->GetReqDlBurstProfile() != diuc) - { - rngrsp->SetDlOperBurstProfile(diuc); - } - - // add SS (Basic CID) to poll list for invited ranging intervals, see Table 115 - ssRecord->EnablePollForRanging(); - } - - rngrsp->SetMacAddress(rngreq->GetMacAddress()); - - if (isOldSS) // CIDs had already been allocated - { - cid = ssRecord->GetBasicCid(); - } - - if (IsRangingAcceptable()) - { - AcceptRanging(cid, rngrsp, ssRecord); - } - else - { - ContinueRanging(cid, rngrsp, ssRecord); - } -} - -void -BSLinkManager::PerformInvitedRanging(Cid cid, RngRsp* rngrsp) -{ - SSRecord* ssRecord = m_bs->GetSSManager()->GetSSRecord(cid); - ssRecord->IncrementRangingCorrectionRetries(); - ssRecord->ResetInvitedRangingRetries(); - - if (IsRangingAcceptable()) - { - AcceptRanging(cid, rngrsp, ssRecord); - } - else - { - if (ssRecord->GetRangingCorrectionRetries() == m_bs->GetMaxRangingCorrectionRetries()) - { - AbortRanging(cid, rngrsp, ssRecord, true); - } - else - { - ContinueRanging(cid, rngrsp, ssRecord); - } - } -} - -void -BSLinkManager::VerifyInvitedRanging(Cid cid, uint8_t uiuc) -{ - if (uiuc == OfdmUlBurstProfile::UIUC_INITIAL_RANGING) - { - SSRecord* ssRecord = m_bs->GetSSManager()->GetSSRecord(cid); - if (ssRecord->GetInvitedRangRetries() > 0) - { - ssRecord->IncrementInvitedRangingRetries(); - - if (ssRecord->GetInvitedRangRetries() == m_bs->GetMaxInvitedRangRetries()) - { - auto rngrsp = new RngRsp(); - AbortRanging(ssRecord->GetBasicCid(), rngrsp, ssRecord, true); - } - // else keep polling - } - } -} - -void -BSLinkManager::SetParametersToAdjust(RngRsp* rngrsp) -{ - // code to calculate parameter adjustment values goes here - rngrsp->SetTimingAdjust(40); - rngrsp->SetPowerLevelAdjust(8); - rngrsp->SetOffsetFreqAdjust(30); -} - -void -BSLinkManager::AbortRanging(Cid cid, RngRsp* rngrsp, SSRecord* ssRecord, bool isOldSS) -{ - rngrsp->SetRangStatus(WimaxNetDevice::RANGING_STATUS_ABORT); - ScheduleRngRspMessage(cid, rngrsp); - - if (isOldSS) - { - ssRecord->SetRangingStatus(WimaxNetDevice::RANGING_STATUS_ABORT); - } - - ssRecord->DisablePollForRanging(); - DeallocateCids(cid); -} - -void -BSLinkManager::AcceptRanging(Cid cid, RngRsp* rngrsp, SSRecord* ssRecord) -{ - rngrsp->SetRangStatus(WimaxNetDevice::RANGING_STATUS_SUCCESS); - ScheduleRngRspMessage(cid, rngrsp); - - /*Shall not be set until the SS receives the RNG-RSP, as it may be lost etc. may be state field - is also added to SSRecord which then set to SS_STATE_REGISTERED once confirmed that SS has - received this RNG-RSP, but how to determine that, may be as a data packet is received by the - SS*/ - ssRecord->SetRangingStatus(WimaxNetDevice::RANGING_STATUS_SUCCESS); - - ssRecord->DisablePollForRanging(); -} - -void -BSLinkManager::ContinueRanging(Cid cid, RngRsp* rngrsp, SSRecord* ssRecord) -{ - rngrsp->SetRangStatus(WimaxNetDevice::RANGING_STATUS_CONTINUE); - ScheduleRngRspMessage(cid, rngrsp); - ssRecord->SetRangingStatus(WimaxNetDevice::RANGING_STATUS_CONTINUE); -} - -void -BSLinkManager::ScheduleRngRspMessage(Cid cid, RngRsp* rngrsp) -{ - if (rngrsp->GetRangStatus() == WimaxNetDevice::RANGING_STATUS_SUCCESS || - rngrsp->GetRangStatus() == WimaxNetDevice::RANGING_STATUS_CONTINUE) - { - SetParametersToAdjust(rngrsp); - } - - Ptr p = Create(); - p->AddHeader(*rngrsp); - p->AddHeader(ManagementMessageType(ManagementMessageType::MESSAGE_TYPE_RNG_RSP)); - - m_bs->Enqueue(p, MacHeaderType(), m_bs->GetConnection(cid)); -} - -void -BSLinkManager::DeallocateCids(Cid cid) -{ - // if necessary, delete entire connections or simply set CIDs to 0 -} - -uint64_t -BSLinkManager::SelectDlChannel() -{ - // Values according to WirelessMAN-OFDM RF profile for 10 MHz channelization - // Section 12.3.3.1 from IEEE 802.16-2004 standard - // profR10_3 : - // channels: 5000 + n â‹… 5 MHz, ∀n ∈ { 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, - // 167 } temporarily set to 1 for quick scanning. To be standard compliant, use a value in the - // list above - return m_bs->GetChannel(1); -} - -bool -BSLinkManager::ChangeDlChannel() -{ - // code to decide if SS shall move to a new channel/frequency goes here - return false; -} - -uint32_t -BSLinkManager::GetNewDlChannel() -{ - // code to determine suggested new frequency goes here - return 100; -} - -uint8_t -BSLinkManager::GetSignalQuality() -{ - // code to measure signal quality goes here - uint8_t signalQuality = m_signalQuality; - m_signalQuality++; - return signalQuality; -} - -bool -BSLinkManager::IsRangingAcceptable() -{ - return GetSignalQuality() > m_signalQualityThreshold; -} - -} // namespace ns3 diff --git a/src/wimax/model/bs-link-manager.h b/src/wimax/model/bs-link-manager.h deleted file mode 100644 index 52b791b66..000000000 --- a/src/wimax/model/bs-link-manager.h +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#ifndef LINK_MANAGER_H -#define LINK_MANAGER_H - -#include "bs-net-device.h" -#include "cid.h" -#include "mac-messages.h" -#include "wimax-net-device.h" - -#include "ns3/event-id.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * - * BaseStation Link Manager - */ -class BSLinkManager : public Object -{ - public: - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - /** - * Constructor - * - * @param bs base station device - */ - BSLinkManager(Ptr bs); - ~BSLinkManager() override; - - // Delete copy constructor and assignment operator to avoid misuse - BSLinkManager(const BSLinkManager&) = delete; - BSLinkManager& operator=(const BSLinkManager&) = delete; - - /** - * @return the ranging opportunities to allocate - */ - uint8_t CalculateRangingOppsToAllocate(); - /** - * @return an available downlink channel - */ - uint64_t SelectDlChannel(); - /** - * @brief process a ranging request message - * @param cid the connection identifier in which the ranging message was received - * @param rngreq the ranging request message - */ - - void ProcessRangingRequest(Cid cid, RngReq rngreq); - /** - * @brief Verifies at the end of an invited ranging interval if SS sent ranging message in it or - * not - * @param cid the connection identifier in which the ranging message was received - * @param uiuc the ranging - */ - void VerifyInvitedRanging(Cid cid, uint8_t uiuc); - - private: - /** - * Perform ranging function - * @param cid the CID - * @param rngreq the ranging request - */ - void PerformRanging(Cid cid, RngReq rngreq); - /** - * Perform initial ranging function - * @param cid the CID - * @param rngreq the ranging request - * @param rngrsp the ranging response - */ - void PerformInitialRanging(Cid cid, RngReq* rngreq, RngRsp* rngrsp); - /** - * Perform inivted ranging function - * @param cid the CID - * @param rngrsp the ranging response - */ - void PerformInvitedRanging(Cid cid, RngRsp* rngrsp); - - /** - * Set parameters to adjust function - * @param rngrsp the ranging response - */ - void SetParametersToAdjust(RngRsp* rngrsp); - /** - * Abort ranging function - * @param cid the CID - * @param rngrsp the ranging response - * @param ssRecord the SS record - * @param isNewSS true if a new SS - */ - void AbortRanging(Cid cid, RngRsp* rngrsp, SSRecord* ssRecord, bool isNewSS); - /** - * Accept ranging function - * @param cid the CID - * @param rngrsp the ranging response - * @param ssRecord the SS record - */ - void AcceptRanging(Cid cid, RngRsp* rngrsp, SSRecord* ssRecord); - /** - * Continue ranging function - * @param cid the CID - * @param rngrsp the ranging response - * @param ssRecord the SS record - */ - void ContinueRanging(Cid cid, RngRsp* rngrsp, SSRecord* ssRecord); - /** - * Schedule range response message function - * @param cid the CID - * @param rngrsp the ranging response - */ - void ScheduleRngRspMessage(Cid cid, RngRsp* rngrsp); - /** - * Deallocate CIDs function - * @param cid the CID - */ - void DeallocateCids(Cid cid); - - /** - * Change DL channel function - * @returns true if the DL channel changed - */ - bool ChangeDlChannel(); - /** - * Get new DL channel function - * @returns the new DL channel - */ - uint32_t GetNewDlChannel(); - /** - * Get signal quality function - * @returns the signal quality - */ - uint8_t GetSignalQuality(); - /** - * Is ranging acceptable function - * @returns true if ranging is acceptable - */ - bool IsRangingAcceptable(); - - Ptr m_bs; ///< base station - - // ranging parameters - uint32_t m_signalQuality; ///< signal quality - uint8_t m_signalQualityThreshold; ///< signal quality threshold - int tries; ///< variable to test multiple RNG-REQ by the SS for example undecodable at BS or - ///< lost RNG-RSP -}; - -} // namespace ns3 - -#endif /* LINK_MANAGER_H */ diff --git a/src/wimax/model/bs-net-device.cc b/src/wimax/model/bs-net-device.cc deleted file mode 100644 index cfb1066ff..000000000 --- a/src/wimax/model/bs-net-device.cc +++ /dev/null @@ -1,1249 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "bs-net-device.h" - -#include "bandwidth-manager.h" -#include "bs-link-manager.h" -#include "bs-scheduler.h" -#include "bs-uplink-scheduler.h" -#include "burst-profile-manager.h" -#include "connection-manager.h" -#include "service-flow-manager.h" -#include "service-flow.h" -#include "ss-manager.h" -#include "ss-record.h" -#include "wimax-mac-queue.h" -#include "wimax-phy.h" - -#include "ns3/enum.h" -#include "ns3/ipv4-address.h" -#include "ns3/llc-snap-header.h" -#include "ns3/node.h" -#include "ns3/packet-burst.h" -#include "ns3/pointer.h" -#include "ns3/simulator.h" -#include "ns3/trace-source-accessor.h" -#include "ns3/uinteger.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("BaseStationNetDevice"); - -NS_OBJECT_ENSURE_REGISTERED(BaseStationNetDevice); - -TypeId -BaseStationNetDevice::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::BaseStationNetDevice") - - .SetParent() - - .SetGroupName("Wimax") - - .AddConstructor() - - .AddAttribute("BSScheduler", - "Downlink Scheduler for BS", - PointerValue(), - MakePointerAccessor(&BaseStationNetDevice::m_scheduler), - MakePointerChecker()) - - .AddAttribute("InitialRangInterval", - "Time between Initial Ranging regions assigned by the BS. Maximum is 2s", - TimeValue(Seconds(0.05)), - MakeTimeAccessor(&BaseStationNetDevice::GetInitialRangingInterval, - &BaseStationNetDevice::SetInitialRangingInterval), - MakeTimeChecker()) - - .AddAttribute("DcdInterval", - "Time between transmission of DCD messages. Maximum value is 10s.", - TimeValue(Seconds(3)), - MakeTimeAccessor(&BaseStationNetDevice::GetDcdInterval, - &BaseStationNetDevice::SetDcdInterval), - MakeTimeChecker()) - - .AddAttribute("UcdInterval", - "Time between transmission of UCD messages. Maximum value is 10s.", - TimeValue(Seconds(3)), - MakeTimeAccessor(&BaseStationNetDevice::GetUcdInterval, - &BaseStationNetDevice::SetUcdInterval), - MakeTimeChecker()) - - .AddAttribute("IntervalT8", - "Wait for DSA/DSC Acknowledge timeout. Maximum 300ms.", - TimeValue(Seconds(0.05)), - MakeTimeAccessor(&BaseStationNetDevice::GetIntervalT8, - &BaseStationNetDevice::SetIntervalT8), - MakeTimeChecker()) - - .AddAttribute("RangReqOppSize", - "The ranging opportunity size in symbols", - UintegerValue(8), - MakeUintegerAccessor(&BaseStationNetDevice::GetRangReqOppSize, - &BaseStationNetDevice::SetRangReqOppSize), - MakeUintegerChecker(1, 256)) - - .AddAttribute("BwReqOppSize", - "The bandwidth request opportunity size in symbols", - UintegerValue(2), - MakeUintegerAccessor(&BaseStationNetDevice::GetBwReqOppSize, - &BaseStationNetDevice::SetBwReqOppSize), - MakeUintegerChecker(1, 256)) - - .AddAttribute( - "MaxRangCorrectionRetries", - "Number of retries on contention Ranging Requests", - UintegerValue(16), - MakeUintegerAccessor(&BaseStationNetDevice::GetMaxRangingCorrectionRetries, - &BaseStationNetDevice::SetMaxRangingCorrectionRetries), - MakeUintegerChecker(1, 16)) - - .AddAttribute("SSManager", - "The ss manager attached to this device.", - PointerValue(), - MakePointerAccessor(&BaseStationNetDevice::GetSSManager, - &BaseStationNetDevice::SetSSManager), - MakePointerChecker()) - - .AddAttribute("Scheduler", - "The BS scheduler attached to this device.", - PointerValue(), - MakePointerAccessor(&BaseStationNetDevice::GetBSScheduler, - &BaseStationNetDevice::SetBSScheduler), - MakePointerChecker()) - - .AddAttribute("LinkManager", - "The link manager attached to this device.", - PointerValue(), - MakePointerAccessor(&BaseStationNetDevice::GetLinkManager, - &BaseStationNetDevice::SetLinkManager), - MakePointerChecker()) - - .AddAttribute("UplinkScheduler", - "The uplink scheduler attached to this device.", - PointerValue(), - MakePointerAccessor(&BaseStationNetDevice::GetUplinkScheduler, - &BaseStationNetDevice::SetUplinkScheduler), - MakePointerChecker()) - - .AddAttribute("BsIpcsPacketClassifier", - "The uplink IP packet classifier attached to this device.", - PointerValue(), - MakePointerAccessor(&BaseStationNetDevice::GetBsClassifier, - &BaseStationNetDevice::SetBsClassifier), - MakePointerChecker()) - - .AddAttribute("ServiceFlowManager", - "The service flow manager attached to this device.", - PointerValue(), - MakePointerAccessor(&BaseStationNetDevice::GetServiceFlowManager, - &BaseStationNetDevice::SetServiceFlowManager), - MakePointerChecker()) - - .AddTraceSource("BSTx", - "A packet has been received from higher layers " - "and is being processed in preparation " - "for queueing for transmission.", - MakeTraceSourceAccessor(&BaseStationNetDevice::m_bsTxTrace), - "ns3::Packet::TracedCallback") - - .AddTraceSource("BSTxDrop", - "A packet has been dropped in the MAC layer " - "before being queued for transmission.", - MakeTraceSourceAccessor(&BaseStationNetDevice::m_bsTxDropTrace), - "ns3::Packet::TracedCallback") - - .AddTraceSource("BSPromiscRx", - "A packet has been received by this device, " - "has been passed up from the physical layer " - "and is being forwarded up the local protocol stack. " - "This is a promiscuous trace,", - MakeTraceSourceAccessor(&BaseStationNetDevice::m_bsPromiscRxTrace), - "ns3::Packet::TracedCallback") - - .AddTraceSource("BSRx", - "A packet has been received by this device, " - "has been passed up from the physical layer " - "and is being forwarded up the local protocol stack. " - "This is a non-promiscuous trace,", - MakeTraceSourceAccessor(&BaseStationNetDevice::m_bsRxTrace), - "ns3::Packet::TracedCallback") - - .AddTraceSource("BSRxDrop", - "A packet has been dropped in the MAC layer " - "after it has been passed up from the physical layer.", - MakeTraceSourceAccessor(&BaseStationNetDevice::m_bsRxDropTrace), - "ns3::Packet::TracedCallback"); - return tid; -} - -BaseStationNetDevice::BaseStationNetDevice() -{ - InitBaseStationNetDevice(); -} - -void -BaseStationNetDevice::InitBaseStationNetDevice() -{ - m_initialRangInterval = Seconds(0.05); // maximum is 2 - m_dcdInterval = Seconds(3); // maximum is 10 - m_ucdInterval = Seconds(3); // maximum is 10 - m_intervalT8 = MilliSeconds(50); // maximum is 300 milliseconds - m_maxRangCorrectionRetries = 16; - m_maxInvitedRangRetries = 16; - m_rangReqOppSize = - 8; // 8 symbols = 2 (preamble) + 2 (RNG-REQ) + 4 (round-trip propagation time) - m_bwReqOppSize = 2; // 2 symbols = 1 (preamble) + 1 (bandwidth request header) - m_nrDlSymbols = 0; - m_nrUlSymbols = 0; - m_nrDlMapSent = 0; - m_nrUlMapSent = 0; - m_nrDcdSent = 0; - m_nrUcdSent = 0; - m_dcdConfigChangeCount = 0; - m_ucdConfigChangeCount = 0; - m_framesSinceLastDcd = 0; - m_framesSinceLastUcd = 0; - m_nrDlFrames = 0; - m_nrUlFrames = 0; - m_nrSsRegistered = 0; - m_nrDlAllocations = 0; - m_nrUlAllocations = 0; - m_dlSubframeStartTime = Seconds(0); - m_ulSubframeStartTime = Seconds(0); - m_ulAllocationNumber = 0; - m_rangingOppNumber = 0; - m_allocationStartTime = 0; - m_psDuration = Seconds(0); - m_symbolDuration = Seconds(0); - m_linkManager = CreateObject(this); - m_cidFactory = new CidFactory(); - m_ssManager = CreateObject(); - m_bsClassifier = CreateObject(); - m_serviceFlowManager = CreateObject(this); -} - -BaseStationNetDevice::BaseStationNetDevice(Ptr node, Ptr phy) -{ - InitBaseStationNetDevice(); - this->SetNode(node); - this->SetPhy(phy); -} - -BaseStationNetDevice::BaseStationNetDevice(Ptr node, - Ptr phy, - Ptr uplinkScheduler, - Ptr bsScheduler) -{ - InitBaseStationNetDevice(); - this->SetNode(node); - this->SetPhy(phy); - m_uplinkScheduler = uplinkScheduler; - m_scheduler = bsScheduler; -} - -BaseStationNetDevice::~BaseStationNetDevice() -{ -} - -void -BaseStationNetDevice::DoDispose() -{ - delete m_cidFactory; - - m_linkManager = nullptr; - m_ssManager = nullptr; - m_bsClassifier = nullptr; - m_serviceFlowManager = nullptr; - m_uplinkScheduler = nullptr; - m_cidFactory = nullptr; - m_ssManager = nullptr; - m_uplinkScheduler = nullptr; - m_scheduler = nullptr; - - WimaxNetDevice::DoDispose(); -} - -void -BaseStationNetDevice::SetBsClassifier(Ptr bsc) -{ - m_bsClassifier = bsc; -} - -Ptr -BaseStationNetDevice::GetBsClassifier() const -{ - return m_bsClassifier; -} - -void -BaseStationNetDevice::SetInitialRangingInterval(Time initialRangInterval) -{ - m_initialRangInterval = initialRangInterval; -} - -Time -BaseStationNetDevice::GetInitialRangingInterval() const -{ - return m_initialRangInterval; -} - -void -BaseStationNetDevice::SetDcdInterval(Time dcdInterval) -{ - m_dcdInterval = dcdInterval; -} - -Time -BaseStationNetDevice::GetDcdInterval() const -{ - return m_dcdInterval; -} - -void -BaseStationNetDevice::SetUcdInterval(Time ucdInterval) -{ - m_ucdInterval = ucdInterval; -} - -Time -BaseStationNetDevice::GetUcdInterval() const -{ - return m_ucdInterval; -} - -void -BaseStationNetDevice::SetIntervalT8(Time interval) -{ - m_intervalT8 = interval; -} - -Time -BaseStationNetDevice::GetIntervalT8() const -{ - return m_intervalT8; -} - -void -BaseStationNetDevice::SetMaxRangingCorrectionRetries(uint8_t maxRangCorrectionRetries) -{ - m_maxRangCorrectionRetries = maxRangCorrectionRetries; -} - -uint8_t -BaseStationNetDevice::GetMaxRangingCorrectionRetries() const -{ - return m_maxRangCorrectionRetries; -} - -void -BaseStationNetDevice::SetMaxInvitedRangRetries(uint8_t maxInvitedRangRetries) -{ - m_maxInvitedRangRetries = maxInvitedRangRetries; -} - -uint8_t -BaseStationNetDevice::GetMaxInvitedRangRetries() const -{ - return m_maxInvitedRangRetries; -} - -void -BaseStationNetDevice::SetRangReqOppSize(uint8_t rangReqOppSize) -{ - m_rangReqOppSize = rangReqOppSize; -} - -uint8_t -BaseStationNetDevice::GetRangReqOppSize() const -{ - return m_rangReqOppSize; -} - -void -BaseStationNetDevice::SetBwReqOppSize(uint8_t bwReqOppSize) -{ - m_bwReqOppSize = bwReqOppSize; -} - -uint8_t -BaseStationNetDevice::GetBwReqOppSize() const -{ - return m_bwReqOppSize; -} - -void -BaseStationNetDevice::SetNrDlSymbols(uint32_t nrDlSymbols) -{ - m_nrDlSymbols = nrDlSymbols; -} - -uint32_t -BaseStationNetDevice::GetNrDlSymbols() const -{ - return m_nrDlSymbols; -} - -void -BaseStationNetDevice::SetNrUlSymbols(uint32_t nrUlSymbols) -{ - m_nrUlSymbols = nrUlSymbols; -} - -uint32_t -BaseStationNetDevice::GetNrUlSymbols() const -{ - return m_nrUlSymbols; -} - -uint32_t -BaseStationNetDevice::GetNrDcdSent() const -{ - return m_nrDcdSent; -} - -uint32_t -BaseStationNetDevice::GetNrUcdSent() const -{ - return m_nrUcdSent; -} - -Time -BaseStationNetDevice::GetDlSubframeStartTime() const -{ - return m_dlSubframeStartTime; -} - -Time -BaseStationNetDevice::GetUlSubframeStartTime() const -{ - return m_ulSubframeStartTime; -} - -uint8_t -BaseStationNetDevice::GetRangingOppNumber() const -{ - return m_rangingOppNumber; -} - -Ptr -BaseStationNetDevice::GetSSManager() const -{ - return m_ssManager; -} - -void -BaseStationNetDevice::SetSSManager(Ptr ssm) -{ - m_ssManager = ssm; -} - -Ptr -BaseStationNetDevice::GetServiceFlowManager() const -{ - return m_serviceFlowManager; -} - -void -BaseStationNetDevice::SetServiceFlowManager(Ptr sfm) -{ - m_serviceFlowManager = sfm; -} - -Ptr -BaseStationNetDevice::GetUplinkScheduler() const -{ - return m_uplinkScheduler; -} - -void -BaseStationNetDevice::SetUplinkScheduler(Ptr uls) -{ - m_uplinkScheduler = uls; -} - -Ptr -BaseStationNetDevice::GetLinkManager() const -{ - return m_linkManager; -} - -void -BaseStationNetDevice::SetLinkManager(Ptr lm) -{ - m_linkManager = lm; -} - -void -BaseStationNetDevice::SetBSScheduler(Ptr bss) -{ - m_scheduler = bss; -} - -Ptr -BaseStationNetDevice::GetBSScheduler() const -{ - return m_scheduler; -} - -Time -BaseStationNetDevice::GetPsDuration() const -{ - return m_psDuration; -} - -Time -BaseStationNetDevice::GetSymbolDuration() const -{ - return m_symbolDuration; -} - -void -BaseStationNetDevice::Start() -{ - SetReceiveCallback(); - GetConnectionManager()->SetCidFactory(m_cidFactory); - GetPhy()->SetPhyParameters(); - GetPhy()->SetDataRates(); - SetTtg(GetPhy()->GetTtg()); - SetRtg(GetPhy()->GetRtg()); - m_psDuration = GetPhy()->GetPsDuration(); - m_symbolDuration = GetPhy()->GetSymbolDuration(); - GetBandwidthManager()->SetSubframeRatio(); - - CreateDefaultConnections(); - GetPhy()->SetSimplex(m_linkManager->SelectDlChannel()); - Simulator::ScheduleNow(&BaseStationNetDevice::StartFrame, this); - - /* shall actually be 2 symbols = 1 (preamble) + 1 (bandwidth request header)*/ - m_bwReqOppSize = 6; - m_uplinkScheduler->InitOnce(); -} - -void -BaseStationNetDevice::Stop() -{ -} - -void -BaseStationNetDevice::StartFrame() -{ - // setting DL/UL subframe allocation for this frame - uint32_t symbolsPerFrame = GetPhy()->GetSymbolsPerFrame(); - SetNrDlSymbols((symbolsPerFrame / 2) - - static_cast(std::ceil(GetTtg() * m_psDuration.GetSeconds() / - m_symbolDuration.GetSeconds()))); - SetNrUlSymbols((symbolsPerFrame / 2) - - static_cast(std::ceil(GetRtg() * m_psDuration.GetSeconds() / - m_symbolDuration.GetSeconds()))); - - m_frameStartTime = Simulator::Now(); - - NS_LOG_INFO("----------------------frame" << GetNrFrames() + 1 << "----------------------"); - - StartDlSubFrame(); -} - -void -BaseStationNetDevice::StartDlSubFrame() -{ - m_dlSubframeStartTime = Simulator::Now(); // same as m_frameStartTime - - NS_LOG_DEBUG("DL frame started : " << m_frameStartTime.As(Time::S)); - - SetNrFrames(GetNrFrames() + 1); - SetState(BS_STATE_DL_SUB_FRAME); - m_direction = DIRECTION_DOWNLINK; - m_uplinkScheduler->Schedule(); - CreateMapMessages(); - m_scheduler->Schedule(); - SendBursts(); - Simulator::Schedule(Seconds(m_nrDlSymbols * m_symbolDuration.GetSeconds()), - &BaseStationNetDevice::EndDlSubFrame, - this); -} - -void -BaseStationNetDevice::EndDlSubFrame() -{ - m_nrDlFrames++; - SetState(BS_STATE_TTG); - Simulator::Schedule(Seconds(GetTtg() * m_psDuration.GetSeconds()), - &BaseStationNetDevice::StartUlSubFrame, - this); -} - -void -BaseStationNetDevice::StartUlSubFrame() -{ - m_ulSubframeStartTime = Simulator::Now(); - - NS_LOG_INFO("UL frame started : " << m_ulSubframeStartTime.As(Time::S)); - - SetState(BS_STATE_UL_SUB_FRAME); - m_direction = DIRECTION_UPLINK; - MarkUplinkAllocations(); - Simulator::Schedule(Seconds(m_nrUlSymbols * m_symbolDuration.GetSeconds()), - &BaseStationNetDevice::EndUlSubFrame, - this); -} - -void -BaseStationNetDevice::EndUlSubFrame() -{ - m_nrUlFrames++; - SetState(BS_STATE_RTG); - Simulator::Schedule(Seconds(GetRtg() * m_psDuration.GetSeconds()), - &BaseStationNetDevice::EndFrame, - this); -} - -void -BaseStationNetDevice::EndFrame() -{ - StartFrame(); -} - -bool -BaseStationNetDevice::DoSend(Ptr packet, - const Mac48Address& source, - const Mac48Address& dest, - uint16_t protocolNumber) -{ - Ptr burst = CreateObject(); - ServiceFlow* serviceFlow = nullptr; - - NS_LOG_INFO("BS (" << source << "):"); - NS_LOG_INFO("\tSending packet..."); - NS_LOG_INFO("\t\tDestination: " << dest); - NS_LOG_INFO("\t\tPacket Size: " << packet->GetSize()); - NS_LOG_INFO("\t\tProtocol: " << protocolNumber); - - if (protocolNumber == 2048) - { - serviceFlow = m_bsClassifier->Classify(packet, - GetServiceFlowManager(), - ServiceFlow::SF_DIRECTION_DOWN); - } - - if (protocolNumber != 2048 || serviceFlow == nullptr) - { - serviceFlow = *GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_ALL).begin(); - } - - if (serviceFlow == nullptr) - { - NS_LOG_INFO("No Service Flow!!"); - m_bsTxDropTrace(packet); - return false; - } - if (serviceFlow->GetIsEnabled()) - { - if (!Enqueue(packet, MacHeaderType(), serviceFlow->GetConnection())) - { - NS_LOG_INFO("Enqueue Error!!"); - m_bsTxDropTrace(packet); - return false; - } - } - else - { - m_bsTxDropTrace(packet); - NS_LOG_INFO("Service Flow is not enabled"); - return false; - } - m_bsTxTrace(packet); - - return true; -} - -bool -BaseStationNetDevice::Enqueue(Ptr packet, - const MacHeaderType& hdrType, - Ptr connection) -{ - NS_ASSERT_MSG( - connection, - "BS: Can not enqueue packet on the selected connection: the connection is not initialized"); - - GenericMacHeader hdr; - hdr.SetLen(packet->GetSize() + hdr.GetSerializedSize()); - - hdr.SetCid(connection->GetCid()); - - return connection->Enqueue(packet, hdrType, hdr); -} - -void -BaseStationNetDevice::DoReceive(Ptr packet) -{ - GenericMacHeader gnrcMacHdr; - BandwidthRequestHeader bwRequestHdr; - ManagementMessageType msgType; - RngReq rngReq; - Cid cid; - uint8_t type = 0; - GrantManagementSubheader grantMgmntSubhdr; - Mac48Address source; - LlcSnapHeader llc; - Ptr connection = nullptr; - FragmentationSubheader fragSubhdr; - bool fragmentation = false; // it becomes true when there is a fragmentation subheader - - packet->RemoveHeader(gnrcMacHdr); - if (gnrcMacHdr.GetHt() == MacHeaderType::HEADER_TYPE_GENERIC) - { - if (!gnrcMacHdr.check_hcs()) - { - // The header is noisy - m_bsRxDropTrace(packet); - NS_LOG_INFO("Header HCS ERROR"); - return; - } - - cid = gnrcMacHdr.GetCid(); - - // checking for subheaders (only grant management subheader is implemented) - type = gnrcMacHdr.GetType(); - if (type) - { - // checking 1st bit, see Table 6 - if (type & 1) - { - packet->RemoveHeader(grantMgmntSubhdr); - } - // Check if there is a fragmentation Subheader - uint8_t tmpType = type; - if (((tmpType >> 2) & 1) == 1) - { - // a TRANSPORT packet with fragmentation subheader has been received! - NS_LOG_INFO("FRAG_DEBUG: DoReceive -> the packet is a fragment" << std::endl); - fragmentation = true; - } - } - - if (cid.IsInitialRanging()) // initial ranging connection - { - packet->RemoveHeader(msgType); - switch (msgType.GetType()) - { - case ManagementMessageType::MESSAGE_TYPE_RNG_REQ: { - packet->RemoveHeader(rngReq); - m_linkManager->ProcessRangingRequest(cid, rngReq); - break; - } - case ManagementMessageType::MESSAGE_TYPE_RNG_RSP: - // from other base station, ignore - break; - default: - NS_FATAL_ERROR("Invalid message type"); - } - } - else if (m_cidFactory->IsBasic(cid)) // basic management connection - { - source = m_ssManager->GetMacAddress(cid); - m_traceBSRx(packet, source, cid); - packet->RemoveHeader(msgType); - switch (msgType.GetType()) - { - case ManagementMessageType::MESSAGE_TYPE_RNG_REQ: { - packet->RemoveHeader(rngReq); - m_linkManager->ProcessRangingRequest(cid, rngReq); - break; - } - case ManagementMessageType::MESSAGE_TYPE_RNG_RSP: - // from other base station, ignore - break; - default: - NS_FATAL_ERROR("Invalid message type"); - } - } - else if (m_cidFactory->IsPrimary(cid)) // primary management connection - { - source = m_ssManager->GetMacAddress(cid); - m_traceBSRx(packet, source, cid); - packet->RemoveHeader(msgType); - switch (msgType.GetType()) - { - case ManagementMessageType::MESSAGE_TYPE_REG_REQ: - // not yet implemented - case ManagementMessageType::MESSAGE_TYPE_REG_RSP: - // from other base station, ignore - break; - case ManagementMessageType::MESSAGE_TYPE_DSA_REQ: { - DsaReq dsaReq; - packet->RemoveHeader(dsaReq); - GetServiceFlowManager()->AllocateServiceFlows(dsaReq, cid); - break; - } - case ManagementMessageType::MESSAGE_TYPE_DSA_RSP: - - /*from other base station, as DSA initiated - from BS is not supported, ignore*/ - break; - case ManagementMessageType::MESSAGE_TYPE_DSA_ACK: { - Simulator::Cancel(GetServiceFlowManager()->GetDsaAckTimeoutEvent()); - DsaAck dsaAck; - packet->RemoveHeader(dsaAck); - GetServiceFlowManager()->ProcessDsaAck(dsaAck, cid); - break; - } - default: - NS_FATAL_ERROR("Invalid message type"); - } - } - else if (cid.IsBroadcast()) // broadcast connection - { - // from other base station, ignore - // or perhaps data packet (using other protocol) for BS, handle later - return; - } - else // transport connection - { - // If fragmentation is true, the packet is a fragment. - Ptr C_Packet = packet->Copy(); - if (!fragmentation) - { - C_Packet->RemoveHeader(llc); - source = m_ssManager->GetMacAddress(cid); - m_bsRxTrace(packet); - ForwardUp(packet->Copy(), source, Mac48Address::GetBroadcast()); - } - else - { - NS_LOG_INFO("FRAG_DEBUG: BS DoReceive, the Packet is a fragment" << std::endl); - packet->RemoveHeader(fragSubhdr); - uint32_t fc = fragSubhdr.GetFc(); - NS_LOG_INFO("\t fragment size = " << packet->GetSize() << std::endl); - if (fc == 2) - { - // This is the latest fragment. - // Take the fragment queue, defragment a packet and send it to the upper layer - NS_LOG_INFO("\t Received the latest fragment" << std::endl); - GetConnectionManager()->GetConnection(cid)->FragmentEnqueue(packet); - WimaxConnection::FragmentsQueue fragmentsQueue = - GetConnectionManager()->GetConnection(cid)->GetFragmentsQueue(); - Ptr fullPacket = Create(); - - // DEFRAGMENTATION - NS_LOG_INFO("\t BS PACKET DEFRAGMENTATION" << std::endl); - for (auto iter = fragmentsQueue.begin(); iter != fragmentsQueue.end(); ++iter) - { - // Create the whole Packet - fullPacket->AddAtEnd(*iter); - } - GetConnectionManager()->GetConnection(cid)->ClearFragmentsQueue(); - - NS_LOG_INFO("\t fullPacket size = " << fullPacket->GetSize() << std::endl); - source = m_ssManager->GetMacAddress(cid); - m_bsRxTrace(fullPacket); - ForwardUp(fullPacket->Copy(), source, Mac48Address::GetBroadcast()); - } - else - { - // This is the first or middle fragment. - // Take the fragment queue, store the fragment into the queue - NS_LOG_INFO("\t Received the first or the middle fragment" << std::endl); - GetConnectionManager()->GetConnection(cid)->FragmentEnqueue(packet); - } - } - } - } - else - { - // bandwidth request header - packet->AddHeader(gnrcMacHdr); - packet->RemoveHeader(bwRequestHdr); - NS_ASSERT_MSG(bwRequestHdr.GetHt() == MacHeaderType::HEADER_TYPE_BANDWIDTH, - "A bandwidth request should be carried by a bandwidth header type"); - if (!bwRequestHdr.check_hcs()) - { - // The header is noisy - NS_LOG_INFO("BS:Header HCS ERROR"); - return; - } - cid = bwRequestHdr.GetCid(); - source = m_ssManager->GetMacAddress(cid); - m_traceBSRx(packet, source, cid); - GetBandwidthManager()->ProcessBandwidthRequest(bwRequestHdr); - } -} - -void -BaseStationNetDevice::CreateMapMessages() -{ - Ptr dlmap; - Ptr ulmap; - bool sendDcd = false; - bool sendUcd = false; - bool updateDcd = false; - bool updateUcd = false; - - uint16_t currentNrSsRegistered = m_ssManager->GetNRegisteredSSs(); - - if (m_nrSsRegistered == currentNrSsRegistered) - { - m_uplinkScheduler->GetChannelDescriptorsToUpdate(updateDcd, updateUcd, sendDcd, sendUcd); - } - else - { - sendDcd = sendUcd = true; - } - - m_nrSsRegistered = currentNrSsRegistered; - - /*either DCD and UCD must be created first because CCC is set during their - creation, or CCC must be calculated first so that it could be set during - creation of DL-MAP and UL-MAP and then set during creation of DCD and UCD*/ - - if (sendDcd) - { - m_dcdConfigChangeCount += 1 % 256; - } - - if (sendUcd) - { - m_ucdConfigChangeCount += 1 % 256; - } - - dlmap = CreateDlMap(); - Enqueue(dlmap, MacHeaderType(), GetBroadcastConnection()); - m_nrDlMapSent++; - - ulmap = CreateUlMap(); - Enqueue(ulmap, MacHeaderType(), GetBroadcastConnection()); - m_nrUlMapSent++; - - CreateDescriptorMessages(sendDcd, sendUcd); -} - -void -BaseStationNetDevice::CreateDescriptorMessages(bool sendDcd, bool sendUcd) -{ - Ptr dcd; - Ptr ucd; - - if (sendDcd) - { - dcd = CreateDcd(); - Enqueue(dcd, MacHeaderType(), GetBroadcastConnection()); - m_nrDcdSent++; - m_framesSinceLastDcd = 0; - } - else - { - m_framesSinceLastDcd++; - } - - if (sendUcd) - { - ucd = CreateUcd(); - Enqueue(ucd, MacHeaderType(), GetBroadcastConnection()); - m_nrUcdSent++; - m_framesSinceLastUcd = 0; - } - else - { - m_framesSinceLastUcd++; - } -} - -/* - Sends bursts in the downlink subframe. i.e., creates the downlink subframe. The first burst - is broadcast burst with MAC management messages. The rest of the bursts contain data packets. - */ -void -BaseStationNetDevice::SendBursts() -{ - Time txTime; - std::pair> pair; - WimaxPhy::ModulationType modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - std::list>>* downlinkBursts = - m_scheduler->GetDownlinkBursts(); - Ptr burst; - OfdmDlMapIe* dlMapIe; - Cid cid; - - while (!downlinkBursts->empty()) - { - pair = downlinkBursts->front(); - burst = pair.second; - dlMapIe = pair.first; - cid = dlMapIe->GetCid(); - uint8_t diuc = dlMapIe->GetDiuc(); - - if (cid != GetInitialRangingConnection()->GetCid() && - cid != GetBroadcastConnection()->GetCid()) - { - modulationType = - GetBurstProfileManager()->GetModulationType(diuc, - WimaxNetDevice::DIRECTION_DOWNLINK); - } - else - { - modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - } - - Simulator::Schedule(txTime, &WimaxNetDevice::ForwardDown, this, burst, modulationType); - txTime += GetPhy()->GetTransmissionTime(burst->GetSize(), modulationType); - downlinkBursts->pop_front(); - delete dlMapIe; - } -} - -Ptr -BaseStationNetDevice::CreateDlMap() -{ - m_nrDlAllocations = 0; - - DlMap dlmap; - dlmap.SetDcdCount(m_dcdConfigChangeCount); - dlmap.SetBaseStationId(GetMacAddress()); - - std::list>>* downlinkBursts = - m_scheduler->GetDownlinkBursts(); - - for (auto iter = downlinkBursts->begin(); iter != downlinkBursts->end(); ++iter) - { - iter->first->SetPreamblePresent(0); - iter->first->SetStartTime(0); - dlmap.AddDlMapElement(*(iter->first)); - } - - OfdmDlMapIe dlMapIeEnd; - - dlMapIeEnd.SetCid(Cid::InitialRanging()); - dlMapIeEnd.SetDiuc(OfdmDlBurstProfile::DIUC_END_OF_MAP); - dlMapIeEnd.SetPreamblePresent(0); - dlMapIeEnd.SetStartTime(0); - - dlmap.AddDlMapElement(dlMapIeEnd); - m_nrDlAllocations = downlinkBursts->size(); - - Ptr p = Create(); - p->AddHeader(dlmap); - p->AddHeader(ManagementMessageType(ManagementMessageType::MESSAGE_TYPE_DL_MAP)); - return p; -} - -Ptr -BaseStationNetDevice::CreateDcd() -{ - Dcd dcd; - OfdmDcdChannelEncodings chnlEncodings; - - chnlEncodings.SetBsEirp(0); - chnlEncodings.SetEirxPIrMax(0); - chnlEncodings.SetFrequency(GetPhy()->GetFrequency()); - chnlEncodings.SetChannelNr(0); - chnlEncodings.SetTtg(GetTtg()); - chnlEncodings.SetRtg(GetRtg()); - chnlEncodings.SetBaseStationId(GetMacAddress()); - chnlEncodings.SetFrameDurationCode(GetPhy()->GetFrameDurationCode()); - chnlEncodings.SetFrameNumber(GetNrFrames()); - - dcd.SetConfigurationChangeCount(m_dcdConfigChangeCount); - dcd.SetChannelEncodings(chnlEncodings); - - SetDlBurstProfiles(&dcd); - SetCurrentDcd(dcd); - - Ptr p = Create(); - p->AddHeader(dcd); - p->AddHeader(ManagementMessageType(ManagementMessageType::MESSAGE_TYPE_DCD)); - return p; -} - -Ptr -BaseStationNetDevice::CreateUlMap() -{ - m_ulAllocationNumber = 0; - m_rangingOppNumber = 0; - m_nrUlAllocations = 0; - - UlMap ulmap; - ulmap.SetUcdCount(m_ucdConfigChangeCount); - ulmap.SetAllocationStartTime(m_uplinkScheduler->CalculateAllocationStartTime()); - - std::list uplinkAllocations = m_uplinkScheduler->GetUplinkAllocations(); - - for (auto iter = uplinkAllocations.begin(); iter != uplinkAllocations.end(); ++iter) - { - ulmap.AddUlMapElement(*iter); - } - - m_nrUlAllocations = uplinkAllocations.size(); - - Ptr p = Create(); - p->AddHeader(ulmap); - p->AddHeader(ManagementMessageType(ManagementMessageType::MESSAGE_TYPE_UL_MAP)); - return p; -} - -Ptr -BaseStationNetDevice::CreateUcd() -{ - Ucd ucd; - ucd.SetConfigurationChangeCount(m_ucdConfigChangeCount); - ucd.SetRangingBackoffStart(3); // setting to 7. i.e., 2^3 = 8 -> 0-7 - ucd.SetRangingBackoffEnd(6); // setting to 63. i.e., 2^6 = 64 -> 0-63 - ucd.SetRequestBackoffStart(3); - ucd.SetRequestBackoffEnd(6); - - OfdmUcdChannelEncodings chnlEncodings; - - chnlEncodings.SetBwReqOppSize(m_bwReqOppSize * GetPhy()->GetPsPerSymbol()); - chnlEncodings.SetRangReqOppSize(m_rangReqOppSize * GetPhy()->GetPsPerSymbol()); - - chnlEncodings.SetFrequency(GetPhy()->GetFrequency()); - chnlEncodings.SetSbchnlReqRegionFullParams(0); - chnlEncodings.SetSbchnlFocContCodes(0); - - ucd.SetChannelEncodings(chnlEncodings); - - SetUlBurstProfiles(&ucd); - SetCurrentUcd(ucd); - - Ptr p = Create(); - p->AddHeader(ucd); - p->AddHeader(ManagementMessageType(ManagementMessageType::MESSAGE_TYPE_UCD)); - return p; -} - -void -BaseStationNetDevice::SetDlBurstProfiles(Dcd* dcd) -{ - for (int i = 0; i < GetBurstProfileManager()->GetNrBurstProfilesToDefine(); ++i) - { - OfdmDlBurstProfile brstProfile; - brstProfile.SetType(0); - brstProfile.SetLength(0); - brstProfile.SetDiuc(i + 1); // DIUC will be between 1-11, see Table 237 - brstProfile.SetFecCodeType(i); - dcd->AddDlBurstProfile(brstProfile); - } -} - -void -BaseStationNetDevice::SetUlBurstProfiles(Ucd* ucd) -{ - for (int i = 0; i < GetBurstProfileManager()->GetNrBurstProfilesToDefine(); ++i) - { - OfdmUlBurstProfile brstProfile; - brstProfile.SetType(0); - brstProfile.SetLength(0); - // UIUC will be between 5-12, see Table 246. UIUC 1 (initial ranging) is not included - brstProfile.SetUiuc(i + 5); - brstProfile.SetFecCodeType(i); - - ucd->AddUlBurstProfile(brstProfile); - } -} - -Ptr -BaseStationNetDevice::GetConnection(Cid cid) -{ - Ptr connection = nullptr; - if (cid.IsInitialRanging()) - { - return GetInitialRangingConnection(); - } - else if (cid.IsBroadcast()) - { - connection = GetBroadcastConnection(); - } - else - { - connection = GetConnectionManager()->GetConnection(cid); - } - - NS_ASSERT_MSG(connection, "BS: Invalid connection=0"); - return connection; -} - -void -BaseStationNetDevice::MarkUplinkAllocations() -{ - uint16_t symbolsToAllocation = 0; - const auto& uplinkAllocations = m_uplinkScheduler->GetUplinkAllocations(); - for (const auto& uplinkAllocation : uplinkAllocations) - { - if (uplinkAllocation.GetUiuc() == OfdmUlBurstProfile::UIUC_END_OF_MAP) - { - break; - } - - symbolsToAllocation = uplinkAllocation.GetStartTime(); - MarkUplinkAllocationStart(symbolsToAllocation * m_symbolDuration); - MarkUplinkAllocationEnd((symbolsToAllocation + uplinkAllocation.GetDuration()) * - m_symbolDuration, - uplinkAllocation.GetCid(), - uplinkAllocation.GetUiuc()); - } -} - -void -BaseStationNetDevice::MarkUplinkAllocationStart(Time allocationStartTime) -{ - Simulator::Schedule(allocationStartTime, &BaseStationNetDevice::UplinkAllocationStart, this); -} - -void -BaseStationNetDevice::MarkUplinkAllocationEnd(Time allocationEndTime, Cid cid, uint8_t uiuc) -{ - Simulator::Schedule(allocationEndTime, - &BaseStationNetDevice::UplinkAllocationEnd, - this, - cid, - uiuc); -} - -void -BaseStationNetDevice::UplinkAllocationStart() -{ - m_ulAllocationNumber++; - - NS_LOG_DEBUG("--UL allocation " << (uint32_t)m_ulAllocationNumber - << " started : " << Simulator::Now().As(Time::S)); -} - -void -BaseStationNetDevice::UplinkAllocationEnd(Cid cid, uint8_t uiuc) -{ - NS_LOG_DEBUG("--UL allocation " << (uint32_t)m_ulAllocationNumber - << " ended : " << Simulator::Now().As(Time::S)); - - if (m_cidFactory->IsBasic(cid)) - { - m_linkManager->VerifyInvitedRanging(cid, uiuc); - } -} - -void -BaseStationNetDevice::MarkRangingOppStart(Time rangingOppStartTime) -{ - Simulator::Schedule(rangingOppStartTime, &BaseStationNetDevice::RangingOppStart, this); -} - -void -BaseStationNetDevice::RangingOppStart() -{ - m_rangingOppNumber++; - - NS_LOG_DEBUG("Ranging TO " << (uint32_t)m_rangingOppNumber << ": " - << Simulator::Now().As(Time::S)); -} - -} // namespace ns3 diff --git a/src/wimax/model/bs-net-device.h b/src/wimax/model/bs-net-device.h deleted file mode 100644 index 1c89fdcf4..000000000 --- a/src/wimax/model/bs-net-device.h +++ /dev/null @@ -1,506 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - */ - -#ifndef WIMAX_BS_NET_DEVICE_H -#define WIMAX_BS_NET_DEVICE_H - -#include "bs-service-flow-manager.h" -#include "dl-mac-messages.h" -#include "ipcs-classifier.h" -#include "wimax-connection.h" -#include "wimax-net-device.h" - -#include "ns3/event-id.h" -#include "ns3/ipv4-address.h" -#include "ns3/mac48-address.h" -#include "ns3/nstime.h" - -namespace ns3 -{ - -class Node; -class Packet; -class SSRecord; -class SSManager; -class BSScheduler; -class BurstProfileManager; -class BSLinkManager; -class UplinkScheduler; -class BsServiceFlowManager; - -/** - * @ingroup wimax - * - * BaseStation NetDevice - */ -class BaseStationNetDevice : public WimaxNetDevice -{ - public: - /// State enumeration - enum State - { - BS_STATE_DL_SUB_FRAME, - BS_STATE_UL_SUB_FRAME, - BS_STATE_TTG, - BS_STATE_RTG - }; - - /// MacPreamble enumeration - enum MacPreamble - { - SHORT_PREAMBLE = 1, - LONG_PREAMBLE - }; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - BaseStationNetDevice(); - /** - * Constructor - * - * @param node the node - * @param phy the wimax phy - */ - BaseStationNetDevice(Ptr node, Ptr phy); - /** - * Constructor - * - * @param node the node - * @param phy the wimax phy - * @param uplinkScheduler uplink scheduler - * @param bsScheduler bs scheduler - */ - BaseStationNetDevice(Ptr node, - Ptr phy, - Ptr uplinkScheduler, - Ptr bsScheduler); - ~BaseStationNetDevice() override; - /** - * @param initialRangInterval Time between initial ranging regions assigned by the BS - */ - void SetInitialRangingInterval(Time initialRangInterval); - /** - * @brief initializes the BS net device and sets its parameters to the default values - */ - void InitBaseStationNetDevice(); - /** - * @returns Time between initial ranging regions assigned by the BS - */ - Time GetInitialRangingInterval() const; - /** - * @param dcdInterval Time between transmission of DCD messages - */ - void SetDcdInterval(Time dcdInterval); - /** - * @returns the Time between transmission of DCD messages - */ - Time GetDcdInterval() const; - /** - * @param ucdInterval the Time between transmission of UCD messages - */ - void SetUcdInterval(Time ucdInterval); - /** - * @returns Time between transmission of UCD messages - */ - Time GetUcdInterval() const; - /** - * @param interval the Wait for DSA/DSC Acknowledge timeout - */ - void SetIntervalT8(Time interval); - /** - * @returns the Wait for DSA/DSC Acknowledge timeout - */ - Time GetIntervalT8() const; - /** - * @param maxRangCorrectionRetries the number of retries on contention Ranging Requests - */ - void SetMaxRangingCorrectionRetries(uint8_t maxRangCorrectionRetries); - /** - * @returns the number of retries on contention Ranging Requests - */ - uint8_t GetMaxRangingCorrectionRetries() const; - /** - * @param maxInvitedRangRetries the number of retries on contention Ranging - */ - void SetMaxInvitedRangRetries(uint8_t maxInvitedRangRetries); - /** - * @returns the number of retries on contention Ranging - */ - uint8_t GetMaxInvitedRangRetries() const; - /** - * @param rangReqOppSize The ranging opportunity size in symbols - */ - void SetRangReqOppSize(uint8_t rangReqOppSize); - /** - * @returns The ranging opportunity size in symbols - */ - uint8_t GetRangReqOppSize() const; - /** - * @param bwReqOppSize The bandwidth request opportunity size in symbols - */ - void SetBwReqOppSize(uint8_t bwReqOppSize); - /** - * @returns The bandwidth request opportunity size in symbols - */ - uint8_t GetBwReqOppSize() const; - /** - * @param dlSymbols the number of symbols in the downlink sub-frame - */ - void SetNrDlSymbols(uint32_t dlSymbols); - /** - * @returns the number of symbols in the downlink sub-frame - */ - uint32_t GetNrDlSymbols() const; - /** - * @param ulSymbols the number of symbols in the uplink sub-frame - */ - void SetNrUlSymbols(uint32_t ulSymbols); - /** - * @returns the number of symbols in the uplink sub-frame - */ - uint32_t GetNrUlSymbols() const; - /** - * @returns the number dcd messages already sent - */ - uint32_t GetNrDcdSent() const; - /** - * @returns the number ucd messages already sent - */ - uint32_t GetNrUcdSent() const; - /** - * @returns the DL subframe start time - */ - Time GetDlSubframeStartTime() const; - /** - * @returns the UL subframe start time - */ - Time GetUlSubframeStartTime() const; - /** - * @returns the ranging opp number - */ - uint8_t GetRangingOppNumber() const; - /** - * @returns a pointer to the SS manager - */ - Ptr GetSSManager() const; - /** - * @param ssManager the SS manager to be installed on the BS - */ - void SetSSManager(Ptr ssManager); - /** - * @returns a pointer to the uplink scheduler installed on the device - */ - Ptr GetUplinkScheduler() const; - /** - * @param ulScheduler the ulScheduler to be isnstalled on the BS - */ - void SetUplinkScheduler(Ptr ulScheduler); - /** - * @returns a pointer to the link manager installed on the BS - */ - Ptr GetLinkManager() const; - /** - * @param bsSchedule the downlink scheduler to be installed on the BS - */ - void SetBSScheduler(Ptr bsSchedule); - /** - * @returns The BS scheduler installed on the BS - */ - Ptr GetBSScheduler() const; - /** - * @param linkManager The link manager installed on the BS - */ - void SetLinkManager(Ptr linkManager); - /** - * @returns a pointer to the classifier installed on the BS - */ - Ptr GetBsClassifier() const; - /** - * @param classifier a classifier to be installed on the BS - */ - void SetBsClassifier(Ptr classifier); - - /** - * @returns PS duration - */ - Time GetPsDuration() const; - /** - * @returns symbol duration - */ - Time GetSymbolDuration() const; - /** - * @brief Start device - */ - void Start() override; - /** - * @brief Stop device - */ - void Stop() override; - /** - * @brief Enqueue a packet into a connection queue - * @param packet the packet to be enqueued - * @param hdrType the mac header type to be appended to the packet - * @param connection the connection to be used - * @return true if successful - */ - bool Enqueue(Ptr packet, - const MacHeaderType& hdrType, - Ptr connection) override; - /** - * @param cid connection ID - * @returns a pointer to the connection - */ - Ptr GetConnection(Cid cid); - - /** - * @brief Mark uplink allocations - */ - void MarkUplinkAllocations(); - /** - * @brief Mark ranging opp start - * @param rangingOppStartTime start time - */ - void MarkRangingOppStart(Time rangingOppStartTime); - /** - * @returns service flow manager - */ - Ptr GetServiceFlowManager() const; - /** - * @brief Set service flow manager - * @param sfm the service flow manager - */ - void SetServiceFlowManager(Ptr sfm); - - private: - void DoDispose() override; - /** - * @brief Start frame function - */ - void StartFrame(); - /** - * @brief Start DL subframe function - */ - void StartDlSubFrame(); - /** - * @brief End DL subframe function - */ - void EndDlSubFrame(); - /** - * @brief Start UL subframe function - */ - void StartUlSubFrame(); - /** - * @brief End UL subframe function - */ - void EndUlSubFrame(); - /** - * @brief End frame function - */ - void EndFrame(); - /** - * @brief Send packet - * @param packet to send - * @param source MAC address - * @param dest destination MAC address - * @param protocolNumber protocol number - * @returns true if successful - */ - bool DoSend(Ptr packet, - const Mac48Address& source, - const Mac48Address& dest, - uint16_t protocolNumber) override; - /** - * @brief Receive packet - * @param packet to send - */ - void DoReceive(Ptr packet) override; - /** - * @brief creates the MAC management messages DL-MAP and UL-MAP - */ - void CreateMapMessages(); - /** - * @brief creates the channel descriptor MAC management messages DCD and UCD - * @param sendDcd true if send DCD - * @param sendUcd true if send UCD - */ - void CreateDescriptorMessages(bool sendDcd, bool sendUcd); - /** - * @brief Send burst function - */ - void SendBursts(); - - /** - * @brief Create DL map - * @returns packet - */ - Ptr CreateDlMap(); - /** - * @brief Create DCD - * @returns packet - */ - Ptr CreateDcd(); - /** - * @brief Create UL map - * @returns packet - */ - Ptr CreateUlMap(); - /** - * @brief Create UCD - * @returns packet - */ - Ptr CreateUcd(); - /** - * @brief Send DL burst profiles - * @param dcd burst profile - */ - void SetDlBurstProfiles(Dcd* dcd); - /** - * @brief Send UL burst profiles - * @param ucd burst profile - */ - void SetUlBurstProfiles(Ucd* ucd); - - /** - * @brief Mark uplink allocation start - * @param allocationStartTime allocation start time - */ - void MarkUplinkAllocationStart(Time allocationStartTime); - /** - * @brief Mark uplink allocation end - * @param allocationEndTime allocation end time - * @param cid connection ID - * @param uiuc - */ - void MarkUplinkAllocationEnd(Time allocationEndTime, Cid cid, uint8_t uiuc); - /** - * @brief Uplink allocation start - */ - void UplinkAllocationStart(); - /** - * @brief Uplink allocation end - * @param cid connection ID - * @param uiuc - */ - void UplinkAllocationEnd(Cid cid, uint8_t uiuc); - /** - * @brief Ranging opp start - */ - void RangingOppStart(); - - // parameters defined in Table 342 - Time m_initialRangInterval; ///< in seconds - Time m_dcdInterval; ///< in seconds - Time m_ucdInterval; ///< in seconds - Time m_intervalT8; ///< in milliseconds, wait for DSA/DSC Acknowledge timeout - - uint8_t m_maxRangCorrectionRetries; ///< maximum range correction retries - uint8_t m_maxInvitedRangRetries; ///< maximum invited range retries - uint8_t m_rangReqOppSize; ///< in symbols - uint8_t m_bwReqOppSize; ///< in symbols - - uint32_t m_nrDlSymbols; ///< number of DL symbols - uint32_t m_nrUlSymbols; ///< number of UL symbols - - // to keep track total number of a certain management messages sent by the BS - uint32_t m_nrDlMapSent; ///< number DL map sent - uint32_t m_nrUlMapSent; ///< number UL map sent - // number of DCDs and UCDs sent even if same - uint32_t m_nrDcdSent; ///< number DCD sent - uint32_t m_nrUcdSent; ///< number UCD sent - - uint32_t m_dcdConfigChangeCount; ///< DCD config change count - uint32_t m_ucdConfigChangeCount; ///< UCD config change count - - uint32_t m_framesSinceLastDcd; ///< frames since last DCD - uint32_t m_framesSinceLastUcd; ///< frames since last UCD - - // uint32_t m_nrFrames; //temporarily defined in wimax-net-device, as static - uint32_t m_nrDlFrames; ///< number DL frames - uint32_t m_nrUlFrames; ///< number UL frames - - // to keep track if number of SSs have changed since the last frame - uint16_t m_nrSsRegistered; ///< number SS registered - - uint16_t m_nrDlAllocations; ///< number DL allocations - uint16_t m_nrUlAllocations; ///< number UL allocations - - Time m_dlSubframeStartTime; ///< DL subframe start time - Time m_ulSubframeStartTime; ///< UL subframe start time - - uint8_t m_ulAllocationNumber; ///< to see UL burst number - uint8_t m_rangingOppNumber; ///< current ranging TO number - - CidFactory* m_cidFactory; ///< the CID factory - - uint32_t m_allocationStartTime; ///< allocation start time - - Ptr m_ssManager; ///< the SS manager - Ptr m_uplinkScheduler; ///< the uplink scheduler - Ptr m_scheduler; ///< the base station scheduler - Ptr m_linkManager; ///< the link manager - Ptr m_bsClassifier; ///< the base station classifier - Ptr m_serviceFlowManager; ///< the service flow manager - // same fields as in PHY, for quick access - Time m_psDuration; ///< ps duration - Time m_symbolDuration; ///< symbol duration - - TracedCallback, Mac48Address, Cid> - m_traceBSRx; ///< the base station receive trace callback - - /** - * The trace source fired when packets come into the "top" of the device - * at the L3/L2 transition, before being queued for transmission. - * - * @see class CallBackTraceSource - */ - TracedCallback> m_bsTxTrace; ///< the base station transmit trace callback - - /** - * The trace source fired when packets coming into the "top" of the device - * are dropped at the MAC layer during transmission. - * - * @see class CallBackTraceSource - */ - TracedCallback> - m_bsTxDropTrace; ///< base station transmit drop trace callback - - /** - * The trace source fired for packets successfully received by the device - * immediately before being forwarded up to higher layers (at the L2/L3 - * transition). This is a promiscuous trace. - * - * @see class CallBackTraceSource - */ - TracedCallback> - m_bsPromiscRxTrace; ///< base station promiscuous receive trace callback - - /** - * The trace source fired for packets successfully received by the device - * immediately before being forwarded up to higher layers (at the L2/L3 - * transition). This is a non- promiscuous trace. - * - * @see class CallBackTraceSource - */ - TracedCallback> m_bsRxTrace; ///< base station receive trace callback - - /** - * The trace source fired when packets coming into the "top" of the device - * are dropped at the MAC layer during reception. - * - * @see class CallBackTraceSource - */ - TracedCallback> m_bsRxDropTrace; ///< base station receive drop trace callback -}; - -} // namespace ns3 - -#endif /* WIMAX_BS_NET_DEVICE_H */ diff --git a/src/wimax/model/bs-scheduler-rtps.cc b/src/wimax/model/bs-scheduler-rtps.cc deleted file mode 100644 index e97441f14..000000000 --- a/src/wimax/model/bs-scheduler-rtps.cc +++ /dev/null @@ -1,734 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * 2009 TELEMATICS LAB, Politecnico di Bari - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Giuseppe Piro - */ - -#include "bs-scheduler-rtps.h" - -#include "bs-net-device.h" -#include "burst-profile-manager.h" -#include "cid.h" -#include "connection-manager.h" -#include "service-flow-manager.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-manager.h" -#include "ss-record.h" -#include "wimax-connection.h" -#include "wimax-mac-header.h" -#include "wimax-mac-queue.h" - -#include "ns3/log.h" -#include "ns3/packet-burst.h" -#include "ns3/simulator.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("BSSchedulerRtps"); - -NS_OBJECT_ENSURE_REGISTERED(BSSchedulerRtps); - -TypeId -BSSchedulerRtps::GetTypeId() -{ - static TypeId tid = TypeId("ns3::BSSchedulerRtps") - .SetParent() - .SetGroupName("Wimax") - .AddConstructor(); - return tid; -} - -BSSchedulerRtps::BSSchedulerRtps() - : m_downlinkBursts(new std::list>>()) -{ - SetBs(nullptr); -} - -BSSchedulerRtps::BSSchedulerRtps(Ptr bs) - : m_downlinkBursts(new std::list>>()) -{ - // m_downlinkBursts is filled by AddDownlinkBurst and emptied by - // wimax-bs-net-device::sendBurst and wimax-ss-net-device::sendBurst - SetBs(bs); -} - -BSSchedulerRtps::~BSSchedulerRtps() -{ - std::list>>* downlinkBursts = m_downlinkBursts; - std::pair> pair; - while (!downlinkBursts->empty()) - { - pair = downlinkBursts->front(); - pair.second = nullptr; - delete pair.first; - } - - SetBs(nullptr); - delete m_downlinkBursts; - m_downlinkBursts = nullptr; -} - -std::list>>* -BSSchedulerRtps::GetDownlinkBursts() const -{ - return m_downlinkBursts; -} - -void -BSSchedulerRtps::AddDownlinkBurst(Ptr connection, - uint8_t diuc, - WimaxPhy::ModulationType modulationType, - Ptr burst) -{ - auto dlMapIe = new OfdmDlMapIe(); - dlMapIe->SetCid(connection->GetCid()); - dlMapIe->SetDiuc(diuc); - - NS_LOG_INFO("BS scheduler, burst size: " << burst->GetSize() << " bytes" - << ", pkts: " << burst->GetNPackets() - << ", connection: " << connection->GetTypeStr() - << ", CID: " << connection->GetCid()); - if (connection->GetType() == Cid::TRANSPORT) - { - NS_LOG_INFO(", SFID: " << connection->GetServiceFlow()->GetSfid() << ", service: " - << connection->GetServiceFlow()->GetSchedulingTypeStr()); - } - NS_LOG_INFO(", modulation: " << modulationType << ", DIUC: " << (uint32_t)diuc); - - m_downlinkBursts->emplace_back(dlMapIe, burst); -} - -/** - * @brief A DownLink Scheduler for rtPS Flows - * - * The DL Scheduler assigns the available bandwidth in the following order: - * - IR Connections - * - Broadcast Connections - * - Basic and Primary Connections - * - UGS Connections - * - rtPS Connections - * - nrtPS Connections - * - BE Connections - * All rtPS flows that have packets in the queue can transmit at least one - * packet, according to the available bandwidth. - */ -void -BSSchedulerRtps::Schedule() -{ - uint32_t availableSymbols = GetBs()->GetNrDlSymbols(); - - BSSchedulerBroadcastConnection(availableSymbols); - - BSSchedulerInitialRangingConnection(availableSymbols); - - BSSchedulerBasicConnection(availableSymbols); - - BSSchedulerPrimaryConnection(availableSymbols); - - BSSchedulerUGSConnection(availableSymbols); - - BSSchedulerRTPSConnection(availableSymbols); - - BSSchedulerNRTPSConnection(availableSymbols); - - BSSchedulerBEConnection(availableSymbols); - - if (!m_downlinkBursts->empty()) - { - NS_LOG_DEBUG( - "BS scheduler, number of bursts: " - << m_downlinkBursts->size() << ", symbols left: " << availableSymbols << std::endl - << "BS scheduler, queues:" - << " IR " << GetBs()->GetInitialRangingConnection()->GetQueue()->GetSize() - << " broadcast " << GetBs()->GetBroadcastConnection()->GetQueue()->GetSize() - << " basic " - << GetBs()->GetConnectionManager()->GetNPackets(Cid::BASIC, ServiceFlow::SF_TYPE_NONE) - << " primary " - << GetBs()->GetConnectionManager()->GetNPackets(Cid::PRIMARY, ServiceFlow::SF_TYPE_NONE) - << " transport " - << GetBs()->GetConnectionManager()->GetNPackets(Cid::TRANSPORT, - ServiceFlow::SF_TYPE_ALL)); - } -} - -Ptr -BSSchedulerRtps::CreateUgsBurst(ServiceFlow* serviceFlow, - WimaxPhy::ModulationType modulationType, - uint32_t availableSymbols) -{ - Time timeStamp; - GenericMacHeader hdr; - Ptr packet; - auto burst = CreateObject(); - uint32_t nrSymbolsRequired = 0; - - // serviceFlow->CleanUpQueue (); - Ptr connection = serviceFlow->GetConnection(); - while (serviceFlow->HasPackets()) - { - uint32_t FirstPacketSize = - connection->GetQueue()->GetFirstPacketRequiredByte(MacHeaderType::HEADER_TYPE_GENERIC); - nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(FirstPacketSize, modulationType); - if (availableSymbols < nrSymbolsRequired && - CheckForFragmentation(connection, availableSymbols, modulationType)) - { - uint32_t availableByte = - GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType); - packet = connection->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte); - availableSymbols = 0; - } - else - { - packet = connection->Dequeue(); - availableSymbols -= nrSymbolsRequired; - } - burst->AddPacket(packet); - if (availableSymbols <= 0) - { - break; - } - } - return burst; -} - -bool -BSSchedulerRtps::SelectConnection(Ptr& connection) -{ - return false; -} - -void -BSSchedulerRtps::BSSchedulerBroadcastConnection(uint32_t& availableSymbols) -{ - Ptr connection; - WimaxPhy::ModulationType modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - uint8_t diuc = OfdmDlBurstProfile::DIUC_BURST_PROFILE_1; - uint32_t nrSymbolsRequired = 0; - GenericMacHeader hdr; - Ptr packet; - auto burst = CreateObject(); - - while (GetBs()->GetBroadcastConnection()->HasPackets() && availableSymbols > 0) - { - connection = GetBs()->GetBroadcastConnection(); - - packet = connection->GetQueue()->Peek(hdr); - nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType); - - if (availableSymbols < nrSymbolsRequired && - !CheckForFragmentation(connection, availableSymbols, modulationType)) - { - break; - } - else if (availableSymbols < nrSymbolsRequired && - CheckForFragmentation(connection, availableSymbols, modulationType)) - { - uint32_t availableByte = - GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType); - packet = connection->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte); - } - else - { - packet = connection->Dequeue(); - } - - NS_ASSERT_MSG(hdr.GetCid().GetIdentifier() == connection->GetCid(), - "Base station: Error while scheduling broadcast connection: header CID != " - "connection CID"); - burst->AddPacket(packet); - availableSymbols -= nrSymbolsRequired; - } - if (burst->GetNPackets() != 0) - { - AddDownlinkBurst(connection, diuc, modulationType, burst); - } -} - -void -BSSchedulerRtps::BSSchedulerInitialRangingConnection(uint32_t& availableSymbols) -{ - Ptr connection; - WimaxPhy::ModulationType modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - uint8_t diuc = OfdmDlBurstProfile::DIUC_BURST_PROFILE_1; - uint32_t nrSymbolsRequired = 0; - GenericMacHeader hdr; - Ptr packet; - auto burst = CreateObject(); - - while (GetBs()->GetInitialRangingConnection()->HasPackets() && availableSymbols > 0) - { - connection = GetBs()->GetInitialRangingConnection(); - - packet = connection->GetQueue()->Peek(hdr); - nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType); - - // PIRO: check for fragmentation - if (availableSymbols < nrSymbolsRequired && - !CheckForFragmentation(connection, availableSymbols, modulationType)) - { - break; - } - else if (availableSymbols < nrSymbolsRequired && - CheckForFragmentation(connection, availableSymbols, modulationType)) - { - uint32_t availableByte = - GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType); - packet = connection->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte); - } - else - { - packet = connection->Dequeue(); - } - - NS_ASSERT_MSG(hdr.GetCid() == connection->GetCid(), - "Base station: Error while scheduling initial ranging connection: header CID " - "!= connection CID"); - burst->AddPacket(packet); - availableSymbols -= nrSymbolsRequired; - } - if (burst->GetNPackets()) - { - AddDownlinkBurst(connection, diuc, modulationType, burst); - } -} - -void -BSSchedulerRtps::BSSchedulerBasicConnection(uint32_t& availableSymbols) -{ - Ptr connection; - WimaxPhy::ModulationType modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - uint8_t diuc = OfdmDlBurstProfile::DIUC_BURST_PROFILE_1; - uint32_t nrSymbolsRequired = 0; - GenericMacHeader hdr; - Ptr packet; - auto burst = CreateObject(); - - std::vector> connections; - - connections = GetBs()->GetConnectionManager()->GetConnections(Cid::BASIC); - for (auto iter = connections.begin(); iter != connections.end(); ++iter) - { - while ((*iter)->HasPackets() && availableSymbols > 0) - { - connection = *iter; - - modulationType = - GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType(); - diuc = GetBs()->GetBurstProfileManager()->GetBurstProfile( - modulationType, - WimaxNetDevice::DIRECTION_DOWNLINK); - - packet = connection->GetQueue()->Peek(hdr); - nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType); - - // PIRO: check for fragmentation - if (availableSymbols < nrSymbolsRequired && - !CheckForFragmentation(connection, availableSymbols, modulationType)) - { - break; - } - else if (availableSymbols < nrSymbolsRequired && - CheckForFragmentation(connection, availableSymbols, modulationType)) - { - uint32_t availableByte = - GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType); - packet = connection->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte); - } - else - { - packet = connection->Dequeue(); - } - - NS_ASSERT_MSG(hdr.GetCid() == connection->GetCid(), - "Base station: Error while scheduling basic connection: header CID != " - "connection CID"); - burst->AddPacket(packet); - availableSymbols -= nrSymbolsRequired; - } - if (burst->GetNPackets() != 0) - { - AddDownlinkBurst(connection, diuc, modulationType, burst); - burst = CreateObject(); - } - } -} - -void -BSSchedulerRtps::BSSchedulerPrimaryConnection(uint32_t& availableSymbols) -{ - Ptr connection; - WimaxPhy::ModulationType modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - uint8_t diuc = 0; - uint32_t nrSymbolsRequired = 0; - GenericMacHeader hdr; - Ptr packet; - auto burst = CreateObject(); - - std::vector> connections; - - connections = GetBs()->GetConnectionManager()->GetConnections(Cid::PRIMARY); - for (auto iter = connections.begin(); iter != connections.end(); ++iter) - { - while ((*iter)->HasPackets() && availableSymbols > 0) - { - connection = *iter; - - modulationType = - GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType(); - diuc = GetBs()->GetBurstProfileManager()->GetBurstProfile( - modulationType, - WimaxNetDevice::DIRECTION_DOWNLINK); - - packet = connection->GetQueue()->Peek(hdr); - nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType); - - // PIRO: check for fragmentation - if (availableSymbols < nrSymbolsRequired && - !CheckForFragmentation(connection, availableSymbols, modulationType)) - { - break; - } - else if (availableSymbols < nrSymbolsRequired && - CheckForFragmentation(connection, availableSymbols, modulationType)) - { - uint32_t availableByte = - GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType); - packet = connection->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte); - } - else - { - packet = connection->Dequeue(); - } - - NS_ASSERT_MSG(hdr.GetCid() == connection->GetCid(), - "Base station: Error while scheduling primary connection: header CID != " - "connection CID"); - burst->AddPacket(packet); - availableSymbols -= nrSymbolsRequired; - } - if (burst->GetNPackets() != 0) - { - AddDownlinkBurst(connection, diuc, modulationType, burst); - } - } -} - -void -BSSchedulerRtps::BSSchedulerUGSConnection(uint32_t& availableSymbols) -{ - Ptr connection; - WimaxPhy::ModulationType modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - uint8_t diuc; - uint32_t nrSymbolsRequired = 0; - GenericMacHeader hdr; - Ptr packet; - auto burst = CreateObject(); - - Time currentTime = Simulator::Now(); - - ServiceFlowRecord* serviceFlowRecord; - std::vector serviceFlows; - - serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_UGS); - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - serviceFlowRecord = (*iter)->GetRecord(); - // if latency would exceed in case grant is allocated in next frame then allocate in current - // frame - if ((*iter)->HasPackets() && - ((currentTime - serviceFlowRecord->GetDlTimeStamp()) + - GetBs()->GetPhy()->GetFrameDuration()) > MilliSeconds((*iter)->GetMaximumLatency())) - { - connection = (*iter)->GetConnection(); - if (connection->GetType() == Cid::MULTICAST) - { - modulationType = connection->GetServiceFlow()->GetModulation(); - } - else - { - modulationType = - GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType(); - } - diuc = GetBs()->GetBurstProfileManager()->GetBurstProfile( - modulationType, - WimaxNetDevice::DIRECTION_DOWNLINK); - - nrSymbolsRequired = connection->GetServiceFlow()->GetRecord()->GetGrantSize(); - - // Packet fragmentation for UGS connections has not been implemented yet! - if (availableSymbols > nrSymbolsRequired) - { - availableSymbols -= nrSymbolsRequired; - burst = - CreateUgsBurst(connection->GetServiceFlow(), modulationType, nrSymbolsRequired); - if (burst->GetNPackets() != 0) - { - AddDownlinkBurst(connection, diuc, modulationType, burst); - currentTime = Simulator::Now(); - serviceFlowRecord->SetDlTimeStamp(currentTime); - burst = CreateObject(); - } - } - } - } -} - -void -BSSchedulerRtps::BSSchedulerRTPSConnection(uint32_t& availableSymbols) -{ - Ptr connection; - GenericMacHeader hdr; - Ptr packet; - auto burst = CreateObject(); - - Time currentTime = Simulator::Now(); - - std::vector> connections; - ServiceFlowRecord* serviceFlowRecord; - std::vector serviceFlows; - - uint32_t symbolsRequired[100]; - WimaxPhy::ModulationType modulationType_[100]; - uint8_t diuc_[100]; - Ptr rtPSConnection[100]; - uint32_t dataToSend; - uint32_t totSymbolsRequired = 0; - int nbConnection = 0; - - NS_LOG_INFO("\tDL Scheduler for rtPS flows \n" - << "\t\tavailableSymbols = " << availableSymbols); - - serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_RTPS); - nbConnection = 0; - for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) - { - // DL RTPS Scheduler works for all rtPS connection that have packets to transmitt!!! - serviceFlowRecord = (*iter2)->GetRecord(); - - if ((*iter2)->HasPackets()) - { - currentTime = Simulator::Now(); - serviceFlowRecord->SetDlTimeStamp(currentTime); - rtPSConnection[nbConnection] = (*iter2)->GetConnection(); - if (rtPSConnection[nbConnection]->GetType() == Cid::MULTICAST) - { - modulationType_[nbConnection] = - rtPSConnection[nbConnection]->GetServiceFlow()->GetModulation(); - } - else - { - modulationType_[nbConnection] = - GetBs() - ->GetSSManager() - ->GetSSRecord(rtPSConnection[nbConnection]->GetCid()) - ->GetModulationType(); - } - diuc_[nbConnection] = GetBs()->GetBurstProfileManager()->GetBurstProfile( - modulationType_[nbConnection], - WimaxNetDevice::DIRECTION_DOWNLINK); - - dataToSend = rtPSConnection[nbConnection]->GetQueue()->GetQueueLengthWithMACOverhead(); - NS_LOG_INFO("\t\tRTPS DL Scheduler for CID = " << rtPSConnection[nbConnection]->GetCid() - << "\n\t\t\t dataToSend = " - << dataToSend); - - symbolsRequired[nbConnection] = - GetBs()->GetPhy()->GetNrSymbols(dataToSend, modulationType_[nbConnection]); - - totSymbolsRequired += symbolsRequired[nbConnection]; - nbConnection++; - } - } - - NS_LOG_INFO("\t\ttotSymbolsRequired = " << totSymbolsRequired); - - // Channel Saturation - while (totSymbolsRequired > availableSymbols) - { - NS_LOG_INFO("\tDL Channel Saturation: totSymbolsRequired > availableSymbols_rtPS"); - double delta = double(availableSymbols) / double(totSymbolsRequired); - NS_LOG_INFO("\t\tdelta = " << delta); - totSymbolsRequired = 0; - for (int i = 0; i < nbConnection; i++) - { - NS_LOG_INFO("\t\tprevious symbolsRequired[" << i << "] = " << symbolsRequired[i]); - symbolsRequired[i] = (uint32_t)std::floor(symbolsRequired[i] * delta); - totSymbolsRequired += symbolsRequired[i]; - NS_LOG_INFO("\t\tnew symbolsRequired[" << i << "] = " << symbolsRequired[i]); - } - NS_LOG_INFO("\t\ttotSymbolsRequired = " << totSymbolsRequired); - } - - // Downlink Bandwidth Allocation - for (int i = 0; i < nbConnection; i++) - { - packet = rtPSConnection[i]->GetQueue()->Peek(hdr); - uint32_t symbolsForPacketTransmission = 0; - burst = CreateObject(); - NS_LOG_INFO("\t\tCID = " << rtPSConnection[i]->GetCid() - << " assignedSymbols = " << symbolsRequired[i]); - - while (symbolsRequired[i] > 0) - { - symbolsForPacketTransmission = GetBs()->GetPhy()->GetNrSymbols( - rtPSConnection[i]->GetQueue()->GetFirstPacketRequiredByte( - MacHeaderType::HEADER_TYPE_GENERIC), - modulationType_[i]); - - // PIRO: check for fragmentation - if (symbolsForPacketTransmission > symbolsRequired[i] && - !CheckForFragmentation(rtPSConnection[i], symbolsRequired[i], modulationType_[i])) - { - break; - } - else if (symbolsForPacketTransmission > symbolsRequired[i] && - CheckForFragmentation(rtPSConnection[i], - symbolsRequired[i], - modulationType_[i])) - { - uint32_t availableByte = - GetBs()->GetPhy()->GetNrBytes(symbolsRequired[i], modulationType_[i]); - packet = - rtPSConnection[i]->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte); - symbolsRequired[i] = 0; - } - else - { - packet = rtPSConnection[i]->Dequeue(); - symbolsRequired[i] -= symbolsForPacketTransmission; - } - - NS_ASSERT_MSG(hdr.GetCid() == rtPSConnection[i]->GetCid(), - "Base station: Error while scheduling RTPs connection: header CID != " - "connection CID"); - burst->AddPacket(packet); - } - - if (burst->GetNPackets() != 0) - { - AddDownlinkBurst(rtPSConnection[i], diuc_[i], modulationType_[i], burst); - } - } - - availableSymbols -= totSymbolsRequired; -} - -void -BSSchedulerRtps::BSSchedulerNRTPSConnection(uint32_t& availableSymbols) -{ - Ptr connection; - WimaxPhy::ModulationType modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - uint8_t diuc = 0; - uint32_t nrSymbolsRequired = 0; - GenericMacHeader hdr; - Ptr packet; - auto burst = CreateObject(); - - std::vector serviceFlows; - - serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_NRTPS); - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - connection = (*iter)->GetConnection(); - - while ((*iter)->HasPackets() && availableSymbols > 0) - { - if (connection->GetType() == Cid::MULTICAST) - { - modulationType = connection->GetServiceFlow()->GetModulation(); - } - else - { - modulationType = - GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType(); - } - - diuc = GetBs()->GetBurstProfileManager()->GetBurstProfile( - modulationType, - WimaxNetDevice::DIRECTION_DOWNLINK); - - packet = connection->GetQueue()->Peek(hdr); - nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType); - - if (availableSymbols < nrSymbolsRequired) - { - break; - } - - packet = connection->Dequeue(); - NS_ASSERT_MSG(hdr.GetCid() == connection->GetCid(), - "Base station: Error while scheduling NRTPs connection: header CID != " - "connection CID"); - burst->AddPacket(packet); - availableSymbols -= nrSymbolsRequired; - } - if (burst->GetNPackets() != 0) - { - AddDownlinkBurst(connection, diuc, modulationType, burst); - burst = CreateObject(); - } - } -} - -void -BSSchedulerRtps::BSSchedulerBEConnection(uint32_t& availableSymbols) -{ - Ptr connection; - WimaxPhy::ModulationType modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - uint8_t diuc = 0; - uint32_t nrSymbolsRequired = 0; - GenericMacHeader hdr; - Ptr packet; - auto burst = CreateObject(); - - std::vector serviceFlows; - - serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_BE); - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - connection = (*iter)->GetConnection(); - - while ((*iter)->HasPackets() && availableSymbols > 0) - { - if (connection->GetType() == Cid::MULTICAST) - { - modulationType = connection->GetServiceFlow()->GetModulation(); - } - else - { - modulationType = - GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType(); - } - diuc = GetBs()->GetBurstProfileManager()->GetBurstProfile( - modulationType, - WimaxNetDevice::DIRECTION_DOWNLINK); - - packet = connection->GetQueue()->Peek(hdr); - nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType); - - if (availableSymbols < nrSymbolsRequired) - { - break; - } - - packet = connection->Dequeue(); - NS_ASSERT_MSG( - hdr.GetCid() == connection->GetCid(), - "Base station: Error while scheduling BE connection: header CID != connection CID"); - burst->AddPacket(packet); - availableSymbols -= nrSymbolsRequired; - } - if (burst->GetNPackets() != 0) - { - AddDownlinkBurst(connection, diuc, modulationType, burst); - burst = CreateObject(); - } - } -} - -} // namespace ns3 diff --git a/src/wimax/model/bs-scheduler-rtps.h b/src/wimax/model/bs-scheduler-rtps.h deleted file mode 100644 index d958052ba..000000000 --- a/src/wimax/model/bs-scheduler-rtps.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * 2009 TELEMATICS LAB, Politecnico di Bari - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Giuseppe Piro - */ - -/* BS outbound scheduler as per in Section 6.3.5.1 */ - -#ifndef BS_SCHEDULER_RTPS_H -#define BS_SCHEDULER_RTPS_H - -#include "bs-scheduler.h" -#include "dl-mac-messages.h" -#include "wimax-phy.h" - -#include "ns3/packet-burst.h" -#include "ns3/packet.h" - -#include - -namespace ns3 -{ - -class BaseStationNetDevice; -class GenericMacHeader; -class WimaxConnection; -class Cid; - -/** - * @ingroup wimax - * @brief This class implements a simple downlink scheduler for rtPS flows. - * - * The DL-rtPS-Scheduler assigns the available bandwidth the service flows - * in the following order: IR Connections, Broadcast Connections, Basic and - * Primary Connections, UGS Connections, rtPS Connections, nrtPS Connections, - * BE Connections. - * The IR, Broadcast and Basic/Primary Connections must transmit - * all packet in the queue. The UGS flows can transmit the quota of date equal to - * the "Grant Size" (that is one of service flows QoS parameters) according to their - * requested MaxLatency (another QoS parameter). - * All rtPS flows are able to transmit all packet in the queue according to the available - * bandwidth. The bandwidth saturation control has been implemented to redistribute - *the effective available bandwidth to all rtPS flows that have at least one packet - * to transmit. The remaining bandwidth is allocated to rntPS and BE Connections. - */ -class BSSchedulerRtps : public BSScheduler -{ - public: - BSSchedulerRtps(); - /** - * Constructor - * - * @param bs base station device - */ - BSSchedulerRtps(Ptr bs); - ~BSSchedulerRtps() override; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - - /** - * @brief This function returns all the downlink bursts scheduled for the next - * downlink sub-frame - * @returns all the downlink bursts scheduled for the next downlink sub-frame - */ - std::list>>* GetDownlinkBursts() const override; - - /** - * @brief This function adds a downlink burst to the list of downlink bursts - * scheduled for the next downlink sub-frame - * @param connection a pointer to connection in which the burst will be sent - * @param diuc downlink iuc - * @param modulationType the modulation type of the burst - * @param burst the downlink burst to add to the downlink sub frame - */ - void AddDownlinkBurst(Ptr connection, - uint8_t diuc, - WimaxPhy::ModulationType modulationType, - Ptr burst) override; - /** - * @brief Schedule function. - */ - void Schedule() override; - /** - * @brief Check for IR and Broadcast connections that have packets to transmit. - * @param connection will point to a initial ranging or broadcast connection - * which have packets to transmit - * @returns false if no initial ranging or broadcast connection has packets - * to transmit, true otherwise - */ - bool SelectIRandBCConnection(Ptr& connection); - /** - * @brief Check for Basic and Primary connections that have packets to transmit. - * @param connection will point to a basic or primary connection - * which have packets to transmit - * @returns false if no basic or primary connection has packets - * to transmit, true otherwise - */ - bool SelectMenagementConnection(Ptr& connection); - /** - * @brief Check for UGS connections that have packets to transmit. - * - * The method return the UGS connection that have packets to transmits, - * according to the MaxLatency specifications. - * @param connection will point to a connection that has packets to be sent - * @return true if successful - */ - bool SelectUGSConnection(Ptr& connection); - /** - * @brief Check for rtPS connections that have packets to transmit. - * @param connection will point to a connection that has packets to be sent - * @returns false if no connection has packets to be sent, true otherwise - */ - bool SelectRTPSConnection(Ptr& connection); - /** - * @brief Check for nrtPS connections that have packets to transmit. - * @param connection will point to a connection that has packets to be sent - * @returns false if no connection has packets to be sent, true otherwise - */ - bool SelectNRTPSConnection(Ptr& connection); - /** - * @brief Check for BE connections that have packets to transmit. - * @param connection will point to a connection that has packets to be sent - * @returns false if no connection has packets to be sent, true otherwise - */ - bool SelectBEConnection(Ptr& connection); - - /** - * @brief Selects a connection from the list of connections having packets to be sent . - * @param connection will point to a connection that has packets to be sent - * @returns false if no connection has packets to be sent, true otherwise - */ - bool SelectConnection(Ptr& connection) override; - - /** - * @brief schedules the broadcast connections - * @param availableSymbols the remaining free OFDM symbols in the current subframe - */ - void BSSchedulerBroadcastConnection(uint32_t& availableSymbols); - - /** - * @brief schedules the IR connections - * @param availableSymbols the remaining free OFDM symbols in the current subframe - */ - void BSSchedulerInitialRangingConnection(uint32_t& availableSymbols); - - /** - * @brief schedules the basic connections - * @param availableSymbols the remaining free OFDM symbols in the current subframe - */ - void BSSchedulerBasicConnection(uint32_t& availableSymbols); - - /** - * @brief schedules the primary connection - * @param availableSymbols the remaining free OFDM symbols in the current subframe - */ - void BSSchedulerPrimaryConnection(uint32_t& availableSymbols); - /** - * @brief schedules the UGS connection - * @param availableSymbols the remaining free OFDM symbols in the current subframe - */ - void BSSchedulerUGSConnection(uint32_t& availableSymbols); - /** - * @brief Downlink Scheduler for rtPS connections. - * - * @param availableSymbols available symbols for rtPS flows - * - * This method represent the DL Scheduler for rtPS connections. - * The scheduler is designed to serve all rtPS connections that - * have at least one packet to transmit, every DL Subframe. - * To each rtPS connections are allocated, at the beginning, - * the bandwidth to transmit a quota of data equal to the - * queue length. - * If the sum of all pre-allocated bandwidth exceed the available - * symbols for rtPS connections, the Channel Saturation Control function - * is called to redistribute the available bandwidth. - */ - void BSSchedulerRTPSConnection(uint32_t& availableSymbols); - - /** - * @brief schedules the NRTPS connections - * @param availableSymbols the remaining free OFDM symbols in the current subframe - */ - void BSSchedulerNRTPSConnection(uint32_t& availableSymbols); - - /** - * @brief schedules the BE connection - * @param availableSymbols the remaining free OFDM symbols in the current subframe - */ - void BSSchedulerBEConnection(uint32_t& availableSymbols); - - /** - * @brief Creates a downlink UGS burst - * @param serviceFlow the service flow of the burst - * @param modulationType the modulation type to be used for the burst - * @param availableSymbols maximum number of OFDM symbols to be used by the burst - * @returns a Burst (list of packets) - */ - Ptr CreateUgsBurst(ServiceFlow* serviceFlow, - WimaxPhy::ModulationType modulationType, - uint32_t availableSymbols) override; - - private: - std::list>>* m_downlinkBursts; ///< down link bursts -}; - -} // namespace ns3 - -#endif /* BS_SCHEDULER_RTPS_H */ diff --git a/src/wimax/model/bs-scheduler-simple.cc b/src/wimax/model/bs-scheduler-simple.cc deleted file mode 100644 index ae8a01af5..000000000 --- a/src/wimax/model/bs-scheduler-simple.cc +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#include "bs-scheduler-simple.h" - -#include "bs-net-device.h" -#include "burst-profile-manager.h" -#include "cid.h" -#include "connection-manager.h" -#include "service-flow-manager.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-manager.h" -#include "ss-record.h" -#include "wimax-connection.h" -#include "wimax-mac-header.h" -#include "wimax-mac-queue.h" - -#include "ns3/log.h" -#include "ns3/packet-burst.h" -#include "ns3/simulator.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("BSSchedulerSimple"); - -NS_OBJECT_ENSURE_REGISTERED(BSSchedulerSimple); - -TypeId -BSSchedulerSimple::GetTypeId() -{ - static TypeId tid = TypeId("ns3::BSSchedulerSimple") - .SetParent() - .SetGroupName("Wimax") - .AddConstructor(); - return tid; -} - -BSSchedulerSimple::BSSchedulerSimple() - : m_downlinkBursts(new std::list>>()) -{ - SetBs(nullptr); -} - -BSSchedulerSimple::BSSchedulerSimple(Ptr bs) - : m_downlinkBursts(new std::list>>()) -{ - // m_downlinkBursts is filled by AddDownlinkBurst and emptied by - // wimax-bs-net-device::sendBurst and wimax-ss-net-device::sendBurst - SetBs(bs); -} - -BSSchedulerSimple::~BSSchedulerSimple() -{ - std::list>>* downlinkBursts = m_downlinkBursts; - std::pair> pair; - while (!downlinkBursts->empty()) - { - pair = downlinkBursts->front(); - pair.second = nullptr; - delete pair.first; - } - SetBs(nullptr); - delete m_downlinkBursts; - m_downlinkBursts = nullptr; -} - -std::list>>* -BSSchedulerSimple::GetDownlinkBursts() const -{ - return m_downlinkBursts; -} - -void -BSSchedulerSimple::AddDownlinkBurst(Ptr connection, - uint8_t diuc, - WimaxPhy::ModulationType modulationType, - Ptr burst) -{ - auto dlMapIe = new OfdmDlMapIe(); - dlMapIe->SetCid(connection->GetCid()); - dlMapIe->SetDiuc(diuc); - - NS_LOG_INFO("BS scheduler, burst size: " << burst->GetSize() << " bytes" - << ", pkts: " << burst->GetNPackets() - << ", connection: " << connection->GetTypeStr() - << ", CID: " << connection->GetCid()); - if (connection->GetType() == Cid::TRANSPORT) - { - NS_LOG_INFO(", SFID: " << connection->GetServiceFlow()->GetSfid() << ", service: " - << connection->GetServiceFlow()->GetSchedulingTypeStr()); - } - NS_LOG_INFO(", modulation: " << modulationType << ", DIUC: " << (uint32_t)diuc); - - m_downlinkBursts->emplace_back(dlMapIe, burst); -} - -void -BSSchedulerSimple::Schedule() -{ - Ptr connection; - WimaxPhy::ModulationType modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - uint8_t diuc = OfdmDlBurstProfile::DIUC_BURST_PROFILE_1; - uint32_t nrSymbolsRequired = 0; - GenericMacHeader hdr; - Ptr packet; - Ptr burst; - ServiceFlow::SchedulingType schedulingType = ServiceFlow::SF_TYPE_NONE; - uint32_t availableSymbols = GetBs()->GetNrDlSymbols(); - - while (SelectConnection(connection)) - { - if (connection != GetBs()->GetInitialRangingConnection() && - connection != GetBs()->GetBroadcastConnection()) - { - /* determines modulation/DIUC only once per burst as it is always same for a particular - * CID */ - if (connection->GetType() == Cid::MULTICAST) - { - modulationType = connection->GetServiceFlow()->GetModulation(); - } - else - { - modulationType = - GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType(); - } - diuc = GetBs()->GetBurstProfileManager()->GetBurstProfile( - modulationType, - WimaxNetDevice::DIRECTION_DOWNLINK); - } - else if (connection == GetBs()->GetInitialRangingConnection() || - connection == GetBs()->GetBroadcastConnection()) - { - modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - diuc = OfdmDlBurstProfile::DIUC_BURST_PROFILE_1; - } - - if (connection->GetType() == Cid::TRANSPORT || connection->GetType() == Cid::MULTICAST) - { - schedulingType = (ServiceFlow::SchedulingType)connection->GetSchedulingType(); - } - - if (schedulingType == ServiceFlow::SF_TYPE_UGS) - { - nrSymbolsRequired = connection->GetServiceFlow()->GetRecord()->GetGrantSize(); - if (nrSymbolsRequired < availableSymbols) - { - burst = - CreateUgsBurst(connection->GetServiceFlow(), modulationType, nrSymbolsRequired); - } - else - { - burst = - CreateUgsBurst(connection->GetServiceFlow(), modulationType, availableSymbols); - } - if (burst->GetNPackets() != 0) - { - uint32_t BurstSizeSymbols = - GetBs()->GetPhy()->GetNrSymbols(burst->GetSize(), modulationType); - AddDownlinkBurst(connection, diuc, modulationType, burst); - - if (availableSymbols <= BurstSizeSymbols) - { - availableSymbols -= - BurstSizeSymbols; /// \todo Overflows but don't know how to fix - break; - } - } - } - else - { - burst = CreateObject(); - while (connection->HasPackets()) - { - uint32_t FirstPacketSize = connection->GetQueue()->GetFirstPacketRequiredByte( - MacHeaderType::HEADER_TYPE_GENERIC); - nrSymbolsRequired = - GetBs()->GetPhy()->GetNrSymbols(FirstPacketSize, modulationType); - if (availableSymbols < nrSymbolsRequired && - CheckForFragmentation(connection, availableSymbols, modulationType)) - { - uint32_t availableByte = - GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType); - packet = connection->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte); - availableSymbols = 0; - } - else if (availableSymbols >= nrSymbolsRequired) - { - packet = connection->Dequeue(); - availableSymbols -= nrSymbolsRequired; - } - else - { - break; - } - burst->AddPacket(packet); - } - AddDownlinkBurst(connection, diuc, modulationType, burst); - } - if (availableSymbols == 0) - { - break; - } - } - - if (!m_downlinkBursts->empty()) - { - NS_LOG_DEBUG( - "BS scheduler, number of bursts: " - << m_downlinkBursts->size() << ", symbols left: " << availableSymbols << std::endl - << "BS scheduler, queues:" - << " IR " << GetBs()->GetInitialRangingConnection()->GetQueue()->GetSize() - << " broadcast " << GetBs()->GetBroadcastConnection()->GetQueue()->GetSize() - << " basic " - << GetBs()->GetConnectionManager()->GetNPackets(Cid::BASIC, ServiceFlow::SF_TYPE_NONE) - << " primary " - << GetBs()->GetConnectionManager()->GetNPackets(Cid::PRIMARY, ServiceFlow::SF_TYPE_NONE) - << " transport " - << GetBs()->GetConnectionManager()->GetNPackets(Cid::TRANSPORT, - ServiceFlow::SF_TYPE_ALL)); - } -} - -bool -BSSchedulerSimple::SelectConnection(Ptr& connection) -{ - connection = nullptr; - Time currentTime = Simulator::Now(); - ServiceFlowRecord* serviceFlowRecord; - NS_LOG_INFO("BS Scheduler: Selecting connection..."); - if (GetBs()->GetBroadcastConnection()->HasPackets()) - { - NS_LOG_INFO("Return GetBroadcastConnection"); - connection = GetBs()->GetBroadcastConnection(); - return true; - } - else if (GetBs()->GetInitialRangingConnection()->HasPackets()) - { - NS_LOG_INFO("Return GetInitialRangingConnection"); - connection = GetBs()->GetInitialRangingConnection(); - return true; - } - else - { - std::vector> connections; - std::vector serviceFlows; - - connections = GetBs()->GetConnectionManager()->GetConnections(Cid::BASIC); - for (auto iter1 = connections.begin(); iter1 != connections.end(); ++iter1) - { - if ((*iter1)->HasPackets()) - { - NS_LOG_INFO("Return Basic"); - connection = *iter1; - return true; - } - } - - connections = GetBs()->GetConnectionManager()->GetConnections(Cid::PRIMARY); - for (auto iter1 = connections.begin(); iter1 != connections.end(); ++iter1) - { - if ((*iter1)->HasPackets()) - { - NS_LOG_INFO("Return Primary"); - connection = *iter1; - return true; - } - } - - serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_UGS); - for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) - { - serviceFlowRecord = (*iter2)->GetRecord(); - NS_LOG_INFO("processing UGS: HAS PACKET=" - << (*iter2)->HasPackets() << "max Latency = " - << MilliSeconds((*iter2)->GetMaximumLatency()) << "Delay = " - << ((currentTime - serviceFlowRecord->GetDlTimeStamp()) + - GetBs()->GetPhy()->GetFrameDuration())); - // if latency would exceed in case grant is allocated in next frame then allocate in - // current frame - if ((*iter2)->HasPackets() && ((currentTime - serviceFlowRecord->GetDlTimeStamp()) + - GetBs()->GetPhy()->GetFrameDuration()) > - MilliSeconds((*iter2)->GetMaximumLatency())) - { - serviceFlowRecord->SetDlTimeStamp(currentTime); - connection = (*iter2)->GetConnection(); - NS_LOG_INFO("Return UGS SF: CID = " << (*iter2)->GetCid() - << "SFID = " << (*iter2)->GetSfid()); - return true; - } - } - - serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_RTPS); - for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) - { - serviceFlowRecord = (*iter2)->GetRecord(); - // if latency would exceed in case poll is allocated in next frame then allocate in - // current frame - if ((*iter2)->HasPackets() && ((currentTime - serviceFlowRecord->GetDlTimeStamp()) + - GetBs()->GetPhy()->GetFrameDuration()) > - MilliSeconds((*iter2)->GetMaximumLatency())) - { - serviceFlowRecord->SetDlTimeStamp(currentTime); - connection = (*iter2)->GetConnection(); - NS_LOG_INFO("Return RTPS SF: CID = " << (*iter2)->GetCid() - << "SFID = " << (*iter2)->GetSfid()); - return true; - } - } - - serviceFlows = - GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_NRTPS); - for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) - { - // unused: serviceFlowRecord = (*iter2)->GetRecord (); - if ((*iter2)->HasPackets()) - { - NS_LOG_INFO("Return NRTPS SF: CID = " << (*iter2)->GetCid() - << "SFID = " << (*iter2)->GetSfid()); - connection = (*iter2)->GetConnection(); - return true; - } - } - - serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_BE); - for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) - { - // unused: serviceFlowRecord = (*iter2)->GetRecord (); - if ((*iter2)->HasPackets()) - { - NS_LOG_INFO("Return BE SF: CID = " << (*iter2)->GetCid() - << "SFID = " << (*iter2)->GetSfid()); - connection = (*iter2)->GetConnection(); - return true; - } - } - } - NS_LOG_INFO("NO connection is selected!"); - return false; -} - -Ptr -BSSchedulerSimple::CreateUgsBurst(ServiceFlow* serviceFlow, - WimaxPhy::ModulationType modulationType, - uint32_t availableSymbols) -{ - Time timeStamp; - GenericMacHeader hdr; - Ptr packet; - auto burst = CreateObject(); - uint32_t nrSymbolsRequired = 0; - - // serviceFlow->CleanUpQueue (); - Ptr connection = serviceFlow->GetConnection(); - while (serviceFlow->HasPackets()) - { - uint32_t FirstPacketSize = - connection->GetQueue()->GetFirstPacketRequiredByte(MacHeaderType::HEADER_TYPE_GENERIC); - nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(FirstPacketSize, modulationType); - if (availableSymbols < nrSymbolsRequired && - CheckForFragmentation(connection, availableSymbols, modulationType)) - { - uint32_t availableByte = - GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType); - packet = connection->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte); - availableSymbols = 0; - } - else - { - packet = connection->Dequeue(); - availableSymbols -= nrSymbolsRequired; - } - burst->AddPacket(packet); - if (availableSymbols <= 0) - { - break; - } - } - return burst; -} - -} // namespace ns3 diff --git a/src/wimax/model/bs-scheduler-simple.h b/src/wimax/model/bs-scheduler-simple.h deleted file mode 100644 index f61d2800b..000000000 --- a/src/wimax/model/bs-scheduler-simple.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -/* BS outbound scheduler as per in Section 6.3.5.1 */ - -#ifndef BS_SCHEDULER_SIMPLE_H -#define BS_SCHEDULER_SIMPLE_H - -#include "bs-scheduler.h" -#include "dl-mac-messages.h" -#include "wimax-phy.h" - -#include "ns3/packet-burst.h" -#include "ns3/packet.h" - -#include - -namespace ns3 -{ - -class BaseStationNetDevice; -class GenericMacHeader; -class WimaxConnection; -class Cid; - -/** - * @ingroup wimax - * - * BaseStation Scheduler - simplified - */ -class BSSchedulerSimple : public BSScheduler -{ - public: - BSSchedulerSimple(); - /** - * Constructor - * - * @param bs base station device - */ - BSSchedulerSimple(Ptr bs); - ~BSSchedulerSimple() override; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - - /** - * @brief This function returns all the downlink bursts scheduled for the next - * downlink sub-frame - * @returns all the downlink bursts scheduled for the next downlink sub-frame - */ - std::list>>* GetDownlinkBursts() const override; - /** - * @brief This function adds a downlink burst to the list of downlink bursts - * scheduled for the next downlink sub-frame - * @param connection a pointer to connection in which the burst will be sent - * @param diuc downlink iuc - * @param modulationType the modulation type of the burst - * @param burst the downlink burst to add to the downlink sub frame - */ - void AddDownlinkBurst(Ptr connection, - uint8_t diuc, - WimaxPhy::ModulationType modulationType, - Ptr burst) override; - - /** - * @brief the scheduling function for the downlink subframe. - */ - void Schedule() override; - /** - * @brief Selects a connection from the list of connections having packets to be sent . - * @param connection will point to a connection that have packets to be sent - * @returns false if no connection has packets to be sent, true otherwise - */ - bool SelectConnection(Ptr& connection) override; - /** - * @brief Creates a downlink UGS burst - * @param serviceFlow the service flow of the burst - * @param modulationType the modulation type to be used for the burst - * @param availableSymbols maximum number of OFDM symbols to be used by the burst - * @returns a Burst (list of packets) - */ - Ptr CreateUgsBurst(ServiceFlow* serviceFlow, - WimaxPhy::ModulationType modulationType, - uint32_t availableSymbols) override; - - private: - std::list>>* m_downlinkBursts; ///< down link bursts -}; - -} // namespace ns3 - -#endif /* BS_SCHEDULER_SIMPLE_H */ diff --git a/src/wimax/model/bs-scheduler.cc b/src/wimax/model/bs-scheduler.cc deleted file mode 100644 index c6f1fd2db..000000000 --- a/src/wimax/model/bs-scheduler.cc +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#include "bs-scheduler.h" - -#include "bs-net-device.h" -#include "burst-profile-manager.h" -#include "cid.h" -#include "connection-manager.h" -#include "service-flow-manager.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-manager.h" -#include "ss-record.h" -#include "wimax-connection.h" -#include "wimax-mac-header.h" -#include "wimax-mac-queue.h" - -#include "ns3/log.h" -#include "ns3/packet-burst.h" -#include "ns3/simulator.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("BSScheduler"); - -NS_OBJECT_ENSURE_REGISTERED(BSScheduler); - -TypeId -BSScheduler::GetTypeId() -{ - static TypeId tid = TypeId("ns3::BSScheduler").SetParent().SetGroupName("Wimax") - // No AddConstructor because this is an abstract class. - ; - return tid; -} - -BSScheduler::BSScheduler() - : m_downlinkBursts(new std::list>>()) -{ - // m_downlinkBursts is filled by AddDownlinkBurst and emptied by - // wimax-bs-net-device::sendBurst and wimax-ss-net-device::sendBurst -} - -BSScheduler::BSScheduler(Ptr bs) - : m_downlinkBursts(new std::list>>()) -{ -} - -BSScheduler::~BSScheduler() -{ - std::list>>* downlinkBursts = m_downlinkBursts; - std::pair> pair; - while (!downlinkBursts->empty()) - { - pair = downlinkBursts->front(); - pair.second = nullptr; - delete pair.first; - } - SetBs(nullptr); - delete m_downlinkBursts; - m_downlinkBursts = nullptr; -} - -void -BSScheduler::SetBs(Ptr bs) -{ - m_bs = bs; -} - -Ptr -BSScheduler::GetBs() -{ - return m_bs; -} - -bool -BSScheduler::CheckForFragmentation(Ptr connection, - int availableSymbols, - WimaxPhy::ModulationType modulationType) -{ - NS_LOG_INFO("BS Scheduler, CheckForFragmentation"); - if (connection->GetType() != Cid::TRANSPORT) - { - NS_LOG_INFO("\t No Transport connection, Fragmentation IS NOT possible"); - return false; - } - uint32_t availableByte = GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType); - - uint32_t headerSize = - connection->GetQueue()->GetFirstPacketHdrSize(MacHeaderType::HEADER_TYPE_GENERIC); - NS_LOG_INFO("\t availableByte = " << availableByte << " headerSize = " << headerSize); - - if (availableByte > headerSize) - { - NS_LOG_INFO("\t Fragmentation IS possible"); - return true; - } - else - { - NS_LOG_INFO("\t Fragmentation IS NOT possible"); - return false; - } -} -} // namespace ns3 diff --git a/src/wimax/model/bs-scheduler.h b/src/wimax/model/bs-scheduler.h deleted file mode 100644 index c44bed126..000000000 --- a/src/wimax/model/bs-scheduler.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -/* BS outbound scheduler as per in Section 6.3.5.1 */ - -#ifndef BS_SCHEDULER_H -#define BS_SCHEDULER_H - -#include "dl-mac-messages.h" -#include "service-flow.h" -#include "wimax-phy.h" - -#include "ns3/packet-burst.h" -#include "ns3/packet.h" - -#include - -namespace ns3 -{ - -class BaseStationNetDevice; -class GenericMacHeader; -class WimaxConnection; -class Cid; - -/** - * @ingroup wimax - * - * BaseStation Scheduler - */ -class BSScheduler : public Object -{ - public: - BSScheduler(); - /** - * Constructor - * - * @param bs base station device - */ - BSScheduler(Ptr bs); - ~BSScheduler() override; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - - /** - * @brief This function returns all the downlink bursts scheduled for the next - * downlink sub-frame - * @returns all the downlink bursts scheduled for the next downlink sub-frame - */ - virtual std::list>>* GetDownlinkBursts() const = 0; - /** - * @brief This function adds a downlink burst to the list of downlink bursts - * scheduled for the next downlink sub-frame - * @param connection a pointer to connection in which the burst will be sent - * @param diuc downlink iuc - * @param modulationType the modulation type of the burst - * @param burst the downlink burst to add to the downlink sub frame - */ - virtual void AddDownlinkBurst(Ptr connection, - uint8_t diuc, - WimaxPhy::ModulationType modulationType, - Ptr burst) = 0; - - /** - * @brief the scheduling function for the downlink subframe. - */ - virtual void Schedule() = 0; - /** - * @brief Selects a connection from the list of connections having packets to be sent . - * @param connection will point to a connection that have packets to be sent - * @returns false if no connection has packets to be sent, true otherwise - */ - virtual bool SelectConnection(Ptr& connection) = 0; - - /** - * @brief Creates a downlink UGS burst - * @param serviceFlow the service flow of the burst - * @param modulationType the modulation type to be used for the burst - * @param availableSymbols maximum number of OFDM symbols to be used by the burst - * @returns a Burst (list of packets) - */ - virtual Ptr CreateUgsBurst(ServiceFlow* serviceFlow, - WimaxPhy::ModulationType modulationType, - uint32_t availableSymbols) = 0; - - /** - * @brief Get the base station. - * @returns the base station net device - */ - virtual Ptr GetBs(); - /** - * @brief Set the base station. - * @param bs the base station net device - */ - virtual void SetBs(Ptr bs); - - /** - * @brief Check if the packet fragmentation is possible for transport connection. - * @param connection the downlink connection - * @param availableSymbols maximum number of OFDM symbols to be used by the burst - * @param modulationType the modulation type to be used for the burst - * @returns false if packet fragmentation is not possible, true otherwise - */ - bool CheckForFragmentation(Ptr connection, - int availableSymbols, - WimaxPhy::ModulationType modulationType); - - private: - Ptr m_bs; ///< base station - std::list>>* m_downlinkBursts; ///< down link bursts -}; - -} // namespace ns3 - -#endif /* BS_SCHEDULER_H */ diff --git a/src/wimax/model/bs-service-flow-manager.cc b/src/wimax/model/bs-service-flow-manager.cc deleted file mode 100644 index 1bf7e3f4b..000000000 --- a/src/wimax/model/bs-service-flow-manager.cc +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - */ - -#include "bs-net-device.h" -#include "bs-uplink-scheduler.h" -#include "connection-manager.h" -#include "service-flow-manager.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-manager.h" -#include "ss-record.h" -#include "ss-scheduler.h" -#include "wimax-connection.h" - -#include "ns3/buffer.h" -#include "ns3/enum.h" -#include "ns3/log.h" -#include "ns3/node.h" -#include "ns3/packet.h" -#include "ns3/pointer.h" -#include "ns3/simulator.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("BsServiceFlowManager"); - -BsServiceFlowManager::BsServiceFlowManager(Ptr device) - : m_device(device), - m_sfidIndex(100), - m_maxDsaRspRetries(100) // default value -{ - m_inuseScheduleDsaRspCid = Cid::InitialRanging(); -} - -BsServiceFlowManager::~BsServiceFlowManager() -{ -} - -/* static */ -TypeId -BsServiceFlowManager::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::BsServiceFlowManager").SetParent().SetGroupName("Wifi") - // No AddConstructor because this class has no default constructor. - ; - return tid; -} - -void -BsServiceFlowManager::DoDispose() -{ - ServiceFlowManager::DoDispose(); -} - -void -BsServiceFlowManager::SetMaxDsaRspRetries(uint8_t maxDsaRspRetries) -{ - m_maxDsaRspRetries = maxDsaRspRetries; -} - -uint8_t -BsServiceFlowManager::GetMaxDsaRspRetries() const -{ - return m_maxDsaRspRetries; -} - -EventId -BsServiceFlowManager::GetDsaAckTimeoutEvent() const -{ - return m_dsaAckTimeoutEvent; -} - -void -BsServiceFlowManager::AddServiceFlow(ServiceFlow* serviceFlow) -{ - ServiceFlowManager::AddServiceFlow(serviceFlow); -} - -ServiceFlow* -BsServiceFlowManager::GetServiceFlow(uint32_t sfid) const -{ - return ServiceFlowManager::GetServiceFlow(sfid); -} - -ServiceFlow* -BsServiceFlowManager::GetServiceFlow(Cid cid) const -{ - return ServiceFlowManager::GetServiceFlow(cid); -} - -std::vector -BsServiceFlowManager::GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const -{ - return ServiceFlowManager::GetServiceFlows(schedulingType); -} - -DsaRsp -BsServiceFlowManager::CreateDsaRsp(const ServiceFlow* serviceFlow, uint16_t transactionId) -{ - DsaRsp dsaRsp; - dsaRsp.SetTransactionId(transactionId); - dsaRsp.SetServiceFlow(*serviceFlow); - // assuming SS can supports all of the service flow parameters - dsaRsp.SetConfirmationCode(CONFIRMATION_CODE_SUCCESS); - - return dsaRsp; -} - -void -BsServiceFlowManager::ScheduleDsaRsp(ServiceFlow* serviceFlow, Cid cid) -{ - Ptr bs = m_device->GetObject(); - - SSRecord* ssRecord = bs->GetSSManager()->GetSSRecord(cid); - if (ssRecord == nullptr) - { - NS_LOG_INFO("SS not registered with the BS CID:" << cid); - return; - } - - serviceFlow->SetIsEnabled(true); - serviceFlow->SetType(ServiceFlow::SF_TYPE_ACTIVE); - ssRecord->AddServiceFlow(serviceFlow); - - bs->GetUplinkScheduler()->SetupServiceFlow(ssRecord, serviceFlow); - - Ptr p = Create(); - DsaRsp dsaRsp; - - if (ssRecord->GetDsaRspRetries() == 0) - { - dsaRsp = CreateDsaRsp(serviceFlow, ssRecord->GetSfTransactionId()); - p->AddHeader(dsaRsp); - ssRecord->SetDsaRsp(dsaRsp); - } - else - { - if (ssRecord->GetDsaRspRetries() < m_maxDsaRspRetries) - { - p->AddHeader(ssRecord->GetDsaRsp()); - } - else - { - NS_LOG_DEBUG("Service flows could not be initialized!"); - } - } - - ssRecord->IncrementDsaRspRetries(); - p->AddHeader(ManagementMessageType(ManagementMessageType::MESSAGE_TYPE_DSA_RSP)); - - if (m_dsaAckTimeoutEvent.IsPending()) - { - Simulator::Cancel(m_dsaAckTimeoutEvent); - } - - m_inuseScheduleDsaRspCid = cid; - - m_dsaAckTimeoutEvent = Simulator::Schedule(bs->GetIntervalT8(), - &BsServiceFlowManager::ScheduleDsaRsp, - this, - serviceFlow, - cid); - m_device->Enqueue(p, MacHeaderType(), bs->GetConnection(ssRecord->GetPrimaryCid())); -} - -ServiceFlow* -BsServiceFlowManager::ProcessDsaReq(const DsaReq& dsaReq, Cid cid) -{ - ServiceFlow* serviceFlow; - Ptr bs = m_device->GetObject(); - SSRecord* ssRecord = bs->GetSSManager()->GetSSRecord(cid); - - NS_LOG_INFO("BsServiceFlowManager: Processing DSA-REQ..."); - if (ssRecord->GetSfTransactionId() != 0) - { - // had already received DSA-REQ. DSA-RSP was lost - NS_ASSERT_MSG( - dsaReq.GetTransactionId() == ssRecord->GetSfTransactionId(), - "Error while processing DSA request:the received transaction ID is not expected"); - serviceFlow = GetServiceFlow(ssRecord->GetDsaRsp().GetSfid()); - } - else - { - ServiceFlow sf = dsaReq.GetServiceFlow(); - Ptr transportConnection; - Ptr BsConManager = bs->GetConnectionManager(); - transportConnection = BsConManager->CreateConnection(Cid::TRANSPORT); - serviceFlow = new ServiceFlow(m_sfidIndex++, sf.GetDirection(), transportConnection); - transportConnection->SetServiceFlow(serviceFlow); - serviceFlow->CopyParametersFrom(sf); - serviceFlow->SetUnsolicitedGrantInterval(1); - serviceFlow->SetUnsolicitedPollingInterval(1); - serviceFlow->SetConvergenceSublayerParam(sf.GetConvergenceSublayerParam()); - AddServiceFlow(serviceFlow); - ssRecord->SetSfTransactionId(dsaReq.GetTransactionId()); - NS_LOG_INFO("BsServiceFlowManager: Creating a new Service flow: SFID = " - << serviceFlow->GetSfid() << " CID = " << serviceFlow->GetCid()); - } - return serviceFlow; -} - -void -BsServiceFlowManager::AddMulticastServiceFlow(ServiceFlow sf, WimaxPhy::ModulationType modulation) -{ - auto serviceFlow = new ServiceFlow(); - serviceFlow->CopyParametersFrom(sf); - Ptr bs = m_device->GetObject(); - Ptr multicastConnection = - bs->GetConnectionManager()->CreateConnection(Cid::MULTICAST); - serviceFlow->SetConnection(multicastConnection); - AddServiceFlow(serviceFlow); - serviceFlow->SetIsEnabled(true); - serviceFlow->SetType(ServiceFlow::SF_TYPE_ACTIVE); - serviceFlow->SetIsMulticast(true); - serviceFlow->SetModulation(modulation); - bs->GetUplinkScheduler()->SetupServiceFlow(nullptr, serviceFlow); -} - -void -BsServiceFlowManager::AllocateServiceFlows(const DsaReq& dsaReq, Cid cid) -{ - ServiceFlow* serviceFlow = ProcessDsaReq(dsaReq, cid); - if (serviceFlow) - { - ScheduleDsaRsp(serviceFlow, cid); - } - else - { - NS_LOG_INFO("No service Flow. Could not connect."); - } -} - -void -BsServiceFlowManager::ProcessDsaAck(const DsaAck& dsaAck, Cid cid) -{ - Ptr bs = m_device->GetObject(); - SSRecord* ssRecord = bs->GetSSManager()->GetSSRecord(cid); - - if (dsaAck.GetTransactionId() != ssRecord->GetSfTransactionId()) - { - return; - } - - ssRecord->SetDsaRspRetries(0); - ssRecord->SetSfTransactionId(0); - - // check if all service flow have been initiated - if (AreServiceFlowsAllocated(ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_ALL))) - { - ssRecord->SetAreServiceFlowsAllocated(true); - } -} -} // namespace ns3 diff --git a/src/wimax/model/bs-service-flow-manager.h b/src/wimax/model/bs-service-flow-manager.h deleted file mode 100644 index 1c4129f0b..000000000 --- a/src/wimax/model/bs-service-flow-manager.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - */ - -#ifndef BS_SERVICE_FLOW_MANAGER_H -#define BS_SERVICE_FLOW_MANAGER_H - -#include "bs-net-device.h" -#include "mac-messages.h" -#include "service-flow-manager.h" - -#include "ns3/buffer.h" -#include "ns3/event-id.h" - -#include - -namespace ns3 -{ - -class Packet; -class ServiceFlow; -class WimaxNetDevice; -class SSRecord; -class WimaxConnection; -class BaseStationNetDevice; - -/** - * @ingroup wimax - * @brief BsServiceFlowManager - */ -class BsServiceFlowManager : public ServiceFlowManager -{ - public: - /// Confirmation code enumeration - enum ConfirmationCode // as per Table 384 (not all codes implemented) - { - CONFIRMATION_CODE_SUCCESS, - CONFIRMATION_CODE_REJECT - }; - - /** - * Constructor - * - * @param device base station device - */ - BsServiceFlowManager(Ptr device); - ~BsServiceFlowManager() override; - void DoDispose() override; - /** - * Register this type. - * @return The TypeId. - */ - static TypeId GetTypeId(); - - /** - * @brief Add a new service flow - * @param serviceFlow the service flow to add - */ - void AddServiceFlow(ServiceFlow* serviceFlow); - /** - * @param sfid the service flow identifier - * @return the service flow which has as identifier sfid - */ - ServiceFlow* GetServiceFlow(uint32_t sfid) const; - /** - * @param cid the connection identifier - * @return the service flow which has as connection identifier cid - */ - ServiceFlow* GetServiceFlow(Cid cid) const; - /** - * @param schedulingType the scheduling type - * @return the list of service flows configured with schedulingType as a QoS class - */ - std::vector GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const; - /** - * @brief set the maximum Dynamic ServiceFlow Add (DSA) retries - * @param maxDsaRspRetries the maximum DSA response retries - */ - void SetMaxDsaRspRetries(uint8_t maxDsaRspRetries); - - /** - * @return the DSA ack timeout event - */ - EventId GetDsaAckTimeoutEvent() const; - /** - * @brief allocate service flows - * @param dsaReq the DSA request - * @param cid the connection identifier - */ - void AllocateServiceFlows(const DsaReq& dsaReq, Cid cid); - /** - * @brief add a multicast service flow - * @param sf the service flow - * @param modulation the wimax phy modulation type - */ - void AddMulticastServiceFlow(ServiceFlow sf, WimaxPhy::ModulationType modulation); - /** - * @brief process a DSA-ACK message - * @param dsaAck the message to process - * @param cid the identifier of the connection on which the message was received - */ - void ProcessDsaAck(const DsaAck& dsaAck, Cid cid); - - /** - * @brief process a DSA-Req message - * @param dsaReq the message to process - * @param cid the identifier of the connection on which the message was received - * @return a pointer to the service flow - */ - ServiceFlow* ProcessDsaReq(const DsaReq& dsaReq, Cid cid); - - private: - /** - * Create DSA response function - * @param serviceFlow service flow - * @param transactionId transaction ID - * @return the DSA response - */ - DsaRsp CreateDsaRsp(const ServiceFlow* serviceFlow, uint16_t transactionId); - /** - * @return the maximum DSA response retries - */ - uint8_t GetMaxDsaRspRetries() const; - /** - * Create DSA response function - * @param serviceFlow service flow - * @param cid the identifier of the connection on which the message was received - */ - void ScheduleDsaRsp(ServiceFlow* serviceFlow, Cid cid); - Ptr m_device; ///< the device - uint32_t m_sfidIndex; ///< SFID index - uint8_t m_maxDsaRspRetries; ///< maximum number of DSA response retries - EventId m_dsaAckTimeoutEvent; ///< DSA ack timeout event - Cid m_inuseScheduleDsaRspCid; ///< in use schedule DSA response CID -}; - -} // namespace ns3 - -#endif /* BS_SERVICE_FLOW_MANAGER_H */ diff --git a/src/wimax/model/bs-uplink-scheduler-mbqos.cc b/src/wimax/model/bs-uplink-scheduler-mbqos.cc deleted file mode 100644 index 9c5ab0eb7..000000000 --- a/src/wimax/model/bs-uplink-scheduler-mbqos.cc +++ /dev/null @@ -1,1197 +0,0 @@ -/* - * SPDX-License-Identifier: GPL-2.0-only - * - */ - -#include "bs-uplink-scheduler-mbqos.h" - -#include "bandwidth-manager.h" -#include "bs-link-manager.h" -#include "bs-net-device.h" -#include "burst-profile-manager.h" -#include "cid.h" -#include "connection-manager.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-manager.h" - -#include "ns3/log.h" -#include "ns3/simulator.h" -#include "ns3/uinteger.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("UplinkSchedulerMBQoS"); - -NS_OBJECT_ENSURE_REGISTERED(UplinkSchedulerMBQoS); - -UplinkSchedulerMBQoS::UplinkSchedulerMBQoS() -{ -} - -UplinkSchedulerMBQoS::UplinkSchedulerMBQoS(Time time) - : m_windowInterval(time) -{ -} - -UplinkSchedulerMBQoS::~UplinkSchedulerMBQoS() -{ - SetBs(nullptr); - m_uplinkAllocations.clear(); -} - -TypeId -UplinkSchedulerMBQoS::GetTypeId() -{ - static TypeId tid = TypeId("ns3::UplinkSchedulerMBQoS") - - .SetParent() - - .SetGroupName("Wimax") - - .AddAttribute("WindowInterval", - "The time to wait to reset window", - TimeValue(Seconds(1)), - MakeTimeAccessor(&UplinkSchedulerMBQoS::m_windowInterval), - MakeTimeChecker()); - return tid; -} - -void -UplinkSchedulerMBQoS::InitOnce() -{ - UplinkSchedWindowTimer(); -} - -std::list -UplinkSchedulerMBQoS::GetUplinkAllocations() const -{ - return m_uplinkAllocations; -} - -void -UplinkSchedulerMBQoS::GetChannelDescriptorsToUpdate(bool& updateDcd, - bool& updateUcd, - bool& sendDcd, - bool& sendUcd) -{ - /* DCD and UCD shall actually be updated when channel or burst profile definitions - change. burst profiles are updated based on number of SSs, network conditions and etc. - for now temporarily assuming DCD/UCD shall be updated every time */ - - uint32_t randNr = rand(); - if (randNr % 5 == 0 || GetBs()->GetNrDcdSent() == 0) - { - sendDcd = true; - } - - randNr = rand(); - if (randNr % 5 == 0 || GetBs()->GetNrUcdSent() == 0) - { - sendUcd = true; - } - - // ------------------------------------- - // additional, just to send more frequently - if (!sendDcd) - { - randNr = rand(); - if (randNr % 4 == 0) - { - sendDcd = true; - } - } - - if (!sendUcd) - { - randNr = rand(); - if (randNr % 4 == 0) - { - sendUcd = true; - } - } - // ------------------------------------- - - Time timeSinceLastDcd = Simulator::Now() - GetDcdTimeStamp(); - Time timeSinceLastUcd = Simulator::Now() - GetUcdTimeStamp(); - - if (timeSinceLastDcd > GetBs()->GetDcdInterval()) - { - sendDcd = true; - SetDcdTimeStamp(Simulator::Now()); - } - - if (timeSinceLastUcd > GetBs()->GetUcdInterval()) - { - sendUcd = true; - SetUcdTimeStamp(Simulator::Now()); - } -} - -uint32_t -UplinkSchedulerMBQoS::CalculateAllocationStartTime() -{ - return GetBs()->GetNrDlSymbols() * GetBs()->GetPhy()->GetPsPerSymbol() + GetBs()->GetTtg(); -} - -void -UplinkSchedulerMBQoS::AddUplinkAllocation(OfdmUlMapIe& ulMapIe, - const uint32_t& allocationSize, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - ulMapIe.SetDuration(allocationSize); - ulMapIe.SetStartTime(symbolsToAllocation); - m_uplinkAllocations.push_back(ulMapIe); - symbolsToAllocation += allocationSize; - availableSymbols -= allocationSize; -} - -void -UplinkSchedulerMBQoS::UplinkSchedWindowTimer() -{ - NS_LOG(LOG_DEBUG, "Window Reset at " << (Simulator::Now()).As(Time::S)); - - uint32_t min_bw = 0; - - if (!GetBs()->GetSSManager()) - { - Simulator::Schedule(m_windowInterval, &UplinkSchedulerMBQoS::UplinkSchedWindowTimer, this); - return; - } - - std::vector* ssRecords = GetBs()->GetSSManager()->GetSSRecords(); - - // For each SS - for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) - { - SSRecord* ssRecord = *iter; - std::vector serviceFlows = - ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_ALL); - - // For each flow - for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) - { - ServiceFlow* serviceFlow = *iter2; - if ((serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_RTPS) || - (serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_NRTPS)) - { - min_bw = (int)ceil(serviceFlow->GetMinReservedTrafficRate()); - - // This way we can compensate flows which did not get min_bw in the previous window - if ((serviceFlow->GetRecord()->GetBacklogged() > 0) && - (serviceFlow->GetRecord()->GetBwSinceLastExpiry() < min_bw)) - { - serviceFlow->GetRecord()->UpdateBwSinceLastExpiry(-min_bw); - - // if backlogged < granted_bw then we don't need to provide granted_bw + min_bw - // in next window, but backlogged + min_bw - if (serviceFlow->GetRecord()->GetBacklogged() < - (serviceFlow->GetRecord()->GetBwSinceLastExpiry())) - { - serviceFlow->GetRecord()->SetBwSinceLastExpiry( - -serviceFlow->GetRecord()->GetBacklogged()); - } - } - else - { - serviceFlow->GetRecord()->SetBwSinceLastExpiry(0); - } - } - } - } - - // Periodically reset window - Simulator::Schedule(m_windowInterval, &UplinkSchedulerMBQoS::UplinkSchedWindowTimer, this); -} - -void -UplinkSchedulerMBQoS::Schedule() -{ - m_uplinkAllocations.clear(); - SetIsIrIntrvlAllocated(false); - SetIsInvIrIntrvlAllocated(false); - bool allocationForDsa = false; - - uint32_t symbolsToAllocation = 0; - uint32_t allocationSize = 0; // size in symbols - uint32_t availableSymbols = GetBs()->GetNrUlSymbols(); - - AllocateInitialRangingInterval(symbolsToAllocation, availableSymbols); - - std::vector* ssRecords = GetBs()->GetSSManager()->GetSSRecords(); - for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) - { - SSRecord* ssRecord = *iter; - - if (ssRecord->GetIsBroadcastSS()) - { - continue; - } - Cid cid = ssRecord->GetBasicCid(); - OfdmUlMapIe ulMapIe; - ulMapIe.SetCid(cid); - - if (ssRecord->GetPollForRanging() && - ssRecord->GetRangingStatus() == WimaxNetDevice::RANGING_STATUS_CONTINUE) - { - // SS's ranging is not yet complete - // allocating invited initial ranging interval - ulMapIe.SetUiuc(OfdmUlBurstProfile::UIUC_INITIAL_RANGING); - allocationSize = GetBs()->GetRangReqOppSize(); - SetIsInvIrIntrvlAllocated(true); - - if (availableSymbols >= allocationSize) - { - AddUplinkAllocation(ulMapIe, allocationSize, symbolsToAllocation, availableSymbols); - } - else - { - break; - } - } - else - { - WimaxPhy::ModulationType modulationType = ssRecord->GetModulationType(); - - // need to update because modulation/FEC to UIUC mapping may vary over time - ulMapIe.SetUiuc(GetBs()->GetBurstProfileManager()->GetBurstProfile( - modulationType, - WimaxNetDevice::DIRECTION_UPLINK)); - - // establish service flows for SS - if (ssRecord->GetRangingStatus() == WimaxNetDevice::RANGING_STATUS_SUCCESS && - !ssRecord->GetAreServiceFlowsAllocated()) - { - // allocating grant (with arbitrary size) to allow SS to send DSA messages DSA-REQ - // and DSA-ACK only one DSA allocation per frame - if (!allocationForDsa) - { - allocationSize = - GetBs()->GetPhy()->GetNrSymbols(sizeof(DsaReq), modulationType); - - if (availableSymbols >= allocationSize) - { - AddUplinkAllocation(ulMapIe, - allocationSize, - symbolsToAllocation, - availableSymbols); - allocationForDsa = true; - } - else - { - break; - } - } - } - else - { - // all service flows associated to SS are established now - - /* Implementation of uplink scheduler - * [1] Freitag, J.; da Fonseca, N.L.S., "Uplink Scheduling with Quality of Service - * in IEEE 802.16 Networks," Global Telecommunications Conference, 2007. GLOBECOM - * '07. IEEE , vol., no., pp.2503-2508, 26-30 Nov. 2007 URL: - * http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=4411386&isnumber=4410910 */ - - // Step 1 - if (availableSymbols) - { - /*allocating grants for data transmission for UGS flows (Data Grant Burst Type - IEs, 6.3.7.4.3.3) (grant has been referred by different names e.g. transmission - opportunity, slot, uplink allocation, etc)*/ - if (ssRecord->GetHasServiceFlowUgs()) - { - NS_LOG_DEBUG("At " << Simulator::Now().As(Time::S) - << " offering be unicast polling"); - // Recover period interval information for UGS flow - Time frame_duration = GetBs()->GetPhy()->GetFrameDuration(); - Time timestamp = - (*(ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_UGS).begin())) - ->GetRecord() - ->GetLastGrantTime() + - MilliSeconds( - (*(ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_UGS).begin())) - ->GetUnsolicitedGrantInterval()); - - int64_t frame = ((timestamp - Simulator::Now()) / frame_duration).GetHigh(); - - if (frame <= 1) - { - // UGS Grants - // It is not necessary to enqueue UGS grants once it is periodically - // served - ServiceUnsolicitedGrants(ssRecord, - ServiceFlow::SF_TYPE_UGS, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - } - - // enqueue allocate unicast polls for rtPS flows if bandwidth is available - if (ssRecord->GetHasServiceFlowRtps()) - { - NS_LOG_DEBUG("At " << Simulator::Now().As(Time::S) - << " offering rtps unicast polling"); - Ptr jobRTPSPoll = - CreateUlJob(ssRecord, ServiceFlow::SF_TYPE_RTPS, UNICAST_POLLING); - EnqueueJob(UlJob::HIGH, jobRTPSPoll); - } - - if (ssRecord->GetHasServiceFlowNrtps()) - { - NS_LOG_DEBUG("At " << Simulator::Now().As(Time::S) - << " offering nrtps unicast polling"); - // allocate unicast polls for nrtPS flows if bandwidth is available - Ptr jobNRTPSPoll = - CreateUlJob(ssRecord, ServiceFlow::SF_TYPE_NRTPS, UNICAST_POLLING); - EnqueueJob(UlJob::HIGH, jobNRTPSPoll); - } - - if (ssRecord->GetHasServiceFlowBe()) - { - NS_LOG_DEBUG("At " << Simulator::Now().As(Time::S) - << " offering be unicast polling"); - // finally allocate unicast polls for BE flows if bandwidth is available - Ptr jobBEPoll = - CreateUlJob(ssRecord, ServiceFlow::SF_TYPE_BE, UNICAST_POLLING); - EnqueueJob(UlJob::HIGH, jobBEPoll); - } - } - } - } - } - NS_LOG_DEBUG("At " << Simulator::Now().As(Time::S) << " high queue has " - << m_uplinkJobs_high.size() << " jobs - after sched"); - - uint32_t availableSymbolsAux = availableSymbols; - uint32_t symbolsUsed = 0; - - symbolsUsed += CountSymbolsQueue(m_uplinkJobs_high); - availableSymbolsAux -= symbolsUsed; - - // Step 2 - Check Deadline - Migrate requests with deadline expiring - CheckDeadline(availableSymbolsAux); - - // Step 3 - Check Minimum Bandwidth - CheckMinimumBandwidth(availableSymbolsAux); - - // Scheduling high priority queue - NS_LOG_DEBUG("At " << Simulator::Now().As(Time::S) << " high queue has " - << m_uplinkJobs_high.size() << " jobs"); - while ((availableSymbols) && (!m_uplinkJobs_high.empty())) - { - Ptr job = m_uplinkJobs_high.front(); - OfdmUlMapIe ulMapIe; - SSRecord* ssRecord = job->GetSsRecord(); - ServiceFlow::SchedulingType schedulingType = job->GetSchedulingType(); - - Cid cid = ssRecord->GetBasicCid(); - ulMapIe.SetCid(cid); - WimaxPhy::ModulationType modulationType = ssRecord->GetModulationType(); - // need to update because modulation/FEC to UIUC mapping may vary over time - ulMapIe.SetUiuc( - GetBs()->GetBurstProfileManager()->GetBurstProfile(modulationType, - WimaxNetDevice::DIRECTION_UPLINK)); - - ReqType reqType = job->GetType(); - - if (reqType == UNICAST_POLLING) - { - ServiceUnsolicitedGrants(ssRecord, - schedulingType, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - else if (reqType == DATA) - { - ServiceFlow* serviceFlow = job->GetServiceFlow(); - uint32_t allocSizeBytes = job->GetSize(); - ServiceBandwidthRequestsBytes(serviceFlow, - schedulingType, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols, - allocSizeBytes); - } - m_uplinkJobs_high.pop_front(); - } - - NS_LOG_DEBUG("At " << Simulator::Now().As(Time::S) << " interqueue has " - << m_uplinkJobs_inter.size() << " jobs"); - /* Scheduling intermediate priority queue */ - while ((availableSymbols) && (!m_uplinkJobs_inter.empty())) - { - NS_LOG_DEBUG("At " << Simulator::Now().As(Time::S) << " Scheduling interqueue"); - Ptr job = m_uplinkJobs_inter.front(); - OfdmUlMapIe ulMapIe; - SSRecord* ssRecord = job->GetSsRecord(); - ServiceFlow::SchedulingType schedulingType = job->GetSchedulingType(); - - Cid cid = ssRecord->GetBasicCid(); - ulMapIe.SetCid(cid); - WimaxPhy::ModulationType modulationType = ssRecord->GetModulationType(); - // need to update because modulation/FEC to UIUC mapping may vary over time - ulMapIe.SetUiuc( - GetBs()->GetBurstProfileManager()->GetBurstProfile(modulationType, - WimaxNetDevice::DIRECTION_UPLINK)); - - ReqType reqType = job->GetType(); - - if (reqType == DATA) - { - ServiceBandwidthRequests(ssRecord, - schedulingType, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - else - { - NS_FATAL_ERROR("Intermediate priority queue only should enqueue data packets."); - } - m_uplinkJobs_inter.pop_front(); - } - - /* Scheduling low priority queue */ - while ((availableSymbols) && (!m_uplinkJobs_low.empty())) - { - Ptr job = m_uplinkJobs_low.front(); - OfdmUlMapIe ulMapIe; - SSRecord* ssRecord = job->GetSsRecord(); - ServiceFlow::SchedulingType schedulingType = job->GetSchedulingType(); - - Cid cid = ssRecord->GetBasicCid(); - ulMapIe.SetCid(cid); - WimaxPhy::ModulationType modulationType = ssRecord->GetModulationType(); - // need to update because modulation/FEC to UIUC mapping may vary over time - ulMapIe.SetUiuc( - GetBs()->GetBurstProfileManager()->GetBurstProfile(modulationType, - WimaxNetDevice::DIRECTION_UPLINK)); - - ReqType reqType = job->GetType(); - - if (reqType == DATA) - { - ServiceBandwidthRequests(ssRecord, - schedulingType, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - else - { - NS_FATAL_ERROR("Low priority queue only should enqueue data packets."); - } - m_uplinkJobs_low.pop_front(); - } - - OfdmUlMapIe ulMapIeEnd; - ulMapIeEnd.SetCid(Cid(0)); - ulMapIeEnd.SetStartTime(symbolsToAllocation); - ulMapIeEnd.SetUiuc(OfdmUlBurstProfile::UIUC_END_OF_MAP); - ulMapIeEnd.SetDuration(0); - m_uplinkAllocations.push_back(ulMapIeEnd); - - // setting DL/UL subframe allocation for the next frame - GetBs()->GetBandwidthManager()->SetSubframeRatio(); -} - -bool -UplinkSchedulerMBQoS::ServiceBandwidthRequestsBytes(ServiceFlow* serviceFlow, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols, - uint32_t allocationSizeBytes) -{ - uint32_t allocSizeBytes = allocationSizeBytes; - uint32_t allocSizeSymbols = 0; - - ServiceFlowRecord* record = serviceFlow->GetRecord(); - - uint32_t requiredBandwidth = record->GetRequestedBandwidth(); - - if (requiredBandwidth > 0) - { - allocSizeSymbols = GetBs()->GetPhy()->GetNrSymbols(allocSizeBytes, modulationType); - - if (availableSymbols < allocSizeSymbols) - { - allocSizeSymbols = availableSymbols; - } - - if (availableSymbols >= allocSizeSymbols) - { - NS_LOG_DEBUG("At " << Simulator::Now().As(Time::S) << " BS uplink scheduler, " - << serviceFlow->GetSchedulingTypeStr() - << " allocation, size: " << allocSizeSymbols << " symbols" - << ", CID: " << serviceFlow->GetConnection()->GetCid() - << ", SFID: " << serviceFlow->GetSfid() - << ", bw requested: " << record->GetRequestedBandwidth() - << ", bw granted: " << allocSizeBytes << std::endl); - - record->UpdateGrantedBandwidthTemp(allocSizeBytes); - record->UpdateGrantedBandwidth(allocSizeBytes); - record->UpdateRequestedBandwidth(-allocSizeBytes); - - record->UpdateBwSinceLastExpiry(allocSizeBytes); - - AddUplinkAllocation(ulMapIe, allocSizeSymbols, symbolsToAllocation, availableSymbols); - } - else - { - return false; - } - } - return true; -} - -uint32_t -UplinkSchedulerMBQoS::CountSymbolsQueue(std::list> jobs) -{ - uint32_t symbols = 0; - for (auto iter = jobs.begin(); iter != jobs.end(); ++iter) - { - Ptr job = *iter; - - // count symbols - symbols += CountSymbolsJobs(job); - } - return symbols; -} - -Ptr -UplinkSchedulerMBQoS::CreateUlJob(SSRecord* ssRecord, - ServiceFlow::SchedulingType schedType, - ReqType reqType) -{ - Ptr job = CreateObject(); - job->SetSsRecord(ssRecord); - job->SetSchedulingType(schedType); - job->SetServiceFlow(*(ssRecord->GetServiceFlows(schedType).begin())); - job->SetType(reqType); - return job; -} - -uint32_t -UplinkSchedulerMBQoS::CountSymbolsJobs(Ptr job) -{ - SSRecord* ssRecord = job->GetSsRecord(); - ServiceFlow* serviceFlow = job->GetServiceFlow(); - uint32_t allocationSize = 0; - - if (job->GetType() == UNICAST_POLLING) - { - // if polling - Time currentTime = Simulator::Now(); - allocationSize = 0; - if ((currentTime - serviceFlow->GetRecord()->GetGrantTimeStamp()).GetMilliSeconds() >= - serviceFlow->GetUnsolicitedPollingInterval()) - { - allocationSize = GetBs()->GetBwReqOppSize(); - } - } - else - { - // if data - uint16_t sduSize = serviceFlow->GetSduSize(); - ServiceFlowRecord* record = serviceFlow->GetRecord(); - uint32_t requiredBandwidth = - record->GetRequestedBandwidth() - record->GetGrantedBandwidth(); - if (requiredBandwidth > 0) - { - WimaxPhy::ModulationType modulationType = ssRecord->GetModulationType(); - if (sduSize > 0) - { - // if SDU size is mentioned, allocate grant of that size - allocationSize = GetBs()->GetPhy()->GetNrSymbols(sduSize, modulationType); - } - else - { - allocationSize = GetBs()->GetPhy()->GetNrSymbols(requiredBandwidth, modulationType); - } - } - } - return allocationSize; -} - -void -UplinkSchedulerMBQoS::EnqueueJob(UlJob::JobPriority priority, Ptr job) -{ - switch (priority) - { - case UlJob::HIGH: - m_uplinkJobs_high.push_back(job); - break; - case UlJob::INTERMEDIATE: - m_uplinkJobs_inter.push_back(job); - break; - case UlJob::LOW: - m_uplinkJobs_low.push_back(job); - } -} - -Ptr -UplinkSchedulerMBQoS::DequeueJob(UlJob::JobPriority priority) -{ - Ptr job_front; - switch (priority) - { - case UlJob::HIGH: - job_front = m_uplinkJobs_high.front(); - m_uplinkJobs_high.pop_front(); - break; - case UlJob::INTERMEDIATE: - job_front = m_uplinkJobs_inter.front(); - m_uplinkJobs_inter.pop_front(); - break; - case UlJob::LOW: - job_front = m_uplinkJobs_low.front(); - m_uplinkJobs_low.pop_front(); - } - return job_front; -} - -void -UplinkSchedulerMBQoS::CheckDeadline(uint32_t& availableSymbols) -{ - // for each request in the intermediate queue - if (!m_uplinkJobs_inter.empty()) - { - auto iter = m_uplinkJobs_inter.begin(); - - while (iter != m_uplinkJobs_inter.end() && availableSymbols) - { - Ptr job = *iter; - - // guarantee delay bound for rtps connections - if (job->GetSchedulingType() == ServiceFlow::SF_TYPE_RTPS) - { - Time deadline = job->GetDeadline(); - Time frame_duration = GetBs()->GetPhy()->GetFrameDuration(); - - int64_t frame = ((deadline - Simulator::Now()) / frame_duration).GetHigh(); - - NS_LOG_DEBUG("At " << Simulator::Now().As(Time::S) << " reserved traffic rate: " - << job->GetServiceFlow()->GetMinReservedTrafficRate() - << " deadline: " << job->GetDeadline().As(Time::S) - << " frame start: " << GetBs()->m_frameStartTime.As(Time::S) - << " frame duration: " << frame_duration); - - // should be schedule in this frame to max latency - if (frame >= 3) - { - if (availableSymbols) - { - uint32_t availableBytes = - GetBs()->GetPhy()->GetNrBytes(availableSymbols, - job->GetSsRecord()->GetModulationType()); - uint32_t allocationSize = job->GetSize(); - if (allocationSize > availableBytes) - { - allocationSize = availableBytes; - } - - if (allocationSize == 0) - { - continue; - } - - uint32_t symbolsToAllocate = GetBs()->GetPhy()->GetNrSymbols( - allocationSize, - job->GetSsRecord()->GetModulationType()); - if (symbolsToAllocate > availableSymbols) - { - symbolsToAllocate = availableSymbols; - allocationSize = GetBs()->GetPhy()->GetNrBytes( - symbolsToAllocate, - job->GetSsRecord()->GetModulationType()); - } - - job->SetSize(job->GetSize() - allocationSize); - - Ptr newJob = CreateObject(); - // Record data in job - newJob->SetSsRecord(job->GetSsRecord()); - newJob->SetServiceFlow(job->GetServiceFlow()); - newJob->SetSize(allocationSize); - newJob->SetDeadline(job->GetDeadline()); - newJob->SetReleaseTime(job->GetReleaseTime()); - newJob->SetSchedulingType(job->GetSchedulingType()); - newJob->SetPeriod(job->GetPeriod()); - newJob->SetType(job->GetType()); - - EnqueueJob(UlJob::HIGH, newJob); - - // migrate request - iter++; - if ((job->GetSize() - allocationSize) == 0) - { - m_uplinkJobs_inter.remove(job); - } - } - } - else - { - iter++; - } - } - else - { - iter++; - } - } - } -} - -void -UplinkSchedulerMBQoS::CheckMinimumBandwidth(uint32_t& availableSymbols) -{ - std::list> priorityUlJobs; - - // For each connection of type rtPS or nrtPS - std::vector* ssRecords = GetBs()->GetSSManager()->GetSSRecords(); - for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) - { - SSRecord* ssRecord = *iter; - std::vector serviceFlows = - ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_ALL); - for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) - { - ServiceFlow* serviceFlow = *iter2; - if (serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_RTPS || - serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_NRTPS) - { - serviceFlow->GetRecord()->SetBackloggedTemp( - serviceFlow->GetRecord()->GetBacklogged()); - serviceFlow->GetRecord()->SetGrantedBandwidthTemp( - serviceFlow->GetRecord()->GetBwSinceLastExpiry()); - } - } - } - - // for each request in the imermediate queue - for (auto iter = m_uplinkJobs_inter.begin(); iter != m_uplinkJobs_inter.end(); ++iter) - { - Ptr job = *iter; - // SSRecord ssRecord = job->GetSsRecord(); - ServiceFlow* serviceFlow = job->GetServiceFlow(); - if ((job->GetSchedulingType() == ServiceFlow::SF_TYPE_RTPS || - job->GetSchedulingType() == ServiceFlow::SF_TYPE_NRTPS) && - (serviceFlow->GetRecord()->GetBacklogged() > 0)) - { - uint32_t minReservedTrafficRate = serviceFlow->GetMinReservedTrafficRate(); - uint32_t grantedBandwidth = serviceFlow->GetRecord()->GetBwSinceLastExpiry(); - - Ptr priorityUlJob = CreateObject(); - priorityUlJob->SetUlJob(job); - // pri_array - if (minReservedTrafficRate <= grantedBandwidth) - { - priorityUlJob->SetPriority(-10000); - } - else - { - uint32_t allocationSize = serviceFlow->GetRecord()->GetRequestedBandwidth() - - serviceFlow->GetRecord()->GetGrantedBandwidth(); - uint32_t sduSize = serviceFlow->GetSduSize(); - - if (allocationSize > 0) - { - if (sduSize > 0) - { - // if SDU size is mentioned, grant of that size - allocationSize = sduSize; - } - } - int priority = - serviceFlow->GetRecord()->GetBackloggedTemp() - - (serviceFlow->GetRecord()->GetGrantedBandwidthTemp() - minReservedTrafficRate); - priorityUlJob->SetPriority(priority); - serviceFlow->GetRecord()->SetGrantedBandwidthTemp( - serviceFlow->GetRecord()->GetGrantedBandwidthTemp() + allocationSize); - serviceFlow->GetRecord()->SetBackloggedTemp( - serviceFlow->GetRecord()->GetBackloggedTemp() - allocationSize); - } - - priorityUlJobs.push_back(priorityUlJob); - } - } - - priorityUlJobs.sort(SortProcessPtr()); - - for (auto iter = priorityUlJobs.begin(); iter != priorityUlJobs.end(); ++iter) - { - Ptr priorityUlJob = *iter; - Ptr job_priority = priorityUlJob->GetUlJob(); - Ptr job = job_priority; - if (availableSymbols) - { - availableSymbols -= CountSymbolsJobs(job); - // migrate request - m_uplinkJobs_inter.remove(job); - EnqueueJob(UlJob::HIGH, job); - } - } -} - -void -UplinkSchedulerMBQoS::ServiceUnsolicitedGrants(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - uint32_t allocationSize = 0; // size in symbols - uint8_t uiuc = ulMapIe.GetUiuc(); // SS's burst profile - std::vector serviceFlows = ssRecord->GetServiceFlows(schedulingType); - - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - ServiceFlow* serviceFlow = *iter; - - /* in case of rtPS, nrtPS and BE, allocating unicast polls for bandwidth requests (Request - IEs, 6.3.7.4.3.1). in case of UGS, allocating grants for data transmission (Data Grant - Burst Type IEs, 6.3.7.4.3.3) (grant has been referred in this code by different names e.g. - transmission opportunity, slot, allocation, etc) */ - - allocationSize = - GetBs()->GetBandwidthManager()->CalculateAllocationSize(ssRecord, serviceFlow); - - if (availableSymbols < allocationSize) - { - break; - } - - if (allocationSize > 0) - { - ulMapIe.SetStartTime(symbolsToAllocation); - if (serviceFlow->GetSchedulingType() != ServiceFlow::SF_TYPE_UGS) - { - // special burst profile with most robust modulation type is used for unicast polls - // (Request IEs) - ulMapIe.SetUiuc(OfdmUlBurstProfile::UIUC_REQ_REGION_FULL); - } - } - else - { - continue; - } - - if (serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_UGS) - { - NS_LOG_DEBUG("BS uplink scheduler, UGS allocation, size: " << allocationSize - << " symbols"); - } - else - { - NS_LOG_DEBUG("BS uplink scheduler, " << serviceFlow->GetSchedulingTypeStr() - << " unicast poll, size: " << allocationSize - << " symbols, modulation: BPSK 1/2"); - } - - NS_LOG_DEBUG(", CID: " << serviceFlow->GetConnection()->GetCid() - << ", SFID: " << serviceFlow->GetSfid()); - - serviceFlow->GetRecord()->SetLastGrantTime(Simulator::Now()); - AddUplinkAllocation(ulMapIe, allocationSize, symbolsToAllocation, availableSymbols); - ulMapIe.SetUiuc(uiuc); - } -} - -void -UplinkSchedulerMBQoS::ServiceBandwidthRequests(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - std::vector serviceFlows = ssRecord->GetServiceFlows(schedulingType); - - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - if (!ServiceBandwidthRequests(*iter, - schedulingType, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols)) - { - break; - } - } -} - -bool -UplinkSchedulerMBQoS::ServiceBandwidthRequests(ServiceFlow* serviceFlow, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - uint32_t allocSizeBytes = 0; - uint32_t allocSizeSymbols = 0; - uint16_t sduSize = 0; - - ServiceFlowRecord* record = serviceFlow->GetRecord(); - sduSize = serviceFlow->GetSduSize(); - - uint32_t requiredBandwidth = record->GetRequestedBandwidth() - record->GetGrantedBandwidth(); - if (requiredBandwidth > 0) - { - if (sduSize > 0) - { - // if SDU size is mentioned, allocate grant of that size - allocSizeBytes = sduSize; - allocSizeSymbols = GetBs()->GetPhy()->GetNrSymbols(sduSize, modulationType); - } - else - { - allocSizeBytes = requiredBandwidth; - allocSizeSymbols = GetBs()->GetPhy()->GetNrSymbols(requiredBandwidth, modulationType); - } - - if (availableSymbols >= allocSizeSymbols) - { - NS_LOG_DEBUG("BS uplink scheduler, " - << serviceFlow->GetSchedulingTypeStr() - << " allocation, size: " << allocSizeSymbols << " symbols" - << ", CID: " << serviceFlow->GetConnection()->GetCid() - << ", SFID: " << serviceFlow->GetSfid() - << ", bw requested: " << record->GetRequestedBandwidth() - << ", bw granted: " << record->GetGrantedBandwidth()); - - record->UpdateGrantedBandwidth(allocSizeBytes); - - record->SetBwSinceLastExpiry(allocSizeBytes); - - if (serviceFlow->GetRecord()->GetBacklogged() < allocSizeBytes) - { - serviceFlow->GetRecord()->SetBacklogged(0); - } - else - { - serviceFlow->GetRecord()->IncreaseBacklogged(-allocSizeBytes); - } - serviceFlow->GetRecord()->SetLastGrantTime(Simulator::Now()); - - AddUplinkAllocation(ulMapIe, allocSizeSymbols, symbolsToAllocation, availableSymbols); - } - else - { - return false; - } - } - return true; -} - -void -UplinkSchedulerMBQoS::AllocateInitialRangingInterval(uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - Time ssUlStartTime = - Seconds(CalculateAllocationStartTime() * GetBs()->GetPsDuration().GetSeconds()); - SetNrIrOppsAllocated(GetBs()->GetLinkManager()->CalculateRangingOppsToAllocate()); - uint32_t allocationSize = GetNrIrOppsAllocated() * GetBs()->GetRangReqOppSize(); - Time timeSinceLastIrInterval = Simulator::Now() - GetTimeStampIrInterval(); - - // adding one frame because may be the time has not elapsed now but will elapse before the next - // frame is sent - if (timeSinceLastIrInterval + GetBs()->GetPhy()->GetFrameDuration() > - GetBs()->GetInitialRangingInterval() && - availableSymbols >= allocationSize) - { - SetIsIrIntrvlAllocated(true); - OfdmUlMapIe ulMapIeIr; - ulMapIeIr.SetCid((GetBs()->GetBroadcastConnection())->GetCid()); - ulMapIeIr.SetStartTime(symbolsToAllocation); - ulMapIeIr.SetUiuc(OfdmUlBurstProfile::UIUC_INITIAL_RANGING); - - NS_LOG_DEBUG("BS uplink scheduler, initial ranging allocation, size: " - << allocationSize << " symbols, modulation: BPSK 1/2"); - - // marking start and end of each TO, only for debugging - for (uint8_t i = 0; i < GetNrIrOppsAllocated(); i++) - { - GetBs()->MarkRangingOppStart( - ssUlStartTime + - Seconds(symbolsToAllocation * GetBs()->GetSymbolDuration().GetSeconds()) + - Seconds(i * GetBs()->GetRangReqOppSize() * - GetBs()->GetSymbolDuration().GetSeconds())); - } - - AddUplinkAllocation(ulMapIeIr, allocationSize, symbolsToAllocation, availableSymbols); - SetTimeStampIrInterval(Simulator::Now()); - } -} - -void -UplinkSchedulerMBQoS::SetupServiceFlow(SSRecord* ssRecord, ServiceFlow* serviceFlow) -{ - uint8_t delayNrFrames = 1; - uint32_t bitsPerSecond = serviceFlow->GetMinReservedTrafficRate(); - WimaxPhy::ModulationType modulation; - uint32_t bytesPerFrame = - (uint32_t((double)(bitsPerSecond)*GetBs()->GetPhy()->GetFrameDuration().GetSeconds())) / 8; - uint32_t frameDurationMSec = GetBs()->GetPhy()->GetFrameDuration().GetMilliSeconds(); - - switch (serviceFlow->GetSchedulingType()) - { - case ServiceFlow::SF_TYPE_UGS: { - if (serviceFlow->GetIsMulticast()) - { - modulation = serviceFlow->GetModulation(); - } - else - { - modulation = ssRecord->GetModulationType(); - } - uint32_t grantSize = GetBs()->GetPhy()->GetNrSymbols(bytesPerFrame, modulation); - serviceFlow->GetRecord()->SetGrantSize(grantSize); - - uint32_t toleratedJitter = serviceFlow->GetToleratedJitter(); - - if (toleratedJitter > frameDurationMSec) - { - delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec); - } - - uint16_t interval = delayNrFrames * frameDurationMSec; - serviceFlow->SetUnsolicitedGrantInterval(interval); - } - break; - case ServiceFlow::SF_TYPE_RTPS: { - serviceFlow->SetUnsolicitedPollingInterval(20); - } - break; - case ServiceFlow::SF_TYPE_NRTPS: { - // no real-time guarantees are given to NRTPS, serviced based on available bandwidth - uint16_t interval = 1000; - serviceFlow->SetUnsolicitedPollingInterval(interval); - } - break; - case ServiceFlow::SF_TYPE_BE: { - // no real-time guarantees are given to BE, serviced based on available bandwidth - } - break; - default: - NS_FATAL_ERROR("Invalid scheduling type"); - } -} - -uint32_t -UplinkSchedulerMBQoS::GetPendingSize(ServiceFlow* serviceFlow) -{ - uint32_t size = 0; - std::list> priorityUlJobs; - - // for each request in the imermediate queue - for (auto iter = m_uplinkJobs_inter.begin(); iter != m_uplinkJobs_inter.end(); ++iter) - { - Ptr job = *iter; - - ServiceFlow* serviceFlowJob = job->GetServiceFlow(); - - if (serviceFlowJob == serviceFlow) - { - size += job->GetSize(); - } - } - return size; -} - -void -UplinkSchedulerMBQoS::ProcessBandwidthRequest(const BandwidthRequestHeader& bwRequestHdr) -{ - // Enqueue requests for uplink scheduler. - Ptr job = CreateObject(); - Ptr connection = - GetBs()->GetConnectionManager()->GetConnection(bwRequestHdr.GetCid()); - SSRecord* ssRecord = GetBs()->GetSSManager()->GetSSRecord(connection->GetCid()); - ServiceFlow* serviceFlow = connection->GetServiceFlow(); - - uint32_t size = bwRequestHdr.GetBr(); - uint32_t pendingSize = GetPendingSize(serviceFlow); - - if (size > pendingSize) - { - size -= pendingSize; - } - else - { - size = 0; - } - - if (size == 0) - { - return; - } - - Time deadline = DetermineDeadline(serviceFlow); - Time currentTime = Simulator::Now(); - const Time& period = deadline; // So that deadline is properly updated.. - - NS_LOG_DEBUG("At " << Simulator::Now().As(Time::S) - << " at BS uplink scheduler, processing bandwidth request from." - << ssRecord->GetMacAddress() << " and sf " - << serviceFlow->GetSchedulingType() << " with deadline in " - << deadline.As(Time::S) << " and size " << size << " aggreg size " - << bwRequestHdr.GetBr()); - - // Record data in job - job->SetSsRecord(ssRecord); - job->SetServiceFlow(serviceFlow); - job->SetSize(size); - job->SetDeadline(deadline); - job->SetReleaseTime(currentTime); - job->SetSchedulingType(serviceFlow->GetSchedulingType()); - job->SetPeriod(period); - job->SetType(DATA); - - // Enqueue job in Uplink Scheduler - switch (serviceFlow->GetSchedulingType()) - { - case ServiceFlow::SF_TYPE_RTPS: - case ServiceFlow::SF_TYPE_NRTPS: - EnqueueJob(UlJob::INTERMEDIATE, job); - break; - case ServiceFlow::SF_TYPE_BE: - default: - EnqueueJob(UlJob::LOW, job); - break; - } -} - -/* - * Calculate Deadline of requests according to QoS parameter - * */ -Time -UplinkSchedulerMBQoS::DetermineDeadline(ServiceFlow* serviceFlow) -{ - uint32_t latency = serviceFlow->GetMaximumLatency(); - Time lastGrantTime = serviceFlow->GetRecord()->GetLastGrantTime(); - Time deadline = MilliSeconds(latency) + lastGrantTime; - return deadline; -} - -void -UplinkSchedulerMBQoS::OnSetRequestedBandwidth(ServiceFlowRecord* sfr) -{ - // virtual function on UplinkScheduler - // this is not necessary on this implementation -} - -} // namespace ns3 diff --git a/src/wimax/model/bs-uplink-scheduler-mbqos.h b/src/wimax/model/bs-uplink-scheduler-mbqos.h deleted file mode 100644 index aa23c713f..000000000 --- a/src/wimax/model/bs-uplink-scheduler-mbqos.h +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright (c) 2009 INRIA/LRC - Computer Networks Laboratory - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Flavio Kobuta - * - */ - -#ifndef UPLINK_SCHEDULER_MBQOS_H -#define UPLINK_SCHEDULER_MBQOS_H - -#include "bs-uplink-scheduler.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ul-job.h" -#include "ul-mac-messages.h" -#include "wimax-phy.h" - -#include "ns3/nstime.h" -#include "ns3/object.h" - -#include - -namespace ns3 -{ - -class BaseStationNetDevice; -class SSRecord; -class ServiceFlow; -class ServiceFlowRecord; -class UlJob; - -/** - * @ingroup wimax - * @brief This class implements a Migration-based Quality of Service uplink scheduler(MBQoS). - * - * This uplink scheduler uses three queues, the low priority - * queue, the intermediate queue and the high priority queue. - * The scheduler serves the requests in strict priority order - * from the high priority queue to the low priority queue. The - * low priority queue stores the bandwidth requests of the BE - * service flow. The intermediate queue holds bandwidth requests - * sent by rtPS and by nrtPS connections. rtPS and nrtPS requests - * can migrate to the high priority queue to guarantee that - * their QoS requirements are met. Besides the requests migrated - * from the intermediate queue, the high priority queue stores - * periodic grants and unicast request opportunities that must be - * scheduled in the following frame. To guarantee the maximum delay - * requirement, the BS assigns a deadline to each rtPS bandwidth - * request in the intermediate queue. The minimum bandwidth - * requirement of both rtPS and nrtPS connections is guaranteed - * over a window of duration T . - * Implementation of uplink scheduler: - * Freitag, J.; da Fonseca, N.L.S., "Uplink Scheduling with Quality of Service in IEEE 802.16 - * Networks," Global Telecommunications Conference, 2007. GLOBECOM '07. IEEE , vol., no., - * pp.2503-2508, 26-30 Nov. 2007 URL: - * http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=4411386&isnumber=4410910 - */ -class UplinkSchedulerMBQoS : public UplinkScheduler -{ - public: - UplinkSchedulerMBQoS(); - /** - * Constructor - * - * @param time the time - */ - UplinkSchedulerMBQoS(Time time); - ~UplinkSchedulerMBQoS() override; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - - /** - * Get uplink allocations - * @returns std::list - */ - std::list GetUplinkAllocations() const override; - - /** - * Determines if channel descriptors sent in the current frame are - * required to be updated - * @param updateDcd update DCD if true - * @param updateUcd update UCD if true - * @param sendDcd send DCD if true - * @param sendUcd send UCD if true - */ - void GetChannelDescriptorsToUpdate(bool& updateDcd, - bool& updateUcd, - bool& sendDcd, - bool& sendUcd) override; - /** - * Calculate allocation start time - * @returns the allocation start time - */ - uint32_t CalculateAllocationStartTime() override; - /** - * Add uplink allocation - * @param ulMapIe the UL map IE - * @param allocationSize the allocation size - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - void AddUplinkAllocation(OfdmUlMapIe& ulMapIe, - const uint32_t& allocationSize, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - - /** - * Schedule function - */ - void Schedule() override; - /** - * Service unsolicited grants - * @param ssRecord the SS record - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - void ServiceUnsolicitedGrants(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * Service bandwidth requests - * @param ssRecord the SS record - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - void ServiceBandwidthRequests(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * Service bandwidth requests - * @param serviceFlow the service flow - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - * @returns true if successful - */ - bool ServiceBandwidthRequests(ServiceFlow* serviceFlow, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * Allocate initial ranging interval - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - void AllocateInitialRangingInterval(uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * Setup service flow - * @param ssRecord the SS record - * @param serviceFlow the service flow - */ - void SetupServiceFlow(SSRecord* ssRecord, ServiceFlow* serviceFlow) override; - - /** - * @param availableSymbols available symbols in the uplink frame - * @brief Check deadline from jobs. Migrate requests if necessary. - * - * This method verifies for each rtPS request whether it should be - * migrated to the high priority queue or not. The conditions for - * migration are: request deadline expires in the frame following - * the next one, and the amount of bandwidth requested is less than - * or equal to the amount of available bytes in the next uplink frame. - */ - void CheckDeadline(uint32_t& availableSymbols); - - /** - * @param availableSymbols available symbols in the uplink frame. - * @brief Check if Minimum bandwidth is guarantee. Migrate requests if necessary. - * - * This method first calculate a priority value for each request - * in the intermediate queue. Then, sorts the intermediate queue - * according to the priority values. Finally, while there is available - * bandwidth, the scheduler migrate the requests to the high priority queue. - */ - void CheckMinimumBandwidth(uint32_t& availableSymbols); - - /** - * @brief Reset the current window. - * According to a configured time, reset the window. - */ - void UplinkSchedWindowTimer(); - - /** - * @param priority Priority of queue - * @param job job information - * - * @brief Enqueue a job in a priority queue. - */ - void EnqueueJob(UlJob::JobPriority priority, Ptr job); - - /** - * @param priority Priority of queue - * @return Ptr - * - * @brief Dequeue a job from a priority queue. - */ - Ptr DequeueJob(UlJob::JobPriority priority); - - void ProcessBandwidthRequest(const BandwidthRequestHeader& bwRequestHdr) override; - - /** - * @param serviceFlow Service flow of connection - * @return Time - * - * @brief Calculates deadline of a request. - */ - Time DetermineDeadline(ServiceFlow* serviceFlow); - - /** - * This method is called once to initialize window. - */ - void InitOnce() override; - - /** - * @param jobs List of jobs - * @returns the symbols count - * - * Sum the amount of symbols of each job of a queue - */ - uint32_t CountSymbolsQueue(std::list> jobs); - - /** - * @param job job - * @returns the symbols count - * - * Count the amount of symbols of a job. - */ - uint32_t CountSymbolsJobs(Ptr job); - - /** - * Set requested bandwidth - * @param sfr the service flow record - */ - void OnSetRequestedBandwidth(ServiceFlowRecord* sfr) override; - - /** - * @param ssRecord Subscriber station record - * @param schedType Service flow type - * @param reqType Type of packet - * @return Ptr - * - * Create and fill information of a job. - */ - Ptr CreateUlJob(SSRecord* ssRecord, - ServiceFlow::SchedulingType schedType, - ReqType reqType); - - /** - * @param serviceFlow ServiceFlow - * @return Ptr - * - * Get pending size. - */ - uint32_t GetPendingSize(ServiceFlow* serviceFlow); - - /** - * Service bandwidth requests bytes. - * @param serviceFlow the service flow - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - * @param allocationSizeBytes the allocation size in bytes - * @returns true if successful - */ - bool ServiceBandwidthRequestsBytes(ServiceFlow* serviceFlow, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols, - uint32_t allocationSizeBytes); - - private: - std::list m_uplinkAllocations; ///< uplink allocations - - // queues for scheduler - std::list> m_uplinkJobs_high; ///< uplink jobs high priority - std::list> m_uplinkJobs_inter; ///< uplink jobs intermedite priority - std::list> m_uplinkJobs_low; ///< uplink jobs low priority - - // interval to reset window - Time m_windowInterval; ///< windows interval -}; - -} // namespace ns3 - -#endif /* UPLINK_SCHEDULER_MBQOS_H */ diff --git a/src/wimax/model/bs-uplink-scheduler-rtps.cc b/src/wimax/model/bs-uplink-scheduler-rtps.cc deleted file mode 100644 index cfc5e853c..000000000 --- a/src/wimax/model/bs-uplink-scheduler-rtps.cc +++ /dev/null @@ -1,738 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * 2009 TELEMATICS LAB, Politecnico di Bari - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Giuseppe Piro - */ - -#include "bs-uplink-scheduler-rtps.h" - -#include "bandwidth-manager.h" -#include "bs-link-manager.h" -#include "bs-net-device.h" -#include "burst-profile-manager.h" -#include "cid.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-manager.h" -#include "ss-record.h" - -#include "ns3/log.h" -#include "ns3/simulator.h" -#include "ns3/uinteger.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("UplinkSchedulerRtps"); - -NS_OBJECT_ENSURE_REGISTERED(UplinkSchedulerRtps); - -UplinkSchedulerRtps::UplinkSchedulerRtps() -{ - SetBs(nullptr); - SetTimeStampIrInterval(Seconds(0)); - SetNrIrOppsAllocated(0); - SetIsIrIntrvlAllocated(false); - SetIsInvIrIntrvlAllocated(false); - SetDcdTimeStamp(Simulator::Now()); - SetUcdTimeStamp(Simulator::Now()); -} - -UplinkSchedulerRtps::UplinkSchedulerRtps(Ptr bs) -{ - SetBs(bs); - SetTimeStampIrInterval(Seconds(0)); - SetNrIrOppsAllocated(0); - SetIsIrIntrvlAllocated(false); - SetIsInvIrIntrvlAllocated(false); - SetDcdTimeStamp(Simulator::Now()); - SetUcdTimeStamp(Simulator::Now()); -} - -UplinkSchedulerRtps::~UplinkSchedulerRtps() -{ - SetBs(nullptr); - m_uplinkAllocations.clear(); -} - -TypeId -UplinkSchedulerRtps::GetTypeId() -{ - static TypeId tid = TypeId("ns3::UplinkSchedulerRtps") - .SetParent() - .SetGroupName("Wimax") - .AddConstructor(); - return tid; -} - -std::list -UplinkSchedulerRtps::GetUplinkAllocations() const -{ - return m_uplinkAllocations; -} - -void -UplinkSchedulerRtps::GetChannelDescriptorsToUpdate(bool& updateDcd, - bool& updateUcd, - bool& sendDcd, - bool& sendUcd) -{ - /*DCD and UCD shall actually be updated when channel or burst profile definitions - change. burst profiles are updated based on number of SSs, network conditions and etc. - for now temporarily assuming DCD/UCD shall be updated every time */ - - uint32_t randNr = rand(); - if (randNr % 5 == 0 || GetBs()->GetNrDcdSent() == 0) - { - sendDcd = true; - } - - randNr = rand(); - if (randNr % 5 == 0 || GetBs()->GetNrUcdSent() == 0) - { - sendUcd = true; - } - - // ------------------------------------- - // additional, just to send more frequently - if (!sendDcd) - { - randNr = rand(); - if (randNr % 4 == 0) - { - sendDcd = true; - } - } - - if (!sendUcd) - { - randNr = rand(); - if (randNr % 4 == 0) - { - sendUcd = true; - } - } - // ------------------------------------- - - Time timeSinceLastDcd = Simulator::Now() - GetDcdTimeStamp(); - Time timeSinceLastUcd = Simulator::Now() - GetUcdTimeStamp(); - - if (timeSinceLastDcd > GetBs()->GetDcdInterval()) - { - sendDcd = true; - SetDcdTimeStamp(Simulator::Now()); - } - - if (timeSinceLastUcd > GetBs()->GetUcdInterval()) - { - sendUcd = true; - SetUcdTimeStamp(Simulator::Now()); - } -} - -uint32_t -UplinkSchedulerRtps::CalculateAllocationStartTime() -{ - return GetBs()->GetNrDlSymbols() * GetBs()->GetPhy()->GetPsPerSymbol() + GetBs()->GetTtg(); -} - -void -UplinkSchedulerRtps::AddUplinkAllocation(OfdmUlMapIe& ulMapIe, - const uint32_t& allocationSize, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - ulMapIe.SetDuration(allocationSize); - ulMapIe.SetStartTime(symbolsToAllocation); - m_uplinkAllocations.push_back(ulMapIe); - symbolsToAllocation += allocationSize; - availableSymbols -= allocationSize; -} - -void -UplinkSchedulerRtps::Schedule() -{ - m_uplinkAllocations.clear(); - SetIsIrIntrvlAllocated(false); - SetIsInvIrIntrvlAllocated(false); - bool allocationForDsa = false; - - uint32_t symbolsToAllocation = 0; - uint32_t allocationSize = 0; // size in symbols - uint32_t availableSymbols = GetBs()->GetNrUlSymbols(); - - WimaxPhy::ModulationType modulationType; - Cid cid; - - AllocateInitialRangingInterval(symbolsToAllocation, availableSymbols); - - std::vector* ssRecords = GetBs()->GetSSManager()->GetSSRecords(); - NS_LOG_INFO("UL Scheduler start, availableSymbols = " << availableSymbols); - - for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) - { - SSRecord* ssRecord = *iter; - if (ssRecord->GetIsBroadcastSS()) - { - continue; - } - cid = ssRecord->GetBasicCid(); - OfdmUlMapIe ulMapIe; - ulMapIe.SetCid(cid); - - if (ssRecord->GetPollForRanging() && - ssRecord->GetRangingStatus() == WimaxNetDevice::RANGING_STATUS_CONTINUE) - { - // SS's ranging is not yet complete - // allocating invited initial ranging interval - ulMapIe.SetUiuc(OfdmUlBurstProfile::UIUC_INITIAL_RANGING); - allocationSize = GetBs()->GetRangReqOppSize(); - SetIsInvIrIntrvlAllocated(true); - - if (availableSymbols >= allocationSize) - { - AddUplinkAllocation(ulMapIe, allocationSize, symbolsToAllocation, availableSymbols); - } - else - { - break; - } - } - else - { - modulationType = ssRecord->GetModulationType(); - - // need to update because modulation/FEC to UIUC mapping may vary over time - ulMapIe.SetUiuc(GetBs()->GetBurstProfileManager()->GetBurstProfile( - modulationType, - WimaxNetDevice::DIRECTION_UPLINK)); - - // establish service flows for SS - if (ssRecord->GetRangingStatus() == WimaxNetDevice::RANGING_STATUS_SUCCESS && - !ssRecord->GetAreServiceFlowsAllocated()) - { - // allocating grant (with arbitrary size) to allow SS to send DSA messages DSA-REQ - // and DSA-ACK only one DSA allocation per frame - if (!allocationForDsa) - { - allocationSize = - GetBs()->GetPhy()->GetNrSymbols(sizeof(DsaReq), modulationType); - if (availableSymbols >= allocationSize) - { - AddUplinkAllocation(ulMapIe, - allocationSize, - symbolsToAllocation, - availableSymbols); - allocationForDsa = true; - } - else - { - break; - } - } - } - else - { - // all service flows associated to SS are established now - - /*allocating grants for data transmission for UGS flows (Data Grant Burst Type - IEs, 6.3.7.4.3.3) (grant has been referred by different names e.g. transmission - opportunity, slot, uplink allocation, etc)*/ - ServiceUnsolicitedGrants(ssRecord, - ServiceFlow::SF_TYPE_UGS, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - - // allocate unicast polls for rtPS flows if bandwidth is available - if (availableSymbols) - { - ServiceUnsolicitedGrants(ssRecord, - ServiceFlow::SF_TYPE_RTPS, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - // allocate unicast polls for nrtPS flows if bandwidth is available - if (availableSymbols) - { - ServiceUnsolicitedGrants(ssRecord, - ServiceFlow::SF_TYPE_NRTPS, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - // finally allocate unicast polls for BE flows if bandwidth is available - if (availableSymbols) - { - ServiceUnsolicitedGrants(ssRecord, - ServiceFlow::SF_TYPE_BE, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - } - } - } - - /* - * Uplink Scheduler for rtPS Connection - */ - if (availableSymbols) - { - ULSchedulerRTPSConnection(symbolsToAllocation, availableSymbols); - } - - // UL Scheduler for nrtPS and BE flows - if (availableSymbols) - { - for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) - { - SSRecord* ssRecord = *iter; - if (ssRecord->GetIsBroadcastSS()) - { - continue; - } - if (!ssRecord->GetPollForRanging() && - ssRecord->GetRangingStatus() != WimaxNetDevice::RANGING_STATUS_CONTINUE && - ssRecord->GetAreServiceFlowsAllocated()) - { - OfdmUlMapIe ulMapIe; - cid = ssRecord->GetBasicCid(); - ulMapIe.SetCid(cid); - modulationType = ssRecord->GetModulationType(); - ulMapIe.SetUiuc(GetBs()->GetBurstProfileManager()->GetBurstProfile( - modulationType, - WimaxNetDevice::DIRECTION_UPLINK)); - - // allocate unicast polls for nrtPS flows if bandwidth is available - - ServiceBandwidthRequests(ssRecord, - ServiceFlow::SF_TYPE_NRTPS, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - - // finally allocate unicast polls for BE flows if bandwidth is available - if (availableSymbols) - { - ServiceBandwidthRequests(ssRecord, - ServiceFlow::SF_TYPE_BE, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - } - } - } - - OfdmUlMapIe ulMapIeEnd; - ulMapIeEnd.SetCid(Cid::InitialRanging()); - ulMapIeEnd.SetStartTime(symbolsToAllocation); - ulMapIeEnd.SetUiuc(OfdmUlBurstProfile::UIUC_END_OF_MAP); - ulMapIeEnd.SetDuration(0); - m_uplinkAllocations.push_back(ulMapIeEnd); - - // setting DL/UL subframe allocation for the next frame - GetBs()->GetBandwidthManager()->SetSubframeRatio(); -} - -void -UplinkSchedulerRtps::ServiceUnsolicitedGrants(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - uint32_t allocationSize = 0; // size in symbols - uint8_t uiuc = ulMapIe.GetUiuc(); // SS's burst profile - std::vector serviceFlows = ssRecord->GetServiceFlows(schedulingType); - - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - ServiceFlow* serviceFlow = *iter; - - /* in case of rtPS, nrtPS and BE, allocating unicast polls for bandwidth requests (Request - IEs, 6.3.7.4.3.1). in case of UGS, allocating grants for data transmission (Data Grant - Burst Type IEs, 6.3.7.4.3.3) (grant has been referred in this code by different names e.g. - transmission opportunity, slot, allocation, etc) */ - - allocationSize = - GetBs()->GetBandwidthManager()->CalculateAllocationSize(ssRecord, serviceFlow); - - // verifying that minimum reserved traffic rate of nrtPS flow is maintained - if (serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_NRTPS) - { - Time currentTime = Simulator::Now(); - ServiceFlowRecord* record = serviceFlow->GetRecord(); - if (currentTime - record->GetGrantTimeStamp() > Seconds(1)) - { - uint32_t bps = (record->GetBwSinceLastExpiry() * 8); - if (bps < serviceFlow->GetMinReservedTrafficRate()) - { - ServiceBandwidthRequests(serviceFlow, - schedulingType, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - record->SetBwSinceLastExpiry(0); - record->SetGrantTimeStamp(currentTime); - } - } - } - - if (availableSymbols < allocationSize) - { - break; - } - - if (allocationSize > 0) - { - ulMapIe.SetStartTime(symbolsToAllocation); - if (serviceFlow->GetSchedulingType() != ServiceFlow::SF_TYPE_UGS) - { - // special burst profile with most robust modulation type is used for unicast polls - // (Request IEs) - ulMapIe.SetUiuc(OfdmUlBurstProfile::UIUC_REQ_REGION_FULL); - } - } - else - { - continue; - } - - if (serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_UGS) - { - NS_LOG_DEBUG("BS uplink scheduler, UGS allocation, size: " << allocationSize - << " symbols"); - } - else - { - NS_LOG_DEBUG("BS uplink scheduler, " << serviceFlow->GetSchedulingTypeStr() - << " unicast poll, size: " << allocationSize - << " symbols, modulation: BPSK 1/2"); - } - - NS_LOG_DEBUG(", CID: " << serviceFlow->GetConnection()->GetCid() - << ", SFID: " << serviceFlow->GetSfid()); - - AddUplinkAllocation(ulMapIe, allocationSize, symbolsToAllocation, availableSymbols); - ulMapIe.SetUiuc(uiuc); - } -} - -void -UplinkSchedulerRtps::ServiceBandwidthRequests(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - std::vector serviceFlows = ssRecord->GetServiceFlows(schedulingType); - - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - if (!ServiceBandwidthRequests(*iter, - schedulingType, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols)) - { - break; - } - } -} - -bool -UplinkSchedulerRtps::ServiceBandwidthRequests(ServiceFlow* serviceFlow, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - uint32_t allocSizeBytes = 0; - uint32_t allocSizeSymbols = 0; - uint16_t sduSize = 0; - - ServiceFlowRecord* record = serviceFlow->GetRecord(); - sduSize = serviceFlow->GetSduSize(); - - uint32_t requiredBandwidth = record->GetRequestedBandwidth() - record->GetGrantedBandwidth(); - if (requiredBandwidth > 0) - { - if (sduSize > 0) - { - // if SDU size is mentioned, allocate grant of that size - allocSizeBytes = sduSize; - allocSizeSymbols = GetBs()->GetPhy()->GetNrSymbols(sduSize, modulationType); - } - else - { - allocSizeBytes = requiredBandwidth; - allocSizeSymbols = GetBs()->GetPhy()->GetNrSymbols(requiredBandwidth, modulationType); - } - - if (availableSymbols >= allocSizeSymbols) - { - NS_LOG_DEBUG("BS uplink scheduler, " - << serviceFlow->GetSchedulingTypeStr() - << " allocation, size: " << allocSizeSymbols << " symbols" - << ", CID: " << serviceFlow->GetConnection()->GetCid() - << ", SFID: " << serviceFlow->GetSfid() - << ", bw requested: " << record->GetRequestedBandwidth() - << ", bw granted: " << record->GetGrantedBandwidth()); - - record->UpdateGrantedBandwidth(allocSizeBytes); - - if (schedulingType == ServiceFlow::SF_TYPE_NRTPS) - { - record->SetBwSinceLastExpiry(allocSizeBytes); - } - - AddUplinkAllocation(ulMapIe, allocSizeSymbols, symbolsToAllocation, availableSymbols); - } - else - { - return false; - } - } - return true; -} - -void -UplinkSchedulerRtps::ULSchedulerRTPSConnection(uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - NS_LOG_INFO("\tUL Scheduler for rtPS flows"); - NS_LOG_INFO("\t\tavailableSymbols = " << availableSymbols); - ServiceFlowRecord* record_[100]; - uint32_t allocSizeSymbols_[100]; // symbolsRequired for each SSRecord - OfdmUlMapIe ulMapIe_[100]; - OfdmUlMapIe ulMapIe; - WimaxPhy::ModulationType modulationType_[100]; - WimaxPhy::ModulationType modulationType; - int nbAllocation = 0; - uint32_t allocSizeBytes; - uint32_t totAllocSizeSymbols = 0; - - Cid cid; - std::vector* ssRecords = GetBs()->GetSSManager()->GetSSRecords(); - - for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) - { - SSRecord* ssRecord = *iter; - if (ssRecord->GetIsBroadcastSS()) - { - continue; - } - if (!ssRecord->GetPollForRanging() && - ssRecord->GetRangingStatus() != WimaxNetDevice::RANGING_STATUS_CONTINUE && - ssRecord->GetAreServiceFlowsAllocated()) - { - cid = ssRecord->GetBasicCid(); - ulMapIe.SetCid(cid); - modulationType = ssRecord->GetModulationType(); - ulMapIe.SetUiuc(GetBs()->GetBurstProfileManager()->GetBurstProfile( - modulationType, - WimaxNetDevice::DIRECTION_UPLINK)); - - std::vector serviceFlows = - ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_RTPS); - for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) - { - record_[nbAllocation] = (*iter2)->GetRecord(); - uint32_t requiredBandwidth = record_[nbAllocation]->GetRequestedBandwidth() - - record_[nbAllocation]->GetGrantedBandwidth(); - - if (requiredBandwidth > 0) - { - modulationType_[nbAllocation] = modulationType; - ulMapIe_[nbAllocation] = ulMapIe; - allocSizeBytes = requiredBandwidth; - allocSizeSymbols_[nbAllocation] = - GetBs()->GetPhy()->GetNrSymbols(allocSizeBytes, - modulationType_[nbAllocation]); - totAllocSizeSymbols += allocSizeSymbols_[nbAllocation]; - - NS_LOG_INFO( - "\t\tUL Scheduler for CID = " << (*iter2)->GetConnection()->GetCid()); - NS_LOG_INFO("\t\t\trequiredBandwidth = " - << record_[nbAllocation]->GetRequestedBandwidth() - << ", allocSizeSymbols = " << allocSizeSymbols_[nbAllocation] - << ", modulationType = " << modulationType_[nbAllocation]); - - nbAllocation += 1; - } - } - } - } - - NS_LOG_INFO("\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols); - - // Channel Saturation - while (totAllocSizeSymbols > availableSymbols) - { - NS_LOG_INFO("\tUL Channel Saturation: totAllocSizeSymbols > availableSymbols"); - double delta = double(availableSymbols) / double(totAllocSizeSymbols); - NS_LOG_INFO("\t\tdelta = " << delta); - totAllocSizeSymbols = 0; - for (int i = 0; i < nbAllocation; i++) - { - NS_LOG_INFO("\t\tprevious allocSizeSymbols_[" << i << "] = " << allocSizeSymbols_[i]); - allocSizeSymbols_[i] = (uint32_t)std::floor(allocSizeSymbols_[i] * delta); - totAllocSizeSymbols += allocSizeSymbols_[i]; - NS_LOG_INFO("\t\tnew allocSizeSymbols_[" << i << "] = " << allocSizeSymbols_[i]); - } - NS_LOG_INFO("\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols); - } - - // Uplink Bandwidth Allocation - for (int i = 0; i < nbAllocation; i++) - { - AddUplinkAllocation(ulMapIe_[i], - allocSizeSymbols_[i], - symbolsToAllocation, - availableSymbols); - allocSizeBytes = GetBs()->GetPhy()->GetNrBytes(allocSizeSymbols_[i], modulationType_[i]); - NS_LOG_INFO("\t\tUpdateGrantedBandwidth for " << i << " = " << allocSizeBytes); - if (record_[i]->GetRequestedBandwidth() < allocSizeBytes) - { - // the flow need new poll to set the newer requiredBandwidth - record_[i]->SetGrantedBandwidth(0); - record_[i]->SetRequestedBandwidth(0); - } - else - { - record_[i]->UpdateGrantedBandwidth(allocSizeBytes); - } - } -} - -void -UplinkSchedulerRtps::AllocateInitialRangingInterval(uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - Time ssUlStartTime = - Seconds(CalculateAllocationStartTime() * GetBs()->GetPsDuration().GetSeconds()); - SetNrIrOppsAllocated(GetBs()->GetLinkManager()->CalculateRangingOppsToAllocate()); - uint32_t allocationSize = GetNrIrOppsAllocated() * GetBs()->GetRangReqOppSize(); - Time timeSinceLastIrInterval = Simulator::Now() - GetTimeStampIrInterval(); - - // adding one frame because may be the time has not elapsed now but will elapse before the next - // frame is sent - if (timeSinceLastIrInterval + GetBs()->GetPhy()->GetFrameDuration() > - GetBs()->GetInitialRangingInterval() && - availableSymbols >= allocationSize) - { - SetIsIrIntrvlAllocated(true); - OfdmUlMapIe ulMapIeIr; - ulMapIeIr.SetCid(GetBs()->GetBroadcastConnection()->GetCid()); - ulMapIeIr.SetStartTime(symbolsToAllocation); - ulMapIeIr.SetUiuc(OfdmUlBurstProfile::UIUC_INITIAL_RANGING); - - NS_LOG_DEBUG("BS uplink scheduler, initial ranging allocation, size: " - << allocationSize << " symbols, modulation: BPSK 1/2"); - - // marking start and end of each TO, only for debugging - for (uint8_t i = 0; i < GetNrIrOppsAllocated(); i++) - { - GetBs()->MarkRangingOppStart( - ssUlStartTime + - Seconds(symbolsToAllocation * GetBs()->GetSymbolDuration().GetSeconds()) + - Seconds(i * GetBs()->GetRangReqOppSize() * - GetBs()->GetSymbolDuration().GetSeconds())); - } - - AddUplinkAllocation(ulMapIeIr, allocationSize, symbolsToAllocation, availableSymbols); - SetTimeStampIrInterval(Simulator::Now()); - } -} - -void -UplinkSchedulerRtps::SetupServiceFlow(SSRecord* ssRecord, ServiceFlow* serviceFlow) -{ - uint8_t delayNrFrames = 1; - uint32_t bitsPerSecond = serviceFlow->GetMinReservedTrafficRate(); - WimaxPhy::ModulationType modulation; - uint32_t bytesPerFrame = - (uint32_t((double)(bitsPerSecond)*GetBs()->GetPhy()->GetFrameDuration().GetSeconds())) / 8; - uint32_t frameDurationMSec = GetBs()->GetPhy()->GetFrameDuration().GetMilliSeconds(); - - switch (serviceFlow->GetSchedulingType()) - { - case ServiceFlow::SF_TYPE_UGS: { - if (serviceFlow->GetIsMulticast()) - { - modulation = serviceFlow->GetModulation(); - } - else - { - modulation = ssRecord->GetModulationType(); - } - uint32_t grantSize = GetBs()->GetPhy()->GetNrSymbols(bytesPerFrame, modulation); - serviceFlow->GetRecord()->SetGrantSize(grantSize); - - uint32_t toleratedJitter = serviceFlow->GetToleratedJitter(); - - if (toleratedJitter > frameDurationMSec) - { - delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec); - } - - uint16_t interval = delayNrFrames * frameDurationMSec; - serviceFlow->SetUnsolicitedGrantInterval(interval); - } - break; - case ServiceFlow::SF_TYPE_RTPS: { - if (serviceFlow->GetSduSize() > bytesPerFrame) - { - delayNrFrames = (uint8_t)(serviceFlow->GetSduSize() / bytesPerFrame); - } - - uint16_t interval = delayNrFrames * frameDurationMSec; - serviceFlow->SetUnsolicitedPollingInterval(interval); - } - break; - case ServiceFlow::SF_TYPE_NRTPS: - // no real-time guarantees are given to NRTPS, serviced based on available bandwidth - case ServiceFlow::SF_TYPE_BE: - // no real-time guarantees are given to BE, serviced based on available bandwidth - break; - default: - NS_FATAL_ERROR("Invalid scheduling type"); - } -} - -void -UplinkSchedulerRtps::InitOnce() -{ -} - -void -UplinkSchedulerRtps::ProcessBandwidthRequest(const BandwidthRequestHeader& bwRequestHdr) -{ -} - -void -UplinkSchedulerRtps::OnSetRequestedBandwidth(ServiceFlowRecord* sfr) -{ - // m_grantedBandwidth must be reset to zero - uint32_t grantedBandwidth = 0; - sfr->SetGrantedBandwidth(grantedBandwidth); -} - -} // namespace ns3 diff --git a/src/wimax/model/bs-uplink-scheduler-rtps.h b/src/wimax/model/bs-uplink-scheduler-rtps.h deleted file mode 100644 index 1d4724dbb..000000000 --- a/src/wimax/model/bs-uplink-scheduler-rtps.h +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Giuseppe Piro - */ - -#ifndef UPLINK_SCHEDULER_RTPS_H -#define UPLINK_SCHEDULER_RTPS_H - -#include "bs-uplink-scheduler.h" -#include "ul-mac-messages.h" -#include "wimax-phy.h" - -#include "ns3/nstime.h" - -#include - -namespace ns3 -{ - -class BaseStationNetDevice; -class SSRecord; -class ServiceFlow; - -/** - * @ingroup wimax - * @brief This class implements a simple uplink scheduler for rtPS flows. - * - * The UL-rtPS-Scheduler work in this way: - * At the beginning of the UL sub-frame some symbols are allocated - * to the rangingInterval Messages, DSA Messages, UGS grants and - * UGS/rtPS/nrtPS/BE poll. - * Then, the remaining available symbols are allocated to the all - * rtPS flows according to their requestedBandwidth. - * The bandwidth saturation control has been implemented to - * redistribute the resource if the sum of requestedBandwidth exceed - * the available bandwidth. - * At the end, if there are some free symbols, their are allocated to - * nrtPS and BE Connections. - */ - -class UplinkSchedulerRtps : public UplinkScheduler -{ - public: - UplinkSchedulerRtps(); - /** - * Constructor - * - * @param bs base station device - */ - UplinkSchedulerRtps(Ptr bs); - ~UplinkSchedulerRtps() override; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - - /** - * @brief Get uplink allocations. - * @returns std::list - */ - std::list GetUplinkAllocations() const override; - - /** - * Determines if channel descriptors sent in the current frame are - * required to be updated - * @param updateDcd if true update DCD - * @param updateUcd if true update UCD - * @param sendDcd if true send DCD - * @param sendUcd if true send UCD - */ - void GetChannelDescriptorsToUpdate(bool& updateDcd, - bool& updateUcd, - bool& sendDcd, - bool& sendUcd) override; - /** - * Calculate allocation start time function - * @returns the allocation start time value - */ - uint32_t CalculateAllocationStartTime() override; - /** - * Add Uplink Allocation function - * @param ulMapIe the UL map IE - * @param allocationSize the allocation size - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - void AddUplinkAllocation(OfdmUlMapIe& ulMapIe, - const uint32_t& allocationSize, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * @brief Schedule function. - */ - void Schedule() override; - /** - * Service Unsolicited Grants function - * @param ssRecord Subscriber station record - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - void ServiceUnsolicitedGrants(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * Service Bandwidth Requests function - * @param ssRecord Subscriber station record - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - void ServiceBandwidthRequests(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * Service bandwidth requests function - * @param serviceFlow the service flow - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - * @returns true if successful - */ - bool ServiceBandwidthRequests(ServiceFlow* serviceFlow, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * @brief Uplink Scheduler for rtPS connections. - * - * @param symbolsToAllocation symbols to allocation for UpLink Subframe - * @param availableSymbols available symbols for rtPS flows - * - * This method represent the UL Scheduler for rtPS connections. - * The scheduler is designed to serve all rtPS connections that - * have at least one packet to transmit, every UL Subframe. - * The method selects all rtPS connection that have al least one - * packet to transmit. To each rtPS connections are allocated, - * at the beginning, the bandwidth to transmit a quota of data equal - * to (RequestedBandwidth - GrantedBandwidth). - * If the sum of all pre-allocated bandwidth exceed the available - * symbols for rtPS connections, the Channel Saturation Control function - * is called to redistribute the available bandwidth. - */ - void ULSchedulerRTPSConnection(uint32_t& symbolsToAllocation, uint32_t& availableSymbols); - /** - * Allocate Initial Ranging Interval function - * - * @param symbolsToAllocation symbols to allocation for UpLink Subframe - * @param availableSymbols available symbols for rtPS flows - */ - void AllocateInitialRangingInterval(uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * Setup service flow function - * @param ssRecord Subscriber station record - * @param serviceFlow the service flow - */ - void SetupServiceFlow(SSRecord* ssRecord, ServiceFlow* serviceFlow) override; - - /** - * Process bandwidth request function - * @param bwRequestHdr the bandwidth request header - */ - void ProcessBandwidthRequest(const BandwidthRequestHeader& bwRequestHdr) override; - - /// Init once function - void InitOnce() override; - - /** - * Set requested bandwidth function - * @param sfr the service flow record - */ - void OnSetRequestedBandwidth(ServiceFlowRecord* sfr) override; - - private: - std::list m_uplinkAllocations; ///< uplink allocations -}; - -} // namespace ns3 - -#endif /* UPLINK_SCHEDULER_RTPS_H */ diff --git a/src/wimax/model/bs-uplink-scheduler-simple.cc b/src/wimax/model/bs-uplink-scheduler-simple.cc deleted file mode 100644 index b7bb05399..000000000 --- a/src/wimax/model/bs-uplink-scheduler-simple.cc +++ /dev/null @@ -1,585 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#include "bs-uplink-scheduler-simple.h" - -#include "bandwidth-manager.h" -#include "bs-link-manager.h" -#include "bs-net-device.h" -#include "burst-profile-manager.h" -#include "cid.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-manager.h" -#include "ss-record.h" - -#include "ns3/log.h" -#include "ns3/simulator.h" -#include "ns3/uinteger.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("UplinkSchedulerSimple"); - -NS_OBJECT_ENSURE_REGISTERED(UplinkSchedulerSimple); - -UplinkSchedulerSimple::UplinkSchedulerSimple() -{ - SetBs(nullptr); - SetTimeStampIrInterval(Seconds(0)); - SetNrIrOppsAllocated(0); - SetIsIrIntrvlAllocated(false); - SetIsInvIrIntrvlAllocated(false); - SetDcdTimeStamp(Simulator::Now()); - SetUcdTimeStamp(Simulator::Now()); -} - -UplinkSchedulerSimple::UplinkSchedulerSimple(Ptr bs) -{ - SetBs(bs); - SetTimeStampIrInterval(Seconds(0)); - SetNrIrOppsAllocated(0); - SetIsIrIntrvlAllocated(false); - SetIsInvIrIntrvlAllocated(false); - SetDcdTimeStamp(Simulator::Now()); - SetUcdTimeStamp(Simulator::Now()); -} - -UplinkSchedulerSimple::~UplinkSchedulerSimple() -{ - SetBs(nullptr); - m_uplinkAllocations.clear(); -} - -void -UplinkSchedulerSimple::InitOnce() -{ -} - -TypeId -UplinkSchedulerSimple::GetTypeId() -{ - static TypeId tid = TypeId("ns3::UplinkSchedulerSimple") - .SetParent() - .SetGroupName("Wimax") - .AddConstructor(); - return tid; -} - -std::list -UplinkSchedulerSimple::GetUplinkAllocations() const -{ - return m_uplinkAllocations; -} - -void -UplinkSchedulerSimple::GetChannelDescriptorsToUpdate(bool& updateDcd, - bool& updateUcd, - bool& sendDcd, - bool& sendUcd) -{ - /*DCD and UCD shall actually be updated when channel or burst profile definitions - change. burst profiles are updated based on number of SSs, network conditions and etc. - for now temporarily assuming DCD/UCD shall be updated every time */ - - uint32_t randNr = rand(); - if (randNr % 5 == 0 || GetBs()->GetNrDcdSent() == 0) - { - sendDcd = true; - } - - randNr = rand(); - if (randNr % 5 == 0 || GetBs()->GetNrUcdSent() == 0) - { - sendUcd = true; - } - - // ------------------------------------- - // additional, just to send more frequently - if (!sendDcd) - { - randNr = rand(); - if (randNr % 4 == 0) - { - sendDcd = true; - } - } - - if (!sendUcd) - { - randNr = rand(); - if (randNr % 4 == 0) - { - sendUcd = true; - } - } - // ------------------------------------- - - Time timeSinceLastDcd = Simulator::Now() - GetDcdTimeStamp(); - Time timeSinceLastUcd = Simulator::Now() - GetUcdTimeStamp(); - - if (timeSinceLastDcd > GetBs()->GetDcdInterval()) - { - sendDcd = true; - SetDcdTimeStamp(Simulator::Now()); - } - - if (timeSinceLastUcd > GetBs()->GetUcdInterval()) - { - sendUcd = true; - SetUcdTimeStamp(Simulator::Now()); - } -} - -uint32_t -UplinkSchedulerSimple::CalculateAllocationStartTime() -{ - return GetBs()->GetNrDlSymbols() * GetBs()->GetPhy()->GetPsPerSymbol() + GetBs()->GetTtg(); -} - -void -UplinkSchedulerSimple::AddUplinkAllocation(OfdmUlMapIe& ulMapIe, - const uint32_t& allocationSize, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - ulMapIe.SetDuration(allocationSize); - ulMapIe.SetStartTime(symbolsToAllocation); - m_uplinkAllocations.push_back(ulMapIe); - symbolsToAllocation += allocationSize; - availableSymbols -= allocationSize; -} - -void -UplinkSchedulerSimple::Schedule() -{ - m_uplinkAllocations.clear(); - SetIsIrIntrvlAllocated(false); - SetIsInvIrIntrvlAllocated(false); - bool allocationForDsa = false; - - uint32_t symbolsToAllocation = 0; - uint32_t allocationSize = 0; // size in symbols - uint32_t availableSymbols = GetBs()->GetNrUlSymbols(); - - AllocateInitialRangingInterval(symbolsToAllocation, availableSymbols); - - std::vector* ssRecords = GetBs()->GetSSManager()->GetSSRecords(); - for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) - { - SSRecord* ssRecord = *iter; - - if (ssRecord->GetIsBroadcastSS()) - { - continue; - } - Cid cid = ssRecord->GetBasicCid(); - OfdmUlMapIe ulMapIe; - ulMapIe.SetCid(cid); - - if (ssRecord->GetPollForRanging() && - ssRecord->GetRangingStatus() == WimaxNetDevice::RANGING_STATUS_CONTINUE) - { - // SS's ranging is not yet complete - // allocating invited initial ranging interval - ulMapIe.SetUiuc(OfdmUlBurstProfile::UIUC_INITIAL_RANGING); - allocationSize = GetBs()->GetRangReqOppSize(); - SetIsInvIrIntrvlAllocated(true); - - if (availableSymbols >= allocationSize) - { - AddUplinkAllocation(ulMapIe, allocationSize, symbolsToAllocation, availableSymbols); - } - else - { - break; - } - } - else - { - WimaxPhy::ModulationType modulationType = ssRecord->GetModulationType(); - - // need to update because modulation/FEC to UIUC mapping may vary over time - ulMapIe.SetUiuc(GetBs()->GetBurstProfileManager()->GetBurstProfile( - modulationType, - WimaxNetDevice::DIRECTION_UPLINK)); - - // establish service flows for SS - if (ssRecord->GetRangingStatus() == WimaxNetDevice::RANGING_STATUS_SUCCESS && - !ssRecord->GetAreServiceFlowsAllocated()) - { - // allocating grant (with arbitrary size) to allow SS to send DSA messages DSA-REQ - // and DSA-ACK only one DSA allocation per frame - if (!allocationForDsa) - { - allocationSize = - GetBs()->GetPhy()->GetNrSymbols(sizeof(DsaReq), modulationType); - - if (availableSymbols >= allocationSize) - { - AddUplinkAllocation(ulMapIe, - allocationSize, - symbolsToAllocation, - availableSymbols); - allocationForDsa = true; - } - else - { - break; - } - } - } - else - { - // all service flows associated to SS are established now - - /*allocating grants for data transmission for UGS flows (Data Grant Burst Type - IEs, 6.3.7.4.3.3) (grant has been referred by different names e.g. transmission - opportunity, slot, uplink allocation, etc)*/ - ServiceUnsolicitedGrants(ssRecord, - ServiceFlow::SF_TYPE_UGS, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - - // allocate unicast polls for rtPS flows if bandwidth is available - if (availableSymbols) - { - ServiceUnsolicitedGrants(ssRecord, - ServiceFlow::SF_TYPE_RTPS, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - // allocate unicast polls for nrtPS flows if bandwidth is available - if (availableSymbols) - { - ServiceUnsolicitedGrants(ssRecord, - ServiceFlow::SF_TYPE_NRTPS, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - // finally allocate unicast polls for BE flows if bandwidth is available - if (availableSymbols) - { - ServiceUnsolicitedGrants(ssRecord, - ServiceFlow::SF_TYPE_BE, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - - // now allocating grants for non-UGS flows (i.e., in response of bandwidth requests) - - if (availableSymbols) - { - ServiceBandwidthRequests(ssRecord, - ServiceFlow::SF_TYPE_RTPS, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - // allocate unicast polls for nrtPS flows if bandwidth is available - if (availableSymbols) - { - ServiceBandwidthRequests(ssRecord, - ServiceFlow::SF_TYPE_NRTPS, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - // finally allocate unicast polls for BE flows if bandwidth is available - if (availableSymbols) - { - ServiceBandwidthRequests(ssRecord, - ServiceFlow::SF_TYPE_BE, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - } - } - } - } - OfdmUlMapIe ulMapIeEnd; - - ulMapIeEnd.SetCid(Cid::InitialRanging()); - ulMapIeEnd.SetStartTime(symbolsToAllocation); - ulMapIeEnd.SetUiuc(OfdmUlBurstProfile::UIUC_END_OF_MAP); - ulMapIeEnd.SetDuration(0); - m_uplinkAllocations.push_back(ulMapIeEnd); - - // setting DL/UL subframe allocation for the next frame - GetBs()->GetBandwidthManager()->SetSubframeRatio(); -} - -void -UplinkSchedulerSimple::ServiceUnsolicitedGrants(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - uint32_t allocationSize = 0; // size in symbols - uint8_t uiuc = ulMapIe.GetUiuc(); // SS's burst profile - std::vector serviceFlows = ssRecord->GetServiceFlows(schedulingType); - - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - ServiceFlow* serviceFlow = *iter; - - /* in case of rtPS, nrtPS and BE, allocating unicast polls for bandwidth requests (Request - IEs, 6.3.7.4.3.1). in case of UGS, allocating grants for data transmission (Data Grant - Burst Type IEs, 6.3.7.4.3.3) (grant has been referred in this code by different names e.g. - transmission opportunity, slot, allocation, etc) */ - - allocationSize = - GetBs()->GetBandwidthManager()->CalculateAllocationSize(ssRecord, serviceFlow); - // verifying that minimum reserved traffic rate of nrtPS flow is maintained - if (serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_NRTPS) - { - Time currentTime = Simulator::Now(); - ServiceFlowRecord* record = serviceFlow->GetRecord(); - if (currentTime - record->GetGrantTimeStamp() > Seconds(1)) - { - uint32_t bps = (record->GetBwSinceLastExpiry() * 8); - if (bps < serviceFlow->GetMinReservedTrafficRate()) - { - ServiceBandwidthRequests(serviceFlow, - schedulingType, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols); - record->SetBwSinceLastExpiry(0); - record->SetGrantTimeStamp(currentTime); - } - } - } - - if (availableSymbols < allocationSize) - { - break; - } - - if (allocationSize > 0) - { - ulMapIe.SetStartTime(symbolsToAllocation); - if (serviceFlow->GetSchedulingType() != ServiceFlow::SF_TYPE_UGS) - { - // special burst profile with most robust modulation type is used for unicast polls - // (Request IEs) - ulMapIe.SetUiuc(OfdmUlBurstProfile::UIUC_REQ_REGION_FULL); - } - } - else - { - continue; - } - - NS_LOG_DEBUG(", CID: " << serviceFlow->GetConnection()->GetCid() - << ", SFID: " << serviceFlow->GetSfid()); - - AddUplinkAllocation(ulMapIe, allocationSize, symbolsToAllocation, availableSymbols); - ulMapIe.SetUiuc(uiuc); - } -} - -void -UplinkSchedulerSimple::ServiceBandwidthRequests(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - std::vector serviceFlows = ssRecord->GetServiceFlows(schedulingType); - - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - if (!ServiceBandwidthRequests(*iter, - schedulingType, - ulMapIe, - modulationType, - symbolsToAllocation, - availableSymbols)) - { - break; - } - } -} - -bool -UplinkSchedulerSimple::ServiceBandwidthRequests(ServiceFlow* serviceFlow, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - uint32_t allocSizeBytes = 0; - uint32_t allocSizeSymbols = 0; - uint16_t sduSize = 0; - - ServiceFlowRecord* record = serviceFlow->GetRecord(); - sduSize = serviceFlow->GetSduSize(); - - uint32_t requiredBandwidth = record->GetRequestedBandwidth() - record->GetGrantedBandwidth(); - if (requiredBandwidth > 0) - { - if (sduSize > 0) - { - // if SDU size is mentioned, allocate grant of that size - allocSizeBytes = sduSize; - allocSizeSymbols = GetBs()->GetPhy()->GetNrSymbols(sduSize, modulationType); - } - else - { - allocSizeBytes = requiredBandwidth; - allocSizeSymbols = GetBs()->GetPhy()->GetNrSymbols(requiredBandwidth, modulationType); - } - - if (availableSymbols >= allocSizeSymbols) - { - record->UpdateGrantedBandwidth(allocSizeBytes); - - if (schedulingType == ServiceFlow::SF_TYPE_NRTPS) - { - record->SetBwSinceLastExpiry(allocSizeBytes); - } - - AddUplinkAllocation(ulMapIe, allocSizeSymbols, symbolsToAllocation, availableSymbols); - } - else - { - return false; - } - } - return true; -} - -void -UplinkSchedulerSimple::AllocateInitialRangingInterval(uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) -{ - Time ssUlStartTime = - Seconds(CalculateAllocationStartTime() * GetBs()->GetPsDuration().GetSeconds()); - SetNrIrOppsAllocated(GetBs()->GetLinkManager()->CalculateRangingOppsToAllocate()); - uint32_t allocationSize = GetNrIrOppsAllocated() * GetBs()->GetRangReqOppSize(); - Time timeSinceLastIrInterval = Simulator::Now() - GetTimeStampIrInterval(); - - // adding one frame because may be the time has not elapsed now but will elapse before the next - // frame is sent - if (timeSinceLastIrInterval + GetBs()->GetPhy()->GetFrameDuration() > - GetBs()->GetInitialRangingInterval() && - availableSymbols >= allocationSize) - { - SetIsIrIntrvlAllocated(true); - OfdmUlMapIe ulMapIeIr; - ulMapIeIr.SetCid((GetBs()->GetBroadcastConnection())->GetCid()); - ulMapIeIr.SetStartTime(symbolsToAllocation); - ulMapIeIr.SetUiuc(OfdmUlBurstProfile::UIUC_INITIAL_RANGING); - - NS_LOG_DEBUG("BS uplink scheduler, initial ranging allocation, size: " - << allocationSize << " symbols, modulation: BPSK 1/2"); - - // marking start and end of each TO, only for debugging - for (uint8_t i = 0; i < GetNrIrOppsAllocated(); i++) - { - GetBs()->MarkRangingOppStart( - ssUlStartTime + - Seconds(symbolsToAllocation * GetBs()->GetSymbolDuration().GetSeconds()) + - Seconds(i * GetBs()->GetRangReqOppSize() * - GetBs()->GetSymbolDuration().GetSeconds())); - } - - AddUplinkAllocation(ulMapIeIr, allocationSize, symbolsToAllocation, availableSymbols); - SetTimeStampIrInterval(Simulator::Now()); - } -} - -void -UplinkSchedulerSimple::SetupServiceFlow(SSRecord* ssRecord, ServiceFlow* serviceFlow) -{ - uint8_t delayNrFrames = 1; - uint32_t bitsPerSecond = serviceFlow->GetMinReservedTrafficRate(); - WimaxPhy::ModulationType modulation; - uint32_t bytesPerFrame = - (uint32_t((double)(bitsPerSecond)*GetBs()->GetPhy()->GetFrameDuration().GetSeconds())) / 8; - uint32_t frameDurationMSec = GetBs()->GetPhy()->GetFrameDuration().GetMilliSeconds(); - - switch (serviceFlow->GetSchedulingType()) - { - case ServiceFlow::SF_TYPE_UGS: { - if (serviceFlow->GetIsMulticast()) - { - modulation = serviceFlow->GetModulation(); - } - else - { - modulation = ssRecord->GetModulationType(); - } - uint32_t grantSize = GetBs()->GetPhy()->GetNrSymbols(bytesPerFrame, modulation); - serviceFlow->GetRecord()->SetGrantSize(grantSize); - - uint32_t toleratedJitter = serviceFlow->GetToleratedJitter(); - - if (toleratedJitter > frameDurationMSec) - { - delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec); - } - - uint16_t interval = delayNrFrames * frameDurationMSec; - serviceFlow->SetUnsolicitedGrantInterval(interval); - } - break; - case ServiceFlow::SF_TYPE_RTPS: { - if (serviceFlow->GetSduSize() > bytesPerFrame) - { - delayNrFrames = (uint8_t)(serviceFlow->GetSduSize() / bytesPerFrame); - } - - uint16_t interval = delayNrFrames * frameDurationMSec; - serviceFlow->SetUnsolicitedPollingInterval(interval); - } - break; - case ServiceFlow::SF_TYPE_NRTPS: - // no real-time guarantees are given to NRTPS, serviced based on available bandwidth - case ServiceFlow::SF_TYPE_BE: - // no real-time guarantees are given to BE, serviced based on available bandwidth - break; - default: - NS_FATAL_ERROR("Invalid scheduling type"); - } -} - -void -UplinkSchedulerSimple::ProcessBandwidthRequest(const BandwidthRequestHeader& bwRequestHdr) -{ - // virtual function on UplinkScheduler - // this is not necessary on this implementation -} - -void -UplinkSchedulerSimple::OnSetRequestedBandwidth(ServiceFlowRecord* sfr) -{ - // m_grantedBandwidth must be reset to zero - uint32_t grantedBandwidth = 0; - sfr->SetGrantedBandwidth(grantedBandwidth); -} - -} // namespace ns3 diff --git a/src/wimax/model/bs-uplink-scheduler-simple.h b/src/wimax/model/bs-uplink-scheduler-simple.h deleted file mode 100644 index 9cf23dd9e..000000000 --- a/src/wimax/model/bs-uplink-scheduler-simple.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#ifndef UPLINK_SCHEDULER_SIMPLE_H -#define UPLINK_SCHEDULER_SIMPLE_H - -#include "bs-uplink-scheduler.h" -#include "service-flow.h" -#include "ul-mac-messages.h" -#include "wimax-phy.h" - -#include "ns3/nstime.h" - -#include - -namespace ns3 -{ - -class BaseStationNetDevice; -class SSRecord; -class ServiceFlow; - -/** - * @ingroup wimax - * - * Uplink Scheduler - simplified - */ -class UplinkSchedulerSimple : public UplinkScheduler -{ - public: - UplinkSchedulerSimple(); - /** - * Constructor - * - * @param bs base station device - */ - UplinkSchedulerSimple(Ptr bs); - ~UplinkSchedulerSimple() override; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - - std::list GetUplinkAllocations() const override; - - /** - * @brief Determines if channel descriptors sent in the current frame are - * required to be updated - * - * @param updateDcd currently unused (assume true) - * @param updateUcd currently unused (assume true) - * @param [out] sendDcd DCD must be updated - * @param [out] sendUcd UCD must be updated - * - */ - void GetChannelDescriptorsToUpdate(bool& updateDcd, - bool& updateUcd, - bool& sendDcd, - bool& sendUcd) override; - uint32_t CalculateAllocationStartTime() override; - void AddUplinkAllocation(OfdmUlMapIe& ulMapIe, - const uint32_t& allocationSize, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - void Schedule() override; - /** - * Service Unsolicited Grants function - * @param ssRecord Subscriber station record - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - void ServiceUnsolicitedGrants(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * Service Bandwidth Requests function - * @param ssRecord Subscriber station record - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - void ServiceBandwidthRequests(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * Service bandwidth requests function - * @param serviceFlow the service flow - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - * @returns true if successful - */ - bool ServiceBandwidthRequests(ServiceFlow* serviceFlow, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * Allocate Initial Ranging Interval function - * - * @param symbolsToAllocation symbols to allocation for UpLink Subframe - * @param availableSymbols available symbols for rtPS flows - */ - void AllocateInitialRangingInterval(uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) override; - /** - * Setup service flow function - * @param ssRecord Subscriber station record - * @param serviceFlow the service flow - */ - void SetupServiceFlow(SSRecord* ssRecord, ServiceFlow* serviceFlow) override; - - /** - * Process bandwidth request function - * @param bwRequestHdr the bandwidth request header - */ - void ProcessBandwidthRequest(const BandwidthRequestHeader& bwRequestHdr) override; - - /// Init once function - void InitOnce() override; - - /** - * Set requested bandwidth function - * @param sfr the service flow record - */ - void OnSetRequestedBandwidth(ServiceFlowRecord* sfr) override; - - private: - std::list m_uplinkAllocations; ///< uplink allocations -}; - -} // namespace ns3 - -#endif /* UPLINK_SCHEDULER_SIMPLE_H */ diff --git a/src/wimax/model/bs-uplink-scheduler.cc b/src/wimax/model/bs-uplink-scheduler.cc deleted file mode 100644 index 01bd28b9f..000000000 --- a/src/wimax/model/bs-uplink-scheduler.cc +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#include "bs-uplink-scheduler.h" - -#include "bandwidth-manager.h" -#include "bs-link-manager.h" -#include "bs-net-device.h" -#include "burst-profile-manager.h" -#include "cid.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-manager.h" -#include "ss-record.h" - -#include "ns3/log.h" -#include "ns3/simulator.h" -#include "ns3/uinteger.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("UplinkScheduler"); - -NS_OBJECT_ENSURE_REGISTERED(UplinkScheduler); - -UplinkScheduler::UplinkScheduler() - : m_bs(nullptr), - m_timeStampIrInterval(), - m_nrIrOppsAllocated(0), - m_isIrIntrvlAllocated(false), - m_isInvIrIntrvlAllocated(false), - m_dcdTimeStamp(Simulator::Now()), - m_ucdTimeStamp(Simulator::Now()) -{ -} - -UplinkScheduler::UplinkScheduler(Ptr bs) - : m_bs(bs), - m_timeStampIrInterval(), - m_nrIrOppsAllocated(0), - m_isIrIntrvlAllocated(false), - m_isInvIrIntrvlAllocated(false), - m_dcdTimeStamp(Simulator::Now()), - m_ucdTimeStamp(Simulator::Now()) -{ -} - -UplinkScheduler::~UplinkScheduler() -{ - m_bs = nullptr; - m_uplinkAllocations.clear(); -} - -void -UplinkScheduler::InitOnce() -{ -} - -TypeId -UplinkScheduler::GetTypeId() -{ - static TypeId tid = TypeId("ns3::UplinkScheduler").SetParent().SetGroupName("Wimax"); - return tid; -} - -uint8_t -UplinkScheduler::GetNrIrOppsAllocated() const -{ - return m_nrIrOppsAllocated; -} - -void -UplinkScheduler::SetNrIrOppsAllocated(uint8_t nrIrOppsAllocated) -{ - m_nrIrOppsAllocated = nrIrOppsAllocated; -} - -bool -UplinkScheduler::GetIsIrIntrvlAllocated() const -{ - return m_isIrIntrvlAllocated; -} - -void -UplinkScheduler::SetIsIrIntrvlAllocated(bool isIrIntrvlAllocated) -{ - m_isIrIntrvlAllocated = isIrIntrvlAllocated; -} - -bool -UplinkScheduler::GetIsInvIrIntrvlAllocated() const -{ - return m_isInvIrIntrvlAllocated; -} - -void -UplinkScheduler::SetIsInvIrIntrvlAllocated(bool isInvIrIntrvlAllocated) -{ - m_isInvIrIntrvlAllocated = isInvIrIntrvlAllocated; -} - -Time -UplinkScheduler::GetDcdTimeStamp() const -{ - return m_dcdTimeStamp; -} - -void -UplinkScheduler::SetDcdTimeStamp(Time dcdTimeStamp) -{ - m_dcdTimeStamp = dcdTimeStamp; -} - -Time -UplinkScheduler::GetUcdTimeStamp() const -{ - return m_ucdTimeStamp; -} - -void -UplinkScheduler::SetUcdTimeStamp(Time ucdTimeStamp) -{ - m_ucdTimeStamp = ucdTimeStamp; -} - -std::list -UplinkScheduler::GetUplinkAllocations() const -{ - return m_uplinkAllocations; -} - -Time -UplinkScheduler::GetTimeStampIrInterval() -{ - return m_timeStampIrInterval; -} - -void -UplinkScheduler::SetTimeStampIrInterval(Time timeStampIrInterval) -{ - m_timeStampIrInterval = timeStampIrInterval; -} - -Ptr -UplinkScheduler::GetBs() -{ - return m_bs; -} - -void -UplinkScheduler::SetBs(Ptr bs) -{ - m_bs = bs; -} -} // namespace ns3 diff --git a/src/wimax/model/bs-uplink-scheduler.h b/src/wimax/model/bs-uplink-scheduler.h deleted file mode 100644 index 0d0071114..000000000 --- a/src/wimax/model/bs-uplink-scheduler.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#ifndef UPLINK_SCHEDULER_H -#define UPLINK_SCHEDULER_H - -#include "service-flow-record.h" -#include "service-flow.h" -#include "ul-mac-messages.h" -#include "wimax-phy.h" - -#include "ns3/nstime.h" - -#include - -namespace ns3 -{ - -class BaseStationNetDevice; -class SSRecord; -class ServiceFlow; -class ServiceFlowRecord; - -/** - * @ingroup wimax - * @brief Virtual class for uplink scheduler. - */ -class UplinkScheduler : public Object -{ - public: - UplinkScheduler(); - /** - * Constructor - * - * @param bs base station device - */ - UplinkScheduler(Ptr bs); - ~UplinkScheduler() override; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - - /** - * @return the number of IR opps allocated - */ - virtual uint8_t GetNrIrOppsAllocated() const; - /** - * @brief Set the number of IR opps allocated - * @param nrIrOppsAllocated number of IR opps allocated - */ - virtual void SetNrIrOppsAllocated(uint8_t nrIrOppsAllocated); - - /** - * @return true if the IR interval is allocated - */ - virtual bool GetIsIrIntrvlAllocated() const; - /** - * @brief Set if the IR interval is allocated - * @param isIrIntrvlAllocated - */ - virtual void SetIsIrIntrvlAllocated(bool isIrIntrvlAllocated); - - /** - * @return true if the Inv IR interval is allocated - */ - virtual bool GetIsInvIrIntrvlAllocated() const; - /** - * @brief Set if the Inv IR interval is allocated - * @param isInvIrIntrvlAllocated - */ - virtual void SetIsInvIrIntrvlAllocated(bool isInvIrIntrvlAllocated); - - /** - * @return uplink allocations - */ - virtual std::list GetUplinkAllocations() const; - - /** - * @return the timestamp of the IR interval - */ - virtual Time GetTimeStampIrInterval(); - /** - * @brief Set timestamp IR interval - * @param timeStampIrInterval - */ - virtual void SetTimeStampIrInterval(Time timeStampIrInterval); - - /** - * @return the DCD timestamp - */ - virtual Time GetDcdTimeStamp() const; - /** - * @brief Set DCD timestamp - * @param dcdTimeStamp - */ - virtual void SetDcdTimeStamp(Time dcdTimeStamp); - - /** - * @return the UCD timestamp - */ - virtual Time GetUcdTimeStamp() const; - /** - * @brief Set UCD timestamp - * @param ucdTimeStamp - */ - virtual void SetUcdTimeStamp(Time ucdTimeStamp); - - /** - * @return the base station device - */ - virtual Ptr GetBs(); - /** - * @brief Set base station device - * @param bs - */ - virtual void SetBs(Ptr bs); - /** - * Determines if channel descriptors sent in the current frame are - * required to be updated - */ - virtual void GetChannelDescriptorsToUpdate(bool&, bool&, bool&, bool&) = 0; - /** - * @return the calculated allocation start time - */ - virtual uint32_t CalculateAllocationStartTime() = 0; - /** - * Add uplink allocation - * @param ulMapIe the UL map IE - * @param allocationSize the allocation size - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - virtual void AddUplinkAllocation(OfdmUlMapIe& ulMapIe, - const uint32_t& allocationSize, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) = 0; - /** - * Schedule function - */ - virtual void Schedule() = 0; - /** - * Service unsolicited grants function - * @param ssRecord the SS record - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - virtual void ServiceUnsolicitedGrants(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) = 0; - /** - * Service bandwidth request function - * @param ssRecord the SS record - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - virtual void ServiceBandwidthRequests(const SSRecord* ssRecord, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) = 0; - /** - * Service bandwidth request function - * @param serviceFlow the service flow - * @param schedulingType the scheduling type - * @param ulMapIe the UL map IE - * @param modulationType the modulation type - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - * @returns true if successful - */ - virtual bool ServiceBandwidthRequests(ServiceFlow* serviceFlow, - ServiceFlow::SchedulingType schedulingType, - OfdmUlMapIe& ulMapIe, - const WimaxPhy::ModulationType modulationType, - uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) = 0; - /** - * Allocate initial ranging interval function - * @param symbolsToAllocation the symbols to allocation - * @param availableSymbols the available symbols - */ - virtual void AllocateInitialRangingInterval(uint32_t& symbolsToAllocation, - uint32_t& availableSymbols) = 0; - /** - * Setp service flow function - * @param ssRecord the SS record - * @param serviceFlow the service flow - */ - virtual void SetupServiceFlow(SSRecord* ssRecord, ServiceFlow* serviceFlow) = 0; - /** - * Process bandwidth request function - * @param bwRequestHdr - */ - virtual void ProcessBandwidthRequest(const BandwidthRequestHeader& bwRequestHdr) = 0; - - /** - * one time initialization function - */ - virtual void InitOnce() = 0; - - /** - * @brief Set requested bandwidth - * @param sfr service flow record - */ - virtual void OnSetRequestedBandwidth(ServiceFlowRecord* sfr) = 0; - - private: - Ptr m_bs; ///< the base station - std::list m_uplinkAllocations; ///< uplink allocations - Time m_timeStampIrInterval; ///< timestamp IR interval - uint8_t m_nrIrOppsAllocated; ///< number IR opps allocated - bool m_isIrIntrvlAllocated; ///< is IR interval allocated - bool m_isInvIrIntrvlAllocated; ///< is Inv IR interval allocated - Time m_dcdTimeStamp; ///< DCD timestamp - Time m_ucdTimeStamp; ///< UCD timestamp -}; - -} // namespace ns3 - -#endif /* UPLINK_SCHEDULER_H */ diff --git a/src/wimax/model/burst-profile-manager.cc b/src/wimax/model/burst-profile-manager.cc deleted file mode 100644 index e3e7ea9dc..000000000 --- a/src/wimax/model/burst-profile-manager.cc +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#include "burst-profile-manager.h" - -#include "bs-net-device.h" -#include "mac-messages.h" -#include "ss-manager.h" -#include "ss-net-device.h" -#include "ss-record.h" - -#include "ns3/log.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("BurstProfileManager"); - -NS_OBJECT_ENSURE_REGISTERED(BurstProfileManager); - -TypeId -BurstProfileManager::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::BurstProfileManager").SetParent().SetGroupName("Wimax"); - return tid; -} - -BurstProfileManager::BurstProfileManager(Ptr device) - : m_device(device) -{ -} - -BurstProfileManager::~BurstProfileManager() -{ - m_device = nullptr; -} - -void -BurstProfileManager::DoDispose() -{ - m_device = nullptr; -} - -uint16_t -BurstProfileManager::GetNrBurstProfilesToDefine() -{ - /* - * 7 modulation types - */ - return 7; -} - -WimaxPhy::ModulationType -BurstProfileManager::GetModulationType(uint8_t iuc, WimaxNetDevice::Direction direction) const -{ - if (direction == WimaxNetDevice::DIRECTION_DOWNLINK) - { - std::vector dlBurstProfiles = - m_device->GetCurrentDcd().GetDlBurstProfiles(); - for (auto iter = dlBurstProfiles.begin(); iter != dlBurstProfiles.end(); ++iter) - { - if (iter->GetDiuc() == iuc) - { - return (WimaxPhy::ModulationType)iter->GetFecCodeType(); - } - } - } - else - { - std::vector ulBurstProfiles = - m_device->GetCurrentUcd().GetUlBurstProfiles(); - for (auto iter = ulBurstProfiles.begin(); iter != ulBurstProfiles.end(); ++iter) - { - if (iter->GetUiuc() == iuc) - { - return (WimaxPhy::ModulationType)iter->GetFecCodeType(); - } - } - } - - // burst profile got to be there in DCD/UCD, assuming always all profiles are defined in DCD/UCD - NS_FATAL_ERROR("burst profile got to be there in DCD/UCD"); - - return (WimaxPhy::ModulationType)-1; -} - -uint8_t -BurstProfileManager::GetBurstProfile(WimaxPhy::ModulationType modulationType, - WimaxNetDevice::Direction direction) const -{ - if (direction == WimaxNetDevice::DIRECTION_DOWNLINK) - { - std::vector dlBurstProfiles = - m_device->GetCurrentDcd().GetDlBurstProfiles(); - for (auto iter = dlBurstProfiles.begin(); iter != dlBurstProfiles.end(); ++iter) - { - if (iter->GetFecCodeType() == modulationType) - { - return iter->GetDiuc(); - } - } - } - else - { - std::vector ulBurstProfiles = - m_device->GetCurrentUcd().GetUlBurstProfiles(); - for (auto iter = ulBurstProfiles.begin(); iter != ulBurstProfiles.end(); ++iter) - { - if (iter->GetFecCodeType() == modulationType) - { - return iter->GetUiuc(); - } - } - } - - // burst profile got to be there in DCD/UCD, assuming always all profiles are defined in DCD/UCD - NS_FATAL_ERROR("burst profile got to be there in DCD/UCD"); - - return ~0; -} - -uint8_t -BurstProfileManager::GetBurstProfileForSS(const SSRecord* ssRecord, - const RngReq* rngreq, - WimaxPhy::ModulationType& modulationType) const -{ - /*during initial ranging or periodic ranging (or when RNG-REQ is used instead of - DBPC) calculates the least robust burst profile for SS, e.g., based on distance, - power, signal etc, temporarily choosing same burst profile SS requested in RNG-REQ*/ - - modulationType = GetModulationTypeForSS(ssRecord, rngreq); - return GetBurstProfile(modulationType, WimaxNetDevice::DIRECTION_DOWNLINK); -} - -WimaxPhy::ModulationType -BurstProfileManager::GetModulationTypeForSS(const SSRecord* ssRecord, const RngReq* rngreq) const -{ - return GetModulationType(rngreq->GetReqDlBurstProfile(), WimaxNetDevice::DIRECTION_DOWNLINK); -} - -uint8_t -BurstProfileManager::GetBurstProfileToRequest() -{ - /*modulation type is currently set by user in simulation script, shall - actually be determined based on SS's distance, power, signal etc*/ - - return GetBurstProfile(m_device->GetObject()->GetModulationType(), - WimaxNetDevice::DIRECTION_DOWNLINK); -} - -} // namespace ns3 diff --git a/src/wimax/model/burst-profile-manager.h b/src/wimax/model/burst-profile-manager.h deleted file mode 100644 index 170c97a9c..000000000 --- a/src/wimax/model/burst-profile-manager.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#ifndef BURST_PROFILE_MANAGER_H -#define BURST_PROFILE_MANAGER_H - -#include "cid.h" -#include "wimax-net-device.h" -#include "wimax-phy.h" - -#include - -namespace ns3 -{ - -class SSRecord; -class RngReq; - -/** - * @ingroup wimax - * - * Profile manager for burst communications - */ -class BurstProfileManager : public Object -{ - public: - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - /** - * Constructor - * - * @param device WIMAX device - */ - BurstProfileManager(Ptr device); - ~BurstProfileManager() override; - - // Delete copy constructor and assignment operator to avoid misuse - BurstProfileManager(const BurstProfileManager&) = delete; - BurstProfileManager& operator=(const BurstProfileManager&) = delete; - - void DoDispose() override; - /** - * @returns the number of available burst profile - */ - uint16_t GetNrBurstProfilesToDefine(); - - /** - * @brief returns the modulation type of a given iuc - * @param direction should be uplink or downlink - * @param iuc the iuc - * @returns the modulation type of the selected iuc - */ - WimaxPhy::ModulationType GetModulationType(uint8_t iuc, - WimaxNetDevice::Direction direction) const; - - /** - * @brief returns the burst profile - * @param modulationType - * @param direction should be uplink or downlink - * @returns the modulation type of the selected iuc - */ - uint8_t GetBurstProfile(WimaxPhy::ModulationType modulationType, - WimaxNetDevice::Direction direction) const; - - /** - * @brief Get burst profile for SS - * @param modulationType - * @param ssRecord - * @param rngreq - * @returns the burst profile for SS - */ - uint8_t GetBurstProfileForSS(const SSRecord* ssRecord, - const RngReq* rngreq, - WimaxPhy::ModulationType& modulationType) const; - /** - * @brief Get module ation type for SS - * @param ssRecord - * @param rngreq - * @returns the burst profile for SS - */ - WimaxPhy::ModulationType GetModulationTypeForSS(const SSRecord* ssRecord, - const RngReq* rngreq) const; - /** - * @brief Get burst profile to request - * @returns the burst profile for SS - */ - uint8_t GetBurstProfileToRequest(); - - private: - Ptr m_device; ///< the device -}; - -} // namespace ns3 - -#endif /* BURST_PROFILE_MANAGER_H */ diff --git a/src/wimax/model/bvec.h b/src/wimax/model/bvec.h deleted file mode 100644 index c3eda2549..000000000 --- a/src/wimax/model/bvec.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -#ifndef BVEC_H -#define BVEC_H - -#include - -namespace ns3 -{ -/// boolean vector typedef -typedef std::vector Bvec; -} // namespace ns3 - -#endif /* BVEC_H */ diff --git a/src/wimax/model/cid-factory.cc b/src/wimax/model/cid-factory.cc deleted file mode 100644 index 243125d54..000000000 --- a/src/wimax/model/cid-factory.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "cid-factory.h" - -#include "ns3/uinteger.h" - -#include - -namespace ns3 -{ - -CidFactory::CidFactory() - : m_m(0x5500), - // this is an arbitrary default - m_basicIdentifier(1), - m_primaryIdentifier(m_m + 1), - m_transportOrSecondaryIdentifier(2 * m_m + 1), - m_multicastPollingIdentifier(0xff00) -{ -} - -Cid -CidFactory::AllocateBasic() -{ - NS_ASSERT(m_basicIdentifier < m_m); - m_basicIdentifier++; - return Cid(m_basicIdentifier); -} - -Cid -CidFactory::AllocatePrimary() -{ - NS_ASSERT(m_primaryIdentifier < 2 * m_m); - m_primaryIdentifier++; - return Cid(m_primaryIdentifier); -} - -Cid -CidFactory::AllocateTransportOrSecondary() -{ - NS_ASSERT(m_transportOrSecondaryIdentifier < 0xfefe); - m_transportOrSecondaryIdentifier++; - return Cid(m_transportOrSecondaryIdentifier); -} - -Cid -CidFactory::AllocateMulticast() -{ - NS_ASSERT(m_multicastPollingIdentifier < 0xfffd); - m_multicastPollingIdentifier++; - return Cid(m_multicastPollingIdentifier); -} - -Cid -CidFactory::Allocate(Cid::Type type) -{ - switch (type) - { - case Cid::BROADCAST: - return Cid::Broadcast(); - case Cid::INITIAL_RANGING: - return Cid::InitialRanging(); - case Cid::BASIC: - return AllocateBasic(); - case Cid::PRIMARY: - return AllocatePrimary(); - case Cid::TRANSPORT: - return AllocateTransportOrSecondary(); - case Cid::MULTICAST: - return AllocateMulticast(); - case Cid::PADDING: - return Cid::Padding(); - default: - NS_FATAL_ERROR("Cannot be reached"); - return 0; // quiet compiler - } -} - -bool -CidFactory::IsTransport(Cid cid) const -{ - int id = cid.m_identifier; - return (id - 2 * m_m > 0) && (id <= 0xfefe); -} - -bool -CidFactory::IsPrimary(Cid cid) const -{ - int id = cid.m_identifier; - return (id - m_m > 0) && (id <= 2 * m_m); -} - -bool -CidFactory::IsBasic(Cid cid) const -{ - uint16_t id = cid.m_identifier; - return id >= 1 && id <= m_m; -} - -void -CidFactory::FreeCid(Cid cid) -{ - /// @todo We need to update the cid bitmap properly here. - NS_FATAL_ERROR( - "TODO: Update the cid bitmap properly here-- please implement and contribute a patch"); -} - -} // namespace ns3 diff --git a/src/wimax/model/cid-factory.h b/src/wimax/model/cid-factory.h deleted file mode 100644 index 4c22796d3..000000000 --- a/src/wimax/model/cid-factory.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#ifndef CONNECTION_IDENTIFIER_FACTORY_H -#define CONNECTION_IDENTIFIER_FACTORY_H - -#include "cid.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * This class is used exclusively by the BS to allocate CIDs to new connections. - * This class uses the definitions from Table 345 in ieee-802.16-2004 to - * allocate cids in different integer ranges according to their type. - * The relative allocation of the ranges is controlled by the parameter 'm' - * introduced in the above-mentioned table. - * - * Note: The current implementation merely allocates cids sequentially from - * the start of the allowed range. A proper implementation would be able - * to recycle cids from previous dead connections and should instead look - * at a bitmap of free cids. Some other day :) - */ -class CidFactory -{ - public: - /** - * Create a cid factory with a default value for m of 0x5500. - */ - CidFactory(); - /** - * @brief This function returns the next basic CID. - * @returns the next basic CID. - */ - Cid AllocateBasic(); - /** - * @brief This function returns the next primary basic CID. - * @returns the next primary CID. - */ - Cid AllocatePrimary(); - /** - * @brief This function returns the next Transport (or Secondary) CID. - * @returns the next Transport (or Secondary) CID. - */ - Cid AllocateTransportOrSecondary(); - /** - * @brief This function returns the next Multicast CID. - * @returns the next Multicast CID. - */ - Cid AllocateMulticast(); - /** - * @brief This function returns the next CID for the specified type. - * @param type CID type - * @returns the next CID. - */ - Cid Allocate(Cid::Type type); - - /** - * @brief This function determines if the CID is a transport. - * @param cid CID type - * @returns true if the CID is a transport. - */ - bool IsTransport(Cid cid) const; - /** - * @brief This function determines if the CID is primary. - * @param cid CID type - * @returns true if the CID is primary. - */ - bool IsPrimary(Cid cid) const; - /** - * @brief This function determines if the CID is basic. - * @param cid CID type - * @returns true if the CID is basic. - */ - bool IsBasic(Cid cid) const; - - /** - * Notify the factory that the connection associated to this - * cid has been killed and that this cid can be reused. - * @param cid CID type - */ - void FreeCid(Cid cid); - - private: - uint16_t m_m; ///< m - - uint16_t m_basicIdentifier; ///< basic identifier - uint16_t m_primaryIdentifier; ///< primary identifier - uint16_t m_transportOrSecondaryIdentifier; ///< transport or secondary identifier - uint16_t m_multicastPollingIdentifier; ///< multicast polling identifier -}; - -} // namespace ns3 - -#endif /* CONNECTION_IDENTIFIER_FACTORY_H */ diff --git a/src/wimax/model/cid.cc b/src/wimax/model/cid.cc deleted file mode 100644 index 7b1c1a9b7..000000000 --- a/src/wimax/model/cid.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "cid.h" - -// 0 will match IR CID, -1 will match broadcast CID 0xFFFF, hence 60000 -#define CID_UNINITIALIZED 60000 - -namespace ns3 -{ - -Cid::Cid() -{ - m_identifier = CID_UNINITIALIZED; -} - -Cid::Cid(uint16_t identifier) -{ - m_identifier = identifier; -} - -Cid::~Cid() -{ -} - -uint16_t -Cid::GetIdentifier() const -{ - return m_identifier; -} - -bool -Cid::IsMulticast() const -{ - return m_identifier >= 0xff00 && m_identifier <= 0xfffd; -} - -bool -Cid::IsBroadcast() const -{ - return *this == Broadcast(); -} - -bool -Cid::IsPadding() const -{ - return *this == Padding(); -} - -bool -Cid::IsInitialRanging() const -{ - return *this == InitialRanging(); -} - -Cid -Cid::Broadcast() -{ - return 0xffff; -} - -Cid -Cid::Padding() -{ - return 0xfffe; -} - -Cid -Cid::InitialRanging() -{ - return 0; -} - -/** - * @brief equality operator - * @param lhs left hand side - * @param rhs right hand side - * @returns true if equal - */ -bool -operator==(const Cid& lhs, const Cid& rhs) -{ - return lhs.m_identifier == rhs.m_identifier; -} - -/** - * @brief inequality operator - * @param lhs left hand side - * @param rhs right hand side - * @returns true if not equal - */ -bool -operator!=(const Cid& lhs, const Cid& rhs) -{ - return !(lhs == rhs); -} - -/** - * @brief output stream output operator - * @param os output stream - * @param cid CID - * @returns output stream - */ -std::ostream& -operator<<(std::ostream& os, const Cid& cid) -{ - os << cid.GetIdentifier(); - return os; -} - -} // namespace ns3 diff --git a/src/wimax/model/cid.h b/src/wimax/model/cid.h deleted file mode 100644 index 4b4c692e9..000000000 --- a/src/wimax/model/cid.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#ifndef CID_H -#define CID_H - -#include -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * @class Cid - * @brief Cid class - */ -class Cid -{ - public: - /// Type enumeration - enum Type - { - BROADCAST = 1, - INITIAL_RANGING, - BASIC, - PRIMARY, - TRANSPORT, - MULTICAST, - PADDING - }; - - /// Create a cid of unknown type - Cid(); - /** - * Constructor - * - * @param cid - */ - Cid(uint16_t cid); - ~Cid(); - /** - * @return the identifier of the cid - */ - uint16_t GetIdentifier() const; - /** - * @return true if the cid is a multicast cid, false otherwise - */ - bool IsMulticast() const; - /** - * @return true if the cid is a broadcast cid, false otherwise - */ - bool IsBroadcast() const; - /** - * @return true if the cid is a padding cid, false otherwise - */ - bool IsPadding() const; - /** - * @return true if the cid is an initial ranging cid, false otherwise - */ - bool IsInitialRanging() const; - /** - * @return the broadcast cid - */ - static Cid Broadcast(); - /** - * @return the padding cid - */ - static Cid Padding(); - /** - * @return the initial ranging cid - */ - static Cid InitialRanging(); - - private: - /// allow CidFactory class friend access - friend class CidFactory; - /// equality operator - friend bool operator==(const Cid& lhs, const Cid& rhs); - uint16_t m_identifier; ///< identiifier -}; - -bool operator==(const Cid& lhs, const Cid& rhs); -bool operator!=(const Cid& lhs, const Cid& rhs); - -std::ostream& operator<<(std::ostream& os, const Cid& cid); - -} // namespace ns3 - -#endif /* CID_H */ diff --git a/src/wimax/model/connection-manager.cc b/src/wimax/model/connection-manager.cc deleted file mode 100644 index e65cca4b1..000000000 --- a/src/wimax/model/connection-manager.cc +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "connection-manager.h" - -#include "bs-net-device.h" -#include "cid-factory.h" -#include "mac-messages.h" -#include "service-flow.h" -#include "ss-net-device.h" -#include "ss-record.h" - -#include "ns3/enum.h" -#include "ns3/log.h" -#include "ns3/pointer.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("ConnectionManager"); - -NS_OBJECT_ENSURE_REGISTERED(ConnectionManager); - -TypeId -ConnectionManager::GetTypeId() -{ - static TypeId tid = TypeId("ns3::ConnectionManager").SetParent().SetGroupName("Wimax"); - return tid; -} - -ConnectionManager::ConnectionManager() - : m_cidFactory(nullptr) -{ -} - -void -ConnectionManager::DoDispose() -{ -} - -ConnectionManager::~ConnectionManager() -{ -} - -void -ConnectionManager::SetCidFactory(CidFactory* cidFactory) -{ - m_cidFactory = cidFactory; -} - -void -ConnectionManager::AllocateManagementConnections(SSRecord* ssRecord, RngRsp* rngrsp) -{ - Ptr basicConnection = CreateConnection(Cid::BASIC); - ssRecord->SetBasicCid(basicConnection->GetCid()); - - Ptr primaryConnection = CreateConnection(Cid::PRIMARY); - ssRecord->SetPrimaryCid(primaryConnection->GetCid()); - - rngrsp->SetBasicCid(basicConnection->GetCid()); - rngrsp->SetPrimaryCid(primaryConnection->GetCid()); -} - -Ptr -ConnectionManager::CreateConnection(Cid::Type type) -{ - Cid cid; - switch (type) - { - case Cid::BASIC: - case Cid::MULTICAST: - case Cid::PRIMARY: - cid = m_cidFactory->Allocate(type); - break; - case Cid::TRANSPORT: - cid = m_cidFactory->AllocateTransportOrSecondary(); - break; - default: - NS_FATAL_ERROR("Invalid connection type"); - break; - } - Ptr connection = CreateObject(cid, type); - AddConnection(connection, type); - return connection; -} - -void -ConnectionManager::AddConnection(Ptr connection, Cid::Type type) -{ - switch (type) - { - case Cid::BASIC: - m_basicConnections.push_back(connection); - break; - case Cid::PRIMARY: - m_primaryConnections.push_back(connection); - break; - case Cid::TRANSPORT: - m_transportConnections.push_back(connection); - break; - case Cid::MULTICAST: - m_multicastConnections.push_back(connection); - break; - default: - NS_FATAL_ERROR("Invalid connection type"); - break; - } -} - -Ptr -ConnectionManager::GetConnection(Cid cid) -{ - for (auto iter = m_basicConnections.begin(); iter != m_basicConnections.end(); ++iter) - { - if ((*iter)->GetCid() == cid) - { - return *iter; - } - } - - for (auto iter = m_primaryConnections.begin(); iter != m_primaryConnections.end(); ++iter) - { - if ((*iter)->GetCid() == cid) - { - return *iter; - } - } - - for (auto iter = m_transportConnections.begin(); iter != m_transportConnections.end(); ++iter) - { - if ((*iter)->GetCid() == cid) - { - return *iter; - } - } - - return nullptr; -} - -std::vector> -ConnectionManager::GetConnections(Cid::Type type) const -{ - std::vector> connections; - - switch (type) - { - case Cid::BASIC: - connections = m_basicConnections; - break; - case Cid::PRIMARY: - connections = m_primaryConnections; - break; - case Cid::TRANSPORT: - connections = m_transportConnections; - break; - default: - NS_FATAL_ERROR("Invalid connection type"); - break; - } - - return connections; -} - -uint32_t -ConnectionManager::GetNPackets(Cid::Type type, ServiceFlow::SchedulingType schedulingType) const -{ - uint32_t nrPackets = 0; - - switch (type) - { - case Cid::BASIC: { - for (auto iter = m_basicConnections.begin(); iter != m_basicConnections.end(); ++iter) - { - nrPackets += (*iter)->GetQueue()->GetSize(); - } - break; - } - case Cid::PRIMARY: { - for (auto iter = m_primaryConnections.begin(); iter != m_primaryConnections.end(); ++iter) - { - nrPackets += (*iter)->GetQueue()->GetSize(); - } - break; - } - case Cid::TRANSPORT: { - for (auto iter = m_transportConnections.begin(); iter != m_transportConnections.end(); - ++iter) - { - if (schedulingType == ServiceFlow::SF_TYPE_ALL || - (*iter)->GetSchedulingType() == schedulingType) - { - nrPackets += (*iter)->GetQueue()->GetSize(); - } - } - break; - } - default: - NS_FATAL_ERROR("Invalid connection type"); - break; - } - - return nrPackets; -} - -bool -ConnectionManager::HasPackets() const -{ - for (auto iter = m_basicConnections.begin(); iter != m_basicConnections.end(); ++iter) - { - if ((*iter)->HasPackets()) - { - return true; - } - } - - for (auto iter = m_primaryConnections.begin(); iter != m_primaryConnections.end(); ++iter) - { - if ((*iter)->HasPackets()) - { - return true; - } - } - - for (auto iter = m_transportConnections.begin(); iter != m_transportConnections.end(); ++iter) - { - if ((*iter)->HasPackets()) - { - return true; - } - } - - return false; -} -} // namespace ns3 diff --git a/src/wimax/model/connection-manager.h b/src/wimax/model/connection-manager.h deleted file mode 100644 index 7c55f0c52..000000000 --- a/src/wimax/model/connection-manager.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#ifndef CONNECTION_MANAGER_H -#define CONNECTION_MANAGER_H - -#include "cid.h" -#include "wimax-connection.h" - -#include "ns3/mac48-address.h" - -#include - -namespace ns3 -{ - -class CidFactory; -class SSRecord; -class RngRsp; -class WimaxNetDevice; -class SubscriberStationNetDevice; - -/** - * @ingroup wimax - * The same connection manager class serves both for BS and SS though some functions are exclusive - * to only one of them. - */ - -class ConnectionManager : public Object -{ - public: - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - ConnectionManager(); - ~ConnectionManager() override; - void DoDispose() override; - /** - * Set CID factory - * @param cidFactory the CID factory - */ - void SetCidFactory(CidFactory* cidFactory); - /** - * @brief allocates the management connection for an ss record. This method is only used by BS - * @param ssRecord the ss record to which the management connection will be allocated - * @param rngrsp the ranging response message - */ - void AllocateManagementConnections(SSRecord* ssRecord, RngRsp* rngrsp); - /** - * @brief create a connection of type type - * @param type type of the connection to create - * @return a smart pointer to the created WimaxConnection - */ - Ptr CreateConnection(Cid::Type type); - /** - * @brief add a connection to the list of managed connections - * @param connection the connection to add - * @param type the type of connection to add - */ - void AddConnection(Ptr connection, Cid::Type type); - /** - * @param cid the connection identifier - * @return the connection corresponding to cid - */ - Ptr GetConnection(Cid cid); - /** - * @param type the type of connection to add - * @return a vector of all connections matching the input type - */ - std::vector> GetConnections(Cid::Type type) const; - /** - * @brief get number of packets - * @param type the type of connection to add - * @param schedulingType the scheduling type - * @returns number of packets - */ - uint32_t GetNPackets(Cid::Type type, ServiceFlow::SchedulingType schedulingType) const; - /** - * @return true if one of the managed connection has at least one packet to send, false - * otherwise - */ - bool HasPackets() const; - - private: - std::vector> m_basicConnections; ///< basic connections - std::vector> m_primaryConnections; ///< primary connections - std::vector> m_transportConnections; ///< transport connections - std::vector> m_multicastConnections; ///< multicast connections - // only for BS - CidFactory* m_cidFactory; ///< the factory -}; - -} // namespace ns3 - -#endif /* CONNECTION_MANAGER_H */ diff --git a/src/wimax/model/crc8.cc b/src/wimax/model/crc8.cc deleted file mode 100644 index 23ee7c155..000000000 --- a/src/wimax/model/crc8.cc +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ -#include - -namespace ns3 -{ - -/* - * CRC8 table on the polynomial: - * x^8 + x^2 + x^1 + x^0 - */ - -/// crc8 table -static uint8_t crc8table[256] = { - 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D, - 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D, - 0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD, - 0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD, - 0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA, - 0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A, - 0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A, - 0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A, - 0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4, - 0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4, - 0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44, - 0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34, - 0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63, - 0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13, - 0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83, - 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3, -}; - -uint8_t -CRC8Calculate(const uint8_t* data, int length) -{ - uint8_t crc = 0; - for (int i = 0; i < length; i++) - { - crc = crc8table[data[i] ^ crc]; - } - return crc; -} - -} // namespace ns3 diff --git a/src/wimax/model/crc8.h b/src/wimax/model/crc8.h deleted file mode 100644 index 05442d840..000000000 --- a/src/wimax/model/crc8.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ -#ifndef CRC8_H -#define CRC8_H -#include - -namespace ns3 -{ - -/** - * @param data buffer to calculate the checksum for - * @param length the length of the buffer (bytes) - * @returns the computed crc. - * - */ -uint8_t CRC8Calculate(const uint8_t* data, int length); - -} // namespace ns3 - -#endif diff --git a/src/wimax/model/cs-parameters.cc b/src/wimax/model/cs-parameters.cc deleted file mode 100644 index d56b295cf..000000000 --- a/src/wimax/model/cs-parameters.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - * - */ -#include "cs-parameters.h" - -#include "wimax-tlv.h" - -namespace ns3 -{ -CsParameters::CsParameters() -{ - m_classifierDscAction = CsParameters::ADD; -} - -CsParameters::~CsParameters() -{ -} - -CsParameters::CsParameters(Tlv tlv) -{ - NS_ASSERT_MSG(tlv.GetType() == SfVectorTlvValue::IPV4_CS_Parameters, "Invalid TLV"); - CsParamVectorTlvValue* param = ((CsParamVectorTlvValue*)(tlv.PeekValue())); - - for (auto iter = param->Begin(); iter != param->End(); ++iter) - { - switch ((*iter)->GetType()) - { - case CsParamVectorTlvValue::Classifier_DSC_Action: { - m_classifierDscAction = - (CsParameters::Action)((U8TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case CsParamVectorTlvValue::Packet_Classification_Rule: { - m_packetClassifierRule = IpcsClassifierRecord(*(*iter)); - break; - } - } - } -} - -CsParameters::CsParameters(CsParameters::Action classifierDscAction, - IpcsClassifierRecord classifier) -{ - m_classifierDscAction = classifierDscAction; - m_packetClassifierRule = classifier; -} - -void -CsParameters::SetClassifierDscAction(CsParameters::Action action) -{ - m_classifierDscAction = action; -} - -void -CsParameters::SetPacketClassifierRule(IpcsClassifierRecord packetClassifierRule) -{ - m_packetClassifierRule = packetClassifierRule; -} - -CsParameters::Action -CsParameters::GetClassifierDscAction() const -{ - return m_classifierDscAction; -} - -IpcsClassifierRecord -CsParameters::GetPacketClassifierRule() const -{ - return m_packetClassifierRule; -} - -Tlv -CsParameters::ToTlv() const -{ - CsParamVectorTlvValue tmp; - tmp.Add( - Tlv(CsParamVectorTlvValue::Classifier_DSC_Action, 1, U8TlvValue(m_classifierDscAction))); - tmp.Add(m_packetClassifierRule.ToTlv()); - return Tlv(SfVectorTlvValue::IPV4_CS_Parameters, tmp.GetSerializedSize(), tmp); -} -} // namespace ns3 diff --git a/src/wimax/model/cs-parameters.h b/src/wimax/model/cs-parameters.h deleted file mode 100644 index 796a6a235..000000000 --- a/src/wimax/model/cs-parameters.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - * - * - */ - -#ifndef WIMAX_CS_PARAMETERS_H -#define WIMAX_CS_PARAMETERS_H - -#include "ipcs-classifier-record.h" -#include "wimax-tlv.h" - -namespace ns3 -{ - -/** - * @ingroup wimax - * @brief CsParameters class - */ -class CsParameters -{ - public: - /// Action enumeration - enum Action - { - ADD = 0, - REPLACE = 1, - DELETE = 2 - }; - - CsParameters(); - ~CsParameters(); - /** - * @brief creates a convergence sub-layer parameters from a tlv - * @param tlv the TLV - */ - CsParameters(Tlv tlv); - /** - * @brief creates a convergence sub-layer parameters from an ipcs classifier record - * @param classifierDscAction the DCS action type - * @param classifier the IPCS classifier record - */ - CsParameters(Action classifierDscAction, IpcsClassifierRecord classifier); - /** - * @brief sets the dynamic service classifier action to ADD, Change or delete. Only ADD is - * supported - * @param action the action enumeration - */ - void SetClassifierDscAction(Action action); - /** - * @brief sets the packet classifier rules - * @param packetClassifierRule the IPCS classifier record - */ - void SetPacketClassifierRule(IpcsClassifierRecord packetClassifierRule); - /** - * @return the dynamic service classifier action - */ - Action GetClassifierDscAction() const; - /** - * @return the the packet classifier rules - */ - IpcsClassifierRecord GetPacketClassifierRule() const; - /** - * @brief creates a tlv from the classifier record - * @return the created tlv - */ - Tlv ToTlv() const; - - private: - Action m_classifierDscAction; ///< classifier DSC action - IpcsClassifierRecord m_packetClassifierRule; ///< packet classifier rule -}; - -} // namespace ns3 -#endif /* WIMAX_CS_PARAMETERS_H */ diff --git a/src/wimax/model/default-traces.h b/src/wimax/model/default-traces.h deleted file mode 100644 index 7a1c64e34..000000000 --- a/src/wimax/model/default-traces.h +++ /dev/null @@ -1,1183 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -#ifndef WIMAX_DEFAULT_TRACES_H -#define WIMAX_DEFAULT_TRACES_H - -namespace ns3 -{ - -/** - * @brief These represent default traces, providing a number of - * parameters for each SNR value. - * - * The parameters provided are (in order): - * - * -# The SNR value, - * -# The bit error rate BER, - * -# The block error rate BlcERm, - * -# The standard deviation on block error rate, - * -# The lower bound confidence interval for a given modulation, and - * -# The upper bound confidence interval for a given modulation. - * - * It is made of 7 tables: one for each modulation and coding scheme. - * Each table is made of 6 columns, as listed above. - * - * These traces are generated by an external OFDM simulator: It is based - * on an external mathematics and signal processing library IT++ and includes: - * - * * A random block generator, - * * A Reed Solomon (RS) coder, - * * A convolutional coder, - * * an interleaver, - * * A 256 FFT-based OFDM modulator, - * * A multi-path channel simulator, and - * * An equalizer. - * - * The multipath channel is simulated using the TDL_channel class of - * the IT++ library. - * - * - * The file format should be as follows - * - * SNR_value1 BER Blc_ER STANDARD_DEVIATION CONFIDENCE_INTERVAL1 CONFIDENCE_INTERVAL2 - * SNR_value2 BER Blc_ER STANDARD_DEVIATION CONFIDENCE_INTERVAL1 CONFIDENCE_INTERVAL2 - * ... ... ... ... ... ... - * - * - * Additional notes: from Esteban Municio - * - * This trace file has been edited for the 16 QAM 3/4 modulation (modulation4) since the original - * SNR traces for this modulation were not long enough, giving inflated BER and BLER figures for - * typical SNR values. Due to the impossibility to get the original IT++ environment used for the - * original traces by the previous authors, the traces of modulation4 have been generated using a - * simple IT++ program simulating the theoretical model of a AWGN channel given - * BER=3/2*erfc(sqrt(k*0.1*(Eb_N0_dB))); - * - * @relates ns3::SNRToBlockErrorRateManager - * @hideinitializer - * @{ - */ - -static const double modulation0[6][29] = { - - {0.00, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.00, 1.10, 1.20, 1.30, 1.40, - 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.10, 2.20, 2.30, 2.40, 2.50, 2.60, 2.70, 2.80}, - - {0.50798, 0.50862, 0.50517, 0.49325, 0.45741, 0.39430, 0.30345, 0.20492, 0.12126, 0.06741, - 0.03429, 0.01710, 0.00865, 0.00419, 0.00223, 0.00098, 0.00065, 0.00028, 0.00013, 0.00006, - 0.00005, 0.00001, 0.00002, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000}, - - {1.00000, 1.00000, 1.00000, 1.00000, 0.99870, 0.98730, 0.93240, 0.81330, 0.62730, 0.45400, - 0.29000, 0.17620, 0.09950, 0.05670, 0.03350, 0.01640, 0.01120, 0.00520, 0.00320, 0.00160, - 0.00110, 0.00060, 0.00040, 0.00010, 0.00010, 0.00010, 0.00000, 0.00000, 0.00000}, - - {0.00000, 0.00000, 0.00000, 0.00000, 0.00130, 0.01254, 0.06303, 0.15184, 0.23380, 0.24788, - 0.20590, 0.14515, 0.08960, 0.05348, 0.03238, 0.01613, 0.01107, 0.00517, 0.00319, 0.00160, - 0.00110, 0.00020, 0.00060, 0.00000, 0.00010, 0.00010, 0.00000, 0.00000, 0.00000}, - - {1.00000, 1.00000, 1.00000, 1.00000, 0.99799, 0.98511, 0.92748, 0.80566, 0.61782, 0.44424, - 0.28111, 0.16873, 0.09363, 0.05217, 0.02997, 0.01391, 0.00914, 0.00379, 0.00209, 0.00082, - 0.00045, 0.00008, 0.00012, 0.00000, 0.00010, 0.00010, 0.00000, 0.00000, 0.00000}, - - {1.00000, 1.00000, 1.00000, 1.00000, 0.99941, 0.98950, 0.93732, 0.82094, 0.63678, 0.46376, - 0.29889, 0.18367, 0.10537, 0.06123, 0.03703, 0.01889, 0.01326, 0.00661, 0.00431, 0.00238, - 0.00175, 0.00048, 0.00108, 0.00000, 0.00030, 0.00030, 0.00000, 0.00000, 0.00000}, -}; - -static const double modulation1[6][42] = { - - {2.00, 2.10, 2.20, 2.30, 2.40, 2.50, 2.60, 2.70, 2.80, 2.90, 3.00, 3.10, 3.20, 3.30, - 3.40, 3.50, 3.60, 3.70, 3.80, 3.90, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50, 4.60, 4.70, - 4.80, 4.90, 5.00, 5.10, 5.20, 5.30, 5.40, 5.50, 5.60, 5.70, 5.80, 5.90, 6.00, 6.10}, - - {0.45604, 0.43627, 0.41185, 0.38360, 0.34393, 0.30548, 0.26033, 0.22148, 0.18646, - 0.14898, 0.11921, 0.09493, 0.07055, 0.05625, 0.04178, 0.03245, 0.02613, 0.01733, - 0.01415, 0.01151, 0.00834, 0.00506, 0.00450, 0.00349, 0.00213, 0.00158, 0.00162, - 0.00078, 0.00070, 0.00039, 0.00039, 0.00059, 0.00049, 0.00005, 0.00015, 0.00010, - 0.00000, 0.00029, 0.00005, 0.00000, 0.00005, 0.00000}, - - {0.95150, 0.91120, 0.86240, 0.80300, 0.72060, 0.64010, 0.54740, 0.46440, 0.39190, - 0.31310, 0.25110, 0.19930, 0.14830, 0.11820, 0.08800, 0.06890, 0.05520, 0.03650, - 0.02980, 0.02440, 0.01770, 0.01090, 0.00920, 0.00730, 0.00460, 0.00340, 0.00340, - 0.00160, 0.00160, 0.00150, 0.00140, 0.00120, 0.00100, 0.00090, 0.00060, 0.00040, - 0.00020, 0.00010, 0.00005, 0.00004, 0.00003, 0.00000}, - - {0.04615, 0.08092, 0.11867, 0.15819, 0.20134, 0.23037, 0.24775, 0.24873, 0.23831, - 0.21507, 0.18805, 0.15958, 0.12631, 0.10423, 0.08026, 0.06415, 0.05215, 0.03517, - 0.02891, 0.02380, 0.01739, 0.01078, 0.00911, 0.00725, 0.00458, 0.00339, 0.00339, - 0.00160, 0.00160, 0.00080, 0.00080, 0.00120, 0.00100, 0.00010, 0.00030, 0.00020, - 0.00000, 0.00060, 0.00010, 0.00000, 0.00010, 0.00000}, - - {0.94729, 0.90563, 0.85565, 0.79520, 0.71181, 0.63069, 0.53764, 0.45463, 0.38233, - 0.30401, 0.24260, 0.19147, 0.14133, 0.11187, 0.08245, 0.06394, 0.05072, 0.03282, - 0.02647, 0.02138, 0.01512, 0.00886, 0.00733, 0.00563, 0.00327, 0.00226, 0.00226, - 0.00082, 0.00082, 0.00025, 0.00025, 0.00052, 0.00038, 0.00010, 0.00004, 0.00008, - 0.00000, 0.00012, 0.00010, 0.00000, 0.00010, 0.00000}, - - {0.95571, 0.91678, 0.86915, 0.81080, 0.72940, 0.64951, 0.55716, 0.47418, 0.40147, - 0.32219, 0.25960, 0.20713, 0.15527, 0.12453, 0.09355, 0.07386, 0.05968, 0.04018, - 0.03313, 0.02742, 0.02028, 0.01294, 0.01107, 0.00897, 0.00593, 0.00454, 0.00454, - 0.00238, 0.00238, 0.00135, 0.00135, 0.00188, 0.00162, 0.00030, 0.00064, 0.00048, - 0.00000, 0.00108, 0.00030, 0.00000, 0.00030, 0.00000}, -}; - -static const double modulation2[6][96] = { - - {3.00, 3.10, 3.20, 3.30, 3.40, 3.50, 3.60, 3.70, 3.80, 3.90, 4.00, 4.10, - 4.20, 4.30, 4.40, 4.50, 4.60, 4.70, 4.80, 4.90, 5.00, 5.10, 5.20, 5.30, - 5.40, 5.50, 5.60, 5.70, 5.80, 5.90, 6.00, 6.10, 6.20, 6.30, 6.40, 6.50, - 6.60, 6.70, 6.80, 6.90, 7.00, 7.10, 7.20, 7.30, 7.40, 7.50, 7.60, 7.70, - 7.80, 7.90, 8.00, 8.10, 8.20, 8.30, 8.40, 8.50, 8.60, 8.70, 8.80, 8.90, - 9.00, 9.10, 9.20, 9.30, 9.40, 9.50, 9.60, 9.70, 9.80, 9.90, 10.00, 10.10, - 10.20, 10.30, 10.40, 10.50, 10.60, 10.70, 10.80, 10.90, 11.00, 11.10, 11.20, 11.30, - 11.40, 11.50, 11.60, 11.70, 11.80, 11.90, 12.00, 12.10, 12.20, 12.30, 12.40, 12.50}, - - {0.36630, 0.35317, 0.34175, 0.33351, 0.31776, 0.30292, 0.28624, 0.27526, 0.26174, 0.24856, - 0.23007, 0.21865, 0.19945, 0.18414, 0.16967, 0.15747, 0.14530, 0.13298, 0.11771, 0.11115, - 0.09713, 0.09123, 0.08231, 0.07267, 0.06616, 0.05673, 0.05156, 0.04577, 0.04282, 0.03866, - 0.03513, 0.02856, 0.02680, 0.02406, 0.01948, 0.01927, 0.01580, 0.01473, 0.01292, 0.01266, - 0.01108, 0.00937, 0.00735, 0.00675, 0.00582, 0.00612, 0.00496, 0.00471, 0.00386, 0.00412, - 0.00333, 0.00387, 0.00234, 0.00257, 0.00204, 0.00161, 0.00179, 0.00128, 0.00114, 0.00136, - 0.00102, 0.00133, 0.00087, 0.00066, 0.00075, 0.00066, 0.00069, 0.00041, 0.00051, 0.00035, - 0.00033, 0.00034, 0.00025, 0.00033, 0.00038, 0.00036, 0.00012, 0.00005, 0.00024, 0.00015, - 0.00010, 0.00000, 0.00011, 0.00001, 0.00024, 0.00001, 0.00001, 0.00005, 0.00001, 0.00005, - 0.00010, 0.00005, 0.00009, 0.00000, 0.00000, 0.00000}, - - {0.99130, 0.98790, 0.97490, 0.96360, 0.94840, 0.92520, 0.89860, 0.87960, 0.84970, 0.81960, - 0.76860, 0.72540, 0.69130, 0.63620, 0.58540, 0.54710, 0.51010, 0.47450, 0.42570, 0.39700, - 0.34730, 0.32840, 0.29360, 0.25990, 0.23970, 0.20910, 0.18810, 0.16480, 0.15410, 0.14130, - 0.12570, 0.10670, 0.09940, 0.08810, 0.07330, 0.06930, 0.05720, 0.05530, 0.04630, 0.04460, - 0.04070, 0.03310, 0.02810, 0.02680, 0.02290, 0.02260, 0.01700, 0.01740, 0.01320, 0.01490, - 0.01210, 0.01320, 0.00820, 0.00850, 0.00840, 0.00640, 0.00590, 0.00480, 0.00450, 0.00490, - 0.00410, 0.00420, 0.00340, 0.00250, 0.00240, 0.00240, 0.00210, 0.00190, 0.00160, 0.00140, - 0.00120, 0.00110, 0.00100, 0.00100, 0.00100, 0.00100, 0.00080, 0.00070, 0.00050, 0.00050, - 0.00040, 0.00040, 0.00030, 0.00030, 0.00020, 0.00020, 0.00010, 0.00008, 0.00007, 0.00005, - 0.00004, 0.00003, 0.00003, 0.00003, 0.00002, 0.00000}, - - {0.00862, 0.01195, 0.02447, 0.03508, 0.04894, 0.06921, 0.09112, 0.10590, 0.12771, 0.14786, - 0.17785, 0.19920, 0.21340, 0.23145, 0.24271, 0.24778, 0.24990, 0.24935, 0.24448, 0.23939, - 0.22668, 0.22055, 0.20740, 0.19235, 0.18224, 0.16538, 0.15272, 0.13764, 0.13035, 0.12133, - 0.10990, 0.09531, 0.08952, 0.08034, 0.06793, 0.06450, 0.05393, 0.05224, 0.04416, 0.04261, - 0.03904, 0.03200, 0.02731, 0.02608, 0.02238, 0.02209, 0.01671, 0.01710, 0.01303, 0.01468, - 0.01195, 0.01303, 0.00813, 0.00843, 0.00833, 0.00636, 0.00587, 0.00478, 0.00448, 0.00488, - 0.00408, 0.00418, 0.00339, 0.00230, 0.00239, 0.00239, 0.00210, 0.00110, 0.00190, 0.00120, - 0.00160, 0.00100, 0.00110, 0.00150, 0.00100, 0.00120, 0.00070, 0.00020, 0.00080, 0.00050, - 0.00030, 0.00000, 0.00050, 0.00010, 0.00050, 0.00010, 0.00010, 0.00010, 0.00020, 0.00020, - 0.00030, 0.00010, 0.00020, 0.00000, 0.00000, 0.00000}, - - {0.98948, 0.98576, 0.97183, 0.95993, 0.94406, 0.92004, 0.89268, 0.87322, 0.84270, 0.81206, - 0.76033, 0.71665, 0.68225, 0.62677, 0.57574, 0.53734, 0.50030, 0.46471, 0.41601, 0.38741, - 0.33797, 0.31920, 0.28467, 0.25130, 0.23133, 0.20113, 0.18044, 0.15753, 0.14702, 0.13447, - 0.11920, 0.10065, 0.09354, 0.08254, 0.06819, 0.06432, 0.05265, 0.05082, 0.04218, 0.04055, - 0.03683, 0.02959, 0.02486, 0.02363, 0.01997, 0.01969, 0.01447, 0.01484, 0.01096, 0.01252, - 0.00996, 0.01096, 0.00643, 0.00670, 0.00661, 0.00484, 0.00440, 0.00345, 0.00319, 0.00353, - 0.00285, 0.00293, 0.00226, 0.00136, 0.00144, 0.00144, 0.00120, 0.00045, 0.00105, 0.00052, - 0.00082, 0.00038, 0.00045, 0.00074, 0.00038, 0.00052, 0.00018, 0.00008, 0.00025, 0.00006, - 0.00004, 0.00000, 0.00006, 0.00010, 0.00006, 0.00010, 0.00010, 0.00010, 0.00008, 0.00008, - 0.00004, 0.00010, 0.00008, 0.00000, 0.00000, 0.00000}, - - {0.99312, 0.99004, 0.97797, 0.96727, 0.95274, 0.93036, 0.90452, 0.88598, 0.85670, 0.82714, - 0.77687, 0.73415, 0.70035, 0.64563, 0.59506, 0.55686, 0.51990, 0.48429, 0.43539, 0.40659, - 0.35663, 0.33760, 0.30253, 0.26850, 0.24807, 0.21707, 0.19576, 0.17207, 0.16118, 0.14813, - 0.13220, 0.11275, 0.10526, 0.09366, 0.07841, 0.07428, 0.06175, 0.05978, 0.05042, 0.04865, - 0.04457, 0.03661, 0.03134, 0.02996, 0.02583, 0.02551, 0.01953, 0.01996, 0.01544, 0.01727, - 0.01424, 0.01544, 0.00997, 0.01030, 0.01019, 0.00796, 0.00740, 0.00615, 0.00581, 0.00627, - 0.00535, 0.00547, 0.00454, 0.00324, 0.00336, 0.00336, 0.00300, 0.00175, 0.00275, 0.00188, - 0.00238, 0.00162, 0.00175, 0.00226, 0.00162, 0.00188, 0.00122, 0.00048, 0.00135, 0.00094, - 0.00064, 0.00000, 0.00094, 0.00030, 0.00094, 0.00030, 0.00030, 0.00030, 0.00048, 0.00048, - 0.00064, 0.00030, 0.00048, 0.00000, 0.00000, 0.00000}, -}; - -static const double modulation3[6][117] = { - - {10.00, 10.10, 10.20, 10.30, 10.40, 10.50, 10.60, 10.70, 10.80, 10.90, 11.00, 11.10, 11.20, - 11.30, 11.40, 11.50, 11.60, 11.70, 11.80, 11.90, 12.00, 12.10, 12.20, 12.30, 12.40, 12.50, - 12.60, 12.70, 12.80, 12.90, 13.00, 13.10, 13.20, 13.30, 13.40, 13.50, 13.60, 13.70, 13.80, - 13.90, 14.00, 14.10, 14.20, 14.30, 14.40, 14.50, 14.60, 14.70, 14.90, 15.00, 15.10, 15.20, - 15.30, 15.40, 15.50, 15.60, 15.70, 15.80, 15.90, 16.00, 16.10, 16.20, 16.30, 16.40, 16.50, - 16.60, 16.70, 16.80, 16.90, 17.10, 17.20, 17.30, 17.40, 17.50, 17.60, 17.70, 17.80, 17.90, - 18.00, 18.10, 18.20, 18.30, 18.40, 18.50, 18.60, 18.70, 18.80, 18.90, 19.00, 19.10, 19.20, - 19.30, 19.40, 19.50, 19.60, 19.70, 19.80, 19.90, 20.00, 20.10, 20.20, 20.30, 20.40, 20.50, - 20.60, 20.70, 20.80, 20.90, 21.00, 21.10, 21.20, 21.30, 21.40, 21.50, 21.60, 21.70, 21.80}, - - {0.39109, 0.37994, 0.36904, 0.36186, 0.35172, 0.34069, 0.32445, 0.31707, 0.30757, 0.28951, - 0.27937, 0.26696, 0.25737, 0.24826, 0.23413, 0.22045, 0.21144, 0.20244, 0.19049, 0.17783, - 0.16793, 0.15746, 0.14697, 0.13387, 0.12757, 0.12354, 0.11370, 0.10474, 0.09701, 0.09219, - 0.08535, 0.07516, 0.07240, 0.06492, 0.06394, 0.05577, 0.05399, 0.05040, 0.04632, 0.04287, - 0.03918, 0.03327, 0.03376, 0.02855, 0.02791, 0.02417, 0.02412, 0.02111, 0.01801, 0.01482, - 0.01486, 0.01324, 0.01167, 0.01137, 0.01127, 0.00911, 0.00930, 0.00650, 0.00748, 0.00615, - 0.00610, 0.00487, 0.00492, 0.00364, 0.00448, 0.00477, 0.00231, 0.00295, 0.00256, 0.00266, - 0.00182, 0.00192, 0.00182, 0.00123, 0.00158, 0.00153, 0.00153, 0.00093, 0.00093, 0.00064, - 0.00064, 0.00059, 0.00069, 0.00034, 0.00034, 0.00054, 0.00039, 0.00010, 0.00025, 0.00049, - 0.00030, 0.00034, 0.00015, 0.00034, 0.00030, 0.00034, 0.00005, 0.00020, 0.00020, 0.00015, - 0.00010, 0.00010, 0.00010, 0.00010, 0.00010, 0.00020, 0.00000, 0.00005, 0.00000, 0.00005, - 0.00010, 0.00020, 0.00010, 0.00005, 0.00005, 0.00020, 0.00000}, - - {0.79460, 0.77200, 0.74980, 0.73520, 0.71470, 0.69220, 0.65920, 0.64420, 0.62490, 0.58830, - 0.56760, 0.54240, 0.52290, 0.50440, 0.47570, 0.44790, 0.42960, 0.41130, 0.38710, 0.36140, - 0.34120, 0.32000, 0.29860, 0.27200, 0.25920, 0.25100, 0.23100, 0.21280, 0.19710, 0.18730, - 0.17340, 0.15270, 0.14710, 0.13190, 0.12990, 0.11330, 0.10970, 0.10240, 0.09410, 0.08710, - 0.07960, 0.06760, 0.06860, 0.05800, 0.05670, 0.04910, 0.04900, 0.04290, 0.03660, 0.03010, - 0.03020, 0.02690, 0.02370, 0.02310, 0.02290, 0.01850, 0.01890, 0.01520, 0.01320, 0.01250, - 0.01240, 0.01000, 0.01000, 0.00940, 0.00910, 0.00970, 0.00700, 0.00600, 0.00520, 0.00540, - 0.00390, 0.00390, 0.00370, 0.00320, 0.00320, 0.00310, 0.00310, 0.00190, 0.00190, 0.00130, - 0.00130, 0.00120, 0.00140, 0.00090, 0.00080, 0.00070, 0.00070, 0.00070, 0.00060, 0.00060, - 0.00060, 0.00050, 0.00050, 0.00050, 0.00040, 0.00040, 0.00040, 0.00040, 0.00040, 0.00030, - 0.00020, 0.00020, 0.00020, 0.00020, 0.00020, 0.00015, 0.00014, 0.00013, 0.00012, 0.00011, - 0.00010, 0.00009, 0.00008, 0.00007, 0.00006, 0.00005, 0.00000}, - - {0.16321, 0.17602, 0.18760, 0.19468, 0.20390, 0.21306, 0.22465, 0.22921, 0.23440, 0.24220, - 0.24543, 0.24820, 0.24948, 0.24998, 0.24941, 0.24729, 0.24504, 0.24213, 0.23725, 0.23079, - 0.22478, 0.21760, 0.20944, 0.19802, 0.19201, 0.18800, 0.17764, 0.16752, 0.15825, 0.15222, - 0.14333, 0.12938, 0.12546, 0.11450, 0.11303, 0.10046, 0.09767, 0.09191, 0.08525, 0.07951, - 0.07326, 0.06303, 0.06389, 0.05464, 0.05348, 0.04669, 0.04660, 0.04106, 0.03526, 0.02919, - 0.02929, 0.02618, 0.02314, 0.02257, 0.02238, 0.01816, 0.01854, 0.01303, 0.01497, 0.01234, - 0.01225, 0.00980, 0.00990, 0.00734, 0.00902, 0.00961, 0.00468, 0.00596, 0.00517, 0.00537, - 0.00369, 0.00388, 0.00369, 0.00249, 0.00319, 0.00309, 0.00309, 0.00190, 0.00190, 0.00130, - 0.00130, 0.00120, 0.00140, 0.00070, 0.00070, 0.00110, 0.00080, 0.00020, 0.00050, 0.00100, - 0.00060, 0.00070, 0.00030, 0.00070, 0.00060, 0.00070, 0.00010, 0.00040, 0.00040, 0.00030, - 0.00020, 0.00020, 0.00020, 0.00020, 0.00020, 0.00040, 0.00000, 0.00010, 0.00000, 0.00010, - 0.00020, 0.00040, 0.00020, 0.00010, 0.00010, 0.00040, 0.00000}, - - {0.78668, 0.76378, 0.74131, 0.72655, 0.70585, 0.68315, 0.64991, 0.63482, 0.61541, 0.57865, - 0.55789, 0.53263, 0.51311, 0.49460, 0.46591, 0.43815, 0.41990, 0.40165, 0.37755, 0.35198, - 0.33191, 0.31086, 0.28963, 0.26328, 0.25061, 0.24250, 0.22274, 0.20478, 0.18930, 0.17965, - 0.16598, 0.14565, 0.14016, 0.12527, 0.12331, 0.10709, 0.10358, 0.09646, 0.08838, 0.08157, - 0.07429, 0.06268, 0.06365, 0.05342, 0.05217, 0.04487, 0.04477, 0.03893, 0.03292, 0.02675, - 0.02685, 0.02373, 0.02072, 0.02016, 0.01997, 0.01586, 0.01623, 0.01096, 0.01280, 0.01032, - 0.01023, 0.00796, 0.00805, 0.00572, 0.00724, 0.00778, 0.00336, 0.00449, 0.00379, 0.00396, - 0.00251, 0.00268, 0.00251, 0.00152, 0.00209, 0.00201, 0.00201, 0.00105, 0.00105, 0.00059, - 0.00059, 0.00052, 0.00067, 0.00018, 0.00018, 0.00045, 0.00025, 0.00008, 0.00006, 0.00038, - 0.00012, 0.00018, 0.00004, 0.00018, 0.00012, 0.00018, 0.00010, 0.00001, 0.00001, 0.00004, - 0.00008, 0.00008, 0.00008, 0.00008, 0.00008, 0.00001, 0.00000, 0.00010, 0.00000, 0.00010, - 0.00008, 0.00001, 0.00008, 0.00010, 0.00010, 0.00001, 0.00000}, - - {0.80252, 0.78022, 0.75829, 0.74385, 0.72355, 0.70125, 0.66849, 0.65358, 0.63439, 0.59795, - 0.57731, 0.55217, 0.53269, 0.51420, 0.48549, 0.45765, 0.43930, 0.42095, 0.39665, 0.37082, - 0.35049, 0.32914, 0.30757, 0.28072, 0.26779, 0.25950, 0.23926, 0.22082, 0.20490, 0.19495, - 0.18082, 0.15975, 0.15404, 0.13853, 0.13649, 0.11951, 0.11582, 0.10834, 0.09982, 0.09263, - 0.08490, 0.07252, 0.07355, 0.06258, 0.06123, 0.05334, 0.05323, 0.04687, 0.04028, 0.03345, - 0.03355, 0.03007, 0.02668, 0.02604, 0.02583, 0.02114, 0.02157, 0.01544, 0.01760, 0.01468, - 0.01457, 0.01184, 0.01195, 0.00908, 0.01096, 0.01162, 0.00604, 0.00751, 0.00661, 0.00684, - 0.00489, 0.00512, 0.00489, 0.00348, 0.00431, 0.00419, 0.00419, 0.00275, 0.00275, 0.00201, - 0.00201, 0.00188, 0.00213, 0.00122, 0.00122, 0.00175, 0.00135, 0.00048, 0.00094, 0.00162, - 0.00108, 0.00122, 0.00064, 0.00122, 0.00108, 0.00122, 0.00030, 0.00079, 0.00079, 0.00064, - 0.00048, 0.00048, 0.00048, 0.00048, 0.00048, 0.00079, 0.00000, 0.00030, 0.00000, 0.00030, - 0.00048, 0.00079, 0.00048, 0.00030, 0.00030, 0.00079, 0.00000}, -}; - -static const double modulation4[6][331] = { - - {20, 20.1, 20.2, 20.3, 20.4, 20.5, 20.6, 20.7, 20.8, 20.9, 21, 21.1, 21.2, 21.3, 21.4, 21.5, - 21.6, 21.7, 21.8, 21.9, 22, 22.1, 22.2, 22.3, 22.4, 22.5, 22.6, 22.7, 22.8, 22.9, 23, 23.1, - 23.2, 23.3, 23.4, 23.5, 23.6, 23.7, 23.8, 23.9, 24, 24.1, 24.2, 24.3, 24.4, 24.5, 24.6, 24.7, - 24.8, 24.9, 25, 25.1, 25.2, 25.3, 25.4, 25.5, 25.6, 25.7, 25.8, 25.9, 26, 26.1, 26.2, 26.3, - 26.4, 26.5, 26.6, 26.7, 26.8, 26.9, 27, 27.1, 27.2, 27.3, 27.4, 27.5, 27.6, 27.7, 27.8, 27.9, - 28, 28.1, 28.2, 28.3, 28.4, 28.5, 28.6, 28.7, 28.8, 28.9, 29, 29.1, 29.2, 29.3, 29.4, 29.5, - 29.6, 29.7, 29.8, 29.9, 30, 30.1, 30.2, 30.3, 30.4, 30.5, 30.6, 30.7, 30.8, 30.9, 31, 31.1, - 31.2, 31.3, 31.4, 31.5, 31.6, 31.7, 31.8, 31.9, 32, 32.1, 32.2, 32.3, 32.4, 32.5, 32.6, 32.7, - 32.8, 32.9, 33, 33.1, 33.2, 33.3, 33.4, 33.5, 33.6, 33.7, 33.8, 33.9, 34, 34.1, 34.2, 34.3, - 34.4, 34.5, 34.6, 34.7, 34.8, 34.9, 35, 35.1, 35.2, 35.3, 35.4, 35.5, 35.6, 35.7, 35.8, 35.9, - 36, 36.1, 36.2, 36.3, 36.4, 36.5, 36.6, 36.7, 36.8, 36.9, 37, 37.1, 37.2, 37.3, 37.4, 37.5, - 37.6, 37.7, 37.8, 37.9, 38, 38.1, 38.2, 38.3, 38.4, 38.5, 38.6, 38.7, 38.8, 38.9, 39, 39.1, - 39.2, 39.3, 39.4, 39.5, 39.6, 39.7, 39.8, 39.9, 40, 40.1, 40.2, 40.3, 40.4, 40.5, 40.6, 40.7, - 40.8, 40.9, 41, 41.1, 41.2, 41.3, 41.4, 41.5, 41.6, 41.7, 41.8, 41.9, 42, 42.1, 42.2, 42.3, - 42.4, 42.5, 42.6, 42.7, 42.8, 42.9, 43, 43.1, 43.2, 43.3, 43.4, 43.5, 43.6, 43.7, 43.8, 43.9, - 44, 44.1, 44.2, 44.3, 44.4, 44.5, 44.6, 44.7, 44.8, 44.9, 45, 45.1, 45.2, 45.3, 45.4, 45.5, - 45.6, 45.7, 45.8, 45.9, 46, 46.1, 46.2, 46.3, 46.4, 46.5, 46.6, 46.7, 46.8, 46.9, 47, 47.1, - 47.2, 47.3, 47.4, 47.5, 47.6, 47.7, 47.8, 47.9, 48, 48.1, 48.2, 48.3, 48.4, 48.5, 48.6, 48.7, - 48.8, 48.9, 49, 49.1, 49.2, 49.3, 49.4, 49.5, 49.6, 49.7, 49.8, 49.9, 50, 50.1, 50.2, 50.3, - 50.4, 50.5, 50.6, 50.7, 50.8, 50.9, 51, 51.1, 51.2, 51.3, 51.4, 51.5, 51.6, 51.7, 51.8, 51.9, - 52, 52.1, 52.2, 52.3, 52.4, 52.5, 52.6, 52.7, 52.8, 52.9, 53}, - - {0.473383, 0.465027, 0.456673, 0.448325, 0.439984, 0.431653, 0.423335, 0.415032, 0.406746, - 0.398480, 0.390237, 0.382020, 0.373830, 0.365672, 0.357547, 0.349458, 0.341409, 0.333402, - 0.325439, 0.317525, 0.309662, 0.301852, 0.294099, 0.286406, 0.278776, 0.271211, 0.263714, - 0.256290, 0.248939, 0.241667, 0.234474, 0.227364, 0.220341, 0.213406, 0.206562, 0.199813, - 0.193161, 0.186608, 0.180156, 0.173809, 0.167569, 0.161438, 0.155418, 0.149511, 0.143719, - 0.138045, 0.132489, 0.127053, 0.121740, 0.116550, 0.111485, 0.106546, 0.101733, 0.097049, - 0.092492, 0.088064, 0.083766, 0.079597, 0.075558, 0.071648, 0.067867, 0.064215, 0.060691, - 0.057295, 0.054025, 0.050880, 0.047860, 0.044962, 0.042185, 0.039528, 0.036989, 0.034565, - 0.032255, 0.030056, 0.027965, 0.025981, 0.024101, 0.022322, 0.020641, 0.019055, 0.017561, - 0.016157, 0.014839, 0.013604, 0.012449, 0.011371, 0.010366, 0.009431, 0.008563, 0.007760, - 0.007017, 0.006331, 0.005700, 0.005120, 0.004589, 0.004103, 0.003660, 0.003256, 0.002890, - 0.002558, 0.002259, 0.001989, 0.001747, 0.001529, 0.001335, 0.001162, 0.001009, 0.000873, - 0.000753, 0.000647, 0.000555, 0.000474, 0.000403, 0.000342, 0.000289, 0.000243, 0.000204, - 0.000170, 0.000142, 0.000117, 0.000097, 0.000080, 0.000065, 0.000053, 0.000043, 0.000035, - 0.000028, 0.000022, 0.000018, 0.000014, 0.000011, 0.000009, 0.000007, 0.000005, 0.000004, - 0.000003, 0.000002, 0.000002, 0.000001, 0.000001, 0.000001, 0.000001, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000}, - - {0.899428, 0.883551, 0.867679, 0.851817, 0.835970, 0.820141, 0.804337, 0.788561, 0.772818, - 0.757113, 0.741451, 0.725838, 0.710278, 0.694776, 0.679339, 0.663970, 0.648677, 0.633463, - 0.618335, 0.603298, 0.588357, 0.573519, 0.558789, 0.544172, 0.529674, 0.515300, 0.501058, - 0.486950, 0.472985, 0.459166, 0.445500, 0.431992, 0.418647, 0.405471, 0.392468, 0.379645, - 0.367005, 0.354554, 0.342297, 0.330238, 0.318382, 0.306732, 0.295294, 0.284071, 0.273066, - 0.262285, 0.251729, 0.241402, 0.231306, 0.221446, 0.211822, 0.202437, 0.193293, 0.184392, - 0.175735, 0.167322, 0.159155, 0.151234, 0.143559, 0.136131, 0.128947, 0.122008, 0.115313, - 0.108860, 0.102647, 0.096672, 0.090933, 0.085428, 0.080152, 0.075104, 0.070279, 0.065674, - 0.061284, 0.057106, 0.053134, 0.049364, 0.045792, 0.042411, 0.039217, 0.036204, 0.033367, - 0.030699, 0.028194, 0.025848, 0.023653, 0.021604, 0.019695, 0.017919, 0.016271, 0.014743, - 0.013332, 0.012029, 0.010830, 0.009728, 0.008719, 0.007796, 0.006953, 0.006187, 0.005491, - 0.004861, 0.004292, 0.003779, 0.003318, 0.002906, 0.002537, 0.002209, 0.001917, 0.001659, - 0.001430, 0.001230, 0.001054, 0.000900, 0.000766, 0.000649, 0.000549, 0.000462, 0.000387, - 0.000324, 0.000269, 0.000223, 0.000184, 0.000151, 0.000124, 0.000101, 0.000082, 0.000066, - 0.000053, 0.000042, 0.000034, 0.000027, 0.000021, 0.000016, 0.000013, 0.000010, 0.000008, - 0.000006, 0.000004, 0.000003, 0.000003, 0.000002, 0.000001, 0.000001, 0.000001, 0.000001, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000}, - - {0.163210, 0.176020, 0.187600, 0.194680, 0.203900, 0.213060, 0.224650, 0.229210, 0.234400, - 0.242200, 0.245430, 0.248200, 0.249480, 0.249980, 0.249410, 0.247290, 0.245040, 0.242130, - 0.237250, 0.230790, 0.224780, 0.217600, 0.209440, 0.198020, 0.192010, 0.188000, 0.177640, - 0.167520, 0.158250, 0.152220, 0.143330, 0.129380, 0.125460, 0.114500, 0.113030, 0.100460, - 0.097670, 0.091910, 0.085250, 0.079510, 0.073260, 0.063030, 0.063890, 0.054640, 0.053480, - 0.046690, 0.046600, 0.041060, 0.035260, 0.029190, 0.029290, 0.026180, 0.023140, 0.022570, - 0.022380, 0.018160, 0.018540, 0.013030, 0.014970, 0.012340, 0.012250, 0.009800, 0.009900, - 0.007340, 0.009020, 0.009610, 0.004680, 0.005960, 0.005170, 0.005370, 0.003690, 0.003880, - 0.003690, 0.002490, 0.003190, 0.003090, 0.003090, 0.001900, 0.001900, 0.001300, 0.001300, - 0.001200, 0.001400, 0.000700, 0.000700, 0.001100, 0.000800, 0.000200, 0.000500, 0.001000, - 0.000600, 0.000700, 0.000300, 0.000700, 0.000600, 0.000700, 0.000100, 0.000400, 0.000400, - 0.000300, 0.000200, 0.000200, 0.000200, 0.000200, 0.000200, 0.000400, 0.000000, 0.000100, - 0.000000, 0.000100, 0.000200, 0.000400, 0.000200, 0.000100, 0.000100, 0.000400, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000}, - - {0.890434, 0.874715, 0.859002, 0.843299, 0.827610, 0.811940, 0.796293, 0.780675, 0.765089, - 0.749542, 0.734037, 0.718579, 0.703175, 0.687828, 0.672545, 0.657331, 0.642190, 0.627128, - 0.612151, 0.597265, 0.582474, 0.567784, 0.553201, 0.538730, 0.524377, 0.510147, 0.496047, - 0.482081, 0.468255, 0.454575, 0.441045, 0.427672, 0.414461, 0.401416, 0.388544, 0.375848, - 0.363335, 0.351009, 0.338874, 0.326936, 0.315198, 0.303665, 0.292341, 0.281230, 0.270336, - 0.259662, 0.249211, 0.238988, 0.228993, 0.219231, 0.209704, 0.200413, 0.191361, 0.182548, - 0.173977, 0.165649, 0.157564, 0.149722, 0.142124, 0.134769, 0.127658, 0.120788, 0.114160, - 0.107771, 0.101620, 0.095705, 0.090024, 0.084573, 0.079351, 0.074353, 0.069576, 0.065017, - 0.060671, 0.056535, 0.052603, 0.048871, 0.045334, 0.041987, 0.038825, 0.035842, 0.033033, - 0.030392, 0.027912, 0.025589, 0.023417, 0.021388, 0.019498, 0.017740, 0.016108, 0.014596, - 0.013198, 0.011909, 0.010722, 0.009631, 0.008632, 0.007718, 0.006884, 0.006125, 0.005436, - 0.004812, 0.004249, 0.003741, 0.003285, 0.002877, 0.002512, 0.002187, 0.001898, 0.001642, - 0.001416, 0.001218, 0.001043, 0.000891, 0.000758, 0.000643, 0.000543, 0.000457, 0.000384, - 0.000320, 0.000267, 0.000221, 0.000182, 0.000150, 0.000123, 0.000100, 0.000081, 0.000065, - 0.000052, 0.000042, 0.000033, 0.000026, 0.000021, 0.000016, 0.000013, 0.000010, 0.000008, - 0.000006, 0.000004, 0.000003, 0.000003, 0.000002, 0.000001, 0.000001, 0.000001, 0.000001, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000}, - - {0.908423, 0.892386, 0.876356, 0.860335, 0.844330, 0.828343, 0.812380, 0.796446, 0.780546, - 0.764684, 0.748866, 0.733096, 0.717380, 0.701724, 0.686132, 0.670610, 0.655163, 0.639798, - 0.624518, 0.609331, 0.594241, 0.579254, 0.564377, 0.549613, 0.534970, 0.520453, 0.506068, - 0.491820, 0.477715, 0.463758, 0.449955, 0.436312, 0.422834, 0.409526, 0.396393, 0.383441, - 0.370675, 0.358100, 0.345720, 0.333540, 0.321565, 0.309799, 0.298247, 0.286911, 0.275797, - 0.264907, 0.254246, 0.243816, 0.233619, 0.223660, 0.213940, 0.204462, 0.195226, 0.186236, - 0.177492, 0.168995, 0.160747, 0.152747, 0.144995, 0.137492, 0.130237, 0.123228, 0.116466, - 0.109948, 0.103673, 0.097639, 0.091843, 0.086282, 0.080954, 0.075855, 0.070982, 0.066330, - 0.061897, 0.057677, 0.053665, 0.049858, 0.046250, 0.042835, 0.039609, 0.036566, 0.033700, - 0.031006, 0.028476, 0.026106, 0.023890, 0.021820, 0.019892, 0.018098, 0.016433, 0.014891, - 0.013465, 0.012149, 0.010938, 0.009826, 0.008806, 0.007873, 0.007023, 0.006249, 0.005546, - 0.004910, 0.004335, 0.003817, 0.003352, 0.002935, 0.002562, 0.002231, 0.001936, 0.001675, - 0.001445, 0.001242, 0.001064, 0.000909, 0.000774, 0.000656, 0.000554, 0.000467, 0.000391, - 0.000327, 0.000272, 0.000225, 0.000186, 0.000153, 0.000125, 0.000102, 0.000083, 0.000067, - 0.000054, 0.000043, 0.000034, 0.000027, 0.000021, 0.000017, 0.000013, 0.000010, 0.000008, - 0.000006, 0.000004, 0.000003, 0.000003, 0.000002, 0.000001, 0.000001, 0.000001, 0.000001, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000}, -}; - -static const double modulation5[6][547] = { - - {50.00, 50.10, 50.20, 50.30, 50.40, 50.50, 50.60, 50.70, 50.80, 50.90, 51.00, 51.10, - 51.20, 51.30, 51.40, 51.50, 51.60, 51.70, 51.80, 51.90, 52.00, 52.10, 52.20, 52.30, - 52.40, 52.50, 52.60, 52.70, 52.80, 52.90, 53.00, 53.10, 53.20, 53.30, 53.40, 53.50, - 53.60, 53.70, 53.80, 53.90, 54.00, 54.10, 54.20, 54.30, 54.40, 54.50, 54.60, 54.70, - 54.80, 54.90, 55.00, 55.10, 55.20, 55.30, 55.40, 55.50, 55.60, 55.70, 55.80, 55.90, - 56.00, 56.10, 56.20, 56.30, 56.40, 56.50, 56.60, 56.70, 56.80, 56.90, 57.00, 57.10, - 57.20, 57.30, 57.40, 57.50, 57.60, 57.70, 57.80, 57.90, 58.00, 58.10, 58.20, 58.30, - 58.40, 58.50, 58.60, 58.70, 58.80, 58.90, 59.00, 59.10, 59.20, 59.30, 59.40, 59.50, - 59.60, 59.70, 59.80, 59.90, 60.00, 60.10, 60.20, 60.30, 60.40, 60.50, 60.60, 60.70, - 60.80, 60.90, 61.00, 61.10, 61.20, 61.30, 61.40, 61.50, 61.60, 61.70, 61.80, 61.90, - 62.00, 62.10, 62.20, 62.30, 62.40, 62.50, 62.60, 62.70, 62.80, 62.90, 63.00, 63.10, - 63.20, 63.30, 63.40, 63.50, 63.60, 63.70, 63.80, 63.90, 64.00, 64.10, 64.20, 64.30, - 64.40, 64.50, 64.60, 64.70, 64.80, 64.90, 65.00, 65.10, 65.20, 65.30, 65.40, 65.50, - 65.60, 65.70, 65.80, 65.90, 66.00, 66.10, 66.20, 66.30, 66.40, 66.50, 66.60, 66.70, - 66.80, 66.90, 67.00, 67.10, 67.20, 67.30, 67.40, 67.50, 67.60, 67.70, 67.80, 67.90, - 68.00, 68.10, 68.20, 68.30, 68.40, 68.50, 68.60, 68.70, 68.80, 68.90, 69.00, 69.10, - 69.20, 69.30, 69.40, 69.50, 69.60, 69.70, 69.80, 69.90, 70.00, 70.10, 70.20, 70.30, - 70.40, 70.50, 70.60, 70.70, 70.80, 70.90, 71.00, 71.10, 71.20, 71.30, 71.40, 71.50, - 71.60, 71.70, 71.80, 71.90, 72.00, 72.10, 72.20, 72.30, 72.40, 72.50, 72.60, 72.70, - 72.80, 72.90, 73.00, 73.10, 73.20, 73.30, 73.40, 73.50, 73.60, 73.70, 73.80, 73.90, - 74.00, 74.10, 74.20, 74.30, 74.40, 74.50, 74.60, 74.70, 74.80, 74.90, 75.00, 75.10, - 75.20, 75.30, 75.40, 75.50, 75.60, 75.70, 75.80, 75.90, 76.00, 76.10, 76.20, 76.30, - 76.40, 76.50, 76.60, 76.70, 76.80, 76.90, 77.00, 77.10, 77.20, 77.30, 77.40, 77.50, - 77.60, 77.70, 77.80, 77.90, 78.00, 78.10, 78.20, 78.30, 78.40, 78.50, 78.60, 78.70, - 78.80, 78.90, 79.00, 79.10, 79.20, 79.30, 79.40, 79.50, 79.60, 79.70, 79.80, 79.90, - 80.00, 80.10, 80.20, 80.30, 80.40, 80.50, 80.60, 80.70, 80.80, 80.90, 81.00, 81.10, - 81.20, 81.30, 81.40, 81.50, 81.60, 81.70, 81.80, 81.90, 82.00, 82.10, 82.20, 82.30, - 82.40, 82.50, 82.60, 82.70, 82.80, 82.90, 83.00, 83.10, 83.20, 83.30, 83.40, 83.50, - 83.60, 83.70, 83.80, 83.90, 84.00, 84.10, 84.20, 84.30, 84.40, 84.50, 84.60, 84.70, - 84.80, 84.90, 85.00, 85.10, 85.20, 85.30, 85.40, 85.50, 85.60, 85.70, 85.80, 85.90, - 86.00, 86.10, 86.20, 86.30, 86.40, 86.50, 86.60, 86.70, 86.80, 86.90, 87.00, 87.10, - 87.20, 87.30, 87.40, 87.50, 87.60, 87.70, 87.80, 87.90, 88.00, 88.10, 88.20, 88.30, - 88.40, 88.50, 88.60, 88.70, 88.80, 88.90, 89.00, 89.10, 89.20, 89.30, 89.40, 89.50, - 89.60, 89.70, 89.80, 89.90, 90.00, 90.10, 90.20, 90.30, 90.40, 90.50, 90.60, 90.70, - 90.80, 90.90, 91.00, 91.10, 91.20, 91.30, 91.40, 91.50, 91.60, 91.70, 91.80, 91.90, - 92.00, 92.10, 92.20, 92.30, 92.40, 92.50, 92.60, 92.70, 92.80, 92.90, 93.00, 93.10, - 93.20, 93.30, 93.40, 93.50, 93.60, 93.70, 93.80, 93.90, 94.00, 94.10, 94.20, 94.30, - 94.40, 94.50, 94.60, 94.70, 94.80, 94.90, 95.00, 96.00, 96.10, 96.20, 96.30, 96.40, - 96.50, 96.60, 96.70, 96.80, 96.90, 97.00, 97.10, 97.20, 97.30, 97.40, 97.50, 97.60, - 97.70, 97.80, 97.90, 98.00, 98.10, 98.20, 98.30, 98.40, 98.50, 98.60, 98.70, 98.80, - 98.90, 99.00, 99.10, 99.20, 99.30, 99.40, 99.50, 99.60, 99.70, 99.80, 99.90, 100.00, - 100.10, 100.20, 100.30, 100.40, 100.50, 100.60, 100.70, 100.80, 100.90, 101.00, 101.10, 101.20, - 101.30, 101.40, 101.50, 101.60, 101.70, 101.80, 101.90, 102.00, 102.10, 102.20, 102.30, 102.40, - 102.50, 102.60, 102.70, 102.80, 102.90, 103.00, 103.10, 103.20, 103.30, 103.40, 103.50, 103.60, - 103.70, 103.80, 103.90, 104.00, 104.10, 104.20, 104.30, 104.40, 104.50, 104.60, 104.70, 104.80, - 104.90, 105.00}, - - {0.46874, 0.46753, 0.46863, 0.46778, 0.46771, 0.46740, 0.46399, 0.46725, 0.46422, 0.46493, - 0.46519, 0.46289, 0.46231, 0.46265, 0.46173, 0.46049, 0.45981, 0.45721, 0.45743, 0.45867, - 0.45599, 0.45719, 0.45515, 0.45272, 0.45396, 0.45432, 0.45263, 0.44926, 0.44898, 0.45062, - 0.45024, 0.44840, 0.44469, 0.44360, 0.44467, 0.44375, 0.44466, 0.44159, 0.44011, 0.43992, - 0.43979, 0.43863, 0.44184, 0.43579, 0.43560, 0.43449, 0.43185, 0.43021, 0.43098, 0.42802, - 0.42823, 0.42574, 0.42867, 0.42309, 0.42344, 0.42089, 0.42158, 0.41947, 0.41761, 0.41779, - 0.41695, 0.41723, 0.41540, 0.40973, 0.41315, 0.40834, 0.40579, 0.40460, 0.40443, 0.40311, - 0.39945, 0.40115, 0.40351, 0.39952, 0.39711, 0.39469, 0.39120, 0.39256, 0.39325, 0.39029, - 0.38713, 0.38405, 0.38310, 0.38170, 0.38153, 0.38150, 0.37932, 0.37625, 0.37639, 0.37513, - 0.36934, 0.37158, 0.36743, 0.36725, 0.36754, 0.36367, 0.36349, 0.36127, 0.35845, 0.35664, - 0.35571, 0.34821, 0.35324, 0.34971, 0.34971, 0.35046, 0.34550, 0.34232, 0.34107, 0.33753, - 0.34123, 0.33774, 0.33267, 0.33334, 0.32925, 0.32793, 0.32465, 0.32587, 0.32283, 0.32465, - 0.31899, 0.31939, 0.31609, 0.31355, 0.31146, 0.30996, 0.30590, 0.30941, 0.30495, 0.30232, - 0.30000, 0.30592, 0.30067, 0.29949, 0.29367, 0.29305, 0.29100, 0.28859, 0.28693, 0.28460, - 0.28802, 0.28214, 0.28012, 0.27655, 0.27398, 0.27489, 0.27265, 0.27207, 0.27215, 0.26801, - 0.27007, 0.26242, 0.26167, 0.25807, 0.26060, 0.25424, 0.25617, 0.25184, 0.25211, 0.24963, - 0.24654, 0.24889, 0.24176, 0.24156, 0.24427, 0.23891, 0.23345, 0.23369, 0.23111, 0.22584, - 0.22942, 0.22945, 0.22418, 0.22058, 0.22445, 0.21787, 0.22024, 0.22024, 0.21310, 0.21312, - 0.21306, 0.21014, 0.21204, 0.20921, 0.20454, 0.20235, 0.20241, 0.19851, 0.20200, 0.19926, - 0.19586, 0.19828, 0.19279, 0.19168, 0.18899, 0.18156, 0.18563, 0.18633, 0.18394, 0.18089, - 0.17964, 0.17685, 0.17630, 0.17696, 0.17502, 0.17138, 0.17179, 0.17177, 0.16918, 0.16656, - 0.16816, 0.16230, 0.16106, 0.15727, 0.15690, 0.15554, 0.15106, 0.15557, 0.14960, 0.15174, - 0.14814, 0.14777, 0.14698, 0.14451, 0.14344, 0.14489, 0.14124, 0.14074, 0.13459, 0.13994, - 0.13606, 0.13941, 0.13231, 0.13203, 0.12701, 0.13091, 0.12635, 0.12740, 0.12701, 0.12425, - 0.12362, 0.12399, 0.12174, 0.12099, 0.11940, 0.11865, 0.11551, 0.11818, 0.11366, 0.11303, - 0.11050, 0.10948, 0.11105, 0.10813, 0.11124, 0.10642, 0.10827, 0.11041, 0.10285, 0.10473, - 0.09880, 0.10248, 0.09540, 0.09905, 0.09991, 0.09618, 0.09506, 0.09641, 0.09405, 0.09332, - 0.09131, 0.09068, 0.09243, 0.08471, 0.08641, 0.08408, 0.08723, 0.08609, 0.08705, 0.08511, - 0.08122, 0.08053, 0.07947, 0.07747, 0.08165, 0.07549, 0.07670, 0.07824, 0.07534, 0.07525, - 0.07588, 0.07390, 0.07203, 0.07413, 0.07441, 0.06786, 0.07505, 0.06733, 0.06543, 0.06713, - 0.06481, 0.06620, 0.06451, 0.06596, 0.06732, 0.06286, 0.06340, 0.06110, 0.06586, 0.05799, - 0.06174, 0.05731, 0.06178, 0.05907, 0.05567, 0.05586, 0.05653, 0.05728, 0.05270, 0.05378, - 0.05503, 0.05143, 0.05158, 0.05056, 0.04994, 0.04988, 0.04934, 0.05066, 0.04965, 0.04614, - 0.04920, 0.04983, 0.04556, 0.04978, 0.04673, 0.04594, 0.04701, 0.04590, 0.04294, 0.04526, - 0.04284, 0.04478, 0.04237, 0.03920, 0.03740, 0.03988, 0.04055, 0.03832, 0.03959, 0.03906, - 0.03856, 0.03672, 0.03585, 0.03492, 0.03618, 0.03672, 0.03633, 0.03628, 0.03366, 0.03619, - 0.03560, 0.03449, 0.03371, 0.03517, 0.03176, 0.03113, 0.03128, 0.03226, 0.03109, 0.03163, - 0.02916, 0.02963, 0.03264, 0.03274, 0.02953, 0.02802, 0.02895, 0.02822, 0.03060, 0.02658, - 0.02759, 0.02779, 0.02575, 0.02637, 0.02603, 0.02783, 0.02525, 0.02744, 0.02429, 0.02613, - 0.02264, 0.02385, 0.02370, 0.02473, 0.02229, 0.02346, 0.02491, 0.02229, 0.02040, 0.02307, - 0.02292, 0.02118, 0.02177, 0.02030, 0.02219, 0.01899, 0.02055, 0.01909, 0.01870, 0.01938, - 0.01836, 0.01850, 0.01899, 0.01918, 0.01671, 0.01957, 0.01603, 0.01816, 0.01700, 0.01559, - 0.01773, 0.01773, 0.01685, 0.01530, 0.01612, 0.01622, 0.01467, 0.01627, 0.01564, 0.01448, - 0.01467, 0.01612, 0.01467, 0.01565, 0.01516, 0.01394, 0.01394, 0.01477, 0.01428, 0.01302, - 0.01423, 0.01146, 0.01311, 0.01418, 0.01302, 0.01224, 0.01269, 0.01190, 0.01055, 0.01258, - 0.01185, 0.01088, 0.01122, 0.01059, 0.01035, 0.01132, 0.00947, 0.01234, 0.00914, 0.01054, - 0.01054, 0.00918, 0.00841, 0.00987, 0.01030, 0.00972, 0.01035, 0.00743, 0.00860, 0.00923, - 0.00894, 0.00948, 0.00908, 0.00801, 0.00792, 0.00826, 0.00724, 0.00801, 0.00728, 0.00782, - 0.00724, 0.00777, 0.00694, 0.00811, 0.00796, 0.00665, 0.00753, 0.00724, 0.00583, 0.00656, - 0.00675, 0.00646, 0.00787, 0.00719, 0.00660, 0.00796, 0.00568, 0.00787, 0.00622, 0.00690, - 0.00694, 0.00563, 0.00597, 0.00627, 0.00660, 0.00578, 0.00719, 0.00442, 0.00524, 0.00583, - 0.00617, 0.00622, 0.00612, 0.00583, 0.00554, 0.00481, 0.00432, 0.00476, 0.00403, 0.00534, - 0.00418, 0.00490, 0.00466, 0.00534, 0.00520, 0.00379, 0.00510, 0.00422, 0.00335, 0.00427, - 0.00437, 0.00452, 0.00374, 0.00524, 0.00442, 0.00320, 0.00403, 0.00388, 0.00461, 0.00379, - 0.00345, 0.00364}, - - {0.96640, 0.96400, 0.96580, 0.96400, 0.96420, 0.96330, 0.95670, 0.96270, 0.95660, 0.95880, - 0.95890, 0.95390, 0.95320, 0.95380, 0.95170, 0.94910, 0.94770, 0.94270, 0.94250, 0.94510, - 0.93970, 0.94230, 0.93810, 0.93310, 0.93570, 0.93640, 0.93310, 0.92610, 0.92570, 0.92820, - 0.92750, 0.92470, 0.91640, 0.91400, 0.91720, 0.91460, 0.91660, 0.91030, 0.90710, 0.90660, - 0.90650, 0.90360, 0.91050, 0.89860, 0.89820, 0.89550, 0.89050, 0.88670, 0.88830, 0.88260, - 0.88290, 0.87750, 0.88350, 0.87280, 0.87280, 0.86770, 0.86900, 0.86460, 0.86070, 0.86080, - 0.85960, 0.85980, 0.85630, 0.84450, 0.85140, 0.84130, 0.83630, 0.83390, 0.83410, 0.83120, - 0.82320, 0.82660, 0.83190, 0.82300, 0.81830, 0.81350, 0.80630, 0.80950, 0.81020, 0.80420, - 0.79810, 0.79170, 0.78960, 0.78720, 0.78590, 0.78610, 0.78180, 0.77540, 0.77590, 0.77300, - 0.76140, 0.76630, 0.75710, 0.75710, 0.75770, 0.74930, 0.74910, 0.74500, 0.73840, 0.73500, - 0.73370, 0.71750, 0.72810, 0.72090, 0.72030, 0.72250, 0.71240, 0.70560, 0.70260, 0.69540, - 0.70310, 0.69620, 0.68590, 0.68740, 0.67870, 0.67590, 0.66930, 0.67200, 0.66590, 0.66930, - 0.65740, 0.65780, 0.65160, 0.64690, 0.64180, 0.63860, 0.63080, 0.63760, 0.62840, 0.62330, - 0.61840, 0.63040, 0.61950, 0.61740, 0.60520, 0.60400, 0.60050, 0.59470, 0.59160, 0.58650, - 0.59390, 0.58170, 0.57710, 0.57010, 0.56440, 0.56660, 0.56190, 0.56080, 0.56090, 0.55270, - 0.55660, 0.54050, 0.53990, 0.53180, 0.53700, 0.52390, 0.52790, 0.51930, 0.51950, 0.51460, - 0.50850, 0.51290, 0.49840, 0.49800, 0.50330, 0.49200, 0.48130, 0.48150, 0.47620, 0.46580, - 0.47300, 0.47270, 0.46220, 0.45480, 0.46250, 0.44910, 0.45430, 0.45400, 0.43910, 0.43900, - 0.43930, 0.43380, 0.43720, 0.43110, 0.42150, 0.41690, 0.41710, 0.40910, 0.41680, 0.41090, - 0.40370, 0.40880, 0.39740, 0.39520, 0.38930, 0.37410, 0.38230, 0.38400, 0.37900, 0.37280, - 0.37040, 0.36430, 0.36310, 0.36480, 0.36080, 0.35330, 0.35380, 0.35410, 0.34870, 0.34340, - 0.34650, 0.33470, 0.33180, 0.32400, 0.32350, 0.32060, 0.31130, 0.32040, 0.30830, 0.31290, - 0.30530, 0.30480, 0.30300, 0.29800, 0.29560, 0.29850, 0.29100, 0.29050, 0.27730, 0.28850, - 0.28050, 0.28740, 0.27250, 0.27230, 0.26170, 0.26980, 0.26060, 0.26240, 0.26170, 0.25610, - 0.25490, 0.25530, 0.25110, 0.24920, 0.24610, 0.24430, 0.23820, 0.24380, 0.23420, 0.23300, - 0.22770, 0.22570, 0.22910, 0.22300, 0.22930, 0.21930, 0.22310, 0.22770, 0.21230, 0.21590, - 0.20360, 0.21110, 0.19670, 0.20420, 0.20590, 0.19840, 0.19580, 0.19860, 0.19390, 0.19240, - 0.18810, 0.18680, 0.19040, 0.17470, 0.17800, 0.17330, 0.17970, 0.17770, 0.17960, 0.17560, - 0.16750, 0.16600, 0.16380, 0.15960, 0.16820, 0.15580, 0.15800, 0.16110, 0.15540, 0.15520, - 0.15650, 0.15270, 0.14830, 0.15290, 0.15340, 0.13980, 0.15480, 0.13890, 0.13490, 0.13830, - 0.13390, 0.13630, 0.13300, 0.13590, 0.13870, 0.12970, 0.13070, 0.12580, 0.13560, 0.11940, - 0.12720, 0.11800, 0.12730, 0.12190, 0.11480, 0.11510, 0.11640, 0.11820, 0.10860, 0.11100, - 0.11340, 0.10590, 0.10620, 0.10410, 0.10300, 0.10270, 0.10160, 0.10430, 0.10240, 0.09500, - 0.10140, 0.10260, 0.09380, 0.10250, 0.09630, 0.09460, 0.09680, 0.09460, 0.08860, 0.09320, - 0.08820, 0.09230, 0.08740, 0.08080, 0.07720, 0.08220, 0.08350, 0.07900, 0.08160, 0.08060, - 0.07940, 0.07570, 0.07390, 0.07190, 0.07450, 0.07560, 0.07490, 0.07470, 0.06940, 0.07460, - 0.07330, 0.07110, 0.06940, 0.07250, 0.06540, 0.06410, 0.06440, 0.06660, 0.06410, 0.06520, - 0.06030, 0.06100, 0.06720, 0.06740, 0.06080, 0.05770, 0.05960, 0.05810, 0.06310, 0.05490, - 0.05680, 0.05730, 0.05310, 0.05430, 0.05360, 0.05730, 0.05200, 0.05650, 0.05010, 0.05380, - 0.04670, 0.04920, 0.04880, 0.05110, 0.04590, 0.04830, 0.05130, 0.04590, 0.04210, 0.04750, - 0.04720, 0.04370, 0.04500, 0.04180, 0.04570, 0.03910, 0.04240, 0.03930, 0.03850, 0.03990, - 0.03780, 0.03810, 0.03910, 0.03950, 0.03440, 0.04030, 0.03310, 0.03740, 0.03500, 0.03210, - 0.03650, 0.03650, 0.03470, 0.03150, 0.03320, 0.03350, 0.03020, 0.03350, 0.03220, 0.02990, - 0.03020, 0.03320, 0.03020, 0.03240, 0.03130, 0.02870, 0.02870, 0.03040, 0.02940, 0.02680, - 0.02930, 0.02360, 0.02700, 0.02920, 0.02680, 0.02520, 0.02630, 0.02450, 0.02180, 0.02590, - 0.02450, 0.02240, 0.02310, 0.02190, 0.02130, 0.02330, 0.01950, 0.02550, 0.01890, 0.02170, - 0.02170, 0.01890, 0.01740, 0.02040, 0.02120, 0.02010, 0.02140, 0.01530, 0.01770, 0.01900, - 0.01840, 0.01960, 0.01870, 0.01650, 0.01630, 0.01700, 0.01500, 0.01650, 0.01500, 0.01610, - 0.01490, 0.01600, 0.01430, 0.01670, 0.01640, 0.01370, 0.01550, 0.01490, 0.01200, 0.01350, - 0.01390, 0.01330, 0.01620, 0.01490, 0.01360, 0.01640, 0.01170, 0.01620, 0.01290, 0.01420, - 0.01430, 0.01160, 0.01230, 0.01300, 0.01360, 0.01190, 0.01490, 0.00910, 0.01080, 0.01200, - 0.01270, 0.01280, 0.01260, 0.01200, 0.01140, 0.00990, 0.00890, 0.00980, 0.00830, 0.01100, - 0.00860, 0.01010, 0.00960, 0.01100, 0.01070, 0.00780, 0.01050, 0.00870, 0.00690, 0.00880, - 0.00900, 0.00930, 0.00780, 0.01080, 0.00920, 0.00660, 0.00830, 0.00800, 0.00950, 0.00780, - 0.00710, 0.00750}, - - {0.03247, 0.03470, 0.03303, 0.03470, 0.03452, 0.03535, 0.04142, 0.03591, 0.04152, 0.03950, - 0.03941, 0.04398, 0.04461, 0.04407, 0.04597, 0.04831, 0.04956, 0.05402, 0.05419, 0.05189, - 0.05666, 0.05437, 0.05807, 0.06242, 0.06017, 0.05955, 0.06242, 0.06844, 0.06878, 0.06664, - 0.06724, 0.06963, 0.07661, 0.07860, 0.07594, 0.07811, 0.07644, 0.08165, 0.08427, 0.08468, - 0.08476, 0.08711, 0.08149, 0.09112, 0.09144, 0.09358, 0.09751, 0.10046, 0.09922, 0.10362, - 0.10339, 0.10749, 0.10293, 0.11102, 0.11102, 0.11480, 0.11384, 0.11707, 0.11990, 0.11982, - 0.12069, 0.12054, 0.12305, 0.13132, 0.12652, 0.13351, 0.13690, 0.13851, 0.13838, 0.14031, - 0.14554, 0.14333, 0.13984, 0.14567, 0.14869, 0.15172, 0.15618, 0.15421, 0.15378, 0.15746, - 0.16114, 0.16491, 0.16613, 0.16752, 0.16826, 0.16815, 0.17059, 0.17416, 0.17388, 0.17547, - 0.18167, 0.17908, 0.18390, 0.18390, 0.18359, 0.18785, 0.18795, 0.18998, 0.19317, 0.19478, - 0.19538, 0.20269, 0.19797, 0.20120, 0.20147, 0.20049, 0.20489, 0.20773, 0.20895, 0.21182, - 0.20875, 0.21151, 0.21544, 0.21488, 0.21807, 0.21906, 0.22134, 0.22042, 0.22248, 0.22134, - 0.22523, 0.22510, 0.22702, 0.22842, 0.22989, 0.23079, 0.23289, 0.23107, 0.23351, 0.23480, - 0.23598, 0.23300, 0.23572, 0.23622, 0.23893, 0.23918, 0.23990, 0.24103, 0.24161, 0.24252, - 0.24118, 0.24333, 0.24406, 0.24509, 0.24585, 0.24556, 0.24617, 0.24630, 0.24629, 0.24722, - 0.24680, 0.24836, 0.24841, 0.24899, 0.24863, 0.24943, 0.24922, 0.24963, 0.24962, 0.24979, - 0.24993, 0.24983, 0.25000, 0.25000, 0.24999, 0.24994, 0.24965, 0.24966, 0.24943, 0.24883, - 0.24927, 0.24926, 0.24857, 0.24796, 0.24859, 0.24741, 0.24791, 0.24788, 0.24629, 0.24628, - 0.24632, 0.24562, 0.24606, 0.24525, 0.24384, 0.24309, 0.24313, 0.24174, 0.24308, 0.24206, - 0.24073, 0.24168, 0.23947, 0.23902, 0.23775, 0.23415, 0.23615, 0.23654, 0.23536, 0.23382, - 0.23320, 0.23159, 0.23126, 0.23172, 0.23062, 0.22848, 0.22863, 0.22871, 0.22711, 0.22548, - 0.22644, 0.22268, 0.22171, 0.21902, 0.21885, 0.21782, 0.21439, 0.21774, 0.21325, 0.21499, - 0.21209, 0.21190, 0.21119, 0.20920, 0.20822, 0.20940, 0.20632, 0.20611, 0.20040, 0.20527, - 0.20182, 0.20480, 0.19824, 0.19815, 0.19321, 0.19701, 0.19269, 0.19355, 0.19321, 0.19051, - 0.18993, 0.19012, 0.18805, 0.18710, 0.18554, 0.18462, 0.18146, 0.18436, 0.17935, 0.17871, - 0.17585, 0.17476, 0.17661, 0.17327, 0.17672, 0.17121, 0.17333, 0.17585, 0.16723, 0.16929, - 0.16215, 0.16654, 0.15801, 0.16250, 0.16351, 0.15904, 0.15746, 0.15916, 0.15630, 0.15538, - 0.15272, 0.15191, 0.15415, 0.14418, 0.14632, 0.14327, 0.14741, 0.14612, 0.14734, 0.14477, - 0.13944, 0.13844, 0.13697, 0.13413, 0.13991, 0.13153, 0.13304, 0.13515, 0.13125, 0.13111, - 0.13201, 0.12938, 0.12631, 0.12952, 0.12987, 0.12026, 0.13084, 0.11961, 0.11670, 0.11917, - 0.11597, 0.11772, 0.11531, 0.11743, 0.11946, 0.11288, 0.11362, 0.10997, 0.11721, 0.10514, - 0.11102, 0.10408, 0.11109, 0.10704, 0.10162, 0.10185, 0.10285, 0.10423, 0.09681, 0.09868, - 0.10054, 0.09469, 0.09492, 0.09326, 0.09239, 0.09215, 0.09128, 0.09342, 0.09191, 0.08597, - 0.09112, 0.09207, 0.08500, 0.09199, 0.08703, 0.08565, 0.08743, 0.08565, 0.08075, 0.08451, - 0.08042, 0.08378, 0.07976, 0.07427, 0.07124, 0.07544, 0.07653, 0.07276, 0.07494, 0.07410, - 0.07310, 0.06997, 0.06844, 0.06673, 0.06895, 0.06989, 0.06929, 0.06912, 0.06458, 0.06903, - 0.06793, 0.06605, 0.06458, 0.06724, 0.06112, 0.05999, 0.06025, 0.06216, 0.05999, 0.06095, - 0.05666, 0.05728, 0.06268, 0.06286, 0.05710, 0.05437, 0.05605, 0.05472, 0.05912, 0.05189, - 0.05357, 0.05402, 0.05028, 0.05135, 0.05073, 0.05402, 0.04930, 0.05331, 0.04759, 0.05091, - 0.04452, 0.04678, 0.04642, 0.04849, 0.04379, 0.04597, 0.04867, 0.04379, 0.04033, 0.04524, - 0.04497, 0.04179, 0.04297, 0.04005, 0.04361, 0.03757, 0.04060, 0.03776, 0.03702, 0.03831, - 0.03637, 0.03665, 0.03757, 0.03794, 0.03322, 0.03868, 0.03200, 0.03600, 0.03377, 0.03107, - 0.03517, 0.03517, 0.03350, 0.03051, 0.03210, 0.03238, 0.02929, 0.03238, 0.03116, 0.02901, - 0.02929, 0.03210, 0.02929, 0.03135, 0.03032, 0.02788, 0.02788, 0.02948, 0.02854, 0.02608, - 0.02844, 0.02304, 0.02627, 0.02835, 0.02608, 0.02457, 0.02561, 0.02390, 0.02133, 0.02523, - 0.02390, 0.02190, 0.02257, 0.02142, 0.02085, 0.02276, 0.01912, 0.02485, 0.01854, 0.02123, - 0.02123, 0.01854, 0.01710, 0.01998, 0.02075, 0.01970, 0.02094, 0.01507, 0.01739, 0.01864, - 0.01806, 0.01922, 0.01835, 0.01623, 0.01603, 0.01671, 0.01477, 0.01623, 0.01477, 0.01584, - 0.01468, 0.01574, 0.01410, 0.01642, 0.01613, 0.01351, 0.01526, 0.01468, 0.01186, 0.01332, - 0.01371, 0.01312, 0.01594, 0.01468, 0.01341, 0.01613, 0.01156, 0.01594, 0.01273, 0.01400, - 0.01410, 0.01146, 0.01215, 0.01283, 0.01341, 0.01176, 0.01468, 0.00902, 0.01068, 0.01186, - 0.01254, 0.01264, 0.01244, 0.01186, 0.01127, 0.00980, 0.00882, 0.00970, 0.00823, 0.01088, - 0.00853, 0.01000, 0.00951, 0.01088, 0.01059, 0.00774, 0.01039, 0.00862, 0.00685, 0.00872, - 0.00892, 0.00921, 0.00774, 0.01068, 0.00911, 0.00656, 0.00823, 0.00794, 0.00941, 0.00774, - 0.00705, 0.00744}, - - {0.96287, 0.96035, 0.96224, 0.96035, 0.96056, 0.95961, 0.95271, 0.95899, 0.95261, 0.95490, - 0.95501, 0.94979, 0.94906, 0.94969, 0.94750, 0.94479, 0.94334, 0.93815, 0.93794, 0.94063, - 0.93503, 0.93773, 0.93338, 0.92820, 0.93089, 0.93162, 0.92820, 0.92097, 0.92056, 0.92314, - 0.92242, 0.91953, 0.91097, 0.90851, 0.91180, 0.90912, 0.91118, 0.90470, 0.90141, 0.90090, - 0.90079, 0.89782, 0.90490, 0.89268, 0.89227, 0.88950, 0.88438, 0.88049, 0.88213, 0.87629, - 0.87660, 0.87107, 0.87721, 0.86627, 0.86627, 0.86106, 0.86239, 0.85789, 0.85391, 0.85401, - 0.85279, 0.85299, 0.84942, 0.83740, 0.84443, 0.83414, 0.82905, 0.82661, 0.82681, 0.82386, - 0.81572, 0.81918, 0.82457, 0.81552, 0.81074, 0.80587, 0.79855, 0.80180, 0.80251, 0.79642, - 0.79023, 0.78374, 0.78161, 0.77918, 0.77786, 0.77806, 0.77370, 0.76722, 0.76773, 0.76479, - 0.75305, 0.75801, 0.74869, 0.74869, 0.74930, 0.74081, 0.74060, 0.73646, 0.72979, 0.72635, - 0.72504, 0.70868, 0.71938, 0.71211, 0.71150, 0.71372, 0.70353, 0.69667, 0.69364, 0.68638, - 0.69415, 0.68719, 0.67680, 0.67831, 0.66955, 0.66673, 0.66008, 0.66280, 0.65665, 0.66008, - 0.64810, 0.64850, 0.64226, 0.63753, 0.63240, 0.62918, 0.62134, 0.62818, 0.61893, 0.61380, - 0.60888, 0.62094, 0.60998, 0.60787, 0.59562, 0.59441, 0.59090, 0.58508, 0.58197, 0.57685, - 0.58427, 0.57203, 0.56742, 0.56040, 0.55468, 0.55689, 0.55217, 0.55107, 0.55117, 0.54295, - 0.54686, 0.53073, 0.53013, 0.52202, 0.52723, 0.51411, 0.51811, 0.50951, 0.50971, 0.50480, - 0.49870, 0.50310, 0.48860, 0.48820, 0.49350, 0.48220, 0.47151, 0.47171, 0.46641, 0.45602, - 0.46321, 0.46292, 0.45243, 0.44504, 0.45273, 0.43935, 0.44454, 0.44424, 0.42937, 0.42927, - 0.42957, 0.42409, 0.42748, 0.42139, 0.41182, 0.40724, 0.40744, 0.39946, 0.40714, 0.40126, - 0.39408, 0.39916, 0.38781, 0.38562, 0.37974, 0.36462, 0.37278, 0.37447, 0.36949, 0.36332, - 0.36094, 0.35487, 0.35367, 0.35536, 0.35139, 0.34393, 0.34443, 0.34473, 0.33936, 0.33409, - 0.33717, 0.32545, 0.32257, 0.31483, 0.31433, 0.31145, 0.30223, 0.31125, 0.29925, 0.30381, - 0.29627, 0.29578, 0.29399, 0.28903, 0.28666, 0.28953, 0.28210, 0.28160, 0.26853, 0.27962, - 0.27170, 0.27853, 0.26377, 0.26358, 0.25309, 0.26110, 0.25200, 0.25378, 0.25309, 0.24754, - 0.24636, 0.24675, 0.24260, 0.24072, 0.23766, 0.23588, 0.22985, 0.23538, 0.22590, 0.22471, - 0.21948, 0.21751, 0.22086, 0.21484, 0.22106, 0.21119, 0.21494, 0.21948, 0.20428, 0.20784, - 0.19571, 0.20310, 0.18891, 0.19630, 0.19798, 0.19058, 0.18802, 0.19078, 0.18615, 0.18467, - 0.18044, 0.17916, 0.18271, 0.16726, 0.17050, 0.16588, 0.17217, 0.17021, 0.17208, 0.16814, - 0.16018, 0.15871, 0.15655, 0.15242, 0.16087, 0.14869, 0.15085, 0.15390, 0.14830, 0.14810, - 0.14938, 0.14565, 0.14133, 0.14585, 0.14634, 0.13300, 0.14771, 0.13212, 0.12820, 0.13153, - 0.12723, 0.12957, 0.12634, 0.12918, 0.13193, 0.12312, 0.12409, 0.11930, 0.12889, 0.11305, - 0.12067, 0.11168, 0.12077, 0.11549, 0.10855, 0.10884, 0.11011, 0.11187, 0.10250, 0.10484, - 0.10719, 0.09987, 0.10016, 0.09811, 0.09704, 0.09675, 0.09568, 0.09831, 0.09646, 0.08925, - 0.09548, 0.09665, 0.08809, 0.09656, 0.09052, 0.08886, 0.09101, 0.08886, 0.08303, 0.08750, - 0.08264, 0.08663, 0.08186, 0.07546, 0.07197, 0.07682, 0.07808, 0.07371, 0.07623, 0.07526, - 0.07410, 0.07051, 0.06877, 0.06684, 0.06935, 0.07042, 0.06974, 0.06955, 0.06442, 0.06945, - 0.06819, 0.06606, 0.06442, 0.06742, 0.06055, 0.05930, 0.05959, 0.06171, 0.05930, 0.06036, - 0.05563, 0.05631, 0.06229, 0.06249, 0.05612, 0.05313, 0.05496, 0.05352, 0.05833, 0.05044, - 0.05226, 0.05275, 0.04870, 0.04986, 0.04919, 0.05275, 0.04765, 0.05198, 0.04582, 0.04938, - 0.04256, 0.04496, 0.04458, 0.04678, 0.04180, 0.04410, 0.04698, 0.04180, 0.03816, 0.04333, - 0.04304, 0.03969, 0.04094, 0.03788, 0.04161, 0.03530, 0.03845, 0.03549, 0.03473, 0.03606, - 0.03406, 0.03435, 0.03530, 0.03568, 0.03083, 0.03644, 0.02959, 0.03368, 0.03140, 0.02865, - 0.03282, 0.03282, 0.03111, 0.02808, 0.02969, 0.02997, 0.02685, 0.02997, 0.02874, 0.02656, - 0.02685, 0.02969, 0.02685, 0.02893, 0.02789, 0.02543, 0.02543, 0.02704, 0.02609, 0.02363, - 0.02600, 0.02063, 0.02382, 0.02590, 0.02363, 0.02213, 0.02316, 0.02147, 0.01894, 0.02279, - 0.02147, 0.01950, 0.02016, 0.01903, 0.01847, 0.02034, 0.01679, 0.02241, 0.01623, 0.01884, - 0.01884, 0.01623, 0.01484, 0.01763, 0.01838, 0.01735, 0.01856, 0.01289, 0.01512, 0.01632, - 0.01577, 0.01688, 0.01605, 0.01400, 0.01382, 0.01447, 0.01262, 0.01400, 0.01262, 0.01363, - 0.01252, 0.01354, 0.01197, 0.01419, 0.01391, 0.01142, 0.01308, 0.01252, 0.00987, 0.01124, - 0.01161, 0.01106, 0.01373, 0.01252, 0.01133, 0.01391, 0.00959, 0.01373, 0.01069, 0.01188, - 0.01197, 0.00950, 0.01014, 0.01078, 0.01133, 0.00978, 0.01252, 0.00724, 0.00877, 0.00987, - 0.01051, 0.01060, 0.01041, 0.00987, 0.00932, 0.00796, 0.00706, 0.00787, 0.00652, 0.00896, - 0.00679, 0.00814, 0.00769, 0.00896, 0.00868, 0.00608, 0.00850, 0.00688, 0.00528, 0.00697, - 0.00715, 0.00742, 0.00608, 0.00877, 0.00733, 0.00501, 0.00652, 0.00625, 0.00760, 0.00608, - 0.00545, 0.00581}, - - {0.96993, 0.96765, 0.96936, 0.96765, 0.96784, 0.96698, 0.96069, 0.96641, 0.96059, 0.96270, - 0.96279, 0.95801, 0.95734, 0.95791, 0.95590, 0.95341, 0.95206, 0.94725, 0.94706, 0.94956, - 0.94437, 0.94687, 0.94282, 0.93800, 0.94051, 0.94118, 0.93800, 0.93123, 0.93084, 0.93326, - 0.93258, 0.92987, 0.92183, 0.91949, 0.92260, 0.92008, 0.92202, 0.91590, 0.91279, 0.91230, - 0.91221, 0.90938, 0.91609, 0.90452, 0.90413, 0.90150, 0.89662, 0.89291, 0.89447, 0.88891, - 0.88920, 0.88393, 0.88979, 0.87933, 0.87933, 0.87434, 0.87561, 0.87131, 0.86749, 0.86759, - 0.86641, 0.86660, 0.86318, 0.85160, 0.85837, 0.84846, 0.84355, 0.84120, 0.84139, 0.83854, - 0.83068, 0.83402, 0.83923, 0.83048, 0.82586, 0.82113, 0.81405, 0.81720, 0.81789, 0.81198, - 0.80597, 0.79966, 0.79759, 0.79522, 0.79394, 0.79414, 0.78990, 0.78358, 0.78407, 0.78121, - 0.76975, 0.77459, 0.76550, 0.76550, 0.76610, 0.75779, 0.75760, 0.75354, 0.74701, 0.74365, - 0.74236, 0.72632, 0.73682, 0.72969, 0.72910, 0.73128, 0.72127, 0.71453, 0.71156, 0.70442, - 0.71205, 0.70521, 0.69500, 0.69649, 0.68785, 0.68507, 0.67852, 0.68120, 0.67514, 0.67852, - 0.66670, 0.66710, 0.66094, 0.65627, 0.65120, 0.64802, 0.64026, 0.64702, 0.63787, 0.63280, - 0.62792, 0.63986, 0.62902, 0.62693, 0.61478, 0.61359, 0.61010, 0.60432, 0.60123, 0.59615, - 0.60353, 0.59137, 0.58678, 0.57980, 0.57412, 0.57631, 0.57163, 0.57053, 0.57063, 0.56244, - 0.56634, 0.55027, 0.54967, 0.54158, 0.54677, 0.53369, 0.53768, 0.52909, 0.52929, 0.52440, - 0.51830, 0.52270, 0.50820, 0.50780, 0.51310, 0.50180, 0.49109, 0.49129, 0.48599, 0.47558, - 0.48279, 0.48248, 0.47197, 0.46456, 0.47227, 0.45885, 0.46406, 0.46376, 0.44883, 0.44873, - 0.44903, 0.44351, 0.44692, 0.44081, 0.43118, 0.42656, 0.42676, 0.41874, 0.42646, 0.42054, - 0.41332, 0.41844, 0.40699, 0.40478, 0.39886, 0.38358, 0.39182, 0.39353, 0.38851, 0.38228, - 0.37987, 0.37373, 0.37253, 0.37423, 0.37021, 0.36267, 0.36317, 0.36347, 0.35804, 0.35271, - 0.35583, 0.34395, 0.34103, 0.33317, 0.33267, 0.32975, 0.32038, 0.32955, 0.31735, 0.32199, - 0.31433, 0.31382, 0.31201, 0.30696, 0.30454, 0.30747, 0.29990, 0.29940, 0.28607, 0.29738, - 0.28930, 0.29627, 0.28123, 0.28103, 0.27032, 0.27850, 0.26920, 0.27102, 0.27032, 0.26465, - 0.26344, 0.26385, 0.25960, 0.25768, 0.25454, 0.25272, 0.24655, 0.25222, 0.24250, 0.24129, - 0.23592, 0.23389, 0.23734, 0.23116, 0.23754, 0.22741, 0.23126, 0.23592, 0.22032, 0.22396, - 0.21149, 0.21910, 0.20449, 0.21210, 0.21382, 0.20622, 0.20358, 0.20642, 0.20165, 0.20013, - 0.19576, 0.19444, 0.19809, 0.18214, 0.18550, 0.18072, 0.18723, 0.18519, 0.18712, 0.18306, - 0.17482, 0.17329, 0.17105, 0.16678, 0.17553, 0.16291, 0.16515, 0.16831, 0.16250, 0.16230, - 0.16362, 0.15975, 0.15527, 0.15995, 0.16046, 0.14660, 0.16189, 0.14568, 0.14160, 0.14507, - 0.14058, 0.14303, 0.13966, 0.14262, 0.14547, 0.13628, 0.13731, 0.13230, 0.14231, 0.12576, - 0.13373, 0.12432, 0.13383, 0.12831, 0.12105, 0.12136, 0.12269, 0.12453, 0.11470, 0.11716, - 0.11961, 0.11193, 0.11224, 0.11009, 0.10896, 0.10865, 0.10752, 0.11029, 0.10834, 0.10075, - 0.10732, 0.10855, 0.09951, 0.10844, 0.10208, 0.10034, 0.10260, 0.10034, 0.09417, 0.09890, - 0.09376, 0.09797, 0.09294, 0.08614, 0.08243, 0.08758, 0.08892, 0.08429, 0.08697, 0.08594, - 0.08470, 0.08088, 0.07903, 0.07696, 0.07965, 0.08078, 0.08006, 0.07985, 0.07438, 0.07975, - 0.07841, 0.07614, 0.07438, 0.07758, 0.07025, 0.06890, 0.06921, 0.07149, 0.06890, 0.07004, - 0.06497, 0.06569, 0.07211, 0.07231, 0.06548, 0.06227, 0.06424, 0.06269, 0.06787, 0.05937, - 0.06134, 0.06186, 0.05749, 0.05874, 0.05801, 0.06186, 0.05635, 0.06103, 0.05438, 0.05822, - 0.05084, 0.05344, 0.05302, 0.05542, 0.05000, 0.05250, 0.05562, 0.05000, 0.04604, 0.05167, - 0.05136, 0.04771, 0.04906, 0.04572, 0.04979, 0.04290, 0.04635, 0.04311, 0.04227, 0.04374, - 0.04154, 0.04185, 0.04290, 0.04332, 0.03797, 0.04415, 0.03661, 0.04112, 0.03860, 0.03556, - 0.04018, 0.04018, 0.03829, 0.03492, 0.03671, 0.03703, 0.03355, 0.03703, 0.03566, 0.03324, - 0.03355, 0.03671, 0.03355, 0.03587, 0.03471, 0.03197, 0.03197, 0.03377, 0.03271, 0.02996, - 0.03261, 0.02658, 0.03018, 0.03250, 0.02996, 0.02827, 0.02944, 0.02753, 0.02466, 0.02901, - 0.02753, 0.02530, 0.02604, 0.02477, 0.02413, 0.02626, 0.02221, 0.02859, 0.02157, 0.02456, - 0.02456, 0.02157, 0.01996, 0.02317, 0.02402, 0.02285, 0.02424, 0.01771, 0.02028, 0.02168, - 0.02103, 0.02232, 0.02135, 0.01900, 0.01878, 0.01953, 0.01738, 0.01900, 0.01738, 0.01857, - 0.01727, 0.01846, 0.01663, 0.01921, 0.01889, 0.01598, 0.01792, 0.01727, 0.01413, 0.01576, - 0.01620, 0.01554, 0.01867, 0.01727, 0.01587, 0.01889, 0.01381, 0.01867, 0.01511, 0.01652, - 0.01663, 0.01370, 0.01446, 0.01522, 0.01587, 0.01402, 0.01727, 0.01096, 0.01283, 0.01413, - 0.01490, 0.01500, 0.01479, 0.01413, 0.01348, 0.01184, 0.01074, 0.01173, 0.01008, 0.01304, - 0.01041, 0.01206, 0.01151, 0.01304, 0.01272, 0.00952, 0.01250, 0.01052, 0.00852, 0.01063, - 0.01085, 0.01118, 0.00952, 0.01283, 0.01107, 0.00819, 0.01008, 0.00975, 0.01140, 0.00952, - 0.00875, 0.00919}, -}; - -static const double modulation6[6][626] = { - - {65.00, 65.10, 65.20, 65.30, 65.40, 65.50, 65.60, 65.70, 65.80, 65.90, 66.00, 66.10, - 66.20, 66.30, 66.40, 66.50, 66.60, 66.70, 66.80, 66.90, 67.00, 67.10, 67.20, 67.30, - 67.40, 67.50, 67.60, 67.70, 67.80, 67.90, 68.00, 68.10, 68.20, 68.30, 68.40, 68.50, - 68.60, 68.70, 68.80, 68.90, 69.00, 69.10, 69.20, 69.30, 69.40, 69.50, 69.60, 69.70, - 69.80, 69.90, 70.00, 70.10, 70.20, 70.30, 70.40, 70.50, 70.60, 70.70, 70.80, 70.90, - 71.00, 71.10, 71.20, 71.30, 71.40, 71.50, 71.60, 71.70, 71.80, 71.90, 72.00, 72.10, - 72.20, 72.30, 72.40, 72.50, 72.60, 72.70, 72.80, 72.90, 73.00, 73.10, 73.20, 73.30, - 73.40, 73.50, 73.60, 73.70, 73.80, 73.90, 74.00, 74.10, 74.20, 74.30, 74.40, 74.50, - 74.60, 74.70, 74.80, 74.90, 75.00, 75.10, 75.20, 75.30, 75.40, 75.50, 75.60, 75.70, - 75.80, 75.90, 76.00, 76.10, 76.20, 76.30, 76.40, 76.50, 76.60, 76.70, 76.80, 76.90, - 77.00, 77.10, 77.20, 77.30, 77.40, 77.50, 77.60, 77.70, 77.80, 77.90, 78.00, 78.10, - 78.20, 78.30, 78.40, 78.50, 78.60, 78.70, 78.80, 78.90, 79.00, 79.10, 79.20, 79.30, - 79.40, 79.50, 79.60, 79.70, 79.80, 79.90, 80.00, 80.10, 80.20, 80.30, 80.40, 80.50, - 80.60, 80.70, 80.80, 80.90, 81.00, 81.10, 81.20, 81.30, 81.40, 81.50, 81.60, 81.70, - 81.80, 81.90, 82.00, 82.10, 82.20, 82.30, 82.40, 82.50, 82.60, 82.70, 82.80, 82.90, - 83.00, 83.10, 83.20, 83.30, 83.40, 83.50, 83.60, 83.70, 83.80, 83.90, 84.00, 84.10, - 84.20, 84.30, 84.40, 84.50, 84.60, 84.70, 84.80, 84.90, 85.00, 85.10, 85.20, 85.30, - 85.40, 85.50, 85.60, 85.70, 85.80, 85.90, 86.00, 86.10, 86.20, 86.30, 86.40, 86.50, - 86.60, 86.70, 86.80, 86.90, 87.00, 87.10, 87.20, 87.30, 87.40, 87.50, 87.60, 87.70, - 87.80, 87.90, 88.00, 88.10, 88.20, 88.30, 88.40, 88.50, 88.60, 88.70, 88.80, 88.90, - 89.00, 89.10, 89.20, 89.30, 89.40, 89.50, 89.60, 89.70, 89.80, 89.90, 90.00, 90.10, - 90.20, 90.30, 90.40, 90.50, 90.60, 90.70, 90.80, 90.90, 91.00, 91.10, 91.20, 91.30, - 91.40, 91.50, 91.60, 91.70, 91.80, 91.90, 92.00, 92.10, 92.20, 92.30, 92.40, 92.50, - 92.60, 92.70, 92.80, 92.90, 93.00, 93.10, 93.20, 93.30, 93.40, 93.50, 93.60, 93.70, - 93.80, 93.90, 94.00, 94.10, 94.20, 94.30, 94.40, 94.50, 94.60, 94.70, 94.80, 94.90, - 95.00, 95.10, 95.20, 95.30, 95.40, 95.50, 95.60, 95.70, 95.80, 95.90, 96.00, 96.10, - 96.20, 96.30, 96.40, 96.50, 96.60, 96.70, 96.80, 96.90, 97.00, 97.10, 97.20, 97.30, - 97.40, 97.50, 97.60, 97.70, 97.80, 97.90, 98.00, 98.10, 98.20, 98.30, 98.40, 98.50, - 98.60, 98.70, 98.80, 98.90, 99.00, 99.10, 99.20, 99.30, 99.40, 99.50, 99.60, 99.70, - 99.80, 99.90, 100.00, 100.10, 100.20, 100.30, 100.40, 100.50, 100.60, 100.70, 100.80, 100.90, - 101.00, 101.10, 101.20, 101.30, 101.40, 101.50, 101.60, 101.70, 101.80, 101.90, 102.00, 102.10, - 102.20, 102.30, 102.40, 102.50, 102.60, 102.70, 102.80, 102.90, 103.00, 103.10, 103.20, 103.30, - 103.40, 103.50, 103.60, 103.70, 103.80, 103.90, 104.00, 104.10, 104.20, 104.30, 104.40, 104.50, - 104.60, 104.70, 104.80, 104.90, 105.00, 105.10, 105.20, 105.30, 105.40, 105.50, 105.60, 105.70, - 105.80, 105.90, 106.00, 106.10, 106.20, 106.30, 106.40, 106.50, 106.60, 106.70, 106.80, 106.90, - 107.00, 107.10, 107.20, 107.30, 107.40, 107.50, 107.60, 107.70, 107.80, 107.90, 108.00, 108.10, - 108.20, 108.30, 108.40, 108.50, 108.60, 108.70, 108.80, 108.90, 109.00, 109.10, 109.20, 109.30, - 109.40, 109.50, 109.60, 109.70, 109.80, 109.90, 110.00, 110.10, 110.20, 110.30, 110.40, 110.50, - 110.60, 110.70, 110.80, 110.90, 111.00, 111.10, 111.20, 111.30, 111.40, 111.50, 111.60, 111.70, - 111.80, 111.90, 112.00, 112.10, 112.20, 112.30, 112.40, 112.50, 112.60, 112.70, 112.80, 112.90, - 113.00, 113.10, 113.20, 113.30, 113.40, 113.50, 113.60, 113.70, 113.80, 113.90, 114.00, 114.10, - 114.20, 114.30, 114.40, 114.50, 114.60, 114.70, 114.80, 114.90, 115.00, 115.10, 115.20, 115.30, - 115.40, 115.50, 115.60, 115.70, 115.80, 115.90, 116.00, 116.10, 116.20, 116.30, 116.40, 116.50, - 116.60, 116.70, 116.80, 116.90, 117.00, 117.10, 117.20, 117.30, 117.40, 117.50, 117.60, 117.70, - 117.80, 117.90, 118.00, 118.10, 118.20, 118.30, 118.40, 118.50, 118.60, 118.70, 118.80, 118.90, - 119.00, 119.10, 119.20, 119.30, 119.40, 119.50, 119.60, 119.70, 119.80, 119.90, 120.00, 120.10, - 120.20, 120.30, 120.40, 120.50, 120.60, 120.70, 120.80, 120.90, 121.00, 121.10, 121.20, 121.30, - 121.40, 121.50, 121.60, 121.70, 121.80, 121.90, 122.00, 122.10, 122.20, 122.30, 122.40, 122.50, - 122.60, 122.70, 122.80, 122.90, 123.00, 124.00, 124.10, 124.20, 124.30, 124.40, 124.50, 124.60, - 124.70, 124.80, 124.90, 125.00, 125.10, 125.20, 125.30, 125.40, 125.50, 125.60, 125.70}, - - {0.46118, 0.46267, 0.46260, 0.46062, 0.45988, 0.45750, 0.46021, 0.45820, 0.45774, 0.45697, - 0.45678, 0.45633, 0.45606, 0.45543, 0.45327, 0.45136, 0.45307, 0.45066, 0.45022, 0.45080, - 0.45273, 0.44948, 0.44888, 0.44860, 0.44675, 0.44709, 0.44582, 0.44565, 0.44609, 0.44360, - 0.44545, 0.44266, 0.44093, 0.43993, 0.44263, 0.43984, 0.44125, 0.43735, 0.43871, 0.43871, - 0.43657, 0.43548, 0.43303, 0.43389, 0.43231, 0.43082, 0.42820, 0.43007, 0.42968, 0.42675, - 0.42627, 0.42764, 0.42337, 0.42284, 0.42278, 0.42405, 0.42300, 0.42091, 0.42366, 0.41906, - 0.41808, 0.41793, 0.41369, 0.41378, 0.41458, 0.40974, 0.41490, 0.40885, 0.40906, 0.40843, - 0.40971, 0.40465, 0.40670, 0.40583, 0.40500, 0.40214, 0.39765, 0.39891, 0.39995, 0.39777, - 0.39554, 0.39643, 0.39355, 0.39314, 0.39298, 0.39014, 0.39016, 0.38465, 0.38676, 0.38720, - 0.38353, 0.38203, 0.38124, 0.37889, 0.37913, 0.38090, 0.37601, 0.37684, 0.37213, 0.37500, - 0.36958, 0.37097, 0.36830, 0.36682, 0.36694, 0.36576, 0.36606, 0.36664, 0.36577, 0.35699, - 0.35730, 0.36052, 0.35415, 0.35786, 0.35534, 0.35470, 0.35333, 0.34656, 0.34505, 0.34741, - 0.34548, 0.34278, 0.34095, 0.34258, 0.34055, 0.33822, 0.34134, 0.33565, 0.33245, 0.33118, - 0.33255, 0.33021, 0.33177, 0.32911, 0.32361, 0.32331, 0.32341, 0.31790, 0.32211, 0.31771, - 0.31716, 0.31626, 0.31212, 0.31109, 0.31258, 0.31131, 0.30939, 0.30945, 0.30670, 0.30392, - 0.30476, 0.29625, 0.29820, 0.29838, 0.29118, 0.29760, 0.29542, 0.29289, 0.29306, 0.29124, - 0.28701, 0.29202, 0.28291, 0.28125, 0.28487, 0.28201, 0.28330, 0.27724, 0.27599, 0.27545, - 0.27225, 0.26982, 0.27139, 0.27038, 0.26739, 0.27304, 0.26271, 0.26461, 0.26286, 0.26207, - 0.25751, 0.25496, 0.25117, 0.25785, 0.25969, 0.25750, 0.25104, 0.24651, 0.24727, 0.24331, - 0.24747, 0.24436, 0.24197, 0.24228, 0.23812, 0.23746, 0.24105, 0.23958, 0.23261, 0.23509, - 0.23063, 0.22904, 0.22771, 0.22589, 0.22494, 0.22919, 0.21779, 0.22510, 0.22190, 0.22851, - 0.22021, 0.21828, 0.21555, 0.21002, 0.21568, 0.21790, 0.21169, 0.20729, 0.20910, 0.20595, - 0.20535, 0.20659, 0.20241, 0.19891, 0.20217, 0.19881, 0.19875, 0.19408, 0.19711, 0.19132, - 0.19490, 0.19370, 0.19445, 0.18866, 0.19095, 0.18546, 0.18449, 0.18135, 0.18628, 0.18052, - 0.18081, 0.18175, 0.17860, 0.18217, 0.17379, 0.17589, 0.17549, 0.17115, 0.17109, 0.16823, - 0.16760, 0.16847, 0.16650, 0.16673, 0.16417, 0.15719, 0.16389, 0.16475, 0.16396, 0.15941, - 0.15694, 0.15821, 0.15311, 0.15547, 0.15958, 0.15608, 0.15193, 0.15027, 0.15130, 0.15188, - 0.14897, 0.14370, 0.14713, 0.14235, 0.13992, 0.13778, 0.14128, 0.14296, 0.13726, 0.13844, - 0.13587, 0.13568, 0.13714, 0.13412, 0.13302, 0.13634, 0.13058, 0.13133, 0.13256, 0.12865, - 0.12876, 0.12829, 0.12406, 0.12533, 0.12706, 0.12624, 0.11936, 0.11965, 0.11939, 0.11757, - 0.11776, 0.11811, 0.11718, 0.11292, 0.11913, 0.10995, 0.11550, 0.11022, 0.11052, 0.10881, - 0.10867, 0.10698, 0.10993, 0.10747, 0.10380, 0.10409, 0.10705, 0.10460, 0.10166, 0.10276, - 0.10485, 0.09890, 0.10002, 0.09657, 0.09693, 0.09508, 0.09633, 0.09700, 0.09512, 0.09168, - 0.09455, 0.09765, 0.09106, 0.09576, 0.09068, 0.09121, 0.09251, 0.08922, 0.08709, 0.08406, - 0.08608, 0.08811, 0.08714, 0.08411, 0.08723, 0.08366, 0.08314, 0.08139, 0.08106, 0.08273, - 0.07820, 0.08163, 0.07717, 0.07587, 0.07916, 0.07616, 0.07180, 0.07727, 0.07398, 0.07423, - 0.07447, 0.07200, 0.07306, 0.06731, 0.07200, 0.06953, 0.07260, 0.07068, 0.06838, 0.06614, - 0.06788, 0.06488, 0.06502, 0.06604, 0.06503, 0.06189, 0.06450, 0.06353, 0.06871, 0.06509, - 0.06091, 0.06271, 0.06141, 0.05912, 0.06207, 0.05918, 0.05966, 0.05936, 0.05913, 0.05385, - 0.05791, 0.05680, 0.05699, 0.05690, 0.05578, 0.05569, 0.05763, 0.05589, 0.05162, 0.05217, - 0.05249, 0.05286, 0.05150, 0.05125, 0.05162, 0.04853, 0.05216, 0.04819, 0.05178, 0.04746, - 0.04974, 0.05071, 0.04636, 0.04751, 0.04621, 0.04922, 0.04485, 0.04282, 0.04456, 0.04577, - 0.04733, 0.04461, 0.04297, 0.03982, 0.04220, 0.04204, 0.04470, 0.03948, 0.04224, 0.03938, - 0.04113, 0.03856, 0.03958, 0.03687, 0.03819, 0.03968, 0.03604, 0.03745, 0.03770, 0.03881, - 0.03740, 0.03711, 0.03711, 0.03750, 0.03827, 0.03633, 0.03664, 0.03596, 0.03561, 0.03440, - 0.03416, 0.03353, 0.03344, 0.03290, 0.03280, 0.03212, 0.03479, 0.03208, 0.03169, 0.03309, - 0.03087, 0.03068, 0.03111, 0.03014, 0.03140, 0.03072, 0.03159, 0.02948, 0.02990, 0.03048, - 0.03073, 0.02976, 0.02836, 0.03049, 0.02816, 0.02985, 0.02744, 0.02492, 0.02753, 0.02632, - 0.02492, 0.02622, 0.02767, 0.02521, 0.02632, 0.02540, 0.02395, 0.02473, 0.02274, 0.02603, - 0.02361, 0.02216, 0.02414, 0.02342, 0.02327, 0.02178, 0.02352, 0.02192, 0.02400, 0.02081, - 0.02298, 0.01936, 0.02235, 0.02110, 0.02090, 0.02042, 0.02318, 0.02076, 0.01984, 0.01979, - 0.02071, 0.01921, 0.02177, 0.02046, 0.01824, 0.01985, 0.01935, 0.01999, 0.01950, 0.02037, - 0.01824, 0.01713, 0.01912, 0.01771, 0.01959, 0.01809, 0.01877, 0.01690, 0.01863, 0.01684, - 0.01844, 0.01568, 0.01858, 0.01810, 0.01786, 0.01757, 0.01451, 0.01602, 0.01583, 0.01534, - 0.01389, 0.01630, 0.01461, 0.01572, 0.01592, 0.01519, 0.01655, 0.01476, 0.01345, 0.01369, - 0.01722, 0.01485, 0.01427, 0.01345, 0.01456, 0.01480, 0.01374, 0.01747, 0.01403, 0.01456, - 0.01442, 0.01209, 0.01239, 0.01311, 0.01268, 0.01253, 0.01195, 0.01306, 0.01249, 0.01355, - 0.01229, 0.01413, 0.01359, 0.01127, 0.01166, 0.01045, 0.01079, 0.01041, 0.01350, 0.01326, - 0.01060, 0.00977, 0.00905, 0.00856, 0.01248, 0.00943, 0.00992, 0.00987, 0.01074, 0.00943, - 0.01185, 0.01118, 0.00890, 0.00986, 0.00929, 0.00822, 0.00939, 0.00827, 0.00818}, - - {0.95430, 0.95690, 0.95710, 0.95300, 0.95170, 0.94690, 0.95250, 0.94820, 0.94680, 0.94550, - 0.94480, 0.94400, 0.94340, 0.94230, 0.93770, 0.93400, 0.93730, 0.93230, 0.93170, 0.93250, - 0.93700, 0.93000, 0.92880, 0.92830, 0.92400, 0.92500, 0.92250, 0.92190, 0.92260, 0.91810, - 0.92150, 0.91580, 0.91230, 0.91040, 0.91540, 0.91020, 0.91280, 0.90520, 0.90780, 0.90810, - 0.90300, 0.90080, 0.89620, 0.89770, 0.89490, 0.89140, 0.88610, 0.88970, 0.88870, 0.88260, - 0.88200, 0.88520, 0.87580, 0.87510, 0.87460, 0.87710, 0.87520, 0.87080, 0.87690, 0.86720, - 0.86490, 0.86480, 0.85620, 0.85650, 0.85760, 0.84760, 0.85830, 0.84620, 0.84630, 0.84530, - 0.84780, 0.83740, 0.84160, 0.83980, 0.83790, 0.83190, 0.82300, 0.82610, 0.82790, 0.82320, - 0.81820, 0.82010, 0.81460, 0.81430, 0.81360, 0.80740, 0.80730, 0.79670, 0.80050, 0.80120, - 0.79360, 0.79050, 0.78920, 0.78410, 0.78480, 0.78850, 0.77820, 0.78020, 0.77010, 0.77600, - 0.76480, 0.76720, 0.76240, 0.75910, 0.75940, 0.75700, 0.75770, 0.75840, 0.75710, 0.73930, - 0.73940, 0.74600, 0.73270, 0.74030, 0.73500, 0.73360, 0.73120, 0.71730, 0.71400, 0.71880, - 0.71490, 0.70910, 0.70550, 0.70900, 0.70450, 0.70000, 0.70600, 0.69440, 0.68800, 0.68560, - 0.68800, 0.68340, 0.68620, 0.68080, 0.66950, 0.66890, 0.66940, 0.65770, 0.66640, 0.65780, - 0.65660, 0.65440, 0.64580, 0.64390, 0.64670, 0.64380, 0.64030, 0.64000, 0.63430, 0.62900, - 0.63060, 0.61280, 0.61750, 0.61770, 0.60290, 0.61590, 0.61130, 0.60600, 0.60600, 0.60260, - 0.59420, 0.60440, 0.58570, 0.58170, 0.58960, 0.58370, 0.58660, 0.57360, 0.57090, 0.56980, - 0.56350, 0.55850, 0.56160, 0.55940, 0.55320, 0.56540, 0.54380, 0.54730, 0.54410, 0.54220, - 0.53280, 0.52760, 0.51980, 0.53340, 0.53730, 0.53260, 0.51970, 0.50970, 0.51180, 0.50390, - 0.51240, 0.50590, 0.50140, 0.50140, 0.49290, 0.49120, 0.49880, 0.49580, 0.48140, 0.48620, - 0.47760, 0.47370, 0.47130, 0.46800, 0.46530, 0.47400, 0.45070, 0.46620, 0.45950, 0.47260, - 0.45560, 0.45180, 0.44590, 0.43500, 0.44630, 0.45130, 0.43800, 0.42900, 0.43270, 0.42640, - 0.42490, 0.42720, 0.41910, 0.41150, 0.41870, 0.41130, 0.41100, 0.40170, 0.40770, 0.39580, - 0.40330, 0.40110, 0.40260, 0.39040, 0.39520, 0.38380, 0.38170, 0.37530, 0.38540, 0.37330, - 0.37410, 0.37630, 0.36970, 0.37700, 0.35940, 0.36390, 0.36300, 0.35430, 0.35430, 0.34790, - 0.34680, 0.34850, 0.34450, 0.34470, 0.33970, 0.32510, 0.33920, 0.34090, 0.33960, 0.33040, - 0.32500, 0.32710, 0.31720, 0.32180, 0.33020, 0.32280, 0.31430, 0.31060, 0.31280, 0.31410, - 0.30810, 0.29720, 0.30420, 0.29460, 0.28930, 0.28550, 0.29230, 0.29610, 0.28380, 0.28660, - 0.28110, 0.28090, 0.28390, 0.27740, 0.27540, 0.28190, 0.27000, 0.27190, 0.27410, 0.26600, - 0.26640, 0.26560, 0.25670, 0.25940, 0.26290, 0.26130, 0.24690, 0.24740, 0.24730, 0.24320, - 0.24350, 0.24440, 0.24220, 0.23360, 0.24650, 0.22780, 0.23900, 0.22790, 0.22890, 0.22520, - 0.22490, 0.22140, 0.22740, 0.22250, 0.21510, 0.21580, 0.22200, 0.21630, 0.21040, 0.21240, - 0.21700, 0.20470, 0.20710, 0.19970, 0.20080, 0.19680, 0.19940, 0.20060, 0.19670, 0.18960, - 0.19590, 0.20210, 0.18840, 0.19820, 0.18790, 0.18880, 0.19140, 0.18470, 0.18020, 0.17380, - 0.17820, 0.18240, 0.18040, 0.17400, 0.18040, 0.17310, 0.17220, 0.16860, 0.16790, 0.17110, - 0.16200, 0.16890, 0.15960, 0.15690, 0.16380, 0.15770, 0.14860, 0.15980, 0.15320, 0.15370, - 0.15430, 0.14900, 0.15110, 0.13940, 0.14900, 0.14390, 0.15050, 0.14610, 0.14160, 0.13680, - 0.14040, 0.13420, 0.13440, 0.13650, 0.13460, 0.12820, 0.13350, 0.13150, 0.14210, 0.13480, - 0.12600, 0.12990, 0.12710, 0.12230, 0.12840, 0.12250, 0.12340, 0.12270, 0.12240, 0.11140, - 0.11970, 0.11740, 0.11780, 0.11780, 0.11530, 0.11520, 0.11940, 0.11570, 0.10680, 0.10820, - 0.10850, 0.10980, 0.10690, 0.10620, 0.10680, 0.10040, 0.10790, 0.09990, 0.10720, 0.09820, - 0.10300, 0.10490, 0.09600, 0.09820, 0.09570, 0.10200, 0.09280, 0.08860, 0.09210, 0.09460, - 0.09810, 0.09240, 0.08890, 0.08230, 0.08740, 0.08690, 0.09240, 0.08180, 0.08750, 0.08140, - 0.08510, 0.07970, 0.08190, 0.07620, 0.07920, 0.08220, 0.07450, 0.07750, 0.07810, 0.08040, - 0.07740, 0.07670, 0.07670, 0.07760, 0.07920, 0.07510, 0.07610, 0.07460, 0.07360, 0.07120, - 0.07060, 0.06940, 0.06920, 0.06810, 0.06780, 0.06640, 0.07210, 0.06630, 0.06550, 0.06840, - 0.06390, 0.06350, 0.06430, 0.06230, 0.06490, 0.06350, 0.06530, 0.06120, 0.06180, 0.06300, - 0.06360, 0.06160, 0.05880, 0.06320, 0.05830, 0.06170, 0.05680, 0.05150, 0.05690, 0.05450, - 0.05150, 0.05430, 0.05720, 0.05210, 0.05450, 0.05260, 0.04950, 0.05120, 0.04700, 0.05380, - 0.04880, 0.04590, 0.05000, 0.04840, 0.04810, 0.04520, 0.04870, 0.04530, 0.04960, 0.04310, - 0.04750, 0.04020, 0.04630, 0.04370, 0.04320, 0.04230, 0.04800, 0.04300, 0.04100, 0.04100, - 0.04280, 0.03970, 0.04500, 0.04230, 0.03780, 0.04120, 0.04000, 0.04140, 0.04030, 0.04220, - 0.03780, 0.03540, 0.03970, 0.03670, 0.04050, 0.03740, 0.03880, 0.03510, 0.03860, 0.03490, - 0.03820, 0.03250, 0.03850, 0.03750, 0.03710, 0.03640, 0.03000, 0.03320, 0.03290, 0.03170, - 0.02880, 0.03370, 0.03020, 0.03250, 0.03290, 0.03140, 0.03420, 0.03050, 0.02780, 0.02830, - 0.03560, 0.03070, 0.02950, 0.02780, 0.03010, 0.03060, 0.02840, 0.03620, 0.02900, 0.03010, - 0.02980, 0.02500, 0.02560, 0.02710, 0.02630, 0.02590, 0.02470, 0.02700, 0.02590, 0.02810, - 0.02540, 0.02930, 0.02810, 0.02330, 0.02410, 0.02160, 0.02230, 0.02160, 0.02800, 0.02740, - 0.02200, 0.02020, 0.01870, 0.01770, 0.02580, 0.01950, 0.02050, 0.02040, 0.02220, 0.01950, - 0.02450, 0.02310, 0.01840, 0.02050, 0.01930, 0.01700, 0.01940, 0.01710, 0.01690}, - - {0.04361, 0.04124, 0.04106, 0.04479, 0.04597, 0.05028, 0.04524, 0.04912, 0.05037, 0.05153, - 0.05215, 0.05286, 0.05340, 0.05437, 0.05842, 0.06164, 0.05877, 0.06312, 0.06363, 0.06294, - 0.05903, 0.06510, 0.06613, 0.06656, 0.07022, 0.06938, 0.07149, 0.07200, 0.07141, 0.07519, - 0.07234, 0.07711, 0.08001, 0.08157, 0.07744, 0.08174, 0.07960, 0.08581, 0.08370, 0.08345, - 0.08759, 0.08936, 0.09303, 0.09183, 0.09405, 0.09681, 0.10093, 0.09813, 0.09891, 0.10362, - 0.10408, 0.10162, 0.10877, 0.10930, 0.10967, 0.10780, 0.10923, 0.11251, 0.10795, 0.11516, - 0.11685, 0.11692, 0.12312, 0.12291, 0.12212, 0.12917, 0.12162, 0.13015, 0.13008, 0.13077, - 0.12904, 0.13616, 0.13331, 0.13454, 0.13582, 0.13984, 0.14567, 0.14366, 0.14248, 0.14554, - 0.14875, 0.14754, 0.15103, 0.15122, 0.15166, 0.15551, 0.15557, 0.16197, 0.15970, 0.15928, - 0.16380, 0.16561, 0.16636, 0.16929, 0.16889, 0.16677, 0.17261, 0.17149, 0.17705, 0.17382, - 0.17988, 0.17860, 0.18115, 0.18287, 0.18271, 0.18395, 0.18359, 0.18323, 0.18390, 0.19274, - 0.19269, 0.18948, 0.19585, 0.19226, 0.19478, 0.19543, 0.19655, 0.20278, 0.20420, 0.20213, - 0.20382, 0.20628, 0.20777, 0.20632, 0.20818, 0.21000, 0.20756, 0.21221, 0.21466, 0.21555, - 0.21466, 0.21636, 0.21533, 0.21731, 0.22127, 0.22147, 0.22130, 0.22513, 0.22231, 0.22510, - 0.22548, 0.22616, 0.22874, 0.22929, 0.22848, 0.22932, 0.23032, 0.23040, 0.23196, 0.23336, - 0.23294, 0.23728, 0.23619, 0.23615, 0.23941, 0.23657, 0.23761, 0.23876, 0.23876, 0.23947, - 0.24113, 0.23910, 0.24266, 0.24333, 0.24197, 0.24299, 0.24250, 0.24458, 0.24497, 0.24513, - 0.24597, 0.24658, 0.24621, 0.24647, 0.24717, 0.24572, 0.24808, 0.24776, 0.24805, 0.24822, - 0.24892, 0.24924, 0.24961, 0.24888, 0.24861, 0.24894, 0.24961, 0.24991, 0.24986, 0.24999, - 0.24985, 0.24996, 0.25000, 0.25000, 0.24995, 0.24992, 0.25000, 0.24998, 0.24965, 0.24981, - 0.24950, 0.24931, 0.24918, 0.24898, 0.24880, 0.24932, 0.24757, 0.24886, 0.24836, 0.24925, - 0.24803, 0.24768, 0.24707, 0.24577, 0.24712, 0.24763, 0.24616, 0.24496, 0.24547, 0.24458, - 0.24436, 0.24470, 0.24346, 0.24217, 0.24339, 0.24213, 0.24208, 0.24034, 0.24148, 0.23914, - 0.24065, 0.24022, 0.24051, 0.23799, 0.23902, 0.23650, 0.23600, 0.23445, 0.23687, 0.23395, - 0.23415, 0.23470, 0.23302, 0.23487, 0.23023, 0.23148, 0.23123, 0.22877, 0.22877, 0.22687, - 0.22653, 0.22705, 0.22582, 0.22588, 0.22430, 0.21941, 0.22414, 0.22469, 0.22427, 0.22124, - 0.21937, 0.22011, 0.21658, 0.21824, 0.22117, 0.21860, 0.21552, 0.21413, 0.21496, 0.21544, - 0.21317, 0.20887, 0.21166, 0.20781, 0.20561, 0.20399, 0.20686, 0.20842, 0.20326, 0.20446, - 0.20208, 0.20200, 0.20330, 0.20045, 0.19956, 0.20243, 0.19710, 0.19797, 0.19897, 0.19524, - 0.19543, 0.19506, 0.19081, 0.19211, 0.19378, 0.19302, 0.18594, 0.18619, 0.18614, 0.18405, - 0.18421, 0.18467, 0.18354, 0.17903, 0.18574, 0.17591, 0.18188, 0.17596, 0.17650, 0.17449, - 0.17432, 0.17238, 0.17569, 0.17299, 0.16883, 0.16923, 0.17272, 0.16951, 0.16613, 0.16729, - 0.16991, 0.16280, 0.16421, 0.15982, 0.16048, 0.15807, 0.15964, 0.16036, 0.15801, 0.15365, - 0.15752, 0.16126, 0.15291, 0.15892, 0.15259, 0.15316, 0.15477, 0.15059, 0.14773, 0.14359, - 0.14644, 0.14913, 0.14786, 0.14372, 0.14786, 0.14314, 0.14255, 0.14017, 0.13971, 0.14183, - 0.13576, 0.14037, 0.13413, 0.13228, 0.13697, 0.13283, 0.12652, 0.13426, 0.12973, 0.13008, - 0.13049, 0.12680, 0.12827, 0.11997, 0.12680, 0.12319, 0.12785, 0.12476, 0.12155, 0.11809, - 0.12069, 0.11619, 0.11634, 0.11787, 0.11648, 0.11177, 0.11568, 0.11421, 0.12191, 0.11663, - 0.11012, 0.11303, 0.11095, 0.10734, 0.11191, 0.10749, 0.10817, 0.10765, 0.10742, 0.09899, - 0.10537, 0.10362, 0.10392, 0.10392, 0.10201, 0.10193, 0.10514, 0.10231, 0.09539, 0.09649, - 0.09673, 0.09774, 0.09547, 0.09492, 0.09539, 0.09032, 0.09626, 0.08992, 0.09571, 0.08856, - 0.09239, 0.09390, 0.08678, 0.08856, 0.08654, 0.09160, 0.08419, 0.08075, 0.08362, 0.08565, - 0.08848, 0.08386, 0.08100, 0.07553, 0.07976, 0.07935, 0.08386, 0.07511, 0.07984, 0.07477, - 0.07786, 0.07335, 0.07519, 0.07039, 0.07293, 0.07544, 0.06895, 0.07149, 0.07200, 0.07394, - 0.07141, 0.07082, 0.07082, 0.07158, 0.07293, 0.06946, 0.07031, 0.06903, 0.06818, 0.06613, - 0.06562, 0.06458, 0.06441, 0.06346, 0.06320, 0.06199, 0.06690, 0.06190, 0.06121, 0.06372, - 0.05982, 0.05947, 0.06017, 0.05842, 0.06069, 0.05947, 0.06104, 0.05745, 0.05798, 0.05903, - 0.05955, 0.05781, 0.05534, 0.05921, 0.05490, 0.05789, 0.05357, 0.04885, 0.05366, 0.05153, - 0.04885, 0.05135, 0.05393, 0.04939, 0.05153, 0.04983, 0.04705, 0.04858, 0.04479, 0.05091, - 0.04642, 0.04379, 0.04750, 0.04606, 0.04579, 0.04316, 0.04633, 0.04325, 0.04714, 0.04124, - 0.04524, 0.03858, 0.04416, 0.04179, 0.04133, 0.04051, 0.04570, 0.04115, 0.03932, 0.03932, - 0.04097, 0.03812, 0.04297, 0.04051, 0.03637, 0.03950, 0.03840, 0.03969, 0.03868, 0.04042, - 0.03637, 0.03415, 0.03812, 0.03535, 0.03886, 0.03600, 0.03730, 0.03387, 0.03711, 0.03368, - 0.03674, 0.03144, 0.03702, 0.03609, 0.03572, 0.03508, 0.02910, 0.03210, 0.03182, 0.03070, - 0.02797, 0.03256, 0.02929, 0.03144, 0.03182, 0.03041, 0.03303, 0.02957, 0.02703, 0.02750, - 0.03433, 0.02976, 0.02863, 0.02703, 0.02919, 0.02966, 0.02759, 0.03489, 0.02816, 0.02919, - 0.02891, 0.02438, 0.02494, 0.02637, 0.02561, 0.02523, 0.02409, 0.02627, 0.02523, 0.02731, - 0.02475, 0.02844, 0.02731, 0.02276, 0.02352, 0.02113, 0.02180, 0.02113, 0.02722, 0.02665, - 0.02152, 0.01979, 0.01835, 0.01739, 0.02513, 0.01912, 0.02008, 0.01998, 0.02171, 0.01912, - 0.02390, 0.02257, 0.01806, 0.02008, 0.01893, 0.01671, 0.01902, 0.01681, 0.01661}, - - {0.95021, 0.95292, 0.95313, 0.94885, 0.94750, 0.94251, 0.94833, 0.94386, 0.94240, 0.94105, - 0.94032, 0.93949, 0.93887, 0.93773, 0.93296, 0.92913, 0.93255, 0.92738, 0.92676, 0.92758, - 0.93224, 0.92500, 0.92376, 0.92324, 0.91881, 0.91984, 0.91726, 0.91664, 0.91736, 0.91273, - 0.91623, 0.91036, 0.90676, 0.90480, 0.90995, 0.90460, 0.90727, 0.89946, 0.90213, 0.90244, - 0.89720, 0.89494, 0.89022, 0.89176, 0.88889, 0.88530, 0.87987, 0.88356, 0.88254, 0.87629, - 0.87568, 0.87895, 0.86934, 0.86862, 0.86811, 0.87067, 0.86872, 0.86423, 0.87046, 0.86055, - 0.85820, 0.85810, 0.84932, 0.84963, 0.85075, 0.84056, 0.85147, 0.83913, 0.83923, 0.83821, - 0.84076, 0.83017, 0.83444, 0.83261, 0.83068, 0.82457, 0.81552, 0.81867, 0.82050, 0.81572, - 0.81064, 0.81257, 0.80698, 0.80668, 0.80597, 0.79967, 0.79957, 0.78881, 0.79267, 0.79338, - 0.78567, 0.78252, 0.78121, 0.77604, 0.77675, 0.78050, 0.77006, 0.77208, 0.76185, 0.76783, - 0.75649, 0.75892, 0.75406, 0.75072, 0.75102, 0.74859, 0.74930, 0.75001, 0.74869, 0.73069, - 0.73080, 0.73747, 0.72403, 0.73171, 0.72635, 0.72493, 0.72251, 0.70847, 0.70514, 0.70999, - 0.70605, 0.70020, 0.69657, 0.70010, 0.69556, 0.69102, 0.69707, 0.68537, 0.67892, 0.67650, - 0.67892, 0.67428, 0.67710, 0.67166, 0.66028, 0.65968, 0.66018, 0.64840, 0.65716, 0.64850, - 0.64729, 0.64508, 0.63643, 0.63452, 0.63733, 0.63441, 0.63089, 0.63059, 0.62486, 0.61953, - 0.62114, 0.60325, 0.60797, 0.60818, 0.59331, 0.60637, 0.60175, 0.59642, 0.59642, 0.59301, - 0.58457, 0.59482, 0.57605, 0.57203, 0.57996, 0.57404, 0.57695, 0.56391, 0.56120, 0.56010, - 0.55378, 0.54877, 0.55188, 0.54967, 0.54346, 0.55568, 0.53404, 0.53754, 0.53434, 0.53243, - 0.52302, 0.51782, 0.51001, 0.52362, 0.52753, 0.52282, 0.50991, 0.49990, 0.50200, 0.49410, - 0.50260, 0.49610, 0.49160, 0.49160, 0.48310, 0.48140, 0.48900, 0.48600, 0.47161, 0.47640, - 0.46781, 0.46391, 0.46152, 0.45822, 0.45552, 0.46421, 0.44095, 0.45642, 0.44973, 0.46281, - 0.44584, 0.44205, 0.43616, 0.42528, 0.43656, 0.44155, 0.42828, 0.41930, 0.42299, 0.41671, - 0.41521, 0.41750, 0.40943, 0.40186, 0.40903, 0.40165, 0.40136, 0.39209, 0.39807, 0.38621, - 0.39369, 0.39149, 0.39299, 0.38084, 0.38562, 0.37427, 0.37218, 0.36581, 0.37586, 0.36382, - 0.36462, 0.36680, 0.36024, 0.36750, 0.35000, 0.35447, 0.35357, 0.34492, 0.34492, 0.33856, - 0.33747, 0.33916, 0.33519, 0.33538, 0.33042, 0.31592, 0.32992, 0.33161, 0.33032, 0.32118, - 0.31582, 0.31790, 0.30808, 0.31264, 0.32098, 0.31364, 0.30520, 0.30153, 0.30371, 0.30500, - 0.29905, 0.28824, 0.29518, 0.28567, 0.28041, 0.27665, 0.28339, 0.28715, 0.27496, 0.27774, - 0.27229, 0.27209, 0.27506, 0.26863, 0.26664, 0.27308, 0.26130, 0.26318, 0.26536, 0.25734, - 0.25773, 0.25694, 0.24814, 0.25081, 0.25427, 0.25269, 0.23845, 0.23894, 0.23884, 0.23479, - 0.23509, 0.23598, 0.23380, 0.22531, 0.23805, 0.21958, 0.23064, 0.21968, 0.22067, 0.21701, - 0.21672, 0.21326, 0.21918, 0.21435, 0.20705, 0.20774, 0.21385, 0.20823, 0.20241, 0.20438, - 0.20892, 0.19679, 0.19916, 0.19186, 0.19295, 0.18901, 0.19157, 0.19275, 0.18891, 0.18192, - 0.18812, 0.19423, 0.18074, 0.19039, 0.18024, 0.18113, 0.18369, 0.17709, 0.17267, 0.16637, - 0.17070, 0.17483, 0.17286, 0.16657, 0.17286, 0.16568, 0.16480, 0.16126, 0.16057, 0.16372, - 0.15478, 0.16156, 0.15242, 0.14977, 0.15655, 0.15056, 0.14163, 0.15262, 0.14614, 0.14663, - 0.14722, 0.14202, 0.14408, 0.13261, 0.14202, 0.13702, 0.14349, 0.13918, 0.13477, 0.13006, - 0.13359, 0.12752, 0.12771, 0.12977, 0.12791, 0.12165, 0.12683, 0.12488, 0.13526, 0.12811, - 0.11950, 0.12331, 0.12057, 0.11588, 0.12184, 0.11607, 0.11695, 0.11627, 0.11598, 0.10523, - 0.11334, 0.11109, 0.11148, 0.11148, 0.10904, 0.10894, 0.11305, 0.10943, 0.10075, 0.10211, - 0.10240, 0.10367, 0.10084, 0.10016, 0.10075, 0.09451, 0.10182, 0.09402, 0.10114, 0.09237, - 0.09704, 0.09889, 0.09023, 0.09237, 0.08993, 0.09607, 0.08711, 0.08303, 0.08643, 0.08886, - 0.09227, 0.08672, 0.08332, 0.07691, 0.08186, 0.08138, 0.08672, 0.07643, 0.08196, 0.07604, - 0.07963, 0.07439, 0.07652, 0.07100, 0.07391, 0.07682, 0.06935, 0.07226, 0.07284, 0.07507, - 0.07216, 0.07148, 0.07148, 0.07236, 0.07391, 0.06993, 0.07090, 0.06945, 0.06848, 0.06616, - 0.06558, 0.06442, 0.06423, 0.06316, 0.06287, 0.06152, 0.06703, 0.06142, 0.06065, 0.06345, - 0.05911, 0.05872, 0.05949, 0.05756, 0.06007, 0.05872, 0.06046, 0.05650, 0.05708, 0.05824, - 0.05882, 0.05689, 0.05419, 0.05843, 0.05371, 0.05698, 0.05226, 0.04717, 0.05236, 0.05005, - 0.04717, 0.04986, 0.05265, 0.04774, 0.05005, 0.04822, 0.04525, 0.04688, 0.04285, 0.04938, - 0.04458, 0.04180, 0.04573, 0.04419, 0.04391, 0.04113, 0.04448, 0.04122, 0.04535, 0.03912, - 0.04333, 0.03635, 0.04218, 0.03969, 0.03921, 0.03836, 0.04381, 0.03902, 0.03711, 0.03711, - 0.03883, 0.03587, 0.04094, 0.03836, 0.03406, 0.03730, 0.03616, 0.03750, 0.03644, 0.03826, - 0.03406, 0.03178, 0.03587, 0.03302, 0.03664, 0.03368, 0.03501, 0.03149, 0.03482, 0.03130, - 0.03444, 0.02902, 0.03473, 0.03378, 0.03340, 0.03273, 0.02666, 0.02969, 0.02940, 0.02827, - 0.02552, 0.03016, 0.02685, 0.02902, 0.02940, 0.02798, 0.03064, 0.02713, 0.02458, 0.02505, - 0.03197, 0.02732, 0.02618, 0.02458, 0.02675, 0.02722, 0.02514, 0.03254, 0.02571, 0.02675, - 0.02647, 0.02194, 0.02250, 0.02392, 0.02316, 0.02279, 0.02166, 0.02382, 0.02279, 0.02486, - 0.02232, 0.02600, 0.02486, 0.02034, 0.02109, 0.01875, 0.01941, 0.01875, 0.02477, 0.02420, - 0.01912, 0.01744, 0.01605, 0.01512, 0.02269, 0.01679, 0.01772, 0.01763, 0.01931, 0.01679, - 0.02147, 0.02016, 0.01577, 0.01772, 0.01660, 0.01447, 0.01670, 0.01456, 0.01437}, - - {0.95839, 0.96088, 0.96107, 0.95715, 0.95590, 0.95130, 0.95667, 0.95254, 0.95120, 0.94995, - 0.94928, 0.94851, 0.94793, 0.94687, 0.94244, 0.93887, 0.94205, 0.93722, 0.93664, 0.93742, - 0.94176, 0.93500, 0.93384, 0.93336, 0.92919, 0.93016, 0.92774, 0.92716, 0.92784, 0.92348, - 0.92677, 0.92124, 0.91784, 0.91600, 0.92085, 0.91580, 0.91833, 0.91094, 0.91347, 0.91376, - 0.90880, 0.90666, 0.90218, 0.90364, 0.90091, 0.89750, 0.89233, 0.89584, 0.89486, 0.88891, - 0.88832, 0.89145, 0.88226, 0.88158, 0.88109, 0.88353, 0.88168, 0.87737, 0.88334, 0.87385, - 0.87160, 0.87150, 0.86308, 0.86337, 0.86445, 0.85464, 0.86513, 0.85327, 0.85337, 0.85239, - 0.85484, 0.84463, 0.84876, 0.84699, 0.84512, 0.83923, 0.83048, 0.83353, 0.83530, 0.83068, - 0.82576, 0.82763, 0.82222, 0.82192, 0.82123, 0.81513, 0.81503, 0.80459, 0.80833, 0.80902, - 0.80153, 0.79848, 0.79719, 0.79216, 0.79285, 0.79650, 0.78634, 0.78832, 0.77835, 0.78417, - 0.77311, 0.77548, 0.77074, 0.76748, 0.76778, 0.76541, 0.76610, 0.76679, 0.76550, 0.74791, - 0.74800, 0.75453, 0.74137, 0.74889, 0.74365, 0.74226, 0.73989, 0.72613, 0.72286, 0.72761, - 0.72375, 0.71800, 0.71443, 0.71790, 0.71344, 0.70898, 0.71493, 0.70343, 0.69708, 0.69470, - 0.69708, 0.69252, 0.69529, 0.68994, 0.67872, 0.67812, 0.67862, 0.66700, 0.67564, 0.66710, - 0.66591, 0.66372, 0.65517, 0.65329, 0.65607, 0.65319, 0.64971, 0.64941, 0.64374, 0.63847, - 0.64006, 0.62235, 0.62703, 0.62723, 0.61249, 0.62543, 0.62085, 0.61558, 0.61558, 0.61219, - 0.60382, 0.61398, 0.59535, 0.59137, 0.59924, 0.59336, 0.59625, 0.58329, 0.58060, 0.57950, - 0.57322, 0.56823, 0.57132, 0.56913, 0.56294, 0.57512, 0.55356, 0.55706, 0.55386, 0.55197, - 0.54258, 0.53739, 0.52959, 0.54318, 0.54707, 0.54238, 0.52949, 0.51950, 0.52160, 0.51370, - 0.52220, 0.51570, 0.51120, 0.51120, 0.50270, 0.50100, 0.50860, 0.50560, 0.49119, 0.49600, - 0.48739, 0.48349, 0.48108, 0.47778, 0.47508, 0.48379, 0.46045, 0.47598, 0.46927, 0.48239, - 0.46536, 0.46155, 0.45564, 0.44472, 0.45604, 0.46105, 0.44772, 0.43870, 0.44241, 0.43609, - 0.43459, 0.43690, 0.42877, 0.42114, 0.42837, 0.42095, 0.42064, 0.41131, 0.41733, 0.40538, - 0.41291, 0.41071, 0.41221, 0.39996, 0.40478, 0.39333, 0.39122, 0.38479, 0.39494, 0.38278, - 0.38358, 0.38579, 0.37916, 0.38650, 0.36880, 0.37333, 0.37243, 0.36368, 0.36368, 0.35724, - 0.35613, 0.35784, 0.35381, 0.35402, 0.34898, 0.33428, 0.34848, 0.35019, 0.34888, 0.33962, - 0.33418, 0.33630, 0.32632, 0.33096, 0.33942, 0.33196, 0.32340, 0.31967, 0.32189, 0.32320, - 0.31715, 0.30616, 0.31322, 0.30353, 0.29819, 0.29435, 0.30121, 0.30505, 0.29264, 0.29546, - 0.28991, 0.28971, 0.29274, 0.28618, 0.28416, 0.29072, 0.27870, 0.28062, 0.28284, 0.27466, - 0.27507, 0.27426, 0.26526, 0.26799, 0.27153, 0.26991, 0.25535, 0.25586, 0.25576, 0.25161, - 0.25191, 0.25282, 0.25060, 0.24189, 0.25495, 0.23602, 0.24736, 0.23612, 0.23713, 0.23339, - 0.23308, 0.22954, 0.23561, 0.23065, 0.22315, 0.22386, 0.23015, 0.22437, 0.21839, 0.22042, - 0.22508, 0.21261, 0.21504, 0.20754, 0.20865, 0.20459, 0.20723, 0.20845, 0.20449, 0.19728, - 0.20368, 0.20997, 0.19606, 0.20601, 0.19556, 0.19647, 0.19911, 0.19231, 0.18773, 0.18123, - 0.18570, 0.18997, 0.18794, 0.18143, 0.18794, 0.18052, 0.17960, 0.17594, 0.17523, 0.17848, - 0.16922, 0.17624, 0.16678, 0.16403, 0.17105, 0.16484, 0.15557, 0.16698, 0.16026, 0.16077, - 0.16138, 0.15598, 0.15812, 0.14619, 0.15598, 0.15078, 0.15751, 0.15302, 0.14843, 0.14353, - 0.14721, 0.14088, 0.14108, 0.14323, 0.14129, 0.13475, 0.14017, 0.13812, 0.14894, 0.14149, - 0.13250, 0.13649, 0.13363, 0.12872, 0.13496, 0.12893, 0.12985, 0.12913, 0.12882, 0.11757, - 0.12606, 0.12371, 0.12412, 0.12412, 0.12156, 0.12146, 0.12576, 0.12197, 0.11285, 0.11429, - 0.11460, 0.11593, 0.11296, 0.11224, 0.11285, 0.10629, 0.11398, 0.10578, 0.11326, 0.10403, - 0.10896, 0.11091, 0.10177, 0.10403, 0.10147, 0.10793, 0.09849, 0.09417, 0.09777, 0.10034, - 0.10393, 0.09808, 0.09448, 0.08769, 0.09294, 0.09242, 0.09808, 0.08717, 0.09304, 0.08676, - 0.09057, 0.08501, 0.08728, 0.08140, 0.08449, 0.08758, 0.07965, 0.08274, 0.08336, 0.08573, - 0.08264, 0.08192, 0.08192, 0.08284, 0.08449, 0.08027, 0.08130, 0.07975, 0.07872, 0.07624, - 0.07562, 0.07438, 0.07417, 0.07304, 0.07273, 0.07128, 0.07717, 0.07118, 0.07035, 0.07335, - 0.06869, 0.06828, 0.06911, 0.06704, 0.06973, 0.06828, 0.07014, 0.06590, 0.06652, 0.06776, - 0.06838, 0.06631, 0.06341, 0.06797, 0.06289, 0.06642, 0.06134, 0.05583, 0.06144, 0.05895, - 0.05583, 0.05874, 0.06175, 0.05646, 0.05895, 0.05697, 0.05375, 0.05552, 0.05115, 0.05822, - 0.05302, 0.05000, 0.05427, 0.05261, 0.05229, 0.04927, 0.05292, 0.04938, 0.05386, 0.04708, - 0.05167, 0.04405, 0.05042, 0.04771, 0.04718, 0.04625, 0.05219, 0.04698, 0.04489, 0.04489, - 0.04677, 0.04353, 0.04906, 0.04625, 0.04154, 0.04510, 0.04384, 0.04530, 0.04415, 0.04614, - 0.04154, 0.03902, 0.04353, 0.04038, 0.04436, 0.04112, 0.04258, 0.03871, 0.04238, 0.03850, - 0.04196, 0.03598, 0.04227, 0.04122, 0.04081, 0.04007, 0.03334, 0.03671, 0.03640, 0.03513, - 0.03208, 0.03724, 0.03355, 0.03598, 0.03640, 0.03482, 0.03776, 0.03387, 0.03102, 0.03155, - 0.03923, 0.03408, 0.03282, 0.03102, 0.03345, 0.03398, 0.03166, 0.03986, 0.03229, 0.03345, - 0.03313, 0.02806, 0.02870, 0.03028, 0.02944, 0.02901, 0.02774, 0.03018, 0.02901, 0.03134, - 0.02848, 0.03261, 0.03134, 0.02626, 0.02711, 0.02445, 0.02519, 0.02445, 0.03123, 0.03060, - 0.02488, 0.02296, 0.02135, 0.02028, 0.02891, 0.02221, 0.02328, 0.02317, 0.02509, 0.02221, - 0.02753, 0.02604, 0.02103, 0.02328, 0.02200, 0.01953, 0.02210, 0.01964, 0.01943}, -}; - -/** @}*/ -} // namespace ns3 - -#endif /* WIMAX_DEFAULT_TRACES_H */ diff --git a/src/wimax/model/dl-mac-messages.cc b/src/wimax/model/dl-mac-messages.cc deleted file mode 100644 index 15449706b..000000000 --- a/src/wimax/model/dl-mac-messages.cc +++ /dev/null @@ -1,657 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "dl-mac-messages.h" - -#include "ns3/address-utils.h" - -#include - -namespace ns3 -{ - -DcdChannelEncodings::DcdChannelEncodings() - : m_bsEirp(0), - m_eirXPIrMax(0), - m_frequency(0) -{ -} - -DcdChannelEncodings::~DcdChannelEncodings() -{ -} - -void -DcdChannelEncodings::SetBsEirp(uint16_t bs_eirp) -{ - m_bsEirp = bs_eirp; -} - -void -DcdChannelEncodings::SetEirxPIrMax(uint16_t eir_x_p_ir_max) -{ - m_eirXPIrMax = eir_x_p_ir_max; -} - -void -DcdChannelEncodings::SetFrequency(uint32_t frequency) -{ - m_frequency = frequency; -} - -uint16_t -DcdChannelEncodings::GetBsEirp() const -{ - return m_bsEirp; -} - -uint16_t -DcdChannelEncodings::GetEirxPIrMax() const -{ - return m_eirXPIrMax; -} - -uint32_t -DcdChannelEncodings::GetFrequency() const -{ - return m_frequency; -} - -uint16_t -DcdChannelEncodings::GetSize() const -{ - return 2 + 2 + 4; -} - -Buffer::Iterator -DcdChannelEncodings::Write(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU16(m_bsEirp); - i.WriteU16(m_eirXPIrMax); - i.WriteU32(m_frequency); - return DoWrite(i); -} - -Buffer::Iterator -DcdChannelEncodings::Read(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_bsEirp = i.ReadU16(); - m_eirXPIrMax = i.ReadU16(); - m_frequency = i.ReadU32(); - return DoRead(i); -} - -// ---------------------------------------------------------------------------------------------------------- - -OfdmDcdChannelEncodings::OfdmDcdChannelEncodings() - : m_channelNr(0), - m_ttg(0), - m_rtg(0), - m_baseStationId(Mac48Address("00:00:00:00:00:00")), - m_frameDurationCode(0), - m_frameNumber(0) -{ -} - -OfdmDcdChannelEncodings::~OfdmDcdChannelEncodings() -{ -} - -void -OfdmDcdChannelEncodings::SetChannelNr(uint8_t channelNr) -{ - m_channelNr = channelNr; -} - -void -OfdmDcdChannelEncodings::SetTtg(uint8_t ttg) -{ - m_ttg = ttg; -} - -void -OfdmDcdChannelEncodings::SetRtg(uint8_t rtg) -{ - m_rtg = rtg; -} - -void -OfdmDcdChannelEncodings::SetBaseStationId(Mac48Address baseStationId) -{ - m_baseStationId = baseStationId; -} - -void -OfdmDcdChannelEncodings::SetFrameDurationCode(uint8_t frameDurationCode) -{ - m_frameDurationCode = frameDurationCode; -} - -void -OfdmDcdChannelEncodings::SetFrameNumber(uint32_t frameNumber) -{ - m_frameNumber = frameNumber; -} - -uint8_t -OfdmDcdChannelEncodings::GetChannelNr() const -{ - return m_channelNr; -} - -uint8_t -OfdmDcdChannelEncodings::GetTtg() const -{ - return m_ttg; -} - -uint8_t -OfdmDcdChannelEncodings::GetRtg() const -{ - return m_rtg; -} - -Mac48Address -OfdmDcdChannelEncodings::GetBaseStationId() const -{ - return m_baseStationId; -} - -uint8_t -OfdmDcdChannelEncodings::GetFrameDurationCode() const -{ - return m_frameDurationCode; -} - -uint32_t -OfdmDcdChannelEncodings::GetFrameNumber() const -{ - return m_frameNumber; -} - -uint16_t -OfdmDcdChannelEncodings::GetSize() const -{ - return DcdChannelEncodings::GetSize() + 1 + 1 + 1 + 6 + 1 + 4; -} - -Buffer::Iterator -OfdmDcdChannelEncodings::DoWrite(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_channelNr); - i.WriteU8(m_ttg); - i.WriteU8(m_rtg); - WriteTo(i, m_baseStationId); - i.WriteU8(m_frameDurationCode); - i.WriteU32(m_frameNumber); - return i; -} - -Buffer::Iterator -OfdmDcdChannelEncodings::DoRead(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_channelNr = i.ReadU8(); - m_ttg = i.ReadU8(); - m_rtg = i.ReadU8(); - ReadFrom(i, m_baseStationId); // length (6) shall also be written in packet instead of hard - // coded, see ARP example - m_frameDurationCode = i.ReadU8(); - m_frameNumber = i.ReadU32(); - return i; -} - -// ---------------------------------------------------------------------------------------------------------- - -OfdmDlBurstProfile::OfdmDlBurstProfile() - : m_type(0), - m_length(0), - m_diuc(0), - m_fecCodeType(0) -{ -} - -OfdmDlBurstProfile::~OfdmDlBurstProfile() -{ -} - -void -OfdmDlBurstProfile::SetType(uint8_t type) -{ - m_type = type; -} - -void -OfdmDlBurstProfile::SetLength(uint8_t length) -{ - m_length = length; -} - -void -OfdmDlBurstProfile::SetDiuc(uint8_t diuc) -{ - m_diuc = diuc; -} - -void -OfdmDlBurstProfile::SetFecCodeType(uint8_t fecCodeType) -{ - m_fecCodeType = fecCodeType; -} - -uint8_t -OfdmDlBurstProfile::GetType() const -{ - return m_type; -} - -uint8_t -OfdmDlBurstProfile::GetLength() const -{ - return m_length; -} - -uint8_t -OfdmDlBurstProfile::GetDiuc() const -{ - return m_diuc; -} - -uint8_t -OfdmDlBurstProfile::GetFecCodeType() const -{ - return m_fecCodeType; -} - -uint16_t -OfdmDlBurstProfile::GetSize() const -{ - return 1 + 1 + 1 + 1; -} - -Buffer::Iterator -OfdmDlBurstProfile::Write(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_type); - i.WriteU8(m_length); - i.WriteU8(m_diuc); - i.WriteU8(m_fecCodeType); - return i; -} - -Buffer::Iterator -OfdmDlBurstProfile::Read(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_type = i.ReadU8(); - m_length = i.ReadU8(); - m_diuc = i.ReadU8(); - m_fecCodeType = i.ReadU8(); - return i; -} - -// ---------------------------------------------------------------------------------------------------------- - -NS_OBJECT_ENSURE_REGISTERED(Dcd); - -Dcd::Dcd() - : m_reserved(0), - m_configurationChangeCount(0), - m_nrDlBurstProfiles(0) -{ -} - -Dcd::~Dcd() -{ -} - -void -Dcd::SetConfigurationChangeCount(uint8_t configurationChangeCount) -{ - m_configurationChangeCount = configurationChangeCount; -} - -void -Dcd::SetChannelEncodings(OfdmDcdChannelEncodings channelEncodings) -{ - m_channelEncodings = channelEncodings; -} - -void -Dcd::SetNrDlBurstProfiles(uint8_t nrDlBurstProfiles) -{ - m_nrDlBurstProfiles = nrDlBurstProfiles; -} - -void -Dcd::AddDlBurstProfile(OfdmDlBurstProfile dlBurstProfile) -{ - m_dlBurstProfiles.push_back(dlBurstProfile); -} - -uint8_t -Dcd::GetConfigurationChangeCount() const -{ - return m_configurationChangeCount; -} - -OfdmDcdChannelEncodings -Dcd::GetChannelEncodings() const -{ - return m_channelEncodings; -} - -std::vector -Dcd::GetDlBurstProfiles() const -{ - return m_dlBurstProfiles; -} - -uint8_t -Dcd::GetNrDlBurstProfiles() const -{ - return m_nrDlBurstProfiles; -} - -std::string -Dcd::GetName() const -{ - return "DCD"; -} - -TypeId -Dcd::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::Dcd").SetParent
().SetGroupName("Wimax").AddConstructor(); - return tid; -} - -TypeId -Dcd::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -Dcd::Print(std::ostream& os) const -{ - os << " configuration change count = " << (uint32_t)m_configurationChangeCount - << ", number of dl burst profiles = " << m_dlBurstProfiles.size(); -} - -uint32_t -Dcd::GetSerializedSize() const -{ - uint32_t dlBurstProfilesSize = 0; - - for (const auto& burstProfile : m_dlBurstProfiles) - { - dlBurstProfilesSize += burstProfile.GetSize(); - } - - return 1 + 1 + m_channelEncodings.GetSize() + dlBurstProfilesSize; -} - -void -Dcd::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_reserved); - i.WriteU8(m_configurationChangeCount); - i = m_channelEncodings.Write(i); - - for (const auto& burstProfile : m_dlBurstProfiles) - { - i = burstProfile.Write(i); - } -} - -uint32_t -Dcd::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_reserved = i.ReadU8(); - m_configurationChangeCount = i.ReadU8(); - i = m_channelEncodings.Read(i); - - for (uint8_t j = 0; j < m_nrDlBurstProfiles; j++) - { - OfdmDlBurstProfile burstProfile; - i = burstProfile.Read(i); - AddDlBurstProfile(burstProfile); - } - - return i.GetDistanceFrom(start); -} - -// ---------------------------------------------------------------------------------------------------------- - -OfdmDlMapIe::OfdmDlMapIe() - : m_cid(), - m_diuc(0), - m_preamblePresent(0), - m_startTime(0) -{ -} - -OfdmDlMapIe::~OfdmDlMapIe() -{ -} - -void -OfdmDlMapIe::SetCid(Cid cid) -{ - m_cid = cid; -} - -void -OfdmDlMapIe::SetDiuc(uint8_t diuc) -{ - m_diuc = diuc; -} - -void -OfdmDlMapIe::SetPreamblePresent(uint8_t preamblePresent) -{ - m_preamblePresent = preamblePresent; -} - -void -OfdmDlMapIe::SetStartTime(uint16_t startTime) -{ - m_startTime = startTime; -} - -Cid -OfdmDlMapIe::GetCid() const -{ - return m_cid; -} - -uint8_t -OfdmDlMapIe::GetDiuc() const -{ - return m_diuc; -} - -uint8_t -OfdmDlMapIe::GetPreamblePresent() const -{ - return m_preamblePresent; -} - -uint16_t -OfdmDlMapIe::GetStartTime() const -{ - return m_startTime; -} - -uint16_t -OfdmDlMapIe::GetSize() const -{ - return 2 + 1 + 1 + 2; -} - -Buffer::Iterator -OfdmDlMapIe::Write(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU16(m_cid.GetIdentifier()); - i.WriteU8(m_diuc); - i.WriteU8(m_preamblePresent); - i.WriteU16(m_startTime); - return i; -} - -Buffer::Iterator -OfdmDlMapIe::Read(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_cid = i.ReadU16(); - m_diuc = i.ReadU8(); - m_preamblePresent = i.ReadU8(); - m_startTime = i.ReadU16(); - return i; -} - -// ---------------------------------------------------------------------------------------------------------- - -NS_OBJECT_ENSURE_REGISTERED(DlMap); - -DlMap::DlMap() - : m_dcdCount(0), - m_baseStationId(Mac48Address("00:00:00:00:00:00")) -{ -} - -DlMap::~DlMap() -{ -} - -void -DlMap::SetDcdCount(uint8_t dcdCount) -{ - m_dcdCount = dcdCount; -} - -void -DlMap::SetBaseStationId(Mac48Address baseStationId) -{ - m_baseStationId = baseStationId; -} - -void -DlMap::AddDlMapElement(OfdmDlMapIe dlMapElement) -{ - m_dlMapElements.push_back(dlMapElement); -} - -uint8_t -DlMap::GetDcdCount() const -{ - return m_dcdCount; -} - -Mac48Address -DlMap::GetBaseStationId() const -{ - return m_baseStationId; -} - -std::list -DlMap::GetDlMapElements() const -{ - return m_dlMapElements; -} - -std::string -DlMap::GetName() const -{ - return "DL-MAP"; -} - -TypeId -DlMap::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::DlMap").SetParent
().SetGroupName("Wimax").AddConstructor(); - return tid; -} - -TypeId -DlMap::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -DlMap::Print(std::ostream& os) const -{ - os << " dcd count = " << (uint32_t)m_dcdCount << ", base station id = " << m_baseStationId - << ", number of dl-map elements = " << m_dlMapElements.size(); -} - -uint32_t -DlMap::GetSerializedSize() const -{ - uint32_t dlMapElementsSize = 0; - - for (const auto& dlMapIe : m_dlMapElements) - { - dlMapElementsSize += dlMapIe.GetSize(); - } - - return 1 + 6 + dlMapElementsSize; -} - -void -DlMap::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_dcdCount); - WriteTo(i, m_baseStationId); - - for (const auto& dlMapIe : m_dlMapElements) - { - i = dlMapIe.Write(i); - } -} - -uint32_t -DlMap::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_dcdCount = i.ReadU8(); - ReadFrom(i, m_baseStationId); // length (6) shall also be written in packet instead of hard - // coded, see ARP example - - m_dlMapElements.clear(); // only for printing, otherwise it shows wrong number of elements - - while (true) - { - OfdmDlMapIe dlMapIe; - i = dlMapIe.Read(i); - - AddDlMapElement(dlMapIe); - - if (dlMapIe.GetDiuc() == 14) // End of Map IE - { - break; - } - } - return i.GetDistanceFrom(start); -} - -} // namespace ns3 diff --git a/src/wimax/model/dl-mac-messages.h b/src/wimax/model/dl-mac-messages.h deleted file mode 100644 index cfd85be1f..000000000 --- a/src/wimax/model/dl-mac-messages.h +++ /dev/null @@ -1,608 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#ifndef DCD_CHANNEL_ENCODINGS_H -#define DCD_CHANNEL_ENCODINGS_H - -#include "ns3/buffer.h" - -#include -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * This class implements the DCD channel encodings as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 11.4.1 DCD channel encodings, page 659 - */ -class DcdChannelEncodings -{ - public: - DcdChannelEncodings(); - virtual ~DcdChannelEncodings(); - - /** - * Set BS EIRP field - * @param bs_eirp the BS EIRP - */ - void SetBsEirp(uint16_t bs_eirp); - /** - * Set EIRX IR MAX field - * @param rss_ir_max the EIRRX IR MAX - */ - void SetEirxPIrMax(uint16_t rss_ir_max); - /** - * Set frequency field - * @param frequency the frequency - */ - void SetFrequency(uint32_t frequency); - - /** - * Get BS EIRP field - * @returns the BS EIRP - */ - uint16_t GetBsEirp() const; - /** - * Get EIRX IR MAX field - * @returns the EIRX IR MAX - */ - uint16_t GetEirxPIrMax() const; - /** - * Get frequency function - * @returns the frequency - */ - uint32_t GetFrequency() const; - - /** - * Get size field - * @returns the size - */ - uint16_t GetSize() const; - - /** - * Write item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator Write(Buffer::Iterator start) const; - /** - * Read item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator Read(Buffer::Iterator start); - - private: - /** - * Write item - * @param start iterator - * @returns the updated iterator - */ - virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const = 0; - /** - * Read item - * @param start the iterator - * @returns the updated iterator - */ - virtual Buffer::Iterator DoRead(Buffer::Iterator start) = 0; - - uint16_t m_bsEirp; ///< BS EIRP - uint16_t m_eirXPIrMax; ///< EIRX IR MAX - uint32_t m_frequency; ///< frequency -}; - -} // namespace ns3 - -#endif /* DCD_CHANNEL_ENCODINGS_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef OFDM_DCD_CHANNEL_ENCODINGS_H -#define OFDM_DCD_CHANNEL_ENCODINGS_H - -#include "ns3/mac48-address.h" - -#include - -namespace ns3 -{ - -/** - * This class implements the OFDM DCD channel encodings as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" - */ -class OfdmDcdChannelEncodings : public DcdChannelEncodings -{ - public: - OfdmDcdChannelEncodings(); - ~OfdmDcdChannelEncodings() override; - - /** - * Set channel number field - * @param channelNr the channel number - */ - void SetChannelNr(uint8_t channelNr); - /** - * Set TTG field - * @param ttg the TTG - */ - void SetTtg(uint8_t ttg); - /** - * Set RTG field - * @param rtg the RTG - */ - void SetRtg(uint8_t rtg); - - /** - * Set base station ID field - * @param baseStationId the base station ID - */ - void SetBaseStationId(Mac48Address baseStationId); - /** - * Set frame duration code field - * @param frameDurationCode the frame duration code - */ - void SetFrameDurationCode(uint8_t frameDurationCode); - /** - * Set frame number field - * @param frameNumber the frame number - */ - void SetFrameNumber(uint32_t frameNumber); - - /** - * Get channel number field - * @returns the channel number - */ - uint8_t GetChannelNr() const; - /** - * Get TTG field - * @returns the TTG - */ - uint8_t GetTtg() const; - /** - * Get RTG field - * @returns the RTG - */ - uint8_t GetRtg() const; - - /** - * Get base station ID field - * @returns the base station MAC address - */ - Mac48Address GetBaseStationId() const; - /** - * Get frame duration code field - * @returns the frame duration code - */ - uint8_t GetFrameDurationCode() const; - /** - * Get frame number field - * @returns the frame number - */ - uint32_t GetFrameNumber() const; - - /** - * Get size field - * @returns the size - */ - uint16_t GetSize() const; - - private: - /** - * Write item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator DoWrite(Buffer::Iterator start) const override; - /** - * Read item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator DoRead(Buffer::Iterator start) override; - - uint8_t m_channelNr; ///< channel number - uint8_t m_ttg; ///< TTG - uint8_t m_rtg; ///< RTG - - Mac48Address m_baseStationId; ///< base station ID - uint8_t m_frameDurationCode; ///< frame duration code - uint32_t m_frameNumber; ///< frame number -}; - -} // namespace ns3 - -#endif /* OFDM_DCD_CHANNEL_ENCODINGS_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef OFDM_DL_BURST_PROFILE_H -#define OFDM_DL_BURST_PROFILE_H - -#include "ns3/buffer.h" - -#include - -namespace ns3 -{ - -/** - * This class implements the OFDM Downlink burst profile descriptor as described by "IEEE Standard - * for Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless - * Access Systems" 8.2.1.10 Burst profile formats page 416 - * - */ -class OfdmDlBurstProfile -{ - public: - /// DIUC enumeration - enum Diuc - { - DIUC_STC_ZONE = 0, - DIUC_BURST_PROFILE_1, - DIUC_BURST_PROFILE_2, - DIUC_BURST_PROFILE_3, - DIUC_BURST_PROFILE_4, - DIUC_BURST_PROFILE_5, - DIUC_BURST_PROFILE_6, - DIUC_BURST_PROFILE_7, - DIUC_BURST_PROFILE_8, - DIUC_BURST_PROFILE_9, - DIUC_BURST_PROFILE_10, - DIUC_BURST_PROFILE_11, - // 12 is reserved - DIUC_GAP = 13, - DIUC_END_OF_MAP - }; - - OfdmDlBurstProfile(); - ~OfdmDlBurstProfile(); - - /** - * Set type field - * @param type the type to set - */ - void SetType(uint8_t type); - /** - * Set length field - * @param length the length to set - */ - void SetLength(uint8_t length); - /** - * Set DIUC field - * @param diuc the DIUC - */ - void SetDiuc(uint8_t diuc); - - /** - * Set FEC code type - * @param fecCodeType the FEC code type - */ - void SetFecCodeType(uint8_t fecCodeType); - - /** - * Get type function - * @returns the type - */ - uint8_t GetType() const; - /** @returns the length field */ - uint8_t GetLength() const; - /** @returns the DIUC field */ - uint8_t GetDiuc() const; - - /** @returns the FEC code type */ - uint8_t GetFecCodeType() const; - - /** @returns the size */ - uint16_t GetSize() const; - - /** - * Write item - * @param start the starting item iterator - * @returns the iterator - */ - Buffer::Iterator Write(Buffer::Iterator start) const; - /** - * Read item - * @param start the starting item iterator - * @returns the iterator - */ - Buffer::Iterator Read(Buffer::Iterator start); - - private: - uint8_t m_type; ///< type - uint8_t m_length; ///< length - uint8_t m_diuc; ///< diuc - - // TLV Encoded information - uint8_t m_fecCodeType; ///< FEC code type -}; - -} // namespace ns3 - -#endif /* OFDM_DL_BURST_PROFILE_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef DCD_H -#define DCD_H - -#include "ns3/header.h" - -#include -#include - -namespace ns3 -{ - -/** - * This class implements Downlink channel descriptor as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 6.3.2.3.1 Downlink Channel Descriptor (DCD) message, page 45 - */ -class Dcd : public Header -{ - public: - Dcd(); - ~Dcd() override; - - /** - * Set configuration change count field - * @param configurationChangeCount the configuration change count - */ - void SetConfigurationChangeCount(uint8_t configurationChangeCount); - /** - * Set channel encodings field - * @param channelEncodings the channel encodings - */ - void SetChannelEncodings(OfdmDcdChannelEncodings channelEncodings); - /** - * Add DL burst profile field - * @param dlBurstProfile the DL burst profile - */ - void AddDlBurstProfile(OfdmDlBurstProfile dlBurstProfile); - /** - * Set number DL burst profile field - * @param nrDlBurstProfiles the number of DL burst profiles - */ - void SetNrDlBurstProfiles(uint8_t nrDlBurstProfiles); - - /** - * Get configuration change count field - * @returns the configuration change count - */ - uint8_t GetConfigurationChangeCount() const; - /** - * Get channel encodings field - * @returns the channel encodings - */ - OfdmDcdChannelEncodings GetChannelEncodings() const; - /** - * Get DL burst profile field - * @returns the DL burst profiles - */ - std::vector GetDlBurstProfiles() const; - /** - * Get number DL burst profiles field - * @returns the number of DL burst profiles - */ - uint8_t GetNrDlBurstProfiles() const; - - /** - * Get name field - * @returns the name string - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - uint8_t m_reserved; ///< changed as per the amendment 802.16e-2005 - uint8_t m_configurationChangeCount; ///< configuration change count - OfdmDcdChannelEncodings m_channelEncodings; ///< TLV Encoded information for the overall channel - std::vector m_dlBurstProfiles; ///< vector of download burst profiles - - uint8_t m_nrDlBurstProfiles; ///< number DL purst profiles -}; - -} // namespace ns3 - -#endif /* DCD_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef OFDM_DL_MAP_IE_H -#define OFDM_DL_MAP_IE_H - -#include "cid.h" - -#include - -namespace ns3 -{ - -/** - * This class implements the OFDM DL-MAP information element as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 6.3.2.3.43.6 Compact DL-MAP IE page 109 - */ -class OfdmDlMapIe -{ - public: - OfdmDlMapIe(); - ~OfdmDlMapIe(); - - /** - * Set CID function - * @param cid the CID - */ - void SetCid(Cid cid); - /** - * Set DIUC field - * @param diuc the DIUC - */ - void SetDiuc(uint8_t diuc); - /** - * Set preamble present field - * @param preamblePresent the preamble present - */ - void SetPreamblePresent(uint8_t preamblePresent); - /** - * Set start time field - * @param startTime the start time value - */ - void SetStartTime(uint16_t startTime); - - /** - * Set CID field - * @returns the CID - */ - Cid GetCid() const; - /** - * Get DIUC field - * @returns the DIUC - */ - uint8_t GetDiuc() const; - /** - * Get preamble present field - * @returns the preamble present indicator - */ - uint8_t GetPreamblePresent() const; - /** - * Get start time field - * @returns the start time - */ - uint16_t GetStartTime() const; - - /** - * Get size - * @returns the size - */ - uint16_t GetSize() const; - - /** - * Write item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator Write(Buffer::Iterator start) const; - /** - * Read item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator Read(Buffer::Iterator start); - - private: - Cid m_cid; ///< CID - uint8_t m_diuc; ///< DIUC - uint8_t m_preamblePresent; ///< preamble present - uint16_t m_startTime; ///< start time -}; - -} // namespace ns3 - -#endif /* OFDM_DL_MAP_IE_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef DL_MAP_H -#define DL_MAP_H - -#include "ns3/header.h" -#include "ns3/mac48-address.h" - -#include -#include - -namespace ns3 -{ - -/** - * This class implements DL-MAP as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 8.2.1.8.1 Compressed DL-MAP, page 402 - */ -class DlMap : public Header -{ - public: - DlMap(); - ~DlMap() override; - - /** - * Set DCD count field - * @param dcdCount the DCD count - */ - void SetDcdCount(uint8_t dcdCount); - /** - * Set base station ID field - * @param baseStationID the base station ID - */ - void SetBaseStationId(Mac48Address baseStationID); - /** - * Add DL Map element field - * @param dlMapElement the DL map element - */ - void AddDlMapElement(OfdmDlMapIe dlMapElement); - - /** - * Get DCD count field - * @returns the DCD count - */ - uint8_t GetDcdCount() const; - /** - * Get base station ID field - * @returns the MAC address - */ - Mac48Address GetBaseStationId() const; - /** - * Get DL Map elements field - * @returns the DL map elements - */ - std::list GetDlMapElements() const; - - /** - * Get name field - * @returns the name string - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - uint8_t m_dcdCount; ///< DCD count - Mac48Address m_baseStationId; ///< base station ID - std::list m_dlMapElements; ///< DL Map elements - // m_paddingNibble; //fields to be implemented later on: -}; - -} // namespace ns3 - -#endif /* DL_MAP_H */ diff --git a/src/wimax/model/ipcs-classifier-record.cc b/src/wimax/model/ipcs-classifier-record.cc deleted file mode 100644 index 9082a553c..000000000 --- a/src/wimax/model/ipcs-classifier-record.cc +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - */ -#include "ipcs-classifier-record.h" - -#include "wimax-tlv.h" - -#include "ns3/ipv4-address.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("IpcsClassifierRecord"); - -IpcsClassifierRecord::IpcsClassifierRecord() -{ - m_priority = 255; - m_priority = 0; - m_index = 0; - m_tosLow = 0; - m_tosHigh = 0; - m_tosMask = 0; - m_cid = 0; - m_protocol.push_back(6); // tcp - m_protocol.push_back(17); // udp - AddSrcAddr(Ipv4Address("0.0.0.0"), Ipv4Mask("0.0.0.0")); - AddDstAddr(Ipv4Address("0.0.0.0"), Ipv4Mask("0.0.0.0")); - AddSrcPortRange(0, 65535); - AddDstPortRange(0, 65535); -} - -IpcsClassifierRecord::~IpcsClassifierRecord() -{ -} - -IpcsClassifierRecord::IpcsClassifierRecord(Tlv tlv) -{ - NS_ASSERT_MSG(tlv.GetType() == CsParamVectorTlvValue::Packet_Classification_Rule, - "Invalid TLV"); - ClassificationRuleVectorTlvValue* rules = - ((ClassificationRuleVectorTlvValue*)(tlv.PeekValue())); - m_priority = 0; - m_index = 0; - m_tosLow = 0; - m_tosHigh = 0; - m_tosMask = 0; - m_cid = 0; - for (auto iter = rules->Begin(); iter != rules->End(); ++iter) - { - switch ((*iter)->GetType()) - { - case ClassificationRuleVectorTlvValue::Priority: { - m_priority = ((U8TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case ClassificationRuleVectorTlvValue::ToS: { - NS_FATAL_ERROR("ToS Not implemented-- please implement and contribute a patch"); - break; - } - case ClassificationRuleVectorTlvValue::Protocol: { - auto list = (ProtocolTlvValue*)(*iter)->PeekValue(); - for (auto iter2 = list->Begin(); iter2 != list->End(); ++iter2) - { - AddProtocol(*iter2); - } - break; - } - case ClassificationRuleVectorTlvValue::IP_src: { - auto list = (Ipv4AddressTlvValue*)(*iter)->PeekValue(); - for (auto iter2 = list->Begin(); iter2 != list->End(); ++iter2) - { - AddSrcAddr((*iter2).Address, (*iter2).Mask); - } - break; - } - case ClassificationRuleVectorTlvValue::IP_dst: { - auto list = (Ipv4AddressTlvValue*)(*iter)->PeekValue(); - for (auto iter2 = list->Begin(); iter2 != list->End(); ++iter2) - { - AddDstAddr((*iter2).Address, (*iter2).Mask); - } - break; - } - case ClassificationRuleVectorTlvValue::Port_src: { - auto list = (PortRangeTlvValue*)(*iter)->PeekValue(); - for (auto iter2 = list->Begin(); iter2 != list->End(); ++iter2) - { - AddSrcPortRange((*iter2).PortLow, (*iter2).PortHigh); - } - break; - } - case ClassificationRuleVectorTlvValue::Port_dst: { - auto list = (PortRangeTlvValue*)(*iter)->PeekValue(); - for (auto iter2 = list->Begin(); iter2 != list->End(); ++iter2) - { - AddDstPortRange((*iter2).PortLow, (*iter2).PortHigh); - } - break; - } - case ClassificationRuleVectorTlvValue::Index: { - m_index = ((U16TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - } - } -} - -IpcsClassifierRecord::IpcsClassifierRecord(Ipv4Address SrcAddress, - Ipv4Mask SrcMask, - Ipv4Address DstAddress, - Ipv4Mask DstMask, - uint16_t SrcPortLow, - uint16_t SrcPortHigh, - uint16_t DstPortLow, - uint16_t DstPortHigh, - uint8_t protocol, - uint8_t priority) -{ - m_priority = priority; - m_protocol.push_back(protocol); - AddSrcAddr(SrcAddress, SrcMask); - AddDstAddr(DstAddress, DstMask); - AddSrcPortRange(SrcPortLow, SrcPortHigh); - AddDstPortRange(DstPortLow, DstPortHigh); - m_index = 0; - m_tosLow = 0; - m_tosHigh = 0; - m_tosMask = 0; - m_cid = 0; -} - -void -IpcsClassifierRecord::AddSrcAddr(Ipv4Address srcAddress, Ipv4Mask srcMask) -{ - Ipv4Addr tmp; - tmp.Address = srcAddress; - tmp.Mask = srcMask; - m_srcAddr.push_back(tmp); -} - -void -IpcsClassifierRecord::AddDstAddr(Ipv4Address dstAddress, Ipv4Mask dstMask) -{ - Ipv4Addr tmp; - tmp.Address = dstAddress; - tmp.Mask = dstMask; - m_dstAddr.push_back(tmp); -} - -void -IpcsClassifierRecord::AddSrcPortRange(uint16_t srcPortLow, uint16_t srcPortHigh) -{ - PortRange tmp; - tmp.PortLow = srcPortLow; - tmp.PortHigh = srcPortHigh; - m_srcPortRange.push_back(tmp); -} - -void -IpcsClassifierRecord::AddDstPortRange(uint16_t dstPortLow, uint16_t dstPortHigh) -{ - PortRange tmp; - tmp.PortLow = dstPortLow; - tmp.PortHigh = dstPortHigh; - m_dstPortRange.push_back(tmp); -} - -void -IpcsClassifierRecord::AddProtocol(uint8_t proto) -{ - m_protocol.push_back(proto); -} - -void -IpcsClassifierRecord::SetPriority(uint8_t prio) -{ - m_priority = prio; -} - -void -IpcsClassifierRecord::SetCid(uint16_t cid) -{ - m_cid = cid; -} - -void -IpcsClassifierRecord::SetIndex(uint16_t index) -{ - m_index = index; -} - -uint16_t -IpcsClassifierRecord::GetIndex() const -{ - return m_index; -} - -uint16_t -IpcsClassifierRecord::GetCid() const -{ - return m_cid; -} - -uint8_t -IpcsClassifierRecord::GetPriority() const -{ - return m_priority; -} - -bool -IpcsClassifierRecord::CheckMatchSrcAddr(Ipv4Address srcAddress) const -{ - for (auto iter = m_srcAddr.begin(); iter != m_srcAddr.end(); ++iter) - { - NS_LOG_INFO("src addr check match: pkt=" << srcAddress << " cls=" << (*iter).Address << "/" - << (*iter).Mask); - if (srcAddress.CombineMask((*iter).Mask) == (*iter).Address) - { - return true; - } - } - NS_LOG_INFO("NOT OK!"); - return false; -} - -bool -IpcsClassifierRecord::CheckMatchDstAddr(Ipv4Address dstAddress) const -{ - for (auto iter = m_dstAddr.begin(); iter != m_dstAddr.end(); ++iter) - { - NS_LOG_INFO("dst addr check match: pkt=" << dstAddress << " cls=" << (*iter).Address << "/" - << (*iter).Mask); - if (dstAddress.CombineMask((*iter).Mask) == (*iter).Address) - { - return true; - } - } - NS_LOG_INFO("NOT OK!"); - return false; -} - -bool -IpcsClassifierRecord::CheckMatchSrcPort(uint16_t port) const -{ - for (auto iter = m_srcPortRange.begin(); iter != m_srcPortRange.end(); ++iter) - { - NS_LOG_INFO("src port check match: pkt=" << port << " cls= [" << (*iter).PortLow << " TO " - << (*iter).PortHigh << "]"); - if (port >= (*iter).PortLow && port <= (*iter).PortHigh) - { - return true; - } - } - NS_LOG_INFO("NOT OK!"); - return false; -} - -bool -IpcsClassifierRecord::CheckMatchDstPort(uint16_t port) const -{ - for (auto iter = m_dstPortRange.begin(); iter != m_dstPortRange.end(); ++iter) - { - NS_LOG_INFO("dst port check match: pkt=" << port << " cls= [" << (*iter).PortLow << " TO " - << (*iter).PortHigh << "]"); - if (port >= (*iter).PortLow && port <= (*iter).PortHigh) - { - return true; - } - } - NS_LOG_INFO("NOT OK!"); - return false; -} - -bool -IpcsClassifierRecord::CheckMatchProtocol(uint8_t proto) const -{ - for (auto iter = m_protocol.begin(); iter != m_protocol.end(); ++iter) - { - NS_LOG_INFO("proto check match: pkt=" << (uint16_t)proto << " cls=" << (uint16_t)proto); - if (proto == (*iter)) - { - return true; - } - } - NS_LOG_INFO("NOT OK!"); - return false; -} - -bool -IpcsClassifierRecord::CheckMatch(Ipv4Address srcAddress, - Ipv4Address dstAddress, - uint16_t srcPort, - uint16_t dstPort, - uint8_t proto) const -{ - return (CheckMatchProtocol(proto) && CheckMatchDstPort(dstPort) && CheckMatchSrcPort(srcPort) && - CheckMatchDstAddr(dstAddress) && CheckMatchSrcAddr(srcAddress)); -} - -Tlv -IpcsClassifierRecord::ToTlv() const -{ - Ipv4AddressTlvValue ipv4AddrValSrc; - for (auto iter = m_srcAddr.begin(); iter != m_srcAddr.end(); ++iter) - { - ipv4AddrValSrc.Add((*iter).Address, (*iter).Mask); - } - - Ipv4AddressTlvValue ipv4AddrValDst; - for (auto iter = m_dstAddr.begin(); iter != m_dstAddr.end(); ++iter) - { - ipv4AddrValDst.Add((*iter).Address, (*iter).Mask); - } - - ProtocolTlvValue protoVal; - for (auto iter = m_protocol.begin(); iter != m_protocol.end(); ++iter) - { - protoVal.Add(*iter); - } - - PortRangeTlvValue portValueSrc; - for (auto iter = m_srcPortRange.begin(); iter != m_srcPortRange.end(); ++iter) - { - portValueSrc.Add((*iter).PortLow, (*iter).PortHigh); - } - - PortRangeTlvValue portValueDst; - for (auto iter = m_dstPortRange.begin(); iter != m_dstPortRange.end(); ++iter) - { - portValueDst.Add((*iter).PortLow, (*iter).PortHigh); - } - - ClassificationRuleVectorTlvValue ClassVectVal; - ClassVectVal.Add(Tlv(ClassificationRuleVectorTlvValue::Priority, 1, U8TlvValue(m_priority))); - ClassVectVal.Add( - Tlv(ClassificationRuleVectorTlvValue::Protocol, protoVal.GetSerializedSize(), protoVal)); - ClassVectVal.Add(Tlv(ClassificationRuleVectorTlvValue::IP_src, - ipv4AddrValSrc.GetSerializedSize(), - ipv4AddrValSrc)); - ClassVectVal.Add(Tlv(ClassificationRuleVectorTlvValue::IP_dst, - ipv4AddrValDst.GetSerializedSize(), - ipv4AddrValDst)); - ClassVectVal.Add(Tlv(ClassificationRuleVectorTlvValue::Port_src, - portValueSrc.GetSerializedSize(), - portValueSrc)); - ClassVectVal.Add(Tlv(ClassificationRuleVectorTlvValue::Port_dst, - portValueDst.GetSerializedSize(), - portValueDst)); - ClassVectVal.Add(Tlv(ClassificationRuleVectorTlvValue::Index, 2, U16TlvValue(1))); - - Tlv tmp_tlv(CsParamVectorTlvValue::Packet_Classification_Rule, - ClassVectVal.GetSerializedSize(), - ClassVectVal); - - return tmp_tlv; -} - -} // namespace ns3 diff --git a/src/wimax/model/ipcs-classifier-record.h b/src/wimax/model/ipcs-classifier-record.h deleted file mode 100644 index 611955eb9..000000000 --- a/src/wimax/model/ipcs-classifier-record.h +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - * - */ - -#ifndef IPCS_CLASSIFIER_RECORD_H -#define IPCS_CLASSIFIER_RECORD_H - -#include "wimax-tlv.h" - -#include "ns3/ipv4-address.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * @brief IpcsClassifierRecord class - */ -class IpcsClassifierRecord -{ - public: - IpcsClassifierRecord(); - ~IpcsClassifierRecord(); - /** - * @brief creates a classifier records and sets all its parameters - * @param srcAddress the source ip address - * @param srcMask the mask to apply on the source ip address - * @param dstAddress the destination ip address - * @param dstMask the mask to apply on the destination ip address - * @param srcPortLow the lower boundary of the source port range - * @param srcPortHigh the higher boundary of the source port range - * @param dstPortLow the lower boundary of the destination port range - * @param dstPortHigh the higher boundary of the destination port range - * @param protocol the L4 protocol - * @param priority the priority of this classifier - * - */ - IpcsClassifierRecord(Ipv4Address srcAddress, - Ipv4Mask srcMask, - Ipv4Address dstAddress, - Ipv4Mask dstMask, - uint16_t srcPortLow, - uint16_t srcPortHigh, - uint16_t dstPortLow, - uint16_t dstPortHigh, - uint8_t protocol, - uint8_t priority); - /** - * @brief Decodes a TLV and creates a classifier - * @param tlv the TLV to decode and from which the classifier parameters will be extracted - */ - IpcsClassifierRecord(Tlv tlv); - /** - * @brief Creates a TLV from this classifier - * @return the created TLV - */ - Tlv ToTlv() const; - /** - * @brief add a new source ip address to the classifier - * @param srcAddress the source ip address - * @param srcMask the mask to apply on the source ip address - */ - void AddSrcAddr(Ipv4Address srcAddress, Ipv4Mask srcMask); - /** - * @brief add a new destination ip address to the classifier - * @param dstAddress the destination ip address - * @param dstMask the mask to apply on the destination ip address - */ - void AddDstAddr(Ipv4Address dstAddress, Ipv4Mask dstMask); - /** - * @brief add a range of source port to the classifier - * @param srcPortLow the lower boundary of the source port range - * @param srcPortHigh the higher boundary of the source port range - */ - void AddSrcPortRange(uint16_t srcPortLow, uint16_t srcPortHigh); - /** - * @brief add a range of destination port to the classifier - * @param dstPortLow the lower boundary of the destination port range - * @param dstPortHigh the higher boundary of the destination port range - */ - void AddDstPortRange(uint16_t dstPortLow, uint16_t dstPortHigh); - /** - * @brief add a protocol to the classifier - * @param proto the L4 protocol to add - */ - void AddProtocol(uint8_t proto); - /** - * @brief Set the priority of this classifier - * @param prio the priority of the classifier - */ - void SetPriority(uint8_t prio); - /** - * @brief Set the index of the classifier - * @param index the index of the classifier - */ - void SetIndex(uint16_t index); - /** - * @brief check if a packets can be used with this classifier - * @param srcAddress the source ip address of the packet - * @param dstAddress the destination ip address of the packet - * @param srcPort the source port of the packet - * @param dstPort the destination port of the packet - * @param proto The L4 protocol of the packet - * @return true if there is a match - */ - bool CheckMatch(Ipv4Address srcAddress, - Ipv4Address dstAddress, - uint16_t srcPort, - uint16_t dstPort, - uint8_t proto) const; - /** - * @return the cid associated with this classifier - */ - uint16_t GetCid() const; - /** - * @return the priority of this classifier - */ - uint8_t GetPriority() const; - /** - * @return the index of this classifier - */ - uint16_t GetIndex() const; - /** - * @brief Set the cid associated to this classifier - * @param cid the connection identifier - */ - void SetCid(uint16_t cid); - - private: - /** - * Check match source address function - * @param srcAddress source IP address to check - * @returns true if a match - */ - bool CheckMatchSrcAddr(Ipv4Address srcAddress) const; - /** - * Check match destination address function - * @param dstAddress destination IP address to check - * @returns true if a match - */ - bool CheckMatchDstAddr(Ipv4Address dstAddress) const; - /** - * Check match source port function - * @param srcPort source port to check - * @returns true if a match - */ - bool CheckMatchSrcPort(uint16_t srcPort) const; - /** - * Check match destination port function - * @param dstPort destination port to check - * @returns true if a match - */ - bool CheckMatchDstPort(uint16_t dstPort) const; - /** - * Check match protocol function - * @param proto protocol number to check - * @returns true if a match - */ - bool CheckMatchProtocol(uint8_t proto) const; - - /// PortRange structure - struct PortRange - { - uint16_t PortLow; ///< port low - uint16_t PortHigh; ///< port high - }; - - /// Ipv4Addr structure - struct Ipv4Addr - { - Ipv4Address Address; ///< IP address - Ipv4Mask Mask; ///< net mask - }; - - uint8_t m_priority; ///< priority - uint16_t m_index; ///< index - uint8_t m_tosLow; ///< TOS low - uint8_t m_tosHigh; ///< TOS high - uint8_t m_tosMask; ///< TOS mask - std::vector m_protocol; ///< protocol - std::vector m_srcAddr; ///< source address - std::vector m_dstAddr; ///< destination address - std::vector m_srcPortRange; ///< source port range - std::vector m_dstPortRange; ///< destination port range - - uint16_t m_cid; ///< the CID -}; -} // namespace ns3 - -#endif /* IPCS_CLASSIFIER_RECORD_H */ diff --git a/src/wimax/model/ipcs-classifier.cc b/src/wimax/model/ipcs-classifier.cc deleted file mode 100644 index 3773cc3cf..000000000 --- a/src/wimax/model/ipcs-classifier.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - * - */ - -#include "ipcs-classifier.h" - -#include "service-flow.h" - -#include "ns3/ipv4-header.h" -#include "ns3/llc-snap-header.h" -#include "ns3/log.h" -#include "ns3/packet.h" -#include "ns3/tcp-header.h" -#include "ns3/tcp-l4-protocol.h" -#include "ns3/udp-header.h" -#include "ns3/udp-l4-protocol.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("IpcsClassifier"); - -NS_OBJECT_ENSURE_REGISTERED(IpcsClassifier); - -TypeId -IpcsClassifier::GetTypeId() -{ - static TypeId tid = TypeId("ns3::IpcsClassifier").SetParent().SetGroupName("Wimax"); - return tid; -} - -IpcsClassifier::IpcsClassifier() -{ -} - -IpcsClassifier::~IpcsClassifier() -{ -} - -ServiceFlow* -IpcsClassifier::Classify(Ptr packet, - Ptr sfm, - ServiceFlow::Direction dir) -{ - Ptr C_Packet = packet->Copy(); - - LlcSnapHeader llc; - C_Packet->RemoveHeader(llc); - - Ipv4Header ipv4Header; - C_Packet->RemoveHeader(ipv4Header); - Ipv4Address source_address = ipv4Header.GetSource(); - Ipv4Address dest_address = ipv4Header.GetDestination(); - uint8_t protocol = ipv4Header.GetProtocol(); - - uint16_t sourcePort = 0; - uint16_t destPort = 0; - if (protocol == UdpL4Protocol::PROT_NUMBER) - { - UdpHeader udpHeader; - C_Packet->RemoveHeader(udpHeader); - sourcePort = udpHeader.GetSourcePort(); - destPort = udpHeader.GetDestinationPort(); - } - else if (protocol == TcpL4Protocol::PROT_NUMBER) - { - TcpHeader tcpHeader; - C_Packet->RemoveHeader(tcpHeader); - sourcePort = tcpHeader.GetSourcePort(); - destPort = tcpHeader.GetDestinationPort(); - } - else - { - NS_LOG_INFO("\t\t\tUnknown protocol: " << protocol); - return nullptr; - } - - NS_LOG_INFO("Classifing packet: src_addr=" << source_address << " dst_addr=" << dest_address - << " src_port=" << sourcePort << " dst_port=" - << destPort << " proto=" << (uint16_t)protocol); - return (sfm->DoClassify(source_address, dest_address, sourcePort, destPort, protocol, dir)); -} - -} // namespace ns3 diff --git a/src/wimax/model/ipcs-classifier.h b/src/wimax/model/ipcs-classifier.h deleted file mode 100644 index 88d10ec76..000000000 --- a/src/wimax/model/ipcs-classifier.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - * - */ - -#ifndef IPCS_CLASSIFIER_H -#define IPCS_CLASSIFIER_H - -#include "ss-service-flow-manager.h" - -#include "ns3/packet.h" -#include "ns3/ptr.h" - -#include -#include - -namespace ns3 -{ -class SsServiceFlowManager; - -/** - * @ingroup wimax - * - * IPCS classifier - */ -class IpcsClassifier : public Object -{ - public: - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - IpcsClassifier(); - ~IpcsClassifier() override; - /** - * @brief classify a packet in a service flow - * @param packet the packet to classify - * @param sfm the service flow manager to be used to classify packets - * @param dir The direction on which the packet should be sent (UP or DOWN) - * @return The service flow that should be used to send this packet - */ - ServiceFlow* Classify(Ptr packet, - Ptr sfm, - ServiceFlow::Direction dir); -}; -} // namespace ns3 - -#endif /* IPCS_CLASSIFIER_H */ diff --git a/src/wimax/model/mac-messages.cc b/src/wimax/model/mac-messages.cc deleted file mode 100644 index 2c1c55eec..000000000 --- a/src/wimax/model/mac-messages.cc +++ /dev/null @@ -1,848 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "mac-messages.h" - -#include "wimax-tlv.h" - -#include "ns3/address-utils.h" -#include "ns3/log.h" -#include "ns3/uinteger.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("MACMESSAGES"); - -NS_OBJECT_ENSURE_REGISTERED(ManagementMessageType); - -ManagementMessageType::ManagementMessageType() - : m_type(~0) -{ -} - -ManagementMessageType::ManagementMessageType(uint8_t type) - : m_type(type) -{ -} - -ManagementMessageType::~ManagementMessageType() -{ -} - -void -ManagementMessageType::SetType(uint8_t type) -{ - m_type = type; -} - -uint8_t -ManagementMessageType::GetType() const -{ - return m_type; -} - -std::string -ManagementMessageType::GetName() const -{ - return "Management Message Type"; -} - -TypeId -ManagementMessageType::GetTypeId() -{ - static TypeId tid = TypeId("ns3::ManagementMessageType") - .SetParent
() - .SetGroupName("Wimax") - .AddConstructor(); - return tid; -} - -TypeId -ManagementMessageType::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -ManagementMessageType::Print(std::ostream& os) const -{ - os << " management message type = " << (uint32_t)m_type; -} - -uint32_t -ManagementMessageType::GetSerializedSize() const -{ - return 1; -} - -void -ManagementMessageType::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_type); -} - -uint32_t -ManagementMessageType::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_type = i.ReadU8(); - return i.GetDistanceFrom(start); -} - -// --------------------------------------------------------------------- - -NS_OBJECT_ENSURE_REGISTERED(RngReq); - -RngReq::RngReq() - : m_reserved(0), - m_reqDlBurstProfile(0), - m_macAddress(Mac48Address("00:00:00:00:00:00")), - m_rangingAnomalies(0) -{ -} - -RngReq::~RngReq() -{ -} - -void -RngReq::SetReqDlBurstProfile(uint8_t reqDlBurstProfile) -{ - m_reqDlBurstProfile = reqDlBurstProfile; -} - -void -RngReq::SetMacAddress(Mac48Address macAddress) -{ - m_macAddress = macAddress; -} - -void -RngReq::SetRangingAnomalies(uint8_t rangingAnomalies) -{ - m_rangingAnomalies = rangingAnomalies; -} - -uint8_t -RngReq::GetReqDlBurstProfile() const -{ - return m_reqDlBurstProfile; -} - -Mac48Address -RngReq::GetMacAddress() const -{ - return m_macAddress; -} - -uint8_t -RngReq::GetRangingAnomalies() const -{ - return m_rangingAnomalies; -} - -std::string -RngReq::GetName() const -{ - return "RNG-REQ"; -} - -TypeId -RngReq::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::RngReq").SetParent
().SetGroupName("Wimax").AddConstructor(); - return tid; -} - -TypeId -RngReq::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -RngReq::Print(std::ostream& os) const -{ - os << " requested dl burst profile = " << (uint32_t)m_reqDlBurstProfile - << ", mac address = " << m_macAddress - << ", ranging anomalies = " << (uint32_t)m_rangingAnomalies; -} - -void -RngReq::PrintDebug() const -{ - NS_LOG_DEBUG(" requested dl burst profile = " - << (uint32_t)m_reqDlBurstProfile << ", mac address = " << m_macAddress - << ", ranging anomalies = " << (uint32_t)m_rangingAnomalies); -} - -uint32_t -RngReq::GetSerializedSize() const -{ - return 1 + 1 + 6 + 1; -} - -void -RngReq::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_reserved); - i.WriteU8(m_reqDlBurstProfile); - WriteTo(i, m_macAddress); - i.WriteU8(m_rangingAnomalies); -} - -uint32_t -RngReq::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_reserved = i.ReadU8(); - m_reqDlBurstProfile = i.ReadU8(); - ReadFrom(i, m_macAddress); - m_rangingAnomalies = i.ReadU8(); - - return i.GetDistanceFrom(start); -} - -// --------------------------------------------------------------------- - -NS_OBJECT_ENSURE_REGISTERED(RngRsp); - -RngRsp::RngRsp() - : m_reserved(0), - m_timingAdjust(0), - m_powerLevelAdjust(0), - m_offsetFreqAdjust(0), - m_rangStatus(0), - m_dlFreqOverride(0), - m_ulChnlIdOverride(0), - m_dlOperBurstProfile(0), - m_macAddress(Mac48Address("00:00:00:00:00:00")), - m_basicCid(), - m_primaryCid(), - m_aasBdcastPermission(0), - m_frameNumber(0), - m_initRangOppNumber(0), - m_rangSubchnl(0) -{ -} - -RngRsp::~RngRsp() -{ -} - -void -RngRsp::SetTimingAdjust(uint32_t timingAdjust) -{ - m_timingAdjust = timingAdjust; -} - -void -RngRsp::SetPowerLevelAdjust(uint8_t powerLevelAdjust) -{ - m_powerLevelAdjust = powerLevelAdjust; -} - -void -RngRsp::SetOffsetFreqAdjust(uint32_t offsetFreqAdjust) -{ - m_offsetFreqAdjust = offsetFreqAdjust; -} - -void -RngRsp::SetRangStatus(uint8_t rangStatus) -{ - m_rangStatus = rangStatus; -} - -void -RngRsp::SetDlFreqOverride(uint32_t dlFreqOverride) -{ - m_dlFreqOverride = dlFreqOverride; -} - -void -RngRsp::SetUlChnlIdOverride(uint8_t ulChnlIdOverride) -{ - m_ulChnlIdOverride = ulChnlIdOverride; -} - -void -RngRsp::SetDlOperBurstProfile(uint16_t dlOperBurstProfile) -{ - m_dlOperBurstProfile = dlOperBurstProfile; -} - -void -RngRsp::SetMacAddress(Mac48Address macAddress) -{ - m_macAddress = macAddress; -} - -void -RngRsp::SetBasicCid(Cid basicCid) -{ - m_basicCid = basicCid; -} - -void -RngRsp::SetPrimaryCid(Cid primaryCid) -{ - m_primaryCid = primaryCid; -} - -void -RngRsp::SetAasBdcastPermission(uint8_t aasBdcastPermission) -{ - m_aasBdcastPermission = aasBdcastPermission; -} - -void -RngRsp::SetFrameNumber(uint32_t frameNumber) -{ - m_frameNumber = frameNumber; -} - -void -RngRsp::SetInitRangOppNumber(uint8_t initRangOppNumber) -{ - m_initRangOppNumber = initRangOppNumber; -} - -void -RngRsp::SetRangSubchnl(uint8_t rangSubchnl) -{ - m_rangSubchnl = rangSubchnl; -} - -uint32_t -RngRsp::GetTimingAdjust() const -{ - return m_timingAdjust; -} - -uint8_t -RngRsp::GetPowerLevelAdjust() const -{ - return m_powerLevelAdjust; -} - -uint32_t -RngRsp::GetOffsetFreqAdjust() const -{ - return m_offsetFreqAdjust; -} - -uint8_t -RngRsp::GetRangStatus() const -{ - return m_rangStatus; -} - -uint32_t -RngRsp::GetDlFreqOverride() const -{ - return m_dlFreqOverride; -} - -uint8_t -RngRsp::GetUlChnlIdOverride() const -{ - return m_ulChnlIdOverride; -} - -uint16_t -RngRsp::GetDlOperBurstProfile() const -{ - return m_dlOperBurstProfile; -} - -Mac48Address -RngRsp::GetMacAddress() const -{ - return m_macAddress; -} - -Cid -RngRsp::GetBasicCid() const -{ - return m_basicCid; -} - -Cid -RngRsp::GetPrimaryCid() const -{ - return m_primaryCid; -} - -uint8_t -RngRsp::GetAasBdcastPermission() const -{ - return m_aasBdcastPermission; -} - -uint32_t -RngRsp::GetFrameNumber() const -{ - return m_frameNumber; -} - -uint8_t -RngRsp::GetInitRangOppNumber() const -{ - return m_initRangOppNumber; -} - -uint8_t -RngRsp::GetRangSubchnl() const -{ - return m_rangSubchnl; -} - -std::string -RngRsp::GetName() const -{ - return "RNG-RSP"; -} - -TypeId -RngRsp::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::RngRsp").SetParent
().SetGroupName("Wimax").AddConstructor(); - return tid; -} - -TypeId -RngRsp::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -RngRsp::Print(std::ostream& os) const -{ - os << " timing adjust = " << m_timingAdjust - << ", power level adjust = " << (uint32_t)m_powerLevelAdjust - << ", offset freq adjust = " << m_offsetFreqAdjust - << ", ranging status = " << (uint32_t)m_rangStatus - << ", dl freq override = " << m_dlFreqOverride - << ", ul channel id override = " << (uint32_t)m_ulChnlIdOverride - << ", dl operational burst profile = " << (uint32_t)m_dlOperBurstProfile - << ", mac address = " << m_macAddress << ", basic cid = " << m_basicCid - << ", primary management cid = " << m_primaryCid - << ", aas broadcast permission = " << (uint32_t)m_aasBdcastPermission - << ", frame number = " << m_frameNumber - << ", initial ranging opportunity number = " << (uint32_t)m_initRangOppNumber - << ", ranging subchannel = " << (uint32_t)m_rangSubchnl; -} - -uint32_t -RngRsp::GetSerializedSize() const -{ - return 1 + 4 + 1 + 4 + 1 + 4 + 1 + 2 + 6 + 2 + 2 + 1 + 4 + 1 + 1; -} - -void -RngRsp::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_reserved); - i.WriteU32(m_timingAdjust); - i.WriteU8(m_powerLevelAdjust); - i.WriteU32(m_offsetFreqAdjust); - i.WriteU8(m_rangStatus); - i.WriteU32(m_dlFreqOverride); - i.WriteU8(m_ulChnlIdOverride); - i.WriteU16(m_dlOperBurstProfile); - WriteTo(i, m_macAddress); - i.WriteU16(m_basicCid.GetIdentifier()); - i.WriteU16(m_primaryCid.GetIdentifier()); - i.WriteU8(m_aasBdcastPermission); - i.WriteU32(m_frameNumber); - i.WriteU8(m_initRangOppNumber); - i.WriteU8(m_rangSubchnl); -} - -uint32_t -RngRsp::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_reserved = i.ReadU8(); - m_timingAdjust = i.ReadU32(); - m_powerLevelAdjust = i.ReadU8(); - m_offsetFreqAdjust = i.ReadU32(); - m_rangStatus = i.ReadU8(); - m_dlFreqOverride = i.ReadU32(); - m_ulChnlIdOverride = i.ReadU8(); - m_dlOperBurstProfile = i.ReadU16(); - ReadFrom(i, m_macAddress); // length (6) shall also be written in packet instead of hard coded, - // see ARP example - m_basicCid = i.ReadU16(); - m_primaryCid = i.ReadU16(); - m_aasBdcastPermission = i.ReadU8(); - m_frameNumber = i.ReadU32(); - m_initRangOppNumber = i.ReadU8(); - m_rangSubchnl = i.ReadU8(); - - return i.GetDistanceFrom(start); -} - -// --------------------------------------------------------------------- - -NS_OBJECT_ENSURE_REGISTERED(DsaReq); - -DsaReq::DsaReq() - : m_transactionId(0), - m_sfid(0), - m_cid(), - m_serviceFlow(ServiceFlow::SF_DIRECTION_DOWN) -{ -} - -DsaReq::DsaReq(ServiceFlow sf) -{ - m_transactionId = 0; - m_serviceFlow = sf; -} - -DsaReq::~DsaReq() -{ -} - -void -DsaReq::SetTransactionId(uint16_t transactionId) -{ - m_transactionId = transactionId; -} - -uint16_t -DsaReq::GetTransactionId() const -{ - return m_transactionId; -} - -void -DsaReq::SetSfid(uint32_t sfid) -{ - m_sfid = sfid; -} - -uint32_t -DsaReq::GetSfid() const -{ - return m_sfid; -} - -void -DsaReq::SetCid(Cid cid) -{ - m_cid = cid; -} - -Cid -DsaReq::GetCid() const -{ - return m_cid; -} - -std::string -DsaReq::GetName() const -{ - return "DSA-REQ"; -} - -TypeId -DsaReq::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::DsaReq").SetParent
().SetGroupName("Wimax").AddConstructor(); - return tid; -} - -TypeId -DsaReq::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -DsaReq::Print(std::ostream& os) const -{ - os << " transaction id = " << (uint32_t)m_transactionId << ", m_sfid = " << m_sfid - << ", cid = " << m_cid; -} - -uint32_t -DsaReq::GetSerializedSize() const -{ - Tlv t = m_serviceFlow.ToTlv(); - uint32_t size = 2 + t.GetSerializedSize(); - return size; -} - -void -DsaReq::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU16(m_transactionId); - Tlv t = m_serviceFlow.ToTlv(); - t.Serialize(i); -} - -uint32_t -DsaReq::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_transactionId = i.ReadU16(); - Tlv tlv; - uint32_t size = tlv.Deserialize(i); - m_serviceFlow = ServiceFlow(tlv); - return size + 2; -} - -ServiceFlow -DsaReq::GetServiceFlow() const -{ - return m_serviceFlow; -} - -void -DsaReq::SetServiceFlow(ServiceFlow sf) -{ - m_serviceFlow = sf; -} - -// --------------------------------------------------------------------- - -NS_OBJECT_ENSURE_REGISTERED(DsaRsp); - -DsaRsp::DsaRsp() - : m_transactionId(0), - m_confirmationCode(0), - m_sfid(0), - m_cid() -{ -} - -DsaRsp::~DsaRsp() -{ -} - -void -DsaRsp::SetTransactionId(uint16_t transactionId) -{ - m_transactionId = transactionId; -} - -uint16_t -DsaRsp::GetTransactionId() const -{ - return m_transactionId; -} - -ServiceFlow -DsaRsp::GetServiceFlow() const -{ - return m_serviceFlow; -} - -void -DsaRsp::SetServiceFlow(ServiceFlow sf) -{ - m_serviceFlow = sf; -} - -void -DsaRsp::SetConfirmationCode(uint16_t confirmationCode) -{ - m_confirmationCode = confirmationCode; -} - -uint16_t -DsaRsp::GetConfirmationCode() const -{ - return m_confirmationCode; -} - -void -DsaRsp::SetSfid(uint32_t sfid) -{ - m_sfid = sfid; -} - -uint32_t -DsaRsp::GetSfid() const -{ - return m_sfid; -} - -void -DsaRsp::SetCid(Cid cid) -{ - m_cid = cid; -} - -Cid -DsaRsp::GetCid() const -{ - return m_cid; -} - -std::string -DsaRsp::GetName() const -{ - return "DSA-RSP"; -} - -TypeId -DsaRsp::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::DsaRsp").SetParent
().SetGroupName("Wimax").AddConstructor(); - return tid; -} - -TypeId -DsaRsp::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -DsaRsp::Print(std::ostream& os) const -{ - os << " transaction id = " << (uint32_t)m_transactionId - << ", confirmation code = " << (uint32_t)m_confirmationCode << ", m_sfid = " << m_sfid - << ", cid = " << m_cid; -} - -uint32_t -DsaRsp::GetSerializedSize() const -{ - return 2 + 1 + m_serviceFlow.ToTlv().GetSerializedSize(); -} - -void -DsaRsp::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - - i.WriteU16(m_transactionId); - i.WriteU8(m_confirmationCode); - m_serviceFlow.ToTlv().Serialize(i); -} - -uint32_t -DsaRsp::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - - m_transactionId = i.ReadU16(); - m_confirmationCode = i.ReadU8(); - Tlv tlv; - uint32_t size = tlv.Deserialize(i); - m_serviceFlow = ServiceFlow(tlv); - return size + 3; -} - -// --------------------------------------------------------------------- - -NS_OBJECT_ENSURE_REGISTERED(DsaAck); - -DsaAck::DsaAck() - : m_transactionId(0), - m_confirmationCode(0) -{ -} - -DsaAck::~DsaAck() -{ -} - -void -DsaAck::SetTransactionId(uint16_t transactionId) -{ - m_transactionId = transactionId; -} - -uint16_t -DsaAck::GetTransactionId() const -{ - return m_transactionId; -} - -void -DsaAck::SetConfirmationCode(uint16_t confirmationCode) -{ - m_confirmationCode = confirmationCode; -} - -uint16_t -DsaAck::GetConfirmationCode() const -{ - return m_confirmationCode; -} - -std::string -DsaAck::GetName() const -{ - return "DSA-ACK"; -} - -TypeId -DsaAck::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::DsaAck").SetParent
().SetGroupName("Wimax").AddConstructor(); - return tid; -} - -TypeId -DsaAck::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -DsaAck::Print(std::ostream& os) const -{ - os << " transaction id = " << (uint32_t)m_transactionId - << ", confirmation code = " << (uint32_t)m_confirmationCode; -} - -uint32_t -DsaAck::GetSerializedSize() const -{ - return 2 + 1; -} - -void -DsaAck::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU16(m_transactionId); - i.WriteU8(m_confirmationCode); -} - -uint32_t -DsaAck::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_transactionId = i.ReadU16(); - m_confirmationCode = i.ReadU8(); - - return i.GetDistanceFrom(start); -} - -} // namespace ns3 diff --git a/src/wimax/model/mac-messages.h b/src/wimax/model/mac-messages.h deleted file mode 100644 index 07d85d171..000000000 --- a/src/wimax/model/mac-messages.h +++ /dev/null @@ -1,718 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -/* - *This file does not contain all MAC messages, the rest of MAC messages have - *This been categorized as DL and UL messages and are placed in - *This dl-mac-messages.h and ul-mac-messages.h files. - */ - -#ifndef MANAGEMENT_MESSAGE_TYPE_H -#define MANAGEMENT_MESSAGE_TYPE_H - -#include "ns3/header.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * Mac Management messages - * Section 6.3.2.3 MAC Management messages page 42, Table 14 page 43 - */ -class ManagementMessageType : public Header -{ - public: - /// Message type enumeration - enum MessageType - { - MESSAGE_TYPE_UCD = 0, - MESSAGE_TYPE_DCD = 1, - MESSAGE_TYPE_DL_MAP = 2, - MESSAGE_TYPE_UL_MAP = 3, - MESSAGE_TYPE_RNG_REQ = 4, - MESSAGE_TYPE_RNG_RSP = 5, - MESSAGE_TYPE_REG_REQ = 6, - MESSAGE_TYPE_REG_RSP = 7, - MESSAGE_TYPE_DSA_REQ = 11, - MESSAGE_TYPE_DSA_RSP = 12, - MESSAGE_TYPE_DSA_ACK = 13 - }; - - ManagementMessageType(); - /** - * Constructor - * - * @param type message type - */ - ManagementMessageType(uint8_t type); - ~ManagementMessageType() override; - /** - * Set type field - * @param type the type - */ - void SetType(uint8_t type); - /** - * Get type field - * @returns the type value - */ - uint8_t GetType() const; - - /** @returns the name field */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - uint8_t m_type; ///< type -}; - -} // namespace ns3 - -#endif /* MANAGEMENT_MESSAGE_TYPE_H */ - -// --------------------------------------------------------------------- - -#ifndef RNG_RSP_H -#define RNG_RSP_H - -#include "cid.h" -#include "service-flow.h" - -#include "ns3/header.h" -#include "ns3/mac48-address.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * This class implements the ranging response message described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 6.3.2.3.6 Ranging response (RNG-RSP) message, page 50 - */ -class RngRsp : public Header -{ - public: - RngRsp(); - ~RngRsp() override; - /** - * @brief set the Tx timing offset adjustment (signed 32-bit). - * @param timingAdjust The time required to advance SS transmission so frames - * arrive at the expected time instance at the BS. - */ - void SetTimingAdjust(uint32_t timingAdjust); - /** - * @brief set the relative change in transmission power level that the SS should make in order - * that transmissions arrive at the BS at the desired power. When subchannelization is employed, - * the subscriber shall interpret the power offset adjustment as a required change to the - * transmitted power density. - * @param powerLevelAdjust the relative change in transmission power level - */ - void SetPowerLevelAdjust(uint8_t powerLevelAdjust); - /** - * @brief set the relative change in transmission frequency that the SS should take in order to - * better match the BS. This is fine-frequency adjustment within a channel, not reassignment to - * a different channel - * @param offsetFreqAdjust Offset frequency adjustment - */ - void SetOffsetFreqAdjust(uint32_t offsetFreqAdjust); - /** - * @brief set the range status. - * @param rangStatus Range status - */ - void SetRangStatus(uint8_t rangStatus); - /** - * @brief set the Center frequency, in kHz, of new downlink channel where the SS should redo - * initial ranging. - * @param dlFreqOverride the Center frequency in kHz - */ - void SetDlFreqOverride(uint32_t dlFreqOverride); - /** - * @brief set the identifier of the uplink channel with which the SS is to redo initial ranging - * @param ulChnlIdOverride the uplink channel index - */ - void SetUlChnlIdOverride(uint8_t ulChnlIdOverride); - /** - * @brief set the DL oper burst profile - * @param dlOperBurstProfile the oper burt profile - */ - void SetDlOperBurstProfile(uint16_t dlOperBurstProfile); - /** - * @brief set the MAC address - * @param macAddress the MAC address - */ - void SetMacAddress(Mac48Address macAddress); - - /** - * @brief set basic CID. - * @param basicCid Basic CID - */ - void SetBasicCid(Cid basicCid); - /** - * @brief set primary CID. - * @param primaryCid Primary CID - */ - void SetPrimaryCid(Cid primaryCid); - - /** - * @brief set AAS broadcast permission. - * @param aasBdcastPermission AAS broadcast permission - */ - void SetAasBdcastPermission(uint8_t aasBdcastPermission); - /** - * @brief set frame number. - * @param frameNumber Frame number - */ - void SetFrameNumber(uint32_t frameNumber); - /** - * @brief set initial range opp number. - * @param initRangOppNumber Initial range opp number - */ - void SetInitRangOppNumber(uint8_t initRangOppNumber); - /** - * @brief set range sub channel. - * @param rangSubchnl Range subchannel - */ - void SetRangSubchnl(uint8_t rangSubchnl); - /** - * @return Tx timing offset adjustment (signed 32-bit). The time required to advance SS - * transmission so frames arrive at the expected time instance at the BS. - */ - uint32_t GetTimingAdjust() const; - /** - * @return the relative change in transmission power level that the SS should take in order - * that transmissions arrive at the BS at the desired power. When subchannelization is employed, - * the subscriber shall interpret the power offset adjustment as a required change to the - * transmitted power density. - */ - uint8_t GetPowerLevelAdjust() const; - /** - * @return the relative change in transmission frequency that the SS should take in order to - * better match the BS. This is fine-frequency adjustment within a channel, not reassignment to - * a different channel. - */ - uint32_t GetOffsetFreqAdjust() const; - /** - * @return the range status. - */ - uint8_t GetRangStatus() const; - /** - * @return Center frequency, in kHz, of new downlink channel where the SS should redo initial - * ranging. - */ - uint32_t GetDlFreqOverride() const; - /** - * @return The identifier of the uplink channel with which the SS is to redo initial ranging - */ - uint8_t GetUlChnlIdOverride() const; - /** - * @return DlOperBurstProfile: This parameter is sent in response to the RNG-REQ Requested - * Downlink Burst Profile parameter - */ - uint16_t GetDlOperBurstProfile() const; - /** - * @return MAC address - */ - Mac48Address GetMacAddress() const; - /** - * @return basic CID - */ - Cid GetBasicCid() const; - /** - * @return primary CID - */ - Cid GetPrimaryCid() const; - /** - * @return AAS broadcast permission - */ - uint8_t GetAasBdcastPermission() const; - /** - * @return frame number - */ - uint32_t GetFrameNumber() const; - /** - * @return initial range opp number - */ - uint8_t GetInitRangOppNumber() const; - /** - * @return range sub channel - */ - uint8_t GetRangSubchnl() const; - - /** - * @return name string - */ - std::string GetName() const; - /** - * Register this type. - * @return The TypeId. - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - uint8_t m_reserved; ///< changed as per the amendment 802.16e-2005 - - // TLV Encoded Information - - /** - * Tx timing offset adjustment (signed 32-bit). The time required to advance SS transmission so - * frames arrive at the expected time instance at the BS. - */ - uint32_t m_timingAdjust; - - /** - * Specifies the relative change in transmission power level that the SS is to make in order - * that transmissions arrive at the BS at the desired power. When subchannelization is employed, - * the subscriber shall interpret the power offset adjustment as a required change to the - * transmitted power density. - */ - uint8_t m_powerLevelAdjust; - - /** - * Specifies the relative change in transmission frequency that the SS is to make in order to - * better match the BS. This is fine-frequency adjustment within a channel, not reassignment to - * a different channel. - */ - uint32_t m_offsetFreqAdjust; - - /** - * range status. - */ - uint8_t m_rangStatus; - - /// Center frequency, in kHz, of new downlink channel where the SS should redo initial ranging. - uint32_t m_dlFreqOverride; - - /** - * Licensed bands: The identifier of the uplink channel with which the SS is to redo initial - * ranging (not used with PHYs without channelized uplinks). - */ - uint8_t m_ulChnlIdOverride; - - /** - * This parameter is sent in response to the RNG-REQ Requested Downlink Burst Profile parameter. - * Byte 0: Specifies the least robust DIUC that may be used by the BS for transmissions to the - * SS. Byte 1: Configuration Change Count value of DCD defining the burst profile associated - * with DIUC. - */ - uint16_t m_dlOperBurstProfile; - - Mac48Address m_macAddress; ///< MAC address - Cid m_basicCid; ///< basic CID - Cid m_primaryCid; ///< primary CID - uint8_t m_aasBdcastPermission; ///< AAS broadcast permission - - /** - * Frame number where the associated RNG_REQ message was detected by the BS. Usage is mutually - * exclusive with SS MAC Address - */ - uint32_t m_frameNumber; - - /** - * Initial Ranging opportunity (1–255) in which the associated RNG_REQ message was detected by - * the BS. Usage is mutually exclusive with SS MAC Address - */ - uint8_t m_initRangOppNumber; - - /** - * Used to indicate the OFDM subchannel reference that was used to transmit the initial ranging - * message (OFDM with subchannelization). - */ - uint8_t m_rangSubchnl; -}; - -} // namespace ns3 - -#endif /* RNG_RSP_H */ - -// --------------------------------------------------------------------- - -#ifndef DSA_REQ_H -#define DSA_REQ_H - -#include "cid.h" -#include "service-flow.h" - -#include "ns3/buffer.h" -#include "ns3/header.h" - -#include - -namespace ns3 -{ -/** - * @ingroup wimax - * This class implements the DSA-REQ message described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 6.3.2.3.10 DSA-REQ message, page 62 - */ -class DsaReq : public Header -{ - public: - DsaReq(); - ~DsaReq() override; - /** - * Constructor - * - * @param sf service flow - */ - DsaReq(ServiceFlow sf); - /** - * @brief set the transaction ID - * @param transactionId - */ - void SetTransactionId(uint16_t transactionId); - /** - * @brief set the service flow identifier - * @param sfid the service flow identifier - */ - void SetSfid(uint32_t sfid); - /** - * @brief set the connection identifier - * @param cid the connection identifier - */ - void SetCid(Cid cid); - /** - * @brief specify a service flow to be requested by this message - * @param sf the service flow - */ - void SetServiceFlow(ServiceFlow sf); - /** - * @return the service flow requested by this message - */ - ServiceFlow GetServiceFlow() const; - /** - * @return the transaction ID - */ - uint16_t GetTransactionId() const; - /** - * @return the service flow identifier - */ - uint32_t GetSfid() const; - /** - * @return the connection identifier - */ - Cid GetCid() const; - /** - * @return the service name - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - uint16_t m_transactionId; ///< transaction ID - // TLV Encoded Information - uint32_t m_sfid; ///< SFID - Cid m_cid; ///< CID - ServiceFlow m_serviceFlow; ///< service flow -}; - -} // namespace ns3 - -#endif /* DSA_REQ_H */ - -// --------------------------------------------------------------------- - -#ifndef DSA_RSP_H -#define DSA_RSP_H - -#include "cid.h" - -#include "ns3/buffer.h" -#include "ns3/header.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * This class implements the DSA-RSP message described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 6.3.2.3.11 DSA-RSP message, page 63 - * @verbatim - 0 7 15 23 - +-------------+-------------+-------------+ - |Mngt msg type| Transaction ID | - +-------------+-------------+-------------+ - | Conf Code | Service Flow TLV | - +~~~~~~~~~~~~~+~~~~~~~~~~~~~+~~~~~~~~~~~~~+ - \endverbatim - */ -class DsaRsp : public Header -{ - public: - DsaRsp(); - ~DsaRsp() override; - - /** - * @brief set the transaction ID - * @param transactionId - */ - void SetTransactionId(uint16_t transactionId); - /** - * @return the transaction ID - */ - uint16_t GetTransactionId() const; - - /** - * @brief set the confirmation code - * @param confirmationCode - */ - void SetConfirmationCode(uint16_t confirmationCode); - /** - * @return the confirmation code - */ - uint16_t GetConfirmationCode() const; - /** - * @brief set the service flow identifier - * @param sfid the service flow identifier - */ - void SetSfid(uint32_t sfid); - /** - * @return the service flow identifier - */ - uint32_t GetSfid() const; - /** - * @brief set the connection identifier - * @param cid the connection identifier - */ - void SetCid(Cid cid); - /** - * @return the connection identifier - */ - Cid GetCid() const; - /** - * @brief specify a service flow to be requested by this message - * @param sf the service flow - */ - void SetServiceFlow(ServiceFlow sf); - /** - * @return the service flow requested by this message - */ - ServiceFlow GetServiceFlow() const; - - /** - * @return the service name - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - uint16_t m_transactionId; ///< transaction ID - uint8_t m_confirmationCode; ///< confirmation code - // TLV Encoded Information - ServiceFlow m_serviceFlow; ///< service flow - uint32_t m_sfid; ///< SFID - Cid m_cid; ///< CID -}; - -} // namespace ns3 - -#endif /* DSA_RSP_H */ - -// --------------------------------------------------------------------- - -#ifndef DSA_ACK_H -#define DSA_ACK_H - -#include "ns3/buffer.h" -#include "ns3/header.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * This class implements the DSA-ACK message described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 6.3.2.3.12 DSA-ACK message, page 64 - */ -class DsaAck : public Header -{ - public: - DsaAck(); - ~DsaAck() override; - - /** - * Set transaction ID field - * @param transactionId the transaction ID - */ - void SetTransactionId(uint16_t transactionId); - /** - * Get transaction ID field - * @returns the transaction ID - */ - uint16_t GetTransactionId() const; - - /** - * Set confirmation code field - * @param confirmationCode the confirmation code - */ - void SetConfirmationCode(uint16_t confirmationCode); - /** - * Get confirmation code field - * @returns the confirmation code - */ - uint16_t GetConfirmationCode() const; - - /** - * Get name field - * @return the name string - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - uint16_t m_transactionId; ///< transaction ID - uint8_t m_confirmationCode; ///< confirmation code -}; - -} // namespace ns3 - -#endif /* DSA_ACK_H */ - -// --------------------------------------------------------------------- - -#ifndef RNG_REQ_H -#define RNG_REQ_H - -#include "service-flow.h" - -#include "ns3/header.h" -#include "ns3/mac48-address.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * This class implements the ranging request message described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" - */ -class RngReq : public Header -{ - public: - RngReq(); - ~RngReq() override; - - /** - * Set request DL burst profile field - * @param reqDlBurstProfile the request DL burst profile - */ - void SetReqDlBurstProfile(uint8_t reqDlBurstProfile); - /** - * Set MAC address field - * @param macAddress the MAC address - */ - void SetMacAddress(Mac48Address macAddress); - /** - * Set ranging anomalies field - * @param rangingAnomalies the rnaging anomalies - */ - void SetRangingAnomalies(uint8_t rangingAnomalies); - - /** - * Get request DL burst profile field - * @returns the request DL burst profile - */ - uint8_t GetReqDlBurstProfile() const; - /** - * Get MAC address field - * @returns the MAC address - */ - Mac48Address GetMacAddress() const; - /** - * Get ranging anomalies field - * @returns the ranging anomalies - */ - uint8_t GetRangingAnomalies() const; - - /** - * @brief Get name field - * @returns the name string - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - /// Print debug function - void PrintDebug() const; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - uint8_t m_reserved; ///< changed as per the amendment 802.16e-2005 - - // TLV Encoded Information - uint8_t m_reqDlBurstProfile; ///< request DL burst profile - Mac48Address m_macAddress; ///< MAC address - uint8_t m_rangingAnomalies; ///< ranging anomalies -}; - -} // namespace ns3 - -#endif /* RNG_REQ_H */ diff --git a/src/wimax/model/ofdm-downlink-frame-prefix.cc b/src/wimax/model/ofdm-downlink-frame-prefix.cc deleted file mode 100644 index 007e5a154..000000000 --- a/src/wimax/model/ofdm-downlink-frame-prefix.cc +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#include "ofdm-downlink-frame-prefix.h" - -#include "ns3/address-utils.h" - -#include - -namespace ns3 -{ - -DlFramePrefixIe::DlFramePrefixIe() - : m_rateId(0), - m_diuc(0), - m_preamblePresent(0), - m_length(0), - m_startTime(0) -{ -} - -DlFramePrefixIe::~DlFramePrefixIe() -{ -} - -void -DlFramePrefixIe::SetRateId(uint8_t rateId) -{ - m_rateId = rateId; -} - -void -DlFramePrefixIe::SetDiuc(uint8_t diuc) -{ - m_diuc = diuc; -} - -void -DlFramePrefixIe::SetPreamblePresent(uint8_t preamblePresent) -{ - m_preamblePresent = preamblePresent; -} - -void -DlFramePrefixIe::SetLength(uint16_t length) -{ - m_length = length; -} - -void -DlFramePrefixIe::SetStartTime(uint16_t startTime) -{ - m_startTime = startTime; -} - -uint8_t -DlFramePrefixIe::GetRateId() const -{ - return m_rateId; -} - -uint8_t -DlFramePrefixIe::GetDiuc() const -{ - return m_diuc; -} - -uint8_t -DlFramePrefixIe::GetPreamblePresent() const -{ - return m_preamblePresent; -} - -uint16_t -DlFramePrefixIe::GetLength() const -{ - return m_length; -} - -uint16_t -DlFramePrefixIe::GetStartTime() const -{ - return m_startTime; -} - -uint16_t -DlFramePrefixIe::GetSize() const -{ - return 1 + 1 + 1 + 2 + 2; -} - -Buffer::Iterator -DlFramePrefixIe::Write(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_rateId); - i.WriteU8(m_diuc); - i.WriteU8(m_preamblePresent); - i.WriteU16(m_length); - i.WriteU16(m_startTime); - return i; -} - -Buffer::Iterator -DlFramePrefixIe::Read(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_rateId = i.ReadU8(); - m_diuc = i.ReadU8(); - m_preamblePresent = i.ReadU8(); - m_length = i.ReadU16(); - m_startTime = i.ReadU16(); - return i; -} - -OfdmDownlinkFramePrefix::OfdmDownlinkFramePrefix() - : m_baseStationId(Mac48Address("00:00:00:00:00:00")), - m_frameNumber(0), - m_configurationChangeCount(0), - m_hcs(0) -{ -} - -OfdmDownlinkFramePrefix::~OfdmDownlinkFramePrefix() -{ -} - -/* static */ -TypeId -OfdmDownlinkFramePrefix::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::OfdmDownlinkFramePrefix").SetParent
().SetGroupName("Wimax") - // No AddConstructor because this is an abstract class. - ; - return tid; -} - -void -OfdmDownlinkFramePrefix::SetBaseStationId(Mac48Address baseStationId) -{ - m_baseStationId = baseStationId; -} - -void -OfdmDownlinkFramePrefix::SetFrameNumber(uint32_t frameNumber) -{ - m_frameNumber = frameNumber; -} - -void -OfdmDownlinkFramePrefix::SetConfigurationChangeCount(uint8_t configurationChangeCount) -{ - m_configurationChangeCount = configurationChangeCount; -} - -void -OfdmDownlinkFramePrefix::AddDlFramePrefixElement(DlFramePrefixIe dlFramePrefixElement) -{ - m_dlFramePrefixElements.push_back(dlFramePrefixElement); -} - -void -OfdmDownlinkFramePrefix::SetHcs(uint8_t hcs) -{ - m_hcs = hcs; -} - -Mac48Address -OfdmDownlinkFramePrefix::GetBaseStationId() const -{ - return m_baseStationId; -} - -uint32_t -OfdmDownlinkFramePrefix::GetFrameNumber() const -{ - return m_frameNumber; -} - -uint8_t -OfdmDownlinkFramePrefix::GetConfigurationChangeCount() const -{ - return m_configurationChangeCount; -} - -std::vector -OfdmDownlinkFramePrefix::GetDlFramePrefixElements() const -{ - return m_dlFramePrefixElements; -} - -uint8_t -OfdmDownlinkFramePrefix::GetHcs() const -{ - return m_hcs; -} - -std::string -OfdmDownlinkFramePrefix::GetName() const -{ - return "OFDM Downlink Frame Prefix"; -} - -void -OfdmDownlinkFramePrefix::Print(std::ostream& os) const -{ - os << " base station id = " << m_baseStationId << ", frame number = " << m_frameNumber - << ", configuration change count = " << (uint32_t)m_configurationChangeCount - << ", number of dl frame prefix elements = " << m_dlFramePrefixElements.size() - << ", hcs = " << (uint32_t)m_hcs; -} - -uint32_t -OfdmDownlinkFramePrefix::GetSerializedSize() const -{ - int dlFramePrefixElementsSize = 0; - - for (const auto& dlFramePrefixElement : m_dlFramePrefixElements) - { - dlFramePrefixElementsSize += dlFramePrefixElement.GetSize(); - } - - return 6 + 4 + 1 + dlFramePrefixElementsSize + 1; -} - -void -OfdmDownlinkFramePrefix::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - WriteTo(i, m_baseStationId); - i.WriteU32(m_frameNumber); - i.WriteU8(m_configurationChangeCount); - - for (const auto& dlFramePrefixElement : m_dlFramePrefixElements) - { - i = dlFramePrefixElement.Write(i); - } - - i.WriteU8(m_hcs); -} - -uint32_t -OfdmDownlinkFramePrefix::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - ReadFrom(i, m_baseStationId); - m_frameNumber = i.ReadU32(); - m_configurationChangeCount = i.ReadU8(); - - bool end = false; - - while (!end) - { - DlFramePrefixIe dlFramePrefixElement; - i = dlFramePrefixElement.Read(i); - - AddDlFramePrefixElement(dlFramePrefixElement); - - if (dlFramePrefixElement.GetDiuc() == 14) - { - end = true; - } - } - - m_hcs = i.ReadU8(); - - return GetSerializedSize(); -} - -} // namespace ns3 diff --git a/src/wimax/model/ofdm-downlink-frame-prefix.h b/src/wimax/model/ofdm-downlink-frame-prefix.h deleted file mode 100644 index de90b520b..000000000 --- a/src/wimax/model/ofdm-downlink-frame-prefix.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#ifndef DL_FRAME_PREFIX_IE_H -#define DL_FRAME_PREFIX_IE_H - -#include "ns3/header.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * @brief This class implements the DL Frame Prefix IE as described by IEEE-802.16 standard - * @brief The DL Frame Prefix IE is contained in DLFP (Downlink Frame Prefix) in OFDM PHY - */ -class DlFramePrefixIe -{ - public: - DlFramePrefixIe(); - ~DlFramePrefixIe(); - - /** - * Set rate ID field - * @param rateId the rate ID - */ - void SetRateId(uint8_t rateId); - /** - * Set DIUC field - * @param diuc the DIUC - */ - void SetDiuc(uint8_t diuc); - /** - * Set preamble present field - * @param preamblePresent the preambel present - */ - void SetPreamblePresent(uint8_t preamblePresent); - /** - * Set length field - * @param length the length - */ - void SetLength(uint16_t length); - /** - * Set start time field - * @param startTime the start time - */ - void SetStartTime(uint16_t startTime); - - /** - * Get rate ID field - * @returns the rate ID - */ - uint8_t GetRateId() const; - /** - * Get DIUC field - * @returns the DIUC - */ - uint8_t GetDiuc() const; - /** - * Get preamble present field - * @returns the preamble present - */ - uint8_t GetPreamblePresent() const; - /** - * Get length field - * @returns the length - */ - uint16_t GetLength() const; - /** - * Get start time field - * @returns the start time - */ - uint16_t GetStartTime() const; - - /** - * Get size field - * @returns the size - */ - uint16_t GetSize() const; - - /** - * Write item function - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator Write(Buffer::Iterator start) const; - /** - * Read item function - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator Read(Buffer::Iterator start); - - private: - uint8_t m_rateId; ///< rate ID - uint8_t m_diuc; ///< DIUC - uint8_t m_preamblePresent; ///< preamble present - uint16_t m_length; ///< length - uint16_t m_startTime; ///< start time - - // shall actually contain m_startTime if DIUC is 0. see Table 225, page 452 -}; - -} // namespace ns3 - -#endif /* DL_FRAME_PREFIX_IE_H */ - -#ifndef OFDM_DOWNLINK_FRAME_PREFIX_H -#define OFDM_DOWNLINK_FRAME_PREFIX_H - -#include "ns3/header.h" -#include "ns3/mac48-address.h" - -#include - -namespace ns3 -{ - -/** - * OfdmDownlinkFramePrefix - */ -class OfdmDownlinkFramePrefix : public Header -{ - public: - OfdmDownlinkFramePrefix(); - ~OfdmDownlinkFramePrefix() override; - - /** - * Register this type. - * @return The TypeId. - */ - static TypeId GetTypeId(); - - /** - * Set base station ID field - * @param baseStationId the base station ID - */ - void SetBaseStationId(Mac48Address baseStationId); - /** - * Set frame number field - * @param frameNumber the frame number - */ - void SetFrameNumber(uint32_t frameNumber); - /** - * Set configuration change count field - * @param configurationChangeCount the configuration change count - */ - void SetConfigurationChangeCount(uint8_t configurationChangeCount); - /** - * Add DL frame prefix element field - * @param dlFramePrefixElement the DL frame prefix element - */ - void AddDlFramePrefixElement(DlFramePrefixIe dlFramePrefixElement); - /** - * Set HCS field - * @param hcs the HCS - */ - void SetHcs(uint8_t hcs); - - /** - * Get base station ID field - * @returns the base station ID - */ - Mac48Address GetBaseStationId() const; - /** - * Get frame number field - * @returns the frame number - */ - uint32_t GetFrameNumber() const; - /** - * Get configuration change count field - * @returns the configuration change count - */ - uint8_t GetConfigurationChangeCount() const; - /** - * Get DL frame prefix elements - * @returns the DL frame prefix elements - */ - std::vector GetDlFramePrefixElements() const; - /** - * Get HCS field - * @returns the HCS - */ - uint8_t GetHcs() const; - - /** - * Get name field - * @returns the name - */ - std::string GetName() const; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - Mac48Address m_baseStationId; ///< base station ID - uint32_t m_frameNumber; ///< shall actually be only 4 LSB of the same field in OFDM DCD Channel - ///< Encodings - uint8_t m_configurationChangeCount; ///< shall actually be only 4 LSB of the same field in DCD - std::vector m_dlFramePrefixElements; ///< vector of dl frame prefix elements - uint8_t m_hcs; ///< Header Check Sequence -}; - -} // namespace ns3 - -#endif /* OFDM_DOWNLINK_FRAME_PREFIX_H */ diff --git a/src/wimax/model/send-params.cc b/src/wimax/model/send-params.cc deleted file mode 100644 index 0ea13e951..000000000 --- a/src/wimax/model/send-params.cc +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#include "send-params.h" - -#include "ns3/packet.h" - -namespace ns3 -{ - -SendParams::SendParams() -{ -} - -SendParams::~SendParams() -{ -} - -// ----------------------------------------- - -OfdmSendParams::OfdmSendParams(Ptr burst, uint8_t modulationType, uint8_t direction) - : SendParams(), - m_burst(burst), - m_modulationType(modulationType), - m_direction(direction) -{ -} - -OfdmSendParams::~OfdmSendParams() -{ -} - -} // namespace ns3 diff --git a/src/wimax/model/send-params.h b/src/wimax/model/send-params.h deleted file mode 100644 index 539ff0218..000000000 --- a/src/wimax/model/send-params.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#ifndef SEND_PARAMS_H -#define SEND_PARAMS_H - -#include - -namespace ns3 -{ - -class WimaxPhy; - -/** - * @ingroup wimax - * @brief The SendParams class defines the parameters with which Send() function of - * a particular PHY is called. The sole purpose of this class is to allow - * defining the pure virtual Send() function in the PHY base-class (WimaxPhy). - * This class shall be sub-classed every time a new PHY is integrated (i.e., - * a new sub-class of WimaxPhy is created) which requires different or - * additional parameters to call its Send() function. For example as it is - * seen here, it has been sub-classed for the OFDM PHY layer since its Send() - * function requires two additional parameters. - */ -class SendParams -{ - public: - SendParams(); - virtual ~SendParams(); - - private: -}; - -} // namespace ns3 - -#endif /* SEND_PARAMS_H */ - -#ifndef OFDM_SEND_PARAMS_H -#define OFDM_SEND_PARAMS_H - -#include "ns3/packet-burst.h" - -#include - -namespace ns3 -{ - -/** - * OfdmSendParams class - */ -class OfdmSendParams : public SendParams -{ - public: - /** - * Constructor - * - * @param burst packet burst object - * @param modulationType modulation type - * @param direction the direction - */ - OfdmSendParams(Ptr burst, uint8_t modulationType, uint8_t direction); - ~OfdmSendParams() override; - - /** - * @return the packet burst - */ - Ptr GetBurst() const - { - return m_burst; - } - - /** - * @return the modulation type - */ - uint8_t GetModulationType() const - { - return m_modulationType; - } - - /** - * @return the direction - */ - uint8_t GetDirection() const - { - return m_direction; - } - - private: - Ptr m_burst; ///< packet burst - uint8_t m_modulationType; ///< modulation type - uint8_t m_direction; ///< direction -}; - -} // namespace ns3 - -#endif /* OFDM_SEND_PARAMS_H */ diff --git a/src/wimax/model/service-flow-manager.cc b/src/wimax/model/service-flow-manager.cc deleted file mode 100644 index 086e3882a..000000000 --- a/src/wimax/model/service-flow-manager.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - */ - -#include "service-flow-manager.h" - -#include "bs-net-device.h" -#include "bs-uplink-scheduler.h" -#include "connection-manager.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-manager.h" -#include "ss-net-device.h" -#include "ss-record.h" -#include "ss-scheduler.h" -#include "wimax-connection.h" -#include "wimax-net-device.h" - -#include "ns3/buffer.h" -#include "ns3/enum.h" -#include "ns3/log.h" -#include "ns3/node.h" -#include "ns3/packet.h" -#include "ns3/pointer.h" -#include "ns3/simulator.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("ServiceFlowManager"); - -NS_OBJECT_ENSURE_REGISTERED(ServiceFlowManager); - -TypeId -ServiceFlowManager::GetTypeId() -{ - static TypeId tid = TypeId("ns3::ServiceFlowManager").SetParent().SetGroupName("Wimax"); - return tid; -} - -ServiceFlowManager::ServiceFlowManager() -{ - m_serviceFlows = new std::vector; -} - -ServiceFlowManager::~ServiceFlowManager() -{ -} - -void -ServiceFlowManager::DoDispose() -{ - for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) - { - delete (*iter); - } - m_serviceFlows->clear(); - delete m_serviceFlows; -} - -void -ServiceFlowManager::AddServiceFlow(ServiceFlow* serviceFlow) -{ - m_serviceFlows->push_back(serviceFlow); -} - -ServiceFlow* -ServiceFlowManager::DoClassify(Ipv4Address srcAddress, - Ipv4Address dstAddress, - uint16_t srcPort, - uint16_t dstPort, - uint8_t proto, - ServiceFlow::Direction dir) const -{ - for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) - { - if ((*iter)->GetDirection() == dir) - { - if ((*iter)->CheckClassifierMatch(srcAddress, dstAddress, srcPort, dstPort, proto)) - { - return *iter; - } - } - } - return nullptr; -} - -ServiceFlow* -ServiceFlowManager::GetServiceFlow(uint32_t sfid) const -{ - for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) - { - if ((*iter)->GetSfid() == sfid) - { - return *iter; - } - } - - NS_LOG_DEBUG("GetServiceFlow: service flow not found!"); - return nullptr; -} - -ServiceFlow* -ServiceFlowManager::GetServiceFlow(Cid cid) const -{ - for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) - { - if ((*iter)->GetCid() == cid.GetIdentifier()) - { - return *iter; - } - } - - NS_LOG_DEBUG("GetServiceFlow: service flow not found!"); - return nullptr; -} - -std::vector -ServiceFlowManager::GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const -{ - std::vector tmpServiceFlows; - for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) - { - if (((*iter)->GetSchedulingType() == schedulingType) || - (schedulingType == ServiceFlow::SF_TYPE_ALL)) - { - tmpServiceFlows.push_back(*iter); - } - } - return tmpServiceFlows; -} - -bool -ServiceFlowManager::AreServiceFlowsAllocated() -{ - return AreServiceFlowsAllocated(m_serviceFlows); -} - -bool -ServiceFlowManager::AreServiceFlowsAllocated(std::vector* serviceFlowVector) -{ - return AreServiceFlowsAllocated(*serviceFlowVector); -} - -bool -ServiceFlowManager::AreServiceFlowsAllocated(std::vector serviceFlowVector) -{ - for (auto iter = serviceFlowVector.begin(); iter != serviceFlowVector.end(); ++iter) - { - if (!(*iter)->GetIsEnabled()) - { - return false; - } - } - return true; -} - -ServiceFlow* -ServiceFlowManager::GetNextServiceFlowToAllocate() -{ - for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) - { - if (!(*iter)->GetIsEnabled()) - { - return *iter; - } - } - return nullptr; -} - -uint32_t -ServiceFlowManager::GetNrServiceFlows() const -{ - return m_serviceFlows->size(); -} - -} // namespace ns3 diff --git a/src/wimax/model/service-flow-manager.h b/src/wimax/model/service-flow-manager.h deleted file mode 100644 index 5972ef571..000000000 --- a/src/wimax/model/service-flow-manager.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - * Mohamed Amine Ismail - */ - -#ifndef SERVICE_FLOW_MANAGER_H -#define SERVICE_FLOW_MANAGER_H - -#include "mac-messages.h" - -#include "ns3/buffer.h" -#include "ns3/event-id.h" - -#include - -namespace ns3 -{ - -class Packet; -class ServiceFlow; -class WimaxNetDevice; -class SSRecord; -class WimaxConnection; - -/** - * @ingroup wimax - * The same service flow manager class serves both for BS and SS though some functions are exclusive - * to only one of them. - */ -class ServiceFlowManager : public Object -{ - public: - /// confirmation code enumeration as per Table 384 (not all codes implemented) - enum ConfirmationCode - { - CONFIRMATION_CODE_SUCCESS, - CONFIRMATION_CODE_REJECT - }; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - - ServiceFlowManager(); - ~ServiceFlowManager() override; - void DoDispose() override; - - /** - * Add service flow function - * @param serviceFlow the service flow - */ - void AddServiceFlow(ServiceFlow* serviceFlow); - /** - * Get service flow by flow id - * @param sfid the service flow id - * @returns pointer to the service flow object corresponding to the flow id - */ - ServiceFlow* GetServiceFlow(uint32_t sfid) const; - /** - * Get service flow by CID - * @param cid the CID - * @returns pointer to the service flow object corresponding to the CID - */ - ServiceFlow* GetServiceFlow(Cid cid) const; - /** - * Get service flows function - * @param schedulingType the scheduling type - * @returns vector of pointers to service flows corresponding to the scheduling type - */ - std::vector GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const; - - /** - * @return true if all service flows are allocated, false otherwise - */ - bool AreServiceFlowsAllocated(); - /** - * @param serviceFlows vector of pointers to service flows to be checked - * @return true if all service flows are allocated, false otherwise - */ - bool AreServiceFlowsAllocated(std::vector* serviceFlows); - /** - * @param serviceFlows vector of pointers to service flows to be checked - * @return true if all service flows are allocated, false otherwise - */ - bool AreServiceFlowsAllocated(std::vector serviceFlows); - /** - * @return pointer to the next service flow to be allocated - */ - ServiceFlow* GetNextServiceFlowToAllocate(); - - /** - * @return the number of all service flows - */ - uint32_t GetNrServiceFlows() const; - - /** - * @param SrcAddress the source ip address - * @param DstAddress the destination ip address - * @param SrcPort the source port - * @param DstPort the destination port - * @param Proto the protocol - * @param dir the direction of the service flow - * @return the service flow to which this ip flow is associated - */ - ServiceFlow* DoClassify(Ipv4Address SrcAddress, - Ipv4Address DstAddress, - uint16_t SrcPort, - uint16_t DstPort, - uint8_t Proto, - ServiceFlow::Direction dir) const; - - private: - std::vector* m_serviceFlows; ///< the service flows -}; - -} // namespace ns3 - -#endif /* SERVICE_FLOW_MANAGER_H */ diff --git a/src/wimax/model/service-flow-record.cc b/src/wimax/model/service-flow-record.cc deleted file mode 100644 index c5bd8c979..000000000 --- a/src/wimax/model/service-flow-record.cc +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#include "service-flow-record.h" - -namespace ns3 -{ - -ServiceFlowRecord::ServiceFlowRecord() - : m_grantSize(0), - m_grantTimeStamp(), - m_dlTimeStamp(), - m_pktsSent(0), - m_pktsRcvd(0), - m_bytesSent(0), - m_bytesRcvd(0), - m_requestedBandwidth(0), - m_grantedBandwidth(0), - m_bwSinceLastExpiry(0) -{ - m_lastGrantTime = Seconds(0); - m_backlogged = 0; - m_backloggedTemp = 0; - m_grantedBandwidthTemp = 0; -} - -ServiceFlowRecord::~ServiceFlowRecord() -{ -} - -void -ServiceFlowRecord::SetGrantSize(uint32_t grantSize) -{ - m_grantSize = grantSize; -} - -uint32_t -ServiceFlowRecord::GetGrantSize() const -{ - return m_grantSize; -} - -void -ServiceFlowRecord::SetGrantTimeStamp(Time grantTimeStamp) -{ - m_grantTimeStamp = grantTimeStamp; -} - -Time -ServiceFlowRecord::GetGrantTimeStamp() const -{ - return m_grantTimeStamp; -} - -void -ServiceFlowRecord::SetDlTimeStamp(Time dlTimeStamp) -{ - m_dlTimeStamp = dlTimeStamp; -} - -Time -ServiceFlowRecord::GetDlTimeStamp() const -{ - return m_dlTimeStamp; -} - -void -ServiceFlowRecord::SetPktsSent(uint32_t pktsSent) -{ - m_pktsSent = pktsSent; -} - -void -ServiceFlowRecord::UpdatePktsSent(uint32_t pktsSent) -{ - m_pktsSent += pktsSent; -} - -uint32_t -ServiceFlowRecord::GetPktsSent() const -{ - return m_pktsSent; -} - -void -ServiceFlowRecord::SetPktsRcvd(uint32_t pktsRcvd) -{ - m_pktsRcvd = pktsRcvd; -} - -void -ServiceFlowRecord::UpdatePktsRcvd(uint32_t pktsRcvd) -{ - m_pktsRcvd += pktsRcvd; -} - -uint32_t -ServiceFlowRecord::GetPktsRcvd() const -{ - return m_pktsRcvd; -} - -void -ServiceFlowRecord::SetBytesSent(uint32_t bytesSent) -{ - m_bytesSent = bytesSent; -} - -void -ServiceFlowRecord::UpdateBytesSent(uint32_t bytesSent) -{ - m_bytesSent += bytesSent; -} - -uint32_t -ServiceFlowRecord::GetBytesSent() const -{ - return m_bytesSent; -} - -void -ServiceFlowRecord::SetBytesRcvd(uint32_t bytesRcvd) -{ - m_bytesRcvd = bytesRcvd; -} - -void -ServiceFlowRecord::UpdateBytesRcvd(uint32_t bytesRcvd) -{ - m_bytesRcvd += bytesRcvd; -} - -uint32_t -ServiceFlowRecord::GetBytesRcvd() const -{ - return m_bytesRcvd; -} - -void -ServiceFlowRecord::SetRequestedBandwidth(uint32_t requestedBandwidth) -{ - m_requestedBandwidth = requestedBandwidth; -} - -void -ServiceFlowRecord::UpdateRequestedBandwidth(uint32_t requestedBandwidth) -{ - m_requestedBandwidth += requestedBandwidth; -} - -uint32_t -ServiceFlowRecord::GetRequestedBandwidth() const -{ - return m_requestedBandwidth; -} - -void -ServiceFlowRecord::SetGrantedBandwidth(uint32_t grantedBandwidth) -{ - m_grantedBandwidth = grantedBandwidth; -} - -void -ServiceFlowRecord::UpdateGrantedBandwidth(uint32_t grantedBandwidth) -{ - m_grantedBandwidth += grantedBandwidth; -} - -uint32_t -ServiceFlowRecord::GetGrantedBandwidth() const -{ - return m_grantedBandwidth; -} - -void -ServiceFlowRecord::SetGrantedBandwidthTemp(uint32_t grantedBandwidthTemp) -{ - m_grantedBandwidthTemp = grantedBandwidthTemp; -} - -void -ServiceFlowRecord::UpdateGrantedBandwidthTemp(uint32_t grantedBandwidthTemp) -{ - m_grantedBandwidthTemp += grantedBandwidthTemp; -} - -uint32_t -ServiceFlowRecord::GetGrantedBandwidthTemp() const -{ - return m_grantedBandwidthTemp; -} - -void -ServiceFlowRecord::SetLastGrantTime(Time grantTime) -{ - m_lastGrantTime = grantTime; -} - -Time -ServiceFlowRecord::GetLastGrantTime() const -{ - return m_lastGrantTime; -} - -void -ServiceFlowRecord::SetBacklogged(uint32_t backlogged) -{ - m_backlogged = backlogged; -} - -void -ServiceFlowRecord::IncreaseBacklogged(uint32_t backlogged) -{ - m_backlogged += backlogged; -} - -uint32_t -ServiceFlowRecord::GetBacklogged() const -{ - return m_backlogged; -} - -void -ServiceFlowRecord::SetBackloggedTemp(uint32_t backloggedTemp) -{ - m_backloggedTemp = backloggedTemp; -} - -void -ServiceFlowRecord::IncreaseBackloggedTemp(uint32_t backloggedTemp) -{ - m_backloggedTemp += backloggedTemp; -} - -uint32_t -ServiceFlowRecord::GetBackloggedTemp() const -{ - return m_backloggedTemp; -} - -void -ServiceFlowRecord::SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry) -{ - m_bwSinceLastExpiry = bwSinceLastExpiry; -} - -void -ServiceFlowRecord::UpdateBwSinceLastExpiry(uint32_t bwSinceLastExpiry) -{ - m_bwSinceLastExpiry += bwSinceLastExpiry; -} - -uint32_t -ServiceFlowRecord::GetBwSinceLastExpiry() const -{ - return m_bwSinceLastExpiry; -} - -} // namespace ns3 diff --git a/src/wimax/model/service-flow-record.h b/src/wimax/model/service-flow-record.h deleted file mode 100644 index b6749a206..000000000 --- a/src/wimax/model/service-flow-record.h +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#ifndef SERVICE_FLOW_RECORD_H -#define SERVICE_FLOW_RECORD_H - -#include "bs-net-device.h" -#include "bs-uplink-scheduler.h" - -#include "ns3/nstime.h" -#include "ns3/ptr.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * @brief this class implements a structure to manage some parameters and statistics related to a - * service flow - */ -class ServiceFlowRecord -{ - public: - ServiceFlowRecord(); - ~ServiceFlowRecord(); - - /** - * @brief Set the grant size (only for UGS service flows) - * @param grantSize the grant size to set - */ - void SetGrantSize(uint32_t grantSize); - /** - * @return the grant size (only for ugs service flows) - */ - uint32_t GetGrantSize() const; - /** - * @brief Set the grant time stamp. Used for data allocation for ugs flows, and unicast poll - * (bw request) for non-UGS flows - * @param grantTimeStamp the grant time stamp to set - */ - void SetGrantTimeStamp(Time grantTimeStamp); - /** - * @return the grant time stamp. Used for data allocation for ugs flows, and unicast poll (bw - * request) for non-UGS flows - */ - Time GetGrantTimeStamp() const; - /** - * @brief Set the DlTimeStamp. - * @param dlTimeStamp time when this service flow's traffic was last sent. - */ - void SetDlTimeStamp(Time dlTimeStamp); - /** - * @return the DlTimeStamp: time when this service flow's traffic was last sent - */ - Time GetDlTimeStamp() const; - /** - * @brief set the number of sent packets in this service flow - * @param pktsSent the number of sent packets - */ - void SetPktsSent(uint32_t pktsSent); - /** - * @brief update the number of sent packets by adding pktsSent - * @param pktsSent the number of sent packets to add - */ - void UpdatePktsSent(uint32_t pktsSent); - /** - * @return the number of sent packet in this service flow - */ - uint32_t GetPktsSent() const; - /** - * @brief Set the number of received packets - * @param pktsRcvd The number of received packets - */ - void SetPktsRcvd(uint32_t pktsRcvd); - /** - * @brief update the number of received packets by adding pktsRcvd - * @param pktsRcvd the number of received packets to add - */ - void UpdatePktsRcvd(uint32_t pktsRcvd); - /** - * @return the number of received packet - */ - uint32_t GetPktsRcvd() const; - /** - * @brief Set the number of sent bytes - * @param bytesSent the number of sent bytes - */ - void SetBytesSent(uint32_t bytesSent); - /** - * @brief update the number of sent bytes by adding bytesSent - * @param bytesSent the number of bytes to add - */ - void UpdateBytesSent(uint32_t bytesSent); - /** - * @return The number of sent bytes - */ - uint32_t GetBytesSent() const; - /** - * @brief Set the number of received bytes - * @param bytesRcvd the number of received bytes - */ - void SetBytesRcvd(uint32_t bytesRcvd); - /** - * @brief update the number of received bytes by adding bytesRcvd - * @param bytesRcvd the number of bytes to add - */ - void UpdateBytesRcvd(uint32_t bytesRcvd); - /** - * @return The number of received bytes - */ - uint32_t GetBytesRcvd() const; - - /** - * @brief set the requested bandwidth - * @param requestedBandwidth the requested bandwidth - */ - void SetRequestedBandwidth(uint32_t requestedBandwidth); - /** - * @brief update the requested bandwidth - * @param requestedBandwidth the requested bandwidth update - */ - void UpdateRequestedBandwidth(uint32_t requestedBandwidth); - /** - * @return The requested bandwidth - */ - uint32_t GetRequestedBandwidth() const; - - /** - * @brief set the granted bandwidth - * @param grantedBandwidth the granted bandwidth - */ - void SetGrantedBandwidth(uint32_t grantedBandwidth); - /** - * @brief update the granted bandwidth - * @param grantedBandwidth the granted bandwidth update - */ - void UpdateGrantedBandwidth(uint32_t grantedBandwidth); - /** - * @return The granted bandwidth - */ - uint32_t GetGrantedBandwidth() const; - - /** - * @brief set the temporary granted bandwidth - * @param grantedBandwidthTemp the temporary granted bandwidth - */ - void SetGrantedBandwidthTemp(uint32_t grantedBandwidthTemp); - /** - * @brief update the temporary granted bandwidth - * @param grantedBandwidthTemp the temporary granted bandwidth - */ - void UpdateGrantedBandwidthTemp(uint32_t grantedBandwidthTemp); - /** - * @return The temporary granted bandwidth - */ - uint32_t GetGrantedBandwidthTemp() const; - - /** - * @brief set BW since last expiry - * @param bwSinceLastExpiry bandwidth since last expiry - */ - void SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry); - /** - * @brief update BW since last expiry - * @param bwSinceLastExpiry bandwidth since last expiry - */ - void UpdateBwSinceLastExpiry(uint32_t bwSinceLastExpiry); - /** - * @return The bandwidth since last expiry - */ - uint32_t GetBwSinceLastExpiry() const; - - /** - * @brief set last grant time - * @param grantTime grant time to set - */ - void SetLastGrantTime(Time grantTime); - /** - * @return The last grant time - */ - Time GetLastGrantTime() const; - - /** - * @brief set backlogged - * @param backlogged number of backlogged - */ - void SetBacklogged(uint32_t backlogged); - /** - * @brief increase backlogged - * @param backlogged the number of backlogged to update - */ - void IncreaseBacklogged(uint32_t backlogged); - /** - * @return The number of backlogged - */ - uint32_t GetBacklogged() const; - - /** - * @brief set temporary back logged - * @param backloggedTemp the temporary backlogged value - */ - void SetBackloggedTemp(uint32_t backloggedTemp); - /** - * @brief increase temporary back logged - * @param backloggedTemp the temporary backlogged value - */ - void IncreaseBackloggedTemp(uint32_t backloggedTemp); - /** - * @return The value of temporary backlogged - */ - uint32_t GetBackloggedTemp() const; - - private: - uint32_t m_grantSize; ///< only used for UGS flow - Time m_grantTimeStamp; ///< allocation (for data) for UGS flows and unicast poll (for bandwidth - ///< requests) for non-UGS flows - Time m_dlTimeStamp; ///< time when this service flow's traffic was last sent - - // stats members - uint32_t m_pktsSent; ///< packets sent - uint32_t m_pktsRcvd; ///< packets received - - uint32_t m_bytesSent; ///< bytes sent - uint32_t m_bytesRcvd; ///< bytes received - - uint32_t m_requestedBandwidth; ///< requested bandwidth - uint32_t m_grantedBandwidth; ///< granted badnwidth - uint32_t m_grantedBandwidthTemp; ///< Temporary variable used to sort list. Necessary to keep - ///< original order - - /** bandwidth granted since last expiry of minimum reserved traffic rate interval, - * only for nrtPS, to make sure minimum reserved traffic rate is maintained */ - uint32_t m_bwSinceLastExpiry; - Time m_lastGrantTime; ///< last grant time - int32_t m_backlogged; ///< back logged - int32_t m_backloggedTemp; ///< back logged temp -}; - -} // namespace ns3 - -#endif /* SERVICE_FLOW_RECORD_H */ diff --git a/src/wimax/model/service-flow.cc b/src/wimax/model/service-flow.cc deleted file mode 100644 index fa5b40987..000000000 --- a/src/wimax/model/service-flow.cc +++ /dev/null @@ -1,888 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "service-flow.h" - -#include "service-flow-record.h" -#include "wimax-tlv.h" - -#include "ns3/simulator.h" - -namespace ns3 -{ - -ServiceFlow::ServiceFlow(Direction direction) -{ - InitValues(); - m_direction = direction; - m_type = SF_TYPE_PROVISIONED; - m_record = new ServiceFlowRecord(); - m_sfid = 0; - m_connection = nullptr; - m_isEnabled = false; - m_isMulticast = false; - m_modulationType = WimaxPhy::MODULATION_TYPE_QPSK_12; -} - -ServiceFlow::ServiceFlow() - : m_sfid(0), - m_direction(SF_DIRECTION_DOWN), - m_type(SF_TYPE_PROVISIONED), - m_connection(nullptr), - m_isEnabled(false), - m_record(new ServiceFlowRecord()) -{ - InitValues(); - m_isMulticast = false; - m_modulationType = WimaxPhy::MODULATION_TYPE_QPSK_12; -} - -ServiceFlow::ServiceFlow(uint32_t sfid, Direction direction, Ptr connection) -{ - InitValues(); - m_record = new ServiceFlowRecord(); - m_isEnabled = false; - m_connection = connection; - m_connection->SetServiceFlow(this); - m_type = SF_TYPE_PROVISIONED; - m_direction = direction; - m_sfid = sfid; - m_isMulticast = false; - m_modulationType = WimaxPhy::MODULATION_TYPE_QPSK_12; -} - -ServiceFlow::ServiceFlow(Tlv tlv) -{ - InitValues(); - m_connection = nullptr; - m_isEnabled = false; - m_record = new ServiceFlowRecord(); - NS_ASSERT_MSG(tlv.GetType() == Tlv::UPLINK_SERVICE_FLOW || - tlv.GetType() == Tlv::DOWNLINK_SERVICE_FLOW, - "Invalid TLV"); - - SfVectorTlvValue* param; - param = (SfVectorTlvValue*)(tlv.PeekValue()); - - if (tlv.GetType() == Tlv::UPLINK_SERVICE_FLOW) - { - m_direction = SF_DIRECTION_UP; - } - else - { - m_direction = SF_DIRECTION_DOWN; - } - - for (auto iter = param->Begin(); iter != param->End(); ++iter) - { - switch ((*iter)->GetType()) - { - case SfVectorTlvValue::SFID: { - m_sfid = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case SfVectorTlvValue::CID: { - uint16_t cid = ((U16TlvValue*)((*iter)->PeekValue()))->GetValue(); - m_connection = CreateObject(cid, Cid::TRANSPORT); - break; - } - case SfVectorTlvValue::QoS_Parameter_Set_Type: { - m_qosParamSetType = ((U8TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case SfVectorTlvValue::Traffic_Priority: { - m_trafficPriority = ((U8TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case SfVectorTlvValue::Maximum_Sustained_Traffic_Rate: { - m_maxSustainedTrafficRate = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case SfVectorTlvValue::Maximum_Traffic_Burst: { - m_maxTrafficBurst = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case SfVectorTlvValue::Minimum_Reserved_Traffic_Rate: { - m_minReservedTrafficRate = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case SfVectorTlvValue::Minimum_Tolerable_Traffic_Rate: { - m_minTolerableTrafficRate = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case SfVectorTlvValue::Service_Flow_Scheduling_Type: { - m_schedulingType = - (ServiceFlow::SchedulingType)((U8TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case SfVectorTlvValue::Request_Transmission_Policy: { - m_requestTransmissionPolicy = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case SfVectorTlvValue::Tolerated_Jitter: { - m_toleratedJitter = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case SfVectorTlvValue::Maximum_Latency: { - m_maximumLatency = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case SfVectorTlvValue::Fixed_length_versus_Variable_length_SDU_Indicator: { - m_fixedversusVariableSduIndicator = ((U8TlvValue*)((*iter)->PeekValue()))->GetValue(); - break; - } - case SfVectorTlvValue::CS_Specification: { - m_csSpecification = - (CsSpecification)(((U8TlvValue*)((*iter)->PeekValue()))->GetValue()); - break; - } - - case SfVectorTlvValue::IPV4_CS_Parameters: { - m_convergenceSublayerParam = CsParameters(*(*iter)); - break; - } - } - } - m_isMulticast = false; - m_modulationType = WimaxPhy::MODULATION_TYPE_QPSK_12; -} - -ServiceFlow::~ServiceFlow() -{ - if (m_record != nullptr) - { - delete m_record; - m_record = nullptr; - } - m_connection = nullptr; -} - -void -ServiceFlow::SetDirection(Direction direction) -{ - m_direction = direction; -} - -ServiceFlow::Direction -ServiceFlow::GetDirection() const -{ - return m_direction; -} - -void -ServiceFlow::SetType(Type type) -{ - m_type = type; -} - -ServiceFlow::Type -ServiceFlow::GetType() const -{ - return m_type; -} - -void -ServiceFlow::SetConnection(Ptr connection) -{ - m_connection = connection; - m_connection->SetServiceFlow(this); -} - -Ptr -ServiceFlow::GetConnection() const -{ - return m_connection; -} - -void -ServiceFlow::SetIsEnabled(bool isEnabled) -{ - m_isEnabled = isEnabled; -} - -bool -ServiceFlow::GetIsEnabled() const -{ - return m_isEnabled; -} - -void -ServiceFlow::SetRecord(ServiceFlowRecord* record) -{ - m_record = record; -} - -ServiceFlowRecord* -ServiceFlow::GetRecord() const -{ - return m_record; -} - -Ptr -ServiceFlow::GetQueue() const -{ - if (!m_connection) - { - return nullptr; - } - return m_connection->GetQueue(); -} - -ServiceFlow::SchedulingType -ServiceFlow::GetSchedulingType() const -{ - return m_schedulingType; -} - -bool -ServiceFlow::HasPackets() const -{ - if (!m_connection) - { - return false; - } - return m_connection->HasPackets(); -} - -bool -ServiceFlow::HasPackets(MacHeaderType::HeaderType packetType) const -{ - if (!m_connection) - { - return false; - } - return m_connection->HasPackets(packetType); -} - -void -ServiceFlow::CleanUpQueue() -{ - GenericMacHeader hdr; - Time timeStamp; - Ptr packet; - Time currentTime = Simulator::Now(); - if (m_connection) - { - while (m_connection->HasPackets()) - { - packet = m_connection->GetQueue()->Peek(hdr, timeStamp); - - if (currentTime - timeStamp > MilliSeconds(GetMaximumLatency())) - { - m_connection->Dequeue(); - } - else - { - break; - } - } - } -} - -void -ServiceFlow::PrintQoSParameters() const -{ -} - -// ============================================================================== - -uint32_t -ServiceFlow::GetSfid() const -{ - return m_sfid; -} - -uint16_t -ServiceFlow::GetCid() const -{ - if (!m_connection) - { - return 0; - } - return m_connection->GetCid().GetIdentifier(); -} - -std::string -ServiceFlow::GetServiceClassName() const -{ - return m_serviceClassName; -} - -uint8_t -ServiceFlow::GetQosParamSetType() const -{ - return m_qosParamSetType; -} - -uint8_t -ServiceFlow::GetTrafficPriority() const -{ - return m_trafficPriority; -} - -uint32_t -ServiceFlow::GetMaxSustainedTrafficRate() const -{ - return m_maxSustainedTrafficRate; -} - -uint32_t -ServiceFlow::GetMaxTrafficBurst() const -{ - return m_maxTrafficBurst; -} - -uint32_t -ServiceFlow::GetMinReservedTrafficRate() const -{ - return m_minReservedTrafficRate; -} - -uint32_t -ServiceFlow::GetMinTolerableTrafficRate() const -{ - return m_minTolerableTrafficRate; -} - -ServiceFlow::SchedulingType -ServiceFlow::GetServiceSchedulingType() const -{ - return m_schedulingType; -} - -uint32_t -ServiceFlow::GetRequestTransmissionPolicy() const -{ - return m_requestTransmissionPolicy; -} - -uint32_t -ServiceFlow::GetToleratedJitter() const -{ - return m_toleratedJitter; -} - -uint32_t -ServiceFlow::GetMaximumLatency() const -{ - return m_maximumLatency; -} - -uint8_t -ServiceFlow::GetFixedversusVariableSduIndicator() const -{ - return m_fixedversusVariableSduIndicator; -} - -uint8_t -ServiceFlow::GetSduSize() const -{ - return m_sduSize; -} - -uint16_t -ServiceFlow::GetTargetSAID() const -{ - return m_targetSAID; -} - -uint8_t -ServiceFlow::GetArqEnable() const -{ - return m_arqEnable; -} - -uint16_t -ServiceFlow::GetArqWindowSize() const -{ - return m_arqWindowSize; -} - -uint16_t -ServiceFlow::GetArqRetryTimeoutTx() const -{ - return m_arqRetryTimeoutTx; -} - -uint16_t -ServiceFlow::GetArqRetryTimeoutRx() const -{ - return m_arqRetryTimeoutRx; -} - -uint16_t -ServiceFlow::GetArqBlockLifeTime() const -{ - return m_arqBlockLifeTime; -} - -uint16_t -ServiceFlow::GetArqSyncLoss() const -{ - return m_arqSyncLoss; -} - -uint8_t -ServiceFlow::GetArqDeliverInOrder() const -{ - return m_arqDeliverInOrder; -} - -uint16_t -ServiceFlow::GetArqPurgeTimeout() const -{ - return m_arqPurgeTimeout; -} - -uint16_t -ServiceFlow::GetArqBlockSize() const -{ - return m_arqBlockSize; -} - -ServiceFlow::CsSpecification -ServiceFlow::GetCsSpecification() const -{ - return m_csSpecification; -} - -CsParameters -ServiceFlow::GetConvergenceSublayerParam() const -{ - return m_convergenceSublayerParam; -} - -uint16_t -ServiceFlow::GetUnsolicitedGrantInterval() const -{ - return m_unsolicitedGrantInterval; -} - -uint16_t -ServiceFlow::GetUnsolicitedPollingInterval() const -{ - return m_unsolicitedPollingInterval; -} - -bool -ServiceFlow::GetIsMulticast() const -{ - return m_isMulticast; -} - -WimaxPhy::ModulationType -ServiceFlow::GetModulation() const -{ - return m_modulationType; -} - -// ============================================================================== - -void -ServiceFlow::SetSfid(uint32_t sfid) -{ - m_sfid = sfid; -} - -void -ServiceFlow::SetServiceClassName(std::string name) -{ - m_serviceClassName = name; -} - -void -ServiceFlow::SetQosParamSetType(uint8_t type) -{ - m_qosParamSetType = type; -} - -void -ServiceFlow::SetTrafficPriority(uint8_t priority) -{ - m_trafficPriority = priority; -} - -void -ServiceFlow::SetMaxSustainedTrafficRate(uint32_t maxSustainedRate) -{ - m_maxSustainedTrafficRate = maxSustainedRate; -} - -void -ServiceFlow::SetMaxTrafficBurst(uint32_t maxTrafficBurst) -{ - m_maxTrafficBurst = maxTrafficBurst; -} - -void -ServiceFlow::SetMinReservedTrafficRate(uint32_t minResvRate) -{ - m_minReservedTrafficRate = minResvRate; -} - -void -ServiceFlow::SetMinTolerableTrafficRate(uint32_t minJitter) -{ - m_minTolerableTrafficRate = minJitter; -} - -void -ServiceFlow::SetServiceSchedulingType(ServiceFlow::SchedulingType schedType) -{ - m_schedulingType = schedType; -} - -void -ServiceFlow::SetRequestTransmissionPolicy(uint32_t policy) -{ - m_requestTransmissionPolicy = policy; -} - -void -ServiceFlow::SetToleratedJitter(uint32_t jitter) -{ - m_toleratedJitter = jitter; -} - -void -ServiceFlow::SetMaximumLatency(uint32_t MaximumLatency) -{ - m_maximumLatency = MaximumLatency; -} - -void -ServiceFlow::SetFixedversusVariableSduIndicator(uint8_t sduIndicator) -{ - m_fixedversusVariableSduIndicator = sduIndicator; -} - -void -ServiceFlow::SetSduSize(uint8_t sduSize) -{ - m_sduSize = sduSize; -} - -void -ServiceFlow::SetTargetSAID(uint16_t targetSaid) -{ - m_targetSAID = targetSaid; -} - -void -ServiceFlow::SetArqEnable(uint8_t arqEnable) -{ - m_arqEnable = arqEnable; -} - -void -ServiceFlow::SetArqWindowSize(uint16_t arqWindowSize) -{ - m_arqWindowSize = arqWindowSize; -} - -void -ServiceFlow::SetArqRetryTimeoutTx(uint16_t timeout) -{ - m_arqRetryTimeoutTx = timeout; -} - -void -ServiceFlow::SetArqRetryTimeoutRx(uint16_t timeout) -{ - m_arqRetryTimeoutRx = timeout; -} - -void -ServiceFlow::SetArqBlockLifeTime(uint16_t lifeTime) -{ - m_arqBlockLifeTime = lifeTime; -} - -void -ServiceFlow::SetArqSyncLoss(uint16_t syncLoss) -{ - m_arqSyncLoss = syncLoss; -} - -void -ServiceFlow::SetArqDeliverInOrder(uint8_t inOrder) -{ - m_arqDeliverInOrder = inOrder; -} - -void -ServiceFlow::SetArqPurgeTimeout(uint16_t timeout) -{ - m_arqPurgeTimeout = timeout; -} - -void -ServiceFlow::SetArqBlockSize(uint16_t size) -{ - m_arqBlockSize = size; -} - -void -ServiceFlow::SetCsSpecification(ServiceFlow::CsSpecification spec) -{ - m_csSpecification = spec; -} - -void -ServiceFlow::SetConvergenceSublayerParam(CsParameters csparam) -{ - m_convergenceSublayerParam = csparam; -} - -void -ServiceFlow::SetUnsolicitedGrantInterval(uint16_t unsolicitedGrantInterval) -{ - m_unsolicitedGrantInterval = unsolicitedGrantInterval; -} - -void -ServiceFlow::SetUnsolicitedPollingInterval(uint16_t unsolicitedPollingInterval) -{ - m_unsolicitedPollingInterval = unsolicitedPollingInterval; -} - -void -ServiceFlow::SetIsMulticast(bool isMulticast) -{ - m_isMulticast = isMulticast; -} - -void -ServiceFlow::SetModulation(WimaxPhy::ModulationType modulationType) -{ - m_modulationType = modulationType; -} - -void -ServiceFlow::InitValues() -{ - m_sfid = 0; - m_serviceClassName = ""; - m_qosParamSetType = 0; - m_trafficPriority = 0; - m_maxSustainedTrafficRate = 0; - m_maxTrafficBurst = 0; - m_minReservedTrafficRate = 0; - m_minTolerableTrafficRate = 0; - m_schedulingType = ServiceFlow::SF_TYPE_NONE; - m_requestTransmissionPolicy = 0; - m_toleratedJitter = 0; - m_maximumLatency = 0; - m_fixedversusVariableSduIndicator = 0; - m_sduSize = 0; - m_targetSAID = 0; - m_arqEnable = 0; - m_arqWindowSize = 0; - m_arqRetryTimeoutTx = 0; - m_arqRetryTimeoutRx = 0; - m_csSpecification = ServiceFlow::IPV4; - m_unsolicitedGrantInterval = 0; - m_unsolicitedPollingInterval = 0; - m_arqBlockLifeTime = 0; - m_arqSyncLoss = 0; - m_arqDeliverInOrder = 0; - m_arqPurgeTimeout = 0; - m_arqBlockSize = 0; - m_direction = ServiceFlow::SF_DIRECTION_DOWN; - m_type = ServiceFlow::SF_TYPE_ACTIVE; - m_isMulticast = false; - m_modulationType = WimaxPhy::MODULATION_TYPE_QPSK_12; -} - -void -ServiceFlow::CopyParametersFrom(ServiceFlow sf) -{ - m_serviceClassName = sf.GetServiceClassName(); - m_qosParamSetType = sf.GetQosParamSetType(); - m_trafficPriority = sf.GetTrafficPriority(); - m_maxSustainedTrafficRate = sf.GetMaxSustainedTrafficRate(); - m_maxTrafficBurst = sf.GetMaxTrafficBurst(); - m_minReservedTrafficRate = sf.GetMinReservedTrafficRate(); - m_minTolerableTrafficRate = sf.GetMinTolerableTrafficRate(); - m_schedulingType = sf.GetServiceSchedulingType(); - m_requestTransmissionPolicy = sf.GetRequestTransmissionPolicy(); - m_toleratedJitter = sf.GetToleratedJitter(); - m_maximumLatency = sf.GetMaximumLatency(); - m_fixedversusVariableSduIndicator = sf.GetFixedversusVariableSduIndicator(); - m_sduSize = sf.GetSduSize(); - m_targetSAID = sf.GetTargetSAID(); - m_arqEnable = sf.GetArqEnable(); - m_arqWindowSize = sf.GetArqWindowSize(); - m_arqRetryTimeoutTx = sf.GetArqRetryTimeoutTx(); - m_arqRetryTimeoutRx = sf.GetArqRetryTimeoutRx(); - m_csSpecification = sf.GetCsSpecification(); - m_convergenceSublayerParam = sf.GetConvergenceSublayerParam(); - m_unsolicitedGrantInterval = sf.GetUnsolicitedGrantInterval(); - m_unsolicitedPollingInterval = sf.GetUnsolicitedPollingInterval(); - m_direction = sf.GetDirection(); - m_isMulticast = sf.GetIsMulticast(); - m_modulationType = sf.GetModulation(); -} - -ServiceFlow::ServiceFlow(const ServiceFlow& sf) -{ - m_sfid = sf.GetSfid(); - m_serviceClassName = sf.GetServiceClassName(); - m_qosParamSetType = sf.GetQosParamSetType(); - m_trafficPriority = sf.GetTrafficPriority(); - m_maxSustainedTrafficRate = sf.GetMaxSustainedTrafficRate(); - m_maxTrafficBurst = sf.GetMaxTrafficBurst(); - m_minReservedTrafficRate = sf.GetMinReservedTrafficRate(); - m_minTolerableTrafficRate = sf.GetMinTolerableTrafficRate(); - m_schedulingType = sf.GetServiceSchedulingType(); - m_requestTransmissionPolicy = sf.GetRequestTransmissionPolicy(); - m_toleratedJitter = sf.GetToleratedJitter(); - m_maximumLatency = sf.GetMaximumLatency(); - m_fixedversusVariableSduIndicator = sf.GetFixedversusVariableSduIndicator(); - m_sduSize = sf.GetSduSize(); - m_targetSAID = sf.GetTargetSAID(); - m_arqEnable = sf.GetArqEnable(); - m_arqWindowSize = sf.GetArqWindowSize(); - m_arqRetryTimeoutTx = sf.GetArqRetryTimeoutTx(); - m_arqRetryTimeoutRx = sf.GetArqRetryTimeoutRx(); - m_csSpecification = sf.GetCsSpecification(); - m_convergenceSublayerParam = sf.GetConvergenceSublayerParam(); - m_unsolicitedGrantInterval = sf.GetUnsolicitedGrantInterval(); - m_unsolicitedPollingInterval = sf.GetUnsolicitedPollingInterval(); - m_direction = sf.GetDirection(); - m_type = sf.GetType(); - m_connection = sf.GetConnection(); - m_isEnabled = sf.GetIsEnabled(); - m_record = new ServiceFlowRecord(); - (*m_record) = (*sf.GetRecord()); - m_isMulticast = sf.GetIsMulticast(); - m_modulationType = sf.GetModulation(); -} - -ServiceFlow& -ServiceFlow::operator=(const ServiceFlow& o) -{ - m_sfid = o.GetSfid(); - m_serviceClassName = o.GetServiceClassName(); - m_qosParamSetType = o.GetQosParamSetType(); - m_trafficPriority = o.GetTrafficPriority(); - m_maxSustainedTrafficRate = o.GetMaxSustainedTrafficRate(); - m_maxTrafficBurst = o.GetMaxTrafficBurst(); - m_minReservedTrafficRate = o.GetMinReservedTrafficRate(); - m_minTolerableTrafficRate = o.GetMinTolerableTrafficRate(); - m_schedulingType = o.GetServiceSchedulingType(); - m_requestTransmissionPolicy = o.GetRequestTransmissionPolicy(); - m_toleratedJitter = o.GetToleratedJitter(); - m_maximumLatency = o.GetMaximumLatency(); - m_fixedversusVariableSduIndicator = o.GetFixedversusVariableSduIndicator(); - m_sduSize = o.GetSduSize(); - m_targetSAID = o.GetTargetSAID(); - m_arqEnable = o.GetArqEnable(); - m_arqWindowSize = o.GetArqWindowSize(); - m_arqRetryTimeoutTx = o.GetArqRetryTimeoutTx(); - m_arqRetryTimeoutRx = o.GetArqRetryTimeoutRx(); - m_csSpecification = o.GetCsSpecification(); - m_convergenceSublayerParam = o.GetConvergenceSublayerParam(); - m_unsolicitedGrantInterval = o.GetUnsolicitedGrantInterval(); - m_unsolicitedPollingInterval = o.GetUnsolicitedPollingInterval(); - m_direction = o.GetDirection(); - m_type = o.GetType(); - m_connection = o.GetConnection(); - m_isEnabled = o.GetIsEnabled(); - m_isMulticast = o.GetIsMulticast(); - m_modulationType = o.GetModulation(); - if (m_record != nullptr) - { - delete m_record; - } - - m_record = new ServiceFlowRecord(); - - (*m_record) = (*o.GetRecord()); - return *this; -} - -char* -ServiceFlow::GetSchedulingTypeStr() const -{ - switch (m_schedulingType) - { - case SF_TYPE_UGS: - return (char*)"UGS"; - case SF_TYPE_RTPS: - return (char*)"rtPS"; - case SF_TYPE_NRTPS: - return (char*)"nrtPS"; - case SF_TYPE_BE: - return (char*)"BE"; - default: - NS_FATAL_ERROR("Invalid scheduling type"); - } - return nullptr; -} - -Tlv -ServiceFlow::ToTlv() const -{ - SfVectorTlvValue tmpSfVector; - tmpSfVector.Add(Tlv(SfVectorTlvValue::SFID, 4, U32TlvValue(m_sfid))); - tmpSfVector.Add(Tlv(SfVectorTlvValue::CID, 2, U16TlvValue(GetCid()))); - tmpSfVector.Add( - Tlv(SfVectorTlvValue::QoS_Parameter_Set_Type, 1, U8TlvValue(m_qosParamSetType))); - tmpSfVector.Add(Tlv(SfVectorTlvValue::Traffic_Priority, 1, U8TlvValue(m_trafficPriority))); - tmpSfVector.Add(Tlv(SfVectorTlvValue::Maximum_Sustained_Traffic_Rate, - 4, - U32TlvValue(m_maxSustainedTrafficRate))); - tmpSfVector.Add( - Tlv(SfVectorTlvValue::Maximum_Traffic_Burst, 4, U32TlvValue(m_maxTrafficBurst))); - tmpSfVector.Add(Tlv(SfVectorTlvValue::Minimum_Reserved_Traffic_Rate, - 4, - U32TlvValue(m_minReservedTrafficRate))); - tmpSfVector.Add(Tlv(SfVectorTlvValue::Minimum_Tolerable_Traffic_Rate, - 4, - U32TlvValue(m_minTolerableTrafficRate))); - tmpSfVector.Add( - Tlv(SfVectorTlvValue::Service_Flow_Scheduling_Type, 1, U8TlvValue(m_schedulingType))); - tmpSfVector.Add(Tlv(SfVectorTlvValue::Request_Transmission_Policy, - 4, - U32TlvValue(m_requestTransmissionPolicy))); - tmpSfVector.Add(Tlv(SfVectorTlvValue::Tolerated_Jitter, 4, U32TlvValue(m_toleratedJitter))); - tmpSfVector.Add(Tlv(SfVectorTlvValue::Maximum_Latency, 4, U32TlvValue(m_maximumLatency))); - tmpSfVector.Add(Tlv(SfVectorTlvValue::Fixed_length_versus_Variable_length_SDU_Indicator, - 1, - U8TlvValue(m_fixedversusVariableSduIndicator))); - tmpSfVector.Add(Tlv(SfVectorTlvValue::SDU_Size, 1, U8TlvValue(m_sduSize))); - tmpSfVector.Add(Tlv(SfVectorTlvValue::Target_SAID, 2, U16TlvValue(m_targetSAID))); - tmpSfVector.Add(Tlv(SfVectorTlvValue::CS_Specification, 1, U8TlvValue(m_csSpecification))); - tmpSfVector.Add(m_convergenceSublayerParam.ToTlv()); - if (m_direction == SF_DIRECTION_UP) - { - return Tlv(Tlv::UPLINK_SERVICE_FLOW, tmpSfVector.GetSerializedSize(), tmpSfVector); - } - else - { - return Tlv(Tlv::DOWNLINK_SERVICE_FLOW, tmpSfVector.GetSerializedSize(), tmpSfVector); - } -} - -bool -ServiceFlow::CheckClassifierMatch(Ipv4Address srcAddress, - Ipv4Address dstAddress, - uint16_t srcPort, - uint16_t dstPort, - uint8_t proto) const -{ - return m_convergenceSublayerParam.GetPacketClassifierRule().CheckMatch(srcAddress, - dstAddress, - srcPort, - dstPort, - proto); -} -} // namespace ns3 diff --git a/src/wimax/model/service-flow.h b/src/wimax/model/service-flow.h deleted file mode 100644 index a7e9b0dce..000000000 --- a/src/wimax/model/service-flow.h +++ /dev/null @@ -1,599 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - * Mohamed Amine Ismail - */ - -#ifndef SERVICE_FLOW_H -#define SERVICE_FLOW_H - -#include "cs-parameters.h" -#include "wimax-connection.h" -#include "wimax-mac-header.h" -#include "wimax-phy.h" - -#include - -namespace ns3 -{ - -class ServiceFlowRecord; -class WimaxConnection; -class WimaxMacQueue; - -/** - * @ingroup wimax - * This class implements service flows as described by the IEEE-802.16 standard - */ -class ServiceFlow -{ - public: - /// Direction enumeration - enum Direction - { - SF_DIRECTION_DOWN, - SF_DIRECTION_UP - }; - - /// Type enumeration - enum Type - { - SF_TYPE_PROVISIONED, - SF_TYPE_ADMITTED, - SF_TYPE_ACTIVE - }; - - /// section 11.13.11 Service flow scheduling type, page 701 - enum SchedulingType - { - SF_TYPE_NONE = 0, - SF_TYPE_UNDEF = 1, - SF_TYPE_BE = 2, - SF_TYPE_NRTPS = 3, - SF_TYPE_RTPS = 4, - SF_TYPE_UGS = 6, - SF_TYPE_ALL = 255 - }; - - /// section 11.13.19.2 CS parameter encoding rules, page 707 - enum CsSpecification - { - ATM = 99, - IPV4 = 100, - IPV6 = 101, - ETHERNET = 102, - VLAN = 103, - IPV4_OVER_ETHERNET = 104, - IPV6_OVER_ETHERNET = 105, - IPV4_OVER_VLAN = 106, - IPV6_OVER_VLAN = 107 - }; - - /// Modulation type enumeration, Table 356 and 362 - enum ModulationType - { - MODULATION_TYPE_BPSK_12, - MODULATION_TYPE_QPSK_12, - MODULATION_TYPE_QPSK_34, - MODULATION_TYPE_QAM16_12, - MODULATION_TYPE_QAM16_34, - MODULATION_TYPE_QAM64_23, - MODULATION_TYPE_QAM64_34 - }; - - /** - * @brief creates a TLV from this service flow - * @return the created tlv - */ - Tlv ToTlv() const; - /** - * @brief creates a service flow from a TLV - * @param tlv the tlv from which the service flow will be created - */ - ServiceFlow(Tlv tlv); - /** - * @brief check classifier match. - * @param srcAddress the source ip address - * @param dstAddress the destination ip address - * @param srcPort the source port - * @param dstPort the destination port - * @param proto the layer 4 protocol - * @return true if the passed parameters match the classifier of the service flow, false - * otherwise - */ - bool CheckClassifierMatch(Ipv4Address srcAddress, - Ipv4Address dstAddress, - uint16_t srcPort, - uint16_t dstPort, - uint8_t proto) const; - /** - * Default constructor. - */ - ServiceFlow(); - /** - * Constructor - * - * @param direction the direction - */ - ServiceFlow(Direction direction); - /** - * Constructor - * - * @param sf service flow - */ - ServiceFlow(const ServiceFlow& sf); - /** - * Constructor - * - * @param sfid the SFID - * @param direction the direction - * @param connection the connection object - */ - ServiceFlow(uint32_t sfid, Direction direction, Ptr connection); - /** - * Destructor. - */ - ~ServiceFlow(); - /** - * assignment operator - * @param o the service flow to assign - * @returns the service flow - */ - ServiceFlow& operator=(const ServiceFlow& o); - - /** - * Initialize values. - */ - void InitValues(); - /** - * Set direction - * @param direction the direction value - */ - void SetDirection(Direction direction); - /** - * Get direction - * @returns the direction - */ - Direction GetDirection() const; - /** - * Copy parameters from another service flow - * @param sf the service flow - */ - void CopyParametersFrom(ServiceFlow sf); - - /** - * Set type of service flow - * @param type the type value - */ - void SetType(Type type); - /** - * Get type of service flow - * @returns the type - */ - Type GetType() const; - /** - * Set connection - * @param connection the connection - */ - void SetConnection(Ptr connection); - /** - * Can return a null connection is this service flow has not - * been associated yet to a connection. - * @returns pointer to the WimaxConnection - */ - Ptr GetConnection() const; - - /** - * Set is enabled flag - * @param isEnabled is enabled flag - */ - void SetIsEnabled(bool isEnabled); - /** - * Get is enabled flag - * @returns is enabled - */ - bool GetIsEnabled() const; - - /** - * Set service flow record - * @param record pointer to the service flow record - */ - void SetRecord(ServiceFlowRecord* record); - /** - * Get service flow record - * @returns pointer to the service flow record - */ - ServiceFlowRecord* GetRecord() const; - - // wrapper functions - /** - * Get pointer to queue - * @returns pointer to the wimax mac queue - */ - Ptr GetQueue() const; - /** - * Get scheduling type - * @returns the scheduling type - */ - ServiceFlow::SchedulingType GetSchedulingType() const; - /** - * Check if packets are present - * @returns true if there are packets - */ - bool HasPackets() const; - /** - * Check if packets of particular type are present - * @param packetType the packet type to select - * @returns true if there are packets of the packet type - */ - bool HasPackets(MacHeaderType::HeaderType packetType) const; - - /** - * Shall be called only by BS. - */ - void CleanUpQueue(); - - /** - * Print QoS parameters. - */ - void PrintQoSParameters() const; - - /** - * Get scheduling type string - * @returns the name of the scheduling type - */ - char* GetSchedulingTypeStr() const; - - /** - * Get SFID - * @returns the SFID - */ - uint32_t GetSfid() const; - /** - * Get CID - * @returns the CID - */ - uint16_t GetCid() const; - /** - * Get service class name - * @returns the service class name - */ - std::string GetServiceClassName() const; - /** - * Get QOS parameter set type - * @returns the QOS parameter set type - */ - uint8_t GetQosParamSetType() const; - /** - * Get traffic priority - * @returns the traffic priority - */ - uint8_t GetTrafficPriority() const; - /** - * Get max sustained traffic rate - * @returns the maximum sustained traffic rate - */ - uint32_t GetMaxSustainedTrafficRate() const; - /** - * Get max traffic burst - * @returns the maximum traffic burst - */ - uint32_t GetMaxTrafficBurst() const; - /** - * Get minimum reserved traffic rate - * @returns the minimum reserved traffic rate - */ - uint32_t GetMinReservedTrafficRate() const; - /** - * Get minimum tolerable traffic rate - * @returns the minimum tolerable traffic rate - */ - uint32_t GetMinTolerableTrafficRate() const; - /** - * Get service scheduling type - * @returns the scheduling type - */ - ServiceFlow::SchedulingType GetServiceSchedulingType() const; - /** - * Get request transmission policy - * @returns the request transmission policy - */ - uint32_t GetRequestTransmissionPolicy() const; - /** - * Get tolerated jitter - * @returns the tolerated jitter - */ - uint32_t GetToleratedJitter() const; - /** - * Get maximum latency - * @returns the maximum latency - */ - uint32_t GetMaximumLatency() const; - /** - * Get fixed versus variable SDU indicator - * @returns the fixed vs variable SDU indicator - */ - uint8_t GetFixedversusVariableSduIndicator() const; - /** - * Get SDU size - * @returns the SDU size - */ - uint8_t GetSduSize() const; - /** - * Get target SAID - * @returns the target SAID - */ - uint16_t GetTargetSAID() const; - /** - * Get ARQ enable - * @returns the ARQ enable - */ - uint8_t GetArqEnable() const; - /** - * Get ARQ retry timeout transmit - * @returns the ARQ retry timeout - */ - uint16_t GetArqWindowSize() const; - /** - * Get ARQ retry timeout transmit - * @returns the ARQ retry timeout transmit - */ - uint16_t GetArqRetryTimeoutTx() const; - /** - * Get ARQ retry timeout receive - * @returns the ARQ retry timeout receive - */ - uint16_t GetArqRetryTimeoutRx() const; - /** - * Get ARQ block lifetime - * @returns the ARQ block lifetime - */ - uint16_t GetArqBlockLifeTime() const; - /** - * Get ARQ sync loss - * @returns the ARQ sync loss value - */ - uint16_t GetArqSyncLoss() const; - /** - * Get ARQ deliver in order - * @returns the ARQ deliver in order - */ - uint8_t GetArqDeliverInOrder() const; - /** - * Get ARQ purge timeout - * @returns the ARQ purge timeout value - */ - uint16_t GetArqPurgeTimeout() const; - /** - * Get ARQ block size - * @returns the ARQ block size - */ - uint16_t GetArqBlockSize() const; - /** - * Get CS specification - * @returns the CS specification - */ - CsSpecification GetCsSpecification() const; - /** - * Get convergence sublayer - * @returns the convergence sublayer - */ - CsParameters GetConvergenceSublayerParam() const; - /** - * Get unsolicited grant interval - * @returns the unsolicited grant interval - */ - uint16_t GetUnsolicitedGrantInterval() const; - /** - * Get unsolicited polling interval - * @returns the unsolicited polling interval - */ - uint16_t GetUnsolicitedPollingInterval() const; - /** - * Get is multicast - * @returns the is multicast flag - */ - bool GetIsMulticast() const; - /** - * Get modulation - * @returns the modulation - */ - WimaxPhy::ModulationType GetModulation() const; - - /** - * Set SFID - * @param sfid the SFID - */ - void SetSfid(uint32_t sfid); - /** - * Set service class name - * @param name the service class name - */ - void SetServiceClassName(std::string name); - /** - * Set QOS parameter set type - * @param type the QOS parameter set type - */ - void SetQosParamSetType(uint8_t type); - /** - * Set traffic priority - * @param priority the traffic priority - */ - void SetTrafficPriority(uint8_t priority); - /** - * Set max sustained traffic rate - * @param maxSustainedRate the maximum sustained traffic rate - */ - void SetMaxSustainedTrafficRate(uint32_t maxSustainedRate); - /** - * Set maximum traffic burst - * @param maxTrafficBurst the maximum traffic burst - */ - void SetMaxTrafficBurst(uint32_t maxTrafficBurst); - /** - * Set minimum reserved traffic rate - * @param minResvRate the minimum reserved traffic rate - */ - void SetMinReservedTrafficRate(uint32_t minResvRate); - /** - * Set minimum tolerable traffic rate - * @param minJitter the minimum tolerable traffic rate - */ - void SetMinTolerableTrafficRate(uint32_t minJitter); - /** - * Set service scheduling type - * @param schedType the service scheduling type - */ - void SetServiceSchedulingType(ServiceFlow::SchedulingType schedType); - /** - * Set request transmission policy - * @param policy the request transmission policy - */ - void SetRequestTransmissionPolicy(uint32_t policy); - /** - * Set tolerated jitter - * @param jitter the tolerated jitter - */ - void SetToleratedJitter(uint32_t jitter); - /** - * Set maximum latency - * @param MaximumLatency the maximum latency - */ - void SetMaximumLatency(uint32_t MaximumLatency); - /** - * Set fixed versus variable SDU indicator - * @param sduIndicator fixed vs variable SDU indicator - */ - void SetFixedversusVariableSduIndicator(uint8_t sduIndicator); - /** - * Set SDU size - * @param sduSize the SDU size - */ - void SetSduSize(uint8_t sduSize); - /** - * Set target SAID - * @param targetSaid the target SAID value - */ - void SetTargetSAID(uint16_t targetSaid); - /** - * Set ARQ enable - * @param arqEnable the ARQ enable setting - */ - void SetArqEnable(uint8_t arqEnable); - /** - * Set ARQ retry timeout transmit - * @param arqWindowSize the ARQ retry timeout transmit - */ - void SetArqWindowSize(uint16_t arqWindowSize); - /** - * Set ARQ retry timeout transmit - * @param timeout the ARQ retry timeout transmit - */ - void SetArqRetryTimeoutTx(uint16_t timeout); - /** - * Set ARQ retry timeout receive - * @param timeout the timeout - */ - void SetArqRetryTimeoutRx(uint16_t timeout); - /** - * Set ARQ block lifetime - * @param lifeTime the ARQ block life time - */ - void SetArqBlockLifeTime(uint16_t lifeTime); - /** - * Set ARQ sync loss - * @param syncLoss the ARQ sync loss - */ - void SetArqSyncLoss(uint16_t syncLoss); - /** - * Set ARQ deliver in order - * @param inOrder the deliver in order setting - */ - void SetArqDeliverInOrder(uint8_t inOrder); - /** - * Set ARQ purge timeout - * @param timeout the timeout value - */ - void SetArqPurgeTimeout(uint16_t timeout); - /** - * Set ARQ block size - * @param size the size - */ - void SetArqBlockSize(uint16_t size); - /** - * Set CS specification - * @param spec the CS specification - */ - void SetCsSpecification(CsSpecification spec); - /** - * Set convergence sublayer parameters - * @param csparam the convergence sublayer parameters - */ - void SetConvergenceSublayerParam(CsParameters csparam); - - /** - * Set unsolicited grant interval - * @param unsolicitedGrantInterval the unsolicited grant interval - */ - void SetUnsolicitedGrantInterval(uint16_t unsolicitedGrantInterval); - /** - * Set unsolicited polling interval - * @param unsolicitedPollingInterval the unsolicited polling interval - */ - void SetUnsolicitedPollingInterval(uint16_t unsolicitedPollingInterval); - /** - * Set is multicast - * @param isMulticast the is multicast flag - */ - void SetIsMulticast(bool isMulticast); - /** - * Set modulation - * @param modulationType the modulation type - */ - void SetModulation(WimaxPhy::ModulationType modulationType); - - private: - uint32_t m_sfid; ///< SFID - std::string m_serviceClassName; ///< service class name - uint8_t m_qosParamSetType; ///< QOS parameter type - uint8_t m_trafficPriority; ///< traffic priority - uint32_t m_maxSustainedTrafficRate; ///< maximum sustained traffic rate - uint32_t m_maxTrafficBurst; ///< maximum traffic burst - uint32_t m_minReservedTrafficRate; ///< minimum reserved traffic rate - uint32_t m_minTolerableTrafficRate; ///< minimum tolerable traffic rate - ServiceFlow::SchedulingType m_schedulingType; ///< scheduling type - uint32_t m_requestTransmissionPolicy; ///< request transmission policy - uint32_t m_toleratedJitter; ///< tolerated jitter - uint32_t m_maximumLatency; ///< maximum latency - uint8_t m_fixedversusVariableSduIndicator; ///< fixed versus variable SDI indicator - uint8_t m_sduSize; ///< SDU size - uint16_t m_targetSAID; ///< target SAID - uint8_t m_arqEnable; ///< ARQ enable - uint16_t m_arqWindowSize; ///< ARQ window size - uint16_t m_arqRetryTimeoutTx; ///< ARQ retry timeout transmit - uint16_t m_arqRetryTimeoutRx; ///< ARQ retry timeout receive - uint16_t m_arqBlockLifeTime; ///< ARQ block life time - uint16_t m_arqSyncLoss; ///< ARQ sync loss - uint8_t m_arqDeliverInOrder; ///< ARQ deliver in order - uint16_t m_arqPurgeTimeout; ///< ARQ purge timeout - uint16_t m_arqBlockSize; ///< ARQ block size - CsSpecification m_csSpecification; ///< CS specification - CsParameters m_convergenceSublayerParam; ///< convergence sublayer parameters - uint16_t m_unsolicitedGrantInterval; ///< unsolicited grant interval - uint16_t m_unsolicitedPollingInterval; ///< unsolicited polling interval - Direction m_direction; ///< direction - Type m_type; ///< type - Ptr m_connection; ///< connection - bool m_isEnabled; ///< is enabled? - bool m_isMulticast; ///< is multicast? - WimaxPhy::ModulationType m_modulationType; ///< modulation type - // will be used by the BS - ServiceFlowRecord* m_record; ///< service flow record -}; - -} // namespace ns3 - -#endif /* SERVICE_FLOW_H */ diff --git a/src/wimax/model/simple-ofdm-send-param.cc b/src/wimax/model/simple-ofdm-send-param.cc deleted file mode 100644 index a81b7853a..000000000 --- a/src/wimax/model/simple-ofdm-send-param.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -#include "simple-ofdm-send-param.h" - -#include "simple-ofdm-wimax-channel.h" -#include "simple-ofdm-wimax-phy.h" - -namespace ns3 -{ -SimpleOfdmSendParam::SimpleOfdmSendParam() -{ - // m_fecBlock = 0; - m_burstSize = 0; - m_isFirstBlock = false; - m_frequency = 0; - m_modulationType = WimaxPhy::MODULATION_TYPE_QPSK_12; - m_direction = 0; - m_rxPowerDbm = 0; -} - -SimpleOfdmSendParam::SimpleOfdmSendParam(const Bvec& fecBlock, - uint32_t burstSize, - bool isFirstBlock, - uint64_t Frequency, - WimaxPhy::ModulationType modulationType, - uint8_t direction, - double rxPowerDbm) -{ - m_fecBlock = fecBlock; - m_burstSize = burstSize; - m_isFirstBlock = isFirstBlock; - m_frequency = Frequency; - m_modulationType = modulationType; - m_direction = direction; - m_rxPowerDbm = rxPowerDbm; -} - -SimpleOfdmSendParam::SimpleOfdmSendParam(uint32_t burstSize, - bool isFirstBlock, - uint64_t Frequency, - WimaxPhy::ModulationType modulationType, - uint8_t direction, - double rxPowerDbm, - Ptr burst) -{ - m_burstSize = burstSize; - m_isFirstBlock = isFirstBlock; - m_frequency = Frequency; - m_modulationType = modulationType; - m_direction = direction; - m_rxPowerDbm = rxPowerDbm; - m_burst = burst; -} - -SimpleOfdmSendParam::~SimpleOfdmSendParam() -{ -} - -void -SimpleOfdmSendParam::SetFecBlock(const Bvec& fecBlock) -{ - m_fecBlock = fecBlock; -} - -void -SimpleOfdmSendParam::SetBurstSize(uint32_t burstSize) -{ - m_burstSize = burstSize; -} - -void -SimpleOfdmSendParam::SetIsFirstBlock(bool isFirstBlock) -{ - m_isFirstBlock = isFirstBlock; -} - -void -SimpleOfdmSendParam::SetFrequency(uint64_t Frequency) -{ - m_frequency = Frequency; -} - -void -SimpleOfdmSendParam::SetModulationType(WimaxPhy::ModulationType modulationType) -{ - m_modulationType = modulationType; -} - -void -SimpleOfdmSendParam::SetDirection(uint8_t direction) -{ - m_direction = direction; -} - -void -SimpleOfdmSendParam::SetRxPowerDbm(double rxPowerDbm) -{ - m_rxPowerDbm = rxPowerDbm; -} - -Bvec -SimpleOfdmSendParam::GetFecBlock() -{ - return m_fecBlock; -} - -uint32_t -SimpleOfdmSendParam::GetBurstSize() const -{ - return m_burstSize; -} - -bool -SimpleOfdmSendParam::GetIsFirstBlock() const -{ - return m_isFirstBlock; -} - -uint64_t -SimpleOfdmSendParam::GetFrequency() const -{ - return m_frequency; -} - -WimaxPhy::ModulationType -SimpleOfdmSendParam::GetModulationType() -{ - return m_modulationType; -} - -uint8_t -SimpleOfdmSendParam::GetDirection() const -{ - return m_direction; -} - -double -SimpleOfdmSendParam::GetRxPowerDbm() const -{ - return m_rxPowerDbm; -} - -Ptr -SimpleOfdmSendParam::GetBurst() -{ - return m_burst; -} - -} // namespace ns3 diff --git a/src/wimax/model/simple-ofdm-send-param.h b/src/wimax/model/simple-ofdm-send-param.h deleted file mode 100644 index a19fc1c27..000000000 --- a/src/wimax/model/simple-ofdm-send-param.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -#ifndef SIMPLE_OFDM_SEND_PARAM_H -#define SIMPLE_OFDM_SEND_PARAM_H - -#include "bvec.h" -#include "wimax-channel.h" -#include "wimax-phy.h" - -#include "ns3/propagation-loss-model.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * SimpleOfdmSendParam class - */ -class SimpleOfdmSendParam -{ - public: - SimpleOfdmSendParam(); - /** - * Constructor - * - * @param fecBlock FEC block - * @param burstSize burst size - * @param isFirstBlock is the first block - * @param Frequency frequency - * @param modulationType modulation type - * @param direction the direction - * @param rxPowerDbm receive power - */ - SimpleOfdmSendParam(const Bvec& fecBlock, - uint32_t burstSize, - bool isFirstBlock, - uint64_t Frequency, - WimaxPhy::ModulationType modulationType, - uint8_t direction, - double rxPowerDbm); - /** - * Constructor - * - * @param burstSize burst size - * @param isFirstBlock is the first block - * @param Frequency frequency - * @param modulationType modulation type - * @param direction the direction - * @param rxPowerDbm receive power - * @param burst packet burst object - */ - SimpleOfdmSendParam(uint32_t burstSize, - bool isFirstBlock, - uint64_t Frequency, - WimaxPhy::ModulationType modulationType, - uint8_t direction, - double rxPowerDbm, - Ptr burst); - ~SimpleOfdmSendParam(); - /** - * @brief sent the fec block to send - * @param fecBlock the fec block to send - */ - void SetFecBlock(const Bvec& fecBlock); - /** - * @brief set the burst size - * @param burstSize the burst size in bytes - */ - void SetBurstSize(uint32_t burstSize); - /** - * @param isFirstBlock Set to true if this fec block is the first one in the burst, set to false - * otherwise - */ - void SetIsFirstBlock(bool isFirstBlock); - /** - * @param Frequency set the frequency of the channel in which this fec block will be sent - */ - void SetFrequency(uint64_t Frequency); - /** - * @param modulationType the modulation type used to send this fec block - */ - void SetModulationType(WimaxPhy::ModulationType modulationType); - /** - * @param direction the direction on which this fec block will be sent - */ - void SetDirection(uint8_t direction); - /** - * @param rxPowerDbm the received power - */ - void SetRxPowerDbm(double rxPowerDbm); - /** - * @return the fec block - */ - Bvec GetFecBlock(); - /** - * @return the burst size - */ - uint32_t GetBurstSize() const; - /** - * @return true if this fec block is the first one in the burst, false otherwise - */ - bool GetIsFirstBlock() const; - /** - * @return the frequency on which the fec block is sent/received - */ - uint64_t GetFrequency() const; - /** - * @return the modulation type used to send this fec block - */ - WimaxPhy::ModulationType GetModulationType(); - /** - * @return the direction on which this fec block was sent. UP or DOWN - */ - uint8_t GetDirection() const; - /** - * @return the Received power - */ - double GetRxPowerDbm() const; - /** - * @return the received burst - */ - Ptr GetBurst(); - - private: - Bvec m_fecBlock; ///< FEC block - uint32_t m_burstSize; ///< burst size - bool m_isFirstBlock; ///< is first block - uint64_t m_frequency; ///< frequency - WimaxPhy::ModulationType m_modulationType; ///< modulation type - uint8_t m_direction; ///< direction - double m_rxPowerDbm; ///< receive power dbM - Ptr m_burst; ///< burst -}; -} // namespace ns3 - -#endif /* SIMPLE_OFDM_SEND_PARAM_H */ diff --git a/src/wimax/model/simple-ofdm-wimax-channel.cc b/src/wimax/model/simple-ofdm-wimax-channel.cc deleted file mode 100644 index 9bceb9447..000000000 --- a/src/wimax/model/simple-ofdm-wimax-channel.cc +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -#include "simple-ofdm-wimax-channel.h" - -#include "simple-ofdm-send-param.h" -#include "simple-ofdm-wimax-phy.h" -#include "wimax-phy.h" - -#include "ns3/assert.h" -#include "ns3/callback.h" -#include "ns3/cost231-propagation-loss-model.h" -#include "ns3/event-id.h" -#include "ns3/mobility-model.h" -#include "ns3/net-device.h" -#include "ns3/node.h" -#include "ns3/nstime.h" -#include "ns3/simulator.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("simpleOfdmWimaxChannel"); - -// NS_OBJECT_ENSURE_REGISTERED (simpleOfdmWimaxChannel); - -SimpleOfdmWimaxChannel::SimpleOfdmWimaxChannel() -{ - m_loss = nullptr; -} - -SimpleOfdmWimaxChannel::~SimpleOfdmWimaxChannel() -{ - m_phyList.clear(); -} - -/* static */ -TypeId -SimpleOfdmWimaxChannel::GetTypeId() -{ - static TypeId tid = TypeId("ns3::SimpleOfdmWimaxChannel") - .SetParent() - .SetGroupName("Wimax") - .AddConstructor(); - return tid; -} - -SimpleOfdmWimaxChannel::SimpleOfdmWimaxChannel(PropModel propModel) -{ - switch (propModel) - { - case RANDOM_PROPAGATION: - m_loss = CreateObject(); - break; - - case FRIIS_PROPAGATION: - m_loss = CreateObject(); - break; - case LOG_DISTANCE_PROPAGATION: - m_loss = CreateObject(); - break; - - case COST231_PROPAGATION: - m_loss = CreateObject(); - break; - - default: - m_loss = nullptr; - } -} - -void -SimpleOfdmWimaxChannel::SetPropagationModel(PropModel propModel) -{ - switch (propModel) - { - case RANDOM_PROPAGATION: - m_loss = CreateObject(); - break; - - case FRIIS_PROPAGATION: - m_loss = CreateObject(); - break; - case LOG_DISTANCE_PROPAGATION: - m_loss = CreateObject(); - break; - - case COST231_PROPAGATION: - m_loss = CreateObject(); - break; - - default: - m_loss = nullptr; - } -} - -void -SimpleOfdmWimaxChannel::DoAttach(Ptr phy) -{ - Ptr o_phy = phy->GetObject(); - m_phyList.push_back(o_phy); -} - -std::size_t -SimpleOfdmWimaxChannel::DoGetNDevices() const -{ - return m_phyList.size(); -} - -Ptr -SimpleOfdmWimaxChannel::DoGetDevice(std::size_t index) const -{ - std::size_t j = 0; - for (auto iter = m_phyList.begin(); iter != m_phyList.end(); ++iter) - { - if (j == index) - { - return (*iter)->GetDevice(); - } - j++; - } - - NS_FATAL_ERROR("Unable to get device"); - return nullptr; -} - -void -SimpleOfdmWimaxChannel::Send(Time BlockTime, - uint32_t burstSize, - Ptr phy, - bool isFirstBlock, - bool isLastBlock, - uint64_t frequency, - WimaxPhy::ModulationType modulationType, - uint8_t direction, - double txPowerDbm, - Ptr burst) -{ - double rxPowerDbm = 0; - Ptr senderMobility = nullptr; - Ptr receiverMobility = nullptr; - senderMobility = phy->GetDevice()->GetNode()->GetObject(); - SimpleOfdmSendParam* param; - for (auto iter = m_phyList.begin(); iter != m_phyList.end(); ++iter) - { - Time delay; - if (phy != *iter) - { - double distance = 0; - receiverMobility = (*iter)->GetDevice()->GetNode()->GetObject(); - if (receiverMobility && senderMobility && m_loss) - { - distance = senderMobility->GetDistanceFrom(receiverMobility); - delay = Seconds(distance / 300000000.0); - rxPowerDbm = m_loss->CalcRxPower(txPowerDbm, senderMobility, receiverMobility); - } - - param = new SimpleOfdmSendParam(burstSize, - isFirstBlock, - frequency, - modulationType, - direction, - rxPowerDbm, - burst); - Ptr dstNetDevice = (*iter)->GetDevice(); - uint32_t dstNode; - if (!dstNetDevice) - { - dstNode = 0xffffffff; - } - else - { - dstNode = dstNetDevice->GetObject()->GetNode()->GetId(); - } - Simulator::ScheduleWithContext(dstNode, - delay, - &SimpleOfdmWimaxChannel::EndSendDummyBlock, - this, - *iter, - param); - } - } -} - -void -SimpleOfdmWimaxChannel::EndSendDummyBlock(Ptr rxphy, SimpleOfdmSendParam* param) -{ - rxphy->StartReceive(param->GetBurstSize(), - param->GetIsFirstBlock(), - param->GetFrequency(), - param->GetModulationType(), - param->GetDirection(), - param->GetRxPowerDbm(), - param->GetBurst()); - delete param; -} - -int64_t -SimpleOfdmWimaxChannel::AssignStreams(int64_t stream) -{ - int64_t currentStream = stream; - for (auto i = m_phyList.begin(); i != m_phyList.end(); i++) - { - Ptr simpleOfdm = (*i); - currentStream += simpleOfdm->AssignStreams(currentStream); - } - return (currentStream - stream); -} - -} // namespace ns3 - -// namespace ns3 diff --git a/src/wimax/model/simple-ofdm-wimax-channel.h b/src/wimax/model/simple-ofdm-wimax-channel.h deleted file mode 100644 index 3f7e9469b..000000000 --- a/src/wimax/model/simple-ofdm-wimax-channel.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -#ifndef SIMPLE_OFDM_WIMAX_CHANNEL_H -#define SIMPLE_OFDM_WIMAX_CHANNEL_H - -#include "bvec.h" -#include "simple-ofdm-send-param.h" -#include "wimax-channel.h" -#include "wimax-phy.h" - -#include "ns3/propagation-loss-model.h" - -#include - -namespace ns3 -{ - -class Packet; -class PacketBurst; -class SimpleOfdmWimaxPhy; - -/** - * @ingroup wimax - * @brief SimpleOfdmWimaxChannel class - */ -class SimpleOfdmWimaxChannel : public WimaxChannel -{ - public: - SimpleOfdmWimaxChannel(); - ~SimpleOfdmWimaxChannel() override; - - /// PropModel enumeration - enum PropModel - { - RANDOM_PROPAGATION, - FRIIS_PROPAGATION, - LOG_DISTANCE_PROPAGATION, - COST231_PROPAGATION - }; - - /** - * Register this type. - * @return The TypeId. - */ - static TypeId GetTypeId(); - - /** - * @brief Creates a channel and sets the propagation model - * @param propModel the propagation model to use - */ - SimpleOfdmWimaxChannel(PropModel propModel); - - /** - * @brief Sends a dummy fec block to all connected physical devices - * @param BlockTime the time needed to send the block - * @param burstSize the size of the burst - * @param phy the sender device - * @param isFirstBlock true if this block is the first one, false otherwise - * @param isLastBlock true if this block is the last one, false otherwise - * @param frequency the frequency on which the block is sent - * @param modulationType the modulation used to send the fec block - * @param direction uplink or downlink - * @param txPowerDbm the transmission power - * @param burst the packet burst to send - */ - void Send(Time BlockTime, - uint32_t burstSize, - Ptr phy, - bool isFirstBlock, - bool isLastBlock, - uint64_t frequency, - WimaxPhy::ModulationType modulationType, - uint8_t direction, - double txPowerDbm, - Ptr burst); - /** - * @brief sets the propagation model - * @param propModel the propagation model to used - */ - void SetPropagationModel(PropModel propModel); - - /** - * Assign a fixed random variable stream number to the random variables - * used by this model. Return the number of streams (possibly zero) that - * have been assigned. - * - * @param stream first stream index to use - * @return the number of stream indices assigned by this model - */ - int64_t AssignStreams(int64_t stream) override; - - private: - /** - * Attach function - * @param phy the phy layer - */ - void DoAttach(Ptr phy) override; - std::list> m_phyList; ///< phy list - /** - * Get number of devices function - * @returns the number of devices - */ - std::size_t DoGetNDevices() const override; - /** - * End send dummy block function - * @param rxphy the Ptr - * @param param the SimpleOfdmSendParam * - */ - void EndSendDummyBlock(Ptr rxphy, SimpleOfdmSendParam* param); - /** - * Get device function - * @param i the device index - * @returns the device - */ - Ptr DoGetDevice(std::size_t i) const override; - Ptr m_loss; ///< loss -}; - -} // namespace ns3 - -#endif /* SIMPLE_OFDM_WIMAX_CHANNEL_H */ diff --git a/src/wimax/model/simple-ofdm-wimax-phy.cc b/src/wimax/model/simple-ofdm-wimax-phy.cc deleted file mode 100644 index 8bb4ca5f3..000000000 --- a/src/wimax/model/simple-ofdm-wimax-phy.cc +++ /dev/null @@ -1,1088 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -#include "simple-ofdm-wimax-phy.h" - -#include "simple-ofdm-wimax-channel.h" -#include "wimax-channel.h" -#include "wimax-mac-header.h" -#include "wimax-net-device.h" - -#include "ns3/double.h" -#include "ns3/node.h" -#include "ns3/packet-burst.h" -#include "ns3/packet.h" -#include "ns3/simulator.h" -#include "ns3/string.h" -#include "ns3/trace-source-accessor.h" -#include "ns3/uinteger.h" - -#include -#include -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("SimpleOfdmWimaxPhy"); - -NS_OBJECT_ENSURE_REGISTERED(SimpleOfdmWimaxPhy); - -TypeId -SimpleOfdmWimaxPhy::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::SimpleOfdmWimaxPhy") - .SetParent() - .SetGroupName("Wimax") - - .AddConstructor() - - .AddAttribute( - "NoiseFigure", - "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.", - DoubleValue(5), - MakeDoubleAccessor(&SimpleOfdmWimaxPhy::SetNoiseFigure, - &SimpleOfdmWimaxPhy::GetNoiseFigure), - MakeDoubleChecker()) - - .AddAttribute("TxPower", - "Transmission power (dB).", - DoubleValue(30), - MakeDoubleAccessor(&SimpleOfdmWimaxPhy::SetTxPower, - &SimpleOfdmWimaxPhy::GetTxPower), - MakeDoubleChecker()) - - .AddAttribute("G", - "This is the ratio of CP time to useful time.", - DoubleValue(0.25), - MakeDoubleAccessor(&SimpleOfdmWimaxPhy::DoSetGValue, - &SimpleOfdmWimaxPhy::DoGetGValue), - MakeDoubleChecker()) - - .AddAttribute( - "TxGain", - "Transmission gain (dB).", - DoubleValue(0), - MakeDoubleAccessor(&SimpleOfdmWimaxPhy::SetTxGain, &SimpleOfdmWimaxPhy::GetTxGain), - MakeDoubleChecker()) - - .AddAttribute( - "RxGain", - "Reception gain (dB).", - DoubleValue(0), - MakeDoubleAccessor(&SimpleOfdmWimaxPhy::SetRxGain, &SimpleOfdmWimaxPhy::GetRxGain), - MakeDoubleChecker()) - - .AddAttribute("Nfft", - "FFT size", - UintegerValue(256), - MakeUintegerAccessor(&SimpleOfdmWimaxPhy::DoSetNfft, - &SimpleOfdmWimaxPhy::DoGetNfft), - MakeUintegerChecker(256, 1024)) - - .AddAttribute("TraceFilePath", - "Path to the directory containing SNR to block error rate files", - StringValue(""), - MakeStringAccessor(&SimpleOfdmWimaxPhy::GetTraceFilePath, - &SimpleOfdmWimaxPhy::SetTraceFilePath), - MakeStringChecker()) - - .AddTraceSource("Rx", - "Receive trace", - MakeTraceSourceAccessor(&SimpleOfdmWimaxPhy::m_traceRx), - "ns3::PacketBurst::TracedCallback") - .AddTraceSource("Tx", - "Transmit trace", - MakeTraceSourceAccessor(&SimpleOfdmWimaxPhy::m_traceTx), - "ns3::PacketBurst::TracedCallback") - - .AddTraceSource( - "PhyTxBegin", - "Trace source indicating a packet has begun transmitting over the channel medium", - MakeTraceSourceAccessor(&SimpleOfdmWimaxPhy::m_phyTxBeginTrace), - "ns3::PacketBurst::TracedCallback") - - .AddTraceSource( - "PhyTxEnd", - "Trace source indicating a packet has been completely transmitted over the channel", - MakeTraceSourceAccessor(&SimpleOfdmWimaxPhy::m_phyTxEndTrace), - "ns3::PacketBurst::TracedCallback") - - .AddTraceSource("PhyTxDrop", - "Trace source indicating a packet has been dropped by the device " - "during transmission", - MakeTraceSourceAccessor(&SimpleOfdmWimaxPhy::m_phyTxDropTrace), - "ns3::PacketBurst::TracedCallback") - - .AddTraceSource("PhyRxBegin", - "Trace source indicating a packet has begun being received from the " - "channel medium by the device", - MakeTraceSourceAccessor(&SimpleOfdmWimaxPhy::m_phyRxBeginTrace), - "ns3::PacketBurst::TracedCallback") - - .AddTraceSource("PhyRxEnd", - "Trace source indicating a packet has been completely received from " - "the channel medium by the device", - MakeTraceSourceAccessor(&SimpleOfdmWimaxPhy::m_phyRxEndTrace), - "ns3::PacketBurst::TracedCallback") - - .AddTraceSource( - "PhyRxDrop", - "Trace source indicating a packet has been dropped by the device during reception", - MakeTraceSourceAccessor(&SimpleOfdmWimaxPhy::m_phyRxDropTrace), - "ns3::PacketBurst::TracedCallback"); - return tid; -} - -void -SimpleOfdmWimaxPhy::InitSimpleOfdmWimaxPhy() -{ - m_fecBlockSize = 0; - m_nrFecBlocksSent = 0; - m_dataRateBpsk12 = 0; - m_dataRateQpsk12 = 0; - m_dataRateQpsk34 = 0; - m_dataRateQam16_12 = 0; - - m_dataRateQam16_34 = 0; - m_dataRateQam64_23 = 0; - m_dataRateQam64_34 = 0; - - m_nrBlocks = 0; - m_blockSize = 0; - m_paddingBits = 0; - m_rxGain = 0; - m_txGain = 0; - m_nfft = 256; - m_g = 1.0 / 4; - SetNrCarriers(192); - m_fecBlocks = new std::list; - m_receivedFecBlocks = new std::list; - m_currentBurstSize = 0; - m_noiseFigure = 5; // dB - m_txPower = 30; // dBm - SetBandwidth(10000000); // 10Mhz - m_nbErroneousBlock = 0; - m_nrReceivedFecBlocks = 0; - m_snrToBlockErrorRateManager = new SNRToBlockErrorRateManager(); -} - -SimpleOfdmWimaxPhy::SimpleOfdmWimaxPhy() -{ - m_URNG = CreateObject(); - - InitSimpleOfdmWimaxPhy(); - m_snrToBlockErrorRateManager->SetTraceFilePath((char*)""); - m_snrToBlockErrorRateManager->LoadTraces(); -} - -SimpleOfdmWimaxPhy::SimpleOfdmWimaxPhy(char* tracesPath) -{ - InitSimpleOfdmWimaxPhy(); - m_snrToBlockErrorRateManager->SetTraceFilePath(tracesPath); - m_snrToBlockErrorRateManager->LoadTraces(); -} - -SimpleOfdmWimaxPhy::~SimpleOfdmWimaxPhy() -{ -} - -void -SimpleOfdmWimaxPhy::ActivateLoss(bool loss) -{ - m_snrToBlockErrorRateManager->ActivateLoss(loss); -} - -void -SimpleOfdmWimaxPhy::SetSNRToBlockErrorRateTracesPath(char* tracesPath) -{ - m_snrToBlockErrorRateManager->SetTraceFilePath(tracesPath); - m_snrToBlockErrorRateManager->ReLoadTraces(); -} - -uint32_t -SimpleOfdmWimaxPhy::GetBandwidth() const -{ - return WimaxPhy::GetChannelBandwidth(); -} - -void -SimpleOfdmWimaxPhy::SetBandwidth(uint32_t BW) -{ - WimaxPhy::SetChannelBandwidth(BW); -} - -double -SimpleOfdmWimaxPhy::GetTxPower() const -{ - return m_txPower; -} - -void -SimpleOfdmWimaxPhy::SetTxPower(double txPower) -{ - m_txPower = txPower; -} - -double -SimpleOfdmWimaxPhy::GetNoiseFigure() const -{ - return m_noiseFigure; -} - -void -SimpleOfdmWimaxPhy::SetNoiseFigure(double noiseFigure) -{ - m_noiseFigure = noiseFigure; -} - -void -SimpleOfdmWimaxPhy::DoDispose() -{ - delete m_receivedFecBlocks; - delete m_fecBlocks; - m_receivedFecBlocks = nullptr; - m_fecBlocks = nullptr; - delete m_snrToBlockErrorRateManager; - WimaxPhy::DoDispose(); -} - -void -SimpleOfdmWimaxPhy::DoAttach(Ptr channel) -{ - GetChannel()->Attach(this); -} - -void -SimpleOfdmWimaxPhy::Send(SendParams* params) -{ - auto o_params = dynamic_cast(params); - NS_ASSERT(o_params != nullptr); - Send(o_params->GetBurst(), - (WimaxPhy::ModulationType)o_params->GetModulationType(), - o_params->GetDirection()); -} - -WimaxPhy::PhyType -SimpleOfdmWimaxPhy::GetPhyType() const -{ - return WimaxPhy::simpleOfdmWimaxPhy; -} - -void -SimpleOfdmWimaxPhy::Send(Ptr burst, - WimaxPhy::ModulationType modulationType, - uint8_t direction) -{ - if (GetState() != PHY_STATE_TX) - { - m_currentBurstSize = burst->GetSize(); - m_nrFecBlocksSent = 0; - m_currentBurst = burst; - SetBlockParameters(burst->GetSize(), modulationType); - NotifyTxBegin(m_currentBurst); - StartSendDummyFecBlock(true, modulationType, direction); - m_traceTx(burst); - } -} - -void -SimpleOfdmWimaxPhy::StartSendDummyFecBlock(bool isFirstBlock, - WimaxPhy::ModulationType modulationType, - uint8_t direction) -{ - SetState(PHY_STATE_TX); - bool isLastFecBlock = false; - if (isFirstBlock) - { - m_blockTime = GetBlockTransmissionTime(modulationType); - } - - SimpleOfdmWimaxChannel* channel = - dynamic_cast(PeekPointer(GetChannel())); - NS_ASSERT(channel != nullptr); - - isLastFecBlock = (m_nrRemainingBlocksToSend == 1); - channel->Send(m_blockTime, - m_currentBurstSize, - this, - isFirstBlock, - isLastFecBlock, - GetTxFrequency(), - modulationType, - direction, - m_txPower, - m_currentBurst); - - m_nrRemainingBlocksToSend--; - Simulator::Schedule(m_blockTime, - &SimpleOfdmWimaxPhy::EndSendFecBlock, - this, - modulationType, - direction); -} - -void -SimpleOfdmWimaxPhy::EndSendFecBlock(WimaxPhy::ModulationType modulationType, uint8_t direction) -{ - m_nrFecBlocksSent++; - SetState(PHY_STATE_IDLE); - - if (m_nrFecBlocksSent * m_blockSize == m_currentBurstSize * 8 + m_paddingBits) - { - // this is the last FEC block of the burst - NS_ASSERT_MSG(m_nrRemainingBlocksToSend == 0, "Error while sending a burst"); - NotifyTxEnd(m_currentBurst); - } - else - { - StartSendDummyFecBlock(false, modulationType, direction); - } -} - -void -SimpleOfdmWimaxPhy::EndSend() -{ - SetState(PHY_STATE_IDLE); -} - -void -SimpleOfdmWimaxPhy::StartReceive(uint32_t burstSize, - bool isFirstBlock, - uint64_t frequency, - WimaxPhy::ModulationType modulationType, - uint8_t direction, - double rxPower, - Ptr burst) -{ - bool drop = false; - double Nwb = -114 + m_noiseFigure + 10 * std::log(GetBandwidth() / 1000000000.0) / 2.303; - double SNR = rxPower - Nwb; - - SNRToBlockErrorRateRecord* record = - m_snrToBlockErrorRateManager->GetSNRToBlockErrorRateRecord(SNR, modulationType); - double I1 = record->GetI1(); - double I2 = record->GetI2(); - - double blockErrorRate = m_URNG->GetValue(I1, I2); - - double rand = m_URNG->GetValue(0.0, 1.0); - - if (rand < blockErrorRate) - { - drop = true; - } - if (rand > blockErrorRate) - { - drop = false; - } - - if (blockErrorRate == 1.0) - { - drop = true; - } - if (blockErrorRate == 0.0) - { - drop = false; - } - delete record; - - NS_LOG_INFO("PHY: Receive rxPower=" << rxPower << ", Nwb=" << Nwb << ", SNR=" << SNR - << ", Modulation=" << modulationType << ", BlockErrorRate=" - << blockErrorRate << ", drop=" << std::boolalpha << drop); - - switch (GetState()) - { - case PHY_STATE_SCANNING: - if (frequency == GetScanningFrequency()) - { - Simulator::Cancel(GetChnlSrchTimeoutEvent()); - SetScanningCallback(); - SetSimplex(frequency); - SetState(PHY_STATE_IDLE); - } - break; - case PHY_STATE_IDLE: - if (frequency == GetRxFrequency()) - { - if (isFirstBlock) - { - NotifyRxBegin(burst); - m_receivedFecBlocks->clear(); - m_nrReceivedFecBlocks = 0; - SetBlockParameters(burstSize, modulationType); - m_blockTime = GetBlockTransmissionTime(modulationType); - } - - Simulator::Schedule(m_blockTime, - &SimpleOfdmWimaxPhy::EndReceiveFecBlock, - this, - burstSize, - modulationType, - direction, - drop, - burst); - - SetState(PHY_STATE_RX); - } - break; - case PHY_STATE_RX: - // drop - break; - case PHY_STATE_TX: - if (IsDuplex() && frequency == GetRxFrequency()) - { - } - break; - } -} - -void -SimpleOfdmWimaxPhy::EndReceiveFecBlock(uint32_t burstSize, - WimaxPhy::ModulationType modulationType, - uint8_t direction, - bool drop, - Ptr burst) -{ - SetState(PHY_STATE_IDLE); - m_nrReceivedFecBlocks++; - - if (drop) - { - m_nbErroneousBlock++; - } - - if ((uint32_t)m_nrReceivedFecBlocks * m_blockSize == burstSize * 8 + m_paddingBits) - { - NotifyRxEnd(burst); - if (m_nbErroneousBlock == 0) - { - Simulator::Schedule(Seconds(0), &SimpleOfdmWimaxPhy::EndReceive, this, burst); - } - else - { - NotifyRxDrop(burst); - } - m_nbErroneousBlock = 0; - m_nrReceivedFecBlocks = 0; - } -} - -void -SimpleOfdmWimaxPhy::EndReceive(Ptr burst) -{ - Ptr b = burst->Copy(); - GetReceiveCallback()(b); - m_traceRx(burst); -} - -Bvec -SimpleOfdmWimaxPhy::ConvertBurstToBits(Ptr burst) -{ - Bvec buffer(burst->GetSize() * 8, false); - - std::list> packets = burst->GetPackets(); - - uint32_t j = 0; - for (auto iter = packets.begin(); iter != packets.end(); ++iter) - { - Ptr packet = *iter; - auto pstart = (uint8_t*)std::malloc(packet->GetSize()); - std::memset(pstart, 0, packet->GetSize()); - packet->CopyData(pstart, packet->GetSize()); - Bvec temp(8); - temp.resize(0, false); - temp.resize(8, false); - for (uint32_t i = 0; i < packet->GetSize(); i++) - { - for (uint8_t l = 0; l < 8; l++) - { - temp[l] = (bool)((((uint8_t)pstart[i]) >> (7 - l)) & 0x01); - buffer.at(j * 8 + l) = temp[l]; - } - j++; - } - std::free(pstart); - } - - return buffer; -} - -/* - Converts back the bit buffer (Bvec) to the actual burst. - Actually creates byte buffer from the Bvec and resets the buffer - of each packet in the copy of the original burst stored before transmitting. - By doing this it preserves the metadata and tags in the packet. - Function could also be named DeserializeBurst because actually it - copying to the burst's byte buffer. - */ -Ptr -SimpleOfdmWimaxPhy::ConvertBitsToBurst(Bvec buffer) -{ - const auto bufferSize = buffer.size() / 8; - std::vector bytes(bufferSize, 0); - int32_t j = 0; - // recreating byte buffer from bit buffer (Bvec) - for (std::size_t i = 0; i < buffer.size(); i += 8) - { - uint8_t temp = 0; - for (std::size_t l = 0; l < 8; l++) - { - bool bin = buffer.at(i + l); - temp |= (bin << (7 - l)); - } - - bytes[j] = temp; - j++; - } - uint16_t pos = 0; - Ptr RecvBurst = CreateObject(); - while (pos < bufferSize) - { - uint16_t packetSize = 0; - // Get the header type: first bit - uint8_t ht = (bytes[pos] >> 7) & 0x01; - if (ht == 1) - { - // BW request header. Size is always 8 bytes - packetSize = 6; - } - else - { - // Read the size - uint8_t Len_MSB = bytes[pos + 1] & 0x07; - packetSize = (uint16_t)((uint16_t)(Len_MSB << 8) | (uint16_t)(bytes[pos + 2])); - if (packetSize == 0) - { - break; // padding - } - } - - Ptr p = Create(&bytes[pos], packetSize); - RecvBurst->AddPacket(p); - pos += packetSize; - } - return RecvBurst; -} - -void -SimpleOfdmWimaxPhy::CreateFecBlocks(const Bvec& buffer, WimaxPhy::ModulationType modulationType) -{ - Bvec fecBlock(m_blockSize); - for (uint32_t i = 0, j = m_nrBlocks; j > 0; i += m_blockSize, j--) - { - if (j == 1 && m_paddingBits > 0) // last block can be smaller than block size - { - fecBlock = Bvec(buffer.begin() + i, buffer.end()); - fecBlock.resize(m_blockSize, false); - } - else - { - fecBlock = Bvec(buffer.begin() + i, buffer.begin() + i + m_blockSize); - } - - m_fecBlocks->push_back(fecBlock); - } -} - -Bvec -SimpleOfdmWimaxPhy::RecreateBuffer() -{ - Bvec buffer(m_blockSize * (unsigned long)m_nrBlocks); - Bvec block(m_blockSize); - uint32_t i = 0; - for (uint32_t j = 0; j < m_nrBlocks; j++) - { - Bvec tmpRecFecBlock = m_receivedFecBlocks->front(); - buffer.insert(buffer.begin() + i, tmpRecFecBlock.begin(), tmpRecFecBlock.end()); - m_receivedFecBlocks->pop_front(); - i += m_blockSize; - } - return buffer; -} - -void -SimpleOfdmWimaxPhy::DoSetDataRates() -{ - m_dataRateBpsk12 = CalculateDataRate(MODULATION_TYPE_BPSK_12); // 6912000 bps - m_dataRateQpsk12 = CalculateDataRate(MODULATION_TYPE_QPSK_12); // 13824000 - m_dataRateQpsk34 = CalculateDataRate(MODULATION_TYPE_QPSK_34); // 20736000 - m_dataRateQam16_12 = CalculateDataRate(MODULATION_TYPE_QAM16_12); // 27648000 - m_dataRateQam16_34 = CalculateDataRate(MODULATION_TYPE_QAM16_34); // 41472000 - m_dataRateQam64_23 = CalculateDataRate(MODULATION_TYPE_QAM64_23); // 55224000 - m_dataRateQam64_34 = CalculateDataRate(MODULATION_TYPE_QAM64_34); // 62208000 -} - -void -SimpleOfdmWimaxPhy::GetModulationFecParams(WimaxPhy::ModulationType modulationType, - uint8_t& bitsPerSymbol, - double& fecCode) const -{ - switch (modulationType) - { - case MODULATION_TYPE_BPSK_12: - bitsPerSymbol = 1; - fecCode = 1.0 / 2; - break; - case MODULATION_TYPE_QPSK_12: - bitsPerSymbol = 2; - fecCode = 1.0 / 2; - break; - case MODULATION_TYPE_QPSK_34: - bitsPerSymbol = 2; - fecCode = 3.0 / 4; - break; - case MODULATION_TYPE_QAM16_12: - bitsPerSymbol = 4; - fecCode = 1.0 / 2; - break; - case MODULATION_TYPE_QAM16_34: - bitsPerSymbol = 4; - fecCode = 3.0 / 4; - break; - case MODULATION_TYPE_QAM64_23: - bitsPerSymbol = 6; - fecCode = 2.0 / 3; - break; - case MODULATION_TYPE_QAM64_34: - bitsPerSymbol = 6; - fecCode = 0.75; - break; - } -} - -uint32_t -SimpleOfdmWimaxPhy::CalculateDataRate(WimaxPhy::ModulationType modulationType) const -{ - uint8_t bitsPerSymbol = 0; - double fecCode = 0; - GetModulationFecParams(modulationType, bitsPerSymbol, fecCode); - double symbolsPerSecond = 1 / GetSymbolDuration().GetSeconds(); - auto bitsTransmittedPerSymbol = (uint16_t)(bitsPerSymbol * GetNrCarriers() * fecCode); - // 96, 192, 288, 384, 576, 767 and 864 bits per symbol for the seven modulations, respectively - - return (uint32_t)(symbolsPerSecond * bitsTransmittedPerSymbol); -} - -uint32_t -SimpleOfdmWimaxPhy::DoGetDataRate(WimaxPhy::ModulationType modulationType) const -{ - switch (modulationType) - { - case MODULATION_TYPE_BPSK_12: - return m_dataRateBpsk12; - case MODULATION_TYPE_QPSK_12: - return m_dataRateQpsk12; - case MODULATION_TYPE_QPSK_34: - return m_dataRateQpsk34; - case MODULATION_TYPE_QAM16_12: - return m_dataRateQam16_12; - case MODULATION_TYPE_QAM16_34: - return m_dataRateQam16_34; - case MODULATION_TYPE_QAM64_23: - return m_dataRateQam64_23; - case MODULATION_TYPE_QAM64_34: - return m_dataRateQam64_34; - } - NS_FATAL_ERROR("Invalid modulation type"); - return 0; -} - -Time -SimpleOfdmWimaxPhy::GetBlockTransmissionTime(WimaxPhy::ModulationType modulationType) const -{ - return Seconds((double)GetFecBlockSize(modulationType) / DoGetDataRate(modulationType)); -} - -Time -SimpleOfdmWimaxPhy::DoGetTransmissionTime(uint32_t size, - WimaxPhy::ModulationType modulationType) const -{ - /*adding 3 extra nano second to cope with the loss of precision problem. - the time is internally stored in a 64 bit hence a floating-point time would loss - precision, e.g., 0.00001388888888888889 seconds will become 13888888888 femtoseconds.*/ - return Seconds(DoGetNrSymbols(size, modulationType) * GetSymbolDuration().GetSeconds()) + - NanoSeconds(3); -} - -uint64_t -SimpleOfdmWimaxPhy::DoGetNrSymbols(uint32_t size, WimaxPhy::ModulationType modulationType) const -{ - Time transmissionTime = - Seconds((double)(GetNrBlocks(size, modulationType) * GetFecBlockSize(modulationType)) / - DoGetDataRate(modulationType)); - return (uint64_t)std::ceil(transmissionTime.GetSeconds() / GetSymbolDuration().GetSeconds()); -} - -uint64_t -SimpleOfdmWimaxPhy::DoGetNrBytes(uint32_t symbols, WimaxPhy::ModulationType modulationType) const -{ - Time transmissionTime = Seconds(symbols * GetSymbolDuration().GetSeconds()); - return (uint64_t)std::floor((transmissionTime.GetSeconds() * DoGetDataRate(modulationType)) / - 8); -} - -uint32_t -SimpleOfdmWimaxPhy::GetFecBlockSize(WimaxPhy::ModulationType modulationType) const -{ - uint32_t blockSize = 0; - switch (modulationType) - { - case MODULATION_TYPE_BPSK_12: - blockSize = 12; - break; - case MODULATION_TYPE_QPSK_12: - blockSize = 24; - break; - case MODULATION_TYPE_QPSK_34: - blockSize = 36; - break; - case MODULATION_TYPE_QAM16_12: - blockSize = 48; - break; - case MODULATION_TYPE_QAM16_34: - blockSize = 72; - break; - case MODULATION_TYPE_QAM64_23: - blockSize = 96; - break; - case MODULATION_TYPE_QAM64_34: - blockSize = 108; - break; - default: - NS_FATAL_ERROR("Invalid modulation type"); - break; - } - return blockSize * 8; // in bits -} - -// Channel coding block size, Table 215, page 434 -uint32_t -SimpleOfdmWimaxPhy::GetCodedFecBlockSize(WimaxPhy::ModulationType modulationType) const -{ - uint32_t blockSize = 0; - switch (modulationType) - { - case MODULATION_TYPE_BPSK_12: - blockSize = 24; - break; - case MODULATION_TYPE_QPSK_12: - case MODULATION_TYPE_QPSK_34: - blockSize = 48; - break; - case MODULATION_TYPE_QAM16_12: - case MODULATION_TYPE_QAM16_34: - blockSize = 96; - break; - case MODULATION_TYPE_QAM64_23: - case MODULATION_TYPE_QAM64_34: - blockSize = 144; - break; - default: - NS_FATAL_ERROR("Invalid modulation type"); - break; - } - return blockSize * 8; // in bits -} - -void -SimpleOfdmWimaxPhy::SetBlockParameters(uint32_t burstSize, WimaxPhy::ModulationType modulationType) -{ - m_blockSize = GetFecBlockSize(modulationType); - m_nrBlocks = GetNrBlocks(burstSize, modulationType); - m_paddingBits = (m_nrBlocks * m_blockSize) - (burstSize * 8); - m_nrRemainingBlocksToSend = m_nrBlocks; - NS_ASSERT_MSG(static_cast(m_nrBlocks * m_blockSize) >= (burstSize * 8), - "Size of padding bytes < 0"); -} - -uint16_t -SimpleOfdmWimaxPhy::DoGetTtg() const -{ - // assumed equal to 2 symbols - return 2 * GetPsPerSymbol(); -} - -uint16_t -SimpleOfdmWimaxPhy::DoGetRtg() const -{ - // assumed equal to 2 symbols - return 2 * GetPsPerSymbol(); -} - -uint8_t -SimpleOfdmWimaxPhy::DoGetFrameDurationCode() const -{ - uint16_t duration = 0; - duration = (uint16_t)(GetFrameDuration().GetSeconds() * 10000); - uint8_t retval = 0; - switch (duration) - { - case 25: { - retval = FRAME_DURATION_2_POINT_5_MS; - break; - } - case 40: { - retval = FRAME_DURATION_4_MS; - break; - } - case 50: { - retval = FRAME_DURATION_5_MS; - break; - } - case 80: { - retval = FRAME_DURATION_8_MS; - break; - } - case 100: { - retval = FRAME_DURATION_10_MS; - break; - } - case 125: { - retval = FRAME_DURATION_12_POINT_5_MS; - break; - } - case 200: { - retval = FRAME_DURATION_20_MS; - break; - } - default: { - NS_FATAL_ERROR("Invalid frame duration = " << duration); - retval = 0; - } - } - return retval; -} - -Time -SimpleOfdmWimaxPhy::DoGetFrameDuration(uint8_t frameDurationCode) const -{ - switch (frameDurationCode) - { - case FRAME_DURATION_2_POINT_5_MS: - return Seconds(2.5); - case FRAME_DURATION_4_MS: - return Seconds(4); - case FRAME_DURATION_5_MS: - return Seconds(5); - case FRAME_DURATION_8_MS: - return Seconds(8); - case FRAME_DURATION_10_MS: - return Seconds(10); - case FRAME_DURATION_12_POINT_5_MS: - return Seconds(12.5); - case FRAME_DURATION_20_MS: - return Seconds(20); - default: - NS_FATAL_ERROR("Invalid modulation type"); - } - return Seconds(0); -} - -/* - Returns number of blocks (FEC blocks) the burst will be split in. - The size of the block is specific for each modulation type. - */ -uint16_t -SimpleOfdmWimaxPhy::GetNrBlocks(uint32_t burstSize, WimaxPhy::ModulationType modulationType) const -{ - uint32_t blockSize = GetFecBlockSize(modulationType); - uint16_t nrBlocks = (burstSize * 8) / blockSize; - - if ((burstSize * 8) % blockSize > 0) - { - nrBlocks += 1; - } - - return nrBlocks; -} - -/*---------------------PHY parameters functions-----------------------*/ - -void -SimpleOfdmWimaxPhy::DoSetPhyParameters() -{ - /*Calculations as per section 8.3.2. - Currently assuming license-exempt 5 GHz band. For channel bandwidth 20 MHz (Table B.28, page - 812) and frame duration 10 ms (Table 232, page 460) i.e, 100 frames per second, sampling - frequency is 23040000, symbol (OFDM symbol) duration is 1.388888888888889e-05 seconds, PS - duration is 1.7361111111111112e-07 seconds. Hence PSs per frame is 57600, symbols per frame is - 720 and PSs per symbol is 80. Note that defining these parameters (symbol and PS duration) as - Time may not result in exactly these values therefore lrint has been used (otherwise should be - defined as double). For licensed bands set channel bandwidth according to Table B.26, page - 810.*/ - - double samplingFrequency = DoGetSamplingFrequency(); - Time psDuration = Seconds(4.0 / samplingFrequency); - - SetPsDuration(psDuration); - uint16_t psPerFrame = (uint16_t)(GetFrameDuration().GetSeconds() / psDuration.GetSeconds()); - SetPsPerFrame(psPerFrame); - double subcarrierSpacing = samplingFrequency / DoGetNfft(); - double tb = 1.0 / subcarrierSpacing; // Tb (useful symbol time) - double tg = DoGetGValue() * tb; // Tg (cyclic prefix time) - Time symbolDuration = Seconds(tb + tg); // OFDM Symbol Time - SetSymbolDuration(symbolDuration); - uint16_t psPerSymbol = lrint(symbolDuration.GetSeconds() / psDuration.GetSeconds()); - SetPsPerSymbol(psPerSymbol); - uint32_t symbolsPerFrame = lrint(GetFrameDuration().GetSeconds() / symbolDuration.GetSeconds()); - SetSymbolsPerFrame(symbolsPerFrame); -} - -void -SimpleOfdmWimaxPhy::DoSetNfft(uint16_t nfft) -{ - m_nfft = nfft; -} - -uint16_t -SimpleOfdmWimaxPhy::DoGetNfft() const -{ - return m_nfft; -} - -double -SimpleOfdmWimaxPhy::DoGetSamplingFactor() const -{ - // sampling factor (n), see Table 213, page 429 - - uint32_t channelBandwidth = GetChannelBandwidth(); - - if (channelBandwidth % 1750000 == 0) - { - return 8.0 / 7; - } - else if (channelBandwidth % 1500000 == 0) - { - return 86.0 / 75; - } - else if (channelBandwidth % 1250000 == 0) - { - return 144.0 / 125; - } - else if (channelBandwidth % 2750000 == 0) - { - return 316.0 / 275; - } - else if (channelBandwidth % 2000000 == 0) - { - return 57.0 / 50; - } - else - { - NS_LOG_DEBUG("Oops may be wrong channel bandwidth for OFDM PHY!"); - NS_FATAL_ERROR("wrong channel bandwidth for OFDM PHY"); - } - - return 8.0 / 7; -} - -double -SimpleOfdmWimaxPhy::DoGetSamplingFrequency() const -{ - // sampling frequency (Fs), see 8.3.2.2 - - return (DoGetSamplingFactor() * GetChannelBandwidth() / 8000) * 8000; -} - -double -SimpleOfdmWimaxPhy::DoGetGValue() const -{ - return m_g; -} - -void -SimpleOfdmWimaxPhy::DoSetGValue(double g) -{ - m_g = g; -} - -void -SimpleOfdmWimaxPhy::SetTxGain(double txGain) -{ - m_txGain = txGain; -} - -void -SimpleOfdmWimaxPhy::SetRxGain(double txRain) -{ - m_rxGain = txRain; -} - -double -SimpleOfdmWimaxPhy::GetTxGain() const -{ - return m_txGain; -} - -double -SimpleOfdmWimaxPhy::GetRxGain() const -{ - return m_rxGain; -} - -std::string -SimpleOfdmWimaxPhy::GetTraceFilePath() const -{ - return (m_snrToBlockErrorRateManager->GetTraceFilePath()); -} - -void -SimpleOfdmWimaxPhy::SetTraceFilePath(std::string path) -{ - m_snrToBlockErrorRateManager->SetTraceFilePath((char*)path.c_str()); - m_snrToBlockErrorRateManager->LoadTraces(); -} - -void -SimpleOfdmWimaxPhy::NotifyTxBegin(Ptr burst) -{ - m_phyTxBeginTrace(burst); -} - -void -SimpleOfdmWimaxPhy::NotifyTxEnd(Ptr burst) -{ - m_phyTxEndTrace(burst); -} - -void -SimpleOfdmWimaxPhy::NotifyTxDrop(Ptr burst) -{ - m_phyTxDropTrace(burst); -} - -void -SimpleOfdmWimaxPhy::NotifyRxBegin(Ptr burst) -{ - m_phyRxBeginTrace(burst); -} - -void -SimpleOfdmWimaxPhy::NotifyRxEnd(Ptr burst) -{ - m_phyRxEndTrace(burst); -} - -void -SimpleOfdmWimaxPhy::NotifyRxDrop(Ptr burst) -{ - m_phyRxDropTrace(burst); -} - -int64_t -SimpleOfdmWimaxPhy::AssignStreams(int64_t stream) -{ - NS_LOG_FUNCTION(this << stream); - m_URNG->SetStream(stream); - return 1; -} - -} // namespace ns3 diff --git a/src/wimax/model/simple-ofdm-wimax-phy.h b/src/wimax/model/simple-ofdm-wimax-phy.h deleted file mode 100644 index 0fcd56f96..000000000 --- a/src/wimax/model/simple-ofdm-wimax-phy.h +++ /dev/null @@ -1,540 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -#ifndef SIMPLE_OFDM_WIMAX_PHY_H -#define SIMPLE_OFDM_WIMAX_PHY_H - -#include "bvec.h" -#include "snr-to-block-error-rate-manager.h" -#include "wimax-connection.h" -#include "wimax-phy.h" - -#include "ns3/callback.h" -#include "ns3/event-id.h" -#include "ns3/nstime.h" -#include "ns3/random-variable-stream.h" - -#include -#include - -namespace ns3 -{ - -class WimaxChannel; -class WimaxNetDevice; -class NetDevice; -class Packet; -class SimpleOfdmWimaxChannel; - -/** - * @ingroup wimax - * @brief SimpleOfdmWimaxPhy class - */ -class SimpleOfdmWimaxPhy : public WimaxPhy -{ - public: - /// Frame duration code enumeration - enum FrameDurationCode - { - FRAME_DURATION_2_POINT_5_MS, - FRAME_DURATION_4_MS, - FRAME_DURATION_5_MS, - FRAME_DURATION_8_MS, - FRAME_DURATION_10_MS, - FRAME_DURATION_12_POINT_5_MS, - FRAME_DURATION_20_MS - }; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - SimpleOfdmWimaxPhy(); - /** - * Constructor - * - * @param tracesPath trace path - */ - SimpleOfdmWimaxPhy(char* tracesPath); - ~SimpleOfdmWimaxPhy() override; - /** - * @brief if called with true it will enable the loss model - * @param loss set to true to enable the loss model - */ - void ActivateLoss(bool loss); - /** - * @brief Set the path of the repository containing the traces - * @param tracesPath the path to the repository. - * see snr-to-block-error-rate-manager.h for more details. - */ - void SetSNRToBlockErrorRateTracesPath(char* tracesPath); - /** - * Attach the physical layer to a channel. - * @param channel the channel to which the physical layer will be attached - */ - void DoAttach(Ptr channel) override; - /** - * @brief set the callback function to call when a burst is received - * @param callback the receive callback function - */ - void SetReceiveCallback(Callback, Ptr> callback); - /** - * @brief Sends a burst on the channel - * @param burst the burst to send - * @param modulationType the modulation that will be used to send this burst - * @param direction set to uplink or downlink - */ - void Send(Ptr burst, WimaxPhy::ModulationType modulationType, uint8_t direction); - /** - * @brief Sends a burst on the channel - * @param params parameters - * @see SendParams - */ - void Send(SendParams* params) override; - /** - * @brief returns the type this physical layer - * @return always WimaxPhy::simpleOfdmWimaxPhy; - */ - WimaxPhy::PhyType GetPhyType() const override; - /** - * @brief start the reception of a fec block - * @param burstSize the burst size - * @param isFirstBlock true if this block is the first one, false otherwise - * @param frequency the frequency in which the fec block is being received - * @param modulationType the modulation used to transmit this fec Block - * @param direction set to uplink and downlink - * @param rxPower the received power. - * @param burst the burst to be sent - */ - - void StartReceive(uint32_t burstSize, - bool isFirstBlock, - uint64_t frequency, - WimaxPhy::ModulationType modulationType, - uint8_t direction, - double rxPower, - Ptr burst); - - /** - * @return the bandwidth - */ - uint32_t GetBandwidth() const; - /** - * @brief Set the bandwidth - * @param BW the bandwidth - */ - void SetBandwidth(uint32_t BW); - /** - * @return the transmission power - */ - double GetTxPower() const; - /** - * @brief set the transmission power - * @param txPower the transmission power - */ - void SetTxPower(double txPower); - /** - * @return the noise figure - */ - double GetNoiseFigure() const; - /** - * @brief set the noise figure of the device - * @param nf the noise figure - */ - void SetNoiseFigure(double nf); - - /** - * Public method used to fire a PhyTxBegin trace. Implemented for encapsulation - * purposes. - * @param burst the packet burst - */ - void NotifyTxBegin(Ptr burst); - - /** - * Public method used to fire a PhyTxEnd trace. Implemented for encapsulation - * purposes. - * @param burst the packet burst - */ - void NotifyTxEnd(Ptr burst); - - /** - * Public method used to fire a PhyTxDrop trace. Implemented for encapsulation - * purposes. - * @param burst the packet burst - */ - void NotifyTxDrop(Ptr burst); - - /** - * Public method used to fire a PhyRxBegin trace. Implemented for encapsulation - * purposes. - * @param burst the packet burst - */ - void NotifyRxBegin(Ptr burst); - - /** - * Public method used to fire a PhyRxEnd trace. Implemented for encapsulation - * purposes. - * @param burst the packet burst - */ - void NotifyRxEnd(Ptr burst); - - /** - * Public method used to fire a PhyRxDrop trace. Implemented for encapsulation - * purposes. - * @param burst the packet burst - */ - void NotifyRxDrop(Ptr burst); - - /** - * Assign a fixed random variable stream number to the random variables - * used by this model. Return the number of streams (possibly zero) that - * have been assigned. - * - * @param stream first stream index to use - * @return the number of stream indices assigned by this model - */ - int64_t AssignStreams(int64_t stream) override; - - private: - /** - * Get transmission time - * @param size the size - * @param modulationType the modulation type - * @returns the transmission time - */ - Time DoGetTransmissionTime(uint32_t size, - WimaxPhy::ModulationType modulationType) const override; - /** - * Get number of symbols - * @param size the size - * @param modulationType the modulation type - * @returns the number of symbols - */ - uint64_t DoGetNrSymbols(uint32_t size, WimaxPhy::ModulationType modulationType) const override; - /** - * Get number of bytes - * @param symbols the symbols - * @param modulationType the modulation type - * @returns the number of bytes - */ - uint64_t DoGetNrBytes(uint32_t symbols, WimaxPhy::ModulationType modulationType) const override; - /** - * Convert burst to bits - * @param burst the packet burst - * @returns the BVEC - */ - Bvec ConvertBurstToBits(Ptr burst); - /** - * Convert bits to burst - * @param buffer the BVEC - * @returns the packet burst - */ - Ptr ConvertBitsToBurst(Bvec buffer); - /** - * Create FEC blocks - * @param buffer the BVEC - * @param modulationType the modulation type - */ - void CreateFecBlocks(const Bvec& buffer, WimaxPhy::ModulationType modulationType); - /** - * Recreate buffer - * @returns BVEC - */ - Bvec RecreateBuffer(); - /** - * Get FEC block size - * @param type the modulation type - * @returns the FEC block size - */ - uint32_t GetFecBlockSize(WimaxPhy::ModulationType type) const; - /** - * Get coded FEC block size - * @param modulationType the modulation type - * @returns the coded FEC block size - */ - uint32_t GetCodedFecBlockSize(WimaxPhy::ModulationType modulationType) const; - /** - * Set block parameters - * @param burstSize the burst size - * @param modulationType the modulation type - */ - void SetBlockParameters(uint32_t burstSize, WimaxPhy::ModulationType modulationType); - /** - * Get number of blocks - * @param burstSize the burst size - * @param modulationType the modulation type - * @returns the number of blocks - */ - uint16_t GetNrBlocks(uint32_t burstSize, WimaxPhy::ModulationType modulationType) const; - void DoDispose() override; - /// End send - void EndSend(); - /** - * End send FEC block - * @param modulationType the modulation type - * @param direction the direction - */ - void EndSendFecBlock(WimaxPhy::ModulationType modulationType, uint8_t direction); - /** - * End receive - * @param burst - */ - void EndReceive(Ptr burst); - /** - * End receive FEC block - * @param burstSize the burst size - * @param modulationType the modulation type - * @param direction the direction - * @param drop whether to drop - * @param burst the burst - */ - void EndReceiveFecBlock(uint32_t burstSize, - WimaxPhy::ModulationType modulationType, - uint8_t direction, - bool drop, - Ptr burst); - /** - * Start end dummy FEC block - * @param isFirstBlock is the first block? - * @param modulationType the modulation type - * @param direction the direction - */ - void StartSendDummyFecBlock(bool isFirstBlock, - WimaxPhy::ModulationType modulationType, - uint8_t direction); - /** - * Get block transmission time - * @param modulationType the modulation type - * @returns the block transmission time - */ - Time GetBlockTransmissionTime(WimaxPhy::ModulationType modulationType) const; - /// Set data rates - void DoSetDataRates() override; - /// Initialize simple OFDM WIMAX Phy - void InitSimpleOfdmWimaxPhy(); - - /** - * Get moduleation FEC parameters - * @param modulationType the modulation type - * @param bitsPerSymbol the number of bits per symbol - * @param fecCode the FEC code - */ - void GetModulationFecParams(WimaxPhy::ModulationType modulationType, - uint8_t& bitsPerSymbol, - double& fecCode) const; - /** - * Calculate data rate - * @param modulationType the modulation type - * @returns the data rate - */ - uint32_t CalculateDataRate(WimaxPhy::ModulationType modulationType) const; - /** - * Get data rate - * @param modulationType the modulation type - * @returns the data rate - */ - uint32_t DoGetDataRate(WimaxPhy::ModulationType modulationType) const override; - /** - * Get TTG - * @returns the TTG - */ - uint16_t DoGetTtg() const override; - /** - * Get RTG - * @returns the RTG - */ - uint16_t DoGetRtg() const override; - /** - * Get frame duration code - * @returns the frame duration code - */ - uint8_t DoGetFrameDurationCode() const override; - /** - * Get frame duration - * @param frameDurationCode the frame duration code - * @returns the frame duration - */ - Time DoGetFrameDuration(uint8_t frameDurationCode) const override; - /// Set Phy parameters - void DoSetPhyParameters() override; - /** - * Get NFFT - * @returns the NFFT - */ - uint16_t DoGetNfft() const override; - /** - * Set NFFT - * @param nfft the NFFT - */ - void DoSetNfft(uint16_t nfft); - /** - * Get sampling factor - * @returns the sampling factor - */ - double DoGetSamplingFactor() const override; - /** - * Get sampling frequency - * @returns the sampling frequency - */ - double DoGetSamplingFrequency() const override; - /** - * Get G value - * @returns the G value - */ - double DoGetGValue() const override; - /** - * Set G value - * @param g the G value - */ - void DoSetGValue(double g); - - /** - * Get receive gain - * @returns the receive gain - */ - double GetRxGain() const; - /** - * Set receive gsain - * @param rxgain the receive gain - */ - void SetRxGain(double rxgain); - - /** - * Get transmit gain - * @returns the transmit gain - */ - double GetTxGain() const; - /** - * Set transmit gain - * @param txgain the transmit gain - */ - void SetTxGain(double txgain); - - /** - * Get trace file path - * @returns the trace file path name - */ - std::string GetTraceFilePath() const; - /** - * Set trace file path - * @param path the trace file path - */ - void SetTraceFilePath(std::string path); - - uint16_t m_fecBlockSize; ///< in bits, size of FEC block transmitted after PHY operations - uint32_t m_currentBurstSize; ///< current burst size - - std::list* m_receivedFecBlocks; ///< a list of received FEC blocks until they are combined - ///< to recreate the full burst buffer - uint32_t m_nrFecBlocksSent; ///< counting the number of FEC blocks sent (within a burst) - std::list* m_fecBlocks; ///< the FEC blocks - Time m_blockTime; ///< block time - - TracedCallback> m_traceRx; ///< trace receive callback - TracedCallback> m_traceTx; ///< trace transmit callback - - // data rates for this Phy - uint32_t m_dataRateBpsk12; ///< data rate - uint32_t m_dataRateQpsk12; ///< data rate - uint32_t m_dataRateQpsk34; ///< data rate - uint32_t m_dataRateQam16_12; ///< data rate - uint32_t m_dataRateQam16_34; ///< data rate - uint32_t m_dataRateQam64_23; ///< data rate - uint32_t m_dataRateQam64_34; ///< data rate - - // parameters to store for a per burst life-time - uint16_t m_nrBlocks; ///< number of blocks - uint16_t m_nrRemainingBlocksToSend; ///< number of remaining blocks to send - Ptr m_currentBurst; ///< current burst - uint16_t m_blockSize; ///< block size - uint32_t m_paddingBits; ///< padding bits - uint16_t m_nbErroneousBlock; ///< erroneous blocks - uint16_t m_nrReceivedFecBlocks; ///< number received FEC blocks - uint16_t m_nfft; ///< NFFT - double m_g; ///< G value - double m_bandWidth; ///< bandwidth - double m_txPower; ///< transmit power - double m_noiseFigure; ///< noise figure - double m_txGain; ///< transmit gain - double m_rxGain; ///< receive gain - /** - * The trace source fired when a packet begins the transmission process on - * the medium. - * - * @see class CallBackTraceSource - * @deprecated The non-const \c Ptr argument is deprecated - * and will be changed to \c Ptrc in a future release. - */ - // NS_DEPRECATED() - tag for future removal - TracedCallback> m_phyTxBeginTrace; - - /** - * The trace source fired when a packet ends the transmission process on - * the medium. - * - * @see class CallBackTraceSource - * @deprecated The non-const \c Ptr argument is deprecated - * and will be changed to \c Ptrc in a future release. - */ - // NS_DEPRECATED() - tag for future removal - TracedCallback> m_phyTxEndTrace; - - /** - * The trace source fired when the phy layer drops a packet as it tries - * to transmit it. - * - * @see class CallBackTraceSource - * @deprecated The non-const \c Ptr argument is deprecated - * and will be changed to \c Ptrc in a future release. - */ - // NS_DEPRECATED() - tag for future removal - TracedCallback> m_phyTxDropTrace; - - /** - * The trace source fired when a packet begins the reception process from - * the medium. - * - * @see class CallBackTraceSource - * @deprecated The non-const \c Ptr argument is deprecated - * and will be changed to \c Ptrc in a future release. - */ - // NS_DEPRECATED() - tag for future removal - TracedCallback> m_phyRxBeginTrace; - - /** - * The trace source fired when a packet ends the reception process from - * the medium. - * - * @see class CallBackTraceSource - * @deprecated The non-const \c Ptr argument is deprecated - * and will be changed to \c Ptrc in a future release. - */ - // NS_DEPRECATED() - tag for future removal - TracedCallback> m_phyRxEndTrace; - - /** - * The trace source fired when the phy layer drops a packet it has received. - * - * @see class CallBackTraceSource - * @deprecated The non-const \c Ptr argument is deprecated - * and will be changed to \c Ptrc in a future release. - */ - // NS_DEPRECATED() - tag for future removal - TracedCallback> m_phyRxDropTrace; - - SNRToBlockErrorRateManager* m_snrToBlockErrorRateManager; ///< SNR to block error rate manager - - /// Provides uniform random variables. - Ptr m_URNG; ///< URNG -}; - -} // namespace ns3 - -#endif /* OFDM_WIMAX_PHY_H */ diff --git a/src/wimax/model/snr-to-block-error-rate-manager.cc b/src/wimax/model/snr-to-block-error-rate-manager.cc deleted file mode 100644 index 0d2edaa37..000000000 --- a/src/wimax/model/snr-to-block-error-rate-manager.cc +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -#include "snr-to-block-error-rate-manager.h" - -#include "default-traces.h" -#include "snr-to-block-error-rate-record.h" - -#include "ns3/assert.h" -#include "ns3/log.h" - -#include -#include -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("SNRToBlockErrorRateManager"); - -SNRToBlockErrorRateManager::SNRToBlockErrorRateManager() -{ - for (int i = 0; i < 7; i++) - { - m_recordModulation[i] = new std::vector(); - } - m_activateLoss = false; - m_traceFilePath = "DefaultTraces"; -} - -SNRToBlockErrorRateManager::~SNRToBlockErrorRateManager() -{ - ClearRecords(); - for (int i = 0; i < 7; i++) - { - delete m_recordModulation[i]; - } -} - -void -SNRToBlockErrorRateManager::ClearRecords() -{ - for (int i = 0; i < 7; i++) - { - for (auto iter = m_recordModulation[i]->begin(); iter != m_recordModulation[i]->end(); - ++iter) - { - if (*iter) - { - delete (*iter); - (*iter) = 0; - } - } - m_recordModulation[i]->clear(); - } -} - -void -SNRToBlockErrorRateManager::ActivateLoss(bool loss) -{ - m_activateLoss = loss; -} - -void -SNRToBlockErrorRateManager::LoadTraces() -{ - std::ifstream traceFile; - ClearRecords(); - double snrValue; - double bitErrorRate; - double burstErrorRate; - double sigma2; - double I1; - double I2; - - for (int i = 0; i < 7; i++) - { - std::stringstream traceFilePath; - traceFilePath << m_traceFilePath << "/modulation" << i << ".txt"; - - traceFile.open(traceFilePath.str(), std::ifstream::in); - if (!traceFile.good()) - { - NS_LOG_INFO("Unable to load " << traceFilePath.str() << "!! Loading default traces..."); - LoadDefaultTraces(); - return; - } - while (traceFile.good()) - { - traceFile >> snrValue >> bitErrorRate >> burstErrorRate >> sigma2 >> I1 >> I2; - auto record = new SNRToBlockErrorRateRecord(snrValue, - bitErrorRate, - burstErrorRate, - sigma2, - I1, - I2); - m_recordModulation[i]->push_back(record); - } - traceFile.close(); - } - m_activateLoss = true; -} - -void -SNRToBlockErrorRateManager::LoadDefaultTraces() -{ - double snrValue; - double bitErrorRate; - double burstErrorRate; - double sigma2; - double I1; - double I2; - ClearRecords(); - for (unsigned int j = 0; j < sizeof(modulation0[0]) / sizeof(double); j++) - { - snrValue = modulation0[0][j]; - bitErrorRate = modulation0[1][j]; - burstErrorRate = modulation0[2][j]; - sigma2 = modulation0[3][j]; - I1 = modulation0[4][j]; - I2 = modulation0[5][j]; - auto record = - new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); - m_recordModulation[0]->push_back(record); - } - for (unsigned int j = 0; j < sizeof(modulation1[0]) / sizeof(double); j++) - { - snrValue = modulation1[0][j]; - bitErrorRate = modulation1[1][j]; - burstErrorRate = modulation1[2][j]; - sigma2 = modulation1[3][j]; - I1 = modulation1[4][j]; - I2 = modulation1[5][j]; - auto record = - new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); - m_recordModulation[1]->push_back(record); - } - for (unsigned int j = 0; j < sizeof(modulation2[0]) / sizeof(double); j++) - { - snrValue = modulation2[0][j]; - bitErrorRate = modulation2[1][j]; - burstErrorRate = modulation2[2][j]; - sigma2 = modulation2[3][j]; - I1 = modulation2[4][j]; - I2 = modulation2[5][j]; - auto record = - new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); - m_recordModulation[2]->push_back(record); - } - for (unsigned int j = 0; j < sizeof(modulation3[0]) / sizeof(double); j++) - { - snrValue = modulation3[0][j]; - bitErrorRate = modulation3[1][j]; - burstErrorRate = modulation3[2][j]; - sigma2 = modulation3[3][j]; - I1 = modulation3[4][j]; - I2 = modulation3[5][j]; - auto record = - new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); - m_recordModulation[3]->push_back(record); - } - for (unsigned int j = 0; j < sizeof(modulation4[0]) / sizeof(double); j++) - { - snrValue = modulation4[0][j]; - bitErrorRate = modulation4[1][j]; - burstErrorRate = modulation4[2][j]; - sigma2 = modulation4[3][j]; - I1 = modulation4[4][j]; - I2 = modulation4[5][j]; - auto record = - new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); - m_recordModulation[4]->push_back(record); - } - for (unsigned int j = 0; j < sizeof(modulation5[0]) / sizeof(double); j++) - { - snrValue = modulation5[0][j]; - bitErrorRate = modulation5[1][j]; - burstErrorRate = modulation5[2][j]; - sigma2 = modulation5[3][j]; - I1 = modulation5[4][j]; - I2 = modulation5[5][j]; - auto record = - new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); - m_recordModulation[5]->push_back(record); - } - for (unsigned int j = 0; j < sizeof(modulation6[0]) / sizeof(double); j++) - { - snrValue = modulation6[0][j]; - bitErrorRate = modulation6[1][j]; - burstErrorRate = modulation6[2][j]; - sigma2 = modulation6[3][j]; - I1 = modulation6[4][j]; - I2 = modulation6[5][j]; - auto record = - new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); - m_recordModulation[6]->push_back(record); - } - m_activateLoss = true; -} - -void -SNRToBlockErrorRateManager::ReLoadTraces() -{ - double snrValue; - double bitErrorRate; - double burstErrorRate; - double sigma2; - double I1; - double I2; - - ClearRecords(); - - std::ifstream traceFile; - - for (int i = 0; i < 7; i++) - { - std::stringstream traceFilePath; - traceFilePath << m_traceFilePath << "/Modulation" << i << ".txt"; - - traceFile.open(traceFilePath.str(), std::ifstream::in); - if (!traceFile.good()) - { - NS_LOG_INFO("Unable to load " << traceFilePath.str() << "!!Loading default traces..."); - LoadDefaultTraces(); - return; - } - while (traceFile.good()) - { - traceFile >> snrValue >> bitErrorRate >> burstErrorRate >> sigma2 >> I1 >> I2; - auto record = new SNRToBlockErrorRateRecord(snrValue, - bitErrorRate, - burstErrorRate, - sigma2, - I1, - I2); - - m_recordModulation[i]->push_back(record); - } - traceFile.close(); - } - m_activateLoss = true; -} - -void -SNRToBlockErrorRateManager::SetTraceFilePath(char* traceFilePath) -{ - m_traceFilePath = traceFilePath; -} - -std::string -SNRToBlockErrorRateManager::GetTraceFilePath() -{ - return m_traceFilePath; -} - -double -SNRToBlockErrorRateManager::GetBlockErrorRate(double SNR, uint8_t modulation) -{ - if (!m_activateLoss) - { - return 0; - } - - std::vector* record = nullptr; - - record = m_recordModulation[modulation]; - - if (SNR <= (record->at(0)->GetSNRValue())) - { - return 1; - } - if (SNR >= (record->at(record->size() - 1)->GetSNRValue())) - { - return 0; - } - - unsigned int i; - for (i = 0; i < record->size(); i++) - { - if (SNR < record->at(i)->GetSNRValue()) - { - break; - } - } - double intervalSize = (record->at(i)->GetSNRValue() - record->at(i - 1)->GetSNRValue()); - double coeff1 = (SNR - record->at(i - 1)->GetSNRValue()) / intervalSize; - double coeff2 = -1 * (SNR - record->at(i)->GetSNRValue()) / intervalSize; - double BlockErrorRate = coeff2 * (record->at(i - 1)->GetBlockErrorRate()) + - coeff1 * (record->at(i)->GetBlockErrorRate()); - return BlockErrorRate; -} - -SNRToBlockErrorRateRecord* -SNRToBlockErrorRateManager::GetSNRToBlockErrorRateRecord(double SNR, uint8_t modulation) -{ - if (!m_activateLoss) - { - return new SNRToBlockErrorRateRecord(SNR, 0, 0, 0, 0, 0); - } - - std::vector* record = nullptr; - record = m_recordModulation[modulation]; - - if (SNR <= (record->at(0)->GetSNRValue())) - { - return record->at(0)->Copy(); - } - if (SNR >= (record->at(record->size() - 1)->GetSNRValue())) - { - return record->at(record->size() - 1)->Copy(); - } - - unsigned int i; - for (i = 0; i < record->size(); i++) - { - if (SNR < record->at(i)->GetSNRValue()) - { - break; - } - } - double intervalSize = (record->at(i)->GetSNRValue() - record->at(i - 1)->GetSNRValue()); - double coeff1 = (SNR - record->at(i - 1)->GetSNRValue()) / intervalSize; - double coeff2 = -1 * (SNR - record->at(i)->GetSNRValue()) / intervalSize; - double BER = coeff2 * (record->at(i - 1)->GetBitErrorRate()) + - coeff1 * (record->at(i)->GetBitErrorRate()); - double BlcER = coeff2 * (record->at(i - 1)->GetBlockErrorRate()) + - coeff1 * (record->at(i)->GetBlockErrorRate()); - double sigma2 = - coeff2 * (record->at(i - 1)->GetSigma2()) + coeff1 * (record->at(i)->GetSigma2()); - double I1 = coeff2 * (record->at(i - 1)->GetI1()) + coeff1 * (record->at(i)->GetI1()); - double I2 = coeff2 * (record->at(i - 1)->GetI2()) + coeff1 * (record->at(i)->GetI2()); - - auto SNRToBlockErrorRate = new SNRToBlockErrorRateRecord(SNR, BER, BlcER, sigma2, I1, I2); - return SNRToBlockErrorRate; -} - -} // namespace ns3 diff --git a/src/wimax/model/snr-to-block-error-rate-manager.h b/src/wimax/model/snr-to-block-error-rate-manager.h deleted file mode 100644 index eca1b9ad7..000000000 --- a/src/wimax/model/snr-to-block-error-rate-manager.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -#ifndef SNR_TO_BLOCK_ERROR_RATE_MANAGER_H -#define SNR_TO_BLOCK_ERROR_RATE_MANAGER_H - -#include "snr-to-block-error-rate-record.h" - -#include "ns3/ptr.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * @brief This class handles the SNR to BlcER traces. - * - * A path to a repository containing trace files should be provided. - * If no repository is provided the traces from default-traces.h will be loaded. - * A valid repository should contain 7 files, one for each modulation - * and coding scheme. - * - * The names of the files should respect the following format: - * \c modulation.txt, _e.g._ - * \c modulation0.txt, \c modulation1.txt, _etc._ for - * modulation 0, modulation 1, and so on... - * - * The file format is ASCII with six columns as follows: - * - * -# The SNR value, - * -# The bit error rate BER, - * -# The block error rate BlcERm, - * -# The standard deviation on block error rate, - * -# The lower bound confidence interval for a given modulation, and - * -# The upper bound confidence interval for a given modulation. - */ -class SNRToBlockErrorRateManager -{ - public: - SNRToBlockErrorRateManager(); - ~SNRToBlockErrorRateManager(); - /** - * @brief Set the path of the repository containing the traces - * @param traceFilePath the path to the repository. - */ - void SetTraceFilePath(char* traceFilePath); - /** - * @return the path to the repository containing the traces. - */ - std::string GetTraceFilePath(); - /** - * @brief returns the Block Error Rate for a given modulation and SNR value - * @param SNR the SNR value - * @param modulation one of the seven MCS - * @return the Block Error Rate - */ - double GetBlockErrorRate(double SNR, uint8_t modulation); - SNRToBlockErrorRateRecord* - /** - * @brief returns a record of type SNRToBlockErrorRateRecord corresponding to a given modulation - * and SNR value - * @param SNR the SNR value - * @param modulation one of the seven MCS - * @return the Block Error Rate - */ - GetSNRToBlockErrorRateRecord(double SNR, uint8_t modulation); - /** - * @brief Loads the traces form the repository specified in the constructor or set by - * SetTraceFilePath function. If no repository is provided, default traces will be loaded from - * default-traces.h file - */ - - void LoadTraces(); - /** - * @brief Loads the default traces from default-traces.h file - */ - void LoadDefaultTraces(); - /** - * @brief Reloads the trace - */ - void ReLoadTraces(); - /** - * @brief If activate loss is called with false, all the returned BlcER will be 0 (no losses) - * @param loss true to activates losses - */ - void ActivateLoss(bool loss); - - private: - /// Clear records function - void ClearRecords(); - bool m_activateLoss; ///< activate loss - std::string m_traceFilePath; ///< trace file path - - std::vector* m_recordModulation[7]; ///< record modulation -}; -} // namespace ns3 - -#endif /* SNR_TO_BLOCK_ERROR_RATE_MANAGER_H */ diff --git a/src/wimax/model/snr-to-block-error-rate-record.cc b/src/wimax/model/snr-to-block-error-rate-record.cc deleted file mode 100644 index 279759ee2..000000000 --- a/src/wimax/model/snr-to-block-error-rate-record.cc +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -#include "snr-to-block-error-rate-record.h" - -#include "ns3/assert.h" -#include "ns3/simulator.h" - -namespace ns3 -{ - -SNRToBlockErrorRateRecord::SNRToBlockErrorRateRecord(double snrValue, - double bitErrorRate, - double blockErrorRate, - double sigma2, - double I1, - double I2) -{ - m_snrValue = snrValue; - m_bitErrorRate = bitErrorRate; - m_blockErrorRate = blockErrorRate; - m_sigma2 = sigma2; - m_i1 = I1; - m_i2 = I2; -} - -SNRToBlockErrorRateRecord* -SNRToBlockErrorRateRecord::Copy() const -{ - return (new SNRToBlockErrorRateRecord(m_snrValue, - m_bitErrorRate, - m_blockErrorRate, - m_sigma2, - m_i1, - m_i2)); -} - -double -SNRToBlockErrorRateRecord::GetSNRValue() const -{ - return m_snrValue; -} - -SNRToBlockErrorRateRecord::~SNRToBlockErrorRateRecord() -{ - m_snrValue = 0; - m_bitErrorRate = 0; - m_blockErrorRate = 0; - m_sigma2 = 0; - m_i1 = 0; - m_i2 = 0; -} - -double -SNRToBlockErrorRateRecord::GetBitErrorRate() const -{ - return m_bitErrorRate; -} - -double -SNRToBlockErrorRateRecord::GetBlockErrorRate() const -{ - return m_blockErrorRate; -} - -double -SNRToBlockErrorRateRecord::GetSigma2() const -{ - return m_sigma2; -} - -double -SNRToBlockErrorRateRecord::GetI1() const -{ - return m_i1; -} - -double -SNRToBlockErrorRateRecord::GetI2() const -{ - return m_i2; -} - -void -SNRToBlockErrorRateRecord::SetSNRValue(double snrValue) -{ - m_snrValue = snrValue; -} - -void -SNRToBlockErrorRateRecord::SetBitErrorRate(double bitErrorRate) -{ - m_bitErrorRate = bitErrorRate; -} - -void -SNRToBlockErrorRateRecord::SetBlockErrorRate(double blockErrorRate) -{ - m_blockErrorRate = blockErrorRate; -} - -void -SNRToBlockErrorRateRecord::SetI1(double i1) -{ - m_i1 = i1; -} - -void -SNRToBlockErrorRateRecord::SetI2(double i2) -{ - m_i2 = i2; -} - -} // namespace ns3 diff --git a/src/wimax/model/snr-to-block-error-rate-record.h b/src/wimax/model/snr-to-block-error-rate-record.h deleted file mode 100644 index c2ddbd7a3..000000000 --- a/src/wimax/model/snr-to-block-error-rate-record.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ - -#ifndef SNR_TO_BLOCK_ERROR_RATE_RECORD_H -#define SNR_TO_BLOCK_ERROR_RATE_RECORD_H - -namespace ns3 -{ - -/** - * @ingroup wimax - * @brief This class represents a record (handled by SnrToBlockErrorRate manager) that keeps a - * mapping between an SNR value and its corresponding (1) Bit Error Rate, (2) Block Error Rate, (3) - * Standard deviation, (4 and 5) confidence interval. - * - */ -class SNRToBlockErrorRateRecord -{ - public: - /** - * @brief creates a record and sets its values - * @param snrValue The SNR value - * @param bitErrorRate the BER - * @param BlockErrorRate the BlcER - * @param sigma2 the standard deviation - * @param I1 the lower boundary of the confidence interval - * @param I2 the upper boundary of the confidence interval - */ - SNRToBlockErrorRateRecord(double snrValue, - double bitErrorRate, - double BlockErrorRate, - double sigma2, - double I1, - double I2); - ~SNRToBlockErrorRateRecord(); - - /** - * @return the SNR value - */ - double GetSNRValue() const; - /** - * @return the BER value - */ - double GetBitErrorRate() const; - /** - * @return the BlcER value - */ - double GetBlockErrorRate() const; - /** - * @return the standard deviation - */ - double GetSigma2() const; - /** - * @return the lower boundary of the confidence interval - */ - double GetI1() const; - /** - * @return the upper boundary of the confidence interval - */ - double GetI2() const; - /** - * @brief copy a record - * @return a copy of this record - */ - SNRToBlockErrorRateRecord* Copy() const; - - /** - * @brief set the snr value - * @param snrValue the SNR value - */ - void SetSNRValue(double snrValue); - /** - * @brief set the BER value - * @param bitErrorRate the bit error rate value - */ - void SetBitErrorRate(double bitErrorRate); - /** - * @brief set the BlcER value - * @param blockErrorRate the block error rate value - */ - void SetBlockErrorRate(double blockErrorRate); - /** - * @brief set the lower boundary of the confidence interval - * @param i1 the lower boundary of the confidence interval - */ - void SetI1(double i1); - /** - * @brief set the upper boundary of the confidence interval - * @param i2 the upper boundary of the confidence interval - */ - void SetI2(double i2); - - private: - double m_snrValue; ///< SNR value - double m_bitErrorRate; ///< bit error rate - double m_blockErrorRate; ///< block error rate - double m_sigma2; ///< sigma2 - double m_i1; ///< The lower boundary of the confidence interval - double m_i2; ///< The upper boundary of the confidence interval -}; - -} // namespace ns3 - -#endif /* SNR_TO_BLOCK_ERROR_RATE_RECORD_H */ diff --git a/src/wimax/model/ss-link-manager.cc b/src/wimax/model/ss-link-manager.cc deleted file mode 100644 index 45471c693..000000000 --- a/src/wimax/model/ss-link-manager.cc +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "ss-link-manager.h" - -#include "burst-profile-manager.h" -#include "service-flow-manager.h" - -#include "ns3/enum.h" -#include "ns3/log.h" -#include "ns3/node.h" -#include "ns3/packet.h" -#include "ns3/pointer.h" -#include "ns3/simulator.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("SSLinkManager"); - -NS_OBJECT_ENSURE_REGISTERED(SSLinkManager); - -TypeId -SSLinkManager::GetTypeId() -{ - static TypeId tid = TypeId("ns3::SSLinkManager").SetParent().SetGroupName("Wimax"); - return tid; -} - -SSLinkManager::SSLinkManager(Ptr ss) - : m_ss(ss), - m_rangingStatus(WimaxNetDevice::RANGING_STATUS_EXPIRED), - m_bsEirp(65535), - m_eirXPIrMax(65535), - m_pTxIrMax(0), - m_initRangOppNumber(0), - m_contentionRangingRetries(0), - m_rngReqFrameNumber(0), - m_dlChnlNr(0), - m_frequency(0), - m_rangingIntervalFound(false), - m_nrRngReqsSent(0), - m_nrRngRspsRecvd(0), - m_nrInvitedPollsRecvd(0), - m_rangingCW(0), - m_rangingBO(0), - m_nrRangingTransOpps(0), - m_isBackoffSet(false), - m_rangingAnomalies(0) -{ -} - -SSLinkManager::~SSLinkManager() -{ - m_ss = nullptr; -} - -void -SSLinkManager::DoDispose() -{ - m_ss = nullptr; -} - -void -SSLinkManager::SetBsEirp(uint16_t bs_eirp) -{ - m_bsEirp = bs_eirp; -} - -void -SSLinkManager::SetEirXPIrMax(uint16_t eir_x_p_ir_max) -{ - m_eirXPIrMax = eir_x_p_ir_max; -} - -void -SSLinkManager::SetRangingIntervalFound(bool rangingIntervalFound) -{ - m_rangingIntervalFound = rangingIntervalFound; -} - -bool -SSLinkManager::GetRangingIntervalFound() const -{ - return m_rangingIntervalFound; -} - -void -SSLinkManager::SetNrRangingTransOpps(uint8_t nrRangingTransOpps) -{ - m_nrRangingTransOpps = nrRangingTransOpps; -} - -void -SSLinkManager::SetRangingCW(uint8_t rangingCW) -{ - m_rangingCW = rangingCW; -} - -void -SSLinkManager::IncrementNrInvitedPollsRecvd() -{ - m_nrInvitedPollsRecvd++; -} - -EventId -SSLinkManager::GetDlMapSyncTimeoutEvent() -{ - return m_dlMapSyncTimeoutEvent; -} - -void -SSLinkManager::StartScanning(SubscriberStationNetDevice::EventType type, bool deleteParameters) -{ - // temp parameter "type" just to check on expiry of which event the function was called - - if (deleteParameters) - { - DeleteUplinkParameters(); - } - - NS_ASSERT_MSG(!m_ss->IsRegistered(), - "Subscriber Station: Error while scanning: Already registered with a BS"); - - if (m_ss->GetState() != SubscriberStationNetDevice::SS_STATE_IDLE) - { - m_dlChnlNr++; - } - - // using max number of channel according to according to Section 8.5.1 of IEEE 802.16-2004 - // standard. - if (m_dlChnlNr >= 200) - { - m_dlChnlNr = 0; - } - - uint64_t dlChannel = m_ss->GetChannel(m_dlChnlNr); - - m_ss->SetState(SubscriberStationNetDevice::SS_STATE_SCANNING); - m_ss->GetPhy()->StartScanning(dlChannel, - m_ss->GetIntervalT20(), - MakeCallback(&SSLinkManager::EndScanning, this)); -} - -void -SSLinkManager::EndScanning(bool status, uint64_t frequency) -{ - if (status) - { - StartSynchronizing(); - m_frequency = frequency; - } - else - { - StartScanning(SubscriberStationNetDevice::EVENT_NONE, false); - } -} - -void -SSLinkManager::StartSynchronizing() -{ - m_ss->SetState(SubscriberStationNetDevice::SS_STATE_SYNCHRONIZING); - m_ss->SetTimer(Simulator::Schedule(m_ss->GetIntervalT21(), - &SSLinkManager::StartScanning, - this, - SubscriberStationNetDevice::EVENT_DL_MAP_SYNC_TIMEOUT, - false), - m_dlMapSyncTimeoutEvent); -} - -void -SSLinkManager::SendRangingRequest(uint8_t uiuc, uint16_t allocationSize) -{ - NS_ASSERT_MSG( - m_ss->GetState() == SubscriberStationNetDevice::SS_STATE_WAITING_REG_RANG_INTRVL || - m_ss->GetState() == SubscriberStationNetDevice::SS_STATE_WAITING_INV_RANG_INTRVL, - "SS: Error while sending a ranging request: the ss state should be " - "SS_STATE_WAITING_REG_RANG_INTRVL or SS_STATE_WAITING_INV_RANG_INTRVL"); - - if (m_nrRngReqsSent == 0) // sending the first time - { - m_pTxIrMax = CalculateMaxIRSignalStrength(); - m_rngreq.SetReqDlBurstProfile(m_ss->GetBurstProfileManager()->GetBurstProfileToRequest()); - m_rngreq.SetMacAddress(m_ss->GetMacAddress()); - } - else - { - m_pTxIrMax++; - if (m_nrRngRspsRecvd > 0) - { - m_rngreq.SetRangingAnomalies(m_rangingAnomalies); - } - } - - Ptr packet = Create(); - Ptr burst = CreateObject(); - - packet->AddHeader(m_rngreq); - packet->AddHeader(ManagementMessageType(ManagementMessageType::MESSAGE_TYPE_RNG_REQ)); - - Ptr connection; - - if (m_rangingStatus == WimaxNetDevice::RANGING_STATUS_CONTINUE) - { - connection = m_ss->GetBasicConnection(); - } - else // have been assigned BCID, means currently adjusting parameters - { - connection = m_ss->GetInitialRangingConnection(); - } - - m_ss->Enqueue(packet, MacHeaderType(), connection); - - m_ss->SetState(SubscriberStationNetDevice::SS_STATE_WAITING_RNG_RSP); - m_ss->SetTimer( - Simulator::Schedule(m_ss->GetIntervalT3(), &SSLinkManager::StartContentionResolution, this), - m_waitForRngRspEvent); - m_nrRngReqsSent++; - - NS_ASSERT_MSG(allocationSize == - m_ss->GetCurrentUcd().GetChannelEncodings().GetRangReqOppSize() / - m_ss->GetPhy()->GetPsPerSymbol(), - "SS: Error while sending a ranging request: the allocation size is not correct"); - - // will work even if connection is not passed (i.e. null is passed) as scheduler will - // automatically select the same connection - m_ss->SendBurst(uiuc, allocationSize, connection); -} - -void -SSLinkManager::StartContentionResolution() -{ - NS_ASSERT_MSG( - m_ss->GetState() == SubscriberStationNetDevice::SS_STATE_WAITING_RNG_RSP || - m_ss->GetState() == SubscriberStationNetDevice::SS_STATE_WAITING_REG_RANG_INTRVL || - m_ss->GetState() == SubscriberStationNetDevice::SS_STATE_ADJUSTING_PARAMETERS, - "SS: Can not start connection resolution: The SS state should be SS_STATE_WAITING_RNG_RSP " - "or SS_STATE_WAITING_REG_RANG_INTRVL or SS_STATE_ADJUSTING_PARAMETERS"); - - if (m_ss->GetState() == SubscriberStationNetDevice::SS_STATE_WAITING_RNG_RSP) - { - m_ss->SetState(SubscriberStationNetDevice::SS_STATE_WAITING_REG_RANG_INTRVL); - IncreaseRangingRequestCW(); - m_contentionRangingRetries++; - } - else if (m_ss->GetState() == SubscriberStationNetDevice::SS_STATE_ADJUSTING_PARAMETERS) - { - m_ss->SetState(SubscriberStationNetDevice::SS_STATE_WAITING_REG_RANG_INTRVL); - } - - if (m_contentionRangingRetries == m_ss->GetMaxContentionRangingRetries()) - { - StartScanning(SubscriberStationNetDevice::EVENT_NONE, false); - } - else - { - if (!m_isBackoffSet) - { - SelectRandomBackoff(); - } - } -} - -void -SSLinkManager::PerformBackoff() -{ - Time deferTime; - Time timeToAllocation; - uint16_t nrPsPerRangOpp = m_ss->GetCurrentUcd().GetChannelEncodings().GetRangReqOppSize(); - uint16_t oppSize = m_ss->GetCurrentUcd().GetChannelEncodings().GetRangReqOppSize() / - m_ss->GetPhy()->GetPsPerSymbol(); - - for (uint8_t deferTOs = 0; deferTOs < m_nrRangingTransOpps; deferTOs++) - { - if (m_rangingBO == 0) - { - deferTime = - Seconds(deferTOs * nrPsPerRangOpp * m_ss->GetPhy()->GetPsDuration().GetSeconds()); - timeToAllocation = m_ss->GetTimeToAllocation(deferTime); - - Simulator::Schedule(timeToAllocation, - &SSLinkManager::SendRangingRequest, - this, - OfdmUlBurstProfile::UIUC_INITIAL_RANGING, - oppSize); - - m_rngReqFrameNumber = m_ss->GetNrFrames(); - m_initRangOppNumber = deferTOs + 1; - - m_isBackoffSet = false; - break; - } - m_rangingBO--; - } -} - -void -SSLinkManager::SelectRandomBackoff() -{ - NS_ASSERT_MSG( - m_rangingCW != 0 && m_rangingBO == 0, - "be sure that CW has been set and BO is not already set"); // ensuring CW has been set and - // BO is not already set - - m_rangingBO = (rand() % m_rangingCW); - m_isBackoffSet = true; -} - -void -SSLinkManager::IncreaseRangingRequestCW() -{ - m_rangingCW = - std::min(uint8_t((m_rangingCW * 2 + 1) - 1), m_ss->GetCurrentUcd().GetRangingBackoffEnd()); -} - -void -SSLinkManager::ResetRangingRequestCW() -{ - m_rangingCW = - (uint8_t)std::pow(2.0, (double)m_ss->GetCurrentUcd().GetRangingBackoffStart()) - 1; -} - -void -SSLinkManager::PerformRanging(Cid cid, RngRsp rngrsp) -{ - // need to distinguish initial ranging or periodic ranging - - if (cid == m_ss->GetInitialRangingConnection()->GetCid()) - { - if (rngrsp.GetFrameNumber() == m_rngReqFrameNumber && - rngrsp.GetInitRangOppNumber() == m_initRangOppNumber) - { - Simulator::Cancel(m_waitForRngRspEvent); - m_nrRngRspsRecvd++; - - // RNG-REQ was undecodable - ResetRangingRequestCW(); - AdjustRangingParameters(rngrsp); - m_ss->SetState(SubscriberStationNetDevice::SS_STATE_ADJUSTING_PARAMETERS); - return; - } - - if (m_ss->GetAddress() != rngrsp.GetMacAddress()) - { - return; - } - - m_ss->SetBasicConnection(CreateObject(rngrsp.GetBasicCid(), Cid::BASIC)); - - m_ss->SetPrimaryConnection( - CreateObject(rngrsp.GetPrimaryCid(), Cid::PRIMARY)); - m_ss->SetAreManagementConnectionsAllocated(true); - } - else - { - // either periodic ranging or an additional RNG-RSP during initial ranging - } - - m_nrRngRspsRecvd++; - if (m_waitForRngRspEvent.IsPending()) - { - Simulator::Cancel(m_waitForRngRspEvent); - } - - m_rangingStatus = (WimaxNetDevice::RangingStatus)rngrsp.GetRangStatus(); - - NS_ASSERT_MSG(m_rangingStatus == WimaxNetDevice::RANGING_STATUS_CONTINUE || - m_rangingStatus == WimaxNetDevice::RANGING_STATUS_ABORT || - m_rangingStatus == WimaxNetDevice::RANGING_STATUS_SUCCESS, - "SS: Can not perform ranging: the ranging status should be " - "RANGING_STATUS_CONTINUE or RANGING_STATUS_ABORT or RANGING_STATUS_SUCCESS"); - - if (m_rangingStatus == WimaxNetDevice::RANGING_STATUS_ABORT) - { - if (rngrsp.GetDlFreqOverride()) - { - // code to move to new channel/frequency goes here - } - // deassigning basic and primary CIDs - m_ss->SetBasicConnection(nullptr); - m_ss->SetPrimaryConnection(nullptr); - m_ss->SetAreManagementConnectionsAllocated(false); - } - else - { - AdjustRangingParameters(rngrsp); - - if (m_rangingStatus == WimaxNetDevice::RANGING_STATUS_SUCCESS) - { - m_ss->SetState(SubscriberStationNetDevice::SS_STATE_REGISTERED); - // initiate service flows - if (m_ss->HasServiceFlows() && !m_ss->GetAreServiceFlowsAllocated()) - { - m_ss->GetServiceFlowManager()->InitiateServiceFlows(); - } - - NegotiateBasicCapabilities(); - } - else - { - m_ss->SetState(SubscriberStationNetDevice::SS_STATE_WAITING_INV_RANG_INTRVL); - // wait for invited ranging interval assigned to its Basic CID - } - } -} - -void -SSLinkManager::DeleteUplinkParameters() -{ - m_ss->SetCurrentUcd(Ucd()); -} - -bool -SSLinkManager::IsUlChannelUsable() -{ - // don't know how to check if usable, see Figure 58. - return true; // temporarily assuming usable -} - -void -SSLinkManager::AdjustRangingParameters(const RngRsp& rngrsp) -{ -#if 0 /* a template for future implementation following */ - bool successful = true; - uint8_t temp = rngrsp.GetTimingAdjust (); - temp = rngrsp.GetPowerLevelAdjust (); - temp = rngrsp.GetOffsetFreqAdjust (); - - // code for adjusting parameters goes here - - if (!successful) - { - // code for setting ranging anomalies goes here - } -#endif -} - -void -SSLinkManager::NegotiateBasicCapabilities() -{ - // code to nagotiate basic capabilities goes here, ignored until very advanced stages -} - -uint16_t -SSLinkManager::CalculateMaxIRSignalStrength() -{ - // SS obtains RSSI measurement from the OFDM downlink preambles using a complex formula, page - // 486 - uint16_t rss = 1; - - if (m_bsEirp == 65535 || m_eirXPIrMax == 65535) - { - return GetMinTransmitPowerLevel(); - } - else - { - return m_eirXPIrMax + m_bsEirp - rss; - } - - return 0; -} - -uint16_t -SSLinkManager::GetMinTransmitPowerLevel() -{ - // code to calculate minimum transmit power level of the SS, see page 189 of amendment - return 10; // temp -} - -void -SSLinkManager::ScheduleScanningRestart(Time interval, - SubscriberStationNetDevice::EventType eventType, - bool deleteUlParameters, - EventId& eventId) -{ - m_ss->SetTimer(Simulator::Schedule(interval, - &SSLinkManager::StartScanning, - this, - eventType, - deleteUlParameters), - eventId); -} - -} // namespace ns3 diff --git a/src/wimax/model/ss-link-manager.h b/src/wimax/model/ss-link-manager.h deleted file mode 100644 index a71bb69e2..000000000 --- a/src/wimax/model/ss-link-manager.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#ifndef LINK_MANAGER_H -#define LINK_MANAGER_H - -#include "cid.h" -#include "mac-messages.h" -#include "ss-net-device.h" -#include "wimax-net-device.h" - -#include "ns3/event-id.h" -#include "ns3/nstime.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * @brief this class implements the link manager of subscriber station net device. An ss link - * manager is responsible for link scanning and ranging - */ -class SSLinkManager : public Object -{ - public: - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - /** - * Constructor - * - * @param ss subscriber station device - */ - SSLinkManager(Ptr ss); - ~SSLinkManager() override; - void DoDispose() override; - - /** - * Set BS EIRP - * @param bs_eirp the BS EIRP - */ - void SetBsEirp(uint16_t bs_eirp); - /** - * Set EIRX IR maximum - * @param eir_x_p_ir_max the EIRX IR maximum - */ - void SetEirXPIrMax(uint16_t eir_x_p_ir_max); - /** - * Set ranging interval found - * @param rangingIntervalFound the ranging interval found - */ - void SetRangingIntervalFound(bool rangingIntervalFound); - /** - * Get ranging interval found - * @returns the ranging interval found - */ - bool GetRangingIntervalFound() const; - /** - * Set NR ranging trans opps - * @param nrRangingTransOpps the NR ranging trans opps - */ - void SetNrRangingTransOpps(uint8_t nrRangingTransOpps); - /** - * Set ranging CW - * @param rangingCW the ranging CW - */ - void SetRangingCW(uint8_t rangingCW); - /// Increment NR invited polls received - void IncrementNrInvitedPollsRecvd(); - /** - * Get DL map sync timeout event - * @returns the event ID - */ - EventId GetDlMapSyncTimeoutEvent(); - - /** - * Perform ranging - * @param cid the CID - * @param rngrsp the ranging response - */ - void PerformRanging(Cid cid, RngRsp rngrsp); - /** - * Start scanning - * @param type the event type - * @param deleteParameters the delete parameters - */ - void StartScanning(SubscriberStationNetDevice::EventType type, bool deleteParameters); - /** - * Send ranging request - * @param uiuc the UIUC - * @param allocationSize the allocation size - */ - void SendRangingRequest(uint8_t uiuc, uint16_t allocationSize); - /// Start contention resolution - void StartContentionResolution(); - /// Perform backoff - void PerformBackoff(); - /** - * Is UL channel usable - * @returns the UL channel usable flag - */ - bool IsUlChannelUsable(); - /** - * Schedule scanning request - * @param interval the scanning request interval - * @param eventType event type - * @param deleteUlParameters the delete UL parameters - * @param eventId the event ID - */ - void ScheduleScanningRestart(Time interval, - SubscriberStationNetDevice::EventType eventType, - bool deleteUlParameters, - EventId& eventId); - - private: - /// type conversion operator - SSLinkManager(const SSLinkManager&); - /** - * assignment operator - * @returns SS link manager - */ - SSLinkManager& operator=(const SSLinkManager&); - - /** - * End scanning - * @param status the end status - * @param frequency the frequency - */ - void EndScanning(bool status, uint64_t frequency); - /// Start synchronizing - void StartSynchronizing(); - /** - * Search for DL channel - * @param channel the DL channel - * @returns true if found - */ - bool SearchForDlChannel(uint8_t channel); - /// Select random backoff - void SelectRandomBackoff(); - /// Increase rnaging request CW - void IncreaseRangingRequestCW(); - /// Reset ranging request CW - void ResetRangingRequestCW(); - /// Delete uplink parameters - void DeleteUplinkParameters(); - /** - * Adjust ranging parameters - * @param rngrsp the ranging response - */ - void AdjustRangingParameters(const RngRsp& rngrsp); - /// Negotiate basic capabilities - void NegotiateBasicCapabilities(); - /** - * Calculate maximum IR signal strength - * @returns the maximum IR signal strength - */ - uint16_t CalculateMaxIRSignalStrength(); - /** - * Get minimum transmit power level - * @returns the minimum transmit power level - */ - uint16_t GetMinTransmitPowerLevel(); - - Ptr m_ss; ///< subscriber station device - - WimaxNetDevice::RangingStatus m_rangingStatus; ///< ranging status - // initial ranging parameters obtained from DCD (in channel encodings) - uint16_t m_bsEirp; ///< BS EIRP - uint16_t m_eirXPIrMax; ///< initial ranging maximum equivalent isotropic received power at BS - uint16_t m_pTxIrMax; ///< maximum transmit signal strength for initial ranging calculated by SS - - uint8_t m_initRangOppNumber; ///< Initial Ranging opportunity (1–255) in which SS transmitted - ///< the RNG_REQ - uint8_t m_contentionRangingRetries; ///< contention ranging retries - uint32_t m_rngReqFrameNumber; ///< frame number in which SS sent RNG_REQ message - RngReq m_rngreq; ///< rng request - - uint8_t m_dlChnlNr; ///< indicates the channel/frequency currently the SS is scanning - uint64_t m_frequency; ///< frequency on which it is currently operating, i.e., where scanning - ///< was successful - bool m_rangingIntervalFound; ///< ranging interval found - - // stats members - uint16_t m_nrRngReqsSent; ///< number rang requests sent - uint16_t m_nrRngRspsRecvd; ///< number rang responses received - uint16_t m_nrInvitedPollsRecvd; ///< number invited polls received - - uint8_t m_rangingCW; ///< ranging CW - uint8_t m_rangingBO; ///< ranging BO - uint8_t m_nrRangingTransOpps; ///< number ranging trans opps - bool m_isBackoffSet; ///< is backoff set - uint8_t m_rangingAnomalies; ///< ranging anomalies - - EventId m_waitForRngRspEvent; ///< wait for rang response event - EventId m_dlMapSyncTimeoutEvent; ///< DL map sync timeout event -}; - -} // namespace ns3 - -#endif /* LINK_MANAGER_H */ diff --git a/src/wimax/model/ss-manager.cc b/src/wimax/model/ss-manager.cc deleted file mode 100644 index 01fc7479d..000000000 --- a/src/wimax/model/ss-manager.cc +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "ss-manager.h" - -#include "service-flow.h" - -#include "ns3/log.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("SSManager"); - -NS_OBJECT_ENSURE_REGISTERED(SSManager); - -TypeId -SSManager::GetTypeId() -{ - static TypeId tid = TypeId("ns3::SSManager").SetParent().SetGroupName("Wimax"); - return tid; -} - -SSManager::SSManager() -{ - m_ssRecords = new std::vector(); -} - -SSManager::~SSManager() -{ - for (auto iter = m_ssRecords->begin(); iter != m_ssRecords->end(); ++iter) - { - delete *iter; - } - delete m_ssRecords; - m_ssRecords = nullptr; -} - -SSRecord* -SSManager::CreateSSRecord(const Mac48Address& macAddress) -{ - auto ssRecord = new SSRecord(macAddress); - m_ssRecords->push_back(ssRecord); - return ssRecord; -} - -SSRecord* -SSManager::GetSSRecord(const Mac48Address& macAddress) const -{ - for (auto iter = m_ssRecords->begin(); iter != m_ssRecords->end(); ++iter) - { - if ((*iter)->GetMacAddress() == macAddress) - { - return *iter; - } - } - - NS_LOG_DEBUG("GetSSRecord: SSRecord not found!"); - return nullptr; -} - -SSRecord* -SSManager::GetSSRecord(Cid cid) const -{ - for (auto iter1 = m_ssRecords->begin(); iter1 != m_ssRecords->end(); ++iter1) - { - SSRecord* ssRecord = *iter1; - if (ssRecord->GetBasicCid() == cid || ssRecord->GetPrimaryCid() == cid) - { - return ssRecord; - } - else - { - std::vector sf = ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_ALL); - for (auto iter2 = sf.begin(); iter2 != sf.end(); ++iter2) - { - if ((*iter2)->GetConnection()->GetCid() == cid) - { - return ssRecord; - } - } - } - } - - NS_LOG_DEBUG("GetSSRecord: SSRecord not found!"); - return nullptr; -} - -std::vector* -SSManager::GetSSRecords() const -{ - return m_ssRecords; -} - -bool -SSManager::IsInRecord(const Mac48Address& macAddress) const -{ - for (auto iter = m_ssRecords->begin(); iter != m_ssRecords->end(); ++iter) - { - if ((*iter)->GetMacAddress() == macAddress) - { - return true; - } - } - return false; -} - -bool -SSManager::IsRegistered(const Mac48Address& macAddress) const -{ - SSRecord* ssRecord = GetSSRecord(macAddress); - return ssRecord != nullptr && - ssRecord->GetRangingStatus() == WimaxNetDevice::RANGING_STATUS_SUCCESS; -} - -void -SSManager::DeleteSSRecord(Cid cid) -{ - for (auto iter1 = m_ssRecords->begin(); iter1 != m_ssRecords->end(); ++iter1) - { - SSRecord* ssRecord = *iter1; - if (ssRecord->GetBasicCid() == cid || ssRecord->GetPrimaryCid() == cid) - { - m_ssRecords->erase(iter1); - return; - } - else - { - std::vector sf = ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_ALL); - for (auto iter2 = sf.begin(); iter2 != sf.end(); ++iter2) - { - if ((*iter2)->GetConnection()->GetCid() == cid) - { - m_ssRecords->erase(iter1); - return; - } - } - } - } -} - -Mac48Address -SSManager::GetMacAddress(Cid cid) const -{ - return GetSSRecord(cid)->GetMacAddress(); -} - -uint32_t -SSManager::GetNSSs() const -{ - return m_ssRecords->size(); -} - -uint32_t -SSManager::GetNRegisteredSSs() const -{ - uint32_t nrSS = 0; - for (auto iter = m_ssRecords->begin(); iter != m_ssRecords->end(); ++iter) - { - if ((*iter)->GetRangingStatus() == WimaxNetDevice::RANGING_STATUS_SUCCESS) - { - nrSS++; - } - } - return nrSS; -} - -} // namespace ns3 diff --git a/src/wimax/model/ss-manager.h b/src/wimax/model/ss-manager.h deleted file mode 100644 index f512d5ed1..000000000 --- a/src/wimax/model/ss-manager.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#ifndef SS_MANAGER_H -#define SS_MANAGER_H - -#include "cid.h" -#include "ss-record.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * @brief this class manages a list of SSrecords - * @see SSrecord - */ -class SSManager : public Object -{ - public: - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - SSManager(); - ~SSManager() override; - /** - * Create SS record - * @param macAddress the MAC address - * @returns pointer to the SS record - */ - SSRecord* CreateSSRecord(const Mac48Address& macAddress); - /** - * Get SS record - * @param macAddress the MAC address - * @returns pointer to the SS record - */ - SSRecord* GetSSRecord(const Mac48Address& macAddress) const; - /** - * @brief returns the ssrecord which has been assigned this cid. Since - * different types of cids (basic, primary, transport) are assigned - * different values, all cids (basic, primary and transport) of the - * ssrecord are matched. - * @param cid the cid to be matched - * @return pointer to the ss record matching the cid - */ - SSRecord* GetSSRecord(Cid cid) const; - /** - * Get SS records - * @returns a vector of pointers to the SS records - */ - std::vector* GetSSRecords() const; - /** - * Check if address is in record - * @param macAddress the MAC address - * @returns whether the address is in the record - */ - bool IsInRecord(const Mac48Address& macAddress) const; - /** - * Check if address is registered - * @param macAddress the MAC address - * @returns whether the address is registered - */ - bool IsRegistered(const Mac48Address& macAddress) const; - /** - * Delete SS record - * @param cid the CID - */ - void DeleteSSRecord(Cid cid); - /** - * Get MAC address by CID - * @param cid the CID - * @returns the MAC address - */ - Mac48Address GetMacAddress(Cid cid) const; - /** - * Get number of SSs - * @returns the number of SSs - */ - uint32_t GetNSSs() const; - /** - * Get number of registered SSs - * @returns the number of registered SSs - */ - uint32_t GetNRegisteredSSs() const; - - private: - std::vector* m_ssRecords; ///< the SS records -}; - -} // namespace ns3 - -#endif /* SS_MANAGER_H */ diff --git a/src/wimax/model/ss-net-device.cc b/src/wimax/model/ss-net-device.cc deleted file mode 100644 index 6c3450684..000000000 --- a/src/wimax/model/ss-net-device.cc +++ /dev/null @@ -1,1356 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "ss-net-device.h" - -#include "bandwidth-manager.h" -#include "burst-profile-manager.h" -#include "connection-manager.h" -#include "dl-mac-messages.h" -#include "service-flow-manager.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-link-manager.h" -#include "ss-scheduler.h" -#include "ul-mac-messages.h" -#include "wimax-mac-queue.h" -#include "wimax-phy.h" - -#include "ns3/config.h" -#include "ns3/enum.h" -#include "ns3/node.h" -#include "ns3/packet-burst.h" -#include "ns3/pointer.h" -#include "ns3/simulator.h" -#include "ns3/trace-source-accessor.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("SubscriberStationNetDevice"); - -NS_OBJECT_ENSURE_REGISTERED(SubscriberStationNetDevice); - -Time -SubscriberStationNetDevice::GetDefaultLostDlMapInterval() -{ - return MicroSeconds(500000); -} - -TypeId -SubscriberStationNetDevice::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::SubscriberStationNetDevice") - - .SetParent() - .SetGroupName("Wimax") - - .AddConstructor() - - .AddAttribute("BasicConnection", - "Basic connection", - PointerValue(), - MakePointerAccessor(&SubscriberStationNetDevice::m_basicConnection), - MakePointerChecker()) - - .AddAttribute("PrimaryConnection", - "Primary connection", - PointerValue(), - MakePointerAccessor(&SubscriberStationNetDevice::m_primaryConnection), - MakePointerChecker()) - - .AddAttribute("LostDlMapInterval", - "Time since last received DL-MAP message before downlink synchronization " - "is considered lost. Maximum is 600ms", - TimeValue(Seconds(0.5)), - MakeTimeAccessor(&SubscriberStationNetDevice::GetLostDlMapInterval, - &SubscriberStationNetDevice::SetLostDlMapInterval), - MakeTimeChecker()) - - .AddAttribute("LostUlMapInterval", - "Time since last received UL-MAP before uplink synchronization is " - "considered lost, maximum is 600.", - TimeValue(MilliSeconds(500)), - MakeTimeAccessor(&SubscriberStationNetDevice::GetLostUlMapInterval, - &SubscriberStationNetDevice::SetLostUlMapInterval), - MakeTimeChecker()) - - .AddAttribute("MaxDcdInterval", - "Maximum time between transmission of DCD messages. Maximum is 10s", - TimeValue(Seconds(10)), - MakeTimeAccessor(&SubscriberStationNetDevice::GetMaxDcdInterval, - &SubscriberStationNetDevice::SetMaxDcdInterval), - MakeTimeChecker()) - - .AddAttribute("MaxUcdInterval", - "Maximum time between transmission of UCD messages. Maximum is 10s", - TimeValue(Seconds(10)), - MakeTimeAccessor(&SubscriberStationNetDevice::GetMaxUcdInterval, - &SubscriberStationNetDevice::SetMaxUcdInterval), - MakeTimeChecker()) - - .AddAttribute("IntervalT1", - "Wait for DCD timeout. Maximum is 5*maxDcdInterval", - TimeValue(Seconds(50)), - MakeTimeAccessor(&SubscriberStationNetDevice::GetIntervalT1, - &SubscriberStationNetDevice::SetIntervalT1), - MakeTimeChecker()) - - .AddAttribute("IntervalT2", - "Wait for broadcast ranging timeout, i.e., wait for initial ranging " - "opportunity. Maximum is 5*Ranging interval", - TimeValue(Seconds(10)), - MakeTimeAccessor(&SubscriberStationNetDevice::GetIntervalT2, - &SubscriberStationNetDevice::SetIntervalT2), - MakeTimeChecker()) - - .AddAttribute("IntervalT3", - "ranging Response reception timeout following the transmission of a " - "ranging request. Maximum is 200ms", - TimeValue(Seconds(0.2)), - MakeTimeAccessor(&SubscriberStationNetDevice::GetIntervalT3, - &SubscriberStationNetDevice::SetIntervalT3), - MakeTimeChecker()) - - .AddAttribute("IntervalT7", - "wait for DSA/DSC/DSD Response timeout. Maximum is 1s", - TimeValue(Seconds(0.1)), - MakeTimeAccessor(&SubscriberStationNetDevice::GetIntervalT7, - &SubscriberStationNetDevice::SetIntervalT7), - MakeTimeChecker()) - - .AddAttribute("IntervalT12", - "Wait for UCD descriptor.Maximum is 5*MaxUcdInterval", - TimeValue(Seconds(10)), - MakeTimeAccessor(&SubscriberStationNetDevice::GetIntervalT12, - &SubscriberStationNetDevice::SetIntervalT12), - MakeTimeChecker()) - - .AddAttribute( - "IntervalT20", - "Time the SS searches for preambles on a given channel. Minimum is 2 MAC frames", - TimeValue(Seconds(0.5)), - MakeTimeAccessor(&SubscriberStationNetDevice::GetIntervalT20, - &SubscriberStationNetDevice::SetIntervalT20), - MakeTimeChecker()) - - .AddAttribute("IntervalT21", - "time the SS searches for (decodable) DL-MAP on a given channel", - TimeValue(Seconds(10)), - MakeTimeAccessor(&SubscriberStationNetDevice::GetIntervalT21, - &SubscriberStationNetDevice::SetIntervalT21), - MakeTimeChecker()) - - .AddAttribute( - "MaxContentionRangingRetries", - "Number of retries on contention Ranging Requests", - UintegerValue(16), - MakeUintegerAccessor(&SubscriberStationNetDevice::GetMaxContentionRangingRetries, - &SubscriberStationNetDevice::SetMaxContentionRangingRetries), - MakeUintegerChecker(1, 16)) - - .AddAttribute("SSScheduler", - "The ss scheduler attached to this device.", - PointerValue(), - MakePointerAccessor(&SubscriberStationNetDevice::GetScheduler, - &SubscriberStationNetDevice::SetScheduler), - MakePointerChecker()) - - .AddAttribute("LinkManager", - "The ss link manager attached to this device.", - PointerValue(), - MakePointerAccessor(&SubscriberStationNetDevice::GetLinkManager, - &SubscriberStationNetDevice::SetLinkManager), - MakePointerChecker()) - - .AddAttribute("Classifier", - "The ss classifier attached to this device.", - PointerValue(), - MakePointerAccessor(&SubscriberStationNetDevice::GetIpcsClassifier, - &SubscriberStationNetDevice::SetIpcsPacketClassifier), - MakePointerChecker()) - - .AddTraceSource( - "SSTxDrop", - "A packet has been dropped in the MAC layer before being queued for transmission.", - MakeTraceSourceAccessor(&SubscriberStationNetDevice::m_ssTxDropTrace), - "ns3::Packet::TracedCallback") - - .AddTraceSource( - "SSPromiscRx", - "A packet has been received by this device, has been passed up from the physical " - "layer " - "and is being forwarded up the local protocol stack. This is a promiscuous trace,", - MakeTraceSourceAccessor(&SubscriberStationNetDevice::m_ssPromiscRxTrace), - "ns3::Packet::TracedCallback") - - .AddTraceSource("SSRx", - "A packet has been received by this device, has been passed up from " - "the physical layer " - "and is being forwarded up the local protocol stack. This is a " - "non-promiscuous trace,", - MakeTraceSourceAccessor(&SubscriberStationNetDevice::m_ssRxTrace), - "ns3::Packet::TracedCallback") - - .AddTraceSource("SSRxDrop", - "A packet has been dropped in the MAC layer after it has been passed " - "up from the physical " - "layer.", - MakeTraceSourceAccessor(&SubscriberStationNetDevice::m_ssRxDropTrace), - "ns3::Packet::TracedCallback"); - return tid; -} - -SubscriberStationNetDevice::SubscriberStationNetDevice() -{ - InitSubscriberStationNetDevice(); -} - -void -SubscriberStationNetDevice::InitSubscriberStationNetDevice() -{ - m_lostDlMapInterval = MilliSeconds(500); - m_lostUlMapInterval = MilliSeconds(500); - m_maxDcdInterval = Seconds(10); - m_maxUcdInterval = Seconds(10); - m_intervalT1 = Seconds(5 * m_maxDcdInterval.GetSeconds()); - m_intervalT2 = Seconds(5 * 2); // shall be 5 * RangingInterval, if ranging interval=see T2 at - // page 638) means Initial Ranging Interval=see page 637) - m_intervalT3 = MilliSeconds(200); - m_intervalT7 = Seconds(0.1); // maximum is 1 - m_intervalT12 = Seconds(5 * m_maxUcdInterval.GetSeconds()); - m_intervalT21 = Seconds(11); - m_maxContentionRangingRetries = 16; - m_dcdCount = 0; - m_baseStationId = Mac48Address("00:00:00:00:00:00"); - m_ucdCount = 0; - m_allocationStartTime = 0; - m_nrDlMapElements = 0; - m_nrUlMapElements = 0; - m_nrDlMapRecvd = 0; - m_nrUlMapRecvd = 0; - m_nrDcdRecvd = 0; - m_nrUcdRecvd = 0; - m_modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - m_areManagementConnectionsAllocated = false; - m_areServiceFlowsAllocated = false; - - m_basicConnection = nullptr; - m_primaryConnection = nullptr; - - m_dlBurstProfile = new OfdmDlBurstProfile(); - m_ulBurstProfile = new OfdmUlBurstProfile(); - m_classifier = CreateObject(); - m_linkManager = CreateObject(this); - m_scheduler = CreateObject(this); - m_serviceFlowManager = CreateObject(this); -} - -SubscriberStationNetDevice::SubscriberStationNetDevice(Ptr node, Ptr phy) -{ - InitSubscriberStationNetDevice(); - this->SetNode(node); - this->SetPhy(phy); -} - -SubscriberStationNetDevice::~SubscriberStationNetDevice() -{ -} - -void -SubscriberStationNetDevice::DoDispose() -{ - delete m_dlBurstProfile; - delete m_ulBurstProfile; - m_scheduler = nullptr; - m_serviceFlowManager = nullptr; - m_basicConnection = nullptr; - m_primaryConnection = nullptr; - m_classifier = nullptr; - m_dlBurstProfile = nullptr; - m_ulBurstProfile = nullptr; - - m_linkManager = nullptr; - - m_asciiTxQueueEnqueueCb.Nullify(); - m_asciiTxQueueDequeueCb.Nullify(); - m_asciiTxQueueDropCb.Nullify(); - - WimaxNetDevice::DoDispose(); -} - -void -SubscriberStationNetDevice::SetLostDlMapInterval(Time lostDlMapInterval) -{ - m_lostDlMapInterval = lostDlMapInterval; -} - -Time -SubscriberStationNetDevice::GetLostDlMapInterval() const -{ - return m_lostDlMapInterval; -} - -void -SubscriberStationNetDevice::SetLostUlMapInterval(Time lostUlMapInterval) -{ - m_lostUlMapInterval = lostUlMapInterval; -} - -Time -SubscriberStationNetDevice::GetLostUlMapInterval() const -{ - return m_lostUlMapInterval; -} - -void -SubscriberStationNetDevice::SetMaxDcdInterval(Time maxDcdInterval) -{ - m_maxDcdInterval = maxDcdInterval; -} - -Time -SubscriberStationNetDevice::GetMaxDcdInterval() const -{ - return m_maxDcdInterval; -} - -void -SubscriberStationNetDevice::SetMaxUcdInterval(Time maxUcdInterval) -{ - m_maxUcdInterval = maxUcdInterval; -} - -Time -SubscriberStationNetDevice::GetMaxUcdInterval() const -{ - return m_maxUcdInterval; -} - -void -SubscriberStationNetDevice::SetIntervalT1(Time interval) -{ - m_intervalT1 = interval; -} - -Time -SubscriberStationNetDevice::GetIntervalT1() const -{ - return m_intervalT1; -} - -void -SubscriberStationNetDevice::SetIntervalT2(Time interval) -{ - m_intervalT2 = interval; -} - -Time -SubscriberStationNetDevice::GetIntervalT2() const -{ - return m_intervalT2; -} - -void -SubscriberStationNetDevice::SetIntervalT3(Time interval) -{ - m_intervalT3 = interval; -} - -Time -SubscriberStationNetDevice::GetIntervalT3() const -{ - return m_intervalT3; -} - -void -SubscriberStationNetDevice::SetIntervalT7(Time interval) -{ - m_intervalT7 = interval; -} - -Time -SubscriberStationNetDevice::GetIntervalT7() const -{ - return m_intervalT7; -} - -void -SubscriberStationNetDevice::SetIntervalT12(Time interval) -{ - m_intervalT12 = interval; -} - -Time -SubscriberStationNetDevice::GetIntervalT12() const -{ - return m_intervalT12; -} - -void -SubscriberStationNetDevice::SetIntervalT20(Time interval) -{ - m_intervalT20 = interval; -} - -Time -SubscriberStationNetDevice::GetIntervalT20() const -{ - return m_intervalT20; -} - -void -SubscriberStationNetDevice::SetIntervalT21(Time interval) -{ - m_intervalT21 = interval; -} - -Time -SubscriberStationNetDevice::GetIntervalT21() const -{ - return m_intervalT21; -} - -void -SubscriberStationNetDevice::SetMaxContentionRangingRetries(uint8_t maxContentionRangingRetries) -{ - m_maxContentionRangingRetries = maxContentionRangingRetries; -} - -uint8_t -SubscriberStationNetDevice::GetMaxContentionRangingRetries() const -{ - return m_maxContentionRangingRetries; -} - -void -SubscriberStationNetDevice::SetBasicConnection(Ptr basicConnection) -{ - m_basicConnection = basicConnection; - uint32_t nodeId = GetNode()->GetId(); - uint32_t ifaceId = GetIfIndex(); - - if (!m_asciiTxQueueEnqueueCb.IsNull()) - { - std::ostringstream oss; - oss << "/NodeList/" << nodeId << "/DeviceList/" << ifaceId - << "/$ns3::SubscriberStationNetDevice/BasicConnection/TxQueue/Enqueue"; - Config::Connect(oss.str(), m_asciiTxQueueEnqueueCb); - } - if (!m_asciiTxQueueDequeueCb.IsNull()) - { - std::ostringstream oss; - oss << "/NodeList/" << nodeId << "/DeviceList/" << ifaceId - << "/$ns3::SubscriberStationNetDevice/BasicConnection/TxQueue/Dequeue"; - Config::Connect(oss.str(), m_asciiTxQueueDequeueCb); - } - if (!m_asciiTxQueueDropCb.IsNull()) - { - std::ostringstream oss; - oss << "/NodeList/" << nodeId << "/DeviceList/" << ifaceId - << "/$ns3::SubscriberStationNetDevice/BasicConnection/TxQueue/Drop"; - Config::Connect(oss.str(), m_asciiTxQueueDropCb); - } -} - -Ptr -SubscriberStationNetDevice::GetBasicConnection() const -{ - return m_basicConnection; -} - -void -SubscriberStationNetDevice::SetPrimaryConnection(Ptr primaryConnection) -{ - m_primaryConnection = primaryConnection; - - uint32_t nodeId = GetNode()->GetId(); - uint32_t ifaceId = GetIfIndex(); - - if (!m_asciiTxQueueEnqueueCb.IsNull()) - { - std::ostringstream oss; - oss << "/NodeList/" << nodeId << "/DeviceList/" << ifaceId - << "/$ns3::SubscriberStationNetDevice/PrimaryConnection/TxQueue/Enqueue"; - Config::Connect(oss.str(), m_asciiTxQueueEnqueueCb); - } - if (!m_asciiTxQueueDequeueCb.IsNull()) - { - std::ostringstream oss; - oss << "/NodeList/" << nodeId << "/DeviceList/" << ifaceId - << "/$ns3::SubscriberStationNetDevice/PrimaryConnection/TxQueue/Dequeue"; - Config::Connect(oss.str(), m_asciiTxQueueDequeueCb); - } - if (!m_asciiTxQueueDropCb.IsNull()) - { - std::ostringstream oss; - oss << "/NodeList/" << nodeId << "/DeviceList/" << ifaceId - << "/$ns3::SubscriberStationNetDevice/PrimaryConnection/TxQueue/Drop"; - Config::Connect(oss.str(), m_asciiTxQueueDropCb); - } -} - -Ptr -SubscriberStationNetDevice::GetPrimaryConnection() const -{ - return m_primaryConnection; -} - -Cid -SubscriberStationNetDevice::GetBasicCid() const -{ - return m_basicConnection->GetCid(); -} - -Cid -SubscriberStationNetDevice::GetPrimaryCid() const -{ - return m_primaryConnection->GetCid(); -} - -void -SubscriberStationNetDevice::SetModulationType(WimaxPhy::ModulationType modulationType) -{ - m_modulationType = modulationType; -} - -WimaxPhy::ModulationType -SubscriberStationNetDevice::GetModulationType() const -{ - return m_modulationType; -} - -void -SubscriberStationNetDevice::SetAreManagementConnectionsAllocated( - bool areManagementConnectionsAllocated) -{ - m_areManagementConnectionsAllocated = areManagementConnectionsAllocated; -} - -bool -SubscriberStationNetDevice::GetAreManagementConnectionsAllocated() const -{ - return m_areManagementConnectionsAllocated; -} - -void -SubscriberStationNetDevice::SetAreServiceFlowsAllocated(bool areServiceFlowsAllocated) -{ - m_areServiceFlowsAllocated = areServiceFlowsAllocated; -} - -bool -SubscriberStationNetDevice::GetAreServiceFlowsAllocated() const -{ - return m_areServiceFlowsAllocated; -} - -Ptr -SubscriberStationNetDevice::GetScheduler() const -{ - return m_scheduler; -} - -void -SubscriberStationNetDevice::SetScheduler(Ptr scheduler) -{ - m_scheduler = scheduler; -} - -bool -SubscriberStationNetDevice::HasServiceFlows() const -{ - return !GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_ALL).empty(); -} - -Ptr -SubscriberStationNetDevice::GetIpcsClassifier() const -{ - return m_classifier; -} - -void -SubscriberStationNetDevice::SetIpcsPacketClassifier(Ptr classifier) -{ - m_classifier = classifier; -} - -Ptr -SubscriberStationNetDevice::GetLinkManager() const -{ - return m_linkManager; -} - -void -SubscriberStationNetDevice::SetLinkManager(Ptr linkManager) -{ - m_linkManager = linkManager; -} - -Ptr -SubscriberStationNetDevice::GetServiceFlowManager() const -{ - return m_serviceFlowManager; -} - -void -SubscriberStationNetDevice::SetServiceFlowManager(Ptr sfm) -{ - m_serviceFlowManager = sfm; -} - -void -SubscriberStationNetDevice::Start() -{ - SetReceiveCallback(); - - GetPhy()->SetPhyParameters(); - GetPhy()->SetDataRates(); - m_intervalT20 = Seconds(4 * GetPhy()->GetFrameDuration().GetSeconds()); - - CreateDefaultConnections(); - Simulator::ScheduleNow(&SSLinkManager::StartScanning, m_linkManager, EVENT_NONE, false); -} - -void -SubscriberStationNetDevice::Stop() -{ - SetState(SS_STATE_STOPPED); -} - -void -SubscriberStationNetDevice::AddServiceFlow(ServiceFlow sf) const -{ - GetServiceFlowManager()->AddServiceFlow(sf); -} - -void -SubscriberStationNetDevice::AddServiceFlow(ServiceFlow* sf) const -{ - GetServiceFlowManager()->AddServiceFlow(sf); -} - -bool -SubscriberStationNetDevice::DoSend(Ptr packet, - const Mac48Address& source, - const Mac48Address& dest, - uint16_t protocolNumber) -{ - NS_LOG_INFO("SS (" << source << "):"); - NS_LOG_INFO("\tSending packet..."); - NS_LOG_INFO("\t\tDestination: " << dest); - NS_LOG_INFO("\t\tPacket Size: " << packet->GetSize()); - NS_LOG_INFO("\t\tProtocol: " << protocolNumber); - - ServiceFlow* serviceFlow = nullptr; - - if (IsRegistered()) - { - NS_LOG_DEBUG("SS (Basic CID: " << m_basicConnection->GetCid() << ")"); - } - else - { - NS_LOG_DEBUG("SS (" << GetMacAddress() << ")"); - NS_LOG_INFO("\tCan't send packet! (NotRegistered with the network)"); - return false; - } - - NS_LOG_DEBUG("packet to send, size : " << packet->GetSize() << ", destination : " << dest); - - if (GetServiceFlowManager()->GetNrServiceFlows() == 0) - { - NS_LOG_INFO("\tCan't send packet! (No service Flow)"); - return false; - } - - if (protocolNumber == 2048) - { - serviceFlow = - m_classifier->Classify(packet, GetServiceFlowManager(), ServiceFlow::SF_DIRECTION_UP); - } - - if ((protocolNumber != 2048) || (serviceFlow == nullptr)) - { - serviceFlow = *GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_ALL).begin(); - NS_LOG_INFO("\tNo service flows matches...using the default one."); - } - - NS_LOG_INFO("\tPacket classified in the service flow SFID = " - << serviceFlow->GetSfid() << " CID = " << serviceFlow->GetCid()); - if (serviceFlow->GetIsEnabled()) - { - if (!Enqueue(packet, MacHeaderType(), serviceFlow->GetConnection())) - { - NS_LOG_INFO("\tEnqueue ERROR!!"); - m_ssTxDropTrace(packet); - return false; - } - else - { - m_ssTxTrace(packet); - } - } - else - { - NS_LOG_INFO("Error!! The Service Flow is not enabled"); - m_ssTxDropTrace(packet); - return false; - } - - return true; -} - -bool -SubscriberStationNetDevice::Enqueue(Ptr packet, - const MacHeaderType& hdrType, - Ptr connection) -{ - NS_ASSERT_MSG(connection, - "SS: Can not enqueue the packet: the selected connection is nor initialized"); - - GenericMacHeader hdr; - - if (hdrType.GetType() == MacHeaderType::HEADER_TYPE_GENERIC) - { - hdr.SetLen(packet->GetSize() + hdr.GetSerializedSize()); - hdr.SetCid(connection->GetCid()); - } - - if (connection->GetType() == Cid::TRANSPORT) - { - if (connection->GetSchedulingType() == ServiceFlow::SF_TYPE_UGS && m_scheduler->GetPollMe()) - { - NS_ASSERT_MSG(hdrType.GetType() != MacHeaderType::HEADER_TYPE_BANDWIDTH, - "Error while enqueuing packet: incorrect header type"); - - GrantManagementSubheader grantMgmntSubhdr; - grantMgmntSubhdr.SetPm(1); - packet->AddHeader(grantMgmntSubhdr); - } - } - NS_LOG_INFO("ServiceFlowManager: enqueuing packet"); - return connection->Enqueue(packet, hdrType, hdr); -} - -void -SubscriberStationNetDevice::SendBurst(uint8_t uiuc, - uint16_t nrSymbols, - Ptr connection, - MacHeaderType::HeaderType packetType) -{ - WimaxPhy::ModulationType modulationType; - - if (uiuc == OfdmUlBurstProfile::UIUC_INITIAL_RANGING || - uiuc == OfdmUlBurstProfile::UIUC_REQ_REGION_FULL) - { - modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - } - else - { - modulationType = GetBurstProfileManager()->GetModulationType(uiuc, DIRECTION_UPLINK); - } - Ptr burst = - m_scheduler->Schedule(nrSymbols, modulationType, packetType, connection); - - if (burst->GetNPackets() == 0) - { - return; - } - - if (IsRegistered()) - { - NS_LOG_DEBUG("SS (Basic CID: " << m_basicConnection->GetCid() << ")"); - } - else - { - NS_LOG_DEBUG("SS (" << GetMacAddress() << ")"); - } - - if (connection->GetType() == Cid::TRANSPORT) - { - ServiceFlowRecord* record = connection->GetServiceFlow()->GetRecord(); - record->UpdatePktsSent(burst->GetNPackets()); - record->UpdateBytesSent(burst->GetSize()); - - NS_LOG_DEBUG(" sending burst, SFID: " << connection->GetServiceFlow()->GetSfid() - << ", pkts sent: " << record->GetPktsSent() - << ", pkts rcvd: " << record->GetPktsRcvd() - << ", bytes sent: " << record->GetBytesSent() - << ", bytes rcvd: " << record->GetBytesRcvd()); - } - - ForwardDown(burst, modulationType); -} - -void -SubscriberStationNetDevice::DoReceive(Ptr packet) -{ - GenericMacHeader gnrcMacHdr; - ManagementMessageType msgType; - RngRsp rngrsp; - Cid cid; - uint32_t pktSize = packet->GetSize(); - packet->RemoveHeader(gnrcMacHdr); - FragmentationSubheader fragSubhdr; - bool fragmentation = false; // it becomes true when there is a fragmentation subheader - - if (gnrcMacHdr.GetHt() == MacHeaderType::HEADER_TYPE_GENERIC) - { - if (!gnrcMacHdr.check_hcs()) - { - // The header is noisy - NS_LOG_INFO("Header HCS ERROR"); - m_ssRxDropTrace(packet); - return; - } - - cid = gnrcMacHdr.GetCid(); - - // checking for subheaders - uint8_t type = gnrcMacHdr.GetType(); - if (type) - { - // Check if there is a fragmentation Subheader - uint8_t tmpType = type; - if (((tmpType >> 2) & 1) == 1) - { - // a TRANSPORT packet with fragmentation subheader has been received! - fragmentation = true; - NS_LOG_INFO("SS DoReceive -> the packet is a fragment" << std::endl); - } - } - - if (cid == GetBroadcastConnection()->GetCid() && !fragmentation) - { - packet->RemoveHeader(msgType); - switch (msgType.GetType()) - { - case ManagementMessageType::MESSAGE_TYPE_DL_MAP: { - if (GetState() == SS_STATE_SYNCHRONIZING) - { - Simulator::Cancel(m_linkManager->GetDlMapSyncTimeoutEvent()); - } - - if (m_lostDlMapEvent.IsPending()) - { - Simulator::Cancel(m_lostDlMapEvent); - } - - m_linkManager->ScheduleScanningRestart(m_lostDlMapInterval, - EVENT_LOST_DL_MAP, - false, - m_lostDlMapEvent); - - if (m_dcdWaitTimeoutEvent.IsPending()) - { - Simulator::Cancel(m_dcdWaitTimeoutEvent); - } - - m_linkManager->ScheduleScanningRestart(m_intervalT1, - EVENT_DCD_WAIT_TIMEOUT, - false, - m_dcdWaitTimeoutEvent); - - if (m_ucdWaitTimeoutEvent.IsPending()) - { - Simulator::Cancel(m_ucdWaitTimeoutEvent); - } - - m_linkManager->ScheduleScanningRestart(m_intervalT12, - EVENT_UCD_WAIT_TIMEOUT, - true, - m_ucdWaitTimeoutEvent); - - DlMap dlmap; - packet->RemoveHeader(dlmap); - ProcessDlMap(dlmap); - break; - } - case ManagementMessageType::MESSAGE_TYPE_UL_MAP: { - if (m_lostUlMapEvent.IsPending()) - { - Simulator::Cancel(m_lostUlMapEvent); - m_linkManager->ScheduleScanningRestart(m_lostUlMapInterval, - EVENT_LOST_UL_MAP, - true, - m_lostUlMapEvent); - } - - UlMap ulmap; - packet->RemoveHeader(ulmap); - - ProcessUlMap(ulmap); - - if (GetState() == SS_STATE_WAITING_REG_RANG_INTRVL) - { - if (m_linkManager->GetRangingIntervalFound()) - { - if (m_rangOppWaitTimeoutEvent.IsPending()) - { - Simulator::Cancel(m_rangOppWaitTimeoutEvent); - } - m_linkManager->PerformBackoff(); - } - } - break; - } - case ManagementMessageType::MESSAGE_TYPE_DCD: { - if (GetState() == SS_STATE_SYNCHRONIZING) - { - SetState(SS_STATE_ACQUIRING_PARAMETERS); - } - - if (m_dcdWaitTimeoutEvent.IsPending()) - { - Simulator::Cancel(m_dcdWaitTimeoutEvent); - m_linkManager->ScheduleScanningRestart(m_intervalT1, - EVENT_DCD_WAIT_TIMEOUT, - false, - m_dcdWaitTimeoutEvent); - } - - Dcd dcd; - // number of burst profiles is set to number of DL-MAP IEs after processing DL-MAP, - // not a very good solution dcd.SetNrDlBurstProfiles (m_nrDlMapElements); - dcd.SetNrDlBurstProfiles(7); - packet->RemoveHeader(dcd); - - ProcessDcd(dcd); - break; - } - case ManagementMessageType::MESSAGE_TYPE_UCD: { - Ucd ucd; - // number of burst profiles is set to number of UL-MAP IEs after processing UL-MAP, - // not a very good solution ucd.SetNrUlBurstProfiles (m_nrUlMapElements); - ucd.SetNrUlBurstProfiles(7); - packet->RemoveHeader(ucd); - - ProcessUcd(ucd); - - if (m_ucdWaitTimeoutEvent.IsPending()) - { - Simulator::Cancel(m_ucdWaitTimeoutEvent); - m_linkManager->ScheduleScanningRestart(m_intervalT12, - EVENT_UCD_WAIT_TIMEOUT, - true, - m_ucdWaitTimeoutEvent); - } - - if (GetState() == SS_STATE_ACQUIRING_PARAMETERS) - { - /*state indicating that SS has completed scanning, synchronization and parameter - acquisition successfully and now waiting for UL-MAP to start initial ranging.*/ - SetState(SS_STATE_WAITING_REG_RANG_INTRVL); - - m_linkManager->ScheduleScanningRestart(m_intervalT2, - EVENT_RANG_OPP_WAIT_TIMEOUT, - false, - m_rangOppWaitTimeoutEvent); - m_linkManager->ScheduleScanningRestart(m_lostUlMapInterval, - EVENT_LOST_UL_MAP, - true, - m_lostUlMapEvent); - } - break; - } - default: - NS_FATAL_ERROR("Invalid management message type"); - } - } - else if (GetInitialRangingConnection() && cid == GetInitialRangingConnection()->GetCid() && - !fragmentation) - { - m_traceSSRx(packet, GetMacAddress(), cid); - packet->RemoveHeader(msgType); - switch (msgType.GetType()) - { - case ManagementMessageType::MESSAGE_TYPE_RNG_REQ: - // intended for base station, ignore - break; - case ManagementMessageType::MESSAGE_TYPE_RNG_RSP: - NS_ASSERT_MSG(GetState() >= SS_STATE_WAITING_REG_RANG_INTRVL, - "SS: Error while receiving a ranging response message: SS state " - "should be at least SS_STATE_WAITING_REG_RANG_INTRVL"); - packet->RemoveHeader(rngrsp); - m_linkManager->PerformRanging(cid, rngrsp); - break; - default: - NS_LOG_ERROR("Invalid management message type"); - } - } - else if (m_basicConnection && cid == m_basicConnection->GetCid() && !fragmentation) - { - m_traceSSRx(packet, GetMacAddress(), cid); - packet->RemoveHeader(msgType); - switch (msgType.GetType()) - { - case ManagementMessageType::MESSAGE_TYPE_RNG_REQ: - // intended for base station, ignore - break; - case ManagementMessageType::MESSAGE_TYPE_RNG_RSP: - NS_ASSERT_MSG(GetState() == SS_STATE_WAITING_RNG_RSP, - "SS: Error while receiving a ranging response message: SS state " - "should be SS_STATE_WAITING_RNG_RSP"); - packet->RemoveHeader(rngrsp); - m_linkManager->PerformRanging(cid, rngrsp); - break; - default: - NS_LOG_ERROR("Invalid management message type"); - } - } - else if (m_primaryConnection && cid == m_primaryConnection->GetCid() && !fragmentation) - { - m_traceSSRx(packet, GetMacAddress(), cid); - packet->RemoveHeader(msgType); - switch (msgType.GetType()) - { - case ManagementMessageType::MESSAGE_TYPE_REG_REQ: - // not yet implemented - case ManagementMessageType::MESSAGE_TYPE_REG_RSP: - // intended for base station, ignore - case ManagementMessageType::MESSAGE_TYPE_DSA_REQ: - /*from other station as DSA initiation - by BS is not supported, ignore*/ - break; - case ManagementMessageType::MESSAGE_TYPE_DSA_RSP: { - Simulator::Cancel(GetServiceFlowManager()->GetDsaRspTimeoutEvent()); - DsaRsp dsaRsp; - packet->RemoveHeader(dsaRsp); - GetServiceFlowManager()->ProcessDsaRsp(dsaRsp); - break; - } - case ManagementMessageType::MESSAGE_TYPE_DSA_ACK: - /*from other station as DSA initiation - by BS is not supported, ignore*/ - break; - default: - NS_LOG_ERROR("Invalid management message type"); - } - } - else if (GetConnectionManager()->GetConnection(cid)) // transport connection - { - ServiceFlow* serviceFlow = GetConnectionManager()->GetConnection(cid)->GetServiceFlow(); - ServiceFlowRecord* record = serviceFlow->GetRecord(); - - record->UpdatePktsRcvd(1); - record->UpdateBytesRcvd(pktSize); - - // If fragmentation is true, the packet is a fragment. - if (!fragmentation) - { - m_ssRxTrace(packet); - ForwardUp(packet, - m_baseStationId, - GetMacAddress()); // source shall be BS's address or sender SS's? - } - else - { - NS_LOG_INFO("FRAG_DEBUG: SS DoReceive, the Packet is a fragment" << std::endl); - packet->RemoveHeader(fragSubhdr); - uint32_t fc = fragSubhdr.GetFc(); - NS_LOG_INFO("\t fragment size = " << packet->GetSize() << std::endl); - - if (fc == 2) - { - // This is the latest fragment. - // Take the fragment queue, defragment a packet and send it to the upper layer - NS_LOG_INFO("\t Received the latest fragment" << std::endl); - GetConnectionManager()->GetConnection(cid)->FragmentEnqueue(packet); - - WimaxConnection::FragmentsQueue fragmentsQueue = - GetConnectionManager()->GetConnection(cid)->GetFragmentsQueue(); - - Ptr fullPacket = Create(); - - // DEFRAGMENTATION - NS_LOG_INFO("\t SS PACKET DEFRAGMENTATION" << std::endl); - for (auto iter = fragmentsQueue.begin(); iter != fragmentsQueue.end(); ++iter) - { - // Create the whole Packet - fullPacket->AddAtEnd(*iter); - } - GetConnectionManager()->GetConnection(cid)->ClearFragmentsQueue(); - NS_LOG_INFO("\t fullPacket size = " << fullPacket->GetSize() << std::endl); - - m_ssRxTrace(fullPacket); - ForwardUp(fullPacket, - m_baseStationId, - GetMacAddress()); // source shall be BS's address or sender SS's? - } - else - { - // This is the first or middle fragment. - // Take the fragment queue, store the fragment into the queue - NS_LOG_INFO("\t Received the first or the middle fragment" << std::endl); - GetConnectionManager()->GetConnection(cid)->FragmentEnqueue(packet); - } - } - } - else if (cid.IsMulticast()) - { - m_traceSSRx(packet, GetMacAddress(), cid); - ForwardUp(packet, - m_baseStationId, - GetMacAddress()); // source shall be BS's address or sender SS's? - } - else if (IsPromisc()) - { - NotifyPromiscTrace(packet); - m_ssPromiscRxTrace(packet); - - // not for me, ignore - } - else - { - // not for me drop - } - } - else - { - // from other SS, ignore - } -} - -void -SubscriberStationNetDevice::ProcessDlMap(const DlMap& dlmap) -{ - m_nrDlMapRecvd++; - m_dcdCount = dlmap.GetDcdCount(); - m_baseStationId = dlmap.GetBaseStationId(); - std::list dlMapElements = dlmap.GetDlMapElements(); - - for (auto iter = dlMapElements.begin(); iter != dlMapElements.end(); ++iter) - { - if (iter->GetDiuc() == OfdmDlBurstProfile::DIUC_END_OF_MAP) - { - break; - } - - if (iter->GetCid() == m_basicConnection->GetCid()) - { - /*here the SS shall actually acquire the start time it shall start receiving the burst - at. start time is used for power saving which is not implemented here, furthermore - there is no need since the simulator architecture automatically callbacks the receive - function. shall acquire the DIUC (burst profile) as well to decode the burst, again not - required again because the callback mechanism automatically passes it as parameter.*/ - } - -#if 0 /* a template for future implementation following */ - uint8_t temp = iter->GetDiuc (); - temp = iter->GetPreamblePresent (); - temp = iter->GetStartTime (); -#endif - } -} - -void -SubscriberStationNetDevice::ProcessUlMap(const UlMap& ulmap) -{ - m_nrUlMapRecvd++; - m_ucdCount = ulmap.GetUcdCount(); - m_allocationStartTime = ulmap.GetAllocationStartTime(); - const auto& ulMapElements = ulmap.GetUlMapElements(); - m_linkManager->SetRangingIntervalFound(false); - - for (const auto& ulMapIe : ulMapElements) - { - if (ulMapIe.GetUiuc() == OfdmUlBurstProfile::UIUC_END_OF_MAP) - { - break; - } - - Cid cid = ulMapIe.GetCid(); - - if (ulMapIe.GetUiuc() == OfdmUlBurstProfile::UIUC_INITIAL_RANGING && - cid == GetBroadcastConnection()->GetCid()) - { - m_linkManager->SetRangingIntervalFound(true); - } - - if (m_areManagementConnectionsAllocated && cid == m_basicConnection->GetCid()) - { - Time timeToAllocation = GetTimeToAllocation( - Seconds(ulMapIe.GetStartTime() * GetPhy()->GetSymbolDuration().GetSeconds())); - - if (ulMapIe.GetUiuc() == - OfdmUlBurstProfile::UIUC_INITIAL_RANGING) // invited ranging interval - - { - m_linkManager->IncrementNrInvitedPollsRecvd(); - NS_ASSERT_MSG(GetState() == SS_STATE_WAITING_INV_RANG_INTRVL, - "SS: Error while processing UL MAP: SS state should be " - "SS_STATE_WAITING_INV_RANG_INTRVL"); - Simulator::Schedule(timeToAllocation, - &SSLinkManager::SendRangingRequest, - m_linkManager, - ulMapIe.GetUiuc(), - ulMapIe.GetDuration()); - } - else if (ulMapIe.GetUiuc() == OfdmUlBurstProfile::UIUC_REQ_REGION_FULL) // unicast poll - - { - Simulator::Schedule(timeToAllocation, - &BandwidthManager::SendBandwidthRequest, - GetBandwidthManager(), - ulMapIe.GetUiuc(), - ulMapIe.GetDuration()); - } - else // regular allocation/grant for data, for UGS flows or in response of requests for - // non-UGS flows - - { - Ptr connection = nullptr; - Simulator::Schedule(timeToAllocation, - &SubscriberStationNetDevice::SendBurst, - this, - ulMapIe.GetUiuc(), - ulMapIe.GetDuration(), - connection, - MacHeaderType::HEADER_TYPE_GENERIC); - } - } - else - { - if (ulMapIe.GetUiuc() == OfdmUlBurstProfile::UIUC_INITIAL_RANGING && - cid == GetBroadcastConnection()->GetCid()) // regular ranging interval - - { - if (GetCurrentUcd().GetChannelEncodings().GetRangReqOppSize() != 0) - { - m_linkManager->SetNrRangingTransOpps( - (ulMapIe.GetDuration() * GetPhy()->GetPsPerSymbol()) / - GetCurrentUcd().GetChannelEncodings().GetRangReqOppSize()); - } - - if (GetState() == SS_STATE_WAITING_REG_RANG_INTRVL || - GetState() == SS_STATE_ADJUSTING_PARAMETERS) - { - m_linkManager->StartContentionResolution(); - } - } - } - } -} - -void -SubscriberStationNetDevice::ProcessDcd(const Dcd& dcd) -{ - m_nrDcdRecvd++; - if (dcd.GetConfigurationChangeCount() == GetCurrentDcd().GetConfigurationChangeCount()) - { - return; // nothing new in DCD so don't read - } - SetCurrentDcd(dcd); - OfdmDcdChannelEncodings dcdChnlEncodings = dcd.GetChannelEncodings(); - - // parameters for initial ranging - m_linkManager->SetBsEirp(dcdChnlEncodings.GetBsEirp()); - m_linkManager->SetEirXPIrMax(dcdChnlEncodings.GetEirxPIrMax()); - - GetPhy()->GetFrameDuration(dcdChnlEncodings.GetFrameDurationCode()); - - const auto& dlBurstProfiles = dcd.GetDlBurstProfiles(); - - for (const auto& brstProfile : dlBurstProfiles) - { - /*NS-2 does this, may be not correct, assumes DIUC/UIUC to - modulation type mapping in DCD/UCD may change over time*/ - if (brstProfile.GetFecCodeType() == m_modulationType) - { - m_dlBurstProfile->SetFecCodeType(brstProfile.GetFecCodeType()); - m_dlBurstProfile->SetDiuc(brstProfile.GetDiuc()); - } - } -} - -void -SubscriberStationNetDevice::ProcessUcd(const Ucd& ucd) -{ - m_nrUcdRecvd++; - if (!m_linkManager->IsUlChannelUsable()) - { - m_linkManager->StartScanning(EVENT_NONE, false); - return; - } - - if (ucd.GetConfigurationChangeCount() == GetCurrentUcd().GetConfigurationChangeCount()) - { - return; // nothing new in UCD so don't read - } - SetCurrentUcd(ucd); - m_linkManager->SetRangingCW((uint8_t)std::pow(2.0, (double)ucd.GetRangingBackoffStart()) - - 1); // initializing ranging CW - OfdmUcdChannelEncodings ucdChnlEncodings = ucd.GetChannelEncodings(); - - const auto& ulBurstProfiles = ucd.GetUlBurstProfiles(); - for (const auto& brstProfile : ulBurstProfiles) - { - /*NS-2 does this, may be not correct, assumes DIUC/UIUC to - modulation type mapping in DCD/UCD may change over time*/ - if (brstProfile.GetFecCodeType() == m_modulationType) - { - m_ulBurstProfile->SetFecCodeType(brstProfile.GetFecCodeType()); - m_ulBurstProfile->SetUiuc(brstProfile.GetUiuc()); - } - } -} - -/*temporarily assuming registered if ranging is complete, - shall actually consider the registration step also */ -bool -SubscriberStationNetDevice::IsRegistered() const -{ - return GetState() >= SS_STATE_REGISTERED; -} - -Time -SubscriberStationNetDevice::GetTimeToAllocation(Time deferTime) -{ - Time timeAlreadyElapsed = Simulator::Now() - m_frameStartTime; - Time timeToUlSubframe = - Seconds(m_allocationStartTime * GetPhy()->GetPsDuration().GetSeconds()) - - timeAlreadyElapsed; - return timeToUlSubframe + deferTime; -} - -void -SubscriberStationNetDevice::SetTimer(EventId eventId, EventId& event) -{ - if (GetState() == SS_STATE_STOPPED) - { - Simulator::Cancel(eventId); // cancelling this event (already scheduled in function call) - return; - } - - event = eventId; -} - -void -SubscriberStationNetDevice::SetAsciiTxQueueEnqueueCallback(AsciiTraceCallback cb) -{ - m_asciiTxQueueEnqueueCb = cb; -} - -void -SubscriberStationNetDevice::SetAsciiTxQueueDequeueCallback(AsciiTraceCallback cb) -{ - m_asciiTxQueueDequeueCb = cb; -} - -void -SubscriberStationNetDevice::SetAsciiTxQueueDropCallback(AsciiTraceCallback cb) -{ - m_asciiTxQueueDropCb = cb; -} - -} // namespace ns3 diff --git a/src/wimax/model/ss-net-device.h b/src/wimax/model/ss-net-device.h deleted file mode 100644 index 4fa0f75a0..000000000 --- a/src/wimax/model/ss-net-device.h +++ /dev/null @@ -1,527 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#ifndef WIMAX_SS_NET_DEVICE_H -#define WIMAX_SS_NET_DEVICE_H - -#include "ipcs-classifier.h" -#include "ss-service-flow-manager.h" -#include "wimax-mac-header.h" -#include "wimax-net-device.h" - -#include "ns3/event-id.h" -#include "ns3/nstime.h" -#include "ns3/uinteger.h" - -namespace ns3 -{ - -class Node; -class OfdmDlBurstProfile; -class OfdmUlBurstProfile; -class SSScheduler; -class SSLinkManager; -class SsServiceFlowManager; -class IpcsClassifier; - -/** - * @ingroup wimax - * SubscriberStationNetDevice subclass of WimaxNetDevice - */ -class SubscriberStationNetDevice : public WimaxNetDevice -{ - public: - /// State enumeration - enum State - { - SS_STATE_IDLE, - SS_STATE_SCANNING, - SS_STATE_SYNCHRONIZING, - SS_STATE_ACQUIRING_PARAMETERS, - SS_STATE_WAITING_REG_RANG_INTRVL, // regular ranging interval - SS_STATE_WAITING_INV_RANG_INTRVL, // invited ranging interval - SS_STATE_WAITING_RNG_RSP, - SS_STATE_ADJUSTING_PARAMETERS, - SS_STATE_REGISTERED, - SS_STATE_TRANSMITTING, // currently not being used anywhere - SS_STATE_STOPPED - }; - - /// EventType enumeration - enum EventType - { - EVENT_NONE, - EVENT_WAIT_FOR_RNG_RSP, - EVENT_DL_MAP_SYNC_TIMEOUT, - EVENT_LOST_DL_MAP, - EVENT_LOST_UL_MAP, - EVENT_DCD_WAIT_TIMEOUT, - EVENT_UCD_WAIT_TIMEOUT, - EVENT_RANG_OPP_WAIT_TIMEOUT - }; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - SubscriberStationNetDevice(); - /** - * Constructor - * - * @param node the node - * @param phy the wimax phy - */ - SubscriberStationNetDevice(Ptr node, Ptr phy); - ~SubscriberStationNetDevice() override; - - /** - * @brief initializes the net device and sets the parameters to the default values - */ - void InitSubscriberStationNetDevice(); - /** - * @param lostDlMapInterval time since last received DL-MAP message before downlink - * synchronization is considered lost - */ - void SetLostDlMapInterval(Time lostDlMapInterval); - /** - * @returns the time since last received DL-MAP message before downlink synchronization is - * considered lost - */ - Time GetLostDlMapInterval() const; - /** - * @param lostUlMapInterval Time since last received UL-MAP before uplink synchronization is - * considered lost - */ - void SetLostUlMapInterval(Time lostUlMapInterval); - /** - * @returns the time since last received UL-MAP before uplink synchronization is considered lost - */ - Time GetLostUlMapInterval() const; - /** - * @param maxDcdInterval Maximum time between transmission of DCD messages - */ - void SetMaxDcdInterval(Time maxDcdInterval); - /** - * @returns the maximum time between transmission of DCD messages - */ - Time GetMaxDcdInterval() const; - /** - * @param maxUcdInterval Maximum time between transmission of UCD messages - */ - void SetMaxUcdInterval(Time maxUcdInterval); - /** - * @returns the maximum time between transmission of UCD messages - */ - Time GetMaxUcdInterval() const; - /** - * @param interval1 Wait for DCD timeout value - */ - void SetIntervalT1(Time interval1); - /** - * @returns the wait for DCD timeout - */ - Time GetIntervalT1() const; - /** - * @param interval2 the wait for broadcast ranging timeout, i.e., wait for initial ranging - * opportunity - */ - void SetIntervalT2(Time interval2); - /** - * @returns the wait for broadcast ranging timeout, i.e., wait for initial ranging opportunity - */ - Time GetIntervalT2() const; - /** - * @param interval3 the ranging Response reception timeout following the transmission of a - * ranging request - */ - void SetIntervalT3(Time interval3); - /** - * @returns the ranging Response reception timeout following the transmission of a ranging - * request - */ - Time GetIntervalT3() const; - /** - * @param interval7 the wait for DSA/DSC/DSD Response timeout - */ - void SetIntervalT7(Time interval7); - /** - * @returns the wait for DSA/DSC/DSD Response timeout - */ - Time GetIntervalT7() const; - /** - * @param interval12 the Wait for UCD descriptor timeout - */ - void SetIntervalT12(Time interval12); - /** - * @returns the wait for UCD descriptor timeout - */ - Time GetIntervalT12() const; - /** - * @param interval20 the Time the SS searches for preambles on a given channel - */ - void SetIntervalT20(Time interval20); - /** - * @returns the Time the SS searches for preambles on a given channel - */ - Time GetIntervalT20() const; - /** - * @param interval21 the time the SS searches for (decodable) DL-MAP on a given channel - */ - void SetIntervalT21(Time interval21); - /** - * @returns the time the SS searches for (decodable) DL-MAP on a given channel - */ - Time GetIntervalT21() const; - /** - * @param maxContentionRangingRetries the Number of retries on contention Ranging Requests - */ - void SetMaxContentionRangingRetries(uint8_t maxContentionRangingRetries); - /** - * @returns the Number of retries on contention Ranging Requests - */ - uint8_t GetMaxContentionRangingRetries() const; - /** - * @param basicConnection the basic connection to be used - */ - void SetBasicConnection(Ptr basicConnection); - /** - * @return the basic connection currently in use - */ - Ptr GetBasicConnection() const; - /** - * @param primaryConnection the primary connection to be used - */ - void SetPrimaryConnection(Ptr primaryConnection); - /** - * @returns the primary connection currently used - */ - Ptr GetPrimaryConnection() const; - /** - * @returns the basic CID - */ - Cid GetBasicCid() const; - /** - * @returns the primary CID - */ - Cid GetPrimaryCid() const; - - /** - * @brief Set the most efficient modulation and coding scheme (MCS) supported by the device - * @param modulationType the most robust MCS supported - */ - void SetModulationType(WimaxPhy::ModulationType modulationType); - /** - * @returns the most efficient modulation and coding scheme (MCS) supported by the device - */ - WimaxPhy::ModulationType GetModulationType() const; - /** - * @param areManagementConnectionsAllocated true if the management connections are allocated, - * false otherwise - */ - void SetAreManagementConnectionsAllocated(bool areManagementConnectionsAllocated); - /** - * @returns true if the management connections are allocated, false otherwise - */ - bool GetAreManagementConnectionsAllocated() const; - /** - * @param areServiceFlowsAllocated true if the service flows are allocated, false otherwise - */ - void SetAreServiceFlowsAllocated(bool areServiceFlowsAllocated); - /** - * @returns true if the service flows are allocated, false otherwise - */ - bool GetAreServiceFlowsAllocated() const; - /** - * @return the scheduler installed on the device - */ - Ptr GetScheduler() const; - /** - * @param ssScheduler the scheduler to be installed on the device - */ - void SetScheduler(Ptr ssScheduler); - /** - * @returns true if the device has at least one active service flow, false otherwise - */ - bool HasServiceFlows() const; - /** - * @brief Enqueue a packet into a connection queue - * @param packet the packet to be enqueued - * @param hdrType the mac header type to be appended to the packet - * @param connection the connection to be used - * @returns true if successful - */ - bool Enqueue(Ptr packet, - const MacHeaderType& hdrType, - Ptr connection) override; - /** - * @brief Sends a burst on the uplink frame - * @param uiuc theOfdmUlBurstProfile - * @param nrSymbols number of symbols - * @param connection connection to use - * @param packetType optional HeaderType (default HEADER_TYPE_GENERIC) - */ - void SendBurst(uint8_t uiuc, - uint16_t nrSymbols, - Ptr connection, - MacHeaderType::HeaderType packetType = MacHeaderType::HEADER_TYPE_GENERIC); - - /** - * @brief Start the device - */ - void Start() override; - /** - * @brief Stop the device - */ - void Stop() override; - - /** - * @brief adds a new service flow - * @param sf pointer to service flow to add - */ - void AddServiceFlow(ServiceFlow* sf) const; - /** - * @brief adds a new service flow - * @param sf service flow to add - */ - void AddServiceFlow(ServiceFlow sf) const; - /** - * @brief Set timer. If in stopped state, the EventId passed in the first - * argument will be cancelled. If not, the second parameter will be set - * to the value of the first parameter. - * - * @param eventId EventId to cancel or to map to the second argument - * @param event EventId is set to first argument if not in stopped state - */ - void SetTimer(EventId eventId, EventId& event); - /** - * @returns true if the SS is registered to a BS, false otherwise - */ - bool IsRegistered() const; - /** - * @brief Get time to allocation - * @param deferTime defer time - * @returns the time to allocation - */ - Time GetTimeToAllocation(Time deferTime); - - Ptr m_linkManager; ///< link manager - /** - * @returns a pointer to the CS packet classifier - */ - Ptr GetIpcsClassifier() const; - /** - * @brief Sets the packet classifier to be used - * @param classifier the classifier to use - */ - void SetIpcsPacketClassifier(Ptr classifier); - /** - * @returns a pointer to the link manager currently used - */ - Ptr GetLinkManager() const; - /** - * @brief sets the link manager to be used - * @param linkManager link manager to use - */ - void SetLinkManager(Ptr linkManager); - /** - * @returns a pointer to the service flow manager installed on the device - */ - Ptr GetServiceFlowManager() const; - /** - * @brief Sets the service flow manager to be installed on the device - * @param sfm service flow manager to be used - */ - void SetServiceFlowManager(Ptr sfm); - - /// Callback for logging packets on ASCII traces - typedef Callback> AsciiTraceCallback; - - /** - * Set the Enqueue callback for ASCII tracing - * @param cb callback for ASCII tracing - */ - void SetAsciiTxQueueEnqueueCallback(AsciiTraceCallback cb); - - /** - * Set the Dequeue callback for ASCII tracing - * @param cb callback for ASCII tracing - */ - void SetAsciiTxQueueDequeueCallback(AsciiTraceCallback cb); - - /** - * Set the Drop callback for ASCII tracing - * @param cb callback for ASCII tracing - */ - void SetAsciiTxQueueDropCallback(AsciiTraceCallback cb); - - private: - /** - * Get default lost DL map interval - * @returns the default lost DL map interval - */ - static Time GetDefaultLostDlMapInterval(); - - void DoDispose() override; - /** - * Send a packet - * @param packet the packet to send - * @param source the source MAC address - * @param dest the destination MAC address - * @param protocolNumber the protocol number - * @returns true if successful - */ - bool DoSend(Ptr packet, - const Mac48Address& source, - const Mac48Address& dest, - uint16_t protocolNumber) override; - /** - * Receive a packet - * @param packet the packet received - */ - void DoReceive(Ptr packet) override; - - /** - * Process DL map - * @param dlmap the DL map - */ - void ProcessDlMap(const DlMap& dlmap); - /** - * Process UL map - * @param ulmap the UL map - */ - void ProcessUlMap(const UlMap& ulmap); - /** - * Process DCD - * @param dcd the DCD - */ - void ProcessDcd(const Dcd& dcd); - /** - * Process UCD - * @param ucd the UCD - */ - void ProcessUcd(const Ucd& ucd); - - // parameters defined in Table 342 - Time m_lostDlMapInterval; ///< in milliseconds, time since last received DL-MAP before downlink - ///< synchronization is considered lost, maximum is 600 - Time m_lostUlMapInterval; ///< in milliseconds, time since last received UL-MAP before uplink - ///< synchronization is considered lost, maximum is 600 - Time m_maxDcdInterval; ///< in seconds, maximum time between transmission of DCD messages - Time m_maxUcdInterval; ///< in seconds, maximum time between transmission of UCD messages - Time m_intervalT1; ///< in seconds, wait for DCD timeout - Time m_intervalT2; ///< in seconds, wait for broadcast ranging timeout, i.e., wait for initial - ///< ranging opportunity - Time m_intervalT3; ///< in milliseconds, ranging Response reception timeout following the - ///< transmission of a ranging request - Time m_intervalT7; ///< in seconds, wait for DSA/DSC/DSD Response timeout - Time m_intervalT12; ///< in seconds, wait for UCD descriptor - Time m_intervalT20; ///< in seconds, time the SS searches for preambles on a given channel - Time m_intervalT21; ///< in seconds, time the SS searches for (decodable) DL-MAP on a given - ///< channel - uint8_t m_maxContentionRangingRetries; ///< maximum contention ranging retries - - // parameters obtained from DL-MAP - uint8_t m_dcdCount; ///< DCD count - Mac48Address m_baseStationId; ///< base station ID - - // parameters obtained from UL-MAP - uint8_t m_ucdCount; ///< UCD count - double m_allocationStartTime; ///< allocation start time - - // to keep the number of DL-MAP/UL-MAP IEs found in the last DL-MAP/U-MAP messages - uint16_t m_nrDlMapElements; ///< number DL Map elements - uint16_t m_nrUlMapElements; ///< number UL Map elements - - Ptr m_basicConnection; ///< basic connection - Ptr m_primaryConnection; ///< primary connection - - EventId m_lostDlMapEvent; ///< lost DL map event - EventId m_lostUlMapEvent; ///< lost UL map event - EventId m_dcdWaitTimeoutEvent; ///< DCD wait timeout event - EventId m_ucdWaitTimeoutEvent; ///< UCD wait timeout event - EventId m_rangOppWaitTimeoutEvent; ///< range opp wait timeout event - - uint32_t m_nrDlMapRecvd; ///< number DL map received - uint32_t m_nrUlMapRecvd; ///< number UL map received - uint32_t m_nrDcdRecvd; ///< number DCD received - uint32_t m_nrUcdRecvd; ///< number UCD received - - OfdmDlBurstProfile* m_dlBurstProfile; ///< DL burst profile - OfdmUlBurstProfile* m_ulBurstProfile; ///< UL burst profile - - /*represents the (least robust) modulation type of the SS which it then requests in RNG-REQ and - if accepted by BS uses it for receiving and transmitting. currently it is set by user in - simulation script, shall actually be determined based on SS's distance, power, signal etc*/ - WimaxPhy::ModulationType m_modulationType; ///< modulation type - - bool m_areManagementConnectionsAllocated; ///< are management connections allocated - bool m_areServiceFlowsAllocated; ///< are service flows allocated - - Ptr m_scheduler; ///< the scheduler - Ptr m_serviceFlowManager; ///< the service flow manager - Ptr m_classifier; ///< the classifier - - TracedCallback, Mac48Address, const Cid&> - m_traceSSRx; ///< trace SS receive callback - - /** - * The trace source fired when packets come into the "top" of the device - * at the L3/L2 transition, before being queued for transmission. - * - * @see class CallBackTraceSource - */ - TracedCallback> m_ssTxTrace; - - /** - * The trace source fired when packets coming into the "top" of the device - * are dropped at the MAC layer during transmission. - * - * @see class CallBackTraceSource - */ - TracedCallback> m_ssTxDropTrace; - - /** - * The trace source fired for packets successfully received by the device - * immediately before being forwarded up to higher layers (at the L2/L3 - * transition). This is a promiscuous trace. - * - * @see class CallBackTraceSource - */ - TracedCallback> m_ssPromiscRxTrace; - - /** - * The trace source fired for packets successfully received by the device - * immediately before being forwarded up to higher layers (at the L2/L3 - * transition). This is a non- promiscuous trace. - * - * @see class CallBackTraceSource - */ - TracedCallback> m_ssRxTrace; - - /** - * The trace source fired when packets coming into the "top" of the device - * are dropped at the MAC layer during reception. - * - * @see class CallBackTraceSource - */ - TracedCallback> m_ssRxDropTrace; - - /// Bound callback to perform ASCII logging for Enqueue events - AsciiTraceCallback m_asciiTxQueueEnqueueCb; - /// Bound callback to perform ASCII logging for Dequeue events - AsciiTraceCallback m_asciiTxQueueDequeueCb; - /// Bound callback to perform ASCII logging for Drop events - AsciiTraceCallback m_asciiTxQueueDropCb; -}; - -} // namespace ns3 - -#endif /* WIMAX_SS_NET_DEVICE_H */ diff --git a/src/wimax/model/ss-record.cc b/src/wimax/model/ss-record.cc deleted file mode 100644 index 69ad77065..000000000 --- a/src/wimax/model/ss-record.cc +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - * Mohamed Amine Ismail - */ - -#include "ss-record.h" - -#include "service-flow.h" - -#include - -namespace ns3 -{ - -SSRecord::SSRecord() -{ - Initialize(); -} - -SSRecord::SSRecord(Mac48Address macAddress) -{ - m_macAddress = macAddress; - Initialize(); -} - -SSRecord::SSRecord(Mac48Address macAddress, Ipv4Address IPaddress) -{ - m_macAddress = macAddress; - m_IPAddress = IPaddress; - Initialize(); -} - -void -SSRecord::Initialize() -{ - m_basicCid = Cid(); - m_primaryCid = Cid(); - - m_rangingCorrectionRetries = 0; - m_invitedRangingRetries = 0; - m_modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12; - m_rangingStatus = WimaxNetDevice::RANGING_STATUS_EXPIRED; - m_pollForRanging = false; - m_areServiceFlowsAllocated = false; - m_pollMeBit = false; - - m_sfTransactionId = 0; - m_dsaRspRetries = 0; - - m_serviceFlows = new std::vector(); - m_dsaRsp = DsaRsp(); - m_broadcast = false; -} - -SSRecord::~SSRecord() -{ - delete m_serviceFlows; - m_serviceFlows = nullptr; -} - -void -SSRecord::SetIPAddress(Ipv4Address IPAddress) -{ - m_IPAddress = IPAddress; -} - -Ipv4Address -SSRecord::GetIPAddress() -{ - return m_IPAddress; -} - -void -SSRecord::SetBasicCid(Cid basicCid) -{ - m_basicCid = basicCid; -} - -Cid -SSRecord::GetBasicCid() const -{ - return m_basicCid; -} - -void -SSRecord::SetPrimaryCid(Cid primaryCid) -{ - m_primaryCid = primaryCid; -} - -Cid -SSRecord::GetPrimaryCid() const -{ - return m_primaryCid; -} - -void -SSRecord::SetMacAddress(Mac48Address macAddress) -{ - m_macAddress = macAddress; -} - -Mac48Address -SSRecord::GetMacAddress() const -{ - return m_macAddress; -} - -uint8_t -SSRecord::GetRangingCorrectionRetries() const -{ - return m_rangingCorrectionRetries; -} - -void -SSRecord::ResetRangingCorrectionRetries() -{ - m_rangingCorrectionRetries = 0; -} - -void -SSRecord::IncrementRangingCorrectionRetries() -{ - m_rangingCorrectionRetries++; -} - -uint8_t -SSRecord::GetInvitedRangRetries() const -{ - return m_invitedRangingRetries; -} - -void -SSRecord::ResetInvitedRangingRetries() -{ - m_invitedRangingRetries = 0; -} - -void -SSRecord::IncrementInvitedRangingRetries() -{ - m_invitedRangingRetries++; -} - -void -SSRecord::SetModulationType(WimaxPhy::ModulationType modulationType) -{ - m_modulationType = modulationType; -} - -WimaxPhy::ModulationType -SSRecord::GetModulationType() const -{ - return m_modulationType; -} - -void -SSRecord::SetRangingStatus(WimaxNetDevice::RangingStatus rangingStatus) -{ - m_rangingStatus = rangingStatus; -} - -WimaxNetDevice::RangingStatus -SSRecord::GetRangingStatus() const -{ - return m_rangingStatus; -} - -void -SSRecord::EnablePollForRanging() -{ - m_pollForRanging = true; -} - -void -SSRecord::DisablePollForRanging() -{ - m_pollForRanging = false; -} - -bool -SSRecord::GetPollForRanging() const -{ - return m_pollForRanging; -} - -void -SSRecord::SetAreServiceFlowsAllocated(bool val) -{ - m_areServiceFlowsAllocated = val; -} - -bool -SSRecord::GetAreServiceFlowsAllocated() const -{ - return m_areServiceFlowsAllocated; -} - -void -SSRecord::SetPollMeBit(bool pollMeBit) -{ - m_pollMeBit = pollMeBit; -} - -bool -SSRecord::GetPollMeBit() const -{ - return m_pollMeBit; -} - -void -SSRecord::AddServiceFlow(ServiceFlow* serviceFlow) -{ - m_serviceFlows->push_back(serviceFlow); -} - -std::vector -SSRecord::GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const -{ - std::vector tmpServiceFlows; - for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) - { - if (((*iter)->GetSchedulingType() == schedulingType) || - (schedulingType == ServiceFlow::SF_TYPE_ALL)) - { - tmpServiceFlows.push_back(*iter); - } - } - return tmpServiceFlows; -} - -void -SSRecord::SetIsBroadcastSS(bool broadcast_enable) -{ - m_broadcast = broadcast_enable; -} - -bool -SSRecord::GetIsBroadcastSS() const -{ - return m_broadcast; -} - -bool -SSRecord::GetHasServiceFlowUgs() const -{ - for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) - { - if ((*iter)->GetSchedulingType() == ServiceFlow::SF_TYPE_UGS) - { - return true; - } - } - return false; -} - -bool -SSRecord::GetHasServiceFlowRtps() const -{ - for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) - { - if ((*iter)->GetSchedulingType() == ServiceFlow::SF_TYPE_RTPS) - { - return true; - } - } - return false; -} - -bool -SSRecord::GetHasServiceFlowNrtps() const -{ - for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) - { - if ((*iter)->GetSchedulingType() == ServiceFlow::SF_TYPE_NRTPS) - { - return true; - } - } - return false; -} - -bool -SSRecord::GetHasServiceFlowBe() const -{ - for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) - { - if ((*iter)->GetSchedulingType() == ServiceFlow::SF_TYPE_BE) - { - return true; - } - } - return false; -} - -void -SSRecord::SetSfTransactionId(uint16_t sfTransactionId) -{ - m_sfTransactionId = sfTransactionId; -} - -uint16_t -SSRecord::GetSfTransactionId() const -{ - return m_sfTransactionId; -} - -void -SSRecord::SetDsaRspRetries(uint8_t dsaRspRetries) -{ - m_dsaRspRetries = dsaRspRetries; -} - -void -SSRecord::IncrementDsaRspRetries() -{ - m_dsaRspRetries++; -} - -uint8_t -SSRecord::GetDsaRspRetries() const -{ - return m_dsaRspRetries; -} - -void -SSRecord::SetDsaRsp(DsaRsp dsaRsp) -{ - m_dsaRsp = dsaRsp; -} - -DsaRsp -SSRecord::GetDsaRsp() const -{ - return m_dsaRsp; -} - -} // namespace ns3 diff --git a/src/wimax/model/ss-record.h b/src/wimax/model/ss-record.h deleted file mode 100644 index d2b9664c5..000000000 --- a/src/wimax/model/ss-record.h +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - * Mohamed Amine Ismail - */ - -#ifndef SS_RECORD_H -#define SS_RECORD_H - -#include "service-flow.h" -#include "wimax-connection.h" -#include "wimax-net-device.h" -#include "wimax-phy.h" - -#include "ns3/ipv4-address.h" -#include "ns3/mac48-address.h" - -#include -#include - -namespace ns3 -{ - -class ServiceFlow; - -/** - * @ingroup wimax - * @brief This class is used by the base station to store some information related to subscriber - * station in the cell. - */ -class SSRecord -{ - public: - SSRecord(); - /** - * Constructor - * - * @param macAddress MAC address - */ - SSRecord(Mac48Address macAddress); - /** - * Constructor - * - * @param macAddress MAC address - * @param IPaddress IP address - */ - SSRecord(Mac48Address macAddress, Ipv4Address IPaddress); - ~SSRecord(); - - /** - * Set basic CID - * @param basicCid the basic CID - */ - void SetBasicCid(Cid basicCid); - /** - * Get basic CID - * @returns the basic CID - */ - Cid GetBasicCid() const; - - /** - * Set primary CID - * @param primaryCid priamry CID - */ - void SetPrimaryCid(Cid primaryCid); - /** - * Get primary CID - * @returns the CID - */ - Cid GetPrimaryCid() const; - - /** - * Set MAC address - * @param macAddress the MAC address - */ - void SetMacAddress(Mac48Address macAddress); - /** - * Get MAC address - * @returns the MAC address - */ - Mac48Address GetMacAddress() const; - - /** - * Get ranging correction retries - * @returns the ranging correction retries - */ - uint8_t GetRangingCorrectionRetries() const; - /// Reset ranging correction retries - void ResetRangingCorrectionRetries(); - /// Increment ranging correction retries - void IncrementRangingCorrectionRetries(); - /** - * Get invited range retries - * @returns the invited range retries - */ - uint8_t GetInvitedRangRetries() const; - /// Reset invited ranging retries - void ResetInvitedRangingRetries(); - /// Increment invited ranging retries - void IncrementInvitedRangingRetries(); - /** - * Set modulation type - * @param modulationType the modulation type - */ - void SetModulationType(WimaxPhy::ModulationType modulationType); - /** - * Get modulation type - * @returns the modulation type - */ - WimaxPhy::ModulationType GetModulationType() const; - - /** - * Set ranging status - * @param rangingStatus the ranging status - */ - void SetRangingStatus(WimaxNetDevice::RangingStatus rangingStatus); - /** - * Get ranging status - * @returns the ranging status - */ - WimaxNetDevice::RangingStatus GetRangingStatus() const; - - /// Enable poll for ranging function - void EnablePollForRanging(); - /// Disable poll for ranging - void DisablePollForRanging(); - /** - * Get poll for ranging - * @returns the poll for ranging flag - */ - bool GetPollForRanging() const; - - /** - * Check if service flows are allocated - * @returns true if service flows are allocated - */ - bool GetAreServiceFlowsAllocated() const; - - /** - * Set poll ME bit - * @param pollMeBit the poll me bit - */ - void SetPollMeBit(bool pollMeBit); - /** - * Get poll ME bit - * @returns the poll me bit - */ - bool GetPollMeBit() const; - - /** - * Add service flow - * @param serviceFlow the service flow - */ - void AddServiceFlow(ServiceFlow* serviceFlow); - /** - * Get service flows - * @param schedulingType the scheduling type - * @returns the service flow - */ - std::vector GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const; - /** - * Check if at least one flow has scheduling type SF_TYPE_UGS - * @return true if at least one flow has scheduling type SF_TYPE_UGS - */ - bool GetHasServiceFlowUgs() const; - /** - * Check if at least one flow has scheduling type SF_TYPE_RTPS - * @return true if at least one flow has scheduling type SF_TYPE_RTPS - */ - bool GetHasServiceFlowRtps() const; - /** - * Check if at least one flow has scheduling type SF_TYPE_NRTPS - * @return true if at least one flow has scheduling type SF_TYPE_NRTPS - */ - bool GetHasServiceFlowNrtps() const; - /** - * Check if at least one flow has scheduling type SF_TYPE_BE - * @return true if at least one flow has scheduling type SF_TYPE_BE - */ - bool GetHasServiceFlowBe() const; - - /** - * Set SF transaction ID - * @param sfTransactionId the SF transaction ID - */ - void SetSfTransactionId(uint16_t sfTransactionId); - /** - * Get SF transaction ID - * @returns the SF transaction ID - */ - uint16_t GetSfTransactionId() const; - - /** - * Set DSA response retries - * @param dsaRspRetries the DSA response retries - */ - void SetDsaRspRetries(uint8_t dsaRspRetries); - /// Increment DAS response retries - void IncrementDsaRspRetries(); - /** - * Get DSA response retries - * @returns the DSA response retries - */ - uint8_t GetDsaRspRetries() const; - - /** - * Set DSA response - * @param dsaRsp the DSA response - */ - void SetDsaRsp(DsaRsp dsaRsp); - /** - * Get DSA response - * @returns the DSA response - */ - DsaRsp GetDsaRsp() const; - /** - * Set is broadcast SS - * @param broadcast_enable the broadcast enable flag - */ - void SetIsBroadcastSS(bool broadcast_enable); - /** - * Get is broadcast SS - * @returns the is broadcast SS flag - */ - bool GetIsBroadcastSS() const; - - /** - * Get IP address - * @returns the IP address - */ - Ipv4Address GetIPAddress(); - /** - * Set IP address - * @param IPaddress the IP address - */ - void SetIPAddress(Ipv4Address IPaddress); - /** - * Set are service flows allocated - * @param val the service flows allocated flag - */ - void SetAreServiceFlowsAllocated(bool val); - - private: - /// Initialize - void Initialize(); - - Mac48Address m_macAddress; ///< MAC address - Ipv4Address m_IPAddress; ///< IP address - - Cid m_basicCid; ///< basic CID - Cid m_primaryCid; ///< primary CID - - uint8_t m_rangingCorrectionRetries; ///< ranging correction retries - uint8_t m_invitedRangingRetries; ///< invited ranging retries - - WimaxPhy::ModulationType - m_modulationType; ///< least robust burst profile (modulation type) for this SS - WimaxNetDevice::RangingStatus m_rangingStatus; ///< ranging status - bool m_pollForRanging; ///< poll for ranging - bool m_areServiceFlowsAllocated; ///< are service floes allowed - bool m_pollMeBit; ///< if PM (poll me) bit set for this SS - bool m_broadcast; ///< broadcast? - - std::vector* m_serviceFlows; ///< service flows - - // fields for service flow creation - uint16_t m_sfTransactionId; ///< SF transaction ID - uint8_t m_dsaRspRetries; ///< DAS response retries - DsaRsp m_dsaRsp; ///< DSA response -}; - -} // namespace ns3 - -#endif /* SS_RECORD_H */ diff --git a/src/wimax/model/ss-scheduler.cc b/src/wimax/model/ss-scheduler.cc deleted file mode 100644 index ff40f6aac..000000000 --- a/src/wimax/model/ss-scheduler.cc +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#include "ss-scheduler.h" - -#include "connection-manager.h" -#include "service-flow-manager.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-net-device.h" -#include "wimax-connection.h" -#include "wimax-mac-queue.h" -#include "wimax-phy.h" - -#include "ns3/log.h" -#include "ns3/node.h" -#include "ns3/simulator.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("SSScheduler"); - -NS_OBJECT_ENSURE_REGISTERED(SSScheduler); - -TypeId -SSScheduler::GetTypeId() -{ - static TypeId tid = TypeId("ns3::SSScheduler").SetParent().SetGroupName("Wimax"); - return tid; -} - -SSScheduler::SSScheduler(Ptr ss) - : m_ss(ss), - m_pollMe(false) -{ -} - -SSScheduler::~SSScheduler() -{ -} - -void -SSScheduler::DoDispose() -{ - m_ss = nullptr; -} - -void -SSScheduler::SetPollMe(bool pollMe) -{ - m_pollMe = pollMe; -} - -bool -SSScheduler::GetPollMe() const -{ - return m_pollMe; -} - -Ptr -SSScheduler::Schedule(uint16_t availableSymbols, - WimaxPhy::ModulationType modulationType, - MacHeaderType::HeaderType packetType, - Ptr& connection) -{ - Time timeStamp; - Ptr burst = CreateObject(); - uint16_t nrSymbolsRequired = 0; - - if (!connection) - { - connection = SelectConnection(); - } - else - { - NS_ASSERT_MSG(connection->HasPackets(), - "SS: Error while scheduling packets: The selected connection has no packets"); - } - - Ptr packet; - - while (connection && connection->HasPackets(packetType)) - { - NS_LOG_INFO("FRAG_DEBUG: SS Scheduler" << std::endl); - - uint32_t availableByte = m_ss->GetPhy()->GetNrBytes(availableSymbols, modulationType); - - uint32_t requiredByte = connection->GetQueue()->GetFirstPacketRequiredByte(packetType); - - NS_LOG_INFO("\t availableByte = " << availableByte << ", requiredByte = " << requiredByte); - - if (availableByte >= requiredByte) - { - // The SS could sent a packet without a other fragmentation - NS_LOG_INFO("\t availableByte >= requiredByte" - "\n\t Send packet without other fragmentation" - << std::endl); - - packet = connection->Dequeue(packetType); - burst->AddPacket(packet); - - nrSymbolsRequired = m_ss->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType); - availableSymbols -= nrSymbolsRequired; - } - else - { - if (connection->GetType() == Cid::TRANSPORT) - { - NS_LOG_INFO("\t availableByte < requiredByte" - "\n\t Check if the fragmentation is possible"); - - uint32_t headerSize = connection->GetQueue()->GetFirstPacketHdrSize(packetType); - if (!connection->GetQueue()->CheckForFragmentation(packetType)) - { - NS_LOG_INFO("\t Add fragmentSubhdrSize = 2"); - headerSize += 2; - } - NS_LOG_INFO("\t availableByte = " << availableByte - << " headerSize = " << headerSize); - - if (availableByte > headerSize) - { - NS_LOG_INFO("\t Fragmentation IS possible"); - packet = connection->Dequeue(packetType, availableByte); - burst->AddPacket(packet); - - nrSymbolsRequired = - m_ss->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType); - availableSymbols -= nrSymbolsRequired; - } - else - { - NS_LOG_INFO("\t Fragmentation IS NOT possible" << std::endl); - break; - } - } - else - { - NS_LOG_INFO("\t no Transport Connection " - "\n\t Fragmentation IS NOT possible, " - << std::endl); - break; - } - } - } - return burst; -} - -Ptr -SSScheduler::SelectConnection() -{ - Time currentTime = Simulator::Now(); - - NS_LOG_INFO("SS Scheduler: Selecting connection..."); - if (m_ss->GetInitialRangingConnection()->HasPackets()) - { - NS_LOG_INFO("Return GetInitialRangingConnection"); - return m_ss->GetInitialRangingConnection(); - } - if (m_ss->GetBasicConnection()->HasPackets()) - { - NS_LOG_INFO("Return GetBasicConnection"); - return m_ss->GetBasicConnection(); - } - if (m_ss->GetPrimaryConnection()->HasPackets()) - { - NS_LOG_INFO("Return GetPrimaryConnection"); - return m_ss->GetPrimaryConnection(); - } - - auto serviceFlows = m_ss->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_UGS); - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - // making sure that this grant was actually intended for this UGS - - if ((*iter)->HasPackets() && (currentTime + m_ss->GetPhy()->GetFrameDuration() > - MilliSeconds((*iter)->GetUnsolicitedGrantInterval()))) - { - NS_LOG_INFO("Return UGS SF: CID = " << (*iter)->GetCid() - << "SFID = " << (*iter)->GetSfid()); - return (*iter)->GetConnection(); - } - } - - /* In the following cases (rtPS, nrtPS and BE flows) connection is seletected only for data - packets, for bandwidth request packets connection will itself be passed to Schedule () and - hence this function will never be called. */ - - serviceFlows = m_ss->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_RTPS); - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - if ((*iter)->HasPackets(MacHeaderType::HEADER_TYPE_GENERIC) && - (currentTime + m_ss->GetPhy()->GetFrameDuration() > - MilliSeconds((*iter)->GetUnsolicitedPollingInterval()))) - { - NS_LOG_INFO("Return RTPS SF: CID = " << (*iter)->GetCid() - << "SFID = " << (*iter)->GetSfid()); - return (*iter)->GetConnection(); - } - } - - serviceFlows = m_ss->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_NRTPS); - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - if ((*iter)->HasPackets(MacHeaderType::HEADER_TYPE_GENERIC)) - { - NS_LOG_INFO("Return NRTPS SF: CID = " << (*iter)->GetCid() - << "SFID = " << (*iter)->GetSfid()); - return (*iter)->GetConnection(); - } - } - - serviceFlows = m_ss->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_BE); - for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) - { - if ((*iter)->HasPackets(MacHeaderType::HEADER_TYPE_GENERIC)) - { - NS_LOG_INFO("Return BE SF: CID = " << (*iter)->GetCid() - << "SFID = " << (*iter)->GetSfid()); - return (*iter)->GetConnection(); - } - } - - if (m_ss->GetBroadcastConnection()->HasPackets()) - { - return m_ss->GetBroadcastConnection(); - } - NS_LOG_INFO("NO connection is selected!"); - return nullptr; -} - -} // namespace ns3 diff --git a/src/wimax/model/ss-scheduler.h b/src/wimax/model/ss-scheduler.h deleted file mode 100644 index 86663b9d4..000000000 --- a/src/wimax/model/ss-scheduler.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -/* SS outbound scheduler as per in Section 6.3.5.1 */ - -#ifndef SS_SCHEDULER_H -#define SS_SCHEDULER_H - -#include "wimax-mac-header.h" -#include "wimax-phy.h" - -#include "ns3/packet-burst.h" -#include "ns3/packet.h" - -#include - -namespace ns3 -{ - -class SubscriberStationNetDevice; -class WimaxConnection; - -/** - * @ingroup wimax - * @param SSScheduler class - */ -class SSScheduler : public Object -{ - public: - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - /** - * Constructor - * - * @param ss subscriber station device - */ - SSScheduler(Ptr ss); - ~SSScheduler() override; - - // Delete copy constructor and assignment operator to avoid misuse - SSScheduler(const SSScheduler&) = delete; - SSScheduler& operator=(const SSScheduler&) = delete; - - /** - * Set poll me value - * @param pollMe the poll me flag - */ - void SetPollMe(bool pollMe); - /** - * Get the poll me value - * @returns the poll me flag - */ - bool GetPollMe() const; - /** - * @return a list of packet to be sent in the next opportunity - * @param availableSymbols the available resources in symbols - * @param modulationType the used modulation - * @param packetType the type of packets to select from - * @param connection the connection from which packets will be selected - */ - Ptr Schedule(uint16_t availableSymbols, - WimaxPhy::ModulationType modulationType, - MacHeaderType::HeaderType packetType, - Ptr& connection); - - void DoDispose() override; - - private: - /** - * Select connection - * @returns pointer to the wimax connection - */ - Ptr SelectConnection(); - Ptr m_ss; ///< the subscriber station - bool m_pollMe; ///< poll me flag -}; - -} // namespace ns3 - -#endif /* SS_SCHEDULER_H */ diff --git a/src/wimax/model/ss-service-flow-manager.cc b/src/wimax/model/ss-service-flow-manager.cc deleted file mode 100644 index 7f5e3622d..000000000 --- a/src/wimax/model/ss-service-flow-manager.cc +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (c) 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - */ - -#include "bs-net-device.h" -#include "bs-uplink-scheduler.h" -#include "connection-manager.h" -#include "service-flow-manager.h" -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-manager.h" -#include "ss-net-device.h" -#include "ss-record.h" -#include "ss-scheduler.h" -#include "wimax-connection.h" -#include "wimax-net-device.h" - -#include "ns3/buffer.h" -#include "ns3/enum.h" -#include "ns3/log.h" -#include "ns3/node.h" -#include "ns3/packet.h" -#include "ns3/pointer.h" -#include "ns3/simulator.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("SsServiceFlowManager"); - -SsServiceFlowManager::SsServiceFlowManager(Ptr device) - : m_device(device), - m_maxDsaReqRetries(100), - m_dsaReq(DsaReq()), - m_dsaAck(DsaAck()), - m_currentTransactionId(0), - m_transactionIdIndex(1), - m_dsaReqRetries(0), - m_pendingServiceFlow(nullptr) -{ -} - -SsServiceFlowManager::~SsServiceFlowManager() -{ -} - -/* static */ -TypeId -SsServiceFlowManager::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::SsServiceFlowManager").SetParent().SetGroupName("Wimax") - // No AddConstructor because this is an abstract class. - ; - return tid; -} - -void -SsServiceFlowManager::DoDispose() -{ - ServiceFlowManager::DoDispose(); -} - -void -SsServiceFlowManager::SetMaxDsaReqRetries(uint8_t maxDsaReqRetries) -{ - m_maxDsaReqRetries = maxDsaReqRetries; -} - -uint8_t -SsServiceFlowManager::GetMaxDsaReqRetries() const -{ - return m_maxDsaReqRetries; -} - -EventId -SsServiceFlowManager::GetDsaRspTimeoutEvent() const -{ - return m_dsaRspTimeoutEvent; -} - -EventId -SsServiceFlowManager::GetDsaAckTimeoutEvent() const -{ - return m_dsaAckTimeoutEvent; -} - -void -SsServiceFlowManager::AddServiceFlow(ServiceFlow serviceFlow) -{ - auto sf = new ServiceFlow(); - sf->CopyParametersFrom(serviceFlow); - ServiceFlowManager::AddServiceFlow(sf); -} - -void -SsServiceFlowManager::AddServiceFlow(ServiceFlow* serviceFlow) -{ - ServiceFlowManager::AddServiceFlow(serviceFlow); -} - -void -SsServiceFlowManager::InitiateServiceFlows() -{ - ServiceFlow* serviceFlow = GetNextServiceFlowToAllocate(); - NS_ASSERT_MSG( - serviceFlow != nullptr, - "Error while initiating a new service flow: All service flows have been initiated"); - m_pendingServiceFlow = serviceFlow; - ScheduleDsaReq(m_pendingServiceFlow); -} - -DsaReq -SsServiceFlowManager::CreateDsaReq(const ServiceFlow* serviceFlow) -{ - DsaReq dsaReq; - dsaReq.SetTransactionId(m_transactionIdIndex); - m_currentTransactionId = m_transactionIdIndex++; - - /*as it is SS-initiated DSA therefore SFID and CID will - not be included, see 6.3.2.3.10.1 and 6.3.2.3.11.1*/ - dsaReq.SetServiceFlow(*serviceFlow); - // dsaReq.SetParameterSet (*serviceFlow->GetParameterSet ()); - return dsaReq; -} - -Ptr -SsServiceFlowManager::CreateDsaAck() -{ - DsaAck dsaAck; - dsaAck.SetTransactionId(m_dsaReq.GetTransactionId()); - dsaAck.SetConfirmationCode(CONFIRMATION_CODE_SUCCESS); - m_dsaAck = dsaAck; - Ptr p = Create(); - p->AddHeader(dsaAck); - p->AddHeader(ManagementMessageType(ManagementMessageType::MESSAGE_TYPE_DSA_ACK)); - return p; -} - -void -SsServiceFlowManager::ScheduleDsaReq(const ServiceFlow* serviceFlow) -{ - Ptr p = Create(); - DsaReq dsaReq; - Ptr ss = m_device->GetObject(); - - if (m_dsaReqRetries == 0) - { - dsaReq = CreateDsaReq(serviceFlow); - p->AddHeader(dsaReq); - m_dsaReq = dsaReq; - } - else - { - if (m_dsaReqRetries <= m_maxDsaReqRetries) - { - p->AddHeader(m_dsaReq); - } - else - { - NS_LOG_DEBUG("Service flows could not be initialized!"); - } - } - - m_dsaReqRetries++; - p->AddHeader(ManagementMessageType(ManagementMessageType::MESSAGE_TYPE_DSA_REQ)); - - if (m_dsaRspTimeoutEvent.IsPending()) - { - Simulator::Cancel(m_dsaRspTimeoutEvent); - } - - m_dsaRspTimeoutEvent = Simulator::Schedule(ss->GetIntervalT7(), - &SsServiceFlowManager::ScheduleDsaReq, - this, - serviceFlow); - - m_device->Enqueue(p, MacHeaderType(), ss->GetPrimaryConnection()); -} - -void -SsServiceFlowManager::ProcessDsaRsp(const DsaRsp& dsaRsp) -{ - Ptr ss = m_device->GetObject(); - - // already received DSA-RSP for that particular DSA-REQ - if (dsaRsp.GetTransactionId() != m_currentTransactionId) - { - return; - } - - Ptr dsaAck = CreateDsaAck(); - m_device->Enqueue(dsaAck, MacHeaderType(), ss->GetPrimaryConnection()); - - m_dsaReqRetries = 0; - if (m_pendingServiceFlow == nullptr) - { - // May be the DSA-ACK was not received by the SS - return; - } - ServiceFlow sf = dsaRsp.GetServiceFlow(); - (*m_pendingServiceFlow) = sf; - m_pendingServiceFlow->SetUnsolicitedGrantInterval(1); - m_pendingServiceFlow->SetUnsolicitedPollingInterval(1); - Ptr transportConnection = - CreateObject(sf.GetCid(), Cid::TRANSPORT); - - m_pendingServiceFlow->SetConnection(transportConnection); - transportConnection->SetServiceFlow(m_pendingServiceFlow); - ss->GetConnectionManager()->AddConnection(transportConnection, Cid::TRANSPORT); - m_pendingServiceFlow->SetIsEnabled(true); - m_pendingServiceFlow = nullptr; - // check if all service flow have been initiated - ServiceFlow* serviceFlow = GetNextServiceFlowToAllocate(); - if (serviceFlow == nullptr) - { - ss->SetAreServiceFlowsAllocated(true); - } - else - { - m_pendingServiceFlow = serviceFlow; - ScheduleDsaReq(m_pendingServiceFlow); - } -} - -} // namespace ns3 diff --git a/src/wimax/model/ss-service-flow-manager.h b/src/wimax/model/ss-service-flow-manager.h deleted file mode 100644 index 1ee4c4344..000000000 --- a/src/wimax/model/ss-service-flow-manager.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - */ - -#ifndef SS_SERVICE_FLOW_MANAGER_H -#define SS_SERVICE_FLOW_MANAGER_H - -#include "mac-messages.h" -#include "service-flow-manager.h" -#include "ss-net-device.h" - -#include "ns3/buffer.h" -#include "ns3/event-id.h" - -#include - -namespace ns3 -{ - -class Packet; -class ServiceFlow; -class WimaxNetDevice; -class WimaxConnection; -class SubscriberStationNetDevice; - -/** - * @ingroup wimax - * @brief SsServiceFlowManager class - */ -class SsServiceFlowManager : public ServiceFlowManager -{ - public: - /// Confirmation code enumeration - enum ConfirmationCode // as per Table 384 (not all codes implemented) - { - CONFIRMATION_CODE_SUCCESS, - CONFIRMATION_CODE_REJECT - }; - - /** - * Constructor - * - * Creates a service flow manager and attaches it to a device - * - * @param device the device to which the service flow manager will be attached - */ - SsServiceFlowManager(Ptr device); - ~SsServiceFlowManager() override; - void DoDispose() override; - - /** - * Register this type. - * @return The TypeId. - */ - static TypeId GetTypeId(); - - /** - * @brief add a service flow to the list - * @param serviceFlow the service flow to add - */ - void AddServiceFlow(ServiceFlow* serviceFlow); - /** - * @brief add a service flow to the list - * @param serviceFlow the service flow to add - */ - void AddServiceFlow(ServiceFlow serviceFlow); - /** - * @brief sets the maximum retries on DSA request message - * @param maxDsaReqRetries the maximum retries on DSA request message - */ - void SetMaxDsaReqRetries(uint8_t maxDsaReqRetries); - /** - * @return the maximum retries on DSA request message - */ - uint8_t GetMaxDsaReqRetries() const; - - /** - * Get DSA response timeout event - * @returns the DSA response timeout event - */ - EventId GetDsaRspTimeoutEvent() const; - /** - * Get DSA ack timeout event - * @returns the DSA ack timeout event - */ - EventId GetDsaAckTimeoutEvent() const; - - /// Initiate service flows - void InitiateServiceFlows(); - - /** - * Create DSA request - * @param serviceFlow the service flow - * @returns the DSA request - */ - DsaReq CreateDsaReq(const ServiceFlow* serviceFlow); - - /** - * Create DSA ack - * @returns the packet - */ - Ptr CreateDsaAck(); - - /** - * Schedule DSA response - * @param serviceFlow the service flow - */ - void ScheduleDsaReq(const ServiceFlow* serviceFlow); - - /** - * Process DSA response - * @param dsaRsp the DSA response - */ - void ProcessDsaRsp(const DsaRsp& dsaRsp); - - private: - Ptr m_device; ///< the device - - uint8_t m_maxDsaReqRetries; ///< maximum DSA request retries - - EventId m_dsaRspTimeoutEvent; ///< DSA response timeout event - EventId m_dsaAckTimeoutEvent; ///< DSA ack timeout event - - DsaReq m_dsaReq; ///< DSA request - DsaAck m_dsaAck; ///< DSA ack - - uint16_t m_currentTransactionId; ///< current transaction ID - uint16_t m_transactionIdIndex; ///< transaction ID index - uint8_t m_dsaReqRetries; ///< DSA request retries - - // pointer to the service flow currently being configured - ServiceFlow* m_pendingServiceFlow; ///< pending service flow -}; - -} // namespace ns3 - -#endif /* SS_SERVICE_FLOW_MANAGER_H */ diff --git a/src/wimax/model/ul-job.cc b/src/wimax/model/ul-job.cc deleted file mode 100644 index f3f7be9f2..000000000 --- a/src/wimax/model/ul-job.cc +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Juliana Freitag Borin, Flavio Kubota and Nelson L. - * S. da Fonseca - wimaxgroup@lrc.ic.unicamp.br - */ - -#include "ul-job.h" - -#include - -namespace ns3 -{ - -UlJob::UlJob() - : m_deadline(), - m_size(0) -{ -} - -UlJob::~UlJob() -{ -} - -SSRecord* -UlJob::GetSsRecord() const -{ - return m_ssRecord; -} - -void -UlJob::SetSsRecord(SSRecord* ssRecord) -{ - m_ssRecord = ssRecord; -} - -ServiceFlow::SchedulingType -UlJob::GetSchedulingType() const -{ - return m_schedulingType; -} - -void -UlJob::SetSchedulingType(ServiceFlow::SchedulingType schedulingType) -{ - m_schedulingType = schedulingType; -} - -ReqType -UlJob::GetType() const -{ - return m_type; -} - -void -UlJob::SetType(ReqType type) -{ - m_type = type; -} - -ServiceFlow* -UlJob::GetServiceFlow() const -{ - return m_serviceFlow; -} - -void -UlJob::SetServiceFlow(ServiceFlow* serviceFlow) -{ - m_serviceFlow = serviceFlow; -} - -Time -UlJob::GetReleaseTime() const -{ - return m_releaseTime; -} - -void -UlJob::SetReleaseTime(Time releaseTime) -{ - m_releaseTime = releaseTime; -} - -Time -UlJob::GetPeriod() const -{ - return m_period; -} - -void -UlJob::SetPeriod(Time period) -{ - m_period = period; -} - -Time -UlJob::GetDeadline() const -{ - return m_deadline; -} - -void -UlJob::SetDeadline(Time deadline) -{ - m_deadline = deadline; -} - -uint32_t -UlJob::GetSize() const -{ - return m_size; -} - -void -UlJob::SetSize(uint32_t size) -{ - m_size = size; -} - -/** - * @brief equality operator - * @param a first ULJob - * @param b second ULJob - * @returns true if equal - */ -bool -operator==(const UlJob& a, const UlJob& b) -{ - return a.GetServiceFlow() == b.GetServiceFlow() && a.GetSsRecord() == b.GetSsRecord(); -} - -PriorityUlJob::PriorityUlJob() -{ -} - -int -PriorityUlJob::GetPriority() const -{ - return m_priority; -} - -void -PriorityUlJob::SetPriority(int priority) -{ - m_priority = priority; -} - -Ptr -PriorityUlJob::GetUlJob() const -{ - return m_job; -} - -void -PriorityUlJob::SetUlJob(Ptr job) -{ - m_job = job; -} - -} // namespace ns3 diff --git a/src/wimax/model/ul-job.h b/src/wimax/model/ul-job.h deleted file mode 100644 index d43d14800..000000000 --- a/src/wimax/model/ul-job.h +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (c) - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Juliana Freitag Borin, Flavio Kubota and Nelson L. - * S. da Fonseca - wimaxgroup@lrc.ic.unicamp.br - */ - -#ifndef UL_JOB_H -#define UL_JOB_H - -#include "service-flow-record.h" -#include "service-flow.h" -#include "ss-record.h" - -#include "ns3/header.h" - -#include - -namespace ns3 -{ - -class SSRecord; -class ServiceFlow; - -/// Request type enumeration -enum ReqType -{ - DATA, - UNICAST_POLLING -}; - -/** - * @ingroup wimax - * @brief this class implements a structure to compute the priority of service flows - */ -class UlJob : public Object -{ - public: - /// Job priority enumeration - enum JobPriority - { - LOW, - INTERMEDIATE, - HIGH - }; - - UlJob(); - ~UlJob() override; - /** - * Get SS record - * @returns the SS record - */ - SSRecord* GetSsRecord() const; - /** - * Set SS record - * @param ssRecord the SS record - */ - void SetSsRecord(SSRecord* ssRecord); - /** - * Get scheduling type - * @returns the scheduling type - */ - ServiceFlow::SchedulingType GetSchedulingType() const; - /** - * Set scheduling type - * @param schedulingType the scheduling type - */ - void SetSchedulingType(ServiceFlow::SchedulingType schedulingType); - /** - * Get service flow - * @returns the service flow - */ - ServiceFlow* GetServiceFlow() const; - /** - * Set service flow - * @param serviceFlow - */ - void SetServiceFlow(ServiceFlow* serviceFlow); - - /** - * Get type - * @returns the request type - */ - ReqType GetType() const; - /** - * Set type - * @param type the type - */ - void SetType(ReqType type); - - /** - * Get release time - * @returns the release time - */ - Time GetReleaseTime() const; - /** - * Set release time - * @param releaseTime the release time - */ - void SetReleaseTime(Time releaseTime); - - /** - * Get period - * @returns the period time - */ - Time GetPeriod() const; - /** - * Set period - * @param period the period - */ - void SetPeriod(Time period); - - /** - * Get deadline - * @returns the deadline time - */ - Time GetDeadline() const; - /** - * Set deadline - * @param deadline the dead line - */ - void SetDeadline(Time deadline); - - /** - * Get size - * @returns the size - */ - uint32_t GetSize() const; - /** - * Set size - * @param size the size - */ - void SetSize(uint32_t size); - - private: - /// equality operator - friend bool operator==(const UlJob& a, const UlJob& b); - - Time m_releaseTime; ///< The time after which the job can be processed - Time m_period; ///< For periodic jobs - Time m_deadline; ///< Request should be satisfied by this time - uint32_t m_size; ///< Number of minislots requested - ServiceFlow::SchedulingType m_schedulingType; ///< Scheduling type of flow - - SSRecord* m_ssRecord; ///< Pointer to SSRecord - - ReqType m_type; ///< Type of request, DATA or Unicast req slots - ServiceFlow* m_serviceFlow; ///< service flow -}; - -/** - * PriorityUlJob class - */ -class PriorityUlJob : public Object -{ - /** - * @brief this class implements an auxiliary struct to compute the priority of the rtPS and - * nrtPS in the intermediate queue - */ - public: - PriorityUlJob(); - /** - * Get priority - * @returns the priority - */ - int GetPriority() const; - /** - * Set priority - * @param priority the priority - */ - void SetPriority(int priority); - - /** - * Get UL job function - * @returns the UL job - */ - Ptr GetUlJob() const; - /** - * Set UL job - * @param job the UL job - */ - void SetUlJob(Ptr job); - - private: - int m_priority; ///< the priority - Ptr m_job; ///< the job -}; - -/// SortProcess structure -struct SortProcess -{ - /** - * @brief comparison operator - * @param left left side input - * @param right right side input - * @returns true if left is logically less then right for given comparison - */ - bool operator()(PriorityUlJob& left, PriorityUlJob& right) const - { - if (left.GetPriority() < right.GetPriority()) - { - return true; - } - else if (left.GetPriority() == right.GetPriority()) - { - int32_t leftBacklogged = - left.GetUlJob()->GetServiceFlow()->GetRecord()->GetBacklogged(); - int32_t rightBacklogged = - left.GetUlJob()->GetServiceFlow()->GetRecord()->GetBacklogged(); - return leftBacklogged <= rightBacklogged; - } - else - { - return false; - } - } -}; - -/// SortProcessPtr structure -struct SortProcessPtr -{ - /** - * @brief comparison operator - * @param left left side input - * @param right right side input - * @returns true if left is logically less then right for given comparison - */ - bool operator()(Ptr& left, Ptr& right) const - { - if (left->GetPriority() < right->GetPriority()) - { - return true; - } - else if (left->GetPriority() == right->GetPriority()) - { - int32_t leftBacklogged = - left->GetUlJob()->GetServiceFlow()->GetRecord()->GetBacklogged(); - int32_t rightBacklogged = - left->GetUlJob()->GetServiceFlow()->GetRecord()->GetBacklogged(); - return leftBacklogged <= rightBacklogged; - } - else - { - return false; - } - } -}; - -} // namespace ns3 - -#endif /* UL_JOB_H */ diff --git a/src/wimax/model/ul-mac-messages.cc b/src/wimax/model/ul-mac-messages.cc deleted file mode 100644 index 835c6a7f0..000000000 --- a/src/wimax/model/ul-mac-messages.cc +++ /dev/null @@ -1,689 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "ul-mac-messages.h" - -#include - -namespace ns3 -{ - -NS_OBJECT_ENSURE_REGISTERED(Ucd); - -UcdChannelEncodings::UcdChannelEncodings() - : m_bwReqOppSize(0), - m_rangReqOppSize(0), - m_frequency(0) -{ -} - -UcdChannelEncodings::~UcdChannelEncodings() -{ -} - -void -UcdChannelEncodings::SetBwReqOppSize(uint16_t bwReqOppSize) -{ - m_bwReqOppSize = bwReqOppSize; -} - -void -UcdChannelEncodings::SetRangReqOppSize(uint16_t rangReqOppSize) -{ - m_rangReqOppSize = rangReqOppSize; -} - -void -UcdChannelEncodings::SetFrequency(uint32_t frequency) -{ - m_frequency = frequency; -} - -uint16_t -UcdChannelEncodings::GetBwReqOppSize() const -{ - return m_bwReqOppSize; -} - -uint16_t -UcdChannelEncodings::GetRangReqOppSize() const -{ - return m_rangReqOppSize; -} - -uint32_t -UcdChannelEncodings::GetFrequency() const -{ - return m_frequency; -} - -uint16_t -UcdChannelEncodings::GetSize() const -{ - return 2 + 2 + 4; -} - -Buffer::Iterator -UcdChannelEncodings::Write(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU16(m_bwReqOppSize); - i.WriteU16(m_rangReqOppSize); - i.WriteU32(m_frequency); - return DoWrite(i); -} - -Buffer::Iterator -UcdChannelEncodings::Read(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_bwReqOppSize = i.ReadU16(); - m_rangReqOppSize = i.ReadU16(); - m_frequency = i.ReadU32(); - return DoRead(i); -} - -// ---------------------------------------------------------------------------------------------------------- - -OfdmUcdChannelEncodings::OfdmUcdChannelEncodings() - : m_sbchnlReqRegionFullParams(0), - m_sbchnlFocContCodes(0) -{ -} - -OfdmUcdChannelEncodings::~OfdmUcdChannelEncodings() -{ -} - -void -OfdmUcdChannelEncodings::SetSbchnlReqRegionFullParams(uint8_t sbchnlReqRegionFullParams) -{ - m_sbchnlReqRegionFullParams = sbchnlReqRegionFullParams; -} - -void -OfdmUcdChannelEncodings::SetSbchnlFocContCodes(uint8_t sbchnlFocContCodes) -{ - m_sbchnlFocContCodes = sbchnlFocContCodes; -} - -uint8_t -OfdmUcdChannelEncodings::GetSbchnlReqRegionFullParams() const -{ - return m_sbchnlReqRegionFullParams; -} - -uint8_t -OfdmUcdChannelEncodings::GetSbchnlFocContCodes() const -{ - return m_sbchnlFocContCodes; -} - -uint16_t -OfdmUcdChannelEncodings::GetSize() const -{ - return UcdChannelEncodings::GetSize() + 1 + 1; -} - -Buffer::Iterator -OfdmUcdChannelEncodings::DoWrite(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_sbchnlReqRegionFullParams); - i.WriteU8(m_sbchnlFocContCodes); - return i; -} - -Buffer::Iterator -OfdmUcdChannelEncodings::DoRead(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_sbchnlReqRegionFullParams = i.ReadU8(); - m_sbchnlFocContCodes = i.ReadU8(); - return i; -} - -// ---------------------------------------------------------------------------------------------------------- - -OfdmUlBurstProfile::OfdmUlBurstProfile() - : m_type(0), - m_length(0), - m_uiuc(0), - m_fecCodeType(0) -{ -} - -OfdmUlBurstProfile::~OfdmUlBurstProfile() -{ -} - -void -OfdmUlBurstProfile::SetType(uint8_t type) -{ - m_type = type; -} - -void -OfdmUlBurstProfile::SetLength(uint8_t length) -{ - m_length = length; -} - -void -OfdmUlBurstProfile::SetUiuc(uint8_t uiuc) -{ - m_uiuc = uiuc; -} - -void -OfdmUlBurstProfile::SetFecCodeType(uint8_t fecCodeType) -{ - m_fecCodeType = fecCodeType; -} - -uint8_t -OfdmUlBurstProfile::GetType() const -{ - return m_type; -} - -uint8_t -OfdmUlBurstProfile::GetLength() const -{ - return m_length; -} - -uint8_t -OfdmUlBurstProfile::GetUiuc() const -{ - return m_uiuc; -} - -uint8_t -OfdmUlBurstProfile::GetFecCodeType() const -{ - return m_fecCodeType; -} - -uint16_t -OfdmUlBurstProfile::GetSize() const -{ - return 1 + 1 + 1 + 1; -} - -Buffer::Iterator -OfdmUlBurstProfile::Write(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_type); - i.WriteU8(m_length); - i.WriteU8(m_uiuc); - i.WriteU8(m_fecCodeType); - return i; -} - -Buffer::Iterator -OfdmUlBurstProfile::Read(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_type = i.ReadU8(); - m_length = i.ReadU8(); - m_uiuc = i.ReadU8(); - m_fecCodeType = i.ReadU8(); - return i; -} - -// ---------------------------------------------------------------------------------------------------------- - -Ucd::Ucd() - : m_configurationChangeCount(0), - m_rangingBackoffStart(0), - m_rangingBackoffEnd(0), - m_requestBackoffStart(0), - m_requestBackoffEnd(0), - m_nrUlBurstProfiles(0) -{ -} - -Ucd::~Ucd() -{ -} - -void -Ucd::SetConfigurationChangeCount(uint8_t configurationChangeCount) -{ - m_configurationChangeCount = configurationChangeCount; -} - -void -Ucd::SetRangingBackoffStart(uint8_t rangingBackoffStart) -{ - m_rangingBackoffStart = rangingBackoffStart; -} - -void -Ucd::SetRangingBackoffEnd(uint8_t rangingBackoffEnd) -{ - m_rangingBackoffEnd = rangingBackoffEnd; -} - -void -Ucd::SetRequestBackoffStart(uint8_t requestBackoffStart) -{ - m_requestBackoffStart = requestBackoffStart; -} - -void -Ucd::SetRequestBackoffEnd(uint8_t requestBackoffEnd) -{ - m_requestBackoffEnd = requestBackoffEnd; -} - -void -Ucd::SetChannelEncodings(OfdmUcdChannelEncodings channelEncodings) -{ - m_channelEncodings = channelEncodings; -} - -void -Ucd::AddUlBurstProfile(OfdmUlBurstProfile ulBurstProfile) -{ - m_ulBurstProfiles.push_back(ulBurstProfile); -} - -void -Ucd::SetNrUlBurstProfiles(uint8_t nrUlBurstProfiles) -{ - // number of burst profiles is set to number of UL-MAP IEs after processing UL-MAP - m_nrUlBurstProfiles = nrUlBurstProfiles; -} - -uint8_t -Ucd::GetConfigurationChangeCount() const -{ - return m_configurationChangeCount; -} - -uint8_t -Ucd::GetRangingBackoffStart() const -{ - return m_rangingBackoffStart; -} - -uint8_t -Ucd::GetRangingBackoffEnd() const -{ - return m_rangingBackoffEnd; -} - -uint8_t -Ucd::GetRequestBackoffStart() const -{ - return m_requestBackoffStart; -} - -uint8_t -Ucd::GetRequestBackoffEnd() const -{ - return m_requestBackoffEnd; -} - -OfdmUcdChannelEncodings -Ucd::GetChannelEncodings() const -{ - return m_channelEncodings; -} - -std::vector -Ucd::GetUlBurstProfiles() const -{ - return m_ulBurstProfiles; -} - -uint8_t -Ucd::GetNrUlBurstProfiles() const -{ - return m_nrUlBurstProfiles; -} - -std::string -Ucd::GetName() const -{ - return "UCD"; -} - -TypeId -Ucd::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::Ucd").SetParent
().SetGroupName("Wimax").AddConstructor(); - return tid; -} - -TypeId -Ucd::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -Ucd::Print(std::ostream& os) const -{ - os << " configuration change count = " << (uint32_t)m_configurationChangeCount - << ", ranging backoff start = " << (uint32_t)m_rangingBackoffStart - << ", ranging backoff end = " << (uint32_t)m_rangingBackoffEnd - << ", request backoff start = " << (uint32_t)m_requestBackoffStart - << ", request backoff end = " << (uint32_t)m_requestBackoffEnd - << ", number of ul burst profiles = " << m_ulBurstProfiles.size(); -} - -uint32_t -Ucd::GetSerializedSize() const -{ - uint32_t ulBurstProfilesSize = 0; - - for (const auto& burstProfile : m_ulBurstProfiles) - { - ulBurstProfilesSize += burstProfile.GetSize(); - } - - return 5 + m_channelEncodings.GetSize() + ulBurstProfilesSize; -} - -void -Ucd::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_configurationChangeCount); - i.WriteU8(m_rangingBackoffStart); - i.WriteU8(m_rangingBackoffEnd); - i.WriteU8(m_requestBackoffStart); - i.WriteU8(m_requestBackoffEnd); - i = m_channelEncodings.Write(i); - - for (const auto& burstProfile : m_ulBurstProfiles) - { - i = burstProfile.Write(i); - } -} - -uint32_t -Ucd::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_configurationChangeCount = i.ReadU8(); - m_rangingBackoffStart = i.ReadU8(); - m_rangingBackoffEnd = i.ReadU8(); - m_requestBackoffStart = i.ReadU8(); - m_requestBackoffEnd = i.ReadU8(); - i = m_channelEncodings.Read(i); - - for (uint8_t j = 0; j < m_nrUlBurstProfiles; j++) - { - OfdmUlBurstProfile burstProfile; - i = burstProfile.Read(i); - AddUlBurstProfile(burstProfile); - } - - return i.GetDistanceFrom(start); -} - -// ---------------------------------------------------------------------------------------------------------- - -OfdmUlMapIe::OfdmUlMapIe() - : m_cid(), - m_startTime(0), - m_subchannelIndex(0), - m_uiuc(0), - m_duration(0), - m_midambleRepetitionInterval(0) -{ -} - -OfdmUlMapIe::~OfdmUlMapIe() -{ -} - -void -OfdmUlMapIe::SetCid(const Cid& cid) -{ - m_cid = cid; -} - -void -OfdmUlMapIe::SetStartTime(uint16_t startTime) -{ - m_startTime = startTime; -} - -void -OfdmUlMapIe::SetSubchannelIndex(uint8_t subchannelIndex) -{ - m_subchannelIndex = subchannelIndex; -} - -void -OfdmUlMapIe::SetUiuc(uint8_t uiuc) -{ - m_uiuc = uiuc; -} - -void -OfdmUlMapIe::SetDuration(uint16_t duration) -{ - m_duration = duration; -} - -void -OfdmUlMapIe::SetMidambleRepetitionInterval(uint8_t midambleRepetitionInterval) -{ - m_midambleRepetitionInterval = midambleRepetitionInterval; -} - -Cid -OfdmUlMapIe::GetCid() const -{ - return m_cid; -} - -uint16_t -OfdmUlMapIe::GetStartTime() const -{ - return m_startTime; -} - -uint8_t -OfdmUlMapIe::GetSubchannelIndex() const -{ - return m_subchannelIndex; -} - -uint8_t -OfdmUlMapIe::GetUiuc() const -{ - return m_uiuc; -} - -uint16_t -OfdmUlMapIe::GetDuration() const -{ - return m_duration; -} - -uint8_t -OfdmUlMapIe::GetMidambleRepetitionInterval() const -{ - return m_midambleRepetitionInterval; -} - -uint16_t -OfdmUlMapIe::GetSize() const -{ - return 2 + 2 + 1 + 1 + 2 + 1; -} - -Buffer::Iterator -OfdmUlMapIe::Write(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU16(m_cid.GetIdentifier()); - i.WriteU16(m_startTime); - i.WriteU8(m_subchannelIndex); - i.WriteU8(m_uiuc); - i.WriteU16(m_duration); - i.WriteU8(m_midambleRepetitionInterval); - return i; -} - -Buffer::Iterator -OfdmUlMapIe::Read(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_cid = i.ReadU16(); - m_startTime = i.ReadU16(); - m_subchannelIndex = i.ReadU8(); - m_uiuc = i.ReadU8(); - m_duration = i.ReadU16(); - m_midambleRepetitionInterval = i.ReadU8(); - return i; -} - -// ---------------------------------------------------------------------------------------------------------- - -NS_OBJECT_ENSURE_REGISTERED(UlMap); - -UlMap::UlMap() - : m_reserved(0), - m_ucdCount(0), - m_allocationStartTime(0) -{ -} - -UlMap::~UlMap() -{ -} - -void -UlMap::SetUcdCount(uint8_t ucdCount) -{ - m_ucdCount = ucdCount; -} - -void -UlMap::SetAllocationStartTime(uint32_t allocationStartTime) -{ - m_allocationStartTime = allocationStartTime; -} - -void -UlMap::AddUlMapElement(OfdmUlMapIe ulMapElement) -{ - m_ulMapElements.push_back(ulMapElement); -} - -uint8_t -UlMap::GetUcdCount() const -{ - return m_ucdCount; -} - -uint32_t -UlMap::GetAllocationStartTime() const -{ - return m_allocationStartTime; -} - -std::list -UlMap::GetUlMapElements() const -{ - return m_ulMapElements; -} - -std::string -UlMap::GetName() const -{ - return "UL-MAP"; -} - -TypeId -UlMap::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::UlMap").SetParent
().SetGroupName("Wimax").AddConstructor(); - return tid; -} - -TypeId -UlMap::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -UlMap::Print(std::ostream& os) const -{ - os << " ucd count = " << (uint32_t)m_ucdCount - << ", allocation start time = " << m_allocationStartTime - << ", number of ul-map elements = " << m_ulMapElements.size(); -} - -uint32_t -UlMap::GetSerializedSize() const -{ - uint32_t ulMapElementsSize = 0; - - for (const auto& ulMapIe : m_ulMapElements) - { - ulMapElementsSize += ulMapIe.GetSize(); - } - - return 1 + 1 + 4 + ulMapElementsSize; -} - -void -UlMap::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_reserved); - i.WriteU8(m_ucdCount); - i.WriteU32(m_allocationStartTime); - - for (const auto& ulMapIe : m_ulMapElements) - { - i = ulMapIe.Write(i); - } -} - -uint32_t -UlMap::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_reserved = i.ReadU8(); - m_ucdCount = i.ReadU8(); - m_allocationStartTime = i.ReadU32(); - - m_ulMapElements.clear(); // only for printing, otherwise it shows wrong number of elements - - while (true) - { - OfdmUlMapIe ulMapIe; - i = ulMapIe.Read(i); - - AddUlMapElement(ulMapIe); - - if (ulMapIe.GetUiuc() == 14) // End of Map IE - { - break; - } - } - return i.GetDistanceFrom(start); -} - -} // namespace ns3 diff --git a/src/wimax/model/ul-mac-messages.h b/src/wimax/model/ul-mac-messages.h deleted file mode 100644 index 528c0f7cd..000000000 --- a/src/wimax/model/ul-mac-messages.h +++ /dev/null @@ -1,640 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#ifndef UCD_CHANNEL_ENCODINGS_H -#define UCD_CHANNEL_ENCODINGS_H - -#include "ns3/buffer.h" - -#include -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * This class implements the UCD channel encodings as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 11.3.1 UCD channel encodings, page 651 - */ -class UcdChannelEncodings -{ - public: - UcdChannelEncodings(); - virtual ~UcdChannelEncodings(); - - /** - * Set BW request opp size - * @param bwReqOppSize the bandwidth request opp size - */ - void SetBwReqOppSize(uint16_t bwReqOppSize); - /** - * Set range request opp size - * @param rangReqOppSize the ranging request opp size - */ - void SetRangReqOppSize(uint16_t rangReqOppSize); - /** - * Set frequency - * @param frequency the frequency - */ - void SetFrequency(uint32_t frequency); - - /** - * Get BW request opp size - * @returns the bandwidth request opp size - */ - uint16_t GetBwReqOppSize() const; - /** - * Get range request opp size - * @returns the ragning request opp size - */ - uint16_t GetRangReqOppSize() const; - /** - * Get frequency - * @returns the frequency - */ - uint32_t GetFrequency() const; - - /** - * Get size - * @returns the size - */ - uint16_t GetSize() const; - - /** - * Write item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator Write(Buffer::Iterator start) const; - /** - * Read item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator Read(Buffer::Iterator start); - - private: - /** - * Write item - * @param start the iterator - * @returns the updated iterator - */ - virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const = 0; - /** - * Read item - * @param start the iterator - * @returns the updated iterator - */ - virtual Buffer::Iterator DoRead(Buffer::Iterator start) = 0; - - uint16_t m_bwReqOppSize; ///< BW request opp size - uint16_t m_rangReqOppSize; ///< range request opp size - uint32_t m_frequency; ///< frequency -}; - -} // namespace ns3 - -#endif /* UCD_CHANNEL_ENCODINGS_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef OFDM_UCD_CHANNEL_ENCODINGS_H -#define OFDM_UCD_CHANNEL_ENCODINGS_H - -#include - -namespace ns3 -{ - -/** - * This class implements the OFDM UCD channel encodings as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 11.3.1 UCD channel encodings, page 651 - */ -class OfdmUcdChannelEncodings : public UcdChannelEncodings -{ - public: - OfdmUcdChannelEncodings(); - ~OfdmUcdChannelEncodings() override; - - /** - * Set SB channel reguest region full parameters - * @param sbchnlReqRegionFullParams the channel request region full parameters - */ - void SetSbchnlReqRegionFullParams(uint8_t sbchnlReqRegionFullParams); - /** - * Set SB channel for control codes - * @param sbchnlFocContCodes the channel control codes - */ - void SetSbchnlFocContCodes(uint8_t sbchnlFocContCodes); - - /** - * Get SB channel request region full parameters - * @returns the channel request region full parameters - */ - uint8_t GetSbchnlReqRegionFullParams() const; - /** - * Get SB channel for control codes - * @returns the channel for control codes - */ - uint8_t GetSbchnlFocContCodes() const; - - /** - * Get size - * @returns the size - */ - uint16_t GetSize() const; - - private: - /** - * Write item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator DoWrite(Buffer::Iterator start) const override; - /** - * Read item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator DoRead(Buffer::Iterator start) override; - - uint8_t m_sbchnlReqRegionFullParams; ///< SB channel request region full parameters - uint8_t m_sbchnlFocContCodes; ///< SB channel for control codes -}; - -} // namespace ns3 - -#endif /* OFDM_UCD_CHANNEL_ENCODINGS_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef OFDM_UL_BURST_PROFILE_H -#define OFDM_UL_BURST_PROFILE_H - -#include "ns3/buffer.h" - -#include - -namespace ns3 -{ - -/** - * This class implements the UL burst profile as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 11.3.1.1 Uplink burst profile encodings, page 655 - */ -class OfdmUlBurstProfile -{ - public: - /// UIUC enumeraton - enum Uiuc - { - UIUC_INITIAL_RANGING = 1, - UIUC_REQ_REGION_FULL, - UIUC_REQ_REGION_FOCUSED, - UIUC_FOCUSED_CONTENTION_IE, - UIUC_BURST_PROFILE_5, - UIUC_BURST_PROFILE_6, - UIUC_BURST_PROFILE_7, - UIUC_BURST_PROFILE_8, - UIUC_BURST_PROFILE_9, - UIUC_BURST_PROFILE_10, - UIUC_BURST_PROFILE_11, - UIUC_BURST_PROFILE_12, - UIUC_SUBCH_NETWORK_ENTRY, - UIUC_END_OF_MAP - }; - - OfdmUlBurstProfile(); - ~OfdmUlBurstProfile(); - - /** - * Set type - * @param type the type - */ - void SetType(uint8_t type); - /** - * Set length - * @param length the length - */ - void SetLength(uint8_t length); - /** - * Set UIUC - * @param uiuc the UIUC - */ - void SetUiuc(uint8_t uiuc); - /** - * Set FEC code type - * @param fecCodeType the FEC code type - */ - void SetFecCodeType(uint8_t fecCodeType); - - /** - * Get type - * @returns the type - */ - uint8_t GetType() const; - /** - * Get length - * @returns the length - */ - uint8_t GetLength() const; - /** - * Get UIUC - * @returns the UIUC - */ - uint8_t GetUiuc() const; - /** - * Get FEC code type - * @returns the FEC code type - */ - uint8_t GetFecCodeType() const; - - /** - * Get size - * @returns the size - */ - uint16_t GetSize() const; - - /** - * Write item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator Write(Buffer::Iterator start) const; - /** - * Read item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator Read(Buffer::Iterator start); - - private: - uint8_t m_type; ///< type - uint8_t m_length; ///< length - uint8_t m_uiuc; ///< UIUC - - // TLV Encoded information - uint8_t m_fecCodeType; ///< FEC code type -}; - -} // namespace ns3 - -#endif /* OFDM_UL_BURST_PROFILE_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef UCD_H -#define UCD_H - -#include "ns3/header.h" - -#include -#include - -namespace ns3 -{ - -/** - * This class implements the UCD message as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 6.3.2.3.3 Uplink Channel Descriptor (UCD) message, page 47 - */ -class Ucd : public Header -{ - public: - Ucd(); - ~Ucd() override; - - /** - * Set configuration change count - * @param ucdCount the UCD count - */ - void SetConfigurationChangeCount(uint8_t ucdCount); - /** - * Set ranging backoff start - * @param rangingBackoffStart ranging backoff start - */ - void SetRangingBackoffStart(uint8_t rangingBackoffStart); - /** - * Set ranging backoff end - * @param rangingBackoffEnd the ranging backoff end - */ - void SetRangingBackoffEnd(uint8_t rangingBackoffEnd); - /** - * Set request backoff start - * @param requestBackoffStart the request backoff start - */ - void SetRequestBackoffStart(uint8_t requestBackoffStart); - /** - * Set request backoff end - * @param requestBackoffEnd the request backoff end - */ - void SetRequestBackoffEnd(uint8_t requestBackoffEnd); - /** - * Set channel encodings - * @param channelEncodings the channel encodings - */ - void SetChannelEncodings(OfdmUcdChannelEncodings channelEncodings); - /** - * Add UL burst profile - * @param ulBurstProfile the UL burst profile - */ - void AddUlBurstProfile(OfdmUlBurstProfile ulBurstProfile); - /** - * Set NR UL burst profiles - * @param nrUlBurstProfiles the NR UL burst profiles - */ - void SetNrUlBurstProfiles(uint8_t nrUlBurstProfiles); - - /** - * Get configuration change count - * @returns the configuration change count - */ - uint8_t GetConfigurationChangeCount() const; - /** - * Get ranging backoff start - * @returns the ranging backoff start - */ - uint8_t GetRangingBackoffStart() const; - /** - * Get ranging backoff end - * @returns the ranging backoff end value - */ - uint8_t GetRangingBackoffEnd() const; - /** - * Get request backoff start - * @returns the request backoff start value - */ - uint8_t GetRequestBackoffStart() const; - /** - * Get request backoff end - * @returns the request backoff end value - */ - uint8_t GetRequestBackoffEnd() const; - /** - * Get channel encodings - * @returns the OFDM UCD channel encodings - */ - OfdmUcdChannelEncodings GetChannelEncodings() const; - /** - * Get UL burst profiles - * @returns the UL burst profile - */ - std::vector GetUlBurstProfiles() const; - /** - * Get number UL burst profiles - * @returns the number of UL burst profiles - */ - uint8_t GetNrUlBurstProfiles() const; - - /** - * Get name - * @returns the name string - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - uint8_t m_configurationChangeCount; ///< configuration change count - uint8_t m_rangingBackoffStart; ///< ranging backoff start - uint8_t m_rangingBackoffEnd; ///< ranging backoff end - uint8_t m_requestBackoffStart; ///< request backoff start - uint8_t m_requestBackoffEnd; ///< request backoff end - OfdmUcdChannelEncodings m_channelEncodings; ///< TLV Encoded information for the overall channel - std::vector m_ulBurstProfiles; ///< UL burst profiles - - uint8_t m_nrUlBurstProfiles; ///< number UL burst profiles -}; - -} // namespace ns3 - -#endif /* UCD_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef OFDM_UL_MAP_IE_H -#define OFDM_UL_MAP_IE_H - -#include "cid.h" - -#include "ns3/header.h" - -#include - -namespace ns3 -{ - -/** - * This class implements the UL-MAP_IE message as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 6.3.2.3.43.7 UL-MAP_IE, page 115 - */ -class OfdmUlMapIe -{ - public: - OfdmUlMapIe(); - ~OfdmUlMapIe(); - - /** - * Set CID - * @param cid the CID - */ - void SetCid(const Cid& cid); - /** - * Set start time - * @param startTime the start time - */ - void SetStartTime(uint16_t startTime); - /** - * Set subchannel index - * @param subchannelIndex - */ - void SetSubchannelIndex(uint8_t subchannelIndex); - /** - * Set UIUC - * @param uiuc the UIUC - */ - void SetUiuc(uint8_t uiuc); - /** - * Set duration - * @param duration the duration - */ - void SetDuration(uint16_t duration); - /** - * Set midambe repetition interval - * @param midambleRepetitionInterval the midambe repetition interval - */ - void SetMidambleRepetitionInterval(uint8_t midambleRepetitionInterval); - - /** - * Get CID - * @returns the CID - */ - Cid GetCid() const; - /** - * Get start time - * @returns the start time - */ - uint16_t GetStartTime() const; - /** - * Get subchannel index - * @returns the subchannel index - */ - uint8_t GetSubchannelIndex() const; - /** - * Get UIUC - * @returns the UIUC - */ - uint8_t GetUiuc() const; - /** - * Get duration - * @returns the duration - */ - uint16_t GetDuration() const; - /** - * Get Midamble repetition interval - * @returns the midamble repetition interval - */ - uint8_t GetMidambleRepetitionInterval() const; - - /** - * Get size - * @returns the size - */ - uint16_t GetSize() const; - - /** - * Write item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator Write(Buffer::Iterator start) const; - /** - * Read item - * @param start the iterator - * @returns the updated iterator - */ - Buffer::Iterator Read(Buffer::Iterator start); - - private: - Cid m_cid; ///< CID - uint16_t m_startTime; ///< start time - uint8_t m_subchannelIndex; ///< subchannel index - uint8_t m_uiuc; ///< UIUC - uint16_t m_duration; ///< duration - uint8_t m_midambleRepetitionInterval; ///< midamble repetition interval - - // fields to be implemented later on: - // m_focusedContentionIe() - // m_subchannelizedNetworkEntryIe() - // m_ulExtendedIe() - // m_paddingNibble; -}; - -} // namespace ns3 - -#endif /* OFDM_UL_MAP_IE_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef UL_MAP_H -#define UL_MAP_H - -#include "ns3/header.h" - -#include -#include - -namespace ns3 -{ - -/** - * This class implements the UL-MAP_IE message as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems" 8.2.1.8.2 Compressed UL-MAP, page 404 - */ -class UlMap : public Header -{ - public: - UlMap(); - ~UlMap() override; - - /** - * Set UCD count - * @param ucdCount the UCD count - */ - void SetUcdCount(uint8_t ucdCount); - /** - * Set allocation start time - * @param allocationStartTime the allocation start time - */ - void SetAllocationStartTime(uint32_t allocationStartTime); - /** - * Add UL map element - * @param ulMapElement the UL map element - */ - void AddUlMapElement(OfdmUlMapIe ulMapElement); - - /** - * Get UCD count - * @returns the UCD count - */ - uint8_t GetUcdCount() const; - /** - * Get allocation start time - * @returns the allocation start time - */ - uint32_t GetAllocationStartTime() const; - /** - * Get UL map elements - * @returns the UL map elements - */ - std::list GetUlMapElements() const; - - /** - * Get name - * @returns the name - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - uint8_t m_reserved; ///< changed as per the amendment 802.16e-2005 - - uint8_t m_ucdCount; ///< UCD count - uint32_t m_allocationStartTime; ///< allocation start time - std::list m_ulMapElements; ///< UL map elements -}; - -} // namespace ns3 - -#endif /* UL_MAP_H */ diff --git a/src/wimax/model/wimax-channel.cc b/src/wimax/model/wimax-channel.cc deleted file mode 100644 index b15730415..000000000 --- a/src/wimax/model/wimax-channel.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#include "wimax-channel.h" - -#include "wimax-phy.h" - -#include "ns3/assert.h" -#include "ns3/net-device.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("WimaxChannel"); - -NS_OBJECT_ENSURE_REGISTERED(WimaxChannel); - -TypeId -WimaxChannel::GetTypeId() -{ - static TypeId tid = TypeId("ns3::WimaxChannel").SetParent().SetGroupName("Wimax"); - return tid; -} - -WimaxChannel::WimaxChannel() -{ -} - -WimaxChannel::~WimaxChannel() -{ -} - -void -WimaxChannel::Attach(Ptr phy) -{ - DoAttach(phy); -} - -std::size_t -WimaxChannel::GetNDevices() const -{ - return DoGetNDevices(); -} - -Ptr -WimaxChannel::GetDevice(std::size_t index) const -{ - return DoGetDevice(index); -} - -} // namespace ns3 diff --git a/src/wimax/model/wimax-channel.h b/src/wimax/model/wimax-channel.h deleted file mode 100644 index ed11c4f87..000000000 --- a/src/wimax/model/wimax-channel.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#ifndef WIMAX_CHANNEL_H -#define WIMAX_CHANNEL_H - -#include "wimax-connection.h" - -#include "ns3/channel.h" -#include "ns3/log.h" - -#include - -namespace ns3 -{ - -class WimaxPhy; -class Packet; -class Position; -class PacketBurst; - -/** - * @ingroup wimax - * The channel object to attach Wimax NetDevices - */ -class WimaxChannel : public Channel -{ - public: - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - WimaxChannel(); - ~WimaxChannel() override; - /** - * @brief attach the channel to a physical layer of a device - * @param phy the physical layer to which the channel will be attached - */ - void Attach(Ptr phy); - /** - * @return the number of attached devices - */ - std::size_t GetNDevices() const override; - /** - * @param i the ith device - * @return the ith attached device - */ - Ptr GetDevice(std::size_t i) const override; - - /** - * Assign a fixed random variable stream number to the random variables - * used by this model. Return the number of streams (possibly zero) that - * have been assigned. - * - * @param stream first stream index to use - * @return the number of stream indices assigned by this model - */ - virtual int64_t AssignStreams(int64_t stream) = 0; - - private: - /** - * Attach a phy to the channel - * @param phy the phy object to attach - */ - virtual void DoAttach(Ptr phy) = 0; - - /** - * Get number of devices on the channel - * @returns the number of devices - */ - virtual std::size_t DoGetNDevices() const = 0; - /** - * Get device corresponding to index - * @param i the device index - * @returns the device - */ - virtual Ptr DoGetDevice(std::size_t i) const = 0; -}; - -} // namespace ns3 - -#endif /* WIMAX_CHANNEL_H */ diff --git a/src/wimax/model/wimax-connection.cc b/src/wimax/model/wimax-connection.cc deleted file mode 100644 index d1260a050..000000000 --- a/src/wimax/model/wimax-connection.cc +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - */ - -#include "wimax-connection.h" - -#include "service-flow.h" - -#include "ns3/enum.h" -#include "ns3/pointer.h" -#include "ns3/uinteger.h" - -namespace ns3 -{ - -NS_OBJECT_ENSURE_REGISTERED(WimaxConnection); - -TypeId -WimaxConnection::GetTypeId() -{ - static TypeId tid = TypeId("ns3::WimaxConnection") - - .SetParent() - - .SetGroupName("Wimax") - - .AddAttribute("Type", - "Connection type", - EnumValue(Cid::INITIAL_RANGING), - MakeEnumAccessor(&WimaxConnection::GetType), - MakeEnumChecker(Cid::BROADCAST, - "Broadcast", - Cid::INITIAL_RANGING, - "InitialRanging", - Cid::BASIC, - "Basic", - Cid::PRIMARY, - "Primary", - Cid::TRANSPORT, - "Transport", - Cid::MULTICAST, - "Multicast", - Cid::PADDING, - "Padding")) - - .AddAttribute("TxQueue", - "Transmit queue", - PointerValue(), - MakePointerAccessor(&WimaxConnection::GetQueue), - MakePointerChecker()); - return tid; -} - -WimaxConnection::WimaxConnection(Cid cid, Cid::Type type) - : m_cid(cid), - m_cidType(type), - m_queue(CreateObject(1024)), - m_serviceFlow(nullptr) -{ -} - -WimaxConnection::~WimaxConnection() -{ -} - -void -WimaxConnection::DoDispose() -{ - m_queue = nullptr; - // m_serviceFlow = 0; -} - -Cid -WimaxConnection::GetCid() const -{ - return m_cid; -} - -Cid::Type -WimaxConnection::GetType() const -{ - return m_cidType; -} - -Ptr -WimaxConnection::GetQueue() const -{ - return m_queue; -} - -void -WimaxConnection::SetServiceFlow(ServiceFlow* serviceFlow) -{ - m_serviceFlow = serviceFlow; -} - -ServiceFlow* -WimaxConnection::GetServiceFlow() const -{ - return m_serviceFlow; -} - -uint8_t -WimaxConnection::GetSchedulingType() const -{ - return m_serviceFlow->GetSchedulingType(); -} - -bool -WimaxConnection::Enqueue(Ptr packet, - const MacHeaderType& hdrType, - const GenericMacHeader& hdr) -{ - return m_queue->Enqueue(packet, hdrType, hdr); -} - -Ptr -WimaxConnection::Dequeue(MacHeaderType::HeaderType packetType) -{ - return m_queue->Dequeue(packetType); -} - -Ptr -WimaxConnection::Dequeue(MacHeaderType::HeaderType packetType, uint32_t availableByte) -{ - return m_queue->Dequeue(packetType, availableByte); -} - -bool -WimaxConnection::HasPackets() const -{ - return !m_queue->IsEmpty(); -} - -bool -WimaxConnection::HasPackets(MacHeaderType::HeaderType packetType) const -{ - return !m_queue->IsEmpty(packetType); -} - -std::string -WimaxConnection::GetTypeStr() const -{ - switch (m_cidType) - { - case Cid::BROADCAST: - return "Broadcast"; - case Cid::INITIAL_RANGING: - return "Initial Ranging"; - case Cid::BASIC: - return "Basic"; - case Cid::PRIMARY: - return "Primary"; - case Cid::TRANSPORT: - return "Transport"; - case Cid::MULTICAST: - return "Multicast"; - default: - NS_FATAL_ERROR("Invalid connection type"); - } - - return ""; -} - -// Defragmentation Function -const WimaxConnection::FragmentsQueue -WimaxConnection::GetFragmentsQueue() const -{ - return m_fragmentsQueue; -} - -void -WimaxConnection::FragmentEnqueue(Ptr fragment) -{ - m_fragmentsQueue.push_back(fragment); -} - -void -WimaxConnection::ClearFragmentsQueue() -{ - m_fragmentsQueue.clear(); -} -} // namespace ns3 diff --git a/src/wimax/model/wimax-connection.h b/src/wimax/model/wimax-connection.h deleted file mode 100644 index 0c74ee758..000000000 --- a/src/wimax/model/wimax-connection.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - * Mohamed Amine Ismail - */ - -#ifndef WIMAX_CONNECTION_H -#define WIMAX_CONNECTION_H - -#include "cid.h" -#include "service-flow.h" -#include "wimax-mac-header.h" -#include "wimax-mac-queue.h" - -#include "ns3/object.h" - -#include -#include - -namespace ns3 -{ - -class ServiceFlow; -class Cid; - -/** - * @ingroup wimax - * Class to represent WiMAX connections - */ -class WimaxConnection : public Object -{ - public: - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - - /** - * Constructor - * - * @param cid connection ID - * @param type CID type - */ - WimaxConnection(Cid cid, Cid::Type type); - ~WimaxConnection() override; - - /** - * Get CID function - * @returns the CID - */ - Cid GetCid() const; - - /** - * Get type function - * @returns the type - */ - Cid::Type GetType() const; - /** - * @return the queue of the connection - */ - Ptr GetQueue() const; - /** - * @brief set the service flow associated to this connection - * @param serviceFlow The service flow to be associated to this connection - */ - void SetServiceFlow(ServiceFlow* serviceFlow); - /** - * @return the service flow associated to this connection - */ - ServiceFlow* GetServiceFlow() const; - - // wrapper functions - /** - * @return the scheduling type of this connection - */ - uint8_t GetSchedulingType() const; - /** - * @brief enqueue a packet in the queue of the connection - * @param packet the packet to be enqueued - * @param hdrType the header type of the packet - * @param hdr the header of the packet - * @return true if successful - */ - bool Enqueue(Ptr packet, const MacHeaderType& hdrType, const GenericMacHeader& hdr); - /** - * @brief dequeue a packet from the queue of the connection - * @param packetType the type of the packet to dequeue - * @return packet dequeued - */ - Ptr Dequeue(MacHeaderType::HeaderType packetType = MacHeaderType::HEADER_TYPE_GENERIC); - /** - * @brief dequeue a packet from the queue of the connection - * Dequeue the first packet in the queue if its size is lower than - * availableByte, the first availableByte of the first packet otherwise - * - * @param packetType the type of the packet to dequeue - * @param availableByte the number of available bytes - * @return packet dequeued - */ - Ptr Dequeue(MacHeaderType::HeaderType packetType, uint32_t availableByte); - /** - * @return true if the connection has at least one packet in its queue, false otherwise - */ - bool HasPackets() const; - /** - * @return true if the connection has at least one packet of type packetType in its queue, false - * otherwise - * @param packetType type of packet to check in the queue - * @return true if packets available - */ - bool HasPackets(MacHeaderType::HeaderType packetType) const; - - /** - * Get type string - * @returns the type string - */ - std::string GetTypeStr() const; - - /// Definition of Fragments Queue data type - typedef std::list> FragmentsQueue; - /** - * @brief get a queue of received fragments - * @returns the fragments queue - */ - const FragmentsQueue GetFragmentsQueue() const; - /** - * @brief enqueue a received packet (that is a fragment) into the fragments queue - * @param fragment received fragment - */ - void FragmentEnqueue(Ptr fragment); - /** - * @brief delete all enqueued fragments - */ - void ClearFragmentsQueue(); - - private: - void DoDispose() override; - - Cid m_cid; ///< CID - Cid::Type m_cidType; ///< CID type - Ptr m_queue; ///< queue - ServiceFlow* m_serviceFlow; ///< service flow - - // FragmentsQueue stores all received fragments - FragmentsQueue m_fragmentsQueue; ///< fragments queue -}; - -} // namespace ns3 - -#endif /* WIMAX_CONNECTION_H */ diff --git a/src/wimax/model/wimax-mac-header.cc b/src/wimax/model/wimax-mac-header.cc deleted file mode 100644 index c3e685b10..000000000 --- a/src/wimax/model/wimax-mac-header.cc +++ /dev/null @@ -1,719 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "wimax-mac-header.h" - -#include "crc8.h" - -namespace ns3 -{ - -NS_OBJECT_ENSURE_REGISTERED(MacHeaderType); - -MacHeaderType::MacHeaderType() - : m_type(0) -{ -} - -MacHeaderType::MacHeaderType(uint8_t type) - : m_type(type) -{ -} - -MacHeaderType::~MacHeaderType() -{ -} - -void -MacHeaderType::SetType(uint8_t type) -{ - m_type = type; -} - -uint8_t -MacHeaderType::GetType() const -{ - return m_type; -} - -std::string -MacHeaderType::GetName() const -{ - return "MAC Header Type"; -} - -TypeId -MacHeaderType::GetTypeId() -{ - static TypeId tid = TypeId("ns3::MacHeaderType") - .SetParent
() - .SetGroupName("Wimax") - .AddConstructor(); - return tid; -} - -TypeId -MacHeaderType::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -MacHeaderType::Print(std::ostream& os) const -{ - os << " header type = " << (uint32_t)m_type; -} - -uint32_t -MacHeaderType::GetSerializedSize() const -{ - return 0; -} - -void -MacHeaderType::Serialize(Buffer::Iterator start) const -{ -} - -uint32_t -MacHeaderType::Deserialize(Buffer::Iterator start) -{ - return 0; -} - -// ---------------------------------------------------------------------------------------------------------- - -NS_OBJECT_ENSURE_REGISTERED(GenericMacHeader); - -GenericMacHeader::GenericMacHeader() - : m_ht(0), - m_ec(0), - m_type(0), - m_ci(0), - m_eks(0), - m_len(0), - m_cid(Cid()) -{ - m_esf = 0; - m_hcs = 0; - m_rsv1 = 0; - c_hcs = 0; -} - -GenericMacHeader::~GenericMacHeader() -{ -} - -void -GenericMacHeader::SetHt(uint8_t ht) -{ - m_ht = ht; -} - -void -GenericMacHeader::SetEc(uint8_t ec) -{ - m_ec = ec; -} - -void -GenericMacHeader::SetType(uint8_t type) -{ - m_type = type; -} - -void -GenericMacHeader::SetCi(uint8_t ci) -{ - m_ci = ci; -} - -void -GenericMacHeader::SetEks(uint8_t eks) -{ - m_eks = eks; -} - -void -GenericMacHeader::SetLen(uint16_t len) -{ - m_len = len; -} - -void -GenericMacHeader::SetCid(Cid cid) -{ - m_cid = cid; -} - -void -GenericMacHeader::SetHcs(uint8_t hcs) -{ - m_hcs = hcs; -} - -uint8_t -GenericMacHeader::GetHt() const -{ - return m_ht; -} - -uint8_t -GenericMacHeader::GetEc() const -{ - return m_ec; -} - -uint8_t -GenericMacHeader::GetType() const -{ - return m_type; -} - -uint8_t -GenericMacHeader::GetCi() const -{ - return m_ci; -} - -uint8_t -GenericMacHeader::GetEks() const -{ - return m_eks; -} - -uint16_t -GenericMacHeader::GetLen() const -{ - return m_len; -} - -Cid -GenericMacHeader::GetCid() const -{ - return m_cid; -} - -uint8_t -GenericMacHeader::GetHcs() const -{ - return m_hcs; -} - -std::string -GenericMacHeader::GetName() const -{ - return "Generic Mac Header"; -} - -TypeId -GenericMacHeader::GetTypeId() -{ - static TypeId tid = TypeId("ns3::GenericMacHeader") - .SetParent
() - .SetGroupName("Wimax") - .AddConstructor(); - return tid; -} - -TypeId -GenericMacHeader::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -GenericMacHeader::Print(std::ostream& os) const -{ - os << " ec (encryption control) = " << (uint32_t)m_ec << ", type = " << (uint32_t)m_type - << ", ci (crc indicator) = " << (uint32_t)m_ci - << ", eks (encryption key sequence) = " << (uint32_t)m_eks << ", len (length) = " << m_len - << ", cid = " << m_cid << ", hcs (header check sequence) = " << (uint32_t)m_hcs; -} - -uint32_t -GenericMacHeader::GetSerializedSize() const -{ - return 6; -} - -void -GenericMacHeader::Serialize(Buffer::Iterator start) const -{ - /* - * AI:Serialize function according to the - * IEEE 8002.16e. - * Please send bug and comments to - * amine.ismail@udcast.com - * amine.ismail@sophia.inria.fr - */ - - Buffer::Iterator i = start; - - uint8_t headerBuffer[6]; - memset(headerBuffer, 0, 6); - - headerBuffer[0] = ((m_ht << 7) & 0x80) | ((m_ec << 6) & 0x40) | (m_type & 0x3F); - headerBuffer[1] = ((m_esf << 7) & 0x80) | ((m_ci << 6) & 0x40) | ((m_eks << 4) & 0x30) | - ((m_rsv1 << 3) & 0x08) | (((uint8_t)(m_len >> 8)) & 0x07); - headerBuffer[2] = (uint8_t)(m_len); - headerBuffer[3] = (uint8_t)(m_cid.GetIdentifier() >> 8); - headerBuffer[4] = (uint8_t)(m_cid.GetIdentifier()); - uint8_t crc = CRC8Calculate(headerBuffer, 5); - headerBuffer[5] = crc; - for (int j = 0; j < 6; j++) - { - i.WriteU8(headerBuffer[j]); - } -} - -uint32_t -GenericMacHeader::Deserialize(Buffer::Iterator start) -{ - /* - * AI:Deserialize function according to the - * IEEE 8002.16e. - * Please send bug and comments to - * amine.ismail@udcast.com - * amine.ismail@sophia.inria.fr - */ - - Buffer::Iterator i = start; - - uint8_t headerBuffer[6]; - for (int j = 0; j < 6; j++) - { - headerBuffer[j] = i.ReadU8(); - } - m_ht = (headerBuffer[0] >> 7) & 0x01; - m_ec = (headerBuffer[0] >> 6) & 0x01; - m_type = (headerBuffer[0]) & 0x3F; - m_esf = (headerBuffer[1] >> 7) & 0x01; - m_ci = (headerBuffer[1] >> 6) & 0x01; - m_eks = (headerBuffer[1] >> 4) & 0x03; - m_rsv1 = (headerBuffer[1] >> 3) & 0x01; - uint16_t lenmsb = (headerBuffer[1] & 0x07); - uint16_t lenlsb = headerBuffer[2]; - m_len = ((lenmsb << 8) & 0x0700) | (lenlsb & 0x00FF); - uint16_t cidmsb = headerBuffer[3]; - uint16_t cidlsb = headerBuffer[4]; - uint16_t cid = ((cidmsb << 8) & 0xFF00) | (cidlsb & 0x00FF); - m_cid = Cid(cid); - m_hcs = headerBuffer[5]; - c_hcs = CRC8Calculate(headerBuffer, 5); - return i.GetDistanceFrom(start); -} - -bool -GenericMacHeader::check_hcs() const -{ - return m_hcs == c_hcs; -} - -// ---------------------------------------------------------------------------------------------------------- - -NS_OBJECT_ENSURE_REGISTERED(BandwidthRequestHeader); - -BandwidthRequestHeader::BandwidthRequestHeader() - : m_ht(1), - m_ec(0), - m_type(0), - m_br(0), - m_cid(Cid()), - m_hcs(0) -{ -} - -BandwidthRequestHeader::~BandwidthRequestHeader() -{ -} - -void -BandwidthRequestHeader::SetHt(uint8_t ht) -{ - m_ht = ht; -} - -void -BandwidthRequestHeader::SetEc(uint8_t ec) -{ - m_ec = ec; -} - -void -BandwidthRequestHeader::SetType(uint8_t type) -{ - m_type = type; -} - -void -BandwidthRequestHeader::SetBr(uint32_t br) -{ - m_br = br; -} - -void -BandwidthRequestHeader::SetCid(Cid cid) -{ - m_cid = cid; -} - -void -BandwidthRequestHeader::SetHcs(uint8_t hcs) -{ - m_hcs = hcs; -} - -uint8_t -BandwidthRequestHeader::GetHt() const -{ - return m_ht; -} - -uint8_t -BandwidthRequestHeader::GetEc() const -{ - return m_ec; -} - -uint8_t -BandwidthRequestHeader::GetType() const -{ - return m_type; -} - -uint32_t -BandwidthRequestHeader::GetBr() const -{ - return m_br; -} - -Cid -BandwidthRequestHeader::GetCid() const -{ - return m_cid; -} - -uint8_t -BandwidthRequestHeader::GetHcs() const -{ - return m_hcs; -} - -std::string -BandwidthRequestHeader::GetName() const -{ - return "Bandwidth Request Header"; -} - -TypeId -BandwidthRequestHeader::GetTypeId() -{ - static TypeId tid = TypeId("ns3::BandwidthRequestHeader") - .SetParent
() - .SetGroupName("Wimax") - .AddConstructor(); - return tid; -} - -TypeId -BandwidthRequestHeader::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -BandwidthRequestHeader::Print(std::ostream& os) const -{ - os << " ec (encryption control) = " << (uint32_t)m_ec << ", type = " << (uint32_t)m_type - << ", br (bandwidth request) = " << m_br << ", cid = "; - m_cid.GetIdentifier(); - os << ", hcs (header check sequence) = " << (uint32_t)m_hcs; -} - -uint32_t -BandwidthRequestHeader::GetSerializedSize() const -{ - /* - * The size of the BandwidthRequest mac header is always 6 bytes - */ - return 6; -} - -void -BandwidthRequestHeader::Serialize(Buffer::Iterator start) const -{ - /* - * AI:Serialize function according to the - * IEEE 8002.16e. - * please send bug and comments to - * amine.ismail@udcast.com - * amine.ismail@sophia.inria.fr - */ - - Buffer::Iterator i = start; - uint8_t headerBuffer[6]; - uint8_t br_msb1 = (((uint32_t)m_br) >> 16) & 0x00000007; - uint8_t br_msb2 = (((uint32_t)m_br) >> 8) & 0x000000FF; - uint8_t br_lsb = m_br & 0x000000FF; - headerBuffer[0] = - ((m_ht << 7) & 0x80) | ((m_ec << 6) & 0x40) | ((m_type << 3) & 0x38) | br_msb1; - headerBuffer[1] = br_msb2; - headerBuffer[2] = br_lsb; - headerBuffer[3] = (uint8_t)((m_cid.GetIdentifier() >> 8) & 0x00FF); - headerBuffer[4] = (uint8_t)(m_cid.GetIdentifier() & 0x00FF); - headerBuffer[5] = CRC8Calculate(headerBuffer, 5); - - for (int j = 0; j < 6; j++) - { - i.WriteU8(headerBuffer[j]); - } -} - -uint32_t -BandwidthRequestHeader::Deserialize(Buffer::Iterator start) -{ - /* - * AI:Deserialize function according to the - * IEEE 8002.16e. - * Please send bug and comments to - * amine.ismail@udcast.com - * amine.ismail@sophia.inria.fr - */ - - Buffer::Iterator i = start; - - uint8_t headerBuffer[6]; - for (int j = 0; j < 6; j++) - { - headerBuffer[j] = i.ReadU8(); - } - - m_ht = (headerBuffer[0] >> 7) & 0x01; - m_ec = (headerBuffer[0] >> 6) & 0x01; - m_type = (headerBuffer[0] >> 3) & 0x07; - uint32_t br_msb1 = headerBuffer[0] & 0x00000007; - uint32_t br_msb2 = headerBuffer[1] & 0x000000FF; - uint32_t br_lsb = headerBuffer[2] & 0x000000FF; - m_br = ((uint32_t)br_msb1 << 14) | ((uint32_t)br_msb2 << 8) | br_lsb; - uint16_t cidmsb = headerBuffer[3]; - uint16_t cidlsb = headerBuffer[4]; - uint16_t cid = ((cidmsb << 8) & 0xFF00) | (cidlsb & 0x00FF); - m_cid = Cid(cid); - m_hcs = headerBuffer[5]; - c_hcs = CRC8Calculate(headerBuffer, 5); - - return i.GetDistanceFrom(start); -} - -bool -BandwidthRequestHeader::check_hcs() const -{ - return m_hcs == c_hcs; -} - -// ---------------------------------------------------------------------------------------------------------- - -NS_OBJECT_ENSURE_REGISTERED(GrantManagementSubheader); - -GrantManagementSubheader::GrantManagementSubheader() - : m_si(0), - m_pm(0), - m_pbr(0) -{ -} - -GrantManagementSubheader::~GrantManagementSubheader() -{ -} - -void -GrantManagementSubheader::SetSi(uint8_t si) -{ - m_si = si; -} - -void -GrantManagementSubheader::SetPm(uint8_t pm) -{ - m_pm = pm; -} - -void -GrantManagementSubheader::SetPbr(uint16_t pbr) -{ - m_pbr = pbr; -} - -uint8_t -GrantManagementSubheader::GetSi() const -{ - return m_si; -} - -uint8_t -GrantManagementSubheader::GetPm() const -{ - return m_pm; -} - -uint16_t -GrantManagementSubheader::GetPbr() const -{ - return m_pbr; -} - -std::string -GrantManagementSubheader::GetName() const -{ - return "Grant Management Subheader"; -} - -TypeId -GrantManagementSubheader::GetTypeId() -{ - static TypeId tid = TypeId("ns3::GrantManagementSubheader") - .SetParent
() - .SetGroupName("Wimax") - .AddConstructor(); - return tid; -} - -TypeId -GrantManagementSubheader::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -GrantManagementSubheader::Print(std::ostream& os) const -{ - os << " si (slip indicator) = " << (uint32_t)m_si << ", pm (poll me) = " << (uint32_t)m_pm - << ", pbr (piggyback request) = " << m_pbr; -} - -uint32_t -GrantManagementSubheader::GetSerializedSize() const -{ - return 1 + 1 + 2; -} - -void -GrantManagementSubheader::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_si); - i.WriteU8(m_pm); - i.WriteU16(m_pbr); -} - -uint32_t -GrantManagementSubheader::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_si = i.ReadU8(); - m_pm = i.ReadU8(); - m_pbr = i.ReadU16(); - - return i.GetDistanceFrom(start); -} - -// ---------------------------------------------------------------------------------------------------------- - -NS_OBJECT_ENSURE_REGISTERED(FragmentationSubheader); - -FragmentationSubheader::FragmentationSubheader() - : m_fc(0), - m_fsn(0) -{ -} - -FragmentationSubheader::~FragmentationSubheader() -{ -} - -void -FragmentationSubheader::SetFc(uint8_t fc) -{ - m_fc = fc; -} - -void -FragmentationSubheader::SetFsn(uint8_t fsn) -{ - m_fsn = fsn; -} - -uint8_t -FragmentationSubheader::GetFc() const -{ - return m_fc; -} - -uint8_t -FragmentationSubheader::GetFsn() const -{ - return m_fsn; -} - -std::string -FragmentationSubheader::GetName() const -{ - return "Fragmentation Subheader"; -} - -TypeId -FragmentationSubheader::GetTypeId() -{ - static TypeId tid = TypeId("ns3::FragmentationSubheader") - .SetParent
() - .SetGroupName("Wimax") - .AddConstructor(); - return tid; -} - -TypeId -FragmentationSubheader::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -FragmentationSubheader::Print(std::ostream& os) const -{ - os << " fc (fragment control) = " << (uint32_t)m_fc - << ", fsn (fragmentation sequence number) = " << (uint32_t)m_fsn << "\n"; -} - -uint32_t -FragmentationSubheader::GetSerializedSize() const -{ - return 2; -} - -void -FragmentationSubheader::Serialize(Buffer::Iterator start) const -{ - Buffer::Iterator i = start; - i.WriteU8(m_fc); - i.WriteU8(m_fsn); -} - -uint32_t -FragmentationSubheader::Deserialize(Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_fc = i.ReadU8(); - m_fsn = i.ReadU8(); - - return i.GetDistanceFrom(start); -} - -} // namespace ns3 diff --git a/src/wimax/model/wimax-mac-header.h b/src/wimax/model/wimax-mac-header.h deleted file mode 100644 index a681350cc..000000000 --- a/src/wimax/model/wimax-mac-header.h +++ /dev/null @@ -1,510 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - * Mohamed Amine Ismail - */ - -#ifndef MAC_HEADER_TYPE_H -#define MAC_HEADER_TYPE_H - -#include "ns3/header.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * This class Represents the HT (Header Type) field of generic MAC and bandwidth request headers - * @see GenericMacHeader - * @see BandwidthRequestHeader - */ -class MacHeaderType : public Header -{ - public: - /// Header type enumeration - enum HeaderType - { - HEADER_TYPE_GENERIC, - HEADER_TYPE_BANDWIDTH - }; - - /** - * Constructor - */ - MacHeaderType(); - /** - * Constructor - * - * @param type MAC header type - */ - MacHeaderType(uint8_t type); - ~MacHeaderType() override; - /** - * Set type field - * @param type the type - */ - void SetType(uint8_t type); - /** - * Get type field - * @returns the type - */ - uint8_t GetType() const; - - /** - * Get name field - * @returns the name - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - uint8_t m_type; ///< MAC header type -}; - -} // namespace ns3 - -#endif /* MAC_HEADER_TYPE_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef GENERIC_MAC_HEADER_H -#define GENERIC_MAC_HEADER_H - -#include "cid.h" - -#include "ns3/header.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * This class implements the Generic mac Header as described by IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems 6.3.2.1.1 Generic MAC header, page 36 - */ -class GenericMacHeader : public Header -{ - public: - GenericMacHeader(); - ~GenericMacHeader() override; - - /** - * Set EC field - * @param ec the EC - */ - void SetEc(uint8_t ec); - /** - * Set type field - * @param type the type - */ - void SetType(uint8_t type); - /** - * Set CI field - * @param ci the CI - */ - void SetCi(uint8_t ci); - /** - * Set EKS field - * @param eks the EKS - */ - void SetEks(uint8_t eks); - /** - * Set length field - * @param len the length - */ - void SetLen(uint16_t len); - /** - * Set CID field - * @param cid the CID - */ - void SetCid(Cid cid); - /** - * Set HCS field - * @param hcs the HCS - */ - void SetHcs(uint8_t hcs); - /** - * Set HT field - * @param ht the HT - */ - void SetHt(uint8_t ht); - - /** - * Get EC field - * @returns the EC - */ - uint8_t GetEc() const; - /** - * Get type field - * @returns the type - */ - uint8_t GetType() const; - /** - * Get CI field - * @returns the CI - */ - uint8_t GetCi() const; - /** - * Get EKS field - * @returns the EKS - */ - uint8_t GetEks() const; - /** - * Get length field - * @returns the length - */ - uint16_t GetLen() const; - /** - * Get CID field - * @returns the CID - */ - Cid GetCid() const; - /** - * Get HCS field - * @returns the HCS - */ - uint8_t GetHcs() const; - /** - * Get HT field - * @returns the HT - */ - uint8_t GetHt() const; - /** - * Get name field - * @returns the name - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - /** - * Check HCS - * @returns true if HCS is validated - */ - bool check_hcs() const; - - private: - uint8_t m_ht; ///< Header type - uint8_t m_ec; ///< Encryption Control - uint8_t m_type; ///< type - uint8_t m_esf; ///< ESF - uint8_t m_ci; ///< CRC Indicator - uint8_t m_eks; ///< Encryption Key Sequence - uint8_t m_rsv1; ///< RSV - uint16_t m_len; ///< length - Cid m_cid; ///< CID - uint8_t m_hcs; ///< Header Check Sequence - uint8_t c_hcs; ///< calculated header check sequence; this is used to check if the received - ///< header is correct or not -}; - -} // namespace ns3 - -#endif /* GENERIC_MAC_HEADER */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef BANDWIDTH_REQUEST_HEADER_H -#define BANDWIDTH_REQUEST_HEADER_H - -#include "cid.h" - -#include "ns3/header.h" - -#include - -namespace ns3 -{ -/** - * @ingroup wimax - * This class implements the bandwidth-request mac Header as described by IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems 6.3.2.1.2 Bandwidth request header, page 38 - */ -class BandwidthRequestHeader : public Header -{ - public: - /// Header type enumeration - enum HeaderType - { - HEADER_TYPE_INCREMENTAL, - HEADER_TYPE_AGGREGATE - }; - - BandwidthRequestHeader(); - ~BandwidthRequestHeader() override; - - /** - * Set HT field - * @param ht the HT - */ - void SetHt(uint8_t ht); - /** - * Set EC field - * @param ec the EC - */ - void SetEc(uint8_t ec); - /** - * Set type field - * @param type the type - */ - void SetType(uint8_t type); - /** - * Set BR field - * @param br the BR - */ - void SetBr(uint32_t br); - /** - * Set CID field - * @param cid the CID - */ - void SetCid(Cid cid); - /** - * Set HCS field - * @param hcs the HCS - */ - void SetHcs(uint8_t hcs); - - /** - * Get HT field - * @returns the HT - */ - uint8_t GetHt() const; - /** - * Get EC field - * @returns the EC - */ - uint8_t GetEc() const; - /** - * Get type field - * @returns the type - */ - uint8_t GetType() const; - /** - * Get BR field - * @returns the BR - */ - uint32_t GetBr() const; - /** - * Get CID field - * @returns the CID - */ - Cid GetCid() const; - /** - * Get HCS field - * @returns the HCS - */ - uint8_t GetHcs() const; - - /** - * Get name field - * @returns the name - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - /** - * Check HCS - * @returns true if HCS is validated - */ - bool check_hcs() const; - - private: - uint8_t m_ht; ///< Header type - uint8_t m_ec; ///< Encryption Control - uint8_t m_type; ///< type - uint32_t m_br; ///< Bandwidth Request - Cid m_cid; ///< Connection identifier - uint8_t m_hcs; ///< Header Check Sequence - uint8_t c_hcs; ///< calculated header check sequence; this is used to check if the received - ///< header is correct or not -}; - -} // namespace ns3 - -#endif /* BANDWIDTH_REQUEST_HEADER_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef GRANT_MANAGEMENT_SUBHEADER_H -#define GRANT_MANAGEMENT_SUBHEADER_H - -#include "ns3/header.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * This class implements the grant management sub-header as described by IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems 6.3.2.2.2 Grant Management subheader, page 40 - */ -class GrantManagementSubheader : public Header -{ - public: - GrantManagementSubheader(); - ~GrantManagementSubheader() override; - - /** - * Set SI field - * @param si the SI - */ - void SetSi(uint8_t si); - /** - * Set PM field - * @param pm the PM - */ - void SetPm(uint8_t pm); - /** - * Set PRR field - * @param pbr the PBR - */ - void SetPbr(uint16_t pbr); - - /** - * Get SI field - * @returns the SI - */ - uint8_t GetSi() const; - /** - * Get PM field - * @returns the PM - */ - uint8_t GetPm() const; - /** - * Get PBR field - * @returns the PBR - */ - uint16_t GetPbr() const; - - /** - * Get name field - * @returns the name - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - // size of the Grant Management Subheader shall actually be 2 bytes - - uint8_t m_si; ///< Slip Indicator - uint8_t m_pm; ///< Poll-Me bit (byte in this case) - uint16_t m_pbr; ///< PiggyBack Request -}; - -} // namespace ns3 - -#endif /* GRANT_MANAGEMENT_SUBHEADER_H */ - -// ---------------------------------------------------------------------------------------------------------- - -#ifndef FRAGMENTATION_SUBHEADER_H -#define FRAGMENTATION_SUBHEADER_H - -#include "ns3/header.h" - -#include - -namespace ns3 -{ -/** - * @ingroup wimax - * This class implements the fragmentation sub-header as described by IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access - * Systems 6.3.2.2.1 Fragmentation subheader, page 39 - */ -class FragmentationSubheader : public Header -{ - public: - FragmentationSubheader(); - ~FragmentationSubheader() override; - - /** - * Set FC field - * @param fc the FC - */ - void SetFc(uint8_t fc); - /** - * Set FSN field - * @param fsn the FSN - */ - void SetFsn(uint8_t fsn); - - /** - * Get FC field - * @returns the FC - */ - uint8_t GetFc() const; - /** - * Get FSN field - * @returns the FSN - */ - uint8_t GetFsn() const; - - /** - * Get name field - * @returns the name - */ - std::string GetName() const; - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - - private: - uint8_t m_fc; ///< Fragment Control - uint8_t m_fsn; ///< Fragment Sequence Number -}; -} // namespace ns3 - -#endif /* FRAGMENTATION_SUBHEADER_H */ diff --git a/src/wimax/model/wimax-mac-queue.cc b/src/wimax/model/wimax-mac-queue.cc deleted file mode 100644 index 9a16595d1..000000000 --- a/src/wimax/model/wimax-mac-queue.cc +++ /dev/null @@ -1,642 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "wimax-mac-queue.h" - -#include "ns3/log.h" -#include "ns3/packet.h" -#include "ns3/simulator.h" -#include "ns3/trace-source-accessor.h" -#include "ns3/uinteger.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("WimaxMacQueue"); - -NS_OBJECT_ENSURE_REGISTERED(WimaxMacQueue); - -WimaxMacQueue::QueueElement::QueueElement() - : m_packet(Create()), - m_hdrType(MacHeaderType()), - m_hdr(GenericMacHeader()), - m_timeStamp(), - m_fragmentation(false), - m_fragmentNumber(0), - m_fragmentOffset(0) -{ -} - -WimaxMacQueue::QueueElement::QueueElement(Ptr packet, - const MacHeaderType& hdrType, - const GenericMacHeader& hdr, - Time timeStamp) - : m_packet(packet), - m_hdrType(hdrType), - m_hdr(hdr), - m_timeStamp(timeStamp), - m_fragmentation(false), - m_fragmentNumber(0), - m_fragmentOffset(0) -{ -} - -uint32_t -WimaxMacQueue::QueueElement::GetSize() const -{ - uint32_t size = m_packet->GetSize() + m_hdrType.GetSerializedSize(); - - /*check because may be it is a bandwidth request packet (in which case a Bandwidth Request - Header has already been added to the packet) in which case Generic MAC Header will not be added - to it. this will only happen in the case of SS as only SS sends the bandwidth request packet. - */ - if (m_hdrType.GetType() == MacHeaderType::HEADER_TYPE_GENERIC) - { - size += m_hdr.GetSerializedSize(); - } - - return size; -} - -TypeId -WimaxMacQueue::GetTypeId() -{ - static TypeId tid = TypeId("ns3::WimaxMacQueue") - .SetParent() - .SetGroupName("Wimax") - .AddAttribute("MaxSize", - "Maximum size", - UintegerValue(1024), - MakeUintegerAccessor(&WimaxMacQueue::GetMaxSize, - &WimaxMacQueue::SetMaxSize), - MakeUintegerChecker()) - .AddTraceSource("Enqueue", - "Enqueue trace", - MakeTraceSourceAccessor(&WimaxMacQueue::m_traceEnqueue), - "ns3::Packet::TracedCallback") - .AddTraceSource("Dequeue", - "Dequeue trace", - MakeTraceSourceAccessor(&WimaxMacQueue::m_traceDequeue), - "ns3::Packet::TracedCallback") - .AddTraceSource("Drop", - "Drop trace", - MakeTraceSourceAccessor(&WimaxMacQueue::m_traceDrop), - "ns3::Packet::TracedCallback"); - return tid; -} - -WimaxMacQueue::WimaxMacQueue() - : m_maxSize(0), - m_bytes(0), - m_nrDataPackets(0), - m_nrRequestPackets(0) -{ -} - -WimaxMacQueue::WimaxMacQueue(uint32_t maxSize) - : m_maxSize(maxSize), - m_bytes(0), - m_nrDataPackets(0), - m_nrRequestPackets(0) -{ -} - -WimaxMacQueue::~WimaxMacQueue() -{ -} - -void -WimaxMacQueue::SetMaxSize(uint32_t maxSize) -{ - m_maxSize = maxSize; -} - -uint32_t -WimaxMacQueue::GetMaxSize() const -{ - return m_maxSize; -} - -bool -WimaxMacQueue::Enqueue(Ptr packet, - const MacHeaderType& hdrType, - const GenericMacHeader& hdr) -{ - if (m_queue.size() == m_maxSize) - { - m_traceDrop(packet); - return false; - } - - m_traceEnqueue(packet); - QueueElement element(packet, hdrType, hdr, Simulator::Now()); - m_queue.push_back(element); - - if (hdrType.GetType() == MacHeaderType::HEADER_TYPE_GENERIC) - { - m_nrDataPackets++; - } - else - { - m_nrRequestPackets++; - } - - m_bytes += element.GetSize(); - return true; -} - -Ptr -WimaxMacQueue::Dequeue(MacHeaderType::HeaderType packetType) -{ - if (!IsEmpty()) - { - QueueElement element = Front(packetType); - Pop(packetType); - - if (element.m_hdrType.GetType() == MacHeaderType::HEADER_TYPE_GENERIC) - { - NS_LOG_INFO("Enqueued Packet IS A data packet"); - NS_ASSERT_MSG(m_nrDataPackets >= 1, - "Can not enqueue more packets: no space left in the queue"); - m_nrDataPackets--; - } - else - { - NS_LOG_INFO("Enqueued Packet IS A Request BW packet"); - NS_ASSERT_MSG(m_nrRequestPackets >= 1, - "Can not enqueue more packets: no space left in the queue"); - m_nrRequestPackets--; - } - - Ptr packet = element.m_packet; - - if (!element.m_fragmentation) - { - NS_LOG_INFO("FRAG_DEBUG: Enqueued Packet IS NOT a fragment" << std::endl); - /*check because may be it is a bandwidth request packet (in which case a Bandwidth - Request Header has already been added to the packet) in which case Generic MAC Header - will not be added to it. this will only happen in the case of SS as only SS sends the - bandwidth request packet. */ - m_bytes -= element.GetSize(); - if (element.m_hdrType.GetType() == MacHeaderType::HEADER_TYPE_GENERIC) - { - packet->AddHeader(element.m_hdr); - } - packet->AddHeader(element.m_hdrType); - - m_traceDequeue(packet); - return packet; - } - else - { - /* - The enqueued packet is a fragment (the latest fragment) - We must modify type field of the m_hdr and add a fragmentation Subhdr - */ - NS_LOG_INFO("\t Enqueued Packet IS a fragment, add subhdr" << std::endl); - - // Create a fragment - uint32_t fragmentOffset = element.m_fragmentOffset; - uint32_t fragmentSize = element.m_packet->GetSize() - fragmentOffset; - - NS_LOG_INFO("\t Create a fragment" - "\n\t\t fragmentOffset=" - << fragmentOffset << "\n\t\t packetSize=" << element.m_packet->GetSize() - << "\n\t\t fragmentSize=" << fragmentSize << std::endl); - - Ptr fragment = packet->CreateFragment(fragmentOffset, fragmentSize); - - FragmentationSubheader fragmentSubhdr; - NS_LOG_INFO("\t Latest Fragment" << std::endl); - fragmentSubhdr.SetFc(2); // This is the latest fragment - fragmentSubhdr.SetFsn(element.m_fragmentNumber); - - NS_LOG_INFO("\t FragmentSize=" << fragment->GetSize() << std::endl); - fragment->AddHeader(fragmentSubhdr); - - /*check because may be it is a bandwidth request packet (in which case a Bandwidth - Request Header has already been added to the packet) in which case Generic MAC Header - will not be added to it. this will only happen in the case of SS as only SS sends the - bandwidth request packet. */ - if (element.m_hdrType.GetType() == MacHeaderType::HEADER_TYPE_GENERIC) - { - uint8_t tmpType = element.m_hdr.GetType(); - tmpType |= 4; - element.m_hdr.SetType(tmpType); - - uint32_t length = fragmentSize + element.m_hdr.GetSerializedSize() + - fragmentSubhdr.GetSerializedSize(); - element.m_hdr.SetLen((uint16_t)length); - - fragment->AddHeader(element.m_hdr); - } - fragment->AddHeader(element.m_hdrType); - m_bytes -= fragmentSize; - - m_traceDequeue(fragment); - return fragment; - } - } - return nullptr; -} - -Ptr -WimaxMacQueue::Dequeue(MacHeaderType::HeaderType packetType, uint32_t availableByte) -{ - if (!IsEmpty()) - { - NS_LOG_INFO("FRAG_DEBUG: Dequeue function" << std::endl); - QueueElement element = Front(packetType); - - uint32_t headerSize = - 2 + element.m_hdr.GetSerializedSize() + element.m_hdrType.GetSerializedSize(); - - // Create a fragment - uint32_t maxFragmentSize = availableByte - headerSize; - uint32_t fragmentOffset = element.m_fragmentOffset; // It is the latest byte sent. - - Ptr packet = element.m_packet->Copy(); - NS_LOG_INFO("\t Create a fragment" - "\n\t\t availableByte=" - << availableByte << "\n\t\t headerSize=" << headerSize - << "\n\t\t maxFragmentSize=" << maxFragmentSize - << "" - "\n\t\t fragmentOffset=" - << fragmentOffset << "\n\t\t payloadSize=" << packet->GetSize() << std::endl); - Ptr fragment = packet->CreateFragment(fragmentOffset, maxFragmentSize); - m_bytes -= maxFragmentSize; - - FragmentationSubheader fragmentSubhdr; - if (!element.m_fragmentation) - { - NS_LOG_INFO("\t First Fragment" << std::endl); - SetFragmentation(packetType); - fragmentSubhdr.SetFc(1); - } - else - { - NS_LOG_INFO("\t Middle Fragment" << std::endl); - fragmentSubhdr.SetFc(3); - } - fragmentSubhdr.SetFsn(element.m_fragmentNumber); - NS_LOG_INFO("\t FragmentSize=" << fragment->GetSize() << std::endl); - fragment->AddHeader(fragmentSubhdr); - - SetFragmentNumber(packetType); - SetFragmentOffset(packetType, maxFragmentSize); - - /*check because may be it is a bandwidth request packet (in which case a Bandwidth Request - Header has already been added to the packet) in which case Generic MAC Header will not be - added to it. this will only happen in the case of SS as only SS sends the bandwidth - request packet. */ - if (element.m_hdrType.GetType() == MacHeaderType::HEADER_TYPE_GENERIC) - { - uint8_t tmpType = element.m_hdr.GetType(); - tmpType |= 4; - element.m_hdr.SetType(tmpType); - - uint32_t length = maxFragmentSize + element.m_hdr.GetSerializedSize() + - fragmentSubhdr.GetSerializedSize(); - element.m_hdr.SetLen((uint16_t)length); - - fragment->AddHeader(element.m_hdr); - } - fragment->AddHeader(element.m_hdrType); - - m_traceDequeue(fragment); - return fragment; - } - return nullptr; -} - -Ptr -WimaxMacQueue::Peek(GenericMacHeader& hdr) const -{ - if (!IsEmpty()) - { - QueueElement element = m_queue.front(); - hdr = element.m_hdr; - Ptr packet = element.m_packet->Copy(); - - // this function must not be used by SS as it may be then a bandwidth request header - packet->AddHeader(element.m_hdr); - return packet; - } - - return nullptr; -} - -Ptr -WimaxMacQueue::Peek(GenericMacHeader& hdr, Time& timeStamp) const -{ - if (!IsEmpty()) - { - QueueElement element = m_queue.front(); - hdr = element.m_hdr; - timeStamp = element.m_timeStamp; - Ptr packet = element.m_packet->Copy(); - - // this function must not be used for by SS as it may be then a bandwidth request header - packet->AddHeader(element.m_hdr); - return packet; - } - - return nullptr; -} - -Ptr -WimaxMacQueue::Peek(MacHeaderType::HeaderType packetType) const -{ - if (!IsEmpty()) - { - QueueElement element = Front(packetType); - Ptr packet = element.m_packet->Copy(); - - /*check because may be it is a bandwidth request packet (in which case a Bandwidth Request - Header has already been added to the packet) in which case Generic MAC Header will not be - added to it. this will only happen in the case of SS as only SS sends the bandwidth request - packet. */ - if (element.m_hdrType.GetType() == MacHeaderType::HEADER_TYPE_GENERIC) - { - packet->AddHeader(element.m_hdr); - } - return packet; - } - - return nullptr; -} - -Ptr -WimaxMacQueue::Peek(MacHeaderType::HeaderType packetType, Time& timeStamp) const -{ - if (!IsEmpty()) - { - QueueElement element = Front(packetType); - timeStamp = element.m_timeStamp; - Ptr packet = element.m_packet->Copy(); - - /*check because may be it is a bandwidth request packet (in which case a Bandwidth Request - Header has already been added to the packet) in which case Generic MAC Header will not be - added to it. this will only happen in the case of SS as only SS sends the bandwidth request - packet. */ - if (element.m_hdrType.GetType() == MacHeaderType::HEADER_TYPE_GENERIC) - { - packet->AddHeader(element.m_hdr); - } - return packet; - } - - return nullptr; -} - -uint32_t -WimaxMacQueue::GetSize() const -{ - return m_queue.size(); -} - -uint32_t -WimaxMacQueue::GetNBytes() const -{ - return m_bytes; -} - -uint32_t -WimaxMacQueue::GetQueueLengthWithMACOverhead() -{ - uint32_t queueSize = GetNBytes(); - // Add MAC Overhead - queueSize += GetSize() * 6; - MacHeaderType::HeaderType packetType = MacHeaderType::HEADER_TYPE_GENERIC; - if (CheckForFragmentation(packetType)) - { - queueSize += 2; - } - return queueSize; -} - -WimaxMacQueue::QueueElement -WimaxMacQueue::Front(MacHeaderType::HeaderType packetType) const -{ - QueueElement element; - - for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) - { - element = *iter; - if (element.m_hdrType.GetType() == packetType) - { - break; - } - } - - return element; -} - -void -WimaxMacQueue::Pop(MacHeaderType::HeaderType packetType) -{ - QueueElement element; - - for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) - { - element = *iter; - if (element.m_hdrType.GetType() == packetType) - { - m_queue.erase(iter); - break; - } - } -} - -bool -WimaxMacQueue::IsEmpty() const -{ - return m_queue.empty(); -} - -bool -WimaxMacQueue::IsEmpty(MacHeaderType::HeaderType packetType) const -{ - if (packetType == MacHeaderType::HEADER_TYPE_GENERIC) - { - return m_nrDataPackets == 0; - } - else - { - return m_nrRequestPackets == 0; - } - - return true; -} - -const WimaxMacQueue::PacketQueue& -WimaxMacQueue::GetPacketQueue() const -{ - return m_queue; -} - -bool -WimaxMacQueue::CheckForFragmentation(MacHeaderType::HeaderType packetType) -{ - QueueElement element; - for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) - { - element = *iter; - if (element.m_hdrType.GetType() == packetType) - { - break; - } - } - - if (element.m_fragmentation) - { - NS_LOG_INFO("FRAG_DEBUG: CheckForFragmentation" - "\n\t\t m_fragmentation is true " - << std::endl); - } - - return element.m_fragmentation; -} - -uint32_t -WimaxMacQueue::GetFirstPacketHdrSize(MacHeaderType::HeaderType packetType) -{ - QueueElement element; - for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) - { - element = *iter; - if (element.m_hdrType.GetType() == packetType) - { - break; - } - } - - NS_LOG_INFO("\t\t GetFirstPacketHdrSize ()"); - - uint32_t hdrSize = 0; - if (element.m_hdrType.GetType() == MacHeaderType::HEADER_TYPE_GENERIC) - { - hdrSize += element.m_hdr.GetSerializedSize(); - NS_LOG_INFO("\t\t\t m_hdr.GetSerializedSize=" << element.m_hdr.GetSerializedSize()); - } - - hdrSize += element.m_hdrType.GetSerializedSize(); - NS_LOG_INFO("\t\t\t m_hdrType.GetSerializedSize=" << element.m_hdrType.GetSerializedSize()); - - if (CheckForFragmentation(packetType)) - { - NS_LOG_INFO("\t\t\t fragSubhdrSize=2"); - hdrSize += 2; - } - - NS_LOG_INFO("\t\t hdrSize=" << hdrSize); - - return hdrSize; -} - -uint32_t -WimaxMacQueue::GetFirstPacketPayloadSize(MacHeaderType::HeaderType packetType) -{ - QueueElement element; - for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) - { - element = *iter; - if (element.m_hdrType.GetType() == packetType) - { - break; - } - } - - NS_LOG_INFO("\t\t GetFirstPacketPayloadSize ()"); - - if (CheckForFragmentation(packetType)) - { - NS_LOG_INFO("\t\t\t fullPayloadSize=" - << element.m_packet->GetSize() << "\n\t\t\t fragmentOffset=" - << element.m_fragmentOffset << "\n\t\t\t (fragment)payloadSize=" - << element.m_packet->GetSize() - element.m_fragmentOffset); - - return element.m_packet->GetSize() - element.m_fragmentOffset; - } - NS_LOG_INFO("\t\t payloadSize=" << element.m_packet->GetSize()); - - return element.m_packet->GetSize(); -} - -uint32_t -WimaxMacQueue::GetFirstPacketRequiredByte(MacHeaderType::HeaderType packetType) -{ - NS_LOG_INFO("\t GetFirstPacketRequiredByte ()"); - - uint32_t requiredByte = - GetFirstPacketPayloadSize(packetType) + GetFirstPacketHdrSize(packetType); - - NS_LOG_INFO("\t Required Bytes = " << requiredByte << std::endl); - - return requiredByte; -} - -void -WimaxMacQueue::SetFragmentation(MacHeaderType::HeaderType packetType) -{ - for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) - { - if (iter->m_hdrType.GetType() == packetType) - { - iter->SetFragmentation(); - break; - } - } -} - -void -WimaxMacQueue::SetFragmentNumber(MacHeaderType::HeaderType packetType) -{ - for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) - { - if (iter->m_hdrType.GetType() == packetType) - { - iter->SetFragmentNumber(); - break; - } - } -} - -void -WimaxMacQueue::SetFragmentOffset(MacHeaderType::HeaderType packetType, uint32_t offset) -{ - for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) - { - if (iter->m_hdrType.GetType() == packetType) - { - iter->SetFragmentOffset(offset); - break; - } - } -} - -void -WimaxMacQueue::QueueElement::SetFragmentation() -{ - m_fragmentation = true; -} - -void -WimaxMacQueue::QueueElement::SetFragmentNumber() -{ - m_fragmentNumber++; -} - -void -WimaxMacQueue::QueueElement::SetFragmentOffset(uint32_t offset) -{ - m_fragmentOffset += offset; -} -} // namespace ns3 diff --git a/src/wimax/model/wimax-mac-queue.h b/src/wimax/model/wimax-mac-queue.h deleted file mode 100644 index 125b50785..000000000 --- a/src/wimax/model/wimax-mac-queue.h +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#ifndef WIMAX_MAC_QUEUE_H -#define WIMAX_MAC_QUEUE_H - -#include "wimax-mac-header.h" - -#include "ns3/nstime.h" -#include "ns3/object.h" -#include "ns3/packet.h" -#include "ns3/traced-callback.h" - -#include -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * Class implementing the device packet queue - */ -class WimaxMacQueue : public Object -{ - public: - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - WimaxMacQueue(); - /** - * Constructor - * - * @param maxSize maximum size of queue - */ - WimaxMacQueue(uint32_t maxSize); - ~WimaxMacQueue() override; - /** - * @brief set the maximum queue size - * @param maxSize the max queue size - */ - void SetMaxSize(uint32_t maxSize); - /** - * @return the maximum queue size - */ - uint32_t GetMaxSize() const; - /** - * @brief Enqueue a packet - * @param packet the packet to enqueue - * @param hdrType the mac header type of the packet - * @param hdr the header of the packet - * @return true if successful - */ - bool Enqueue(Ptr packet, const MacHeaderType& hdrType, const GenericMacHeader& hdr); - /** - * @brief Dequeue a packet of type packetType from the queue - * @param packetType the type of the packet - * @return the first packet in the queue - */ - Ptr Dequeue(MacHeaderType::HeaderType packetType); - /** - * @brief Dequeue a fragment of size availableByte from the queue - * @param packetType the type of the packet - * @param availableByte the size of the fragment - * @return the first packet in the queue if its size is lower than availableByte, the first - * availableByte of the first packet otherwise - */ - Ptr Dequeue(MacHeaderType::HeaderType packetType, uint32_t availableByte); - - /** - * @brief Exclusively for BS. - * Two versions of Peek function (with Generic MAC Header as parameter) only - * for BS, as BS's scheduler needs to know the CID in Generic MAC Header. - * @param hdr the header of the packet - * @return the first packet in the queue - */ - Ptr Peek(GenericMacHeader& hdr) const; - /** - * @brief Exclusively for BS. - * Two versions of Peek function (with Generic MAC Header as parameter) only - * for BS, as BS's scheduler needs to know the CID in Generic MAC Header. - * @param hdr the header of the packet - * @param timeStamp the timestamp of the packet - * @return the first packet in the queue - */ - Ptr Peek(GenericMacHeader& hdr, Time& timeStamp) const; - - /** - * @brief Two versions for SS without Generic MAC Header parameter, as SS's - * scheduler does not require to know the CID in Generic MAC Header. - * @param packetType the type of the packet - * @return the first packet in the queue - */ - Ptr Peek(MacHeaderType::HeaderType packetType) const; - /** - * @brief Two versions for SS without Generic MAC Header parameter, as SS's - * scheduler does not require to know the CID in Generic MAC Header. - * @param packetType the type of the packet - * @param timeStamp the timestamp of the packet - * @return the first packet in the queue - */ - Ptr Peek(MacHeaderType::HeaderType packetType, Time& timeStamp) const; - - /** - * Check if queue is empty - * @returns true if empty - */ - bool IsEmpty() const; - - /** - * Exclusively for SS. - * @return true if queue is empty of type packetType - * @param packetType packet type to check - */ - bool IsEmpty(MacHeaderType::HeaderType packetType) const; - - /** - * Get size of queue - * @returns the size - */ - uint32_t GetSize() const; - /** - * Get number of bytes in queue - * @returns the number of bytes - */ - uint32_t GetNBytes() const; - - /** - * Check for fragmentation of the first packet of the specified type - * @param packetType the packet type - * @returns true if fragmented - */ - bool CheckForFragmentation(MacHeaderType::HeaderType packetType); - /** - * Get first packet header size of the specified type - * @param packetType the packet type - * @returns the first packet header size - */ - uint32_t GetFirstPacketHdrSize(MacHeaderType::HeaderType packetType); - /** - * Get first packet payload size of the specified type - * @param packetType the packet type - * @returns the first packet payload size - */ - uint32_t GetFirstPacketPayloadSize(MacHeaderType::HeaderType packetType); - /** - * Get required number of bytes to hold first packet of packetType - * @param packetType the packet type - * @returns the sum of the first packet header and payload (of specified type) - */ - uint32_t GetFirstPacketRequiredByte(MacHeaderType::HeaderType packetType); - /** - * Get queue length considering also the MAC overhead - * @return queue length - */ - uint32_t GetQueueLengthWithMACOverhead(); - /// Set fragmentation function - /** - * Set fragmentation state for first packet of type packetType - * @param packetType packetType to check - */ - void SetFragmentation(MacHeaderType::HeaderType packetType); - /** - * Set fragment number for first packet of type packetType - * @param packetType packetType to check - */ - void SetFragmentNumber(MacHeaderType::HeaderType packetType); - /** - * Set fragment offset for first packet of type packetType - * @param packetType packetType to check - * @param offset offset value to set - */ - void SetFragmentOffset(MacHeaderType::HeaderType packetType, uint32_t offset); - - /// QueueElement structure - struct QueueElement - { - QueueElement(); - /** - * Constructor - * - * @param packet the packet - * @param hdrType MAC header type - * @param hdr MAC header - * @param timeStamp time stamp - */ - QueueElement(Ptr packet, - const MacHeaderType& hdrType, - const GenericMacHeader& hdr, - Time timeStamp); - /** - * Get size function - * @returns the size - */ - uint32_t GetSize() const; - Ptr m_packet; ///< packet - MacHeaderType m_hdrType; ///< header type - GenericMacHeader m_hdr; ///< header - Time m_timeStamp; ///< timestamp - - /** - To manage fragmentation feature, each QueueElement have 3 new fields: - m_fragmentation that becomes true when the fragmentation starts; - m_fragmentNumber that is incremented when a new fragment is sent - m_fragmentOffset that tracks the start of the next fragment into the packet - */ - bool m_fragmentation; ///< becomes true when the fragmentation starts - uint32_t m_fragmentNumber; ///< incremented when a new fragment is sent - uint32_t m_fragmentOffset; ///< tracks the start of the next fragment into the packet - - /// Set fragmentation - void SetFragmentation(); - /// Set fragment number - void SetFragmentNumber(); - /** - * Set fragment offset - * @param offset the offset - */ - void SetFragmentOffset(uint32_t offset); - }; - - private: - /** - In the case of non-UGS service flows at the SS side the queue will store both data packets - and bandwidth request packets. The two are distinguished by their headers. The below two - functions are for this purpose exclusively. The Front function returns the first packet of a - specific packet type from the queue (which may not necessarily be at the front of the queue), - and the Pop function pops that elements. - * @param packetType the type of the packet - * @returns the first packet in the queue of the specified type - */ - WimaxMacQueue::QueueElement Front(MacHeaderType::HeaderType packetType) const; - /** - * Pop function - * @param packetType the packet type - */ - void Pop(MacHeaderType::HeaderType packetType); - - /// PacketQueue typedef - typedef std::deque PacketQueue; - PacketQueue m_queue; ///< the queue - uint32_t m_maxSize; ///< maximum size - uint32_t m_bytes; ///< bytes - uint32_t m_nrDataPackets; ///< number data packets - uint32_t m_nrRequestPackets; ///< number request packets - - TracedCallback> m_traceEnqueue; ///< enqueue trace callback - TracedCallback> m_traceDequeue; ///< dequeue trace callback - TracedCallback> m_traceDrop; ///< drop trace callback - public: - /** - * Get packet queue function - * @returns the packet queue - */ - const WimaxMacQueue::PacketQueue& GetPacketQueue() const; -}; - -} // namespace ns3 - -#endif /* WIMAX_MAC_QUEUE_H */ diff --git a/src/wimax/model/wimax-mac-to-mac-header.cc b/src/wimax/model/wimax-mac-to-mac-header.cc deleted file mode 100644 index 59edb4b7c..000000000 --- a/src/wimax/model/wimax-mac-to-mac-header.cc +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2010 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - * - */ -#include "wimax-mac-to-mac-header.h" - -#include "ns3/address-utils.h" -#include "ns3/log.h" -#include "ns3/uinteger.h" - -namespace ns3 -{ - -NS_OBJECT_ENSURE_REGISTERED(WimaxMacToMacHeader); - -WimaxMacToMacHeader::WimaxMacToMacHeader() - : m_len(0) -{ -} - -WimaxMacToMacHeader::WimaxMacToMacHeader(uint32_t len) - : m_len(len) -{ -} - -WimaxMacToMacHeader::~WimaxMacToMacHeader() -{ -} - -TypeId -WimaxMacToMacHeader::GetTypeId() -{ - static TypeId tid = TypeId("ns3::WimaxMacToMacHeader") - .SetParent
() - .SetGroupName("Wimax") - .AddConstructor(); - return tid; -} - -TypeId -WimaxMacToMacHeader::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -uint8_t -WimaxMacToMacHeader::GetSizeOfLen() const -{ - uint8_t sizeOfLen = 1; - - if (m_len > 127) - { - sizeOfLen = 2; - uint64_t testValue = 0xFF; - while (m_len > testValue) - { - sizeOfLen++; - testValue *= 0xFF; - } - } - return sizeOfLen; -} - -uint32_t -WimaxMacToMacHeader::GetSerializedSize() const -{ - uint8_t sizeOfLen = GetSizeOfLen(); - if (sizeOfLen == 1) - { - return 20; - } - else - { - return 20 + sizeOfLen - 1; - } - // return 19+sizeOfLen; -} - -void -WimaxMacToMacHeader::Serialize(Buffer::Iterator i) const -{ - // The following header encoding was reverse-engineered by looking - // at existing live pcap traces which could be opened with wireshark - // i.e., we have no idea where this is coming from. - // - // 6 zeros for mac destination - // 6 zeros for mac source - // 2 bytes for length/type: 0x08f0 - // 2 bytes for sequence number: 0x0001 - // 2 bytes for number of tlvs: 0x0001 - // 1 byte for type of first tlv: 0x09 - // 1 byte to indicate the length of the length field of the tlv : 0x80 | 0x04 - // n bytes to indicate the size of the packet (network order) - // n bytes for the packet data - - uint8_t zero = 0; - - for (int j = 0; j < 12; j++) - { - i.WriteU8(zero); - } - i.WriteU16(0xf008); // eth length/type - i.WriteU16(0x0100); // sequence number - i.WriteU16(0x0100); // number of tlvs - i.WriteU8(0x09); // type of first tlv - uint8_t lenSize = GetSizeOfLen(); - if (lenSize == 1) - { - i.WriteU8(m_len); - } - else - { - i.WriteU8((lenSize - 1) | 0x80); - for (int j = 0; j < lenSize - 1; j++) - { - i.WriteU8((uint8_t)(m_len >> ((lenSize - 1 - 1 - j) * 8))); - } - } -} - -uint32_t -WimaxMacToMacHeader::Deserialize(Buffer::Iterator start) -{ - // not needed here - return 20; -} - -void -WimaxMacToMacHeader::Print(std::ostream& os) const -{ -} -}; // namespace ns3 diff --git a/src/wimax/model/wimax-mac-to-mac-header.h b/src/wimax/model/wimax-mac-to-mac-header.h deleted file mode 100644 index 562713362..000000000 --- a/src/wimax/model/wimax-mac-to-mac-header.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2010 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - * - */ -#ifndef WIMAX_MAC_TO_MAC_HEADER_H -#define WIMAX_MAC_TO_MAC_HEADER_H - -#include "ns3/header.h" - -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * @brief this class implements the mac to mac header needed to dump a wimax pcap file - * The header format was reverse-engineered by looking at existing live pcap traces which - * could be opened with wireshark i.e., we have no idea where this is coming from. - */ -class WimaxMacToMacHeader : public Header -{ - public: - WimaxMacToMacHeader(); - ~WimaxMacToMacHeader() override; - /** - * Constructor - * - * @param len length - */ - WimaxMacToMacHeader(uint32_t len); - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - /** - * Get size of length field - * @returns the size of length field - */ - uint8_t GetSizeOfLen() const; - void Print(std::ostream& os) const override; - - private: - uint32_t m_len; ///< length -}; -}; // namespace ns3 -#endif diff --git a/src/wimax/model/wimax-net-device.cc b/src/wimax/model/wimax-net-device.cc deleted file mode 100644 index 925f11335..000000000 --- a/src/wimax/model/wimax-net-device.cc +++ /dev/null @@ -1,638 +0,0 @@ -/* - * Copyright (c) 2007,2008,2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - * - */ - -#include "wimax-net-device.h" - -#include "bandwidth-manager.h" -#include "burst-profile-manager.h" -#include "connection-manager.h" -#include "send-params.h" -#include "service-flow-manager.h" -#include "wimax-channel.h" - -#include "ns3/callback.h" -#include "ns3/enum.h" -#include "ns3/llc-snap-header.h" -#include "ns3/node.h" -#include "ns3/packet-burst.h" -#include "ns3/packet.h" -#include "ns3/pointer.h" -#include "ns3/simulator.h" -#include "ns3/trace-source-accessor.h" -#include "ns3/uinteger.h" - -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("WimaxNetDevice"); - -NS_OBJECT_ENSURE_REGISTERED(WimaxNetDevice); - -uint32_t WimaxNetDevice::m_nrFrames = 0; -uint8_t WimaxNetDevice::m_direction = ~0; -Time WimaxNetDevice::m_frameStartTime = Seconds(0); - -TypeId -WimaxNetDevice::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::WimaxNetDevice") - - .SetParent() - .SetGroupName("Wimax") - - // No AddConstructor because this is an abstract class. - - .AddAttribute("Mtu", - "The MAC-level Maximum Transmission Unit", - UintegerValue(DEFAULT_MSDU_SIZE), - MakeUintegerAccessor(&WimaxNetDevice::SetMtu, &WimaxNetDevice::GetMtu), - MakeUintegerChecker(0, MAX_MSDU_SIZE)) - - .AddAttribute("Phy", - "The PHY layer attached to this device.", - PointerValue(), - MakePointerAccessor(&WimaxNetDevice::GetPhy, &WimaxNetDevice::SetPhy), - MakePointerChecker()) - - .AddAttribute( - "Channel", - "The channel attached to this device.", - PointerValue(), - MakePointerAccessor(&WimaxNetDevice::GetPhyChannel, &WimaxNetDevice::SetChannel), - MakePointerChecker()) - - .AddAttribute("RTG", - "receive/transmit transition gap.", - UintegerValue(0), - MakeUintegerAccessor(&WimaxNetDevice::GetRtg, &WimaxNetDevice::SetRtg), - MakeUintegerChecker(0, 120)) - - .AddAttribute("TTG", - "transmit/receive transition gap.", - UintegerValue(0), - MakeUintegerAccessor(&WimaxNetDevice::GetTtg, &WimaxNetDevice::SetTtg), - MakeUintegerChecker(0, 120)) - - .AddAttribute("ConnectionManager", - "The connection manager attached to this device.", - PointerValue(), - MakePointerAccessor(&WimaxNetDevice::GetConnectionManager, - &WimaxNetDevice::SetConnectionManager), - MakePointerChecker()) - - .AddAttribute("BurstProfileManager", - "The burst profile manager attached to this device.", - PointerValue(), - MakePointerAccessor(&WimaxNetDevice::GetBurstProfileManager, - &WimaxNetDevice::SetBurstProfileManager), - MakePointerChecker()) - - .AddAttribute("BandwidthManager", - "The bandwidth manager attached to this device.", - PointerValue(), - MakePointerAccessor(&WimaxNetDevice::GetBandwidthManager, - &WimaxNetDevice::SetBandwidthManager), - MakePointerChecker()) - - .AddAttribute("InitialRangingConnection", - "Initial ranging connection", - PointerValue(), - MakePointerAccessor(&WimaxNetDevice::m_initialRangingConnection), - MakePointerChecker()) - - .AddAttribute("BroadcastConnection", - "Broadcast connection", - PointerValue(), - MakePointerAccessor(&WimaxNetDevice::m_broadcastConnection), - MakePointerChecker()) - - .AddTraceSource("Rx", - "Receive trace", - MakeTraceSourceAccessor(&WimaxNetDevice::m_traceRx), - "ns3::WimaxNetDevice::TxRxTracedCallback") - - .AddTraceSource("Tx", - "Transmit trace", - MakeTraceSourceAccessor(&WimaxNetDevice::m_traceTx), - "ns3::WimaxNetDevice::TxRxTracedCallback"); - return tid; -} - -WimaxNetDevice::WimaxNetDevice() - : m_state(0), - m_symbolIndex(0), - m_ttg(0), - m_rtg(0) -{ - InitializeChannels(); - m_connectionManager = CreateObject(); - m_burstProfileManager = CreateObject(this); - m_bandwidthManager = CreateObject(this); - m_nrFrames = 0; - m_direction = ~0; - m_frameStartTime = Seconds(0); -} - -WimaxNetDevice::~WimaxNetDevice() -{ -} - -void -WimaxNetDevice::DoDispose() -{ - m_phy->Dispose(); - m_phy = nullptr; - m_node = nullptr; - m_initialRangingConnection = nullptr; - m_broadcastConnection = nullptr; - m_connectionManager = nullptr; - m_burstProfileManager = nullptr; - m_bandwidthManager = nullptr; - - NetDevice::DoDispose(); -} - -void -WimaxNetDevice::SetTtg(uint16_t ttg) -{ - m_ttg = ttg; -} - -uint16_t -WimaxNetDevice::GetTtg() const -{ - return m_ttg; -} - -void -WimaxNetDevice::SetRtg(uint16_t rtg) -{ - m_rtg = rtg; -} - -uint16_t -WimaxNetDevice::GetRtg() const -{ - return m_rtg; -} - -void -WimaxNetDevice::SetName(const std::string name) -{ - m_name = name; -} - -std::string -WimaxNetDevice::GetName() const -{ - return m_name; -} - -void -WimaxNetDevice::SetIfIndex(const uint32_t index) -{ - m_ifIndex = index; -} - -uint32_t -WimaxNetDevice::GetIfIndex() const -{ - return m_ifIndex; -} - -Ptr -WimaxNetDevice::GetChannel() const -{ - return DoGetChannel(); -} - -Ptr -WimaxNetDevice::GetPhyChannel() const -{ - return DoGetChannel(); -} - -bool -WimaxNetDevice::SetMtu(const uint16_t mtu) -{ - if (mtu > MAX_MSDU_SIZE) - { - return false; - } - m_mtu = mtu; - return true; -} - -uint16_t -WimaxNetDevice::GetMtu() const -{ - return m_mtu; -} - -bool -WimaxNetDevice::IsLinkUp() const -{ - return m_phy && m_linkUp; -} - -void -WimaxNetDevice::SetLinkChangeCallback(Callback callback) -{ - m_linkChange = callback; -} - -bool -WimaxNetDevice::IsBroadcast() const -{ - return true; -} - -Address -WimaxNetDevice::GetBroadcast() const -{ - return Mac48Address::GetBroadcast(); -} - -bool -WimaxNetDevice::IsMulticast() const -{ - return false; -} - -Address -WimaxNetDevice::GetMulticast() const -{ - return Mac48Address("01:00:5e:00:00:00"); -} - -Address -WimaxNetDevice::MakeMulticastAddress(Ipv4Address multicastGroup) const -{ - return GetMulticast(); -} - -bool -WimaxNetDevice::IsPointToPoint() const -{ - return false; -} - -bool -WimaxNetDevice::Send(Ptr packet, const Address& dest, uint16_t protocolNumber) -{ - Mac48Address to = Mac48Address::ConvertFrom(dest); - LlcSnapHeader llcHdr; - llcHdr.SetType(protocolNumber); - packet->AddHeader(llcHdr); - - m_traceTx(packet, to); - - return DoSend(packet, Mac48Address::ConvertFrom(GetAddress()), to, protocolNumber); -} - -void -WimaxNetDevice::SetNode(Ptr node) -{ - m_node = node; -} - -Ptr -WimaxNetDevice::GetNode() const -{ - return m_node; -} - -bool -WimaxNetDevice::NeedsArp() const -{ - return false; - /* - * Modified by Mohamed Amine ISMAIL. - * see "Transmission of IPv4 packets over IEEE 802.16's IP Convergence - * Sublayer draft-ietf-16ng-ipv4-over-802-dot-16-ipcs-04.txt" section - * 5.2 - */ -} - -void -WimaxNetDevice::SetReceiveCallback(ReceiveCallback cb) -{ - m_forwardUp = cb; -} - -void -WimaxNetDevice::ForwardUp(Ptr packet, const Mac48Address& source, const Mac48Address& dest) -{ - m_traceRx(packet, source); - LlcSnapHeader llc; - packet->RemoveHeader(llc); - m_forwardUp(this, packet, llc.GetType(), source); -} - -void -WimaxNetDevice::Attach(Ptr channel) -{ - m_phy->Attach(channel); -} - -void -WimaxNetDevice::SetPhy(Ptr phy) -{ - m_phy = phy; -} - -Ptr -WimaxNetDevice::GetPhy() const -{ - return m_phy; -} - -void -WimaxNetDevice::SetChannel(Ptr channel) -{ - if (m_phy) - { - m_phy->Attach(channel); - } -} - -uint64_t -WimaxNetDevice::GetChannel(uint8_t index) const -{ - return m_dlChannels.at(index); -} - -void -WimaxNetDevice::SetNrFrames(uint32_t nrFrames) -{ - m_nrFrames = nrFrames; -} - -uint32_t -WimaxNetDevice::GetNrFrames() const -{ - return m_nrFrames; -} - -void -WimaxNetDevice::SetAddress(Address address) -{ - m_address = Mac48Address::ConvertFrom(address); -} - -void -WimaxNetDevice::SetMacAddress(Mac48Address address) -{ - m_address = address; -} - -Address -WimaxNetDevice::GetAddress() const -{ - return m_address; -} - -Mac48Address -WimaxNetDevice::GetMacAddress() const -{ - return m_address; -} - -void -WimaxNetDevice::SetState(uint8_t state) -{ - m_state = state; -} - -uint8_t -WimaxNetDevice::GetState() const -{ - return m_state; -} - -Ptr -WimaxNetDevice::GetInitialRangingConnection() const -{ - return m_initialRangingConnection; -} - -Ptr -WimaxNetDevice::GetBroadcastConnection() const -{ - return m_broadcastConnection; -} - -void -WimaxNetDevice::SetCurrentDcd(Dcd dcd) -{ - m_currentDcd = dcd; -} - -Dcd -WimaxNetDevice::GetCurrentDcd() const -{ - return m_currentDcd; -} - -void -WimaxNetDevice::SetCurrentUcd(Ucd ucd) -{ - m_currentUcd = ucd; -} - -Ucd -WimaxNetDevice::GetCurrentUcd() const -{ - return m_currentUcd; -} - -Ptr -WimaxNetDevice::GetConnectionManager() const -{ - return m_connectionManager; -} - -void -WimaxNetDevice::SetConnectionManager(Ptr cm) -{ - m_connectionManager = cm; -} - -Ptr -WimaxNetDevice::GetBurstProfileManager() const -{ - return m_burstProfileManager; -} - -void -WimaxNetDevice::SetBurstProfileManager(Ptr bpm) -{ - m_burstProfileManager = bpm; -} - -Ptr -WimaxNetDevice::GetBandwidthManager() const -{ - return m_bandwidthManager; -} - -void -WimaxNetDevice::SetBandwidthManager(Ptr bwm) -{ - m_bandwidthManager = bwm; -} - -void -WimaxNetDevice::CreateDefaultConnections() -{ - m_initialRangingConnection = - CreateObject(Cid::InitialRanging(), Cid::INITIAL_RANGING); - m_broadcastConnection = CreateObject(Cid::Broadcast(), Cid::BROADCAST); -} - -void -WimaxNetDevice::Receive(Ptr burst) -{ - NS_LOG_DEBUG("WimaxNetDevice::Receive, station = " << GetMacAddress()); - - Ptr b = burst->Copy(); - for (auto iter = b->Begin(); iter != b->End(); ++iter) - { - Ptr packet = *iter; - DoReceive(packet); - } -} - -Ptr -WimaxNetDevice::DoGetChannel() const -{ - return m_phy->GetChannel(); -} - -void -WimaxNetDevice::SetReceiveCallback() -{ - m_phy->SetReceiveCallback(MakeCallback(&WimaxNetDevice::Receive, this)); -} - -bool -WimaxNetDevice::SendFrom(Ptr packet, - const Address& source, - const Address& dest, - uint16_t protocolNumber) -{ - Mac48Address from = Mac48Address::ConvertFrom(source); - Mac48Address to = Mac48Address::ConvertFrom(dest); - - LlcSnapHeader llcHdr; - llcHdr.SetType(protocolNumber); - packet->AddHeader(llcHdr); - - m_traceTx(packet, to); - return DoSend(packet, from, to, protocolNumber); -} - -void -WimaxNetDevice::SetPromiscReceiveCallback(PromiscReceiveCallback cb) -{ - m_promiscRx = cb; -} - -bool -WimaxNetDevice::IsPromisc() -{ - return !(m_promiscRx.IsNull()); -} - -void -WimaxNetDevice::NotifyPromiscTrace(Ptr p) -{ - // m_promiscRx(p); -} - -bool -WimaxNetDevice::SupportsSendFrom() const -{ - return false; -} - -void -WimaxNetDevice::ForwardDown(Ptr burst, WimaxPhy::ModulationType modulationType) -{ - SendParams* params = new OfdmSendParams(burst, modulationType, m_direction); - m_phy->Send(params); - delete params; -} - -void -WimaxNetDevice::InitializeChannels() -{ - // initializing vector of channels (or frequencies) - // Values according to WirelessMAN-OFDM RF profile for 10 MHz channelization - // Section 12.3.3.1 from IEEE 802.16-2004 standard - // profR10_3 : - // channels: 5000 + n ⋅ 5 MHz, ∀n ∈ { 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167 } - // from a range 5GHz to 6GHz, according to Section 8.5.1. - uint64_t frequency = 5000; - - for (uint8_t i = 0; i < 200; i++) - { - m_dlChannels.push_back(frequency); - frequency += 5; - } -} - -bool -WimaxNetDevice::IsBridge() const -{ - NS_LOG_FUNCTION_NOARGS(); - return false; -} - -Address -WimaxNetDevice::GetMulticast(Ipv4Address multicastGroup) const -{ - NS_LOG_FUNCTION(multicastGroup); - - Mac48Address ad = Mac48Address::GetMulticast(multicastGroup); - - // - // Implicit conversion (operator Address ()) is defined for Mac48Address, so - // use it by just returning the EUI-48 address which is automagically converted - // to an Address. - // - NS_LOG_LOGIC("multicast address is " << ad); - - return ad; -} - -Address -WimaxNetDevice::GetMulticast(Ipv6Address addr) const -{ - Mac48Address ad = Mac48Address::GetMulticast(addr); - - NS_LOG_LOGIC("MAC IPv6 multicast address is " << ad); - return ad; -} - -void -WimaxNetDevice::AddLinkChangeCallback(Callback callback) -{ - /* \todo Add a callback invoked whenever the link - * status changes to UP. This callback is typically used - * by the IP/ARP layer to flush the ARP cache and by IPv6 stack - * to flush NDISC cache whenever the link goes up. - */ - NS_FATAL_ERROR("Not implemented-- please implement and contribute a patch"); -} -} // namespace ns3 diff --git a/src/wimax/model/wimax-net-device.h b/src/wimax/model/wimax-net-device.h deleted file mode 100644 index efd959d97..000000000 --- a/src/wimax/model/wimax-net-device.h +++ /dev/null @@ -1,559 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Authors: Jahanzeb Farooq - * Mohamed Amine Ismail - */ - -#ifndef WIMAX_NET_DEVICE_H -#define WIMAX_NET_DEVICE_H - -#include "cid-factory.h" -#include "cid.h" -#include "dl-mac-messages.h" -#include "mac-messages.h" -#include "ul-mac-messages.h" -#include "wimax-connection.h" -#include "wimax-mac-header.h" -#include "wimax-phy.h" - -#include "ns3/event-id.h" -#include "ns3/log.h" -#include "ns3/mac48-address.h" -#include "ns3/net-device.h" -#include "ns3/nstime.h" -#include "ns3/traced-callback.h" - -namespace ns3 -{ - -class Node; -class Packet; -class TraceContext; -class TraceResolver; -class Channel; -class WimaxChannel; -class PacketBurst; -class BurstProfileManager; -class ConnectionManager; -class ServiceFlowManager; -class BandwidthManager; -class UplinkScheduler; - -/** - * @defgroup wimax WiMAX Models - * This section documents the API of the ns-3 wimax module. For a generic functional description, - * please refer to the ns-3 manual. - */ - -/** - * @brief Hold together all WiMAX-related objects in a NetDevice. - * @ingroup wimax - * - * This class holds together ns3::WimaxPhy, ns3::WimaxConnection, - * ns3::ConnectionManager, ns3::BurstProfileManager, and - * ns3::BandwidthManager. - */ -class WimaxNetDevice : public NetDevice -{ - public: - /// Direction enumeration - enum Direction - { - DIRECTION_DOWNLINK, - DIRECTION_UPLINK - }; - - /// RangingStatus enumeration - enum RangingStatus - { - RANGING_STATUS_EXPIRED, - RANGING_STATUS_CONTINUE, - RANGING_STATUS_ABORT, - RANGING_STATUS_SUCCESS - }; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - WimaxNetDevice(); - ~WimaxNetDevice() override; - /** - * Set transmission/receive transition gap - * @param ttg transmit/receive transition gap - */ - void SetTtg(uint16_t ttg); - /** - * Get transmission/receive transition gap - * @returns transmit/receive transition gap - */ - uint16_t GetTtg() const; - /** - * Set receive/transmit transition gap - * @param rtg receive/transmit transition gap - */ - void SetRtg(uint16_t rtg); - /** - * Get receive/transmit transition gap - * @returns receive/transmit transition gap - */ - uint16_t GetRtg() const; - /** - * Attach device to channel - * @param channel channel to attach - */ - void Attach(Ptr channel); - /** - * Set the physical layer object - * @param phy the phy layer object to use - */ - void SetPhy(Ptr phy); - /** - * Get the physical layer object - * @returns a pointer to the physical layer object - */ - Ptr GetPhy() const; - - /** - * Set the channel object - * @param wimaxChannel the channel to be used - */ - void SetChannel(Ptr wimaxChannel); - - /** - * Get the channel object by index - * @param index the channel index - * @returns the channel being used. - */ - uint64_t GetChannel(uint8_t index) const; - - /** - * Set the number of frames - * @param nrFrames the number of frames - */ - void SetNrFrames(uint32_t nrFrames); - /** - * Get the number of frames - * @returns the number of frames. - */ - uint32_t GetNrFrames() const; - /** - * Set the MAC address - * @param address the mac address of the net device - */ - void SetMacAddress(Mac48Address address); - /** - * Get the MAC address - * @returns the mac address of the net device - */ - Mac48Address GetMacAddress() const; - /** - * Set the device state - * @param state the state - */ - void SetState(uint8_t state); - /** - * Get the device state - * @returns the state - */ - uint8_t GetState() const; - /** - * Get the initial ranging connection - * @returns the initial ranging connection - */ - Ptr GetInitialRangingConnection() const; - /** - * Get the broadcast connection - * @returns the broadcast connection - */ - Ptr GetBroadcastConnection() const; - - /** - * Set the current DCD - * @param dcd the DCD - */ - void SetCurrentDcd(Dcd dcd); - /** - * Get the current DCD - * @returns the DCD - */ - Dcd GetCurrentDcd() const; - /** - * Set the current UCD - * @param ucd the UCD - */ - void SetCurrentUcd(Ucd ucd); - /** - * Get the current UCD - * @returns the UCD - */ - Ucd GetCurrentUcd() const; - /** - * Get the connection manager of the device - * @returns the connection manager of the device - */ - Ptr GetConnectionManager() const; - - /** - * Set the connection manager of the device - * @param connectionManager the connection manager to be installed in the device - */ - virtual void SetConnectionManager(Ptr connectionManager); - - /** - * Get the burst profile manager - * @returns the burst profile manager currently installed in the device - */ - Ptr GetBurstProfileManager() const; - - /** - * Set the burst profile manager - * @param burstProfileManager the burst profile manager to be installed on the device - */ - void SetBurstProfileManager(Ptr burstProfileManager); - - /** - * Get the bandwidth manager on the device - * @returns the bandwidth manager installed on the device - */ - Ptr GetBandwidthManager() const; - - /** - * Set the bandwidth manager on the device - * @param bandwidthManager the bandwidth manager to be installed on the device - */ - void SetBandwidthManager(Ptr bandwidthManager); - - /** - * @brief Creates the initial ranging and broadcast connections - */ - void CreateDefaultConnections(); - - /// Start function - virtual void Start() = 0; - /// Stop function - virtual void Stop() = 0; - - /// Set receive callback function - void SetReceiveCallback(); - - /** - * Forward a packet to the next layer above the device - * @param packet the packet - * @param source the source MAC address - * @param dest the destination MAC address - */ - void ForwardUp(Ptr packet, const Mac48Address& source, const Mac48Address& dest); - - /** - * Enqueue a packet - * @param packet the packet - * @param hdrType the header type - * @param connection the wimax connection - * @returns true if successful - */ - virtual bool Enqueue(Ptr packet, - const MacHeaderType& hdrType, - Ptr connection) = 0; - /** - * Forward a packet down the stack - * @param burst the packet burst - * @param modulationType the modulation type - */ - void ForwardDown(Ptr burst, WimaxPhy::ModulationType modulationType); - - // temp, shall be private - static uint8_t m_direction; ///< downlink or uplink - - static Time m_frameStartTime; ///< temp, to determine the frame start time at SS side, shall - ///< actually be determined by frame start preamble - - /** - * Set device name - * @param name the device name - */ - virtual void SetName(const std::string name); - /** - * Get device name - * @returns the device name - */ - virtual std::string GetName() const; - /** - * Set interface index - * @param index the index - */ - void SetIfIndex(const uint32_t index) override; - /** - * Get interface index - * @returns the interface index - */ - uint32_t GetIfIndex() const override; - /** - * Get the channel (this method is redundant with GetChannel()) - * @returns the channel used by the phy layer - */ - virtual Ptr GetPhyChannel() const; - /** - * Get the channel - * @returns the channel - */ - Ptr GetChannel() const override; - /** - * Set address of the device - * @param address the address - */ - void SetAddress(Address address) override; - /** - * Get address of the device - * @returns the address - */ - Address GetAddress() const override; - /** - * Set MTU value for the device - * @param mtu the MTU - * @returns true if successful - */ - bool SetMtu(const uint16_t mtu) override; - /** - * Get MTU of the device - * @returns the MTU - */ - uint16_t GetMtu() const override; - /** - * Check if link is up - * @return true if the link is up - */ - bool IsLinkUp() const override; - /** - * Set link change callback function - * @param callback the callback function - */ - virtual void SetLinkChangeCallback(Callback callback); - /** - * Check if broadcast enabled - * @returns true if broadcast - */ - bool IsBroadcast() const override; - /** - * Get broadcast address - * @returns the address - */ - Address GetBroadcast() const override; - /** - * Check if multicast enabled - * @returns true if multicast - */ - bool IsMulticast() const override; - /** - * Get multicast address - * @returns the multicast address - */ - virtual Address GetMulticast() const; - /** - * Make multicast address - * @param multicastGroup the IPv4 address - * @returns the multicast address - */ - virtual Address MakeMulticastAddress(Ipv4Address multicastGroup) const; - /** - * Check if device is a point-to-point device - * @returns true if point to point - */ - bool IsPointToPoint() const override; - /** - * Send function - * @param packet the packet - * @param dest the destination address - * @param protocolNumber the protocol number - * @returns true if successful - */ - bool Send(Ptr packet, const Address& dest, uint16_t protocolNumber) override; - /** - * Set node pointer - * @param node the node pointer - */ - void SetNode(Ptr node) override; - /** - * Get node pointer - * @returns the node pointer - */ - Ptr GetNode() const override; - /** - * Check if device needs ARP - * @returns true if ARP required - */ - bool NeedsArp() const override; - /** - * Set receive callback function - * @param cb the receive callback function - */ - void SetReceiveCallback(NetDevice::ReceiveCallback cb) override; - /** - * Add link change callback function - * @param callback the link change callback function - */ - void AddLinkChangeCallback(Callback callback) override; - /** - * Send a packet - * @param packet the packet - * @param source the source address - * @param dest the destination address - * @param protocolNumber the protocol number - * @returns true if successful - */ - bool SendFrom(Ptr packet, - const Address& source, - const Address& dest, - uint16_t protocolNumber) override; - /** - * Set promiscuous receive callback function - * @param cb the promiscuous mode callback - */ - void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override; - /** - * Get promiscuous receive callback function - * @returns the promiscuous mode callback - */ - NetDevice::PromiscReceiveCallback GetPromiscReceiveCallback(); - /** - * Check if device supports the SendFrom method - * @returns true if SendFrom is supported - */ - bool SupportsSendFrom() const override; - - /** - * TracedCallback signature for packet and Mac48Address. - * - * @param [in] packet The packet. - * @param [in] mac The Mac48Address. - * @deprecated The `const Mac48Address &` argument is deprecated - * and will be changed to \c Mac48Address in a future release. - * The TracedCallback signature will then match \c Packet::Mac48Address - * and this typedef can be removed. - */ - // NS_DEPRECATED() - tag for future removal - typedef void (*TxRxTracedCallback)(Ptr packet, const Mac48Address& mac); - /** - * @deprecated The `const Mac48Address &` argument is deprecated - * and will be changed to \c Mac48Address in a future release. - * The TracedCallback signature will then match \c Packet::Mac48Address - * and this typedef can be removed. - * @todo This member variable should be private. - */ - // NS_DEPRECATED() - tag for future removal - TracedCallback, const Mac48Address&> m_traceRx; - /** - * @deprecated The `const Mac48Address &` argument is deprecated - * and will be changed to \c Mac48Address in a future release. - * The TracedCallback signature will then match \c Packet::Mac48Address - * and this typedef can be removed. - * @todo This member variable should be private. - */ - // NS_DEPRECATED() - tag for future removal - TracedCallback, const Mac48Address&> m_traceTx; - - void DoDispose() override; - Address GetMulticast(Ipv6Address addr) const override; - Address GetMulticast(Ipv4Address multicastGroup) const override; - bool IsBridge() const override; - - /** - * Check if device is promiscuous - * @returns true if promiscuous - */ - bool IsPromisc(); - /** - * Notify promiscuous trace of a packet arrival - * @param p the packet - */ - void NotifyPromiscTrace(Ptr p); - - private: - /// copy constructor (disabled) - WimaxNetDevice(const WimaxNetDevice&); - /** - * assignment operator (disabled) - * @returns the wimax net device - */ - WimaxNetDevice& operator=(const WimaxNetDevice&); - - /// Maximum MSDU size - static const uint16_t MAX_MSDU_SIZE = 1500; - /// recommended by wimax forum. - static const uint16_t DEFAULT_MSDU_SIZE = 1400; - - /** - * Send a packet - * @param packet the packet - * @param source the source MAC address - * @param dest the destination MAC address - * @param protocolNumber the protocol number - * @returns true if successful - */ - virtual bool DoSend(Ptr packet, - const Mac48Address& source, - const Mac48Address& dest, - uint16_t protocolNumber) = 0; - /** - * Receive a packet - * @param packet the packet received - */ - virtual void DoReceive(Ptr packet) = 0; - /** - * Get the channel - * @returns the wimax channel - */ - virtual Ptr DoGetChannel() const; - /** - * Receive a packet burst - * @param burst the packet burst - */ - void Receive(Ptr burst); - /// Initialize channels function - void InitializeChannels(); - - Ptr m_node; ///< the node - Ptr m_phy; ///< the phy - NetDevice::ReceiveCallback m_forwardUp; ///< forward up callback function - NetDevice::PromiscReceiveCallback m_promiscRx; ///< promiscuous receive callback function - - uint32_t m_ifIndex; ///< IF index - std::string m_name; ///< service name - bool m_linkUp; ///< link up? - Callback m_linkChange; ///< link change callback - mutable uint16_t m_mtu; ///< MTU - - /// temp, shall be in BS. defined here to allow SS to access. SS shall actually determine it - /// from DLFP, shall be moved to BS after DLFP is implemented - static uint32_t m_nrFrames; - - /// not sure if it shall be included here - std::vector m_dlChannels; - - Mac48Address m_address; ///< MAC address - uint8_t m_state; ///< state - uint32_t m_symbolIndex; ///< symbol index - - /// length of TTG in units of PSs - uint16_t m_ttg; - /// length of RTG in units of PSs - uint16_t m_rtg; - - Dcd m_currentDcd; ///< DCD - Ucd m_currentUcd; ///< UCD - - Ptr m_initialRangingConnection; ///< initial rnaging connection - Ptr m_broadcastConnection; ///< broadcast connection - - Ptr m_connectionManager; ///< connection manager - Ptr m_burstProfileManager; ///< burst profile manager - Ptr m_bandwidthManager; ///< badnwidth manager -}; - -} // namespace ns3 - -#endif /* WIMAX_NET_DEVICE_H */ diff --git a/src/wimax/model/wimax-phy.cc b/src/wimax/model/wimax-phy.cc deleted file mode 100644 index 057a718a2..000000000 --- a/src/wimax/model/wimax-phy.cc +++ /dev/null @@ -1,416 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#include "wimax-phy.h" - -#include "wimax-channel.h" -#include "wimax-net-device.h" - -#include "ns3/double.h" -#include "ns3/node.h" -#include "ns3/packet-burst.h" -#include "ns3/packet.h" -#include "ns3/pointer.h" -#include "ns3/simulator.h" -#include "ns3/trace-source-accessor.h" -#include "ns3/uinteger.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("WimaxPhy"); - -NS_OBJECT_ENSURE_REGISTERED(WimaxPhy); - -TypeId -WimaxPhy::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::WimaxPhy") - .SetParent() - .SetGroupName("Wimax") - - // No AddConstructor because this is an abstract class. - - .AddAttribute("Channel", - "Wimax channel", - PointerValue(), - MakePointerAccessor(&WimaxPhy::GetChannel, &WimaxPhy::Attach), - MakePointerChecker()) - - .AddAttribute( - "FrameDuration", - "The frame duration in seconds.", - TimeValue(Seconds(0.01)), - MakeTimeAccessor(&WimaxPhy::SetFrameDuration, &WimaxPhy::GetFrameDurationSec), - MakeTimeChecker()) - - .AddAttribute("Frequency", - "The central frequency in KHz.", - UintegerValue(5000000), - MakeUintegerAccessor(&WimaxPhy::SetFrequency, &WimaxPhy::GetFrequency), - MakeUintegerChecker(1000000, 11000000)) - - .AddAttribute("Bandwidth", - "The channel bandwidth in Hz.", - UintegerValue(10000000), - MakeUintegerAccessor(&WimaxPhy::SetChannelBandwidth, - &WimaxPhy::GetChannelBandwidth), - MakeUintegerChecker(5000000, 30000000)) - - ; - return tid; -} - -WimaxPhy::WimaxPhy() - : m_state(PHY_STATE_IDLE), - m_nrCarriers(0), - m_frameDuration(Seconds(0.01)), - m_frequency(5000000), - m_channelBandwidth(10000000), - m_psDuration(), - m_symbolDuration(), - m_psPerSymbol(0), - m_psPerFrame(0), - m_symbolsPerFrame(0) -{ - m_duplex = false; - m_txFrequency = 0; - m_rxFrequency = 0; -} - -WimaxPhy::~WimaxPhy() -{ -} - -void -WimaxPhy::DoDispose() -{ - m_device = nullptr; - m_channel = nullptr; -} - -void -WimaxPhy::Attach(Ptr channel) -{ - m_channel = channel; - DoAttach(channel); -} - -Ptr -WimaxPhy::GetChannel() const -{ - return m_channel; -} - -void -WimaxPhy::SetDevice(Ptr device) -{ - m_device = device; -} - -Ptr -WimaxPhy::GetDevice() const -{ - return m_device; -} - -void -WimaxPhy::StartScanning(uint64_t frequency, Time timeout, Callback callback) -{ - NS_ASSERT_MSG( - m_state == PHY_STATE_IDLE || m_state == PHY_STATE_SCANNING, - "Error while scanning: The PHY state should be PHY_STATE_SCANNING or PHY_STATE_IDLE"); - - m_state = PHY_STATE_SCANNING; - m_scanningFrequency = frequency; - m_dlChnlSrchTimeoutEvent = Simulator::Schedule(timeout, &WimaxPhy::EndScanning, this); - m_scanningCallback = callback; -} - -void -WimaxPhy::EndScanning() -{ - m_scanningCallback(false, m_scanningFrequency); -} - -void -WimaxPhy::SetReceiveCallback(Callback> callback) -{ - m_rxCallback = callback; -} - -Callback> -WimaxPhy::GetReceiveCallback() const -{ - return m_rxCallback; -} - -void -WimaxPhy::SetDuplex(uint64_t rxFrequency, uint64_t txFrequency) -{ - m_txFrequency = txFrequency; - m_rxFrequency = rxFrequency; -} - -void -WimaxPhy::SetSimplex(uint64_t frequency) -{ - m_txFrequency = frequency; - m_rxFrequency = frequency; -} - -uint64_t -WimaxPhy::GetRxFrequency() const -{ - return m_rxFrequency; -} - -uint64_t -WimaxPhy::GetTxFrequency() const -{ - return m_txFrequency; -} - -uint64_t -WimaxPhy::GetScanningFrequency() const -{ - return m_scanningFrequency; -} - -void -WimaxPhy::SetState(PhyState state) -{ - m_state = state; -} - -WimaxPhy::PhyState -WimaxPhy::GetState() const -{ - return m_state; -} - -bool -WimaxPhy::IsDuplex() const -{ - return m_duplex; -} - -EventId -WimaxPhy::GetChnlSrchTimeoutEvent() const -{ - return m_dlChnlSrchTimeoutEvent; -} - -void -WimaxPhy::SetScanningCallback() const -{ - m_scanningCallback(true, GetScanningFrequency()); -} - -void -WimaxPhy::SetDataRates() -{ - DoSetDataRates(); -} - -uint32_t -WimaxPhy::GetDataRate(WimaxPhy::ModulationType modulationType) const -{ - return DoGetDataRate(modulationType); -} - -Time -WimaxPhy::GetTransmissionTime(uint32_t size, WimaxPhy::ModulationType modulationType) const -{ - return DoGetTransmissionTime(size, modulationType); -} - -uint64_t -WimaxPhy::GetNrSymbols(uint32_t size, WimaxPhy::ModulationType modulationType) const -{ - return DoGetNrSymbols(size, modulationType); -} - -uint64_t -WimaxPhy::GetNrBytes(uint32_t symbols, WimaxPhy::ModulationType modulationType) const -{ - return DoGetNrBytes(symbols, modulationType); -} - -uint16_t -WimaxPhy::GetTtg() const -{ - return DoGetTtg(); -} - -uint16_t -WimaxPhy::GetRtg() const -{ - return DoGetRtg(); -} - -uint8_t -WimaxPhy::GetFrameDurationCode() const -{ - return DoGetFrameDurationCode(); -} - -Time -WimaxPhy::GetFrameDuration(uint8_t frameDurationCode) const -{ - return DoGetFrameDuration(frameDurationCode); -} - -/*---------------------PHY parameters functions-----------------------*/ - -void -WimaxPhy::SetPhyParameters() -{ - DoSetPhyParameters(); -} - -void -WimaxPhy::SetNrCarriers(uint8_t nrCarriers) -{ - m_nrCarriers = nrCarriers; -} - -uint8_t -WimaxPhy::GetNrCarriers() const -{ - return m_nrCarriers; -} - -void -WimaxPhy::SetFrameDuration(Time frameDuration) -{ - m_frameDuration = frameDuration; -} - -Time -WimaxPhy::GetFrameDuration() const -{ - return GetFrameDurationSec(); -} - -Time -WimaxPhy::GetFrameDurationSec() const -{ - return m_frameDuration; -} - -void -WimaxPhy::SetFrequency(uint32_t frequency) -{ - m_frequency = frequency; -} - -uint32_t -WimaxPhy::GetFrequency() const -{ - return m_frequency; -} - -void -WimaxPhy::SetChannelBandwidth(uint32_t channelBandwidth) -{ - m_channelBandwidth = channelBandwidth; -} - -uint32_t -WimaxPhy::GetChannelBandwidth() const -{ - return m_channelBandwidth; -} - -uint16_t -WimaxPhy::GetNfft() const -{ - return DoGetNfft(); -} - -double -WimaxPhy::GetSamplingFactor() const -{ - return DoGetSamplingFactor(); -} - -double -WimaxPhy::GetSamplingFrequency() const -{ - return DoGetSamplingFrequency(); -} - -void -WimaxPhy::SetPsDuration(Time psDuration) -{ - m_psDuration = psDuration; -} - -Time -WimaxPhy::GetPsDuration() const -{ - return m_psDuration; -} - -void -WimaxPhy::SetSymbolDuration(Time symbolDuration) -{ - m_symbolDuration = symbolDuration; -} - -Time -WimaxPhy::GetSymbolDuration() const -{ - return m_symbolDuration; -} - -double -WimaxPhy::GetGValue() const -{ - return DoGetGValue(); -} - -void -WimaxPhy::SetPsPerSymbol(uint16_t psPerSymbol) -{ - m_psPerSymbol = psPerSymbol; -} - -uint16_t -WimaxPhy::GetPsPerSymbol() const -{ - return m_psPerSymbol; -} - -void -WimaxPhy::SetPsPerFrame(uint16_t psPerFrame) -{ - m_psPerFrame = psPerFrame; -} - -uint16_t -WimaxPhy::GetPsPerFrame() const -{ - return m_psPerFrame; -} - -void -WimaxPhy::SetSymbolsPerFrame(uint32_t symbolsPerFrame) -{ - m_symbolsPerFrame = symbolsPerFrame; -} - -uint32_t -WimaxPhy::GetSymbolsPerFrame() const -{ - return m_symbolsPerFrame; -} - -} // namespace ns3 diff --git a/src/wimax/model/wimax-phy.h b/src/wimax/model/wimax-phy.h deleted file mode 100644 index feef06786..000000000 --- a/src/wimax/model/wimax-phy.h +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Copyright (c) 2007,2008 INRIA - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Jahanzeb Farooq - */ - -#ifndef WIMAX_PHY_H -#define WIMAX_PHY_H - -#include "bvec.h" -#include "send-params.h" - -#include "ns3/callback.h" -#include "ns3/event-id.h" -#include "ns3/log.h" -#include "ns3/nstime.h" -#include "ns3/object.h" -#include "ns3/traced-callback.h" - -#include -#include - -namespace ns3 -{ - -class WimaxChannel; -class WimaxNetDevice; -class NetDevice; -class Packet; - -/** - * @ingroup wimax - * - * WiMAX PHY entity - */ -class WimaxPhy : public Object -{ - public: - /// ModulationType enumeration - enum ModulationType // Table 356 and 362 - { - MODULATION_TYPE_BPSK_12, - MODULATION_TYPE_QPSK_12, - MODULATION_TYPE_QPSK_34, - MODULATION_TYPE_QAM16_12, - MODULATION_TYPE_QAM16_34, - MODULATION_TYPE_QAM64_23, - MODULATION_TYPE_QAM64_34 - }; - - /// PhyState enumeration - enum PhyState - { - PHY_STATE_IDLE, - PHY_STATE_SCANNING, - PHY_STATE_TX, - PHY_STATE_RX - }; - - /// PhyType enumeration - enum PhyType - { - SimpleWimaxPhy, - simpleOfdmWimaxPhy - }; - - /** - * @brief Get the type ID. - * @return the object TypeId - */ - static TypeId GetTypeId(); - WimaxPhy(); - ~WimaxPhy() override; - /** - * Attach the physical layer to a channel. - * @param channel the channel to which the physical layer will be attached - */ - void Attach(Ptr channel); - /** - * @return the channel to which this physical layer is attached - */ - Ptr GetChannel() const; - /** - * @brief Set the device in which this physical layer is installed - * @param device the device in which this physical layer is installed - */ - void SetDevice(Ptr device); - /** - * @return the the device in which this physical layer is installed - */ - Ptr GetDevice() const; - /** - * @brief set the callback function to call when a burst is received - * @param callback the callback function to call when a burst is received - */ - void SetReceiveCallback(Callback> callback); - /** - * @return the receive callback - */ - Callback> GetReceiveCallback() const; - /** - * @brief send a packet on the channel - * @param params the parameters used to send the packet - */ - virtual void Send(SendParams* params) = 0; - /** - * @brief Get the type of the physical layer - * @returns the phy type - */ - virtual PhyType GetPhyType() const = 0; - /** - * @brief configure the physical layer in duplex mode - * @param rxFrequency the reception frequency - * @param txFrequency the transmission frequency - */ - void SetDuplex(uint64_t rxFrequency, uint64_t txFrequency); - /** - * @brief configure the physical layer in simplex mode - * @param frequency the frequency to be used for reception and transmission process - */ - void SetSimplex(uint64_t frequency); - /** - * Get the reception frequency - * @return the reception frequency - */ - uint64_t GetRxFrequency() const; - /** - * Get the transmission frequency - * @return the transmission frequency - */ - uint64_t GetTxFrequency() const; - /** - * Get the scanning frequency - * @return the scanning frequency - */ - uint64_t GetScanningFrequency() const; - /** - * Set the number of carriers in the physical frame - * @brief Set the number of carriers in the physical frame - * @param nrCarriers the number of carriers in the frame - */ - void SetNrCarriers(uint8_t nrCarriers); - /** - * Get the number of carriers in the physical frame - * @return the number of carriers in the physical frame - */ - uint8_t GetNrCarriers() const; - /** - * @brief Set the frame duration - * @param frameDuration the frame duration - */ - void SetFrameDuration(Time frameDuration); - /** - * @brief Get the frame duration - * This method is redundant with GetFrameDuration () - * @return the frame duration - */ - Time GetFrameDurationSec() const; - /** - * @brief Get the frame duration - * @return the frame duration - */ - Time GetFrameDuration() const; - /** - * @brief set the frequency on which the device should lock - * @param frequency the frequency to configure - */ - void SetFrequency(uint32_t frequency); - /** - * Get the frequency on which the device is locked - * @return the frequency on which the device is locked - */ - uint32_t GetFrequency() const; - /** - * @brief Set the channel bandwidth - * @param channelBandwidth The channel bandwidth - */ - void SetChannelBandwidth(uint32_t channelBandwidth); - /** - * Get the channel bandwidth - * @return the channel bandwidth - */ - uint32_t GetChannelBandwidth() const; - /** - * Get the size of the FFT - * @return the size of the FFT - */ - uint16_t GetNfft() const; - /** - * Get the sampling factor - * @return the sampling factor - */ - double GetSamplingFactor() const; - /** - * Get the sampling frequency - * @return the sampling frequency - */ - double GetSamplingFrequency() const; - /** - * @brief set the physical slot duration - * @param psDuration the physical slot duration - */ - void SetPsDuration(Time psDuration); - /** - * Get the physical slot duration - * @return the physical slot duration - */ - Time GetPsDuration() const; - /** - * @brief set the OFDM symbol duration - * @param symbolDuration the symbol duration - */ - void SetSymbolDuration(Time symbolDuration); - /** - * Get the OFDM symbol duration - * @return the symbol duration in second - */ - Time GetSymbolDuration() const; - /** - * Get the guard interval factor (the ratio TG/Td) - * @return the guard interval factor - */ - double GetGValue() const; - /** - * @brief set the number of physical slots per symbol - * @param psPerSymbol the number of physical slots per symbol - */ - void SetPsPerSymbol(uint16_t psPerSymbol); - /** - * Get the number of physical slots per symbol - * @return the number of physical slots per symbol - */ - uint16_t GetPsPerSymbol() const; - - /** - * @brief set the number of physical slots per frame - * @param psPerFrame the number of physical slots per frame - */ - void SetPsPerFrame(uint16_t psPerFrame); - /** - * Get the number of physical slots per frame - * @return the number of physical slot per frame - */ - uint16_t GetPsPerFrame() const; - /** - * @brief set the number of symbols per frame - * @param symbolsPerFrame the number of symbols per frame - */ - void SetSymbolsPerFrame(uint32_t symbolsPerFrame); - /** - * Get the number of symbols per frame - * @return the number of symbols per frame - */ - uint32_t GetSymbolsPerFrame() const; - /** - * Check if configured in duplex mode - * @return true if the device is configured in duplex mode - */ - bool IsDuplex() const; - /** - * @brief set the state of the device - * @param state the state to be set (PHY_STATE_IDLE, PHY_STATE_SCANNING, PHY_STATE_TX, - * PHY_STATE_RX) - */ - void SetState(PhyState state); - /** - * Get the state of the device - * @return the state of the device (PHY_STATE_IDLE, PHY_STATE_SCANNING, PHY_STATE_TX, - * PHY_STATE_RX) - */ - PhyState GetState() const; - /** - * @brief scan a frequency for maximum timeout seconds and call the callback if the frequency - * can be used - * @param frequency the frequency to scan - * @param timeout the timeout before considering the channel as unusable - * @param callback the function to call if the channel could be used - */ - void StartScanning(uint64_t frequency, Time timeout, Callback callback); - - /** - * @brief calls the scanning call back function - */ - void SetScanningCallback() const; - /** - * @brief Get channel search timeout event - * @return event ID - */ - EventId GetChnlSrchTimeoutEvent() const; - /** - * @brief calculates the data rate of each modulation and save them for future use - */ - void SetDataRates(); - /** - * Get the data rate corresponding to a modulation type - * @return the data rate - * @param modulationType the modulation that you want to get its data rate - */ - uint32_t GetDataRate(ModulationType modulationType) const; - /** - * Get transmission time needed to send bytes at a given modulation - * @return the time needed - * @param size the number of byte to transmit - * @param modulationType the modulation that will be used to transmit the bytes - */ - Time GetTransmissionTime(uint32_t size, ModulationType modulationType) const; - /** - * Get the number of symbols needed to transmit size bytes using the modulation modulationType - * @return the number of symbols needed - * @param size the number of byte to transmit - * @param modulationType the modulation that will be used to transmit the bytes - */ - uint64_t GetNrSymbols(uint32_t size, ModulationType modulationType) const; - /** - * Get the maximum number of bytes that could be carried by symbols symbols using the modulation - * modulationType - * @param symbols the number of symbols to use - * @param modulationType the modulation that will be used - * @return the maximum number of bytes - */ - uint64_t GetNrBytes(uint32_t symbols, ModulationType modulationType) const; - /** - * Get the transmit/receive transition gap - * @return the transmit/receive transition gap - */ - uint16_t GetTtg() const; - /** - * Get the receive/transmit transition gap - * @return the receive/transmit transition gap - */ - uint16_t GetRtg() const; - /** - * Get the frame duration code - * @return the frame duration code - */ - uint8_t GetFrameDurationCode() const; - /** - * Get the frame duration corresponding to a given code - * @param frameDurationCode the frame duration code to use - * @return the frame duration - */ - Time GetFrameDuration(uint8_t frameDurationCode) const; - /** - * @brief computes the Physical parameters and store them - */ - void SetPhyParameters(); - void DoDispose() override; - - /** - * Assign a fixed random variable stream number to the random variables - * used by this model. Return the number of streams (possibly zero) that - * have been assigned. - * - * @param stream first stream index to use - * @return the number of stream indices assigned by this model - */ - virtual int64_t AssignStreams(int64_t stream) = 0; - - private: - /** - * Get modulation FEC parameters - * @param modulationType the modultion type - * @param bitsPerSymbol the number of bits per symbol page - * @param fecCode the FEC code - */ - void GetModulationFecParams(ModulationType modulationType, - uint8_t& bitsPerSymbol, - double& fecCode) const; - /// End scanning - void EndScanning(); - /** - * Get transmission time - * @param size the transmission size - * @param modulationType the modulation type - * @returns the transmission time - */ - virtual Time DoGetTransmissionTime(uint32_t size, ModulationType modulationType) const = 0; - /** - * Attach channel - * @param channel the wimax channel - */ - virtual void DoAttach(Ptr channel) = 0; - /// Set data rates - virtual void DoSetDataRates() = 0; - /** - * Get data rate - * @param modulationType the modulation type - * @returns the data rate - */ - virtual uint32_t DoGetDataRate(ModulationType modulationType) const = 0; - /** - * Get number of symbols - * @param size the transmission size - * @param modulationType the modulation type - * @returns the number of symbols - */ - virtual uint64_t DoGetNrSymbols(uint32_t size, ModulationType modulationType) const = 0; - /** - * Get number of bytes - * @param symbols the number of symbols - * @param modulationType the modulation type - * @returns the number of bytes - */ - virtual uint64_t DoGetNrBytes(uint32_t symbols, ModulationType modulationType) const = 0; - /** - * Get TTG - * @returns the TTG - */ - virtual uint16_t DoGetTtg() const = 0; - /** - * Get RTG - * @returns the RTG - */ - virtual uint16_t DoGetRtg() const = 0; - - /** - * Get frame duration code - * @returns the frame duration code - */ - virtual uint8_t DoGetFrameDurationCode() const = 0; - /** - * Get frame duration - * @param frameDurationCode the frame duration code - * @returns the frame duration time - */ - virtual Time DoGetFrameDuration(uint8_t frameDurationCode) const = 0; - /** - * Set phy parameters - */ - virtual void DoSetPhyParameters() = 0; - /** - * Get sampling factor - * @return the sampling factor - */ - virtual double DoGetSamplingFactor() const = 0; - /** - * Get NFFT - * @returns the NFFT - */ - virtual uint16_t DoGetNfft() const = 0; - /** - * Get sampling frequency - * @returns the sampling frequency - */ - virtual double DoGetSamplingFrequency() const = 0; - /** - * Get G value - * @returns he G value - */ - virtual double DoGetGValue() const = 0; - - Ptr m_device; ///< the device - Ptr m_channel; ///< channel - - uint64_t m_txFrequency; ///< transmit frequency - uint64_t m_rxFrequency; ///< receive frequency - uint64_t m_scanningFrequency; ///< scanning frequency - EventId m_dlChnlSrchTimeoutEvent; ///< DL channel search timeout event - bool m_duplex; ///< duplex - PhyState m_state; ///< state - - Callback> m_rxCallback; ///< receive callback function - Callback m_scanningCallback; ///< scanning callback function - - uint8_t m_nrCarriers; ///< number of carriers - Time m_frameDuration; ///< in seconds - uint32_t m_frequency; ///< in KHz - uint32_t m_channelBandwidth; ///< in Hz - Time m_psDuration; ///< in seconds - Time m_symbolDuration; ///< in seconds - uint16_t m_psPerSymbol; ///< ps per sumbol - uint16_t m_psPerFrame; ///< ps per framce - uint32_t m_symbolsPerFrame; ///< symbols per frame -}; - -} // namespace ns3 - -#endif /* WIMAX_PHY_H */ diff --git a/src/wimax/model/wimax-tlv.cc b/src/wimax/model/wimax-tlv.cc deleted file mode 100644 index 9fb61dacb..000000000 --- a/src/wimax/model/wimax-tlv.cc +++ /dev/null @@ -1,1072 +0,0 @@ -/* - * Copyright (c) 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - * - */ - -#include "wimax-tlv.h" - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("Tlv"); - -// NS_OBJECT_ENSURE_REGISTERED ("Tlv"); - -/* static */ -TypeId -Tlv::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::Tlv").SetParent
().SetGroupName("Wimax").AddConstructor(); - return tid; -} - -TypeId -Tlv::GetInstanceTypeId() const -{ - return GetTypeId(); -} - -void -Tlv::Print(std::ostream& os) const -{ - os << "TLV type = " << (uint32_t)m_type << " TLV Length = " << (uint64_t)m_length; -} - -Tlv::Tlv(uint8_t type, uint64_t length, const TlvValue& value) -{ - m_type = type; - m_length = length; - m_value = value.Copy(); -} - -Tlv::Tlv() -{ - m_type = 0; - m_length = 0; - m_value = nullptr; -} - -Tlv::~Tlv() -{ - if (m_value != nullptr) - { - delete m_value; - m_value = nullptr; - } -} - -TlvValue* -Tlv::CopyValue() const -{ - return m_value->Copy(); -} - -Tlv::Tlv(const Tlv& tlv) -{ - m_type = tlv.GetType(); - m_length = tlv.GetLength(); - m_value = tlv.CopyValue(); -} - -Tlv& -Tlv::operator=(const Tlv& o) -{ - if (m_value != nullptr) - { - delete m_value; - } - m_type = o.GetType(); - m_length = o.GetLength(); - m_value = o.CopyValue(); - - return *this; -} - -uint32_t -Tlv::GetSerializedSize() const -{ - return 1 + GetSizeOfLen() + m_value->GetSerializedSize(); -} - -uint8_t -Tlv::GetSizeOfLen() const -{ - uint8_t sizeOfLen = 1; - - if (m_length > 127) - { - sizeOfLen = 2; - uint64_t testValue = 0xFF; - while (m_length > testValue) - { - sizeOfLen++; - testValue *= 0xFF; - } - } - return sizeOfLen; -} - -void -Tlv::Serialize(Buffer::Iterator i) const -{ - i.WriteU8(m_type); - uint8_t lenSize = GetSizeOfLen(); - if (lenSize == 1) - { - i.WriteU8(m_length); - } - else - { - i.WriteU8((lenSize - 1) | WIMAX_TLV_EXTENDED_LENGTH_MASK); - for (int j = 0; j < lenSize - 1; j++) - { - i.WriteU8((uint8_t)(m_length >> ((lenSize - 1 - 1 - j) * 8))); - } - } - m_value->Serialize(i); -} - -uint32_t -Tlv::Deserialize(Buffer::Iterator i) -{ - // read the type of tlv - m_type = i.ReadU8(); - - // read the length - uint8_t lenSize = i.ReadU8(); - uint32_t serializedSize = 2; - if (lenSize < 127) - { - m_length = lenSize; - } - else - { - lenSize &= ~WIMAX_TLV_EXTENDED_LENGTH_MASK; - for (int j = 0; j < lenSize; j++) - { - m_length <<= 8; - m_length |= i.ReadU8(); - serializedSize++; - } - } - switch (m_type) - { - case HMAC_TUPLE: - /// @todo implement Deserialize HMAC_TUPLE - NS_FATAL_ERROR("Not implemented-- please implement and contribute a patch"); - break; - case MAC_VERSION_ENCODING: - /// @todo implement Deserialize MAC_VERSION_ENCODING - NS_FATAL_ERROR("Not implemented-- please implement and contribute a patch"); - break; - case CURRENT_TRANSMIT_POWER: - /// @todo implement Deserialize CURRENT_TRANSMIT_POWER - NS_FATAL_ERROR("Not implemented-- please implement and contribute a patch"); - break; - case DOWNLINK_SERVICE_FLOW: { - SfVectorTlvValue val; - serializedSize += val.Deserialize(i, m_length); - m_value = val.Copy(); - break; - } - case UPLINK_SERVICE_FLOW: { - SfVectorTlvValue val; - serializedSize += val.Deserialize(i, m_length); - m_value = val.Copy(); - break; - } - case VENDOR_ID_EMCODING: - /// @todo implement Deserialize VENDOR_ID_EMCODING - NS_FATAL_ERROR("Not implemented-- please implement and contribute a patch"); - break; - case VENDOR_SPECIFIC_INFORMATION: - /// @todo implement Deserialize VENDOR_SPECIFIC_INFORMATION - NS_FATAL_ERROR("Not implemented-- please implement and contribute a patch"); - break; - default: - NS_ASSERT_MSG(false, "Unknown tlv type."); - break; - } - - return serializedSize; -} - -uint8_t -Tlv::GetType() const -{ - return m_type; -} - -uint64_t -Tlv::GetLength() const -{ - return m_length; -} - -TlvValue* -Tlv::PeekValue() -{ - return m_value; -} - -Tlv* -Tlv::Copy() const -{ - return new Tlv(m_type, m_length, *m_value); -} - -// ============================================================================== -VectorTlvValue::VectorTlvValue() -{ - m_tlvList = new std::vector; -} - -VectorTlvValue::~VectorTlvValue() -{ - for (auto iter = m_tlvList->begin(); iter != m_tlvList->end(); ++iter) - { - delete (*iter); - } - m_tlvList->clear(); - delete m_tlvList; -} - -uint32_t -VectorTlvValue::GetSerializedSize() const -{ - uint32_t size = 0; - for (auto iter = m_tlvList->begin(); iter != m_tlvList->end(); ++iter) - { - size += (*iter)->GetSerializedSize(); - } - return size; -} - -void -VectorTlvValue::Serialize(Buffer::Iterator i) const -{ - for (auto iter = m_tlvList->begin(); iter != m_tlvList->end(); ++iter) - { - (*iter)->Serialize(i); - i.Next((*iter)->GetSerializedSize()); - } -} - -VectorTlvValue::Iterator -VectorTlvValue::Begin() const -{ - return m_tlvList->begin(); -} - -VectorTlvValue::Iterator -VectorTlvValue::End() const -{ - return m_tlvList->end(); -} - -void -VectorTlvValue::Add(const Tlv& val) -{ - m_tlvList->push_back(val.Copy()); -} - -// ============================================================================== -SfVectorTlvValue::SfVectorTlvValue() -{ -} - -SfVectorTlvValue* -SfVectorTlvValue::Copy() const -{ - auto tmp = new SfVectorTlvValue(); - for (auto iter = Begin(); iter != End(); ++iter) - { - tmp->Add(Tlv((*iter)->GetType(), (*iter)->GetLength(), *(*iter)->PeekValue())); - } - return tmp; -} - -uint32_t -SfVectorTlvValue::Deserialize(Buffer::Iterator i, uint64_t valueLen) -{ - uint64_t serializedSize = 0; - while (serializedSize < valueLen) - { - uint8_t type = i.ReadU8(); - // read the length - uint8_t lenSize = i.ReadU8(); - serializedSize += 2; - uint64_t length = 0; - if (lenSize < 127) - { - length = lenSize; - } - else - { - lenSize &= ~WIMAX_TLV_EXTENDED_LENGTH_MASK; - for (int j = 0; j < lenSize; j++) - { - length <<= 8; - length |= i.ReadU8(); - serializedSize++; - } - } - switch (type) - { - case SFID: { - U32TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(SFID, 4, val)); - break; - } - case CID: { - U16TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(CID, 2, val)); - break; - } - case Service_Class_Name: - NS_FATAL_ERROR("Not implemented-- please implement and contribute a patch"); - break; - case reserved1: - // NOTHING - break; - case QoS_Parameter_Set_Type: { - U8TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(QoS_Parameter_Set_Type, 1, val)); - break; - } - case Traffic_Priority: { - U8TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Traffic_Priority, 1, val)); - break; - } - case Maximum_Sustained_Traffic_Rate: { - U32TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Maximum_Sustained_Traffic_Rate, 4, val)); - break; - } - case Maximum_Traffic_Burst: { - U32TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Maximum_Traffic_Burst, 4, val)); - break; - } - case Minimum_Reserved_Traffic_Rate: { - U32TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Minimum_Reserved_Traffic_Rate, 4, val)); - break; - } - case Minimum_Tolerable_Traffic_Rate: { - U32TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Minimum_Tolerable_Traffic_Rate, 4, val)); - break; - } - case Service_Flow_Scheduling_Type: { - U8TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Service_Flow_Scheduling_Type, 1, val)); - break; - } - case Request_Transmission_Policy: { - U32TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Request_Transmission_Policy, 4, val)); - break; - } - case Tolerated_Jitter: { - U32TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Tolerated_Jitter, 4, val)); - break; - } - case Maximum_Latency: { - U32TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Maximum_Latency, 4, val)); - break; - } - case Fixed_length_versus_Variable_length_SDU_Indicator: { - U8TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Fixed_length_versus_Variable_length_SDU_Indicator, 1, val)); - break; - } - case SDU_Size: { - U8TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(SDU_Size, 1, val)); - break; - } - case Target_SAID: { - U16TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Target_SAID, 2, val)); - break; - } - case ARQ_Enable: { - U8TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(ARQ_Enable, 1, val)); - break; - } - case ARQ_WINDOW_SIZE: { - U16TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(ARQ_WINDOW_SIZE, 2, val)); - break; - } - case ARQ_RETRY_TIMEOUT_Transmitter_Delay: - case ARQ_RETRY_TIMEOUT_Receiver_Delay: - case ARQ_BLOCK_LIFETIME: - case ARQ_SYNC_LOSS: - case ARQ_DELIVER_IN_ORDER: - case ARQ_PURGE_TIMEOUT: - case ARQ_BLOCK_SIZE: - case reserved2: - break; - case CS_Specification: { - U8TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(CS_Specification, 1, val)); - break; - } - case IPV4_CS_Parameters: { - CsParamVectorTlvValue val; - uint32_t size = val.Deserialize(i, length); - serializedSize += size; - Add(Tlv(IPV4_CS_Parameters, size, val)); - break; - } - default: - NS_ASSERT_MSG(false, "Unknown tlv type."); - break; - } - i.Next(length); - } - return serializedSize; -} - -// ============================================================================== - -U8TlvValue::U8TlvValue(uint8_t value) -{ - m_value = value; -} - -U8TlvValue::U8TlvValue() -{ - m_value = 0; -} - -U8TlvValue::~U8TlvValue() -{ -} - -uint32_t -U8TlvValue::GetSerializedSize() const -{ - return 1; -} - -void -U8TlvValue::Serialize(Buffer::Iterator i) const -{ - i.WriteU8(m_value); -} - -uint32_t -U8TlvValue::Deserialize(Buffer::Iterator i, uint64_t valueLen) -{ - return Deserialize(i); -} - -uint32_t -U8TlvValue::Deserialize(Buffer::Iterator i) -{ - m_value = i.ReadU8(); - return 1; -} - -uint8_t -U8TlvValue::GetValue() const -{ - return m_value; -} - -U8TlvValue* -U8TlvValue::Copy() const -{ - auto tmp = new U8TlvValue(m_value); - return tmp; -} - -// ============================================================================== -U16TlvValue::U16TlvValue(uint16_t value) -{ - m_value = value; -} - -U16TlvValue::U16TlvValue() -{ - m_value = 0; -} - -U16TlvValue::~U16TlvValue() -{ -} - -uint32_t -U16TlvValue::GetSerializedSize() const -{ - return 2; -} - -void -U16TlvValue::Serialize(Buffer::Iterator i) const -{ - i.WriteHtonU16(m_value); -} - -uint32_t -U16TlvValue::Deserialize(Buffer::Iterator i, uint64_t valueLen) -{ - return Deserialize(i); -} - -uint32_t -U16TlvValue::Deserialize(Buffer::Iterator i) -{ - m_value = i.ReadNtohU16(); - return 2; -} - -uint16_t -U16TlvValue::GetValue() const -{ - return m_value; -} - -U16TlvValue* -U16TlvValue::Copy() const -{ - auto tmp = new U16TlvValue(m_value); - return tmp; -} - -// ============================================================================== -U32TlvValue::U32TlvValue(uint32_t value) -{ - m_value = value; -} - -U32TlvValue::U32TlvValue() -{ - m_value = 0; -} - -U32TlvValue::~U32TlvValue() -{ -} - -uint32_t -U32TlvValue::GetSerializedSize() const -{ - return 4; -} - -void -U32TlvValue::Serialize(Buffer::Iterator i) const -{ - i.WriteHtonU32(m_value); -} - -uint32_t -U32TlvValue::Deserialize(Buffer::Iterator i, uint64_t valueLen) -{ - return Deserialize(i); -} - -uint32_t -U32TlvValue::Deserialize(Buffer::Iterator i) -{ - m_value = i.ReadNtohU32(); - return 4; -} - -uint32_t -U32TlvValue::GetValue() const -{ - return m_value; -} - -U32TlvValue* -U32TlvValue::Copy() const -{ - auto tmp = new U32TlvValue(m_value); - return tmp; -} - -// ============================================================================== -uint32_t -CsParamVectorTlvValue::Deserialize(Buffer::Iterator i, uint64_t valueLength) -{ - uint64_t serializedSize = 0; - uint8_t lenSize = 0; - uint8_t type = 0; - while (serializedSize < valueLength) - { - type = i.ReadU8(); - // read the length - lenSize = i.ReadU8(); - serializedSize += 2; - uint64_t length = 0; - if (lenSize < 127) - { - length = lenSize; - } - else - { - lenSize &= ~WIMAX_TLV_EXTENDED_LENGTH_MASK; - for (int j = 0; j < lenSize; j++) - { - length <<= 8; - length |= i.ReadU8(); - serializedSize++; - } - } - switch (type) - { - case Classifier_DSC_Action: { - U8TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Classifier_DSC_Action, 1, val)); - break; - } - case Packet_Classification_Rule: { - ClassificationRuleVectorTlvValue val; - serializedSize += val.Deserialize(i, length); - Add(Tlv(Packet_Classification_Rule, val.GetSerializedSize(), val)); - break; - } - } - i.Next(length); - } - return serializedSize; -} - -CsParamVectorTlvValue::CsParamVectorTlvValue() -{ -} - -CsParamVectorTlvValue* -CsParamVectorTlvValue::Copy() const -{ - auto tmp = new CsParamVectorTlvValue(); - for (auto iter = Begin(); iter != End(); ++iter) - { - tmp->Add(Tlv((*iter)->GetType(), (*iter)->GetLength(), *(*iter)->PeekValue())); - } - return tmp; -} - -// ============================================================================== - -ClassificationRuleVectorTlvValue::ClassificationRuleVectorTlvValue() -{ -} - -ClassificationRuleVectorTlvValue* -ClassificationRuleVectorTlvValue::Copy() const -{ - auto tmp = new ClassificationRuleVectorTlvValue(); - for (auto iter = Begin(); iter != End(); ++iter) - { - tmp->Add(Tlv((*iter)->GetType(), (*iter)->GetLength(), *(*iter)->PeekValue())); - } - return tmp; -} - -uint32_t -ClassificationRuleVectorTlvValue::Deserialize(Buffer::Iterator i, uint64_t valueLength) -{ - uint64_t serializedSize = 0; - uint8_t lenSize = 0; - uint8_t type = 0; - while (serializedSize < valueLength) - { - type = i.ReadU8(); - // read the length - lenSize = i.ReadU8(); - serializedSize += 2; - uint64_t length = 0; - if (lenSize < 127) - { - length = lenSize; - } - else - { - lenSize &= ~WIMAX_TLV_EXTENDED_LENGTH_MASK; - for (int j = 0; j < lenSize; j++) - { - length <<= 8; - length |= i.ReadU8(); - serializedSize++; - } - } - switch (type) - { - case Priority: { - U8TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Priority, 1, val)); - break; - } - case ToS: { - TosTlvValue val; - serializedSize += val.Deserialize(i, length); - Add(Tlv(ToS, val.GetSerializedSize(), val)); - break; - } - case Protocol: { - ProtocolTlvValue val; - serializedSize += val.Deserialize(i, length); - Add(Tlv(Protocol, val.GetSerializedSize(), val)); - break; - } - case IP_src: { - Ipv4AddressTlvValue val; - serializedSize += val.Deserialize(i, length); - Add(Tlv(IP_src, val.GetSerializedSize(), val)); - break; - } - case IP_dst: { - Ipv4AddressTlvValue val; - serializedSize += val.Deserialize(i, length); - Add(Tlv(IP_dst, val.GetSerializedSize(), val)); - break; - } - case Port_src: { - PortRangeTlvValue val; - serializedSize += val.Deserialize(i, length); - Add(Tlv(Port_src, val.GetSerializedSize(), val)); - break; - } - case Port_dst: { - PortRangeTlvValue val; - serializedSize += val.Deserialize(i, length); - Add(Tlv(Port_dst, val.GetSerializedSize(), val)); - break; - } - case Index: { - U16TlvValue val; - serializedSize += val.Deserialize(i); - Add(Tlv(Index, 2, val)); - break; - } - } - i.Next(length); - } - return serializedSize; -} - -// ============================================================================== -TosTlvValue::TosTlvValue() -{ - m_low = 0; - m_high = 0; - m_mask = 0; -} - -TosTlvValue::TosTlvValue(uint8_t low, uint8_t high, uint8_t mask) -{ - m_low = low; - m_high = high; - m_mask = mask; -} - -TosTlvValue::~TosTlvValue() -{ -} - -uint32_t -TosTlvValue::GetSerializedSize() const -{ - return 3; -} - -void -TosTlvValue::Serialize(Buffer::Iterator i) const -{ - i.WriteU8(m_low); - i.WriteU8(m_high); - i.WriteU8(m_mask); -} - -uint32_t -TosTlvValue::Deserialize(Buffer::Iterator i, uint64_t valueLength) -{ - m_low = i.ReadU8(); - m_high = i.ReadU8(); - m_mask = i.ReadU8(); - return 3; -} - -uint8_t -TosTlvValue::GetLow() const -{ - return m_low; -} - -uint8_t -TosTlvValue::GetHigh() const -{ - return m_high; -} - -uint8_t -TosTlvValue::GetMask() const -{ - return m_mask; -} - -TosTlvValue* -TosTlvValue::Copy() const -{ - return new TosTlvValue(m_low, m_high, m_mask); -} - -// ============================================================================== -PortRangeTlvValue::PortRangeTlvValue() -{ - m_portRange = new std::vector; -} - -PortRangeTlvValue::~PortRangeTlvValue() -{ - m_portRange->clear(); - delete m_portRange; -} - -uint32_t -PortRangeTlvValue::GetSerializedSize() const -{ - return m_portRange->size() * 4; // a port range is defined by 2 ports, each using 2 bytes -} - -void -PortRangeTlvValue::Serialize(Buffer::Iterator i) const -{ - for (auto iter = m_portRange->begin(); iter != m_portRange->end(); ++iter) - { - i.WriteHtonU16((*iter).PortLow); - i.WriteHtonU16((*iter).PortHigh); - } -} - -uint32_t -PortRangeTlvValue::Deserialize(Buffer::Iterator i, uint64_t valueLength) -{ - uint64_t len = 0; - while (len < valueLength) - { - uint16_t low = i.ReadNtohU16(); - uint16_t high = i.ReadNtohU16(); - Add(low, high); - len += 4; - } - return len; -} - -void -PortRangeTlvValue::Add(uint16_t portLow, uint16_t portHigh) -{ - PortRange tmp; - tmp.PortLow = portLow; - tmp.PortHigh = portHigh; - m_portRange->push_back(tmp); -} - -PortRangeTlvValue::Iterator -PortRangeTlvValue::Begin() const -{ - return m_portRange->begin(); -} - -PortRangeTlvValue::Iterator -PortRangeTlvValue::End() const -{ - return m_portRange->end(); -} - -PortRangeTlvValue* -PortRangeTlvValue::Copy() const -{ - auto tmp = new PortRangeTlvValue(); - for (auto iter = m_portRange->begin(); iter != m_portRange->end(); ++iter) - { - tmp->Add((*iter).PortLow, (*iter).PortHigh); - } - return tmp; -} - -// ============================================================================== - -ProtocolTlvValue::ProtocolTlvValue() -{ - m_protocol = new std::vector; -} - -ProtocolTlvValue::~ProtocolTlvValue() -{ - if (m_protocol != nullptr) - { - m_protocol->clear(); - delete m_protocol; - m_protocol = nullptr; - } -} - -uint32_t -ProtocolTlvValue::GetSerializedSize() const -{ - return m_protocol->size(); -} - -void -ProtocolTlvValue::Serialize(Buffer::Iterator i) const -{ - for (auto iter = m_protocol->begin(); iter != m_protocol->end(); ++iter) - { - i.WriteU8(*iter); - } -} - -uint32_t -ProtocolTlvValue::Deserialize(Buffer::Iterator i, uint64_t valueLength) -{ - uint64_t len = 0; - while (len < valueLength) - { - Add(i.ReadU8()); - len++; - } - return len; -} - -void -ProtocolTlvValue::Add(uint8_t protocol) -{ - m_protocol->push_back(protocol); -} - -ProtocolTlvValue::Iterator -ProtocolTlvValue::Begin() const -{ - return m_protocol->begin(); -} - -ProtocolTlvValue::Iterator -ProtocolTlvValue::End() const -{ - return m_protocol->end(); -} - -ProtocolTlvValue* -ProtocolTlvValue::Copy() const -{ - auto tmp = new ProtocolTlvValue(); - for (auto iter = m_protocol->begin(); iter != m_protocol->end(); ++iter) - { - tmp->Add(*iter); - } - return tmp; -} - -// ============================================================================== - -Ipv4AddressTlvValue::Ipv4AddressTlvValue() -{ - m_ipv4Addr = new std::vector; -} - -Ipv4AddressTlvValue::~Ipv4AddressTlvValue() -{ - if (m_ipv4Addr != nullptr) - { - m_ipv4Addr->clear(); - delete m_ipv4Addr; - m_ipv4Addr = nullptr; - } -} - -uint32_t -Ipv4AddressTlvValue::GetSerializedSize() const -{ - return m_ipv4Addr->size() * 8; // IPv4 address and mask are 4 bytes each -} - -void -Ipv4AddressTlvValue::Serialize(Buffer::Iterator i) const -{ - for (auto iter = m_ipv4Addr->begin(); iter != m_ipv4Addr->end(); ++iter) - { - i.WriteHtonU32((*iter).Address.Get()); - i.WriteHtonU32((*iter).Mask.Get()); - } -} - -uint32_t -Ipv4AddressTlvValue::Deserialize(Buffer::Iterator i, uint64_t valueLength) -{ - uint64_t len = 0; - while (len < valueLength) - { - uint32_t addr = i.ReadNtohU32(); - uint32_t mask = i.ReadNtohU32(); - Add(Ipv4Address(addr), Ipv4Mask(mask)); - len += 8; - } - return len; -} - -void -Ipv4AddressTlvValue::Add(Ipv4Address address, Ipv4Mask mask) -{ - m_ipv4Addr->push_back({address, mask}); -} - -Ipv4AddressTlvValue::Iterator -Ipv4AddressTlvValue::Begin() const -{ - return m_ipv4Addr->begin(); -} - -Ipv4AddressTlvValue::Iterator -Ipv4AddressTlvValue::End() const -{ - return m_ipv4Addr->end(); -} - -Ipv4AddressTlvValue* -Ipv4AddressTlvValue::Copy() const -{ - auto tmp = new Ipv4AddressTlvValue(); - for (auto iter = m_ipv4Addr->begin(); iter != m_ipv4Addr->end(); ++iter) - { - tmp->Add((*iter).Address, (*iter).Mask); - } - return tmp; -} - -} // namespace ns3 diff --git a/src/wimax/model/wimax-tlv.h b/src/wimax/model/wimax-tlv.h deleted file mode 100644 index 94434f321..000000000 --- a/src/wimax/model/wimax-tlv.h +++ /dev/null @@ -1,602 +0,0 @@ -/* - * Copyright (c) 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - * - */ - -#ifndef WIMAX_TLV_H -#define WIMAX_TLV_H - -#define WIMAX_TLV_EXTENDED_LENGTH_MASK 0x80 - -#include "ns3/assert.h" -#include "ns3/header.h" -#include "ns3/ipv4-address.h" -#include "ns3/log.h" -#include "ns3/uinteger.h" - -#include -#include - -namespace ns3 -{ - -/** - * @ingroup wimax - * The value field of a tlv can take different values (uint8_t, uint16, - * vector, ...). This class is a virtual interface - * from which all the types of tlv values should derive - */ -class TlvValue -{ - public: - virtual ~TlvValue() - { - } - - /** - * Get serialized size in bytes - * @returns the serialized size - */ - virtual uint32_t GetSerializedSize() const = 0; - /** - * Serialize to a buffer - * @param start the iterator - */ - virtual void Serialize(Buffer::Iterator start) const = 0; - /** - * Deserialize from a buffer - * @param start the iterator - * @param valueLen the maximum length of the value - * @returns the - */ - virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLen) = 0; - /** - * Copy function - * @returns the TLV value - */ - virtual TlvValue* Copy() const = 0; - - private: -}; - -// ============================================================================= -/** - * @ingroup wimax - * @brief This class implements the Type-Len-Value structure channel encodings as described by "IEEE - * Standard for Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband - * Wireless Access Systems" - * 11. TLV encodings, page 645 - * - */ -class Tlv : public Header -{ - public: - /// CommonTypes enumeration - enum CommonTypes - { - HMAC_TUPLE = 149, - MAC_VERSION_ENCODING = 148, - CURRENT_TRANSMIT_POWER = 147, - DOWNLINK_SERVICE_FLOW = 146, - UPLINK_SERVICE_FLOW = 145, - VENDOR_ID_EMCODING = 144, - VENDOR_SPECIFIC_INFORMATION = 143 - }; - - /** - * Constructor - * - * @param type type - * @param length the length - * @param value TLV value - */ - Tlv(uint8_t type, uint64_t length, const TlvValue& value); - Tlv(); - ~Tlv() override; - /** - * Register this type. - * @return the TypeId. - */ - static TypeId GetTypeId(); - TypeId GetInstanceTypeId() const override; - void Print(std::ostream& os) const override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start) override; - /** - * Get size of length field - * @returns the size of length field - */ - uint8_t GetSizeOfLen() const; - /** - * Get type value - * @returns the type - */ - uint8_t GetType() const; - /** - * Get length value - * @returns the length - */ - uint64_t GetLength() const; - /** - * Peek value - * @returns the TLV value - */ - TlvValue* PeekValue(); - /** - * Copy TLV - * @returns a pointer to a TLV copy - */ - Tlv* Copy() const; - /** - * Copy TlvValue - * @returns the TLV value - */ - TlvValue* CopyValue() const; - /** - * assignment operator - * @param o the TLV to assign - * @returns the TLV - */ - Tlv& operator=(const Tlv& o); - /** - * type conversion operator - * @param tlv the TLV - */ - Tlv(const Tlv& tlv); - - private: - uint8_t m_type; ///< type - uint64_t m_length; ///< length - TlvValue* m_value; ///< value -}; - -// ============================================================================== -/** - * @ingroup wimax - * @brief U8TlvValue class - */ -class U8TlvValue : public TlvValue -{ - public: - /** - * Constructor - * - * @param value value to encode - */ - U8TlvValue(uint8_t value); - U8TlvValue(); - ~U8TlvValue() override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLen) override; - /** - * Deserialize from a buffer - * @param start the iterator - * @returns the size of the item - */ - uint32_t Deserialize(Buffer::Iterator start); - /** - * Get value - * @returns the value - */ - uint8_t GetValue() const; - /** - * Copy - * @returns a U8 TLV value - */ - U8TlvValue* Copy() const override; - - private: - uint8_t m_value; ///< value -}; - -// ============================================================================== -/** - * @ingroup wimax - * @brief U16TlvValue class - */ -class U16TlvValue : public TlvValue -{ - public: - /** - * Constructor - * - * @param value value to encode - */ - U16TlvValue(uint16_t value); - U16TlvValue(); - ~U16TlvValue() override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLen) override; - /** - * Deserialize from a buffer - * @param start the iterator - * @returns the size - */ - uint32_t Deserialize(Buffer::Iterator start); - /** - * Get value - * @returns the value - */ - uint16_t GetValue() const; - /** - * Copy - * @returns the U16 TLV value - */ - U16TlvValue* Copy() const override; - - private: - uint16_t m_value; ///< value -}; - -// ============================================================================== -/** - * @ingroup wimax - * @brief U32TlvValue class - */ -class U32TlvValue : public TlvValue -{ - public: - /** - * Constructor - * - * @param value to encode - */ - U32TlvValue(uint32_t value); - U32TlvValue(); - ~U32TlvValue() override; - - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLen) override; - /** - * Deserialize from a buffer - * @param start the iterator - * @returns the size - */ - uint32_t Deserialize(Buffer::Iterator start); - /** - * Get value - * @returns the value - */ - uint32_t GetValue() const; - /** - * Copy - * @returns the U32 TLV Value - */ - U32TlvValue* Copy() const override; - - private: - uint32_t m_value; ///< value -}; - -// ============================================================================== - -/** - * @ingroup wimax - * @brief this class is used to implement a vector of values in one tlv value field - */ -class VectorTlvValue : public TlvValue -{ - public: - /// TLV vector iterator typedef - typedef std::vector::const_iterator Iterator; - VectorTlvValue(); - ~VectorTlvValue() override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength) override = 0; - /** - * Begin iterator - * @returns the beginning element - */ - Iterator Begin() const; - /** - * End iterator - * @returns the ending element - */ - Iterator End() const; - /** - * Add a TLV - * @param val the TLV value - */ - void Add(const Tlv& val); - /** - * Copy - * @returns the vector TLV value - */ - VectorTlvValue* Copy() const override = 0; - - private: - std::vector* m_tlvList; ///< tlv list -}; - -// ============================================================================== -/** - * @ingroup wimax - * @brief SfVectorTlvValue class - */ -class SfVectorTlvValue : public VectorTlvValue -{ - public: - /// Type enumeration - enum Type - { - SFID = 1, - CID = 2, - Service_Class_Name = 3, - reserved1 = 4, - QoS_Parameter_Set_Type = 5, - Traffic_Priority = 6, - Maximum_Sustained_Traffic_Rate = 7, - Maximum_Traffic_Burst = 8, - Minimum_Reserved_Traffic_Rate = 9, - Minimum_Tolerable_Traffic_Rate = 10, - Service_Flow_Scheduling_Type = 11, - Request_Transmission_Policy = 12, - Tolerated_Jitter = 13, - Maximum_Latency = 14, - Fixed_length_versus_Variable_length_SDU_Indicator = 15, - SDU_Size = 16, - Target_SAID = 17, - ARQ_Enable = 18, - ARQ_WINDOW_SIZE = 19, - ARQ_RETRY_TIMEOUT_Transmitter_Delay = 20, - ARQ_RETRY_TIMEOUT_Receiver_Delay = 21, - ARQ_BLOCK_LIFETIME = 22, - ARQ_SYNC_LOSS = 23, - ARQ_DELIVER_IN_ORDER = 24, - ARQ_PURGE_TIMEOUT = 25, - ARQ_BLOCK_SIZE = 26, - reserved2 = 27, - CS_Specification = 28, - IPV4_CS_Parameters = 100 - }; - - SfVectorTlvValue(); - uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength) override; - SfVectorTlvValue* Copy() const override; -}; - -// ============================================================================== - -/** - * @ingroup wimax - * @brief this class implements the convergence sub-layer descriptor as a tlv vector - */ -class CsParamVectorTlvValue : public VectorTlvValue -{ - public: - /// Type enumeration - enum Type - { - Classifier_DSC_Action = 1, - Packet_Classification_Rule = 3, - }; - - CsParamVectorTlvValue(); - uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength) override; - CsParamVectorTlvValue* Copy() const override; - - private: -}; - -// ============================================================================== - -/** - * @ingroup wimax - * @brief this class implements the classifier descriptor as a tlv vector - */ -class ClassificationRuleVectorTlvValue : public VectorTlvValue -{ - public: - /// ClassificationRuleTlvType enumeration - enum ClassificationRuleTlvType - { - Priority = 1, - ToS = 2, - Protocol = 3, - IP_src = 4, - IP_dst = 5, - Port_src = 6, - Port_dst = 7, - Index = 14, - }; - - ClassificationRuleVectorTlvValue(); - uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength) override; - ClassificationRuleVectorTlvValue* Copy() const override; - - private: -}; - -// ============================================================================== -/** - * @ingroup wimax - * @brief TosTlvValue class - */ -class TosTlvValue : public TlvValue -{ - public: - TosTlvValue(); - /** - * Constructor - * - * @param low low value - * @param high high value - * @param mask the mask - */ - TosTlvValue(uint8_t low, uint8_t high, uint8_t mask); - ~TosTlvValue() override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength) override; - /** - * Get low part - * @returns the low part - */ - uint8_t GetLow() const; - /** - * Get high part - * @returns the high part - */ - uint8_t GetHigh() const; - /** - * Get the mask - * @returns the mask - */ - uint8_t GetMask() const; - /** - * Copy - * @returns the TOS TLV value - */ - TosTlvValue* Copy() const override; - - private: - uint8_t m_low; ///< low - uint8_t m_high; ///< high - uint8_t m_mask; ///< mask -}; - -// ============================================================================== -/** - * @ingroup wimax - * @brief PortRangeTlvValue class - */ -class PortRangeTlvValue : public TlvValue -{ - public: - /// PortRange structure - struct PortRange - { - uint16_t PortLow; ///< low - uint16_t PortHigh; ///< high - }; - - /// PortRange vector iterator typedef - typedef std::vector::const_iterator Iterator; - PortRangeTlvValue(); - ~PortRangeTlvValue() override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength) override; - /** - * Add a range - * @param portLow the low port of the range - * @param portHigh the high port of the range - */ - void Add(uint16_t portLow, uint16_t portHigh); - /** - * Begin iterator - * @returns the beginning element - */ - Iterator Begin() const; - /** - * End iterator - * @returns the ending element - */ - Iterator End() const; - /** - * Copy - * @returns the port range tlv value - */ - PortRangeTlvValue* Copy() const override; - - private: - std::vector* m_portRange; ///< port range -}; - -// ============================================================================== -/** - * @ingroup wimax - * @brief ProtocolTlvValue class - */ -class ProtocolTlvValue : public TlvValue -{ - public: - ProtocolTlvValue(); - ~ProtocolTlvValue() override; - /// Iterator typedef - typedef std::vector::const_iterator Iterator; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength) override; - /** - * Add protocol number - * @param protocol the protocol number - */ - void Add(uint8_t protocol); - /** - * Begin iterator - * @returns the beginning element - */ - Iterator Begin() const; - /** - * End iterator - * @return the ending element - */ - Iterator End() const; - /** - * Copy - * @returns the protocol tlv value - */ - ProtocolTlvValue* Copy() const override; - - private: - std::vector* m_protocol; ///< protocol -}; - -// ============================================================================== - -/** - * @ingroup wimax - * @brief Ipv4AddressTlvValue class - */ -class Ipv4AddressTlvValue : public TlvValue -{ - public: - /// Ipv4Addr structure - struct Ipv4Addr - { - Ipv4Address Address; ///< address - Ipv4Mask Mask; ///< mask - }; - - /// IPv4 address vector iterator typedef - typedef std::vector::const_iterator Iterator; - Ipv4AddressTlvValue(); - ~Ipv4AddressTlvValue() override; - uint32_t GetSerializedSize() const override; - void Serialize(Buffer::Iterator start) const override; - uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength) override; - /** - * Add IPv4 address and mask - * @param address the IPv4 address - * @param mask the IPv4 mask - */ - void Add(Ipv4Address address, Ipv4Mask mask); - /** - * Begin iterator - * @returns the beginning element - */ - Iterator Begin() const; - /** - * End iterator - * @returns the ending element - */ - Iterator End() const; - Ipv4AddressTlvValue* Copy() const override; - - private: - std::vector* m_ipv4Addr; ///< ipv4 addr -}; - -} // namespace ns3 - -#endif /* WIMAX_TLV_H */ diff --git a/src/wimax/test/examples-to-run.py b/src/wimax/test/examples-to-run.py deleted file mode 100644 index 6fdfa782e..000000000 --- a/src/wimax/test/examples-to-run.py +++ /dev/null @@ -1,21 +0,0 @@ -#! /usr/bin/env python3 - -# A list of C++ examples to run in order to ensure that they remain -# buildable and runnable over time. Each tuple in the list contains -# -# (example_name, do_run, do_valgrind_run). -# -# See test.py for more information. -cpp_examples = [ - ("wimax-simple", "True", "True"), - ("wimax-ipv4", "True", "True"), - ("wimax-multicast", "True", "True"), -] - -# A list of Python examples to run in order to ensure that they remain -# runnable over time. Each tuple in the list contains -# -# (example_name, do_run). -# -# See test.py for more information. -python_examples = [] diff --git a/src/wimax/test/mac-messages-test.cc b/src/wimax/test/mac-messages-test.cc deleted file mode 100644 index be32abebd..000000000 --- a/src/wimax/test/mac-messages-test.cc +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - * - */ -#include "ns3/mac-messages.h" -#include "ns3/service-flow.h" -#include "ns3/test.h" - -using namespace ns3; - -/** - * @ingroup wimax - * @defgroup wimax-test wimax module tests - */ - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Test the DSA request message. - */ -class DsaRequestTestCase : public TestCase -{ - public: - DsaRequestTestCase(); - ~DsaRequestTestCase() override; - - private: - void DoRun() override; -}; - -DsaRequestTestCase::DsaRequestTestCase() - : TestCase("Test the DSA request messages") -{ -} - -DsaRequestTestCase::~DsaRequestTestCase() -{ -} - -void -DsaRequestTestCase::DoRun() -{ - IpcsClassifierRecord classifier = IpcsClassifierRecord(); - CsParameters csParam(CsParameters::ADD, classifier); - ServiceFlow sf = ServiceFlow(ServiceFlow::SF_DIRECTION_DOWN); - - sf.SetSfid(100); - sf.SetConvergenceSublayerParam(csParam); - sf.SetCsSpecification(ServiceFlow::IPV4); - sf.SetServiceSchedulingType(ServiceFlow::SF_TYPE_UGS); - sf.SetMaxSustainedTrafficRate(1000000); - sf.SetMinReservedTrafficRate(1000000); - sf.SetMinTolerableTrafficRate(1000000); - sf.SetMaximumLatency(10); - sf.SetMaxTrafficBurst(1000); - sf.SetTrafficPriority(1); - - DsaReq dsaReq(sf); - Ptr packet = Create(); - packet->AddHeader(dsaReq); - - DsaReq dsaReqRecv; - packet->RemoveHeader(dsaReqRecv); - - ServiceFlow sfRecv = dsaReqRecv.GetServiceFlow(); - - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetDirection(), - ServiceFlow::SF_DIRECTION_DOWN, - "The sfRecv had the wrong direction."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetSfid(), 100, "The sfRecv had the wrong sfid."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetCsSpecification(), - ServiceFlow::IPV4, - "The sfRecv had the wrong cs specification."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetServiceSchedulingType(), - ServiceFlow::SF_TYPE_UGS, - "The sfRecv had the wrong service scheduling type."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMaxSustainedTrafficRate(), - 1000000, - "The sfRecv had the wrong maximum sustained traffic rate."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMinReservedTrafficRate(), - 1000000, - "The sfRecv had the wrong minimum reserved traffic rate."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMinTolerableTrafficRate(), - 1000000, - "The sfRecv had the wrong minimum tolerable traffic rate."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMaximumLatency(), - 10, - "The sfRecv had the wrong maximum latency."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMaxTrafficBurst(), - 1000, - "The sfRecv had the wrong maximum traffic burst."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetTrafficPriority(), - 1, - "The sfRecv had the wrong traffic priority."); -} - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Ns3 Wimax Mac Messages Test Suite - */ -class Ns3WimaxMacMessagesTestSuite : public TestSuite -{ - public: - Ns3WimaxMacMessagesTestSuite(); -}; - -Ns3WimaxMacMessagesTestSuite::Ns3WimaxMacMessagesTestSuite() - : TestSuite("wimax-mac-messages", Type::UNIT) -{ - AddTestCase(new DsaRequestTestCase, TestCase::Duration::QUICK); -} - -static Ns3WimaxMacMessagesTestSuite ns3WimaxMacMessagesTestSuite; ///< the test suite diff --git a/src/wimax/test/phy-test.cc b/src/wimax/test/phy-test.cc deleted file mode 100644 index 1dfbf2e2d..000000000 --- a/src/wimax/test/phy-test.cc +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ -#include "ns3/log.h" -#include "ns3/net-device-container.h" -#include "ns3/node-container.h" -#include "ns3/simulator.h" -#include "ns3/snr-to-block-error-rate-manager.h" -#include "ns3/test.h" -#include "ns3/wimax-helper.h" - -using namespace ns3; - -NS_LOG_COMPONENT_DEFINE("WimaxPhyTest"); - -/* - * Configure a network with 3 SS and 1 BS - * Install a SIMPLE OFDM PHY layer on all nodes and check that all SSs - * could register with the BS - * - */ - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Ns3 Wimax Simple OFDM Test Case - */ -class Ns3WimaxSimpleOFDMTestCase : public TestCase -{ - public: - Ns3WimaxSimpleOFDMTestCase(); - ~Ns3WimaxSimpleOFDMTestCase() override; - - private: - void DoRun() override; - /** - * Run once function - * @param FrameDuration the frame duration - * @returns true if successful - */ - bool DoRunOnce(double FrameDuration); -}; - -Ns3WimaxSimpleOFDMTestCase::Ns3WimaxSimpleOFDMTestCase() - : TestCase("Test the Phy model with different frame durations") -{ -} - -Ns3WimaxSimpleOFDMTestCase::~Ns3WimaxSimpleOFDMTestCase() -{ -} - -bool -Ns3WimaxSimpleOFDMTestCase::DoRunOnce(double FrameDuration) -{ - WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - NodeContainer ssNodes; - NodeContainer bsNodes; - ssNodes.Create(3); - bsNodes.Create(1); - - WimaxHelper wimax; - - NetDeviceContainer ssDevs; - NetDeviceContainer bsDevs; - - ssDevs = wimax.Install(ssNodes, - WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler, - FrameDuration); - bsDevs = wimax.Install(bsNodes, - WimaxHelper::DEVICE_TYPE_BASE_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler, - FrameDuration); - - Simulator::Stop(Seconds(1)); - Simulator::Run(); - for (int i = 0; i < 3; i++) - { - if (!ssDevs.Get(i)->GetObject()->IsRegistered()) - { - NS_LOG_DEBUG("SS[" << i << "] not registered"); - return true; // Test fail because SS[i] is not registered - } - } - Simulator::Destroy(); - return false; // Test was ok, all the SSs are registered -} - -void -Ns3WimaxSimpleOFDMTestCase::DoRun() -{ - double frameDuratioTab[7] = {0.0025, 0.004, 0.005, 0.008, 0.01, 0.0125, 0.02}; - for (int i = 0; i < 7; i++) - { - NS_LOG_DEBUG("Frame Duration = " << frameDuratioTab[i]); - if (DoRunOnce(frameDuratioTab[i])) - { - return; - } - } -} - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Test the SNr tom block error rate module - */ -class Ns3WimaxSNRtoBLERTestCase : public TestCase -{ - public: - Ns3WimaxSNRtoBLERTestCase(); - ~Ns3WimaxSNRtoBLERTestCase() override; - - private: - void DoRun() override; - /** - * Run once function - * @param modulationType the modulation type - * @returns true if successful - */ - bool DoRunOnce(uint8_t modulationType); -}; - -Ns3WimaxSNRtoBLERTestCase::Ns3WimaxSNRtoBLERTestCase() - : TestCase("Test the SNR to block error rate module") -{ -} - -Ns3WimaxSNRtoBLERTestCase::~Ns3WimaxSNRtoBLERTestCase() -{ -} - -bool -Ns3WimaxSNRtoBLERTestCase::DoRunOnce(uint8_t modulationType) -{ - SNRToBlockErrorRateManager l_SNRToBlockErrorRateManager; - l_SNRToBlockErrorRateManager.LoadTraces(); - SNRToBlockErrorRateRecord* BLERRec; - - for (double i = -5; i < 40; i += 0.1) - { - BLERRec = l_SNRToBlockErrorRateManager.GetSNRToBlockErrorRateRecord(i, modulationType); - delete BLERRec; - } - return false; -} - -void -Ns3WimaxSNRtoBLERTestCase::DoRun() -{ - for (int i = 0; i < 7; i++) - { - DoRunOnce(i); - } -} - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief The test suite - */ -class Ns3WimaxPhyTestSuite : public TestSuite -{ - public: - Ns3WimaxPhyTestSuite(); -}; - -Ns3WimaxPhyTestSuite::Ns3WimaxPhyTestSuite() - : TestSuite("wimax-phy-layer", Type::UNIT) -{ - AddTestCase(new Ns3WimaxSNRtoBLERTestCase, TestCase::Duration::QUICK); - AddTestCase(new Ns3WimaxSimpleOFDMTestCase, TestCase::Duration::QUICK); -} - -static Ns3WimaxPhyTestSuite ns3WimaxPhyTestSuite; ///< the test suite diff --git a/src/wimax/test/qos-test.cc b/src/wimax/test/qos-test.cc deleted file mode 100644 index c0b558912..000000000 --- a/src/wimax/test/qos-test.cc +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ -#include "ns3/internet-stack-helper.h" -#include "ns3/ipcs-classifier-record.h" -#include "ns3/ipv4-address-helper.h" -#include "ns3/ipv4-address.h" -#include "ns3/ipv4-interface-container.h" -#include "ns3/log.h" -#include "ns3/net-device-container.h" -#include "ns3/node-container.h" -#include "ns3/service-flow.h" -#include "ns3/simulator.h" -#include "ns3/test.h" -#include "ns3/wimax-helper.h" - -using namespace ns3; - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Ns3 Wimax Scheduling Test Case - */ -class Ns3WimaxSchedulingTestCase : public TestCase -{ - public: - Ns3WimaxSchedulingTestCase(); - ~Ns3WimaxSchedulingTestCase() override; - - private: - void DoRun() override; - /** - * Run once function - * @param scheduler the wimax scheduler type - * @returns true if successful - */ - bool DoRunOnce(WimaxHelper::SchedulerType scheduler); -}; - -Ns3WimaxSchedulingTestCase::Ns3WimaxSchedulingTestCase() - : TestCase("Test the 2 different schedulers") -{ -} - -Ns3WimaxSchedulingTestCase::~Ns3WimaxSchedulingTestCase() -{ -} - -bool -Ns3WimaxSchedulingTestCase::DoRunOnce(WimaxHelper::SchedulerType scheduler) -{ - NodeContainer ssNodes; - NodeContainer bsNodes; - ssNodes.Create(2); - bsNodes.Create(1); - WimaxHelper wimax; - NetDeviceContainer ssDevs; - NetDeviceContainer bsDevs; - ssDevs = wimax.Install(ssNodes, - WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - bsDevs = wimax.Install(bsNodes, - WimaxHelper::DEVICE_TYPE_BASE_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - ssDevs.Get(0)->GetObject()->SetModulationType( - WimaxPhy::MODULATION_TYPE_QAM16_12); - ssDevs.Get(1)->GetObject()->SetModulationType( - WimaxPhy::MODULATION_TYPE_QAM16_12); - - InternetStackHelper stack; - stack.Install(bsNodes); - stack.Install(ssNodes); - - Ipv4AddressHelper address; - address.SetBase("10.1.1.0", "255.255.255.0"); - - Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs); - Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs); - - /*------------------------------*/ - // UdpServerHelper udpServer; - // ApplicationContainer serverApps; - // UdpClientHelper udpClient; - // ApplicationContainer clientApps; - // - // udpServer = UdpServerHelper (100); - // serverApps = udpServer.Install (ssNodes.Get (0)); - // serverApps.Start (Seconds (1)); - // serverApps.Stop (Seconds (2)); - // - // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100); - // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200)); - // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12))); - // udpClient.SetAttribute ("PacketSize", UintegerValue (1024)); - // clientApps = udpClient.Install (ssNodes.Get (1)); - // clientApps.Start (Seconds (1)); - // clientApps.Stop (Seconds (2)); - - Simulator::Stop(Seconds(2 + 0.1)); - - IpcsClassifierRecord DlClassifierUgs(Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - SSinterfaces.GetAddress(0), - Ipv4Mask("255.255.255.255"), - 0, - 65000, - 100, - 100, - 17, - 1); - ServiceFlow DlServiceFlowUgs = wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_DOWN, - ServiceFlow::SF_TYPE_RTPS, - DlClassifierUgs); - IpcsClassifierRecord UlClassifierUgs(SSinterfaces.GetAddress(1), - Ipv4Mask("255.255.255.255"), - Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - 0, - 65000, - 100, - 100, - 17, - 1); - ServiceFlow UlServiceFlowUgs = wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_UP, - ServiceFlow::SF_TYPE_RTPS, - UlClassifierUgs); - ssDevs.Get(0)->GetObject()->AddServiceFlow(DlServiceFlowUgs); - ssDevs.Get(1)->GetObject()->AddServiceFlow(UlServiceFlowUgs); - - Simulator::Run(); - Simulator::Destroy(); - return false; -} - -void -Ns3WimaxSchedulingTestCase::DoRun() -{ - if (DoRunOnce(WimaxHelper::SCHED_TYPE_SIMPLE)) - { - return; - } - if (DoRunOnce(WimaxHelper::SCHED_TYPE_RTPS)) - { - return; - } -} - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Ns3 Wimax SF Type Test Case - */ -class Ns3WimaxSFTypeTestCase : public TestCase -{ - public: - Ns3WimaxSFTypeTestCase(); - ~Ns3WimaxSFTypeTestCase() override; - - private: - void DoRun() override; - /** - * Run once function - * @param schedulingType the scheduling type - * @returns true if successful - */ - bool DoRunOnce(ServiceFlow::SchedulingType schedulingType); -}; - -Ns3WimaxSFTypeTestCase::Ns3WimaxSFTypeTestCase() - : TestCase("Test the service flow scheduling types") -{ -} - -Ns3WimaxSFTypeTestCase::~Ns3WimaxSFTypeTestCase() -{ -} - -bool -Ns3WimaxSFTypeTestCase::DoRunOnce(ServiceFlow::SchedulingType schedulingType) -{ - NodeContainer ssNodes; - NodeContainer bsNodes; - ssNodes.Create(2); - bsNodes.Create(1); - WimaxHelper wimax; - NetDeviceContainer ssDevs; - NetDeviceContainer bsDevs; - ssDevs = wimax.Install(ssNodes, - WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - WimaxHelper::SCHED_TYPE_SIMPLE); - bsDevs = wimax.Install(bsNodes, - WimaxHelper::DEVICE_TYPE_BASE_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - WimaxHelper::SCHED_TYPE_SIMPLE); - ssDevs.Get(0)->GetObject()->SetModulationType( - WimaxPhy::MODULATION_TYPE_QAM16_12); - ssDevs.Get(1)->GetObject()->SetModulationType( - WimaxPhy::MODULATION_TYPE_QAM16_12); - - InternetStackHelper stack; - stack.Install(bsNodes); - stack.Install(ssNodes); - - Ipv4AddressHelper address; - address.SetBase("10.1.1.0", "255.255.255.0"); - - Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs); - Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs); - - /*------------------------------*/ - // UdpServerHelper udpServer; - // ApplicationContainer serverApps; - // UdpClientHelper udpClient; - // ApplicationContainer clientApps; - // - // udpServer = UdpServerHelper (100); - // serverApps = udpServer.Install (ssNodes.Get (0)); - // serverApps.Start (Seconds (1)); - // serverApps.Stop (Seconds (2)); - // - // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100); - // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200)); - // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12))); - // udpClient.SetAttribute ("PacketSize", UintegerValue (1024)); - // clientApps = udpClient.Install (ssNodes.Get (1)); - // clientApps.Start (Seconds (1)); - // clientApps.Stop (Seconds (2)); - - Simulator::Stop(Seconds(2 + 0.1)); - - IpcsClassifierRecord DlClassifier(Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - SSinterfaces.GetAddress(0), - Ipv4Mask("255.255.255.255"), - 0, - 65000, - 100, - 100, - 17, - 1); - ServiceFlow DlServiceFlow = - wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_DOWN, schedulingType, DlClassifier); - IpcsClassifierRecord UlClassifier(SSinterfaces.GetAddress(1), - Ipv4Mask("255.255.255.255"), - Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - 0, - 65000, - 100, - 100, - 17, - 1); - ServiceFlow UlServiceFlow = - wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_UP, schedulingType, UlClassifier); - ssDevs.Get(0)->GetObject()->AddServiceFlow(DlServiceFlow); - ssDevs.Get(1)->GetObject()->AddServiceFlow(UlServiceFlow); - - Simulator::Run(); - Simulator::Destroy(); - return false; -} - -void -Ns3WimaxSFTypeTestCase::DoRun() -{ - if (DoRunOnce(ServiceFlow::SF_TYPE_UGS)) - { - return; - } - if (DoRunOnce(ServiceFlow::SF_TYPE_RTPS)) - { - return; - } - if (DoRunOnce(ServiceFlow::SF_TYPE_BE)) - { - return; - } -} - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Ns3 Wimax QoS Test Suite - */ -class Ns3WimaxQoSTestSuite : public TestSuite -{ - public: - Ns3WimaxQoSTestSuite(); -}; - -Ns3WimaxQoSTestSuite::Ns3WimaxQoSTestSuite() - : TestSuite("wimax-qos", Type::SYSTEM) -{ - AddTestCase(new Ns3WimaxSFTypeTestCase, TestCase::Duration::QUICK); - AddTestCase(new Ns3WimaxSchedulingTestCase, TestCase::Duration::QUICK); -} - -static Ns3WimaxQoSTestSuite ns3WimaxQoSTestSuite; ///< the test suite diff --git a/src/wimax/test/ss-mac-test.cc b/src/wimax/test/ss-mac-test.cc deleted file mode 100644 index 9460fbe99..000000000 --- a/src/wimax/test/ss-mac-test.cc +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2007,2008, 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Author: Mohamed Amine Ismail - * - */ -#include "ns3/log.h" -#include "ns3/net-device-container.h" -#include "ns3/node-container.h" -#include "ns3/simulator.h" -#include "ns3/test.h" -#include "ns3/wimax-helper.h" - -using namespace ns3; - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Test the network entry procedure. - * Create a network with a BS and 10 SS and check that all the SS perform the - * network entry correctly - * - */ -class Ns3WimaxNetworkEntryTestCase : public TestCase -{ - public: - Ns3WimaxNetworkEntryTestCase(); - ~Ns3WimaxNetworkEntryTestCase() override; - - private: - void DoRun() override; -}; - -Ns3WimaxNetworkEntryTestCase::Ns3WimaxNetworkEntryTestCase() - : TestCase("Test the network entry procedure") -{ -} - -Ns3WimaxNetworkEntryTestCase::~Ns3WimaxNetworkEntryTestCase() -{ -} - -void -Ns3WimaxNetworkEntryTestCase::DoRun() -{ - WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - NodeContainer ssNodes; - NodeContainer bsNodes; - - ssNodes.Create(10); - bsNodes.Create(1); - - WimaxHelper wimax; - - NetDeviceContainer ssDevs; - NetDeviceContainer bsDevs; - - ssDevs = wimax.Install(ssNodes, - WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - bsDevs = wimax.Install(bsNodes, - WimaxHelper::DEVICE_TYPE_BASE_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - Simulator::Stop(Seconds(1)); - Simulator::Run(); - for (int i = 0; i < 10; i++) - { - NS_TEST_EXPECT_MSG_EQ( - ssDevs.Get(i)->GetObject()->IsRegistered(), - true, - "SS[" << i << "] IsNotRegistered"); - } - Simulator::Destroy(); -} - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Test if the management connections are correctly setup. - * Create a network with a BS and 10 SS and check that the management - * connections are correctly setup for all SS - * - */ -class Ns3WimaxManagementConnectionsTestCase : public TestCase -{ - public: - Ns3WimaxManagementConnectionsTestCase(); - ~Ns3WimaxManagementConnectionsTestCase() override; - - private: - void DoRun() override; -}; - -Ns3WimaxManagementConnectionsTestCase::Ns3WimaxManagementConnectionsTestCase() - : TestCase("Test if the management connections are correctly setup") -{ -} - -Ns3WimaxManagementConnectionsTestCase::~Ns3WimaxManagementConnectionsTestCase() -{ -} - -void -Ns3WimaxManagementConnectionsTestCase::DoRun() -{ - WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - NodeContainer ssNodes; - NodeContainer bsNodes; - - ssNodes.Create(10); - bsNodes.Create(1); - - WimaxHelper wimax; - - NetDeviceContainer ssDevs; - NetDeviceContainer bsDevs; - - ssDevs = wimax.Install(ssNodes, - WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - bsDevs = wimax.Install(bsNodes, - WimaxHelper::DEVICE_TYPE_BASE_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - Simulator::Stop(Seconds(1)); - Simulator::Run(); - for (int i = 0; i < 10; i++) - { - NS_TEST_EXPECT_MSG_EQ(ssDevs.Get(i) - ->GetObject() - ->GetAreManagementConnectionsAllocated(), - true, - "Management connections for SS[" << i << "] are not allocated"); - } - Simulator::Destroy(); -} - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Ns3 Wimax SS Mac Test Suite - */ -class Ns3WimaxSSMacTestSuite : public TestSuite -{ - public: - Ns3WimaxSSMacTestSuite(); -}; - -Ns3WimaxSSMacTestSuite::Ns3WimaxSSMacTestSuite() - : TestSuite("wimax-ss-mac-layer", Type::UNIT) -{ - AddTestCase(new Ns3WimaxNetworkEntryTestCase, TestCase::Duration::QUICK); - AddTestCase(new Ns3WimaxManagementConnectionsTestCase, TestCase::Duration::QUICK); -} - -static Ns3WimaxSSMacTestSuite ns3WimaxSSMacTestSuite; ///< the test suite diff --git a/src/wimax/test/wimax-fragmentation-test.cc b/src/wimax/test/wimax-fragmentation-test.cc deleted file mode 100644 index a9a9b99aa..000000000 --- a/src/wimax/test/wimax-fragmentation-test.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2009-2010 TELEMATICS LAB - Poliotecnico di Bari - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Giuseppe Piro - * - */ -#include "ns3/cid.h" -#include "ns3/log.h" -#include "ns3/mac-messages.h" -#include "ns3/packet.h" -#include "ns3/ptr.h" -#include "ns3/simulator.h" -#include "ns3/test.h" -#include "ns3/wimax-connection.h" -#include "ns3/wimax-mac-header.h" - -using namespace ns3; - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Test the wimax packet fragmentation. - */ -class Ns3WimaxFragmentationTestCase : public TestCase -{ - public: - Ns3WimaxFragmentationTestCase(); - ~Ns3WimaxFragmentationTestCase() override; - - private: - void DoRun() override; -}; - -Ns3WimaxFragmentationTestCase::Ns3WimaxFragmentationTestCase() - : TestCase("Test the packet fragmentation and defragmentation.") -{ -} - -Ns3WimaxFragmentationTestCase::~Ns3WimaxFragmentationTestCase() -{ -} - -void -Ns3WimaxFragmentationTestCase::DoRun() -{ - GenericMacHeader gnrcMacHdr; - ManagementMessageType msgType; - FragmentationSubheader fragSubhdr; - GenericMacHeader hdr; - - Cid cid; - auto connectionTx = new WimaxConnection(cid, Cid::TRANSPORT); - auto connectionRx = new WimaxConnection(cid, Cid::TRANSPORT); - - // A Packet of 1000 bytes has been created. - // It will be fragmentated into 4 fragments and then defragmentated into fullPacket. - Ptr packet = Create(1000); - Ptr fragment; - Ptr fullPacket = Create(); - - // Enqueued packet - hdr.SetLen(packet->GetSize() + hdr.GetSerializedSize()); - hdr.SetCid(connectionTx->GetCid()); - MacHeaderType::HeaderType packetType = MacHeaderType::HEADER_TYPE_GENERIC; - - connectionTx->Enqueue(packet, packetType, hdr); - - uint32_t availableByteForFragment = 280; - for (int i = 0; i < 4; i++) - { - // dequeue a fragment - if (connectionTx->GetQueue()->GetFirstPacketRequiredByte(packetType) > - availableByteForFragment) - { - fragment = connectionTx->Dequeue(packetType, availableByteForFragment); - } - else - { - fragment = connectionTx->Dequeue(packetType); - } - // *** send packet -----> receive packet ----** - - // check if receive packet is a fragment - fragment->RemoveHeader(gnrcMacHdr); - uint8_t type = gnrcMacHdr.GetType(); - if (type) - { - // Check if there is a fragmentation Subheader - NS_TEST_EXPECT_MSG_EQ(((type >> 2) & 1), 1, "The packet is not a fragment"); - } - - // remove header from the received fragment - fragment->RemoveHeader(fragSubhdr); - uint32_t fc = fragSubhdr.GetFc(); - - NS_TEST_EXPECT_MSG_EQ((fc == 1 && i != 0), false, "The fragment in not the first one"); - NS_TEST_EXPECT_MSG_EQ((fc == 2 && i != 3), false, "The fragment in not the latest one"); - NS_TEST_EXPECT_MSG_EQ(((fc == 3 && i != 1) && (fc == 3 && i != 2)), - false, - "The fragment in not the middle one"); - - if (fc != 2) - { - // This is the first or middle fragment. - // Take the fragment queue, store the fragment into the queue - connectionRx->FragmentEnqueue(fragment); - } - else - { - // This is the latest fragment. - // Take the fragment queue, defragment a packet and send it to the upper layer - connectionRx->FragmentEnqueue(fragment); - WimaxConnection::FragmentsQueue fragmentsQueue = connectionRx->GetFragmentsQueue(); - - // DEFRAGMENTATION - for (auto iter = fragmentsQueue.begin(); iter != fragmentsQueue.end(); ++iter) - { - // Create the whole Packet - fullPacket->AddAtEnd(*iter); - } - connectionRx->ClearFragmentsQueue(); - - NS_TEST_EXPECT_MSG_EQ(fullPacket->GetSize(), 1000, "The defragmentation is incorrect"); - } - } - delete connectionTx; - delete connectionRx; - Simulator::Destroy(); -} - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Ns3 Wimax Fragmentation Test Suite - */ -class Ns3WimaxFragmentationTestSuite : public TestSuite -{ - public: - Ns3WimaxFragmentationTestSuite(); -}; - -Ns3WimaxFragmentationTestSuite::Ns3WimaxFragmentationTestSuite() - : TestSuite("wimax-fragmentation", Type::UNIT) -{ - AddTestCase(new Ns3WimaxFragmentationTestCase, TestCase::Duration::QUICK); -} - -static Ns3WimaxFragmentationTestSuite ns3WimaxFragmentationTestSuite; ///< the test suite diff --git a/src/wimax/test/wimax-service-flow-test.cc b/src/wimax/test/wimax-service-flow-test.cc deleted file mode 100644 index a0d195022..000000000 --- a/src/wimax/test/wimax-service-flow-test.cc +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - * - * - */ -#include "ns3/cs-parameters.h" -#include "ns3/internet-stack-helper.h" -#include "ns3/ipcs-classifier-record.h" -#include "ns3/ipv4-address-helper.h" -#include "ns3/ipv4-address.h" -#include "ns3/ipv4-interface-container.h" -#include "ns3/service-flow.h" -#include "ns3/simulator.h" -#include "ns3/test.h" -#include "ns3/wimax-helper.h" - -using namespace ns3; - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Test the service flow creation. - */ -class Ns3WimaxSfCreationTestCase : public TestCase -{ - public: - Ns3WimaxSfCreationTestCase(); - ~Ns3WimaxSfCreationTestCase() override; - - private: - void DoRun() override; -}; - -Ns3WimaxSfCreationTestCase::Ns3WimaxSfCreationTestCase() - : TestCase("Test the service flow tlv implementation.") -{ -} - -Ns3WimaxSfCreationTestCase::~Ns3WimaxSfCreationTestCase() -{ -} - -void -Ns3WimaxSfCreationTestCase::DoRun() -{ - // default values - int duration = 2; - WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE; - - NodeContainer ssNodes; - NodeContainer bsNodes; - - ssNodes.Create(1); - bsNodes.Create(1); - - WimaxHelper wimax; - - NetDeviceContainer ssDevs; - NetDeviceContainer bsDevs; - - ssDevs = wimax.Install(ssNodes, - WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - bsDevs = wimax.Install(bsNodes, - WimaxHelper::DEVICE_TYPE_BASE_STATION, - WimaxHelper::SIMPLE_PHY_TYPE_OFDM, - scheduler); - - ssDevs.Get(0)->GetObject()->SetModulationType( - WimaxPhy::MODULATION_TYPE_QAM16_12); - bsDevs.Get(0)->GetObject(); - - InternetStackHelper stack; - stack.Install(bsNodes); - stack.Install(ssNodes); - - Ipv4AddressHelper address; - address.SetBase("10.1.1.0", "255.255.255.0"); - - Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs); - Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs); - - // Create one UGS Downlink service flow between the ss and the bs - auto DlServiceFlowUgs = new ServiceFlow(ServiceFlow::SF_DIRECTION_DOWN); - IpcsClassifierRecord DlClassifierUgs(Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - 3000, - 3000, - 0, - 35000, - 17, - 1); - CsParameters DlcsParam(CsParameters::ADD, DlClassifierUgs); - DlServiceFlowUgs->SetConvergenceSublayerParam(DlcsParam); - DlServiceFlowUgs->SetCsSpecification(ServiceFlow::IPV4); - DlServiceFlowUgs->SetServiceSchedulingType(ServiceFlow::SF_TYPE_UGS); - DlServiceFlowUgs->SetMaxSustainedTrafficRate(1000000); - DlServiceFlowUgs->SetMinReservedTrafficRate(1000000); - DlServiceFlowUgs->SetMinTolerableTrafficRate(1000000); - DlServiceFlowUgs->SetMaximumLatency(10); - DlServiceFlowUgs->SetMaxTrafficBurst(1000); - DlServiceFlowUgs->SetTrafficPriority(1); - - // Create one UGS Uplink service flow between the ss and the bs - auto UlServiceFlowUgs = new ServiceFlow(ServiceFlow::SF_DIRECTION_UP); - IpcsClassifierRecord UlClassifierUgs(Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - Ipv4Address("0.0.0.0"), - Ipv4Mask("0.0.0.0"), - 0, - 35000, - 3000, - 3000, - 17, - 1); - CsParameters UlcsParam(CsParameters::ADD, UlClassifierUgs); - UlServiceFlowUgs->SetConvergenceSublayerParam(UlcsParam); - UlServiceFlowUgs->SetCsSpecification(ServiceFlow::IPV4); - UlServiceFlowUgs->SetServiceSchedulingType(ServiceFlow::SF_TYPE_UGS); - UlServiceFlowUgs->SetMaxSustainedTrafficRate(1000000); - UlServiceFlowUgs->SetMinReservedTrafficRate(1000000); - UlServiceFlowUgs->SetMinTolerableTrafficRate(1000000); - UlServiceFlowUgs->SetMaximumLatency(10); - UlServiceFlowUgs->SetMaxTrafficBurst(1000); - UlServiceFlowUgs->SetTrafficPriority(1); - ssDevs.Get(0)->GetObject()->AddServiceFlow(DlServiceFlowUgs); - ssDevs.Get(0)->GetObject()->AddServiceFlow(UlServiceFlowUgs); - - Simulator::Stop(Seconds(duration)); - Simulator::Run(); - Simulator::Destroy(); -} - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Ns3 Wimax Service Flow Test Suite - */ -class Ns3WimaxServiceFlowTestSuite : public TestSuite -{ - public: - Ns3WimaxServiceFlowTestSuite(); -}; - -Ns3WimaxServiceFlowTestSuite::Ns3WimaxServiceFlowTestSuite() - : TestSuite("wimax-service-flow", Type::UNIT) -{ - AddTestCase(new Ns3WimaxSfCreationTestCase, TestCase::Duration::QUICK); -} - -static Ns3WimaxServiceFlowTestSuite ns3WimaxServiceFlowTestSuite; ///< the test suite diff --git a/src/wimax/test/wimax-tlv-test.cc b/src/wimax/test/wimax-tlv-test.cc deleted file mode 100644 index ce4e3a031..000000000 --- a/src/wimax/test/wimax-tlv-test.cc +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 2009 INRIA, UDcast - * - * SPDX-License-Identifier: GPL-2.0-only - * - * Mohamed Amine Ismail - * - * - */ -#include "ns3/cs-parameters.h" -#include "ns3/ipcs-classifier-record.h" -#include "ns3/log.h" -#include "ns3/packet.h" -#include "ns3/ptr.h" -#include "ns3/service-flow.h" -#include "ns3/test.h" -#include "ns3/wimax-helper.h" -#include "ns3/wimax-tlv.h" - -using namespace ns3; - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Test the wimax tlv implementation. - */ -class Ns3WimaxCsParamTlvTestCase : public TestCase -{ - public: - Ns3WimaxCsParamTlvTestCase(); - ~Ns3WimaxCsParamTlvTestCase() override; - - private: - void DoRun() override; -}; - -Ns3WimaxCsParamTlvTestCase::Ns3WimaxCsParamTlvTestCase() - : TestCase("Test the CS parameters tlv implementation.") -{ -} - -Ns3WimaxCsParamTlvTestCase::~Ns3WimaxCsParamTlvTestCase() -{ -} - -void -Ns3WimaxCsParamTlvTestCase::DoRun() -{ - IpcsClassifierRecord classifier(Ipv4Address("10.0.0.0"), - Ipv4Mask("255.0.0.0"), - Ipv4Address("11.0.0.0"), - Ipv4Mask("255.0.0.0"), - 1000, - 1100, - 3000, - 3100, - 17, - 1); - - classifier.AddSrcAddr(Ipv4Address("1.0.0.0"), Ipv4Mask("255.0.0.0")); - classifier.AddDstAddr(Ipv4Address("16.0.0.0"), Ipv4Mask("255.0.0.0")); - classifier.AddProtocol(6); - classifier.AddSrcPortRange(1, 2); - classifier.AddDstPortRange(4000, 4100); - classifier.SetIndex(1); - - CsParameters csParam(CsParameters::ADD, classifier); - - SfVectorTlvValue sfVectorTlvValue; - sfVectorTlvValue.Add(csParam.ToTlv()); - - Tlv tlvSent(145, sfVectorTlvValue.GetSerializedSize(), sfVectorTlvValue); - Ptr packet = Create(); - packet->AddHeader(tlvSent); - - Tlv tlvReceived; - packet->RemoveHeader(tlvReceived); - if (tlvReceived.GetType() == Tlv::UPLINK_SERVICE_FLOW) - { - auto sfVecValue = (SfVectorTlvValue*)tlvReceived.PeekValue(); - for (auto iter = sfVecValue->Begin(); iter != sfVecValue->End(); ++iter) - { - if ((*iter)->GetType() == SfVectorTlvValue::IPV4_CS_Parameters) - { - CsParameters csParamsRecv(*(*iter)); - IpcsClassifierRecord classifier = csParamsRecv.GetPacketClassifierRule(); - - NS_TEST_ASSERT_MSG_EQ(!classifier.CheckMatch(Ipv4Address("10.1.1.1"), - Ipv4Address("16.1.1.1"), - 1050, - 3050, - 17), - false, - "The classifier address did not match."); - NS_TEST_ASSERT_MSG_EQ(!classifier.CheckMatch(Ipv4Address("10.1.5.1"), - Ipv4Address("11.1.1.23"), - 1070, - 3040, - 6), - false, - "The classifier address did not match."); - NS_TEST_ASSERT_MSG_EQ(classifier.CheckMatch(Ipv4Address("11.1.1.1"), - Ipv4Address("17.1.1.1"), - 1050, - 3050, - 17), - false, - "The classifier addresses matched."); - NS_TEST_ASSERT_MSG_EQ(classifier.CheckMatch(Ipv4Address("10.1.1.1"), - Ipv4Address("16.1.1.1"), - 1050, - 3050, - 8), - false, - "The classifier addresses matched."); - } - } - } -} - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Test the service flow tlv implementation. - */ -class Ns3WimaxSfTlvTestCase : public TestCase -{ - public: - Ns3WimaxSfTlvTestCase(); - ~Ns3WimaxSfTlvTestCase() override; - - private: - void DoRun() override; -}; - -Ns3WimaxSfTlvTestCase::Ns3WimaxSfTlvTestCase() - : TestCase("Test the service flow tlv implementation.") -{ -} - -Ns3WimaxSfTlvTestCase::~Ns3WimaxSfTlvTestCase() -{ -} - -void -Ns3WimaxSfTlvTestCase::DoRun() -{ - IpcsClassifierRecord classifier = IpcsClassifierRecord(); - CsParameters csParam(CsParameters::ADD, classifier); - ServiceFlow sf = ServiceFlow(ServiceFlow::SF_DIRECTION_DOWN); - - sf.SetSfid(100); - sf.SetConvergenceSublayerParam(csParam); - sf.SetCsSpecification(ServiceFlow::IPV4); - sf.SetServiceSchedulingType(ServiceFlow::SF_TYPE_UGS); - sf.SetMaxSustainedTrafficRate(1000000); - sf.SetMinReservedTrafficRate(1000000); - sf.SetMinTolerableTrafficRate(1000000); - sf.SetMaximumLatency(10); - sf.SetMaxTrafficBurst(1000); - sf.SetTrafficPriority(1); - - Ptr packet = Create(); - packet->AddHeader(sf.ToTlv()); - - Tlv tlvReceived; - packet->RemoveHeader(tlvReceived); - - ServiceFlow sfRecv = ServiceFlow(tlvReceived); - - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetDirection(), - ServiceFlow::SF_DIRECTION_DOWN, - "The sfRecv had the wrong direction."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetSfid(), 100, "The sfRecv had the wrong sfid."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetCsSpecification(), - ServiceFlow::IPV4, - "The sfRecv had the wrong cs specification."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetServiceSchedulingType(), - ServiceFlow::SF_TYPE_UGS, - "The sfRecv had the wrong service scheduling type."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMaxSustainedTrafficRate(), - 1000000, - "The sfRecv had the wrong maximum sustained traffic rate."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMinReservedTrafficRate(), - 1000000, - "The sfRecv had the wrong minimum reserved traffic rate."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMinTolerableTrafficRate(), - 1000000, - "The sfRecv had the wrong minimum tolerable traffic rate."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMaximumLatency(), - 10, - "The sfRecv had the wrong maximum latency."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMaxTrafficBurst(), - 1000, - "The sfRecv had the wrong maximum traffic burst."); - NS_TEST_ASSERT_MSG_EQ(sfRecv.GetTrafficPriority(), - 1, - "The sfRecv had the wrong traffic priority."); -} - -/** - * @ingroup wimax-test - * @ingroup tests - * - * @brief Ns3 Wimax Tlv Test Suite - */ -class Ns3WimaxTlvTestSuite : public TestSuite -{ - public: - Ns3WimaxTlvTestSuite(); -}; - -Ns3WimaxTlvTestSuite::Ns3WimaxTlvTestSuite() - : TestSuite("wimax-tlv", Type::UNIT) -{ - AddTestCase(new Ns3WimaxCsParamTlvTestCase, TestCase::Duration::QUICK); - AddTestCase(new Ns3WimaxSfTlvTestCase, TestCase::Duration::QUICK); -} - -static Ns3WimaxTlvTestSuite ns3WimaxTlvTestSuite; ///< the test suite diff --git a/utils/tests/test-ns3.py b/utils/tests/test-ns3.py index b9a13203b..81ca14952 100755 --- a/utils/tests/test-ns3.py +++ b/utils/tests/test-ns3.py @@ -939,7 +939,7 @@ class NS3ConfigureTestCase(NS3BaseTestCase): """ # Try filtering disabled modules to disable lte and modules that depend on it. return_code, stdout, stderr = run_ns3( - "configure -G \"{generator}\" --disable-modules='lte;wimax'" + "configure -G \"{generator}\" --disable-modules='lte;wifi'" ) self.config_ok(return_code, stdout, stderr) @@ -947,7 +947,7 @@ class NS3ConfigureTestCase(NS3BaseTestCase): enabled_modules = get_enabled_modules() self.assertLess(len(enabled_modules), len(self.ns3_modules)) self.assertNotIn("ns3-lte", enabled_modules) - self.assertNotIn("ns3-wimax", enabled_modules) + self.assertNotIn("ns3-wifi", enabled_modules) # Try cleaning the list of enabled modules to reset to the normal configuration. return_code, stdout, stderr = run_ns3("configure -G \"{generator}\" --disable-modules=''") @@ -1127,7 +1127,7 @@ class NS3ConfigureTestCase(NS3BaseTestCase): 'lte', #comment2, #comment3 - 'network', 'internet','wimax'""", + 'network', 'internet','wifi'""", examples="True", tests="True", ) @@ -1135,7 +1135,7 @@ class NS3ConfigureTestCase(NS3BaseTestCase): else: f.write( ns3rc_template.format( - modules="'core', 'lte', 'network', 'internet', 'wimax'", + modules="'core', 'lte', 'network', 'internet', 'wifi'", examples="True", tests="True", ) @@ -1150,7 +1150,7 @@ class NS3ConfigureTestCase(NS3BaseTestCase): self.assertIn("ns3-core", enabled_modules) self.assertIn("ns3-internet", enabled_modules) self.assertIn("ns3-lte", enabled_modules) - self.assertIn("ns3-wimax", enabled_modules) + self.assertIn("ns3-wifi", enabled_modules) self.assertTrue(get_test_enabled()) self.assertGreater(len(get_programs_list()), len(self.ns3_executables))