diff --git a/.clang-tidy b/.clang-tidy index 1a72f0934..924c8086e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -18,10 +18,14 @@ Checks: > modernize-make-shared, modernize-make-unique, modernize-redundant-void-arg, + modernize-type-traits, + modernize-use-auto, + modernize-use-bool-literals, modernize-use-emplace, modernize-use-equals-delete, modernize-use-nullptr, modernize-use-override, + modernize-use-transparent-functors, performance-faster-string-find, performance-for-range-copy, performance-implicit-conversion-in-loop, diff --git a/.gitignore b/.gitignore index 24c5af167..46a4022ed 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ cmake-build-debug/ cmake-build-relwithdebinfo/ cmake-build-minsizerel/ cmake-build-release/ +vcpkg/ .vs/ diff --git a/AUTHORS b/AUTHORS index 718f2ec46..eb103c65e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -164,6 +164,7 @@ Sandra Lagen (sandra.lagen@cttc.es) Emmanuelle Laprise (emmmanuelle.laprise@bluekazoo.ca) Harsh Lara (harshapplefan@gmail.com) Mattia Lecci (mattia.lecci@gmail.com) +Ben Lee (limjcst@163.com) Robin Lee (xinyashuai1987@163.com) Juan Leon (juanvleonr@gmail.com) Kristijan Lenković (k.lenkovic@me.com) diff --git a/CHANGES.md b/CHANGES.md index a56da96e1..6b7dcd88b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,36 @@ Note that users who upgrade the simulator across versions, or who work directly This file is a best-effort approach to solving this issue; we will do our best but can guarantee that there will be things that fall through the cracks, unfortunately. If you, as a user, can suggest improvements to this file based on your experience, please contribute a patch or drop us a note on ns-developers mailing list. +Changes from ns-3.39 to ns-3.40 +------------------------------- + +### New API + +* (energy) Added `GenericBatteryModel` to the energy module with working examples, and support for battery presets and cell packs. +* (lr-wpan) Added the functions to set or get the capability field via bitmap (a 8 bit int). +* (lr-wpan) Added the possibility to obtain the LQI from a received `MlmeAssociateIndicationParams`. +* (wifi) Added new helper methods to SpectrumWifiPhyHelper to allow flexible configuration for the mapping between spectrum PHY interfaces and PHY instances. +* (wifi) Added new trace sources to `WifiPhy`: **OperatingChannelChange**, which is fired when the operating channel of a PHY is changed. +* (wifi) The attribute `WifiPhy::Antennas` is extended to support up to 8 antennas. + +### Changes to existing API + +* (core) Removed private class `EmpiricalRandomVariable::ValueCDF` in favor of `std::map`. +* (lr-wpan) Removed unnecessary bcst filter from `LrWpanMac::PdDataIndication` which also blocked the correct reception of beacon request commands. +* (wifi) The attribute `WifiPhy::Antennas` is extended to support up to 8 antennas. +* (wifi) `StaWifiMac::MacState` enum is now public, and `WifiMacHeader` can be subclassed + +### Changes to build system + +* Added support for Vcpkg and CPM package managers + +### Changed behavior + +* (core) `EmpiricalRandomVariable` CDF pairs can now be added in any order. +* (core) `EmpiricalRandomVariable` no longer requires that a CDF pair with a range value exactly equal to 1.0 be added (see issue #922). +* (wifi) Upon ML setup, a non-AP MLD updates the IDs of the setup links to match the IDs used by the AP MLD. +* (wifi) Attribute **TrackSignalsFromInactiveInterfaces** in SpectrumWifiPhy has been defaulted to be enabled. + Changes from ns-3.38 to ns-3.39 ------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index 896162929..442cf883b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ option(NS3_NETANIM "Build netanim" OFF) # other options option(NS3_ENABLE_BUILD_VERSION "Embed version info into libraries" OFF) option(NS3_CCACHE "Use Ccache to speed up recompilation" ON) +option(NS3_CPM "Enable the CPM C++ library manager support" OFF) option(NS3_FAST_LINKERS "Use Mold or LLD to speed up linking if available" ON) option(NS3_FETCH_OPTIONAL_COMPONENTS "Fetch Brite, Click and Openflow dependencies" OFF @@ -83,6 +84,7 @@ option(NS3_EIGEN "Build with Eigen support" ON) option(NS3_STATIC "Build a static ns-3 library and link it against executables" OFF ) +option(NS3_VCPKG "Enable the Vcpkg C++ library manager support" OFF) option(NS3_VERBOSE "Print additional build system messages" OFF) option(NS3_VISUALIZER "Build visualizer module" ON) option(NS3_WARNINGS "Enable compiler warnings" ON) diff --git a/README.md b/README.md index 0501e5ec5..ea8bc56b7 100644 --- a/README.md +++ b/README.md @@ -238,4 +238,4 @@ Below are some links that may also be helpful to you: - [ns-3 Tutorial](https://www.nsnam.org/docs/tutorial/html/index.html) - [ns-3 Model Library](https://www.nsnam.org/docs/models/html/index.html) -- [ns-3 Manual](https://www.nsnam.org/docs/manual/html/index.html) \ No newline at end of file +- [ns-3 Manual](https://www.nsnam.org/docs/manual/html/index.html) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e046153aa..5e60a81c3 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -13,6 +13,55 @@ a [GitLab.com issue tracker](https://gitlab.com/nsnam/ns-3-dev/-/issues) number, and references prefixed by '!' refer to a [GitLab.com merge request](https://gitlab.com/nsnam/ns-3-dev/-/merge_requests) number. +Release 3.40 +------------ + +### Availability + +This release is available from: + + +### Supported platforms + +This release is intended to work on systems with the following minimal +requirements (Note: not all ns-3 features are available on all systems): + +- g++-9 or later, or LLVM/clang++-10 or later +- Python 3.6 or later +- CMake 3.10 or later +- (macOS only) Xcode 11 or later +- (Windows only) Msys2/MinGW64 toolchain or WSL2 + +Python API requires [Cppyy](https://cppyy.readthedocs.io/en/latest/installation.html) and works for Linux only. Specifically, avoid Cppyy version 3; stay with version 2.4.2 for this release. + +### New user-visible features + +- (core) !1586 - `EmpiricalRandomVariable` CDF pairs can now be added in any order. +- (energy) !1329 - Extensions to battery discharge module +- (lr-wpan) !1604 - Add CapabilityField bitmap functions +- (lr-wpan) !1645 - Add LQI to MlmeAssociateIndicationParams +- (wifi) Added support for 802.11be TID-to-Link Mapping +- (wifi) Added a new trace source to WifiPhy to indicate operating channel change +- (wifi) Improved support for multiple spectrum PHY interfaces +- (wifi) Added initial support for MU-MIMO (ideal PHY layer only) + +### Bugs fixed + +- (antenna) #889 - Improve `WrapTo*` functions +- (core) #922 - `EmpiricalRandomVariable` no longer requires that a CDF pair with a range value exactly equal to 1.0 be added. +- (core) #949 - Fix bound callbacks arguments type detection +- (internet) #956 - Avoid sending RS when link goes down +- (lr-wpan) !1591 - Removed unnecessary Bcst filter from MAC +- (lr-wpan) #944 - Fix for-loop in PrintTxQueue(s) functions +- (lr-wpan) - Fix incorrect return parameter in the MAC MlmeAssociateConfirm +- (mobility) #943 - Fix node direction change when node is in a corner +- (wifi) - Reset MU PPDU UID to prevent STA from receiving the TB PPDU sent by another STA +- (wifi) - Fix max value for UL MCS field of User Info fields (depends on TF variant) +- (wifi) - Update TXOP bandwidth upon every transmission +- (wifi) - Fix flush operation on WifiMacQueues +- (wifi) #942 - Trace expired MPDUs before removing them from the queue to avoid blocking the recipient buffer +- (wifi) - Fix wrong condition preventing PHY from aborting RX when starting TX + Release 3.39 ------------ diff --git a/VERSION b/VERSION index d9fcf0a6a..a2b1f5109 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.39 +3.40 diff --git a/build-support/custom-modules/ns3-cmake-package.cmake b/build-support/custom-modules/ns3-cmake-package.cmake index ecc2e045f..e441281d7 100644 --- a/build-support/custom-modules/ns3-cmake-package.cmake +++ b/build-support/custom-modules/ns3-cmake-package.cmake @@ -29,7 +29,7 @@ function(build_required_and_libs_lists module_name visibility libraries ) set(lib_real_name "-l${lib_real_name}") else() - if(IS_ABSOLUTE ${lib}) + if((IS_ABSOLUTE "${lib}") OR ("${lib}" MATCHES "^-l")) set(lib_real_name ${lib}) else() set(lib_real_name "-l${lib}") @@ -88,6 +88,9 @@ function(pkgconfig_module libname) string(REPLACE ";-I" " -I" pkgconfig_interface_include_directories "${pkgconfig_interface_include_directories}" ) + string(REPLACE ";" "" pkgconfig_interface_include_directories + "${pkgconfig_interface_include_directories}" + ) endif() # Configure pkgconfig file for the module using pkgconfig variables diff --git a/build-support/custom-modules/ns3-configtable.cmake b/build-support/custom-modules/ns3-configtable.cmake index 9f77f9b3e..fc4ef9a32 100644 --- a/build-support/custom-modules/ns3-configtable.cmake +++ b/build-support/custom-modules/ns3-configtable.cmake @@ -54,12 +54,20 @@ # Now the CMake part +set(ON ON) macro(check_on_or_off user_config_switch confirmation_flag) - if(${user_config_switch}) - if(${confirmation_flag}) + # Argument parsing + if(${${user_config_switch}}) + if(${${confirmation_flag}}) string(APPEND out "${Green}ON${ColourReset}\n") else() - string(APPEND out "${Red}OFF (missing dependency)${ColourReset}\n") + if(${confirmation_flag}_REASON) + string(APPEND out + "${Red}OFF (${${confirmation_flag}_REASON})${ColourReset}\n" + ) + else() + string(APPEND out "${Red}OFF (missing dependency)${ColourReset}\n") + endif() endif() else() string(APPEND out "OFF (not requested)\n") @@ -120,76 +128,76 @@ macro(write_configtable) ) string(APPEND out "Build with runtime asserts : ") - check_on_or_off("${NS3_ASSERT}" "${NS3_ASSERT}") + check_on_or_off("NS3_ASSERT" "NS3_ASSERT") string(APPEND out "Build with runtime logging : ") - check_on_or_off("${NS3_LOG}" "${NS3_LOG}") + check_on_or_off("NS3_LOG" "NS3_LOG") string(APPEND out "Build version embedding : ") - check_on_or_off("${NS3_ENABLE_BUILD_VERSION}" "${ENABLE_BUILD_VERSION}") + check_on_or_off("NS3_ENABLE_BUILD_VERSION" "ENABLE_BUILD_VERSION") string(APPEND out "BRITE Integration : ") - check_on_or_off("ON" "${NS3_BRITE}") + check_on_or_off("ON" "NS3_BRITE") string(APPEND out "DES Metrics event collection : ") - check_on_or_off("${NS3_DES_METRICS}" "${NS3_DES_METRICS}") + check_on_or_off("NS3_DES_METRICS" "NS3_DES_METRICS") string(APPEND out "DPDK NetDevice : ") - check_on_or_off("${NS3_DPDK}" "${ENABLE_DPDKDEVNET}") + check_on_or_off("NS3_DPDK" "ENABLE_DPDKDEVNET") string(APPEND out "Emulation FdNetDevice : ") - check_on_or_off("${ENABLE_EMU}" "${ENABLE_EMUNETDEV}") + check_on_or_off("ENABLE_EMU" "ENABLE_EMUNETDEV") string(APPEND out "Examples : ") - check_on_or_off("${ENABLE_EXAMPLES}" "${ENABLE_EXAMPLES}") + check_on_or_off("ENABLE_EXAMPLES" "ENABLE_EXAMPLES") string(APPEND out "File descriptor NetDevice : ") - check_on_or_off("ON" "${ENABLE_FDNETDEV}") + check_on_or_off("ON" "ENABLE_FDNETDEV") string(APPEND out "GNU Scientific Library (GSL) : ") - check_on_or_off("${NS3_GSL}" "${GSL_FOUND}") + check_on_or_off("NS3_GSL" "GSL_FOUND") string(APPEND out "GtkConfigStore : ") - check_on_or_off("${NS3_GTK3}" "${GTK3_FOUND}") + check_on_or_off("NS3_GTK3" "GTK3_FOUND") string(APPEND out "LibXml2 support : ") - check_on_or_off("ON" "${LIBXML2_FOUND}") + check_on_or_off("ON" "LIBXML2_FOUND") string(APPEND out "MPI Support : ") - check_on_or_off("${NS3_MPI}" "${MPI_FOUND}") + check_on_or_off("NS3_MPI" "MPI_FOUND") string(APPEND out "Multithreaded Simulation : ") check_on_or_off("${NS3_MTP}" "ON") string(APPEND out "ns-3 Click Integration : ") - check_on_or_off("ON" "${NS3_CLICK}") + check_on_or_off("ON" "NS3_CLICK") string(APPEND out "ns-3 OpenFlow Integration : ") - check_on_or_off("ON" "${NS3_OPENFLOW}") + check_on_or_off("ON" "NS3_OPENFLOW") string(APPEND out "Netmap emulation FdNetDevice : ") - check_on_or_off("${ENABLE_EMU}" "${ENABLE_NETMAP_EMU}") + check_on_or_off("ENABLE_EMU" "ENABLE_NETMAP_EMU") string(APPEND out "PyViz visualizer : ") - check_on_or_off("${NS3_VISUALIZER}" "${ENABLE_VISUALIZER}") + check_on_or_off("NS3_VISUALIZER" "ENABLE_VISUALIZER") string(APPEND out "Python Bindings : ") - check_on_or_off("${NS3_PYTHON_BINDINGS}" "${ENABLE_PYTHON_BINDINGS}") + check_on_or_off("NS3_PYTHON_BINDINGS" "ENABLE_PYTHON_BINDINGS") string(APPEND out "SQLite support : ") - check_on_or_off("${NS3_SQLITE}" "${ENABLE_SQLITE}") + check_on_or_off("NS3_SQLITE" "ENABLE_SQLITE") string(APPEND out "Eigen3 support : ") - check_on_or_off("${NS3_EIGEN}" "${ENABLE_EIGEN}") + check_on_or_off("NS3_EIGEN" "ENABLE_EIGEN") string(APPEND out "Tap Bridge : ") - check_on_or_off("${ENABLE_TAP}" "${ENABLE_TAP}") + check_on_or_off("ENABLE_TAP" "ENABLE_TAP") string(APPEND out "Tap FdNetDevice : ") - check_on_or_off("${ENABLE_TAP}" "${ENABLE_TAPNETDEV}") + check_on_or_off("ENABLE_TAP" "ENABLE_TAPNETDEV") string(APPEND out "Tests : ") - check_on_or_off("${ENABLE_TESTS}" "${ENABLE_TESTS}") + check_on_or_off("ENABLE_TESTS" "ENABLE_TESTS") # string(APPEND out "Use sudo to set suid bit : not enabled (option # --enable-sudo not selected) string(APPEND out "XmlIo : enabled diff --git a/build-support/custom-modules/ns3-module-macros.cmake b/build-support/custom-modules/ns3-module-macros.cmake index 4dd9f6d75..82f5d0590 100644 --- a/build-support/custom-modules/ns3-module-macros.cmake +++ b/build-support/custom-modules/ns3-module-macros.cmake @@ -191,9 +191,29 @@ function(build_lib) # include directories, allowing consumers of this module to include and link # the 3rd-party code with no additional setup get_target_includes(${lib${BLIB_LIBNAME}} exported_include_directories) + string(REPLACE "-I" "" exported_include_directories "${exported_include_directories}" ) + + # include directories prefixed in the source or binary directory need to be + # treated differently + set(new_exported_include_directories) + foreach(directory ${exported_include_directories}) + string(FIND "${directory}" "${PROJECT_SOURCE_DIR}" is_prefixed_in_subdir) + if(${is_prefixed_in_subdir} GREATER_EQUAL 0) + string(SUBSTRING "${directory}" ${is_prefixed_in_subdir} -1 + directory_path + ) + list(APPEND new_exported_include_directories + $ + ) + else() + list(APPEND new_exported_include_directories ${directory}) + endif() + endforeach() + set(exported_include_directories ${new_exported_include_directories}) + string(REPLACE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/include" "" exported_include_directories "${exported_include_directories}" @@ -235,6 +255,23 @@ function(build_lib) INTERFACE ${exported_include_directories} ) + # Export definitions as interface definitions, propagating local definitions + # to other modules and scratches + get_target_property( + target_definitions ${lib${BLIB_LIBNAME}} COMPILE_DEFINITIONS + ) + if(${target_definitions} STREQUAL "target_definitions-NOTFOUND") + set(target_definitions) + endif() + get_directory_property(dir_definitions COMPILE_DEFINITIONS) + set(exported_definitions "${target_definitions};${dir_definitions}") + list(REMOVE_DUPLICATES exported_definitions) + list(REMOVE_ITEM exported_definitions "") + set_target_properties( + ${lib${BLIB_LIBNAME}} PROPERTIES INTERFACE_COMPILE_DEFINITIONS + "${exported_definitions}" + ) + set(ns3-external-libs "${non_ns_libraries_to_link};${ns3-external-libs}" CACHE INTERNAL "list of non-ns libraries to link to NS3_STATIC and NS3_MONOLIB" diff --git a/build-support/custom-modules/ns3-vcpkg-hunter.cmake b/build-support/custom-modules/ns3-vcpkg-hunter.cmake new file mode 100644 index 000000000..db8acdc75 --- /dev/null +++ b/build-support/custom-modules/ns3-vcpkg-hunter.cmake @@ -0,0 +1,198 @@ +# Copyright (c) 2017-2023 Universidade de Brasília +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License version 2 as published by the Free +# Software Foundation; +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Gabriel Ferreira + +# Set default installation directory +set(VCPKG_DIR "${PROJECT_SOURCE_DIR}/vcpkg") + +# Check if there is an existing vcpkg installation in the user directory +if(WIN32) + set(user_dir $ENV{USERPROFILE}) +else() + set(user_dir $ENV{HOME}) +endif() + +# Override the default vcpkg installation directory in case it does +if(EXISTS "${user_dir}/vcpkg") + set(VCPKG_DIR "${user_dir}/vcpkg") +endif() + +find_package(Git) + +if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(VCPKG_TARGET_ARCH x64) +else() + set(VCPKG_TARGET_ARCH x86) +endif() + +if(WIN32) + set(VCPKG_EXEC vcpkg.exe) + set(VCPKG_TRIPLET ${VCPKG_TARGET_ARCH}-windows) +else() + set(VCPKG_EXEC vcpkg) + if(NOT APPLE) # LINUX + set(VCPKG_TRIPLET ${VCPKG_TARGET_ARCH}-linux) + else() + set(VCPKG_TRIPLET ${VCPKG_TARGET_ARCH}-osx) + endif() +endif() + +# https://learn.microsoft.com/en-us/vcpkg/users/buildsystems/cmake-integration +set(VCPKG_TARGET_TRIPLET ${VCPKG_TRIPLET}) +set(VCPKG_MANIFEST ${PROJECT_SOURCE_DIR}/vcpkg.json) + +function(setup_vcpkg) + message(STATUS "vcpkg: setting up support in ${VCPKG_DIR}") + + # Check if vcpkg was downloaded previously + if(EXISTS "${VCPKG_DIR}") + # Vcpkg already downloaded + message(STATUS "vcpkg: folder already exists, skipping git download") + else() + if(NOT ${Git_FOUND}) + message(FATAL_ERROR "vcpkg: Git is required, but it was not found") + endif() + get_filename_component(VCPKG_PARENT_DIR ${VCPKG_DIR} DIRECTORY) + execute_process( + COMMAND ${GIT_EXECUTABLE} clone --depth 1 + https://github.com/microsoft/vcpkg.git + WORKING_DIRECTORY "${VCPKG_PARENT_DIR}/" + ) + endif() + + if(${MSVC}) + message(FATAL_ERROR "vcpkg: Visual Studio is unsupported") + else() + # Check if required packages are installed (unzip curl tar) + if(WIN32) + find_program(ZIP_PRESENT zip.exe) + find_program(UNZIP_PRESENT unzip.exe) + find_program(CURL_PRESENT curl.exe) + find_program(TAR_PRESENT tar.exe) + else() + find_program(ZIP_PRESENT zip) + find_program(UNZIP_PRESENT unzip) + find_program(CURL_PRESENT curl) + find_program(TAR_PRESENT tar) + endif() + + if(${ZIP_PRESENT} STREQUAL ZIP_PRESENT-NOTFOUND) + message(FATAL_ERROR "vcpkg: Zip is required, but is not installed") + endif() + + if(${UNZIP_PRESENT} STREQUAL UNZIP_PRESENT-NOTFOUND) + message(FATAL_ERROR "vcpkg: Unzip is required, but is not installed") + endif() + + if(${CURL_PRESENT} STREQUAL CURL_PRESENT-NOTFOUND) + message(FATAL_ERROR "vcpkg: Curl is required, but is not installed") + endif() + + if(${TAR_PRESENT} STREQUAL TAR_PRESENT-NOTFOUND) + message(FATAL_ERROR "vcpkg: Tar is required, but is not installed") + endif() + endif() + + # message(WARNING "Checking VCPKG bootstrapping") Check if vcpkg was + # bootstrapped previously + if(EXISTS "${VCPKG_DIR}/${VCPKG_EXEC}") + message(STATUS "vcpkg: already bootstrapped") + else() + # message(WARNING "vcpkg: bootstrapping") + set(COMPILER_ENFORCING) + + if(WIN32) + set(command bootstrap-vcpkg.bat -disableMetrics) + else() + # if(NOT APPLE) #linux/bsd + set(command bootstrap-vcpkg.sh -disableMetrics) + # else() set(command bootstrap-vcpkg.sh)# --allowAppleClang) endif() + endif() + + execute_process( + COMMAND ${COMPILER_ENFORCING} ${VCPKG_DIR}/${command} + WORKING_DIRECTORY ${VCPKG_DIR} + ) + # message(STATUS "vcpkg: bootstrapped") include_directories(${VCPKG_DIR}) + set(ENV{VCPKG_ROOT} ${VCPKG_DIR}) + endif() + + if(NOT WIN32) + execute_process(COMMAND chmod +x ${VCPKG_DIR}/${VCPKG_EXEC}) + endif() + + set(CMAKE_PREFIX_PATH + "${VCPKG_DIR}/installed/${VCPKG_TRIPLET}/;${CMAKE_PREFIX_PATH}" + PARENT_SCOPE + ) + + # Install packages in manifest mode + if(EXISTS ${VCPKG_MANIFEST}) + message(STATUS "vcpkg: detected a vcpkg manifest file: ${VCPKG_MANIFEST}") + execute_process( + COMMAND ${VCPKG_DIR}/${VCPKG_EXEC} install --triplet ${VCPKG_TRIPLET} + --x-install-root=${VCPKG_DIR}/installed RESULT_VARIABLE res + ) + if(${res} EQUAL 0) + message(STATUS "vcpkg: packages defined in the manifest were installed") + else() + message( + FATAL_ERROR + "vcpkg: packages defined in the manifest failed to be installed" + ) + endif() + endif() +endfunction() + +function(add_package package_name) + # Early exit in case vcpkg support is not enabled + if(NOT ${NS3_VCPKG}) + message(${HIGHLIGHTED_STATUS} + "vcpkg: support is disabled. Not installing: ${package_name}" + ) + return() + endif() + + # Early exit in case a vcpkg.json manifest file is present + if(EXISTS ${VCPKG_MANIFEST}) + file(READ ${VCPKG_MANIFEST} contents) + if(${contents} MATCHES ${package_name}) + message(STATUS "vcpkg: ${package_name} was installed") + return() + else() + message( + FATAL_ERROR + "vcpkg: manifest mode in use, but ${package_name} is not listed in ${VCPKG_MANIFEST}" + ) + endif() + endif() + + # Normal exit + message(STATUS "vcpkg: ${package_name} will be installed") + execute_process( + COMMAND ${VCPKG_DIR}/${VCPKG_EXEC} install ${package_name} --triplet + ${VCPKG_TRIPLET} RESULT_VARIABLE res + ) + if(${res} EQUAL 0) + message(STATUS "vcpkg: ${package_name} was installed") + else() + message(FATAL_ERROR "vcpkg: ${package_name} failed to be installed") + endif() +endfunction() + +if(${NS3_VCPKG}) + setup_vcpkg() +endif() diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 6bee30f0d..490f14b08 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -150,6 +150,7 @@ set(CMAKE_HEADER_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/include/ns3) set(THIRD_PARTY_DIRECTORY ${PROJECT_SOURCE_DIR}/3rd-party) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) link_directories(${CMAKE_OUTPUT_DIRECTORY}/lib) +file(MAKE_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}) # Get installation folder default values for each platform and include package # configuration macro @@ -664,23 +665,6 @@ macro(process_options) endif() endif() - set(ENABLE_SQLITE False) - if(${NS3_SQLITE}) - # find_package(SQLite3 QUIET) # unsupported in CMake 3.10 We emulate the - # behavior of find_package below - find_external_library( - DEPENDENCY_NAME SQLite3 HEADER_NAME sqlite3.h LIBRARY_NAME sqlite3 - ) - - if(${SQLite3_FOUND}) - set(ENABLE_SQLITE True) - add_definitions(-DHAVE_SQLITE3) - include_directories(${SQLite3_INCLUDE_DIRS}) - else() - message(${HIGHLIGHTED_STATUS} "SQLite was not found") - endif() - endif() - if(${NS3_NATIVE_OPTIMIZATIONS} AND ${GCC}) add_compile_options(-march=native -mtune=native) endif() @@ -751,6 +735,68 @@ macro(process_options) ) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/build-support/3rd-party") + # Include our package managers + # cmake-format: off + # Starting with a custom cmake file that provides a Hunter-like interface to vcpkg + # Use add_package(package) to install a package + # Then find_package(package) to use it + # cmake-format: on + include(ns3-vcpkg-hunter) + + # Then the beautiful CPM manager (too bad it doesn't work with everything) + # https://github.com/cpm-cmake/CPM.cmake + if(${NS3_CPM}) + set(CPM_DOWNLOAD_VERSION 0.38.2) + set(CPM_DOWNLOAD_LOCATION + "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake" + ) + if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) + message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") + file( + DOWNLOAD + https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} + ) + endif() + include(${CPM_DOWNLOAD_LOCATION}) + set(CPM_USE_LOCAL_PACKAGES ON) + endif() + # Package manager test block + if(TEST_PACKAGE_MANAGER) + if(${TEST_PACKAGE_MANAGER} STREQUAL "CPM") + cpmaddpackage( + NAME ARMADILLO GIT_TAG 6cada351248c9a967b137b9fcb3d160dad7c709b + GIT_REPOSITORY https://gitlab.com/conradsnicta/armadillo-code.git + ) + find_package(ARMADILLO REQUIRED) + message(STATUS "Armadillo was found? ${ARMADILLO_FOUND}") + elseif(${TEST_PACKAGE_MANAGER} STREQUAL "VCPKG") + add_package(Armadillo) + find_package(Armadillo REQUIRED) + message(STATUS "Armadillo was found? ${ARMADILLO_FOUND}") + else() + find_package(Armadillo REQUIRED) + endif() + endif() + # End of package managers + + set(ENABLE_SQLITE False) + if(${NS3_SQLITE}) + # find_package(SQLite3 QUIET) # unsupported in CMake 3.10 We emulate the + # behavior of find_package below + find_external_library( + DEPENDENCY_NAME SQLite3 HEADER_NAME sqlite3.h LIBRARY_NAME sqlite3 + ) + + if(${SQLite3_FOUND}) + set(ENABLE_SQLITE True) + add_definitions(-DHAVE_SQLITE3) + include_directories(${SQLite3_INCLUDE_DIRS}) + else() + message(${HIGHLIGHTED_STATUS} "SQLite was not found") + endif() + endif() + set(ENABLE_EIGEN False) if(${NS3_EIGEN}) find_package(Eigen3 QUIET) @@ -889,6 +935,7 @@ macro(process_options) message(${HIGHLIGHTED_STATUS} "Python: development libraries were not found" ) + set(ENABLE_PYTHON_BINDINGS_REASON "missing Python development libraries") endif() else() if(${NS3_PYTHON_BINDINGS}) @@ -896,6 +943,7 @@ macro(process_options) ${HIGHLIGHTED_STATUS} "Python: an incompatible version of Python was found, python bindings will be disabled" ) + set(ENABLE_PYTHON_BINDINGS_REASON "incompatible Python version") endif() endif() @@ -906,6 +954,15 @@ macro(process_options) ${HIGHLIGHTED_STATUS} "Bindings: python bindings require Python, but it could not be found" ) + set(ENABLE_PYTHON_BINDINGS_REASON "missing dependency: python") + elseif(APPLE AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64") + # Warn users that Cppyy on ARM Macs isn't supported yet + message(${HIGHLIGHTED_STATUS} + "Bindings: macOS silicon detected -- see issue 930" + ) + set(ENABLE_PYTHON_BINDINGS_REASON + "macOS silicon detected -- see issue 930" + ) else() check_python_packages("cppyy" missing_packages) if(missing_packages) @@ -913,6 +970,9 @@ macro(process_options) ${HIGHLIGHTED_STATUS} "Bindings: python bindings disabled due to the following missing dependencies: ${missing_packages}" ) + set(ENABLE_PYTHON_BINDINGS_REASON + "missing dependency: ${missing_packages}" + ) else() set(ENABLE_PYTHON_BINDINGS ON) endif() @@ -999,10 +1059,21 @@ macro(process_options) set(ENABLE_VISUALIZER FALSE) if(${NS3_VISUALIZER}) - if((NOT ${ENABLE_PYTHON_BINDINGS}) OR (NOT ${Python3_FOUND})) - message(${HIGHLIGHTED_STATUS} "Visualizer requires Python bindings") + # If bindings are enabled, check if visualizer dependencies are met + if(${NS3_PYTHON_BINDINGS}) + if(NOT ${Python3_FOUND}) + set(ENABLE_VISUALIZER_REASON "missing Python") + elseif(NOT ${ENABLE_PYTHON_BINDINGS}) + set(ENABLE_VISUALIZER_REASON "missing Python Bindings") + else() + set(ENABLE_VISUALIZER TRUE) + endif() + # If bindings are disabled, just say python bindings are disabled else() - set(ENABLE_VISUALIZER TRUE) + set(ENABLE_VISUALIZER_REASON "Python Bindings are disabled") + endif() + if(ENABLE_VISUALIZER_REASON) + message(${HIGHLIGHTED_STATUS} "Visualizer: ${ENABLE_VISUALIZER_REASON}") endif() endif() diff --git a/build-support/test-files/test-package-managers/CMakeLists.txt b/build-support/test-files/test-package-managers/CMakeLists.txt new file mode 100644 index 000000000..32f8ae84b --- /dev/null +++ b/build-support/test-files/test-package-managers/CMakeLists.txt @@ -0,0 +1,42 @@ +if(NOT + TEST_PACKAGE_MANAGER +) + message( + STATUS "Skipping test module because TEST_PACKAGE_MANAGER is not set." + ) + return() +endif() + +set(armadillo) +if(${TEST_PACKAGE_MANAGER} + STREQUAL + "CPM" +) + set(armadillo + armadillo + ) + include_directories(${CMAKE_BINARY_DIR}/_deps/armadillo-src/include) +elseif( + ${TEST_PACKAGE_MANAGER} + STREQUAL + "VCPKG" +) + set(armadillo + ${ARMADILLO_LIBRARIES} + ) + include_directories(${ARMADILLO_INCLUDE_DIRS}) +else() + message(FATAL_ERROR "zoincs") + message( + STATUS + "Skipping test module because TEST_PACKAGE_MANAGER is set to an unsupported value." + ) + return() +endif() + +build_lib( + LIBNAME test-package-managers + SOURCE_FILES src.cc + LIBRARIES_TO_LINK ${libcore} + ${armadillo} +) diff --git a/build-support/test-files/test-package-managers/src.cc b/build-support/test-files/test-package-managers/src.cc new file mode 100644 index 000000000..515252187 --- /dev/null +++ b/build-support/test-files/test-package-managers/src.cc @@ -0,0 +1,10 @@ +#include + +int +main(int argc, char** argv) +{ + arma::arma_rng::set_seed_random(); + arma::Mat mat = arma::randu(4, 4); + std::cout << "mat:\n" << mat << "\n"; + return 0; +} diff --git a/doc/contributing/pickle-to-xml.py b/doc/contributing/pickle-to-xml.py index 1f557370f..6a4fcebb3 100755 --- a/doc/contributing/pickle-to-xml.py +++ b/doc/contributing/pickle-to-xml.py @@ -12,11 +12,11 @@ import os import codecs def dump_pickles(out, dirname, filename, path): - f = open(os.path.join(dirname, filename), 'r') - data = pickle.load(f) - fragment_file = codecs.open(data['current_page_name'] + '.frag', mode='w', encoding='utf-8') - fragment_file.write(data['body']) - fragment_file.close() + with open(os.path.join(dirname, filename), 'r', encoding='utf-8') as f: + data = pickle.load(f) + with codecs.open(data['current_page_name'] + '.frag', mode='w', encoding='utf-8') as fragment_file: + fragment_file.write(data['body']) + out.write(' \n' % path) out.write(' %s.frag\n' % data['current_page_name']) if data['prev'] is not None: @@ -28,12 +28,11 @@ def dump_pickles(out, dirname, filename, path): (os.path.normpath(os.path.join(path, data['next']['link'])), data['next']['title'])) out.write(' \n') - f.close() + if data['next'] is not None: next_path = os.path.normpath(os.path.join(path, data['next']['link'])) next_filename = os.path.basename(next_path) + '.fpickle' dump_pickles(out, dirname, next_filename, next_path) - return import sys diff --git a/doc/contributing/source/coding-style.rst b/doc/contributing/source/coding-style.rst index 09e07bc34..15941d45f 100644 --- a/doc/contributing/source/coding-style.rst +++ b/doc/contributing/source/coding-style.rst @@ -38,9 +38,9 @@ previous versions. The following list contains the set of clang-format versions that are verified to produce consistent output among themselves. -* clang-format-14 -* clang-format-15 * clang-format-16 +* clang-format-15 +* clang-format-14 Integration with IDEs ===================== @@ -121,13 +121,14 @@ We recommend running this script over your newly introduced C++ files prior to s as a Merge Request. The script has multiple modes of operation. By default, the script checks if -source code files are well formatted and text files do not have trailing whitespace +source code files are well formatted, if there are no #include headers from the same +module with the "ns3/" prefix, and text files do not have trailing whitespace nor tabs. The process returns a zero exit code if all files adhere to these rules. If there are files that do not comply with the rules, the process returns a non-zero exit code and lists the respective files. This mode is useful for developers editing their code and for the GitLab CI/CD pipeline to check if the codebase is well formatted. All checks are enabled by default. Users can disable specific checks using the corresponding -flags: ``--no-formatting``, ``--no-whitespace`` and ``--no-tabs``. +flags: ``--no-include-prefixes``, ``--no-formatting``, ``--no-whitespace`` and ``--no-tabs``. Additional information about the formatting issues detected by the script can be enabled by adding the ``-v, --verbose`` flag. @@ -151,17 +152,13 @@ For quick-reference, the most used commands are listed below: .. sourcecode:: console # Entire codebase (using paths relative to the ns-3 main directory) - ./utils/check-style-clang-format.py [--fix] [--verbose] [--no-formatting] [--no-whitespace] [--no-tabs] . + ./utils/check-style-clang-format.py --fix . # Entire codebase (using absolute paths) - /path/to/utils/check-style-clang-format.py [--fix] [--verbose] [--no-formatting] [--no-whitespace] [--no-tabs] /path/to/ns3 - - # Specific directory - /path/to/utils/check-style-clang-format.py [--fix] [--verbose] [--no-formatting] [--no-whitespace] [--no-tabs] absolute_or_relative/path/to/directory - - # Individual file - /path/to/utils/check-style-clang-format.py [--fix] [--verbose] [--no-formatting] [--no-whitespace] [--no-tabs] absolute_or_relative/path/to/file + /path/to/utils/check-style-clang-format.py --fix /path/to/ns3 + # Specific directory or file + /path/to/utils/check-style-clang-format.py --fix absolute_or_relative/path/to/directory_or_file Clang-tidy ********** @@ -799,6 +796,29 @@ file (``*.cc``). // Or as constexpr (in implementation files) constexpr uint8_t STATUS_PDU{0}; +When declaring variables that are easily deducible from context, prefer to declare them +with ``auto`` instead of repeating the type name. Not only does this improve code readability, +by making lines shorter, but it also facilitates future code refactoring. +When declaring variables, prefer to use direct-initialization, to avoid repeating the type name. + +.. sourcecode:: cpp + + // Avoid repeating the type name when declaring iterators or pointers, and casting variables + std::map::const_iterator it = myMap.find(key); + int* ptr = new int[10]; + uint8_t m = static_cast(97 + (i % 26)); + + // Prefer to declare them with auto + auto it = myMap.find(key); + auto* ptr = new int[10]; + auto m = static_cast(97 + (i % 26)); + + // Avoid splitting the declaration and initialization of variables + Ipv4Address ipv4Address = Ipv4Address("192.168.0.1") + + // Prefer to use direct-initialization + Ipv4Address ipv4Address("192.168.0.1") + Comments ======== @@ -1200,6 +1220,125 @@ the |ns3| smart pointer class ``Ptr`` should be used in boolean comparisons as f NS_TEST... (p, nullptr, ...) NS_TEST... (p, nullptr, ...) +Code performance tips +===================== + +While developing code, consider the following tips to improve the code's performance. +Some tips are general recommendations, but are not strictly enforced. +Other tips are enforced by clang-tidy. Please refer to the clang-tidy section below +for more details. + +- Prefer to use ``.emplace_back()`` over ``.push_back()`` to optimize performance. + +- When initializing STL containers (e.g., ``std::vector``) with known size, + reserve memory to store all items, before pushing them in a loop. + + .. sourcecode:: cpp + + constexpr int N_ITEMS = 5; + + std::vector myVector; + myVector.reserve(N_ITEMS); // Reserve memory to store all items + + for (int i = 0; i < N_ITEMS; i++) + { + myVector.emplace_back(i); + } + +- Prefer to initialize STL containers (e.g., ``std::vector``, ``std::map``, etc.) + directly through the constructor or with a braced-init-list, instead of pushing + elements one-by-one. + + .. sourcecode:: cpp + + // Prefer to initialize containers directly + std::vector myVector1{1, 2, 3}; + std::vector myVector2(myVector1.begin(), myVector1.end()); + std::vector myVector3(myVector2.size(), true); + + // Avoid pushing elements one-by-one + std::vector myVector1; + myVector1.reserve(3); + myVector1.emplace_back(1); + myVector1.emplace_back(2); + myVector1.emplace_back(3); + + std::vector myVector2; + myVector2.reserve(myVector1.size()); + for (const auto& v : myVector1) + { + myVector2.emplace_back(v); + } + + std::vector myVector3; + myVector3.reserve(myVector1.size()); + for (std::size_t i = 0; i < myVector1.size(); i++) + { + myVector3.emplace_back(true); + } + +- When looping through containers, prefer to use const-ref syntax over copying + elements. + + .. sourcecode:: cpp + + std::vector myVector{1, 2, 3}; + + for (const auto& v : myVector) { ... } // OK + for (auto v : myVector) { ... } // Avoid + +- Prefer to use the ``empty()`` function of STL containers (e.g., ``std::vector``), + instead of the condition ``size() > 0``, to avoid unnecessarily calculating the + size of the container. + +- Avoid unnecessary calls to the functions ``.c_str()`` and ``.data()`` of + ``std::string``. + +- Avoid unnecessarily dereferencing std smart pointers (``std::shared_ptr``, + ``std::unique_ptr``) with calls to their member function ``.get()``. + Prefer to use the std smart pointer directly where needed. + + .. sourcecode:: cpp + + auto ptr = std::make_shared(); + + // OK + if (ptr) { ... } + + // Avoid + if (ptr.get()) { ... } + +- Consider caching frequently-used results (especially expensive calculations, + such as mathematical functions) in a temporary variable, instead of calculating + them in every loop. + + .. sourcecode:: cpp + + // Prefer to cache intermediate results + const double sinTheta = std::sin(theta); + const double cosTheta = std::cos(theta); + + for (uint8_t i = 0; i < NUM_VALUES; i++) + { + double power = std::pow(2, i); + + array1[i] = (power * sinTheta) + cosTheta; + array2[i] = (power * cosTheta) + sinTheta; + } + + // Avoid repeating calculations + for (uint8_t i = 0; i < NUM_VALUES; i++) + { + array1[i] = (std::pow(2, i) * std::sin(theta)) + std::cos(theta); + array2[i] = (std::pow(2, i) * std::cos(theta)) + std::sin(theta); + } + +- Do not include inline implementations in header files; put all + implementation in a ``.cc`` file (unless implementation in the header file + brings demonstrable and significant performance improvement). + +- Avoid declaring trivial destructors, to optimize performance. + C++ standard ============ @@ -1250,10 +1389,6 @@ Miscellaneous items void MySub(const T& t); // OK void MySub(T const& t); // Not OK -- Do not include inline implementations in header files; put all - implementation in a ``.cc`` file (unless implementation in the header file - brings demonstrable and significant performance improvement). - - Do not use ``NULL``, ``nil`` or ``0`` constants; use ``nullptr`` (improves portability) - Consider whether you want the default constructor, copy constructor, or assignment @@ -1315,12 +1450,13 @@ Miscellaneous items Clang-tidy rules ================ -Please refer to the ``.clang-tidy`` file in the |ns3| root directory for the full list +Please refer to the ``.clang-tidy`` file in the |ns3| main directory for the full list of rules that should be observed while developing code. -- Explicitly mark inherited functions with the ``override`` specifier. +Some rules are explained in the corresponding sections above. The remaining rules are +explained here. -- Prefer to use ``.emplace_back()`` over ``.push_back()`` to optimize performance. +- Explicitly mark inherited functions with the ``override`` specifier. - When creating STL smart pointers, prefer to use ``std::make_shared`` or ``std::make_unique``, instead of creating the smart pointer with ``new``. @@ -1340,69 +1476,6 @@ of rules that should be observed while developing code. for (const auto& v : myVector) { ... } // Prefer for (int i = 0; i < myVector.size(); i++) { ... } // Avoid -- When looping through containers, prefer to use const-ref syntax over copying - elements. - - .. sourcecode:: cpp - - std::vector myVector{1, 2, 3}; - - for (const auto& v : myVector) { ... } // OK - for (auto v : myVector) { ... } // Avoid - -- When initializing ``std::vector`` containers with known size, reserve memory to - store all items, before pushing them in a loop. - - .. sourcecode:: cpp - - constexpr int N_ITEMS = 5; - - std::vector myVector; - myVector.reserve(N_ITEMS); // Reserve memory to store all items - - for (int i = 0; i < N_ITEMS; i++) - { - myVector.emplace_back(i); - } - -- Prefer to initialize STL containers (e.g., ``std::vector``, ``std::map``, etc.) - directly with a braced-init-list, instead of pushing elements one-by-one. - - .. sourcecode:: cpp - - // OK - std::vector myVector{1, 2, 3}; - - // Avoid - std::vector myVector; - myVector.reserve(3); - myVector.emplace_back(1); - myVector.emplace_back(2); - myVector.emplace_back(3); - -- Prefer to use the ``empty()`` function of STL containers (e.g., ``std::vector``), - instead of the condition ``size() > 0``, to avoid unnecessarily calculating the - size of the container. - -- Avoid unnecessary calls to the functions ``.c_str()`` and ``.data()`` of - ``std::string``. - -- Avoid unnecessarily dereferencing std smart pointers (``std::shared_ptr``, - ``std::unique_ptr``) with calls to their member function ``.get()``. - Prefer to use the std smart pointer directly where needed. - - .. sourcecode:: cpp - - auto ptr = std::make_shared(); - - // OK - if (ptr) { ... } - - // Avoid - if (ptr.get()) { ... } - -- Avoid declaring trivial destructors, to optimize performance. - - Avoid accessing class static functions and members through objects. Instead, prefer to access them through the class. @@ -1415,5 +1488,34 @@ of rules that should be observed while developing code. MyClass myClass; MyClass.StaticFunction(); +- Prefer using type traits in short form ``traits_t<...>`` and ``traits_v<...>``, + instead of the long form ``traits<...>::type`` and ``traits<...>::value``, respectively. + + .. sourcecode:: cpp + + // Prefer using the shorter version of type traits + std::is_same_v + std::is_integral_v + std::enable_if_t, Time> + + // Avoid the longer form of type traits + std::is_same::value + std::is_integral::value + std::enable_if::value, Time>::type + +- Avoid using integer values (``1`` or ``0``) to represent boolean variables + (``true`` or ``false``), to improve code readability and avoid implicit conversions. + - Prefer to use ``static_assert()`` over ``NS_ASSERT()`` when conditions can be evaluated at compile-time. + +- Prefer using transparent functors to non-transparent ones, to avoid repeating + the type name. This improves readability and avoids errors when refactoring code. + + .. sourcecode:: cpp + + // Prefer using transparent functors + std::map> myMap; + + // Avoid repeating the type name "MyClass" in std::less<> + std::map> myMap; diff --git a/doc/contributing/source/conf.py b/doc/contributing/source/conf.py index 20ce22bac..d468812fb 100644 --- a/doc/contributing/source/conf.py +++ b/doc/contributing/source/conf.py @@ -48,9 +48,9 @@ copyright = u'2015, ns-3 project' # built documents. # # The short X.Y version. -version = 'ns-3.39' +version = 'ns-3.40' # The full version, including alpha/beta/rc tags. -release = 'ns-3.39' +release = 'ns-3.40' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/contributing/source/index.rst b/doc/contributing/source/index.rst index 7604e4194..798857449 100644 --- a/doc/contributing/source/index.rst +++ b/doc/contributing/source/index.rst @@ -24,6 +24,7 @@ This document is written in `reStructuredText (ObjectBase \\*" # ATTRIBUTE_HELPER_CPP( and _HEADER( REappend filter_blacklistRE "ATTRIBUTE_HELPER_\\(CPP\\|HEADER\\)" diff --git a/doc/installation/source/conf.py b/doc/installation/source/conf.py index 9d56b8a40..5627815cf 100644 --- a/doc/installation/source/conf.py +++ b/doc/installation/source/conf.py @@ -48,9 +48,9 @@ copyright = u'2018, ns-3 project' # built documents. # # The short X.Y version. -version = 'ns-3.39' +version = 'ns-3.40' # The full version, including alpha/beta/rc tags. -release = 'ns-3.39' +release = 'ns-3.40' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/installation/source/index.rst b/doc/installation/source/index.rst index cbc5d8623..a11a97ada 100644 --- a/doc/installation/source/index.rst +++ b/doc/installation/source/index.rst @@ -24,6 +24,7 @@ for `Sphinx `_ and is maintained in the ``doc/installa .. toctree:: :maxdepth: 2 + :numbered: overview quick-start diff --git a/doc/installation/source/macos.rst b/doc/installation/source/macos.rst index 918671b13..2b241f85d 100644 --- a/doc/installation/source/macos.rst +++ b/doc/installation/source/macos.rst @@ -38,6 +38,8 @@ of Python, please keep the possibility of a virtualenv in mind if you run into P For a short guide on virtual environments, please see `this link `_. +Due to an `upstream limitation with Cppyy `_, Python bindings do not work on macOS machines with Apple silicon (M1 and M2 processors). + Requirements ************ diff --git a/doc/installation/source/quick-start.rst b/doc/installation/source/quick-start.rst index bb7813883..5b8647df8 100644 --- a/doc/installation/source/quick-start.rst +++ b/doc/installation/source/quick-start.rst @@ -42,7 +42,7 @@ source archive download (via a web browser, ``wget``, or ``curl``). | | or ``tar`` and ``bunzip2`` | No minimum version | | | (for Web download) | | +--------------------+--------------------------------------+------------------------------+ - | **Compiler** | ``g++`` | >= 8 | + | **Compiler** | ``g++`` | >= 9 | + + + + | | or ``clang++`` | >= 10 | +--------------------+--------------------------------------+------------------------------+ @@ -80,13 +80,13 @@ Download There are two main options: -1. Download a release tarball. This will unpack to a directory such as ``ns-allinone-3.39`` +1. Download a release tarball. This will unpack to a directory such as ``ns-allinone-3.40`` containing |ns3| and some other programs. Below is a command-line download using ``wget``, but a browser download will also work:: - $ wget https://www.nsnam.org/releases/ns-allinone-3.39.tar.bz2 - $ tar xfj ns-allinone-3.39.tar.bz2 - $ cd ns-allinone-3.39/ns-3.39 + $ wget https://www.nsnam.org/releases/ns-allinone-3.40.tar.bz2 + $ tar xfj ns-allinone-3.40.tar.bz2 + $ cd ns-allinone-3.40/ns-3.40 2. Clone |ns3| from the Git repository. The ``ns-3-allinone`` can be cloned, as well as ``ns-3-dev`` by itself. Below, we illustrate the latter:: @@ -99,7 +99,7 @@ you clone |ns3|, your directory will be named ``ns-3-dev``. By default, Git wil the |ns3| ``master`` branch, which is a development branch. All |ns3| releases are tagged in Git, so if you would then like to check out a past release, you can do so as follows:: - $ git checkout -b ns-3.39-release ns-3.39 + $ git checkout -b ns-3.40-release ns-3.40 In this quick-start, we are omitting download and build instructions for optional |ns3| modules, the ``NetAnim`` animator, Python bindings, and ``NetSimulyzer``. The @@ -177,3 +177,30 @@ since CMake enables |ns3| integration with a variety of code editors, including: * Apple's XCode * CodeBlocks * Eclipse CDT4 + +Installing ns-3 +*************** + +Most users do not install |ns3| libraries to typical system library directories; they instead +just leave the libraries in the ``build`` directory, and the ``ns3`` Python program will +find these libraries. However, it is possible to perform an installation step-- ``ns3 install``-- +with the following caveats. + +The location of the installed libraries is set by the ``--prefix`` option specified at the +configure step. The prefix defaults to ``/usr/local``. For a given ``--prefix=$PREFIX``, +the installation step will install headers to a ``$PREFIX/include`` directory, libraries +and pkgconfig files to a ``$PREFIX/lib`` directory, and a few binaries to a +``$PREFIX/libexec`` directory. For example, ``./ns3 configure --prefix=/tmp``, followed +by ``./ns3 build`` and ``./ns3 install``, will lead to files being installed in +``/tmp/include``, ``/tmp/lib``, and ``/tmp/libexec``. + +Note that the ``ns3`` script prevents running the script as root (or as a sudo user). As a +result, with the default prefix of ``/usr/local``, the installation will fail unless the +user has write privileges in that directory. Attempts to force this with +``sudo ./ns3 install`` will fail due to a check in the ``ns3`` program that prevents running +as root. This check was installed by |ns3| maintainers for the safety of novice users who may +run ``./ns3`` in a root shell and later in a normal shell, and become confused about errors +resulting in lack of privileges to modify files. For users who know what they are doing and +who want to install to a privileged directory, users can comment out the statement +``refuse_run_as_root()`` in the ``ns3`` program (around line 1400), and then run +``sudo ./ns3 install``. diff --git a/doc/installation/source/system.rst b/doc/installation/source/system.rst index a458d6510..1641022ac 100644 --- a/doc/installation/source/system.rst +++ b/doc/installation/source/system.rst @@ -143,6 +143,8 @@ Python bindings (ns-3.37 and newer) |ns3| Python support now uses `cppyy `_. Version 2.4.2 is the most recent supported cppyy release; version 3.0.0 is not currently supported. +Due to an `upstream limitation with cppyy `_, Python bindings do not work on macOS machines with Apple silicon (M1 and M2 processors). + Using Python bindings (release 3.30 to ns-3.36) =============================================== diff --git a/doc/installation/source/windows.rst b/doc/installation/source/windows.rst index 0bb0db686..7badcb82a 100644 --- a/doc/installation/source/windows.rst +++ b/doc/installation/source/windows.rst @@ -19,7 +19,7 @@ either WSL or the Msys2/MinGW64 toolchain (installing both is not required). .. note:: |ns3| is not fully compatible with Visual Studio IDE / MSVC compiler; only Visual Studio Code -editor, the Msys2/MinGW64 toolchain, and WSL, as explained below. + editor, the Msys2/MinGW64 toolchain, and WSL, as explained below. .. _WSL2: diff --git a/doc/manual/Makefile b/doc/manual/Makefile index 3fb0b88e5..893ba5ba8 100644 --- a/doc/manual/Makefile +++ b/doc/manual/Makefile @@ -78,7 +78,6 @@ SOURCEFIGS = \ figures/hotspot-top-down.png \ figures/perfetto-trace-cmake.png \ figures/uprof-collect-callstack.png \ - figures/uprof-collect-callstack.png \ figures/uprof-profile-application.png \ figures/uprof-select-events.png \ figures/uprof-start.png \ diff --git a/doc/manual/source/conf.py b/doc/manual/source/conf.py index b82319874..c3cfee573 100644 --- a/doc/manual/source/conf.py +++ b/doc/manual/source/conf.py @@ -73,9 +73,9 @@ copyright = u'2006-2019' # built documents. # # The short X.Y version. -version = u'ns-3.39' +version = u'ns-3.40' # The full version, including alpha/beta/rc tags. -release = u'ns-3.39' +release = u'ns-3.40' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/manual/source/enable-modules.rst b/doc/manual/source/enable-modules.rst index 9921351f1..a94398159 100644 --- a/doc/manual/source/enable-modules.rst +++ b/doc/manual/source/enable-modules.rst @@ -97,6 +97,8 @@ The .ns3rc file should now be in your top level |ns3| directory, and it contains # Modules that depend on the listed modules will be enabled also. # # All modules can be enabled by emptying the list. + # To list modules, append the modules separated by space or semicolon; e.g.: + # set(ns3rc_enabled_modules core propagation) set(ns3rc_enabled_modules) # A list of the modules that will be disabled when ns-3 is run. @@ -123,6 +125,8 @@ Use your favorite editor to modify the .ns3rc file to only enable the core modul # Modules that depend on the listed modules will be enabled also. # # All modules can be enabled by emptying the list. + # To list modules, append the modules separated by space or semicolon; e.g.: + # set(ns3rc_enabled_modules core propagation) set(ns3rc_enabled_modules core) # A list of the modules that will be disabled when ns-3 is run. @@ -176,3 +180,16 @@ Running test.py will cause those tests that depend on only the core and network .. sourcecode:: text 31 of 31 tests passed (31 passed, 0 skipped, 0 failed, 0 crashed, 0 valgrind errors) + +As the comment in the sample ``.ns3rc`` file suggests, users may list multiple enabled modules by +separating each requested module by space or semicolon; e.g.: + +.. sourcecode:: cmake + + set(ns3rc_enabled_modules core propagation) + +The following also works (but note that a comma delimiter will not work with this CMake list): + +.. sourcecode:: cmake + + set(ns3rc_enabled_modules core;propagation) diff --git a/doc/manual/source/enable-tests.rst b/doc/manual/source/enable-tests.rst index c8e8b4f79..829a17756 100644 --- a/doc/manual/source/enable-tests.rst +++ b/doc/manual/source/enable-tests.rst @@ -173,3 +173,48 @@ Running test.py will cause all of the examples and tests to be run: .. sourcecode:: text 170 of 170 tests passed (170 passed, 0 skipped, 0 failed, 0 crashed, 0 valgrind errors) + + +Enable examples and tests that depend on a set of modules using |ns3| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +As seen above, the following command only builds the requested modules (core and wifi), +plus any modules that are implicitly needed (e.g., network), and the resulting compatible examples and tests: + +.. sourcecode:: terminal + + ./ns3 configure --enable-modules="wifi;core" --enable-examples --enable-tests + +However, when developing a new module, you may prefer to use the following alternative, which builds +all module libraries, but will filter out any examples and tests from modules that are not explicitly listed. + +.. sourcecode:: terminal + + ./ns3 configure --filter-module-examples-and-tests="wifi;core" --enable-examples --enable-tests + +The first command will generally lead to a shorter build time, but the second option will provide better +coverage, by building additional test cases and examples directly related to the specified modules. + +Enable examples and tests that depend on a set of modules using the |ns3| configuration file +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +As seen above, examples and tests can be enabled for just a subset of the available modules via the +``ns3`` script. The same can be accomplished via the ``.ns3rc`` configuration file. + +.. sourcecode:: cmake + + # A list of the modules that will be enabled when ns-3 is run. + # Modules that depend on the listed modules will be enabled also. + # + # All modules can be enabled by emptying the list. + set(ns3rc_enabled_modules) + + # ... + + # Override other ns-3 settings by setting their values below + # Note: command-line settings will also be overridden. + #set(NS3_LOG ON) + + # The following will build core and wifi tests, plus their examples + # and examples on /ns-3-dev/examples that depend on either of them + set(NS3_FILTER_MODULE_EXAMPLES_AND_TESTS wifi core) # <== diff --git a/doc/manual/source/events.rst b/doc/manual/source/events.rst index a7c39dd7b..26a95711e 100644 --- a/doc/manual/source/events.rst +++ b/doc/manual/source/events.rst @@ -215,9 +215,9 @@ for example:: GlobalValue::Bind("SimulatorImplementationType", StringValue("ns3::DistributedSimulatorImpl")); -or by using a command line argument:: +or by using a command line argument -.. sourcecode:: bash +.. sourcecode:: terminal $ ./ns3 run "... -–SimulatorImplementationType=ns3::DistributedSimulatorImpl" diff --git a/doc/manual/source/index.rst b/doc/manual/source/index.rst index 534153633..f2bf761da 100644 --- a/doc/manual/source/index.rst +++ b/doc/manual/source/index.rst @@ -24,6 +24,7 @@ This document is written in `reStructuredText `_, Python bindings do not work on macOS machines with Apple silicon (M1 and M2 processors). Prior to ns-3.37, the previous Python bindings framework was based on `Pybindgen `_. diff --git a/doc/manual/source/utilities.rst b/doc/manual/source/utilities.rst index 9c6421580..491e58da1 100644 --- a/doc/manual/source/utilities.rst +++ b/doc/manual/source/utilities.rst @@ -33,7 +33,7 @@ search for specific information. To run it, simply open terminal and type -.. sourcecode:: +.. sourcecode:: bash $ ./ns3 run print-introspected-doxygen @@ -78,7 +78,7 @@ This tool is used to benchmark the scheduler algorithms used in |ns3|. Command-line Arguments ++++++++++++++++++++++ -.. sourcecode:: +.. sourcecode:: bash $ ./ns3 run "bench-scheduler --help" bench-scheduler [Program Options] [General Arguments] @@ -129,7 +129,7 @@ Invocation To run it, simply open the terminal and type -.. sourcecode:: +.. sourcecode:: bash $ ./ns3 run bench-scheduler -- --runs=5 @@ -156,7 +156,7 @@ It will show something like this depending upon the scheduler being benchmarked: Suppose we had to benchmark `CalendarScheduler` instead, we would have written -.. sourcecode:: +.. sourcecode:: bash $ ./ns3 run bench-scheduler -- --runs=5 --cal" diff --git a/doc/manual/source/working-with-cmake.rst b/doc/manual/source/working-with-cmake.rst index e630ef9a4..562ecd063 100644 --- a/doc/manual/source/working-with-cmake.rst +++ b/doc/manual/source/working-with-cmake.rst @@ -125,7 +125,7 @@ Now we run it for real: -- Processing src/wimax -- ---- Summary of optional ns-3 features: Build profile : release - Build directory : /mnt/dev/tools/source/ns-3-dev/build + Build directory : /ns-3-dev/build ... Examples : ON ... @@ -147,7 +147,7 @@ Now we run it for real: -- Configuring done -- Generating done - -- Build files have been written to: /mnt/dev/tools/source/ns-3-dev/cmake-cache + -- Build files have been written to: /ns-3-dev/cmake-cache Finished executing the following commands: mkdir cmake-cache cd cmake-cache; /usr/bin/cmake -DCMAKE_BUILD_TYPE=release -DNS3_NATIVE_OPTIMIZATIONS=OFF -DNS3_EXAMPLES=ON -DNS3_TESTS=ON -G Unix Makefiles .. ; cd .. @@ -357,7 +357,7 @@ calling the underlying build system (e.g. Ninja) directly. The last way is omitted, since each underlying build system has its own unique command-line syntax. -Building the project with n``s3`` +Building the project with ``ns3`` +++++++++++++++++++++++++++++++++ The ``ns3`` wrapper script makes life easier for command line users, accepting module names without @@ -819,6 +819,11 @@ If you do not want to link the library against all the targets More details on how find_external_library works and the other ways to import third-party libraries are presented next. +It is recommended to use a system package managers to install libraries, +but ns-3 also supports vcpkg and CPM. More information on how to +use them is available in `Using C++ library managers`_. + + .. _Linking third-party libraries without CMake or PkgConfig support: Linking third-party libraries without CMake or PkgConfig support @@ -1203,7 +1208,7 @@ Linking third-party libraries using CMake's find_package Assume we have a module with optional features that rely on a third-party library that provides a FindThirdPartyPackage.cmake. This ``Find${Package}.cmake`` file can be distributed by `CMake itself`_, via library/package managers (APT, Pacman, -`VcPkg`_), or included to the project tree in the build-support/3rd-party directory. +`vcpkg`_), or included to the project tree in the build-support/3rd-party directory. .. _CMake itself: https://github.com/Kitware/CMake/tree/master/Modules .. _Vcpkg: https://github.com/Microsoft/vcpkg#using-vcpkg-with-cmake @@ -1494,7 +1499,543 @@ source files similarly to the previous cases, as shown in the example below: test/hypothetical.cc ) +.. _Using C++ library managers: +Using C++ library managers +++++++++++++++++++++++++++ + +It is not rare to try using a library that is not available +on a certain platform or does not have a CMake-friendly +interface for us to use. + +.. _CPM: https://github.com/cpm-cmake/CPM.cmake + +Some C++ package managers are fairly easy to use with CMake, +such as `Vcpkg`_ and `CPM`_. + +vcpkg +===== + +Vcpkg requires ``git``, ``curl``, ``zip``, ``unzip`` and ``tar``, +along with the default ns-3 dependencies. The setup downloads +and builds vcpkg from their Git repository. Telemetry is disabled +by default. + +.. sourcecode:: console + + ~$ ./ns3 configure -- -DNS3_VCPKG=ON + ... + -- vcpkg: setting up support + Cloning into 'vcpkg'... + Updating files: 100% (10376/10376), done. + Downloading vcpkg-glibc... + vcpkg package management program version 2023-07-19-814b7ec837b59f1c8778f72351c1dd7605983cd2 + ... + +Configuration will finish successfully. +For example, now we can try using the Armadillo library. +To do that, we use the following CMake statements: + +.. sourcecode:: cmake + + # Check this is not a fluke + find_package(Armadillo) + message(STATUS "Armadillo was found? ${ARMADILLO_FOUND}") + +Reconfigure ns-3 to check if Armadillo is available. + +.. sourcecode:: console + + ~$ ./ns3 configure + ... + -- vcpkg: setting up support + -- vcpkg: folder already exists, skipping git download + -- vcpkg: already bootstrapped + ... + -- Could NOT find Armadillo (missing: ARMADILLO_INCLUDE_DIR) + -- Armadillo was found? FALSE + +As you can see, no Armadillo found. +We can now use vcpkg to install it, using the CMake +function ``add_package(package_name)``. CMake +will then be able to find the installed package using ``find_package``. + +Note: some packages may require additional dependencies. +The Armadillo package requires ``pkg-config`` and a fortran compiler. +You will be prompted with a CMake error when a missing dependency is found. + +.. sourcecode:: cmake + + # Install Armadillo and search for it again + add_package(Armadillo) # Installs Armadillo with vcpkg + find_package(Armadillo) # Loads vcpkg installation of Armadillo + message(STATUS "Armadillo was found? ${ARMADILLO_FOUND}") + +Sadly, we will need to reconfigure ns-3 from the scratch, +since CMake ``find_package`` caches are problematic. +Installing the packages can take a while, and it can look like it hanged. + +.. sourcecode:: console + + ~$ ./ns3 clean + ~$ ./ns3 configure -- -DNS3_VCPKG=ON + ... + -- vcpkg: setting up support + -- vcpkg: folder already exists, skipping git download + -- vcpkg: already bootstrapped + ... + -- vcpkg: Armadillo will be installed + -- vcpkg: Armadillo was installed + -- Armadillo was found? TRUE + +As shown above, the Armadillo library gets installed by vcpkg +and it can be found by CMake's ``find_package`` function. +We can then use it for our targets. + +.. sourcecode:: cmake + + # Install Armadillo + add_package(Armadillo) # Installs Armadillo with vcpkg + find_package(Armadillo) # Loads vcpkg installation of Armadillo + message(STATUS "Armadillo was found? ${ARMADILLO_FOUND}") + + # Include and link Armadillo to targets + include_directories(${ARMADILLO_INCLUDE_DIRS}) + link_libraries(${ARMADILLO_LIBRARIES}) + +.. _vcpkg manifests: https://learn.microsoft.com/en-us/vcpkg/users/manifests + +An alternative to manually installing packages with ``add_package`` is +placing all packages into a ``vcpkg.json`` file in the ns-3 main directory. +This mode is known as the "manifest mode" in the Vcpkg manual. +Packages there will be automatically installed at the beginning of the configuration. +More information about the manifest mode can be found in `vcpkg manifests`_ website. + +Let us see an example of this mode starting with the ``vcpkg.json`` file. + +.. sourcecode:: json + + { + "dependencies": [ + "sqlite3", + "eigen3", + "libxml2", + "gsl", + "boost-units" + ] + } + +These are some of the optional dependencies used by the upstream ns-3 modules. +When configuring ns-3 with the Vcpkg support, we will see the following. + +.. sourcecode:: console + + /ns-3-dev$ ./ns3 clean + /ns-3-dev$ ./ns3 configure -- -DNS3_VCPKG=ON + ... + -- vcpkg: setting up support + Cloning into 'vcpkg'... + Updating files: 100% (10434/10434), done. + Downloading vcpkg-glibc... + vcpkg package management program version 2023-08-02-6d13efa755f9b5e101712d210199e4139b4c29f6 + + See LICENSE.txt for license information. + -- vcpkg: detected a vcpkg manifest file: /ns-3-dev/vcpkg.json + A suitable version of cmake was not found (required v3.27.1) Downloading portable cmake 3.27.1... + Downloading cmake... + https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-linux-x86_64.tar.gz->/ns-3-dev/vcpkg/downloads/cmake-3.27.1-linux-x86_64.tar.gz + Extracting cmake... + Detecting compiler hash for triplet x64-linux... + The following packages will be built and installed: + * boost-array:x64-linux -> 1.82.0#2 + ... + * boost-winapi:x64-linux -> 1.82.0#2 + eigen3:x64-linux -> 3.4.0#2 + gsl:x64-linux -> 2.7.1#3 + * libiconv:x64-linux -> 1.17#1 + * liblzma:x64-linux -> 5.4.3#1 + libxml2[core,iconv,lzma,zlib]:x64-linux -> 2.10.3#1 + sqlite3[core,json1]:x64-linux -> 3.42.0#1 + * vcpkg-cmake:x64-linux -> 2023-05-04 + * vcpkg-cmake-config:x64-linux -> 2022-02-06#1 + * vcpkg-cmake-get-vars:x64-linux -> 2023-03-02 + * zlib:x64-linux -> 1.2.13 + Additional packages (*) will be modified to complete this operation. + Restored 0 package(s) from /root/.cache/vcpkg/archives in 98.7 us. Use --debug to see more details. + Installing 1/58 boost-uninstall:x64-linux... + ... + Installing 50/58 boost-units:x64-linux... + Building boost-units:x64-linux... + -- Downloading https://github.com/boostorg/units/archive/boost-1.82.0.tar.gz -> boostorg-units-boost-1.82.0.tar.gz... + -- Extracting source /ns-3-dev/vcpkg/downloads/boostorg-units-boost-1.82.0.tar.gz + -- Using source at /ns-3-dev/vcpkg/buildtrees/boost-units/src/ost-1.82.0-a9fdcc40b2.clean + -- Copying headers + -- Copying headers done + -- Installing: /ns-3-dev/vcpkg/packages/boost-units_x64-linux/share/boost-units/usage + -- Installing: /ns-3-dev/vcpkg/packages/boost-units_x64-linux/share/boost-units/copyright + -- Performing post-build validation + Stored binaries in 1 destinations in 276 ms. + Elapsed time to handle boost-units:x64-linux: 3.8 s + Installing 51/58 vcpkg-cmake-config:x64-linux... + Building vcpkg-cmake-config:x64-linux... + -- Installing: /ns-3-dev/vcpkg/packages/vcpkg-cmake-config_x64-linux/share/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake + -- Installing: /ns-3-dev/vcpkg/packages/vcpkg-cmake-config_x64-linux/share/vcpkg-cmake-config/vcpkg-port-config.cmake + -- Installing: /ns-3-dev/vcpkg/packages/vcpkg-cmake-config_x64-linux/share/vcpkg-cmake-config/copyright + -- Performing post-build validation + Stored binaries in 1 destinations in 8.58 ms. + Elapsed time to handle vcpkg-cmake-config:x64-linux: 144 ms + Installing 52/58 eigen3:x64-linux... + Building eigen3:x64-linux... + -- Downloading https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz -> libeigen-eigen-3.4.0.tar.gz... + -- Extracting source /ns-3-dev/vcpkg/downloads/libeigen-eigen-3.4.0.tar.gz + -- Applying patch remove_configure_checks.patch + -- Applying patch fix-vectorized-reductions-half.patch + -- Using source at /ns-3-dev/vcpkg/buildtrees/eigen3/src/3.4.0-74a8d62212.clean + -- Configuring x64-linux + -- Building x64-linux-dbg + -- Building x64-linux-rel + -- Fixing pkgconfig file: /ns-3-dev/vcpkg/packages/eigen3_x64-linux/lib/pkgconfig/eigen3.pc + CMake Error at scripts/cmake/vcpkg_find_acquire_program.cmake:163 (message): + Could not find pkg-config. Please install it via your package manager: + + sudo apt-get install pkg-config + Call Stack (most recent call first): + scripts/cmake/vcpkg_fixup_pkgconfig.cmake:203 (vcpkg_find_acquire_program) + ports/eigen3/portfile.cmake:30 (vcpkg_fixup_pkgconfig) + scripts/ports.cmake:147 (include) + + + error: building eigen3:x64-linux failed with: BUILD_FAILED + Elapsed time to handle eigen3:x64-linux: 19 s + Please ensure you're using the latest port files with `git pull` and `vcpkg update`. + Then check for known issues at: + https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+eigen3 + You can submit a new issue at: + https://github.com/microsoft/vcpkg/issues/new?title=[eigen3]+Build+error&body=Copy+issue+body+from+%2Fns-3-dev%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md + + CMake Error at build-support/3rd-party/colored-messages.cmake:82 (_message): + vcpkg: packages defined in the manifest failed to be installed + Call Stack (most recent call first): + build-support/custom-modules/ns3-vcpkg-hunter.cmake:138 (message) + build-support/custom-modules/ns3-vcpkg-hunter.cmake:183 (setup_vcpkg) + build-support/macros-and-definitions.cmake:743 (include) + CMakeLists.txt:149 (process_options) + +As we can see above, the setup failed during the eigen3 setup due to a missing dependency. +In this case, pkg-config. We can install it using the system package manager and then +resume the ns-3 configuration. + + +.. sourcecode:: console + + /ns-3-dev$ apt install -y pkg-config + /ns-3-dev$ ./ns3 configure -- -DNS3_VCPKG=ON + ... + -- vcpkg: folder already exists, skipping git download + -- vcpkg: already bootstrapped + -- vcpkg: detected a vcpkg manifest file: /ns-3-dev/vcpkg.json + Detecting compiler hash for triplet x64-linux... + The following packages will be built and installed: + eigen3:x64-linux -> 3.4.0#2 + gsl:x64-linux -> 2.7.1#3 + * libiconv:x64-linux -> 1.17#1 + * liblzma:x64-linux -> 5.4.3#1 + libxml2[core,iconv,lzma,zlib]:x64-linux -> 2.10.3#1 + sqlite3[core,json1]:x64-linux -> 3.42.0#1 + * zlib:x64-linux -> 1.2.13 + Additional packages (*) will be modified to complete this operation. + Restored 0 package(s) from /root/.cache/vcpkg/archives in 97.6 us. Use --debug to see more details. + Installing 1/7 eigen3:x64-linux... + Building eigen3:x64-linux... + -- Using cached libeigen-eigen-3.4.0.tar.gz. + -- Cleaning sources at /ns-3-dev/vcpkg/buildtrees/eigen3/src/3.4.0-74a8d62212.clean. Use --editable to skip cleaning for the packages you specify. + -- Extracting source /ns-3-dev/vcpkg/downloads/libeigen-eigen-3.4.0.tar.gz + -- Applying patch remove_configure_checks.patch + -- Applying patch fix-vectorized-reductions-half.patch + -- Using source at /ns-3-dev/vcpkg/buildtrees/eigen3/src/3.4.0-74a8d62212.clean + -- Configuring x64-linux + -- Building x64-linux-dbg + -- Building x64-linux-rel + -- Fixing pkgconfig file: /ns-3-dev/vcpkg/packages/eigen3_x64-linux/lib/pkgconfig/eigen3.pc + -- Fixing pkgconfig file: /ns-3-dev/vcpkg/packages/eigen3_x64-linux/debug/lib/pkgconfig/eigen3.pc + -- Installing: /ns-3-dev/vcpkg/packages/eigen3_x64-linux/share/eigen3/copyright + -- Performing post-build validation + Stored binaries in 1 destinations in 1.7 s. + Elapsed time to handle eigen3:x64-linux: 28 s + Installing 2/7 gsl:x64-linux... + ... + Installing 7/7 sqlite3:x64-linux... + Building sqlite3[core,json1]:x64-linux... + -- Downloading https://sqlite.org/2023/sqlite-amalgamation-3420000.zip -> sqlite-amalgamation-3420000.zip... + -- Extracting source /ns-3-dev/vcpkg/downloads/sqlite-amalgamation-3420000.zip + -- Applying patch fix-arm-uwp.patch + -- Applying patch add-config-include.patch + -- Using source at /ns-3-dev/vcpkg/buildtrees/sqlite3/src/on-3420000-e624a7f335.clean + -- Configuring x64-linux + -- Building x64-linux-dbg + -- Building x64-linux-rel + -- Fixing pkgconfig file: /ns-3-dev/vcpkg/packages/sqlite3_x64-linux/lib/pkgconfig/sqlite3.pc + -- Fixing pkgconfig file: /ns-3-dev/vcpkg/packages/sqlite3_x64-linux/debug/lib/pkgconfig/sqlite3.pc + -- Installing: /ns-3-dev/vcpkg/packages/sqlite3_x64-linux/share/sqlite3/usage + -- Performing post-build validation + Stored binaries in 1 destinations in 430 ms. + Elapsed time to handle sqlite3:x64-linux: 42 s + Total install time: 2.5 min + The package boost is compatible with built-in CMake targets: + + find_package(Boost REQUIRED [COMPONENTS ...]) + target_link_libraries(main PRIVATE Boost::boost Boost:: Boost:: ...) + + eigen3 provides CMake targets: + + # this is heuristically generated, and may not be correct + find_package(Eigen3 CONFIG REQUIRED) + target_link_libraries(main PRIVATE Eigen3::Eigen) + + The package gsl is compatible with built-in CMake targets: + + find_package(GSL REQUIRED) + target_link_libraries(main PRIVATE GSL::gsl GSL::gslcblas) + + The package libxml2 is compatible with built-in CMake targets: + + find_package(LibXml2 REQUIRED) + target_link_libraries(main PRIVATE LibXml2::LibXml2) + + sqlite3 provides pkgconfig bindings. + sqlite3 provides CMake targets: + + find_package(unofficial-sqlite3 CONFIG REQUIRED) + target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3) + + -- vcpkg: packages defined in the manifest were installed + -- find_external_library: SQLite3 was found. + ... + -- LibXML2 was found. + ... + -- Found Boost: /ns-3-dev/vcpkg/installed/x64-linux/include (found version "1.82.0") + ... + -- Looking for include files boost/units/quantity.hpp, boost/units/systems/si.hpp + -- Looking for include files boost/units/quantity.hpp, boost/units/systems/si.hpp - found + -- Boost Units have been found. + ... + -- ---- Summary of ns-3 settings: + Build profile : default + Build directory : /ns-3-dev/build + Build with runtime asserts : ON + ... + GNU Scientific Library (GSL) : ON + ... + LibXml2 support : ON + ... + SQLite support : ON + Eigen3 support : ON + ... + +From the above, we can see that the headers and libraries installed by the packages +were correctly found by CMake and the optional features were successfully enabled. + +.. _Armadillo's port on vcpkg: https://github.com/microsoft/vcpkg/blob/master/ports/armadillo/usage + +Note: not every vcpkg package (also known as a port) obeys +the same pattern for usage. The user of the package needs +to look into the usage file of said port for instructions. +In the case of Armadillo, the corresponding file can be found +in `Armadillo's port on vcpkg`_. + +Vcpkg is installed to a ``vcpkg`` directory inside the ns-3 main directory (e.g. ``ns-3-dev``). +Packages installed via vcpkg are installed to ``ns-3-dev/vcpkg/installed/${VCPKG_TRIPLET}``, +which is automatically added to the ``CMAKE_PREFIX_PATH``, making headers, libraries, and +pkg-config and CMake packages discoverable via ``find_file``, ``find_library``, ``find_package`` +and ``pkg_check_modules``. + +CPM +=== + +`CPM`_ is a package manager made for CMake projects consuming CMake projects. +Some CMake projects however, create files during the installation step, which +is not supported by CPM, which treats the package as a CMake subproject that +we can then depend upon. CPM may require dependencies such as ``git`` and ``tar``, +depending on the package sources used. + +Let's see an example trying to find the Armadillo library via CMake. + +.. sourcecode:: cmake + + # Check this is not a fluke + find_package(Armadillo) + message(STATUS "Armadillo was found? ${ARMADILLO_FOUND}") + +Reconfigure ns-3 to check if Armadillo is available. + +.. sourcecode:: console + + ~$ ./ns3 configure + ... + -- Could NOT find Armadillo (missing: ARMADILLO_INCLUDE_DIR) + -- Armadillo was found? FALSE + +As you can see, no Armadillo found. +We can now use CPM to install it, using the CMake +function ``CPMAddPackage(package_info)``. + +.. sourcecode:: cmake + + # Install Armadillo and search for it again + CPMAddPackage( + NAME ARMADILLO + GIT_TAG 6cada351248c9a967b137b9fcb3d160dad7c709b + GIT_REPOSITORY https://gitlab.com/conradsnicta/armadillo-code.git + ) + find_package(Armadillo) # Loads CPM installation of Armadillo + message(STATUS "Armadillo was found? ${ARMADILLO_FOUND}") + +Sadly, we will need to reconfigure ns-3 from the scratch, +since CMake ``find_package`` caches are problematic. +Installing the packages can take a while, and it can look like it hanged. + +.. sourcecode:: console + + ~$ ./ns3 clean + ~$ ./ns3 configure -- -DNS3_CPM=ON + ... + -- CPM: Adding package ARMADILLO@0 (6cada351248c9a967b137b9fcb3d160dad7c709b) + -- *** set cmake policy CMP0025 to NEW + -- CMAKE_CXX_STANDARD = 11 + -- Configuring Armadillo 12.6.1 + -- + -- *** WARNING: variable 'CMAKE_CXX_FLAGS' is not empty; this may cause problems! + -- + -- Detected Clang 6.0 or newer + -- ARMA_USE_EXTERN_RNG = true + -- CMAKE_SYSTEM_NAME = Linux + -- CMAKE_CXX_COMPILER_ID = Clang + -- CMAKE_CXX_COMPILER_VERSION = 15.0.7 + -- CMAKE_COMPILER_IS_GNUCXX = + -- + -- *** Options: + -- BUILD_SHARED_LIBS = ON + -- OPENBLAS_PROVIDES_LAPACK = OFF + -- ALLOW_FLEXIBLAS_LINUX = ON + -- ALLOW_OPENBLAS_MACOS = OFF + -- ALLOW_BLAS_LAPACK_MACOS = OFF + -- BUILD_SMOKE_TEST = ON + -- + -- *** Looking for external libraries + -- Found OpenBLAS: /usr/lib/x86_64-linux-gnu/libopenblas.so + -- Found BLAS: /usr/lib/x86_64-linux-gnu/libblas.so + -- Found LAPACK: /usr/lib/x86_64-linux-gnu/liblapack.so + -- FlexiBLAS_FOUND = NO + -- MKL_FOUND = NO + -- OpenBLAS_FOUND = YES + -- ATLAS_FOUND = NO + -- BLAS_FOUND = YES + -- LAPACK_FOUND = YES + -- + -- *** NOTE: found both OpenBLAS and BLAS; BLAS will not be used + -- + -- *** NOTE: if OpenBLAS is known to provide LAPACK functions, recommend to + -- *** NOTE: rerun cmake with the OPENBLAS_PROVIDES_LAPACK option enabled: + -- *** NOTE: cmake -D OPENBLAS_PROVIDES_LAPACK=true . + -- + -- *** If the OpenBLAS library is installed in + -- *** /usr/local/lib or /usr/local/lib64 + -- *** make sure the run-time linker can find it. + -- *** On Linux systems this can be done by editing /etc/ld.so.conf + -- *** or modifying the LD_LIBRARY_PATH environment variable. + -- + -- Found ARPACK: /usr/lib/x86_64-linux-gnu/libarpack.so + -- ARPACK_FOUND = YES + -- Looking for SuperLU version 5 + -- Found SuperLU: /usr/lib/x86_64-linux-gnu/libsuperlu.so + -- SuperLU_FOUND = YES + -- SuperLU_INCLUDE_DIR = /usr/include/superlu + -- + -- *** Result of configuration: + -- *** ARMA_USE_WRAPPER = true + -- *** ARMA_USE_LAPACK = true + -- *** ARMA_USE_BLAS = true + -- *** ARMA_USE_ATLAS = false + -- *** ARMA_USE_ARPACK = true + -- *** ARMA_USE_EXTERN_RNG = true + -- *** ARMA_USE_SUPERLU = true + -- + -- *** Armadillo wrapper library will use the following libraries: + -- *** ARMA_LIBS = /usr/lib/x86_64-linux-gnu/libopenblas.so;/usr/lib/x86_64-linux-gnu/liblapack.so;/usr/lib/x86_64-linux-gnu/libarpack.so;/usr/lib/x86_64-linux-gnu/libsuperlu.so + -- + -- Copying /ns-3-dev/cmake-build-release/_deps/armadillo-src/include/ to /ns-3-dev/cmake-build-release/_deps/armadillo-build/tmp/include/ + -- Generating /ns-3-dev/cmake-build-release/_deps/armadillo-build/tmp/include/config.hpp + -- CMAKE_CXX_FLAGS = -fsanitize=address,leak,undefined -O2 + -- CMAKE_SHARED_LINKER_FLAGS = -Wl,--no-as-needed + -- CMAKE_REQUIRED_INCLUDES = /usr/include;/usr/include/superlu + -- + -- CMAKE_INSTALL_PREFIX = /usr + -- CMAKE_INSTALL_LIBDIR = lib/x86_64-linux-gnu + -- CMAKE_INSTALL_INCLUDEDIR = include + -- CMAKE_INSTALL_DATADIR = share + -- CMAKE_INSTALL_BINDIR = bin + -- Generating '/ns-3-dev/cmake-build-release/_deps/armadillo-build/ArmadilloConfig.cmake' + -- Generating '/ns-3-dev/cmake-build-release/_deps/armadillo-build/ArmadilloConfigVersion.cmake' + -- Generating '/ns-3-dev/cmake-build-release/_deps/armadillo-build/InstallFiles/ArmadilloConfig.cmake' + -- Generating '/ns-3-dev/cmake-build-release/_deps/armadillo-build/InstallFiles/ArmadilloConfigVersion.cmake' + -- Copying /ns-3-dev/cmake-build-release/_deps/armadillo-src/misc/ to /ns-3-dev/cmake-build-release/_deps/armadillo-build/tmp/misc/ + -- Generating '/ns-3-dev/cmake-build-release/_deps/armadillo-build/tmp/misc/armadillo.pc' + -- *** configuring smoke_test + -- Armadillo was found? TRUE + ... + +As shown above, the Armadillo library gets installed by CPM +and it can be found by CMake's ``find_package`` function. +Differently from other packages found via ``find_package``, +CPM creates native CMake targets from the subprojects. +In the case of Armadillo, the target is called ``armadillo``, +which we can link to our targets. + +.. sourcecode:: cmake + + # Install Armadillo + CPMAddPackage( + NAME ARMADILLO + GIT_TAG 6cada351248c9a967b137b9fcb3d160dad7c709b + GIT_REPOSITORY https://gitlab.com/conradsnicta/armadillo-code.git + ) + find_package(Armadillo) # Loads CPM installation of Armadillo + message(STATUS "Armadillo was found? ${ARMADILLO_FOUND}") + + # CPM is kind of jenky. It could get the ARMADILLO_INCLUDE_DIRS + # from the ArmadilloConfig.cmake file in ${CMAKE_BINARY_DIR}/_deps/armadillo-build, + # but it doesn't... So add its include directories directly from the source directory + include_directories(${CMAKE_BINARY_DIR}/_deps/armadillo-src/include) + + # Link to Armadillo and + link_libraries(armadillo) + +.. _`CPM's examples`: https://github.com/cpm-cmake/CPM.cmake/wiki/More-Snippets + +Note: using CPM can be challenging. Users are recommended +to look at `CPM's examples`_. + +For example, the libraries of installed packages will be placed by default in +the ``ns-3-dev/build/lib`` directory. On the other hand, header placement depends +on how the CMake project was setup. + +If the package CMakeLists.txt was made to build in-source, headers will be +along the source files, which will be placed in +``${PROJECT_BINARY_DIR}/_deps/packageName-src``. When configured with the +ns3 script, ``PROJECT_BINARY_DIR corresponds`` to ``ns-3-dev/cmake-cache``. + +If the package CMakeLists.txt copies the headers to an output directory +(like ns-3 does), it will be placed in +``${PROJECT_BINARY_DIR}/_deps/packageName-build``, +possibly in an ``include`` subdirectory. + +In case it was configured to copy the headers to ``${CMAKE_BINARY_DIR}/include``, +the headers will land on ``${PROJECT_BINARY_DIR}/include`` of the most top-level +project. In our case, the top-level project is the NS3 project. + +Since the packages get installed into the ns-3 cache directory +(``PROJECT_BINARY_DIR``), using ``./ns3 clean`` will delete them, +requiring them to be rebuilt. Inclusion of options ++++++++++++++++++++ diff --git a/doc/models/Makefile b/doc/models/Makefile index d93c9b75f..2f9405c7e 100644 --- a/doc/models/Makefile +++ b/doc/models/Makefile @@ -360,7 +360,13 @@ SOURCEFIGS = \ $(SRC)/lr-wpan/doc/lr-wpan-primitives.dia \ $(SRC)/lr-wpan/doc/802-15-4-ber.eps \ $(SRC)/lr-wpan/doc/802-15-4-per-sens.eps \ - $(SRC)/lr-wpan/doc/802-15-4-psr-distance.eps + $(SRC)/lr-wpan/doc/802-15-4-psr-distance.eps \ + $(SRC)/energy/doc/figures/dischargeCurve.png \ + $(SRC)/energy/doc/figures/energyFramework.dia \ + $(SRC)/energy/doc/figures/leadacid.png \ + $(SRC)/energy/doc/figures/liion.png \ + $(SRC)/energy/doc/figures/nicd.png \ + $(SRC)/energy/doc/figures/nimh.png # specify figures from which .png and .pdf figures need to be # generated (all dia and eps figures) @@ -457,6 +463,7 @@ IMAGES_EPS = \ $(FIGURES)/802-15-4-ber.eps \ $(FIGURES)/802-15-4-per-sens.eps \ $(FIGURES)/802-15-4-psr-distance.eps \ + $(FIGURES)/energyFramework.eps \ $(FIGURES)/clear-channel.eps \ $(FIGURES)/assoc-manager.eps \ $(FIGURES)/nist-frame-success-rate.eps \ diff --git a/doc/models/source/conf.py b/doc/models/source/conf.py index 76c3b5145..642cc2eeb 100644 --- a/doc/models/source/conf.py +++ b/doc/models/source/conf.py @@ -73,9 +73,9 @@ copyright = u'2006-2019' # built documents. # # The short X.Y version. -version = u'ns-3.39' +version = u'ns-3.40' # The full version, including alpha/beta/rc tags. -release = u'ns-3.39' +release = u'ns-3.40' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/models/source/index.rst b/doc/models/source/index.rst index 382f7b9ca..205b92d40 100644 --- a/doc/models/source/index.rst +++ b/doc/models/source/index.rst @@ -25,6 +25,7 @@ from the ``doc/`` directory of each module. Source file column width is 100 col .. toctree:: :maxdepth: 1 + :numbered: organization animation diff --git a/doc/ns3_html_theme/layout.html b/doc/ns3_html_theme/layout.html index 0140ac840..54f809460 100644 --- a/doc/ns3_html_theme/layout.html +++ b/doc/ns3_html_theme/layout.html @@ -38,7 +38,7 @@ - ns-3 Logo diff --git a/doc/ns3_html_theme/static/ns3_stylesheet.css b/doc/ns3_html_theme/static/ns3_stylesheet.css index 4f934f761..e29ba9ce8 100644 --- a/doc/ns3_html_theme/static/ns3_stylesheet.css +++ b/doc/ns3_html_theme/static/ns3_stylesheet.css @@ -5,36 +5,14 @@ table, div, p, dl { - color: black; - font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; - font-size: 12px; -} - -/* Dark mode is not supported in Doxygen versions earlier than 1.9.6 */ -@media (prefers-color-scheme: dark) { - body, - table, - div, - p, - dl, - div.body, - div.sphinxsidebar h3, - div.sphinxsidebar h4 , - div.sphinxsidebar h3 a{ - color: ivory; - background:black; - } - div.sphinxsidebar input{ - background: #2c2d24; - } - div.related{ - background-image: linear-gradient(to bottom, #66696a 0%, transparent 80%); - } + color: black; + font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size: 12px; } a { - color: #91A501; - font-weight: bold; + color: #91A501; + font-weight: bold; } /* Sphinx headings */ @@ -51,16 +29,16 @@ div.body h6 { /* Sphinx figure captions */ p.caption { - font-weight: bold; + font-weight: bold; } /* Doxygen side bar */ #nav-tree { - font-size: 12px; + font-size: 12px; } #nav-tree a { - font-weight: normal; + font-weight: normal; } /* Sphinx nav links bar (relbar) */ @@ -71,87 +49,87 @@ div.related { */ div.related h3 { - display: none; + display: none; } div.related a { - color: #91A501; - font-size: 14px; - font-weight: bold; + color: #91A501; + font-size: 14px; + font-weight: bold; } div.related li { - background-image: url('bc_s.png'); - background-position: 100% 40%; - background-repeat: no-repeat; - padding-left: 10px; - padding-right: 15px; + background-image: url('bc_s.png'); + background-position: 100% 40%; + background-repeat: no-repeat; + padding-left: 10px; + padding-right: 15px; } div.related li.right { - background-image: none; - padding-left: 0px; - padding-right: 0px; + background-image: none; + padding-left: 0px; + padding-right: 0px; } /* Sphinx side bar */ div.sphinxsidebar { - font-size: 12px; + font-size: 12px; } div.sphinxsidebar a { - font-weight: normal; + font-weight: normal; } /* Title bar elements */ #titlearea { - background-image: url('bar-top.png'); - background-repeat: repeat; - border-bottom: 1px solid #5B5B5B; - color: white; - position: relative; - /* Doxygen tab bar ("Main Page", "Related Pages"..) is at z: 9999 */ - z-index: 10000; + background-image: url('bar-top.png'); + background-repeat: repeat; + border-bottom: 1px solid #5B5B5B; + color: white; + position: relative; + /* Doxygen tab bar ("Main Page", "Related Pages"..) is at z: 9999 */ + z-index: 10000; } #projectlogo { - color: white; - margin: 10px; - text-align: center; - vertical-align: middle; - width: 220px; + color: white; + margin: 10px; + text-align: center; + vertical-align: middle; + width: 220px; } #projecttext { - text-align: left; - color: white; - padding-left: 2em; - width: 250px; + text-align: left; + color: white; + padding-left: 2em; + width: 250px; } #projectbrief { - color: white; - font: 120% Tahoma, Arial, sans-serif; - margin: 0px; - padding: 0px; + color: white; + font: 120% Tahoma, Arial, sans-serif; + margin: 0px; + padding: 0px; } #projectnumber { - color: white; - font: 100% Tahoma, Arial, sans-serif; - margin: 0px; - padding: 0px; + color: white; + font: 100% Tahoma, Arial, sans-serif; + margin: 0px; + padding: 0px; } #projectsection { - color: white; - font: 24pt Aldo, Tahoma, Arial, sans-serif; - margin-right: 10px; - margin: 10px; - text-align: right; - vertical-align: middle; + color: white; + font: 24pt Aldo, Tahoma, Arial, sans-serif; + margin-right: 10px; + margin: 10px; + text-align: right; + vertical-align: middle; } /* @@ -162,86 +140,217 @@ div.sphinxsidebar a { */ #ns3-menu .menu { - background-image: url('menu-bgr-400.png'); - /* background-origin: padding-box; */ - /* background-position: -10px 0; */ - background-repeat: no-repeat; - background-size: 100% 39px; - display: table-cell; - float: left; - height: 40px; - margin: 0px 0px 0px 0px; - padding: 0px 0px 0px 0px; - vertical-align: middle; + background-image: url('menu-bgr-400.png'); + /* background-origin: padding-box; */ + /* background-position: -10px 0; */ + background-repeat: no-repeat; + background-size: 100% 39px; + display: table-cell; + float: left; + height: 40px; + margin: 0px 0px 0px 0px; + padding: 0px 0px 0px 0px; + vertical-align: middle; } #ns3-menu .menu ul { - /* float:left; */ - height: 40; - list-style: none; - margin: 0px 0px 0px -2px; - /* overflow:hidden; */ - padding: 0px 0px 0px 0px; - z-index: 30; + /* float:left; */ + height: 40; + list-style: none; + margin: 0px 0px 0px -2px; + /* overflow:hidden; */ + padding: 0px 0px 0px 0px; + z-index: 30; } #ns3-menu .menu ul li { - background-image: url('ver.png'); - background-origin: padding-box; - background-position: 0 11px; - background-repeat: no-repeat; - color: #ffffff; - float: left; - font-family: Aldo, Tahoma, Arial, sans-serif; - font-size: 14px; - /* height:40px; */ - margin: 0px 0px 0px 0px; - /* overflow:hidden; */ - padding: 11px 13px 0px 12px; - text-transform: uppercase; + background-image: url('ver.png'); + background-origin: padding-box; + background-position: 0 11px; + background-repeat: no-repeat; + color: #ffffff; + float: left; + font-family: Aldo, Tahoma, Arial, sans-serif; + font-size: 14px; + /* height:40px; */ + margin: 0px 0px 0px 0px; + /* overflow:hidden; */ + padding: 11px 13px 0px 12px; + text-transform: uppercase; } #ns3-menu .menu ul li a { - color: #ffffff; - /* cursor: pointer; */ - display: block; - float: left; - font-weight: normal; - /* default anchors are bold */ - text-decoration: none; - /* default anchors are underlined */ + color: #ffffff; + /* cursor: pointer; */ + display: block; + float: left; + font-weight: normal; + /* default anchors are bold */ + text-decoration: none; + /* default anchors are underlined */ } #ns3-menu .menu ul li a:hover { - color: #cadc48; - text-decoration: none; - /* don't add underline on hover */ + color: #cadc48; + text-decoration: none; + /* don't add underline on hover */ } #ns3-menu .menu div { - background: #94A901; - background-size: 100%; - color: #ffffff; - position: absolute; - visibility: hidden; + background: #94A901; + background-size: 100%; + color: #ffffff; + position: absolute; + visibility: hidden; } #ns3-menu .menu div a { - position: relative; - display: block; - float: left; - font-family: Aldo, Tahoma, Arial, sans-serif; - font-size: 14px; - margin: 0; - padding: 5px 10px; - text-align: left; - width: auto; - white-space: nowrap; + position: relative; + display: block; + float: left; + font-family: Aldo, Tahoma, Arial, sans-serif; + font-size: 14px; + margin: 0; + padding: 5px 10px; + text-align: left; + width: auto; + white-space: nowrap; } #ns3-menu .menu div a:hover { - color: #cadc48; - text-decoration: none; - /* don't add underline on hover */ + color: #cadc48; + text-decoration: none; + /* don't add underline on hover */ +} + +/* Dark mode is not supported in Doxygen versions earlier than 1.9.6 */ +@media (prefers-color-scheme: dark) { + a { + color: #cfde63; + } + + a:visited { + color: #91A501; + } + + body, + table, + div, + p, + dl, + div.body, + div.sphinxsidebar h3, + div.sphinxsidebar h4, + div.sphinxsidebar h3 a { + color: ivory; + background: #2f2f2f; + } + + div.related a, + div.sphinxsidebar a { + color: #cfde63; + } + + div.sphinxsidebar input { + background: #2c2d24; + } + + div.note { + background-color: unset; + } + + div.related { + background-image: linear-gradient(to bottom, #66696a 0%, transparent 80%); + } + + th { + background-color: #483448; + } + + th p { + background-color: transparent; + } + + .highlight { + background-color: #424e20; + } + + .highlight .c, + .highlight .c1, + .highlight .ch, + .highlight .cm, + .highlight .cpf { + color: #79a6b2; + } + + .highlight .fm, + .highlight .nf { + color: #82abdb; + } + + .highlight .gi { + color: #65df65; + } + + .highlight .go { + color: #b6b2ad; + } + + .highlight .m, + .highlight .mf, + .highlight .mh, + .highlight .mi { + color: #7ec6a2; + } + + .highlight .cp, + .highlight .k, + .highlight .kn, + .highlight .nb { + color: #7edf9a; + } + + .highlight .kt { + color: #df876d; + } + + .highlight .nn { + color: unset; + } + + .highlight .nt { + color: #87afdb; + } + + .highlight .s, + .highlight .s1, + .highlight .s2 { + color: #7c9cb7; + } + + .highlight .ss { + color: #adcc80; + } + + .highlight .nc { + color: #5db1d5; + } + + .highlight .nv { + color: #ae6dc1; + } + + .highlight .o { + color: #9e9890; + } + + pre { + color: #ceccca; + } + + img { + background-color: #ceccca; + padding: 3px; + } } diff --git a/doc/tutorial/pickle-to-xml.py b/doc/tutorial/pickle-to-xml.py index 1f557370f..6a4fcebb3 100755 --- a/doc/tutorial/pickle-to-xml.py +++ b/doc/tutorial/pickle-to-xml.py @@ -12,11 +12,11 @@ import os import codecs def dump_pickles(out, dirname, filename, path): - f = open(os.path.join(dirname, filename), 'r') - data = pickle.load(f) - fragment_file = codecs.open(data['current_page_name'] + '.frag', mode='w', encoding='utf-8') - fragment_file.write(data['body']) - fragment_file.close() + with open(os.path.join(dirname, filename), 'r', encoding='utf-8') as f: + data = pickle.load(f) + with codecs.open(data['current_page_name'] + '.frag', mode='w', encoding='utf-8') as fragment_file: + fragment_file.write(data['body']) + out.write(' \n' % path) out.write(' %s.frag\n' % data['current_page_name']) if data['prev'] is not None: @@ -28,12 +28,11 @@ def dump_pickles(out, dirname, filename, path): (os.path.normpath(os.path.join(path, data['next']['link'])), data['next']['title'])) out.write(' \n') - f.close() + if data['next'] is not None: next_path = os.path.normpath(os.path.join(path, data['next']['link'])) next_filename = os.path.basename(next_path) + '.fpickle' dump_pickles(out, dirname, next_filename, next_path) - return import sys diff --git a/doc/tutorial/source/conf.py b/doc/tutorial/source/conf.py index 1ebe7befc..a93ff993f 100644 --- a/doc/tutorial/source/conf.py +++ b/doc/tutorial/source/conf.py @@ -71,9 +71,9 @@ copyright = u'2006-2019' # built documents. # # The short X.Y version. -version = u'ns-3.39' +version = u'ns-3.40' # The full version, including alpha/beta/rc tags. -release = u'ns-3.39' +release = u'ns-3.40' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/tutorial/source/getting-started.rst b/doc/tutorial/source/getting-started.rst index d8ccba2f5..c393b9020 100644 --- a/doc/tutorial/source/getting-started.rst +++ b/doc/tutorial/source/getting-started.rst @@ -61,7 +61,7 @@ the project provides an installation guide for various systems, available at https://www.nsnam.org/docs/installation/html/index.html. -As of the most recent |ns3| release (ns-3.39), the following tools +As of the most recent |ns3| release (ns-3.40), the following tools are needed to get started with |ns3|: ============ =========================================================== @@ -116,21 +116,21 @@ get a copy of a release by typing the following into your Linux shell $ cd $ mkdir workspace $ cd workspace - $ wget https://www.nsnam.org/release/ns-allinone-3.39.tar.bz2 - $ tar xjf ns-allinone-3.39.tar.bz2 + $ wget https://www.nsnam.org/release/ns-allinone-3.40.tar.bz2 + $ tar xjf ns-allinone-3.40.tar.bz2 Notice the use above of the ``wget`` utility, which is a command-line tool to fetch objects from the web; if you do not have this installed, you can use a browser for this step. Following these steps, if you change into the directory -``ns-allinone-3.39``, you should see a number of files and directories +``ns-allinone-3.40``, you should see a number of files and directories .. sourcecode:: text - $ cd ns-allinone-3.39 + $ cd ns-allinone-3.40 $ ls - bake build.py constants.py netanim-3.109 ns-3.39 README.md util.py + bake build.py constants.py netanim-3.109 ns-3.40 README.md util.py You are now ready to build the base |ns3| distribution and may skip ahead to the section on building |ns3|. @@ -180,7 +180,7 @@ release number: .. sourcecode:: console - $ python3 download.py -n ns-3.39 + $ python3 download.py -n ns-3.40 After this step, the additional repositories of |ns3|, bake, pybindgen, and netanim will be downloaded to the ``ns-3-allinone`` directory. @@ -249,9 +249,9 @@ distribution of your choice. There are a few configuration targets available: -1. ``ns-3.39``: the code corresponding to the release +1. ``ns-3.40``: the code corresponding to the release 2. ``ns-3-dev``: a similar module but using the development code tree -3. ``ns-allinone-3.39``: the module that includes other optional features +3. ``ns-allinone-3.40``: the module that includes other optional features such as bake build system, netanim animator, and pybindgen 4. ``ns-3-allinone``: similar to the released version of the allinone module, but for development code. @@ -268,7 +268,7 @@ code either by inspection of the repository list or by going to the `"ns-3 Releases" `_ web page and clicking on the latest release link. We'll proceed in -this tutorial example with ``ns-3.39``. +this tutorial example with ``ns-3.40``. We are now going to use the bake tool to pull down the various pieces of |ns3| you will be using. First, we'll say a word about running bake. @@ -297,7 +297,7 @@ Step into the workspace directory and type the following into your shell: .. sourcecode:: console - $ ./bake.py configure -e ns-allinone-3.39 + $ ./bake.py configure -e ns-allinone-3.40 Next, we'll ask bake to check whether we have enough tools to download various components. Type: @@ -347,7 +347,7 @@ should yield something like: >> Downloading click-ns-3.37 - OK >> Downloading BRITE - OK >> Downloading openflow-dev - OK - >> Downloading ns-3.39 (target directory:ns-3.39) - OK + >> Downloading ns-3.40 (target directory:ns-3.40) - OK The above suggests that three sources have been downloaded. Check the ``source`` directory now and type ``ls``; one should see: @@ -356,7 +356,7 @@ The above suggests that three sources have been downloaded. Check the $ cd source $ ls - BRITE click-ns-3.37 netanim-3.109 ns-3.39 openflow-dev + BRITE click-ns-3.37 netanim-3.109 ns-3.40 openflow-dev You are now ready to build the |ns3| distribution. @@ -386,7 +386,7 @@ native |ns3| build system, CMake, to be introduced later in this tutorial. If you downloaded using a tarball you should have a directory called something like -``ns-allinone-3.39`` under your ``~/workspace`` directory. +``ns-allinone-3.40`` under your ``~/workspace`` directory. Type the following: .. sourcecode:: console @@ -419,7 +419,7 @@ and you should see something like: .. sourcecode:: text >> Building netanim-3.109 - OK - >> Building ns-3.39 - OK + >> Building ns-3.40 - OK There may be failures to build all components, but the build will proceed anyway if the component is optional. diff --git a/doc/tutorial/source/index.rst b/doc/tutorial/source/index.rst index 042b1efd0..8af2593b1 100644 --- a/doc/tutorial/source/index.rst +++ b/doc/tutorial/source/index.rst @@ -24,6 +24,7 @@ This document is written in `reStructuredText GetBoundaries(); diff --git a/examples/energy/energy-model-example.cc b/examples/energy/energy-model-example.cc index ab42be174..a59b043c5 100644 --- a/examples/energy/energy-model-example.cc +++ b/examples/energy/energy-model-example.cc @@ -289,9 +289,7 @@ main(int argc, char* argv[]) Simulator::Stop(Seconds(10.0)); Simulator::Run(); - for (DeviceEnergyModelContainer::Iterator iter = deviceModels.Begin(); - iter != deviceModels.End(); - iter++) + for (auto iter = deviceModels.Begin(); iter != deviceModels.End(); iter++) { double energyConsumed = (*iter)->GetTotalEnergyConsumption(); NS_LOG_UNCOND("End of simulation (" diff --git a/examples/energy/energy-model-with-harvesting-example.cc b/examples/energy/energy-model-with-harvesting-example.cc index 99fd3ba24..4ee5639a8 100644 --- a/examples/energy/energy-model-with-harvesting-example.cc +++ b/examples/energy/energy-model-with-harvesting-example.cc @@ -354,9 +354,7 @@ main(int argc, char* argv[]) Simulator::Stop(Seconds(10.0)); Simulator::Run(); - for (DeviceEnergyModelContainer::Iterator iter = deviceModels.Begin(); - iter != deviceModels.End(); - iter++) + for (auto iter = deviceModels.Begin(); iter != deviceModels.End(); iter++) { double energyConsumed = (*iter)->GetTotalEnergyConsumption(); NS_LOG_UNCOND("End of simulation (" diff --git a/examples/ipv6/radvd-two-prefix.cc b/examples/ipv6/radvd-two-prefix.cc index d6087aebf..a9633ec1a 100644 --- a/examples/ipv6/radvd-two-prefix.cc +++ b/examples/ipv6/radvd-two-prefix.cc @@ -164,8 +164,7 @@ main(int argc, char** argv) routerInterface->SetMaxRtrAdvInterval(2000); routerInterface->SetMinRtrAdvInterval(1000); RadvdInterface::RadvdPrefixList prefixList = routerInterface->GetPrefixes(); - for (RadvdInterface::RadvdPrefixListI iter = prefixList.begin(); iter != prefixList.end(); - iter++) + for (auto iter = prefixList.begin(); iter != prefixList.end(); iter++) { (*iter)->SetPreferredLifeTime(3); (*iter)->SetValidLifeTime(5); @@ -179,8 +178,7 @@ main(int argc, char** argv) routerInterface->SetMaxRtrAdvInterval(2000); routerInterface->SetMinRtrAdvInterval(1000); prefixList = routerInterface->GetPrefixes(); - for (RadvdInterface::RadvdPrefixListI iter = prefixList.begin(); iter != prefixList.end(); - iter++) + for (auto iter = prefixList.begin(); iter != prefixList.end(); iter++) { (*iter)->SetPreferredLifeTime(3); (*iter)->SetValidLifeTime(5); diff --git a/examples/matrix-topology/matrix-topology.cc b/examples/matrix-topology/matrix-topology.cc index 9c1cf4f22..6203ec9b4 100644 --- a/examples/matrix-topology/matrix-topology.cc +++ b/examples/matrix-topology/matrix-topology.cc @@ -163,7 +163,7 @@ main(int argc, char* argv[]) { for (size_t j = 0; j < Adj_Matrix[i].size(); j++) { - if (Adj_Matrix[i][j] == 1) + if (Adj_Matrix[i][j]) { NodeContainer n_links = NodeContainer(nodes.Get(i), nodes.Get(j)); NetDeviceContainer n_devs = p2p.Install(n_links); diff --git a/examples/routing/global-routing-multi-switch-plus-router.cc b/examples/routing/global-routing-multi-switch-plus-router.cc index 882f37dd5..1b0fdbdc6 100644 --- a/examples/routing/global-routing-multi-switch-plus-router.cc +++ b/examples/routing/global-routing-multi-switch-plus-router.cc @@ -350,9 +350,7 @@ main(int argc, char* argv[]) } } - for (std::vector::const_iterator ploc = pcapLocationVec.begin(); - ploc != pcapLocationVec.end(); - ++ploc) + for (auto ploc = pcapLocationVec.begin(); ploc != pcapLocationVec.end(); ++ploc) { NS_LOG_INFO("PCAP capture at: <" + *ploc + ">"); } diff --git a/examples/tcp/tcp-pacing.cc b/examples/tcp/tcp-pacing.cc index 8ad772eee..2b061654b 100644 --- a/examples/tcp/tcp-pacing.cc +++ b/examples/tcp/tcp-pacing.cc @@ -161,7 +161,7 @@ main(int argc, char* argv[]) Time simulationEndTime = Seconds(5); DataRate bottleneckBandwidth("10Mbps"); // value of x as shown in the above network topology Time bottleneckDelay = MilliSeconds(40); - DataRate regLinkBandwidth = DataRate(4 * bottleneckBandwidth.GetBitRate()); + DataRate regLinkBandwidth(4 * bottleneckBandwidth.GetBitRate()); Time regLinkDelay = MilliSeconds(5); DataRate maxPacingRate("4Gbps"); @@ -324,9 +324,7 @@ main(int argc, char* argv[]) monitor->CheckForLostPackets(); Ptr classifier = DynamicCast(flowmon.GetClassifier()); FlowMonitor::FlowStatsContainer stats = monitor->GetFlowStats(); - for (std::map::const_iterator i = stats.begin(); - i != stats.end(); - ++i) + for (auto i = stats.begin(); i != stats.end(); ++i) { Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first); diff --git a/examples/wireless/examples-to-run.py b/examples/wireless/examples-to-run.py index 7eef186fe..3acd036ee 100755 --- a/examples/wireless/examples-to-run.py +++ b/examples/wireless/examples-to-run.py @@ -60,7 +60,7 @@ cpp_examples = [ ("wifi-eht-network --simulationTime=0.1 --frequency=5 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=547", "True", "True"), ("wifi-eht-network --simulationTime=0.1 --frequency=2.4 --useRts=0 --useExtendedBlockAck=1 --frequency2=5 --minExpectedThroughput=12 --maxExpectedThroughput=500", "True", "True"), ("wifi-eht-network --simulationTime=0.1 --frequency=2.4 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=212", "True", "True"), - ("wifi-eht-network --simulationTime=0.22 --udp=0 --downlink=1 --useRts=0 --nStations=4 --dlAckType=ACK-SU-FORMAT --enableUlOfdma=1 --enableBsrp=0 --mcs=4 --frequency2=6 --minExpectedThroughput=35 --maxExpectedThroughput=280", "True", "True"), + ("wifi-eht-network --simulationTime=0.23 --udp=0 --downlink=1 --useRts=0 --nStations=4 --dlAckType=ACK-SU-FORMAT --enableUlOfdma=1 --enableBsrp=0 --mcs=4 --frequency2=6 --minExpectedThroughput=35 --maxExpectedThroughput=280", "True", "True"), ("wifi-eht-network --simulationTime=0.25 --frequency=2.4 --udp=0 --downlink=1 --useRts=0 --nStations=5 --dlAckType=MU-BAR --enableUlOfdma=1 --enableBsrp=1 --mcs=5 --frequency2=5 --useExtendedBlockAck=1 --minExpectedThroughput=40 --maxExpectedThroughput=100", "True", "True"), ("wifi-eht-network --simulationTime=0.3 --udp=0 --downlink=1 --useRts=1 --nStations=5 --dlAckType=AGGR-MU-BAR --enableUlOfdma=1 --enableBsrp=0 --mcs=6 --muSchedAccessReqInterval=50ms --frequency2=2.4 --minExpectedThroughput=50 --maxExpectedThroughput=140", "True", "True"), ("wifi-eht-network --simulationTime=0.2 --udp=1 --downlink=0 --useRts=0 --nStations=5 --dlAckType=AGGR-MU-BAR --enableUlOfdma=1 --enableBsrp=1 --mcs=5 --muSchedAccessReqInterval=50ms --frequency2=6 --minExpectedThroughput=70 --maxExpectedThroughput=715", "True", "True"), diff --git a/examples/wireless/wifi-80211e-txop.cc b/examples/wireless/wifi-80211e-txop.cc index 08c1a243c..1656068af 100644 --- a/examples/wireless/wifi-80211e-txop.cc +++ b/examples/wireless/wifi-80211e-txop.cc @@ -96,8 +96,8 @@ main(int argc, char* argv[]) uint32_t payloadSize = 1472; // bytes double simulationTime = 10; // seconds double distance = 5; // meters - bool enablePcap = 0; - bool verifyResults = 0; // used for regression + bool enablePcap = false; + bool verifyResults = false; // used for regression Time txopLimit = MicroSeconds(4096); CommandLine cmd(__FILE__); diff --git a/examples/wireless/wifi-aggregation.cc b/examples/wireless/wifi-aggregation.cc index 73d58abae..3f33abd20 100644 --- a/examples/wireless/wifi-aggregation.cc +++ b/examples/wireless/wifi-aggregation.cc @@ -84,9 +84,9 @@ main(int argc, char* argv[]) uint32_t payloadSize = 1472; // bytes double simulationTime = 10; // seconds double distance = 5; // meters - bool enableRts = 0; - bool enablePcap = 0; - bool verifyResults = 0; // used for regression + bool enableRts = false; + bool enablePcap = false; + bool verifyResults = false; // used for regression CommandLine cmd(__FILE__); cmd.AddValue("payloadSize", "Payload size in bytes", payloadSize); diff --git a/examples/wireless/wifi-ap.py b/examples/wireless/wifi-ap.py index 9139e9a6c..65be16d4a 100644 --- a/examples/wireless/wifi-ap.py +++ b/examples/wireless/wifi-ap.py @@ -85,7 +85,7 @@ ns.cppyy.cppdef(""" def main(argv): ns.core.CommandLine().Parse(argv) - ns.network.Packet.EnablePrinting(); + ns.network.Packet.EnablePrinting() wifi = ns.wifi.WifiHelper() mobility = ns.mobility.MobilityHelper() @@ -110,7 +110,10 @@ def main(argv): # setup stas. wifiMac.SetType("ns3::StaWifiMac", - "Ssid", ns.wifi.SsidValue(ssid)) + "ActiveProbing", + ns.core.BooleanValue(True), + "Ssid", + ns.wifi.SsidValue(ssid)) staDevs = wifi.Install(wifiPhy, wifiMac, stas) # setup ap. wifiMac.SetType("ns3::ApWifiMac", diff --git a/examples/wireless/wifi-dsss-validation.cc b/examples/wireless/wifi-dsss-validation.cc index 23dcea37f..5c6c0ac0a 100644 --- a/examples/wireless/wifi-dsss-validation.cc +++ b/examples/wireless/wifi-dsss-validation.cc @@ -35,7 +35,7 @@ using namespace ns3; int main(int argc, char* argv[]) { - uint32_t FrameSize = 1500; // bytes + uint32_t frameSizeBytes = 1500; std::ofstream file("frame-success-rate-dsss.plt"); const std::vector modes{ @@ -46,7 +46,7 @@ main(int argc, char* argv[]) }; CommandLine cmd(__FILE__); - cmd.AddValue("FrameSize", "The frame size in bytes", FrameSize); + cmd.AddValue("FrameSize", "The frame size in bytes", frameSizeBytes); cmd.Parse(argc, argv); Gnuplot plot = Gnuplot("frame-success-rate-dsss.eps"); @@ -56,27 +56,27 @@ main(int argc, char* argv[]) Ptr table = CreateObject(); WifiTxVector txVector; - for (uint32_t i = 0; i < modes.size(); i++) - { - std::cout << modes[i] << std::endl; - Gnuplot2dDataset dataset(modes[i]); - txVector.SetMode(modes[i]); + uint32_t frameSizeBits = frameSizeBytes * 8; - for (double snr = -10.0; snr <= 20.0; snr += 0.1) + for (const auto& mode : modes) + { + std::cout << mode << std::endl; + Gnuplot2dDataset dataset(mode); + txVector.SetMode(mode); + + WifiMode wifiMode(mode); + + for (double snrDb = -10.0; snrDb <= 20.0; snrDb += 0.1) { - double psYans = yans->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + double snr = std::pow(10.0, snrDb / 10.0); + + double psYans = yans->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (psYans < 0.0 || psYans > 1.0) { // error exit(1); } - double psNist = nist->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + double psNist = nist->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (psNist < 0.0 || psNist > 1.0) { std::cout << psNist << std::endl; @@ -87,10 +87,7 @@ main(int argc, char* argv[]) { exit(1); } - double psTable = table->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + double psTable = table->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (psTable < 0.0 || psTable > 1.0) { std::cout << psTable << std::endl; @@ -101,7 +98,7 @@ main(int argc, char* argv[]) { exit(1); } - dataset.Add(snr, psYans); + dataset.Add(snrDb, psYans); } plot.AddDataset(dataset); diff --git a/examples/wireless/wifi-error-models-comparison.cc b/examples/wireless/wifi-error-models-comparison.cc index 01259408b..03bd46988 100644 --- a/examples/wireless/wifi-error-models-comparison.cc +++ b/examples/wireless/wifi-error-models-comparison.cc @@ -86,66 +86,61 @@ main(int argc, char* argv[]) mode << format << "Mcs" << +endMcs; modes.push_back(mode.str()); - for (uint32_t i = 0; i < modes.size(); i++) + for (const auto& mode : modes) { - std::cout << modes[i] << std::endl; - Gnuplot2dDataset yansdataset(modes[i]); - Gnuplot2dDataset nistdataset(modes[i]); - Gnuplot2dDataset tabledataset(modes[i]); - txVector.SetMode(modes[i]); + std::cout << mode << std::endl; + Gnuplot2dDataset yansdataset(mode); + Gnuplot2dDataset nistdataset(mode); + Gnuplot2dDataset tabledataset(mode); + txVector.SetMode(mode); - for (double snr = -5.0; snr <= (endMcs * 5); snr += 0.1) + WifiMode wifiMode(mode); + + for (double snrDb = -5.0; snrDb <= (endMcs * 5); snrDb += 0.1) { - double ps = yans->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - size); + double snr = std::pow(10.0, snrDb / 10.0); + + double ps = yans->GetChunkSuccessRate(wifiMode, txVector, snr, size); if (ps < 0 || ps > 1) { // error exit(1); } - yansdataset.Add(snr, 1 - ps); - ps = nist->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - size); + yansdataset.Add(snrDb, 1 - ps); + ps = nist->GetChunkSuccessRate(wifiMode, txVector, snr, size); if (ps < 0 || ps > 1) { // error exit(1); } - nistdataset.Add(snr, 1 - ps); - ps = table->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - size); + nistdataset.Add(snrDb, 1 - ps); + ps = table->GetChunkSuccessRate(wifiMode, txVector, snr, size); if (ps < 0 || ps > 1) { // error exit(1); } - tabledataset.Add(snr, 1 - ps); + tabledataset.Add(snrDb, 1 - ps); } if (tableErrorModelEnabled) { std::stringstream ss; - ss << "Table-" << modes[i]; + ss << "Table-" << mode; tabledataset.SetTitle(ss.str()); plot.AddDataset(tabledataset); } if (yansErrorModelEnabled) { std::stringstream ss; - ss << "Yans-" << modes[i]; + ss << "Yans-" << mode; yansdataset.SetTitle(ss.str()); plot.AddDataset(yansdataset); } if (nistErrorModelEnabled) { std::stringstream ss; - ss << "Nist-" << modes[i]; + ss << "Nist-" << mode; nistdataset.SetTitle(ss.str()); plot.AddDataset(nistdataset); } diff --git a/examples/wireless/wifi-hidden-terminal.cc b/examples/wireless/wifi-hidden-terminal.cc index 6adfa9249..9c7d94180 100644 --- a/examples/wireless/wifi-hidden-terminal.cc +++ b/examples/wireless/wifi-hidden-terminal.cc @@ -163,9 +163,7 @@ experiment(bool enableCtsRts, std::string wifiManager) monitor->CheckForLostPackets(); Ptr classifier = DynamicCast(flowmon.GetClassifier()); FlowMonitor::FlowStatsContainer stats = monitor->GetFlowStats(); - for (std::map::const_iterator i = stats.begin(); - i != stats.end(); - ++i) + for (auto i = stats.begin(); i != stats.end(); ++i) { // first 2 FlowIds are for ECHO apps, we don't want to display them // diff --git a/examples/wireless/wifi-ht-network.cc b/examples/wireless/wifi-ht-network.cc index e9008932f..d9fa8df55 100644 --- a/examples/wireless/wifi-ht-network.cc +++ b/examples/wireless/wifi-ht-network.cc @@ -118,7 +118,7 @@ main(int argc, char* argv[]) double previous = 0; for (int channelWidth = 20; channelWidth <= 40;) { - for (int sgi = 0; sgi < 2; sgi++) + for (auto sgi : {false, true}) { uint32_t payloadSize; // 1500 byte IP packet if (udp) @@ -283,11 +283,11 @@ main(int argc, char* argv[]) Simulator::Destroy(); - std::cout << mcs << "\t\t\t" << channelWidth << " MHz\t\t\t" << sgi << "\t\t\t" - << throughput << " Mbit/s" << std::endl; + std::cout << mcs << "\t\t\t" << channelWidth << " MHz\t\t\t" << std::boolalpha + << sgi << "\t\t\t" << throughput << " Mbit/s" << std::endl; // test first element - if (mcs == 0 && channelWidth == 20 && sgi == 0) + if (mcs == 0 && channelWidth == 20 && !sgi) { if (throughput < minExpectedThroughput) { @@ -295,7 +295,7 @@ main(int argc, char* argv[]) } } // test last element - if (mcs == 7 && channelWidth == 40 && sgi == 1) + if (mcs == 7 && channelWidth == 40 && sgi) { if (maxExpectedThroughput > 0 && throughput > maxExpectedThroughput) { diff --git a/examples/wireless/wifi-mixed-network.cc b/examples/wireless/wifi-mixed-network.cc index 22432c8ef..b079842f0 100644 --- a/examples/wireless/wifi-mixed-network.cc +++ b/examples/wireless/wifi-mixed-network.cc @@ -370,7 +370,7 @@ main(int argc, char* argv[]) params.payloadSize = 1472; // bytes params.simulationTime = 10; // seconds - bool verifyResults = 0; // used for regression + bool verifyResults = false; // used for regression CommandLine cmd(__FILE__); cmd.AddValue("payloadSize", "Payload size in bytes", params.payloadSize); diff --git a/examples/wireless/wifi-multirate.cc b/examples/wireless/wifi-multirate.cc index fd0a224a6..409c1cea2 100644 --- a/examples/wireless/wifi-multirate.cc +++ b/examples/wireless/wifi-multirate.cc @@ -116,7 +116,7 @@ class Experiment */ bool IsRouting() const { - return (m_enableRouting == 1) ? 1 : 0; + return m_enableRouting; } /** @@ -126,7 +126,7 @@ class Experiment */ bool IsMobility() const { - return (m_enableMobility == 1) ? 1 : 0; + return m_enableMobility; } /** @@ -239,7 +239,7 @@ class Experiment uint32_t m_gridSize; //!< Grid size. uint32_t m_nodeDistance; //!< Node distance. uint32_t m_port; //!< Listening port. - uint32_t m_scenario; //!< Scnario number. + uint32_t m_scenario; //!< Scenario number. bool m_enablePcap; //!< True if PCAP output is enabled. bool m_enableTracing; //!< True if tracing output is enabled. diff --git a/examples/wireless/wifi-ofdm-eht-validation.cc b/examples/wireless/wifi-ofdm-eht-validation.cc index 266ba1d11..38098b929 100644 --- a/examples/wireless/wifi-ofdm-eht-validation.cc +++ b/examples/wireless/wifi-ofdm-eht-validation.cc @@ -37,7 +37,7 @@ using namespace ns3; int main(int argc, char* argv[]) { - uint32_t FrameSize = 1500; // bytes + uint32_t frameSizeBytes = 1500; std::ofstream yansfile("yans-frame-success-rate-be.plt"); std::ofstream nistfile("nist-frame-success-rate-be.plt"); std::ofstream tablefile("table-frame-success-rate-be.plt"); @@ -60,7 +60,7 @@ main(int argc, char* argv[]) }; CommandLine cmd(__FILE__); - cmd.AddValue("FrameSize", "The frame size", FrameSize); + cmd.AddValue("FrameSize", "The frame size", frameSizeBytes); cmd.Parse(argc, argv); Gnuplot yansplot = Gnuplot("yans-frame-success-rate-be.eps"); @@ -72,48 +72,45 @@ main(int argc, char* argv[]) Ptr table = CreateObject(); WifiTxVector txVector; - for (uint32_t i = 0; i < modes.size(); i++) + uint32_t frameSizeBits = frameSizeBytes * 8; + + for (const auto& mode : modes) { - std::cout << modes[i] << std::endl; - Gnuplot2dDataset yansdataset(modes[i]); - Gnuplot2dDataset nistdataset(modes[i]); - Gnuplot2dDataset tabledataset(modes[i]); - txVector.SetMode(modes[i]); + std::cout << mode << std::endl; + Gnuplot2dDataset yansdataset(mode); + Gnuplot2dDataset nistdataset(mode); + Gnuplot2dDataset tabledataset(mode); + txVector.SetMode(mode); - for (double snr = -5.0; snr <= 55.0; snr += 0.1) + WifiMode wifiMode(mode); + + for (double snrDb = -5.0; snrDb <= 55.0; snrDb += 0.1) { - double ps = yans->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); - if (ps < 0.0 || ps > 1.0) - { - // error - exit(1); - } - yansdataset.Add(snr, ps); + double snr = std::pow(10.0, snrDb / 10.0); - ps = nist->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + double ps = yans->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (ps < 0.0 || ps > 1.0) { // error exit(1); } - nistdataset.Add(snr, ps); + yansdataset.Add(snrDb, ps); - ps = table->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + ps = nist->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (ps < 0.0 || ps > 1.0) { // error exit(1); } - tabledataset.Add(snr, ps); + nistdataset.Add(snrDb, ps); + + ps = table->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); + if (ps < 0.0 || ps > 1.0) + { + // error + exit(1); + } + tabledataset.Add(snrDb, ps); } yansplot.AddDataset(yansdataset); diff --git a/examples/wireless/wifi-ofdm-he-validation.cc b/examples/wireless/wifi-ofdm-he-validation.cc index 24a71353b..67d6fc8da 100644 --- a/examples/wireless/wifi-ofdm-he-validation.cc +++ b/examples/wireless/wifi-ofdm-he-validation.cc @@ -35,7 +35,7 @@ using namespace ns3; int main(int argc, char* argv[]) { - uint32_t FrameSize = 1500; // bytes + uint32_t frameSizeBytes = 1500; std::ofstream yansfile("yans-frame-success-rate-ax.plt"); std::ofstream nistfile("nist-frame-success-rate-ax.plt"); std::ofstream tablefile("table-frame-success-rate-ax.plt"); @@ -56,7 +56,7 @@ main(int argc, char* argv[]) }; CommandLine cmd(__FILE__); - cmd.AddValue("FrameSize", "The frame size", FrameSize); + cmd.AddValue("FrameSize", "The frame size", frameSizeBytes); cmd.Parse(argc, argv); Gnuplot yansplot = Gnuplot("yans-frame-success-rate-ax.eps"); @@ -68,48 +68,45 @@ main(int argc, char* argv[]) Ptr table = CreateObject(); WifiTxVector txVector; - for (uint32_t i = 0; i < modes.size(); i++) + uint32_t frameSizeBits = frameSizeBytes * 8; + + for (const auto& mode : modes) { - std::cout << modes[i] << std::endl; - Gnuplot2dDataset yansdataset(modes[i]); - Gnuplot2dDataset nistdataset(modes[i]); - Gnuplot2dDataset tabledataset(modes[i]); - txVector.SetMode(modes[i]); + std::cout << mode << std::endl; + Gnuplot2dDataset yansdataset(mode); + Gnuplot2dDataset nistdataset(mode); + Gnuplot2dDataset tabledataset(mode); + txVector.SetMode(mode); - for (double snr = -5.0; snr <= 40.0; snr += 0.1) + WifiMode wifiMode(mode); + + for (double snrDb = -5.0; snrDb <= 40.0; snrDb += 0.1) { - double ps = yans->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); - if (ps < 0.0 || ps > 1.0) - { - // error - exit(1); - } - yansdataset.Add(snr, ps); + double snr = std::pow(10.0, snrDb / 10.0); - ps = nist->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + double ps = yans->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (ps < 0.0 || ps > 1.0) { // error exit(1); } - nistdataset.Add(snr, ps); + yansdataset.Add(snrDb, ps); - ps = table->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + ps = nist->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (ps < 0.0 || ps > 1.0) { // error exit(1); } - tabledataset.Add(snr, ps); + nistdataset.Add(snrDb, ps); + + ps = table->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); + if (ps < 0.0 || ps > 1.0) + { + // error + exit(1); + } + tabledataset.Add(snrDb, ps); } yansplot.AddDataset(yansdataset); diff --git a/examples/wireless/wifi-ofdm-ht-validation.cc b/examples/wireless/wifi-ofdm-ht-validation.cc index 92a431d24..5cc01a874 100644 --- a/examples/wireless/wifi-ofdm-ht-validation.cc +++ b/examples/wireless/wifi-ofdm-ht-validation.cc @@ -35,7 +35,7 @@ using namespace ns3; int main(int argc, char* argv[]) { - uint32_t FrameSize = 1500; // bytes + uint32_t frameSizeBytes = 1500; std::ofstream yansfile("yans-frame-success-rate-n.plt"); std::ofstream nistfile("nist-frame-success-rate-n.plt"); std::ofstream tablefile("table-frame-success-rate-n.plt"); @@ -52,7 +52,7 @@ main(int argc, char* argv[]) }; CommandLine cmd(__FILE__); - cmd.AddValue("FrameSize", "The frame size in bytes", FrameSize); + cmd.AddValue("FrameSize", "The frame size in bytes", frameSizeBytes); cmd.Parse(argc, argv); Gnuplot yansplot = Gnuplot("yans-frame-success-rate-n.eps"); @@ -64,48 +64,45 @@ main(int argc, char* argv[]) Ptr nist = CreateObject(); Ptr table = CreateObject(); - for (uint32_t i = 0; i < modes.size(); i++) + uint32_t frameSizeBits = frameSizeBytes * 8; + + for (const auto& mode : modes) { - std::cout << modes[i] << std::endl; - Gnuplot2dDataset yansdataset(modes[i]); - Gnuplot2dDataset nistdataset(modes[i]); - Gnuplot2dDataset tabledataset(modes[i]); - txVector.SetMode(modes[i]); + std::cout << mode << std::endl; + Gnuplot2dDataset yansdataset(mode); + Gnuplot2dDataset nistdataset(mode); + Gnuplot2dDataset tabledataset(mode); + txVector.SetMode(mode); - for (double snr = -5.0; snr <= 30.0; snr += 0.1) + WifiMode wifiMode(mode); + + for (double snrDb = -5.0; snrDb <= 30.0; snrDb += 0.1) { - double ps = yans->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); - if (ps < 0.0 || ps > 1.0) - { - // error - exit(1); - } - yansdataset.Add(snr, ps); + double snr = std::pow(10.0, snrDb / 10.0); - ps = nist->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + double ps = yans->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (ps < 0.0 || ps > 1.0) { // error exit(1); } - nistdataset.Add(snr, ps); + yansdataset.Add(snrDb, ps); - ps = table->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + ps = nist->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (ps < 0.0 || ps > 1.0) { // error exit(1); } - tabledataset.Add(snr, ps); + nistdataset.Add(snrDb, ps); + + ps = table->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); + if (ps < 0.0 || ps > 1.0) + { + // error + exit(1); + } + tabledataset.Add(snrDb, ps); } yansplot.AddDataset(yansdataset); diff --git a/examples/wireless/wifi-ofdm-validation.cc b/examples/wireless/wifi-ofdm-validation.cc index 6eb1d212a..907db3a54 100644 --- a/examples/wireless/wifi-ofdm-validation.cc +++ b/examples/wireless/wifi-ofdm-validation.cc @@ -37,7 +37,7 @@ using namespace ns3; int main(int argc, char* argv[]) { - uint32_t FrameSize = 1500; // bytes + uint32_t frameSizeBytes = 1500; std::ofstream yansfile("yans-frame-success-rate-ofdm.plt"); std::ofstream nistfile("nist-frame-success-rate-ofdm.plt"); std::ofstream tablefile("table-frame-success-rate-ofdm.plt"); @@ -54,7 +54,7 @@ main(int argc, char* argv[]) }; CommandLine cmd(__FILE__); - cmd.AddValue("FrameSize", "The frame size in bytes", FrameSize); + cmd.AddValue("FrameSize", "The frame size in bytes", frameSizeBytes); cmd.Parse(argc, argv); Gnuplot yansplot = Gnuplot("yans-frame-success-rate-ofdm.eps"); @@ -66,48 +66,45 @@ main(int argc, char* argv[]) Ptr table = CreateObject(); WifiTxVector txVector; - for (uint32_t i = 0; i < modes.size(); i++) + uint32_t frameSizeBits = frameSizeBytes * 8; + + for (const auto& mode : modes) { - std::cout << modes[i] << std::endl; - Gnuplot2dDataset yansdataset(modes[i]); - Gnuplot2dDataset nistdataset(modes[i]); - Gnuplot2dDataset tabledataset(modes[i]); - txVector.SetMode(modes[i]); + std::cout << mode << std::endl; + Gnuplot2dDataset yansdataset(mode); + Gnuplot2dDataset nistdataset(mode); + Gnuplot2dDataset tabledataset(mode); + txVector.SetMode(mode); - for (double snr = -5.0; snr <= 30.0; snr += 0.1) + WifiMode wifiMode(mode); + + for (double snrDb = -5.0; snrDb <= 30.0; snrDb += 0.1) { - double ps = yans->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); - if (ps < 0.0 || ps > 1.0) - { - // error - exit(1); - } - yansdataset.Add(snr, ps); + double snr = std::pow(10.0, snrDb / 10.0); - ps = nist->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + double ps = yans->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (ps < 0.0 || ps > 1.0) { // error exit(1); } - nistdataset.Add(snr, ps); + yansdataset.Add(snrDb, ps); - ps = table->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + ps = nist->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (ps < 0.0 || ps > 1.0) { // error exit(1); } - tabledataset.Add(snr, ps); + nistdataset.Add(snrDb, ps); + + ps = table->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); + if (ps < 0.0 || ps > 1.0) + { + // error + exit(1); + } + tabledataset.Add(snrDb, ps); } yansplot.AddDataset(yansdataset); diff --git a/examples/wireless/wifi-ofdm-vht-validation.cc b/examples/wireless/wifi-ofdm-vht-validation.cc index 8e2bded0f..a42e96b99 100644 --- a/examples/wireless/wifi-ofdm-vht-validation.cc +++ b/examples/wireless/wifi-ofdm-vht-validation.cc @@ -36,7 +36,7 @@ using namespace ns3; int main(int argc, char* argv[]) { - uint32_t FrameSize = 1500; // bytes + uint32_t frameSizeBytes = 1500; std::ofstream yansfile("yans-frame-success-rate-ac.plt"); std::ofstream nistfile("nist-frame-success-rate-ac.plt"); std::ofstream tablefile("table-frame-success-rate-ac.plt"); @@ -54,7 +54,7 @@ main(int argc, char* argv[]) }; CommandLine cmd(__FILE__); - cmd.AddValue("FrameSize", "The frame size in bytes", FrameSize); + cmd.AddValue("FrameSize", "The frame size in bytes", frameSizeBytes); cmd.Parse(argc, argv); Gnuplot yansplot = Gnuplot("yans-frame-success-rate-ac.eps"); @@ -66,48 +66,45 @@ main(int argc, char* argv[]) Ptr table = CreateObject(); WifiTxVector txVector; - for (uint32_t i = 0; i < modes.size(); i++) + uint32_t frameSizeBits = frameSizeBytes * 8; + + for (const auto& mode : modes) { - std::cout << modes[i] << std::endl; - Gnuplot2dDataset yansdataset(modes[i]); - Gnuplot2dDataset nistdataset(modes[i]); - Gnuplot2dDataset tabledataset(modes[i]); - txVector.SetMode(modes[i]); + std::cout << mode << std::endl; + Gnuplot2dDataset yansdataset(mode); + Gnuplot2dDataset nistdataset(mode); + Gnuplot2dDataset tabledataset(mode); + txVector.SetMode(mode); - for (double snr = -5.0; snr <= 30.0; snr += 0.1) + WifiMode wifiMode(mode); + + for (double snrDb = -5.0; snrDb <= 30.0; snrDb += 0.1) { - double ps = yans->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); - if (ps < 0.0 || ps > 1.0) - { - // error - exit(1); - } - yansdataset.Add(snr, ps); + double snr = std::pow(10.0, snrDb / 10.0); - ps = nist->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + double ps = yans->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (ps < 0.0 || ps > 1.0) { // error exit(1); } - nistdataset.Add(snr, ps); + yansdataset.Add(snrDb, ps); - ps = table->GetChunkSuccessRate(WifiMode(modes[i]), - txVector, - std::pow(10.0, snr / 10.0), - FrameSize * 8); + ps = nist->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); if (ps < 0.0 || ps > 1.0) { // error exit(1); } - tabledataset.Add(snr, ps); + nistdataset.Add(snrDb, ps); + + ps = table->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits); + if (ps < 0.0 || ps > 1.0) + { + // error + exit(1); + } + tabledataset.Add(snrDb, ps); } yansplot.AddDataset(yansdataset); diff --git a/examples/wireless/wifi-power-adaptation-distance.cc b/examples/wireless/wifi-power-adaptation-distance.cc index 08e28624f..651a1dad8 100644 --- a/examples/wireless/wifi-power-adaptation-distance.cc +++ b/examples/wireless/wifi-power-adaptation-distance.cc @@ -253,7 +253,7 @@ NodeStatistics::SetupPhy(Ptr phy) txVector.SetMode(mode); txVector.SetPreambleType(WIFI_PREAMBLE_LONG); txVector.SetChannelWidth(phy->GetChannelWidth()); - DataRate dataRate = DataRate(mode.GetDataRate(phy->GetChannelWidth())); + DataRate dataRate(mode.GetDataRate(phy->GetChannelWidth())); Time time = phy->CalculateTxDuration(packetSize, txVector, phy->GetPhyBand()); NS_LOG_DEBUG(mode.GetUniqueName() << " " << time.GetSeconds() << " " << dataRate); m_timeTable.emplace_back(time, dataRate); @@ -263,7 +263,7 @@ NodeStatistics::SetupPhy(Ptr phy) Time NodeStatistics::GetCalcTxTime(DataRate rate) { - for (TxTime::const_iterator i = m_timeTable.begin(); i != m_timeTable.end(); i++) + for (auto i = m_timeTable.begin(); i != m_timeTable.end(); i++) { if (rate == i->second) { diff --git a/examples/wireless/wifi-power-adaptation-interference.cc b/examples/wireless/wifi-power-adaptation-interference.cc index 8ea2446b3..e72ac666d 100644 --- a/examples/wireless/wifi-power-adaptation-interference.cc +++ b/examples/wireless/wifi-power-adaptation-interference.cc @@ -274,7 +274,7 @@ NodeStatistics::SetupPhy(Ptr phy) txVector.SetMode(mode); txVector.SetPreambleType(WIFI_PREAMBLE_LONG); txVector.SetChannelWidth(phy->GetChannelWidth()); - DataRate dataRate = DataRate(mode.GetDataRate(phy->GetChannelWidth())); + DataRate dataRate(mode.GetDataRate(phy->GetChannelWidth())); Time time = phy->CalculateTxDuration(packetSize, txVector, phy->GetPhyBand()); NS_LOG_DEBUG(mode.GetUniqueName() << " " << time.GetSeconds() << " " << dataRate); m_timeTable.emplace_back(time, dataRate); @@ -284,7 +284,7 @@ NodeStatistics::SetupPhy(Ptr phy) Time NodeStatistics::GetCalcTxTime(DataRate rate) { - for (TxTime::const_iterator i = m_timeTable.begin(); i != m_timeTable.end(); i++) + for (auto i = m_timeTable.begin(); i != m_timeTable.end(); i++) { if (rate == i->second) { @@ -667,9 +667,7 @@ main(int argc, char* argv[]) Ptr classifier = DynamicCast(flowmon.GetClassifier()); std::map stats = monitor->GetFlowStats(); - for (std::map::const_iterator i = stats.begin(); - i != stats.end(); - ++i) + for (auto i = stats.begin(); i != stats.end(); ++i) { Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first); if ((t.sourceAddress == "10.1.1.3" && t.destinationAddress == "10.1.1.1")) diff --git a/examples/wireless/wifi-rate-adaptation-distance.cc b/examples/wireless/wifi-rate-adaptation-distance.cc index 7b1abe643..4dc7f6617 100644 --- a/examples/wireless/wifi-rate-adaptation-distance.cc +++ b/examples/wireless/wifi-rate-adaptation-distance.cc @@ -403,8 +403,8 @@ main(int argc, char* argv[]) std::ofstream outfile("throughput-" + outputFileName + ".plt"); Gnuplot gnuplot = Gnuplot("throughput-" + outputFileName + ".eps", "Throughput"); gnuplot.SetTerminal("post eps color enhanced"); - gnuplot.SetLegend("Time (seconds)", "Throughput (Mb/s)"); - gnuplot.SetTitle("Throughput (AP to STA) vs time"); + gnuplot.SetLegend("Distance (meters)", "Throughput (Mb/s)"); + gnuplot.SetTitle("Throughput (AP to STA) vs distance"); gnuplot.AddDataset(atpCounter.GetDatafile()); gnuplot.GenerateOutput(outfile); diff --git a/examples/wireless/wifi-simple-ht-hidden-stations.cc b/examples/wireless/wifi-simple-ht-hidden-stations.cc index a52169032..58f238080 100644 --- a/examples/wireless/wifi-simple-ht-hidden-stations.cc +++ b/examples/wireless/wifi-simple-ht-hidden-stations.cc @@ -59,7 +59,7 @@ main(int argc, char* argv[]) double simulationTime = 10; // seconds uint32_t nMpdus = 1; uint32_t maxAmpduSize = 0; - bool enableRts = 0; + bool enableRts = false; double minExpectedThroughput = 0; double maxExpectedThroughput = 0; diff --git a/examples/wireless/wifi-sleep.cc b/examples/wireless/wifi-sleep.cc index 857ea2039..2bc04743a 100644 --- a/examples/wireless/wifi-sleep.cc +++ b/examples/wireless/wifi-sleep.cc @@ -228,7 +228,7 @@ main(int argc, char* argv[]) DoubleValue(eta)); // install an energy source on each node - for (NodeContainer::Iterator n = c.Begin(); n != c.End(); n++) + for (auto n = c.Begin(); n != c.End(); n++) { eSources.Add(basicSourceHelper.Install(*n)); diff --git a/examples/wireless/wifi-txop-aggregation.cc b/examples/wireless/wifi-txop-aggregation.cc index 0c2d6d6fd..385d1630a 100644 --- a/examples/wireless/wifi-txop-aggregation.cc +++ b/examples/wireless/wifi-txop-aggregation.cc @@ -111,9 +111,9 @@ main(int argc, char* argv[]) double simulationTime = 10; // seconds double txopLimit = 3520; // microseconds double distance = 5; // meters - bool enableRts = 0; - bool enablePcap = 0; - bool verifyResults = 0; // used for regression + bool enableRts = false; + bool enablePcap = false; + bool verifyResults = false; // used for regression CommandLine cmd(__FILE__); cmd.AddValue("payloadSize", "Payload size in bytes", payloadSize); diff --git a/examples/wireless/wifi-vht-network.cc b/examples/wireless/wifi-vht-network.cc index b9acfc8a6..f8c679a49 100644 --- a/examples/wireless/wifi-vht-network.cc +++ b/examples/wireless/wifi-vht-network.cc @@ -117,7 +117,7 @@ main(int argc, char* argv[]) channelWidth *= 2; continue; } - for (int sgi = 0; sgi < 2; sgi++) + for (auto sgi : {false, true}) { uint32_t payloadSize; // 1500 byte IP packet if (udp) @@ -265,11 +265,11 @@ main(int argc, char* argv[]) Simulator::Destroy(); - std::cout << mcs << "\t\t\t" << channelWidth << " MHz\t\t\t" << sgi << "\t\t\t" - << throughput << " Mbit/s" << std::endl; + std::cout << mcs << "\t\t\t" << channelWidth << " MHz\t\t\t" << std::boolalpha + << sgi << "\t\t\t" << throughput << " Mbit/s" << std::endl; // test first element - if (mcs == 0 && channelWidth == 20 && sgi == 0) + if (mcs == 0 && channelWidth == 20 && !sgi) { if (throughput < minExpectedThroughput) { @@ -278,7 +278,7 @@ main(int argc, char* argv[]) } } // test last element - if (mcs == 9 && channelWidth == 160 && sgi == 1) + if (mcs == 9 && channelWidth == 160 && sgi) { if (maxExpectedThroughput > 0 && throughput > maxExpectedThroughput) { diff --git a/ns3 b/ns3 index 9da22bdec..4745aded2 100755 --- a/ns3 +++ b/ns3 @@ -168,13 +168,14 @@ def parse_args(argv): parser_configure = on_off_argument(parser_configure, *on_off_option) parser_configure.add_argument('--enable-modules', - help='List of modules to build (e.g. core;network;internet)', + help='List of modules to build (e.g. \"core;network;internet\")', action="store", type=str, default=None) 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;wimax\")', action="store", type=str, default=None) parser_configure.add_argument('--filter-module-examples-and-tests', - help='List of modules that should have their examples and tests built (e.g. lte;wifi)', + help=('List of modules that should have their examples ' + 'and tests built (e.g. \"lte;wifi\")'), action="store", type=str, default=None) parser_configure.add_argument('--lcov-report', help=('Generate a code coverage report ' @@ -430,7 +431,8 @@ def print_and_buffer(message): def remove_dir(dir_to_remove, dry_run, directory_qualifier=""): dir_to_remove = os.path.abspath(dir_to_remove) if os.path.exists(dir_to_remove): - if ".." in os.path.relpath(dir_to_remove, ns3_path): + if (".." in os.path.relpath(dir_to_remove, ns3_path) + or os.path.abspath(dir_to_remove) == os.path.abspath(ns3_path)): # In case the directory to remove isn't within # the current ns-3 directory, print an error # message for the dry-run case @@ -506,6 +508,10 @@ def clean_pip_packaging_artifacts(dry_run=False): remove_dir(directory, dry_run) +def clean_vcpkg_artifacts(dry_run=False): + remove_dir(os.path.join(ns3_path, "vcpkg"), dry_run) + + def search_cmake_cache(build_profile): # Search for the CMake cache cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path, recursive=True) @@ -1447,6 +1453,7 @@ def main(): clean_cmake_artifacts(dry_run=args.dry_run) clean_docs_and_tests_artifacts(dry_run=args.dry_run) clean_pip_packaging_artifacts(dry_run=args.dry_run) + clean_vcpkg_artifacts(dry_run=args.dry_run) # We end things earlier when cleaning return diff --git a/src/antenna/doc/source/antenna-design.rst b/src/antenna/doc/source/antenna-design.rst index d5d71ecc9..0caeb6c6f 100644 --- a/src/antenna/doc/source/antenna-design.rst +++ b/src/antenna/doc/source/antenna-design.rst @@ -153,6 +153,7 @@ Derived classes must implement the following functions: The class PhasedArrayModel also assumes that all antenna elements are equal, a typical key assumption which allows to model the PAA field pattern as the sum of the array factor, given by the geometry of the location of the antenna elements, and the element field pattern. Any class derived from AntennaModel is a valid antenna element for the PhasedArrayModel, allowing for a great flexibility of the framework. +.. _3gpp-antenna-model: UniformPlanarArray ++++++++++++++++++ diff --git a/src/antenna/model/angles.cc b/src/antenna/model/angles.cc index 18e7e86f8..ef86c9511 100644 --- a/src/antenna/model/angles.cc +++ b/src/antenna/model/angles.cc @@ -74,55 +74,85 @@ RadiansToDegrees(const std::vector& radians) double WrapTo360(double a) { - a = fmod(a, 360); - if (a < 0) + static constexpr int64_t INT_RANGE = 100000000000; + // Divide the input by 360. + // Multiply it by INT_RANGE and store into an integer. + int64_t b(a / (360.0) * INT_RANGE); + // Clamp it between [-INT_RANGE / 2, INT_RANGE / 2) + b = b % INT_RANGE; + if (b < 0) { - a += 360; + b += INT_RANGE; } - - NS_ASSERT_MSG(0 <= a && a < 360, "Invalid wrap, a=" << a); - return a; + else if (b >= INT_RANGE) + { + b -= INT_RANGE; + } + // Divide by INT_RANGE and multiply by 360. + return b * (360.0) / INT_RANGE; } double WrapTo180(double a) { - a = fmod(a + 180, 360); - if (a < 0) + static constexpr int64_t INT_RANGE = 100000000000; + // Divide the input by 360. + // Multiply it by INT_RANGE and store into an integer. + int64_t b(a / (360.0) * INT_RANGE); + // Clamp it between [-INT_RANGE / 2, INT_RANGE / 2) + b = b % INT_RANGE; + if (b < -INT_RANGE / 2) { - a += 360; + b += INT_RANGE; } - a -= 180; - - NS_ASSERT_MSG(-180 <= a && a < 180, "Invalid wrap, a=" << a); - return a; + else if (b >= INT_RANGE / 2) + { + b -= INT_RANGE; + } + // Divide by INT_RANGE and multiply by 360. + return b * (360.0) / INT_RANGE; } double WrapTo2Pi(double a) { - a = fmod(a, 2 * M_PI); - if (a < 0) + static constexpr int64_t INT_RANGE = 100000000000; + // Divide the input by 2*M_PI. + // Multiply it by INT_RANGE and store into an integer. + int64_t b(a / (2 * M_PI) * INT_RANGE); + // Clamp it between [-INT_RANGE / 2, INT_RANGE / 2) + b = b % INT_RANGE; + if (b < 0) { - a += 2 * M_PI; + b += INT_RANGE; } - - NS_ASSERT_MSG(0 <= a && a < 2 * M_PI, "Invalid wrap, a=" << a); - return a; + else if (b >= INT_RANGE) + { + b -= INT_RANGE; + } + // Divide by INT_RANGE and multiply by 2*M_PI. + return b * (2 * M_PI) / INT_RANGE; } double WrapToPi(double a) { - a = fmod(a + M_PI, 2 * M_PI); - if (a < 0) + static constexpr int64_t INT_RANGE = 100000000000; + // Divide the input by 2*M_PI. + // Multiply it by INT_RANGE and store into an integer. + int64_t b(a / (2 * M_PI) * INT_RANGE); + // Clamp it between [-INT_RANGE / 2, INT_RANGE / 2) + b = b % INT_RANGE; + if (b < -INT_RANGE / 2) { - a += 2 * M_PI; + b += INT_RANGE; } - a -= M_PI; - - NS_ASSERT_MSG(-M_PI <= a && a < M_PI, "Invalid wrap, a=" << a); - return a; + else if (b >= INT_RANGE / 2) + { + b -= INT_RANGE; + } + // Divide by INT_RANGE and multiply by 2*M_PI. + return b * (2 * M_PI) / INT_RANGE; } std::ostream& diff --git a/src/antenna/model/antenna-model.h b/src/antenna/model/antenna-model.h index 788bbf39d..5dd0871dd 100644 --- a/src/antenna/model/antenna-model.h +++ b/src/antenna/model/antenna-model.h @@ -20,7 +20,8 @@ #ifndef ANTENNA_MODEL_H #define ANTENNA_MODEL_H -#include +#include "angles.h" + #include namespace ns3 diff --git a/src/antenna/model/cosine-antenna-model.h b/src/antenna/model/cosine-antenna-model.h index 825b2fce6..a2b653059 100644 --- a/src/antenna/model/cosine-antenna-model.h +++ b/src/antenna/model/cosine-antenna-model.h @@ -20,7 +20,8 @@ #ifndef COSINE_ANTENNA_MODEL_H #define COSINE_ANTENNA_MODEL_H -#include +#include "antenna-model.h" + #include namespace ns3 diff --git a/src/antenna/model/isotropic-antenna-model.h b/src/antenna/model/isotropic-antenna-model.h index f8e976eb8..7d15bacf8 100644 --- a/src/antenna/model/isotropic-antenna-model.h +++ b/src/antenna/model/isotropic-antenna-model.h @@ -20,7 +20,8 @@ #ifndef ISOTROPIC_ANTENNA_MODEL_H #define ISOTROPIC_ANTENNA_MODEL_H -#include +#include "antenna-model.h" + #include namespace ns3 diff --git a/src/antenna/model/parabolic-antenna-model.h b/src/antenna/model/parabolic-antenna-model.h index 720b51673..05afd9fdb 100644 --- a/src/antenna/model/parabolic-antenna-model.h +++ b/src/antenna/model/parabolic-antenna-model.h @@ -20,7 +20,8 @@ #ifndef PARABOLIC_ANTENNA_MODEL_H #define PARABOLIC_ANTENNA_MODEL_H -#include +#include "antenna-model.h" + #include namespace ns3 diff --git a/src/antenna/model/phased-array-model.cc b/src/antenna/model/phased-array-model.cc index f2af5b859..81477811d 100644 --- a/src/antenna/model/phased-array-model.cc +++ b/src/antenna/model/phased-array-model.cc @@ -17,9 +17,10 @@ #include "phased-array-model.h" +#include "isotropic-antenna-model.h" + #include #include -#include #include #include #include diff --git a/src/antenna/model/phased-array-model.h b/src/antenna/model/phased-array-model.h index 9f6472536..e1129a80a 100644 --- a/src/antenna/model/phased-array-model.h +++ b/src/antenna/model/phased-array-model.h @@ -18,8 +18,9 @@ #ifndef PHASED_ARRAY_MODEL_H #define PHASED_ARRAY_MODEL_H -#include -#include +#include "angles.h" +#include "antenna-model.h" + #include #include diff --git a/src/antenna/model/three-gpp-antenna-model.h b/src/antenna/model/three-gpp-antenna-model.h index 78fd144be..453e719e2 100644 --- a/src/antenna/model/three-gpp-antenna-model.h +++ b/src/antenna/model/three-gpp-antenna-model.h @@ -18,7 +18,8 @@ #ifndef THREE_GPP_ANTENNA_MODEL_H #define THREE_GPP_ANTENNA_MODEL_H -#include +#include "antenna-model.h" + #include namespace ns3 diff --git a/src/antenna/model/uniform-planar-array.h b/src/antenna/model/uniform-planar-array.h index 70ee3ee0d..82d23c513 100644 --- a/src/antenna/model/uniform-planar-array.h +++ b/src/antenna/model/uniform-planar-array.h @@ -18,8 +18,9 @@ #ifndef UNIFORM_PLANAR_ARRAY_H #define UNIFORM_PLANAR_ARRAY_H +#include "phased-array-model.h" + #include -#include namespace ns3 { diff --git a/src/antenna/test/test-angles.cc b/src/antenna/test/test-angles.cc index 5ce7639f0..d84aa441d 100644 --- a/src/antenna/test/test-angles.cc +++ b/src/antenna/test/test-angles.cc @@ -134,6 +134,156 @@ TwoVectorsConstructorTestCase::DoRun() NS_TEST_EXPECT_MSG_EQ_TOL(a.GetInclination(), m_a.GetInclination(), 1e-10, "incorrect theta"); } +using WrapToRangeFunction = std::function; + +/** + * \ingroup tests + * + * \brief Test bounds for various WrapTo... methods (WrapTo180, WrapTo360, WrapToPi, and WrapTo2Pi) + * by using a std::function wrapper + */ +class WrapToRangeTestCase : public TestCase +{ + public: + /** + * Build the test name + * \param lowerBound the lower bound of the WrapTo... function + * \param upperBound the upper bound of the WrapTo... function + * \return the test name + */ + static std::string BuildNameString(double lowerBound, double upperBound); + /** + * Constructor + * \param wrapper for one of WrapTo180, WrapTo360, WrapToPi, and WrapTo2Pi + * \param lowerBound the corresponding lower bound + * \param upperBound the corresponding upper bound + */ + WrapToRangeTestCase(WrapToRangeFunction wrapper, double lowerBound, double upperBound); + + protected: + /** + * The given wrapper shall wrap an angle into the expected range + * \param wrapPoint an angle + */ + void CheckWrappingPoint(double wrapPoint); + + private: + void DoRun() override; + + WrapToRangeFunction m_wrapper; //!< the wrapper function + double m_lowerBound; //!< the corresponding lower bound + double m_upperBound; //!< the corresponding upper bound +}; + +std::string +WrapToRangeTestCase::BuildNameString(double lowerBound, double upperBound) +{ + std::ostringstream oss; + oss << "WrapTo [" << lowerBound << ", " << upperBound << ")"; + return oss.str(); +} + +WrapToRangeTestCase::WrapToRangeTestCase(WrapToRangeFunction wrapper, + double lowerBound, + double upperBound) + : TestCase(BuildNameString(lowerBound, upperBound)), + m_wrapper(wrapper), + m_lowerBound(lowerBound), + m_upperBound(upperBound) +{ +} + +void +WrapToRangeTestCase::DoRun() +{ + CheckWrappingPoint(m_lowerBound); + CheckWrappingPoint(m_upperBound); +} + +void +WrapToRangeTestCase::CheckWrappingPoint(double wrapPoint) +{ + constexpr int STEP_NUM = 100; + double directions[] = {std::numeric_limits::lowest(), + std::numeric_limits::max()}; + for (double dir : directions) + { + int i = 0; + for (double x = wrapPoint; i < STEP_NUM; x = std::nextafter(x, dir), ++i) + { + // If asserts are enabled, this test will crash with an assert instead of failing + double result = m_wrapper(x); + NS_TEST_EXPECT_MSG_EQ((m_lowerBound <= result), + true, + "Invalid wrap (too low) " << x << " maps to " << result << " and " + << result - m_lowerBound); + NS_TEST_EXPECT_MSG_EQ((result < m_upperBound), + true, + "Invalid wrap (too high) " << x << " maps to " << result + << " and " << result - m_lowerBound); + } + } +} + +/** + * \ingroup tests + * + * \brief Test the output for WrapToRangeFunction + */ +class WrapToRangeFunctionalTestCase : public TestCase +{ + public: + /** + * Build the test name + * \param angle the angle + * \param wrappedAngle the expected result + * \return the test name + */ + static std::string BuildNameString(double angle, double wrappedAngle); + /** + * Constructor + * \param wrapper one WrapToRangeFunction + * \param angle the angle + * \param wrappedAngle the expected result + */ + WrapToRangeFunctionalTestCase(WrapToRangeFunction wrapper, double angle, double wrappedAngle); + + private: + void DoRun() override; + + WrapToRangeFunction m_wrapper; //!< the wrapper function + double m_angle; //!< the input angle + double m_wrappedAngle; //!< the expected wrapper angle +}; + +std::string +WrapToRangeFunctionalTestCase::BuildNameString(double angle, double wrappedAngle) +{ + std::ostringstream oss; + oss << "Wrap " << angle << " to " << wrappedAngle; + return oss.str(); +} + +WrapToRangeFunctionalTestCase::WrapToRangeFunctionalTestCase(WrapToRangeFunction wrapper, + double angle, + double wrappedAngle) + : TestCase(BuildNameString(angle, wrappedAngle)), + m_wrapper(wrapper), + m_angle(angle), + m_wrappedAngle(wrappedAngle) +{ +} + +void +WrapToRangeFunctionalTestCase::DoRun() +{ + NS_TEST_EXPECT_MSG_EQ_TOL(m_wrapper(m_angle), + m_wrappedAngle, + 1e-6, + "Invalid wrap " << m_angle << " wrapped to " << m_wrapper(m_angle) + << " instead of " << m_wrappedAngle); +} + /** * \ingroup tests * @@ -355,6 +505,18 @@ AnglesTestSuite::AnglesTestSuite() Vector(-0.5, 12.45, -1), Angles(-M_PI_4, M_PI_4)), TestCase::QUICK); + AddTestCase(new WrapToRangeTestCase(WrapTo180, -180, 180), TestCase::QUICK); + AddTestCase(new WrapToRangeTestCase(WrapToPi, -M_PI, M_PI), TestCase::QUICK); + AddTestCase(new WrapToRangeTestCase(WrapTo360, 0, 360), TestCase::QUICK); + AddTestCase(new WrapToRangeTestCase(WrapTo2Pi, 0, 2 * M_PI), TestCase::QUICK); + AddTestCase(new WrapToRangeFunctionalTestCase(WrapTo180, -182.2, 177.8), TestCase::QUICK); + AddTestCase(new WrapToRangeFunctionalTestCase(WrapTo180, -179, -179), TestCase::QUICK); + AddTestCase(new WrapToRangeFunctionalTestCase(WrapTo180, 181, -179), TestCase::QUICK); + AddTestCase(new WrapToRangeFunctionalTestCase(WrapTo180, 360.6, 0.6), TestCase::QUICK); + AddTestCase(new WrapToRangeFunctionalTestCase(WrapTo360, -182.8, 177.2), TestCase::QUICK); + AddTestCase(new WrapToRangeFunctionalTestCase(WrapTo360, -179, 181), TestCase::QUICK); + AddTestCase(new WrapToRangeFunctionalTestCase(WrapTo360, 181, 181), TestCase::QUICK); + AddTestCase(new WrapToRangeFunctionalTestCase(WrapTo360, 360.2, 0.2), TestCase::QUICK); } /// Static variable for test initialization diff --git a/src/aodv/helper/aodv-helper.cc b/src/aodv/helper/aodv-helper.cc index f00401333..5fd6c2cc8 100644 --- a/src/aodv/helper/aodv-helper.cc +++ b/src/aodv/helper/aodv-helper.cc @@ -59,7 +59,7 @@ AodvHelper::AssignStreams(NodeContainer c, int64_t stream) { int64_t currentStream = stream; Ptr node; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); Ptr ipv4 = node->GetObject(); diff --git a/src/aodv/model/aodv-id-cache.cc b/src/aodv/model/aodv-id-cache.cc index b8b9a075b..b00cacb22 100644 --- a/src/aodv/model/aodv-id-cache.cc +++ b/src/aodv/model/aodv-id-cache.cc @@ -36,7 +36,7 @@ bool IdCache::IsDuplicate(Ipv4Address addr, uint32_t id) { Purge(); - for (std::vector::const_iterator i = m_idCache.begin(); i != m_idCache.end(); ++i) + for (auto i = m_idCache.begin(); i != m_idCache.end(); ++i) { if (i->m_context == addr && i->m_id == id) { diff --git a/src/aodv/model/aodv-neighbor.cc b/src/aodv/model/aodv-neighbor.cc index caa94d63b..3d7e6b4d7 100644 --- a/src/aodv/model/aodv-neighbor.cc +++ b/src/aodv/model/aodv-neighbor.cc @@ -51,7 +51,7 @@ bool Neighbors::IsNeighbor(Ipv4Address addr) { Purge(); - for (std::vector::const_iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_neighborAddress == addr) { @@ -65,7 +65,7 @@ Time Neighbors::GetExpireTime(Ipv4Address addr) { Purge(); - for (std::vector::const_iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_neighborAddress == addr) { @@ -78,7 +78,7 @@ Neighbors::GetExpireTime(Ipv4Address addr) void Neighbors::Update(Ipv4Address addr, Time expire) { - for (std::vector::iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_neighborAddress == addr) { @@ -125,7 +125,7 @@ Neighbors::Purge() CloseNeighbor pred; if (!m_handleLinkFailure.IsNull()) { - for (std::vector::iterator j = m_nb.begin(); j != m_nb.end(); ++j) + for (auto j = m_nb.begin(); j != m_nb.end(); ++j) { if (pred(*j)) { @@ -162,7 +162,7 @@ Mac48Address Neighbors::LookupMacAddress(Ipv4Address addr) { Mac48Address hwaddr; - for (std::vector>::const_iterator i = m_arp.begin(); i != m_arp.end(); ++i) + for (auto i = m_arp.begin(); i != m_arp.end(); ++i) { ArpCache::Entry* entry = (*i)->Lookup(addr); if (entry != nullptr && (entry->IsAlive() || entry->IsPermanent()) && !entry->IsExpired()) @@ -179,7 +179,7 @@ Neighbors::ProcessTxError(const WifiMacHeader& hdr) { Mac48Address addr = hdr.GetAddr1(); - for (std::vector::iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_hardwareAddress == addr) { diff --git a/src/aodv/model/aodv-packet.cc b/src/aodv/model/aodv-packet.cc index a6741e21c..bdf7684df 100644 --- a/src/aodv/model/aodv-packet.cc +++ b/src/aodv/model/aodv-packet.cc @@ -554,8 +554,7 @@ RerrHeader::Serialize(Buffer::Iterator i) const i.WriteU8(m_flag); i.WriteU8(m_reserved); i.WriteU8(GetDestCount()); - std::map::const_iterator j; - for (j = m_unreachableDstSeqNo.begin(); j != m_unreachableDstSeqNo.end(); ++j) + for (auto j = m_unreachableDstSeqNo.begin(); j != m_unreachableDstSeqNo.end(); ++j) { WriteTo(i, (*j).first); i.WriteHtonU32((*j).second); @@ -588,8 +587,7 @@ void RerrHeader::Print(std::ostream& os) const { os << "Unreachable destination (ipv4 address, seq. number):"; - std::map::const_iterator j; - for (j = m_unreachableDstSeqNo.begin(); j != m_unreachableDstSeqNo.end(); ++j) + for (auto j = m_unreachableDstSeqNo.begin(); j != m_unreachableDstSeqNo.end(); ++j) { os << (*j).first << ", " << (*j).second; } @@ -635,7 +633,7 @@ RerrHeader::RemoveUnDestination(std::pair& un) { return false; } - std::map::iterator i = m_unreachableDstSeqNo.begin(); + auto i = m_unreachableDstSeqNo.begin(); un = *i; m_unreachableDstSeqNo.erase(i); return true; @@ -657,8 +655,8 @@ RerrHeader::operator==(const RerrHeader& o) const return false; } - std::map::const_iterator j = m_unreachableDstSeqNo.begin(); - std::map::const_iterator k = o.m_unreachableDstSeqNo.begin(); + auto j = m_unreachableDstSeqNo.begin(); + auto k = o.m_unreachableDstSeqNo.begin(); for (uint8_t i = 0; i < GetDestCount(); ++i) { if ((j->first != k->first) || (j->second != k->second)) diff --git a/src/aodv/model/aodv-routing-protocol.cc b/src/aodv/model/aodv-routing-protocol.cc index 94cb44489..b0352e413 100644 --- a/src/aodv/model/aodv-routing-protocol.cc +++ b/src/aodv/model/aodv-routing-protocol.cc @@ -362,15 +362,12 @@ void RoutingProtocol::DoDispose() { m_ipv4 = nullptr; - for (std::map, Ipv4InterfaceAddress>::iterator iter = m_socketAddresses.begin(); - iter != m_socketAddresses.end(); - iter++) + for (auto iter = m_socketAddresses.begin(); iter != m_socketAddresses.end(); iter++) { iter->first->Close(); } m_socketAddresses.clear(); - for (std::map, Ipv4InterfaceAddress>::iterator iter = - m_socketSubnetBroadcastAddresses.begin(); + for (auto iter = m_socketSubnetBroadcastAddresses.begin(); iter != m_socketSubnetBroadcastAddresses.end(); iter++) { @@ -541,9 +538,7 @@ RoutingProtocol::RouteInput(Ptr p, } // Broadcast local delivery/forwarding - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ipv4InterfaceAddress iface = j->second; if (m_ipv4->GetInterfaceForAddress(iface.GetLocal()) == iif) @@ -984,9 +979,7 @@ bool RoutingProtocol::IsMyOwnAddress(Ipv4Address src) { NS_LOG_FUNCTION(this << src); - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ipv4InterfaceAddress iface = j->second; if (src == iface.GetLocal()) @@ -1020,7 +1013,7 @@ RoutingProtocol::LoopbackRoute(const Ipv4Header& hdr, Ptr oif) const // If RouteOutput() caller specified an outgoing interface, that // further constrains the selection of source address // - std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); + auto j = m_socketAddresses.begin(); if (oif) { // Iterate to find an address on the oif device @@ -1136,9 +1129,7 @@ RoutingProtocol::SendRequest(Ipv4Address dst) rreqHeader.SetId(m_requestId); // Send RREQ as subnet directed broadcast from each interface used by aodv - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; @@ -1505,9 +1496,7 @@ RoutingProtocol::RecvRequest(Ptr p, Ipv4Address receiver, Ipv4Address sr return; } - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; @@ -1868,9 +1857,7 @@ RoutingProtocol::RecvError(Ptr p, Ipv4Address src) std::pair un; while (rerrHeader.RemoveUnDestination(un)) { - for (std::map::const_iterator i = dstWithNextHopSrc.begin(); - i != dstWithNextHopSrc.end(); - ++i) + for (auto i = dstWithNextHopSrc.begin(); i != dstWithNextHopSrc.end(); ++i) { if (i->first == un.first) { @@ -1880,8 +1867,7 @@ RoutingProtocol::RecvError(Ptr p, Ipv4Address src) } std::vector precursors; - for (std::map::const_iterator i = unreachable.begin(); - i != unreachable.end();) + for (auto i = unreachable.begin(); i != unreachable.end();) { if (!rerrHeader.AddUnDestination(i->first, i->second)) { @@ -2013,9 +1999,7 @@ RoutingProtocol::SendHello() * Hop Count 0 * Lifetime AllowedHelloLoss * HelloInterval */ - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; @@ -2087,8 +2071,7 @@ RoutingProtocol::SendRerrWhenBreaksLinkToNextHop(Ipv4Address nextHop) toNextHop.GetPrecursors(precursors); rerrHeader.AddUnDestination(nextHop, toNextHop.GetSeqNo()); m_routingTable.GetListOfDestinationWithNextHop(nextHop, unreachable); - for (std::map::const_iterator i = unreachable.begin(); - i != unreachable.end();) + for (auto i = unreachable.begin(); i != unreachable.end();) { if (!rerrHeader.AddUnDestination(i->first, i->second)) { @@ -2161,10 +2144,7 @@ RoutingProtocol::SendRerrWhenNoRouteToForward(Ipv4Address dst, } else { - for (std::map, Ipv4InterfaceAddress>::const_iterator i = - m_socketAddresses.begin(); - i != m_socketAddresses.end(); - ++i) + for (auto i = m_socketAddresses.begin(); i != m_socketAddresses.end(); ++i) { Ptr socket = i->first; Ipv4InterfaceAddress iface = i->second; @@ -2232,8 +2212,7 @@ RoutingProtocol::SendRerrMessage(Ptr packet, std::vector pr // route std::vector ifaces; RoutingTableEntry toPrecursor; - for (std::vector::const_iterator i = precursors.begin(); i != precursors.end(); - ++i) + for (auto i = precursors.begin(); i != precursors.end(); ++i) { if (m_routingTable.LookupValidRoute(*i, toPrecursor) && std::find(ifaces.begin(), ifaces.end(), toPrecursor.GetInterface()) == ifaces.end()) @@ -2242,8 +2221,7 @@ RoutingProtocol::SendRerrMessage(Ptr packet, std::vector pr } } - for (std::vector::const_iterator i = ifaces.begin(); i != ifaces.end(); - ++i) + for (auto i = ifaces.begin(); i != ifaces.end(); ++i) { Ptr socket = FindSocketWithInterfaceAddress(*i); NS_ASSERT(socket); @@ -2273,9 +2251,7 @@ Ptr RoutingProtocol::FindSocketWithInterfaceAddress(Ipv4InterfaceAddress addr) const { NS_LOG_FUNCTION(this << addr); - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; @@ -2292,8 +2268,7 @@ Ptr RoutingProtocol::FindSubnetBroadcastSocketWithInterfaceAddress(Ipv4InterfaceAddress addr) const { NS_LOG_FUNCTION(this << addr); - for (std::map, Ipv4InterfaceAddress>::const_iterator j = - m_socketSubnetBroadcastAddresses.begin(); + for (auto j = m_socketSubnetBroadcastAddresses.begin(); j != m_socketSubnetBroadcastAddresses.end(); ++j) { diff --git a/src/aodv/model/aodv-rqueue.cc b/src/aodv/model/aodv-rqueue.cc index 4b571c5de..b45625613 100644 --- a/src/aodv/model/aodv-rqueue.cc +++ b/src/aodv/model/aodv-rqueue.cc @@ -51,7 +51,7 @@ bool RequestQueue::Enqueue(QueueEntry& entry) { Purge(); - for (std::vector::const_iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if ((i->GetPacket()->GetUid() == entry.GetPacket()->GetUid()) && (i->GetIpv4Header().GetDestination() == entry.GetIpv4Header().GetDestination())) @@ -74,7 +74,7 @@ RequestQueue::DropPacketWithDst(Ipv4Address dst) { NS_LOG_FUNCTION(this << dst); Purge(); - for (std::vector::iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -91,7 +91,7 @@ bool RequestQueue::Dequeue(Ipv4Address dst, QueueEntry& entry) { Purge(); - for (std::vector::iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -106,7 +106,7 @@ RequestQueue::Dequeue(Ipv4Address dst, QueueEntry& entry) bool RequestQueue::Find(Ipv4Address dst) { - for (std::vector::const_iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -138,7 +138,7 @@ void RequestQueue::Purge() { IsExpired pred; - for (std::vector::iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (pred(*i)) { diff --git a/src/aodv/model/aodv-rtable.cc b/src/aodv/model/aodv-rtable.cc index 6962c7453..7b0c1b209 100644 --- a/src/aodv/model/aodv-rtable.cc +++ b/src/aodv/model/aodv-rtable.cc @@ -94,9 +94,7 @@ bool RoutingTableEntry::LookupPrecursor(Ipv4Address id) { NS_LOG_FUNCTION(this << id); - for (std::vector::const_iterator i = m_precursorList.begin(); - i != m_precursorList.end(); - ++i) + for (auto i = m_precursorList.begin(); i != m_precursorList.end(); ++i) { if (*i == id) { @@ -112,8 +110,7 @@ bool RoutingTableEntry::DeletePrecursor(Ipv4Address id) { NS_LOG_FUNCTION(this << id); - std::vector::iterator i = - std::remove(m_precursorList.begin(), m_precursorList.end(), id); + auto i = std::remove(m_precursorList.begin(), m_precursorList.end(), id); if (i == m_precursorList.end()) { NS_LOG_LOGIC("Precursor " << id << " not found"); @@ -148,16 +145,15 @@ RoutingTableEntry::GetPrecursors(std::vector& prec) const { return; } - for (std::vector::const_iterator i = m_precursorList.begin(); - i != m_precursorList.end(); - ++i) + for (auto i = m_precursorList.begin(); i != m_precursorList.end(); ++i) { bool result = true; - for (std::vector::const_iterator j = prec.begin(); j != prec.end(); ++j) + for (auto j = prec.begin(); j != prec.end(); ++j) { if (*j == *i) { result = false; + break; } } if (result) @@ -243,7 +239,7 @@ RoutingTable::LookupRoute(Ipv4Address id, RoutingTableEntry& rt) NS_LOG_LOGIC("Route to " << id << " not found; m_ipv4AddressEntry is empty"); return false; } - std::map::const_iterator i = m_ipv4AddressEntry.find(id); + auto i = m_ipv4AddressEntry.find(id); if (i == m_ipv4AddressEntry.end()) { NS_LOG_LOGIC("Route to " << id << " not found"); @@ -291,8 +287,7 @@ RoutingTable::AddRoute(RoutingTableEntry& rt) { rt.SetRreqCnt(0); } - std::pair::iterator, bool> result = - m_ipv4AddressEntry.insert(std::make_pair(rt.GetDestination(), rt)); + auto result = m_ipv4AddressEntry.insert(std::make_pair(rt.GetDestination(), rt)); return result.second; } @@ -300,8 +295,7 @@ bool RoutingTable::Update(RoutingTableEntry& rt) { NS_LOG_FUNCTION(this); - std::map::iterator i = - m_ipv4AddressEntry.find(rt.GetDestination()); + auto i = m_ipv4AddressEntry.find(rt.GetDestination()); if (i == m_ipv4AddressEntry.end()) { NS_LOG_LOGIC("Route update to " << rt.GetDestination() << " fails; not found"); @@ -320,7 +314,7 @@ bool RoutingTable::SetEntryState(Ipv4Address id, RouteFlags state) { NS_LOG_FUNCTION(this); - std::map::iterator i = m_ipv4AddressEntry.find(id); + auto i = m_ipv4AddressEntry.find(id); if (i == m_ipv4AddressEntry.end()) { NS_LOG_LOGIC("Route set entry state to " << id << " fails; not found"); @@ -339,9 +333,7 @@ RoutingTable::GetListOfDestinationWithNextHop(Ipv4Address nextHop, NS_LOG_FUNCTION(this); Purge(); unreachable.clear(); - for (std::map::const_iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end(); - ++i) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i) { if (i->second.GetNextHop() == nextHop) { @@ -356,13 +348,9 @@ RoutingTable::InvalidateRoutesWithDst(const std::map& unr { NS_LOG_FUNCTION(this); Purge(); - for (std::map::iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end(); - ++i) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i) { - for (std::map::const_iterator j = unreachable.begin(); - j != unreachable.end(); - ++j) + for (auto j = unreachable.begin(); j != unreachable.end(); ++j) { if ((i->first == j->first) && (i->second.GetFlag() == VALID)) { @@ -381,12 +369,11 @@ RoutingTable::DeleteAllRoutesFromInterface(Ipv4InterfaceAddress iface) { return; } - for (std::map::iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end();) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end();) { if (i->second.GetInterface() == iface) { - std::map::iterator tmp = i; + auto tmp = i; ++i; m_ipv4AddressEntry.erase(tmp); } @@ -405,14 +392,13 @@ RoutingTable::Purge() { return; } - for (std::map::iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end();) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end();) { if (i->second.GetLifeTime() < Seconds(0)) { if (i->second.GetFlag() == INVALID) { - std::map::iterator tmp = i; + auto tmp = i; ++i; m_ipv4AddressEntry.erase(tmp); } @@ -442,13 +428,13 @@ RoutingTable::Purge(std::map& table) const { return; } - for (std::map::iterator i = table.begin(); i != table.end();) + for (auto i = table.begin(); i != table.end();) { if (i->second.GetLifeTime() < Seconds(0)) { if (i->second.GetFlag() == INVALID) { - std::map::iterator tmp = i; + auto tmp = i; ++i; table.erase(tmp); } @@ -474,7 +460,7 @@ bool RoutingTable::MarkLinkAsUnidirectional(Ipv4Address neighbor, Time blacklistTimeout) { NS_LOG_FUNCTION(this << neighbor << blacklistTimeout.As(Time::S)); - std::map::iterator i = m_ipv4AddressEntry.find(neighbor); + auto i = m_ipv4AddressEntry.find(neighbor); if (i == m_ipv4AddressEntry.end()) { NS_LOG_LOGIC("Mark link unidirectional to " << neighbor << " fails; not found"); @@ -505,9 +491,7 @@ RoutingTable::Print(Ptr stream, Time::Unit unit /* = Time:: *os << std::setw(16) << "Flag"; *os << std::setw(16) << "Expire"; *os << "Hops" << std::endl; - for (std::map::const_iterator i = table.begin(); - i != table.end(); - ++i) + for (auto i = table.begin(); i != table.end(); ++i) { i->second.Print(stream, unit); } diff --git a/src/aodv/test/aodv-test-suite.cc b/src/aodv/test/aodv-test-suite.cc index 5f3f903de..35e8cc9ff 100644 --- a/src/aodv/test/aodv-test-suite.cc +++ b/src/aodv/test/aodv-test-suite.cc @@ -317,11 +317,11 @@ struct RerrHeaderTest : public TestCase RerrHeader h; h.SetNoDelete(true); NS_TEST_EXPECT_MSG_EQ(h.GetNoDelete(), true, "trivial"); - Ipv4Address dst = Ipv4Address("1.2.3.4"); + Ipv4Address dst("1.2.3.4"); NS_TEST_EXPECT_MSG_EQ(h.AddUnDestination(dst, 12), true, "trivial"); NS_TEST_EXPECT_MSG_EQ(h.GetDestCount(), 1, "trivial"); NS_TEST_EXPECT_MSG_EQ(h.AddUnDestination(dst, 13), true, "trivial"); - Ipv4Address dst2 = Ipv4Address("4.3.2.1"); + Ipv4Address dst2("4.3.2.1"); NS_TEST_EXPECT_MSG_EQ(h.AddUnDestination(dst2, 12), true, "trivial"); NS_TEST_EXPECT_MSG_EQ(h.GetDestCount(), 2, "trivial"); diff --git a/src/applications/helper/bulk-send-helper.cc b/src/applications/helper/bulk-send-helper.cc index 1d7c4b2f7..6e53e06d4 100644 --- a/src/applications/helper/bulk-send-helper.cc +++ b/src/applications/helper/bulk-send-helper.cc @@ -59,7 +59,7 @@ ApplicationContainer BulkSendHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/applications/helper/on-off-helper.cc b/src/applications/helper/on-off-helper.cc index 311fee0f4..5dfcdbc13 100644 --- a/src/applications/helper/on-off-helper.cc +++ b/src/applications/helper/on-off-helper.cc @@ -60,7 +60,7 @@ ApplicationContainer OnOffHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } @@ -82,7 +82,7 @@ OnOffHelper::AssignStreams(NodeContainer c, int64_t stream) { int64_t currentStream = stream; Ptr node; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); for (uint32_t j = 0; j < node->GetNApplications(); j++) diff --git a/src/applications/helper/packet-sink-helper.cc b/src/applications/helper/packet-sink-helper.cc index a1e2139f8..72f8af81a 100644 --- a/src/applications/helper/packet-sink-helper.cc +++ b/src/applications/helper/packet-sink-helper.cc @@ -56,7 +56,7 @@ ApplicationContainer PacketSinkHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/applications/helper/three-gpp-http-helper.cc b/src/applications/helper/three-gpp-http-helper.cc index 85fc270c3..4cc25643a 100644 --- a/src/applications/helper/three-gpp-http-helper.cc +++ b/src/applications/helper/three-gpp-http-helper.cc @@ -61,7 +61,7 @@ ApplicationContainer ThreeGppHttpClientHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } @@ -109,7 +109,7 @@ ApplicationContainer ThreeGppHttpServerHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/applications/helper/udp-client-server-helper.cc b/src/applications/helper/udp-client-server-helper.cc index 9307bf0ea..99fd4b710 100644 --- a/src/applications/helper/udp-client-server-helper.cc +++ b/src/applications/helper/udp-client-server-helper.cc @@ -48,7 +48,7 @@ ApplicationContainer UdpServerHelper::Install(NodeContainer c) { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; @@ -93,7 +93,7 @@ ApplicationContainer UdpClientHelper::Install(NodeContainer c) { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr client = m_factory.Create(); @@ -133,7 +133,7 @@ ApplicationContainer UdpTraceClientHelper::Install(NodeContainer c) { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr client = m_factory.Create(); diff --git a/src/applications/helper/udp-echo-helper.cc b/src/applications/helper/udp-echo-helper.cc index e8b24a8db..ce5760223 100644 --- a/src/applications/helper/udp-echo-helper.cc +++ b/src/applications/helper/udp-echo-helper.cc @@ -55,7 +55,7 @@ ApplicationContainer UdpEchoServerHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } @@ -129,7 +129,7 @@ ApplicationContainer UdpEchoClientHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/applications/model/application-packet-probe.cc b/src/applications/model/application-packet-probe.cc index 00ffa7b42..909caf7f0 100644 --- a/src/applications/model/application-packet-probe.cc +++ b/src/applications/model/application-packet-probe.cc @@ -20,7 +20,7 @@ * Modified by: Mitch Watrous (watrous@u.washington.edu) */ -#include "ns3/application-packet-probe.h" +#include "application-packet-probe.h" #include "ns3/config.h" #include "ns3/log.h" diff --git a/src/applications/model/bulk-send-application.h b/src/applications/model/bulk-send-application.h index bb809fe1b..1e8a835d9 100644 --- a/src/applications/model/bulk-send-application.h +++ b/src/applications/model/bulk-send-application.h @@ -20,11 +20,12 @@ #ifndef BULK_SEND_APPLICATION_H #define BULK_SEND_APPLICATION_H +#include "seq-ts-size-header.h" + #include "ns3/address.h" #include "ns3/application.h" #include "ns3/event-id.h" #include "ns3/ptr.h" -#include "ns3/seq-ts-size-header.h" #include "ns3/traced-callback.h" namespace ns3 diff --git a/src/applications/model/onoff-application.h b/src/applications/model/onoff-application.h index e1cb143a7..eb69943c8 100644 --- a/src/applications/model/onoff-application.h +++ b/src/applications/model/onoff-application.h @@ -24,12 +24,13 @@ #ifndef ONOFF_APPLICATION_H #define ONOFF_APPLICATION_H +#include "seq-ts-size-header.h" + #include "ns3/address.h" #include "ns3/application.h" #include "ns3/data-rate.h" #include "ns3/event-id.h" #include "ns3/ptr.h" -#include "ns3/seq-ts-size-header.h" #include "ns3/traced-callback.h" namespace ns3 diff --git a/src/applications/model/packet-loss-counter.cc b/src/applications/model/packet-loss-counter.cc index 362986585..0f0574e2e 100644 --- a/src/applications/model/packet-loss-counter.cc +++ b/src/applications/model/packet-loss-counter.cc @@ -113,14 +113,14 @@ PacketLossCounter::NotifyReceived(uint32_t seqNum) NS_LOG_FUNCTION(this << seqNum); for (uint32_t i = m_lastMaxSeqNum + 1; i <= seqNum; i++) { - if (GetBit(i) != 1) + if (!GetBit(i)) { NS_LOG_INFO("Packet lost: " << i - (m_bitMapSize * 8)); m_lost++; } - SetBit(i, 0); + SetBit(i, false); } - SetBit(seqNum, 1); + SetBit(seqNum, true); if (seqNum > m_lastMaxSeqNum) { m_lastMaxSeqNum = seqNum; diff --git a/src/applications/model/packet-sink.h b/src/applications/model/packet-sink.h index 170dee422..bd66f6e56 100644 --- a/src/applications/model/packet-sink.h +++ b/src/applications/model/packet-sink.h @@ -20,13 +20,14 @@ #ifndef PACKET_SINK_H #define PACKET_SINK_H +#include "seq-ts-size-header.h" + #include "ns3/address.h" #include "ns3/application.h" #include "ns3/event-id.h" #include "ns3/inet-socket-address.h" #include "ns3/inet6-socket-address.h" #include "ns3/ptr.h" -#include "ns3/seq-ts-size-header.h" #include "ns3/traced-callback.h" #include diff --git a/src/applications/model/seq-ts-size-header.h b/src/applications/model/seq-ts-size-header.h index 1bc0e4528..c2c71a7b0 100644 --- a/src/applications/model/seq-ts-size-header.h +++ b/src/applications/model/seq-ts-size-header.h @@ -20,7 +20,7 @@ #ifndef SEQ_TS_SIZE_HEADER_H #define SEQ_TS_SIZE_HEADER_H -#include +#include "seq-ts-header.h" namespace ns3 { diff --git a/src/applications/model/three-gpp-http-client.cc b/src/applications/model/three-gpp-http-client.cc index ecf837d49..2fde0d5df 100644 --- a/src/applications/model/three-gpp-http-client.cc +++ b/src/applications/model/three-gpp-http-client.cc @@ -20,6 +20,8 @@ #include "three-gpp-http-client.h" +#include "three-gpp-http-variables.h" + #include #include #include @@ -30,7 +32,6 @@ #include #include #include -#include #include NS_LOG_COMPONENT_DEFINE("ThreeGppHttpClient"); diff --git a/src/applications/model/three-gpp-http-client.h b/src/applications/model/three-gpp-http-client.h index d0ad86ce7..344f9ec71 100644 --- a/src/applications/model/three-gpp-http-client.h +++ b/src/applications/model/three-gpp-http-client.h @@ -21,9 +21,10 @@ #ifndef THREE_GPP_HTTP_CLIENT_H #define THREE_GPP_HTTP_CLIENT_H +#include "three-gpp-http-header.h" + #include #include -#include #include namespace ns3 diff --git a/src/applications/model/three-gpp-http-server.cc b/src/applications/model/three-gpp-http-server.cc index f458a49bb..3f7caa76d 100644 --- a/src/applications/model/three-gpp-http-server.cc +++ b/src/applications/model/three-gpp-http-server.cc @@ -20,6 +20,8 @@ #include "three-gpp-http-server.h" +#include "three-gpp-http-variables.h" + #include #include #include @@ -31,7 +33,6 @@ #include #include #include -#include #include NS_LOG_COMPONENT_DEFINE("ThreeGppHttpServer"); @@ -632,8 +633,7 @@ ThreeGppHttpServerTxBuffer::ThreeGppHttpServerTxBuffer() bool ThreeGppHttpServerTxBuffer::IsSocketAvailable(Ptr socket) const { - std::map, TxBuffer_t>::const_iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); return (it != m_txBuffer.end()); } @@ -659,8 +659,7 @@ ThreeGppHttpServerTxBuffer::RemoveSocket(Ptr socket) { NS_LOG_FUNCTION(this << socket); - std::map, TxBuffer_t>::iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); if (!Simulator::IsExpired(it->second.nextServe)) @@ -683,8 +682,7 @@ ThreeGppHttpServerTxBuffer::CloseSocket(Ptr socket) { NS_LOG_FUNCTION(this << socket); - std::map, TxBuffer_t>::iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); if (!Simulator::IsExpired(it->second.nextServe)) @@ -715,8 +713,7 @@ ThreeGppHttpServerTxBuffer::CloseAllSockets() { NS_LOG_FUNCTION(this); - std::map, TxBuffer_t>::iterator it; - for (it = m_txBuffer.begin(); it != m_txBuffer.end(); ++it) + for (auto it = m_txBuffer.begin(); it != m_txBuffer.end(); ++it) { if (!Simulator::IsExpired(it->second.nextServe)) { @@ -738,8 +735,7 @@ ThreeGppHttpServerTxBuffer::CloseAllSockets() bool ThreeGppHttpServerTxBuffer::IsBufferEmpty(Ptr socket) const { - std::map, TxBuffer_t>::const_iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); return (it->second.txBufferSize == 0); } @@ -747,8 +743,7 @@ ThreeGppHttpServerTxBuffer::IsBufferEmpty(Ptr socket) const Time ThreeGppHttpServerTxBuffer::GetClientTs(Ptr socket) const { - std::map, TxBuffer_t>::const_iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); return it->second.clientTs; } @@ -756,8 +751,7 @@ ThreeGppHttpServerTxBuffer::GetClientTs(Ptr socket) const ThreeGppHttpHeader::ContentType_t ThreeGppHttpServerTxBuffer::GetBufferContentType(Ptr socket) const { - std::map, TxBuffer_t>::const_iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); return it->second.txBufferContentType; } @@ -765,8 +759,7 @@ ThreeGppHttpServerTxBuffer::GetBufferContentType(Ptr socket) const uint32_t ThreeGppHttpServerTxBuffer::GetBufferSize(Ptr socket) const { - std::map, TxBuffer_t>::const_iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); return it->second.txBufferSize; } @@ -774,8 +767,7 @@ ThreeGppHttpServerTxBuffer::GetBufferSize(Ptr socket) const bool ThreeGppHttpServerTxBuffer::HasTxedPartOfObject(Ptr socket) const { - std::map, TxBuffer_t>::const_iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found"); return it->second.hasTxedPartOfObject; } @@ -791,8 +783,7 @@ ThreeGppHttpServerTxBuffer::WriteNewObject(Ptr socket, "Unable to write an object without a proper Content-Type."); NS_ASSERT_MSG(objectSize > 0, "Unable to write a zero-sized object."); - std::map, TxBuffer_t>::iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); NS_ASSERT_MSG(it->second.txBufferSize == 0, "Cannot write to Tx buffer of socket " @@ -809,8 +800,7 @@ ThreeGppHttpServerTxBuffer::RecordNextServe(Ptr socket, { NS_LOG_FUNCTION(this << socket << clientTs.As(Time::S)); - std::map, TxBuffer_t>::iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); it->second.nextServe = eventId; it->second.clientTs = clientTs; @@ -823,8 +813,7 @@ ThreeGppHttpServerTxBuffer::DepleteBufferSize(Ptr socket, uint32_t amoun NS_ASSERT_MSG(amount > 0, "Unable to consume zero bytes."); - std::map, TxBuffer_t>::iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); NS_ASSERT_MSG(it->second.txBufferSize >= amount, "The requested amount is larger than the current buffer size."); @@ -846,8 +835,7 @@ void ThreeGppHttpServerTxBuffer::PrepareClose(Ptr socket) { NS_LOG_FUNCTION(this << socket); - std::map, TxBuffer_t>::iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); it->second.isClosing = true; } diff --git a/src/applications/model/three-gpp-http-server.h b/src/applications/model/three-gpp-http-server.h index 4b7b1c6ff..e2781ad9d 100644 --- a/src/applications/model/three-gpp-http-server.h +++ b/src/applications/model/three-gpp-http-server.h @@ -21,13 +21,14 @@ #ifndef THREE_GPP_HTTP_SERVER_H #define THREE_GPP_HTTP_SERVER_H +#include "three-gpp-http-header.h" + #include #include #include #include #include #include -#include #include #include diff --git a/src/applications/model/three-gpp-http-variables.cc b/src/applications/model/three-gpp-http-variables.cc index bad12f5c3..f5f2bb328 100644 --- a/src/applications/model/three-gpp-http-variables.cc +++ b/src/applications/model/three-gpp-http-variables.cc @@ -267,7 +267,7 @@ uint32_t ThreeGppHttpVariables::GetNumOfEmbeddedObjects() { // Validate parameters. - const uint32_t upperBound = static_cast(m_numOfEmbeddedObjectsRng->GetBound()); + const auto upperBound = static_cast(m_numOfEmbeddedObjectsRng->GetBound()); if (upperBound <= m_numOfEmbeddedObjectsScale) { NS_FATAL_ERROR("`NumOfEmbeddedObjectsMax` attribute " diff --git a/src/applications/model/udp-trace-client.h b/src/applications/model/udp-trace-client.h index 6b81b5a74..9dd8498e7 100644 --- a/src/applications/model/udp-trace-client.h +++ b/src/applications/model/udp-trace-client.h @@ -39,15 +39,18 @@ class Packet; * * \brief A trace based streamer * - * Sends UDP packets based on a trace file of an MPEG4 stream - * trace files could be downloaded form: - * https://web.archive.org/web/20200729203634/https://earth-info.nga.mil/GandG/publications/tr8350.2/wgs84fin.pdf + * Sends UDP packets based on a trace file of a MPEG4 stream. + * Trace files can be downloaded from: + * http://trace.eas.asu.edu/mpeg4/index.html * (the 2 first lines of the file should be removed) A valid trace file is a file with 4 columns: * \li -1- the first one represents the frame index * \li -2- the second one indicates the type of the frame: I, P or B * \li -3- the third one indicates the time on which the frame was generated by the encoder * (integer, milliseconds) \li -4- the fourth one indicates the frame size in byte * + * Additional trace files can be generated from MPEG4 files using the tool + * available in https://pypi.org/project/trace-extractor/ + * * If no valid MPEG4 trace file is provided to the application the trace from * g_defaultEntries array will be loaded. * diff --git a/src/bridge/helper/bridge-helper.cc b/src/bridge/helper/bridge-helper.cc index 3fea2f89d..d56d504c7 100644 --- a/src/bridge/helper/bridge-helper.cc +++ b/src/bridge/helper/bridge-helper.cc @@ -57,7 +57,7 @@ BridgeHelper::Install(Ptr node, NetDeviceContainer c) devs.Add(dev); node->AddDevice(dev); - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { NS_LOG_LOGIC("**** Add BridgePort " << *i); dev->AddBridgePort(*i); diff --git a/src/bridge/model/bridge-channel.cc b/src/bridge/model/bridge-channel.cc index 56dbdb30b..6d7585357 100644 --- a/src/bridge/model/bridge-channel.cc +++ b/src/bridge/model/bridge-channel.cc @@ -52,9 +52,7 @@ BridgeChannel::~BridgeChannel() { NS_LOG_FUNCTION_NOARGS(); - for (std::vector>::iterator iter = m_bridgedChannels.begin(); - iter != m_bridgedChannels.end(); - iter++) + for (auto iter = m_bridgedChannels.begin(); iter != m_bridgedChannels.end(); iter++) { *iter = nullptr; } @@ -71,9 +69,7 @@ std::size_t BridgeChannel::GetNDevices() const { uint32_t ndevices = 0; - for (std::vector>::const_iterator iter = m_bridgedChannels.begin(); - iter != m_bridgedChannels.end(); - iter++) + for (auto iter = m_bridgedChannels.begin(); iter != m_bridgedChannels.end(); iter++) { ndevices += (*iter)->GetNDevices(); } @@ -84,9 +80,7 @@ Ptr BridgeChannel::GetDevice(std::size_t i) const { std::size_t ndevices = 0; - for (std::vector>::const_iterator iter = m_bridgedChannels.begin(); - iter != m_bridgedChannels.end(); - iter++) + for (auto iter = m_bridgedChannels.begin(); iter != m_bridgedChannels.end(); iter++) { if ((i - ndevices) < (*iter)->GetNDevices()) { diff --git a/src/bridge/model/bridge-net-device.cc b/src/bridge/model/bridge-net-device.cc index 0613232f2..6b0fd1106 100644 --- a/src/bridge/model/bridge-net-device.cc +++ b/src/bridge/model/bridge-net-device.cc @@ -80,8 +80,7 @@ void BridgeNetDevice::DoDispose() { NS_LOG_FUNCTION_NOARGS(); - for (std::vector>::iterator iter = m_ports.begin(); iter != m_ports.end(); - iter++) + for (auto iter = m_ports.begin(); iter != m_ports.end(); iter++) { *iter = nullptr; } @@ -163,8 +162,7 @@ BridgeNetDevice::ForwardUnicast(Ptr incomingPort, else { NS_LOG_LOGIC("No learned state: send through all ports"); - for (std::vector>::iterator iter = m_ports.begin(); iter != m_ports.end(); - iter++) + for (auto iter = m_ports.begin(); iter != m_ports.end(); iter++) { Ptr port = *iter; if (port != incomingPort) @@ -193,8 +191,7 @@ BridgeNetDevice::ForwardBroadcast(Ptr incomingPort, << ", protocol=" << protocol << ", src=" << src << ", dst=" << dst << ")"); Learn(src, incomingPort); - for (std::vector>::iterator iter = m_ports.begin(); iter != m_ports.end(); - iter++) + for (auto iter = m_ports.begin(); iter != m_ports.end(); iter++) { Ptr port = *iter; if (port != incomingPort) @@ -227,7 +224,7 @@ BridgeNetDevice::GetLearnedState(Mac48Address source) if (m_enableLearning) { Time now = Simulator::Now(); - std::map::iterator iter = m_learnState.find(source); + auto iter = m_learnState.find(source); if (iter != m_learnState.end()) { LearnedState& state = iter->second; @@ -420,8 +417,7 @@ BridgeNetDevice::SendFrom(Ptr packet, // data was not unicast or no state has been learned for that mac // address => flood through all ports. Ptr pktCopy; - for (std::vector>::iterator iter = m_ports.begin(); iter != m_ports.end(); - iter++) + for (auto iter = m_ports.begin(); iter != m_ports.end(); iter++) { pktCopy = packet->Copy(); Ptr port = *iter; diff --git a/src/bridge/model/bridge-net-device.h b/src/bridge/model/bridge-net-device.h index 5d29f726f..d5d6f0958 100644 --- a/src/bridge/model/bridge-net-device.h +++ b/src/bridge/model/bridge-net-device.h @@ -17,7 +17,8 @@ #ifndef BRIDGE_NET_DEVICE_H #define BRIDGE_NET_DEVICE_H -#include "ns3/bridge-channel.h" +#include "bridge-channel.h" + #include "ns3/mac48-address.h" #include "ns3/net-device.h" #include "ns3/nstime.h" diff --git a/src/brite/helper/brite-topology-helper.cc b/src/brite/helper/brite-topology-helper.cc index f98728165..d37f60963 100644 --- a/src/brite/helper/brite-topology-helper.cc +++ b/src/brite/helper/brite-topology-helper.cc @@ -186,10 +186,9 @@ BriteTopologyHelper::BuildBriteEdgeInfoList() { NS_LOG_FUNCTION(this); brite::Graph* g = m_topology->GetGraph(); - std::list::iterator el; std::list edgeList = g->GetEdges(); - for (el = edgeList.begin(); el != edgeList.end(); el++) + for (auto el = edgeList.begin(); el != edgeList.end(); el++) { BriteEdgeInfo edgeInfo; edgeInfo.edgeId = (*el)->GetId(); @@ -418,9 +417,7 @@ BriteTopologyHelper::BuildBriteTopology(InternetStackHelper& stack, const uint32 } // create nodes - for (BriteTopologyHelper::BriteNodeInfoList::iterator it = m_briteNodeInfoList.begin(); - it != m_briteNodeInfoList.end(); - ++it) + for (auto it = m_briteNodeInfoList.begin(); it != m_briteNodeInfoList.end(); ++it) { m_nodes.Add(CreateObject(GetSystemNumberForAs((*it).asId))); m_numNodes++; @@ -468,9 +465,7 @@ BriteTopologyHelper::ConstructTopology() m_nodesByAs.push_back(new NodeContainer()); } - for (BriteTopologyHelper::BriteEdgeInfoList::iterator it = m_briteEdgeInfoList.begin(); - it != m_briteEdgeInfoList.end(); - ++it) + for (auto it = m_briteEdgeInfoList.begin(); it != m_briteEdgeInfoList.end(); ++it) { // Set the link delay // The brite value for delay is given in milliseconds @@ -492,9 +487,7 @@ BriteTopologyHelper::ConstructTopology() NS_LOG_INFO("Created " << m_numEdges << " edges in BRITE topology"); // iterate through all nodes and add leaf nodes for each AS - for (BriteTopologyHelper::BriteNodeInfoList::iterator it = m_briteNodeInfoList.begin(); - it != m_briteNodeInfoList.end(); - ++it) + for (auto it = m_briteNodeInfoList.begin(); it != m_briteNodeInfoList.end(); ++it) { m_nodesByAs[(*it).asId]->Add(m_nodes.Get((*it).nodeId)); diff --git a/src/buildings/examples/outdoor-group-mobility-example.cc b/src/buildings/examples/outdoor-group-mobility-example.cc index d9c657cbe..59515ebf8 100644 --- a/src/buildings/examples/outdoor-group-mobility-example.cc +++ b/src/buildings/examples/outdoor-group-mobility-example.cc @@ -111,7 +111,7 @@ PrintGnuplottableBuildingListToFile(std::string filename) return; } uint32_t index = 1; - for (BuildingList::Iterator it = BuildingList::Begin(); it != BuildingList::End(); ++it) + for (auto it = BuildingList::Begin(); it != BuildingList::End(); ++it) { ++index; Box box = (*it)->GetBoundaries(); diff --git a/src/buildings/examples/outdoor-random-walk-example.cc b/src/buildings/examples/outdoor-random-walk-example.cc index 7ba4a3ade..36da591a1 100644 --- a/src/buildings/examples/outdoor-random-walk-example.cc +++ b/src/buildings/examples/outdoor-random-walk-example.cc @@ -44,7 +44,7 @@ PrintGnuplottableBuildingListToFile(std::string filename) return; } uint32_t index = 0; - for (BuildingList::Iterator it = BuildingList::Begin(); it != BuildingList::End(); ++it) + for (auto it = BuildingList::Begin(); it != BuildingList::End(); ++it) { ++index; Box box = (*it)->GetBoundaries(); diff --git a/src/buildings/helper/building-allocator.h b/src/buildings/helper/building-allocator.h index e81df23a0..33957708e 100644 --- a/src/buildings/helper/building-allocator.h +++ b/src/buildings/helper/building-allocator.h @@ -22,7 +22,8 @@ #ifndef BUILDING_ALLOCATOR_H #define BUILDING_ALLOCATOR_H -#include "ns3/building-container.h" +#include "building-container.h" + #include "ns3/object-factory.h" #include "ns3/object.h" #include "ns3/position-allocator.h" diff --git a/src/buildings/helper/building-container.cc b/src/buildings/helper/building-container.cc index fafba52a3..55816a4c9 100644 --- a/src/buildings/helper/building-container.cc +++ b/src/buildings/helper/building-container.cc @@ -77,7 +77,7 @@ BuildingContainer::Create(uint32_t n) void BuildingContainer::Add(BuildingContainer other) { - for (Iterator i = other.Begin(); i != other.End(); i++) + for (auto i = other.Begin(); i != other.End(); i++) { m_buildings.push_back(*i); } @@ -100,7 +100,7 @@ BuildingContainer BuildingContainer::GetGlobal() { BuildingContainer c; - for (BuildingList::Iterator i = BuildingList::Begin(); i != BuildingList::End(); ++i) + for (auto i = BuildingList::Begin(); i != BuildingList::End(); ++i) { c.Add(*i); } diff --git a/src/buildings/helper/building-position-allocator.cc b/src/buildings/helper/building-position-allocator.cc index 1a6bfbd21..31fb58250 100644 --- a/src/buildings/helper/building-position-allocator.cc +++ b/src/buildings/helper/building-position-allocator.cc @@ -19,11 +19,12 @@ */ #include "building-position-allocator.h" +#include "buildings-helper.h" + #include "ns3/boolean.h" #include "ns3/box.h" #include "ns3/building-list.h" #include "ns3/building.h" -#include "ns3/buildings-helper.h" #include "ns3/double.h" #include "ns3/enum.h" #include "ns3/log.h" @@ -81,8 +82,7 @@ RandomBuildingPositionAllocator::GetNext() const { if (m_buildingListWithoutReplacement.empty()) { - for (BuildingList::Iterator bit = BuildingList::Begin(); bit != BuildingList::End(); - ++bit) + for (auto bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) { m_buildingListWithoutReplacement.push_back(*bit); } @@ -188,7 +188,7 @@ OutdoorPositionAllocator::GetNext() const NS_LOG_INFO("Position " << position); bool inside = false; - for (BuildingList::Iterator bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) + for (auto bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) { if ((*bit)->IsInside(position)) { @@ -254,7 +254,7 @@ RandomRoomPositionAllocator::GetNext() const if (m_roomListWithoutReplacement.empty()) { - for (BuildingList::Iterator bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) + for (auto bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) { NS_LOG_LOGIC("building " << (*bit)->GetId()); for (uint32_t rx = 1; rx <= (*bit)->GetNRoomsX(); ++rx) @@ -326,7 +326,7 @@ SameRoomPositionAllocator::SameRoomPositionAllocator(NodeContainer c) m_rand = CreateObject(); m_nodeIt = m_nodes.Begin(); // this is needed to make sure the building models associated with c have been initialized - for (NodeContainer::Iterator it = m_nodes.Begin(); it != m_nodes.End(); ++it) + for (auto it = m_nodes.Begin(); it != m_nodes.End(); ++it) { Ptr mm = (*it)->GetObject(); NS_ASSERT_MSG(mm, "no mobility model aggregated to this node"); diff --git a/src/buildings/helper/buildings-helper.cc b/src/buildings/helper/buildings-helper.cc index 8d0f614bf..1f15a778e 100644 --- a/src/buildings/helper/buildings-helper.cc +++ b/src/buildings/helper/buildings-helper.cc @@ -35,7 +35,7 @@ NS_LOG_COMPONENT_DEFINE("BuildingsHelper"); void BuildingsHelper::Install(NodeContainer c) { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Install(*i); } diff --git a/src/buildings/model/building-list.cc b/src/buildings/model/building-list.cc index 9bf0c3826..e6c634255 100644 --- a/src/buildings/model/building-list.cc +++ b/src/buildings/model/building-list.cc @@ -158,7 +158,7 @@ void BuildingListPriv::DoDispose() { NS_LOG_FUNCTION_NOARGS(); - for (std::vector>::iterator i = m_buildings.begin(); i != m_buildings.end(); i++) + for (auto i = m_buildings.begin(); i != m_buildings.end(); i++) { Ptr building = *i; building->Dispose(); diff --git a/src/buildings/model/buildings-channel-condition-model.cc b/src/buildings/model/buildings-channel-condition-model.cc index 8b1dfbcb1..74c2ca0b3 100644 --- a/src/buildings/model/buildings-channel-condition-model.cc +++ b/src/buildings/model/buildings-channel-condition-model.cc @@ -18,11 +18,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "ns3/buildings-channel-condition-model.h" +#include "buildings-channel-condition-model.h" + +#include "building-list.h" +#include "mobility-building-info.h" -#include "ns3/building-list.h" #include "ns3/log.h" -#include "ns3/mobility-building-info.h" #include "ns3/mobility-model.h" namespace ns3 @@ -170,7 +171,7 @@ bool BuildingsChannelConditionModel::IsLineOfSightBlocked(const ns3::Vector& l1, const ns3::Vector& l2) const { - for (BuildingList::Iterator bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) + for (auto bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) { if ((*bit)->IsIntersect(l1, l2)) { diff --git a/src/buildings/model/buildings-propagation-loss-model.cc b/src/buildings/model/buildings-propagation-loss-model.cc index 34544ee05..9c8878a7c 100644 --- a/src/buildings/model/buildings-propagation-loss-model.cc +++ b/src/buildings/model/buildings-propagation-loss-model.cc @@ -21,13 +21,14 @@ #include "buildings-propagation-loss-model.h" +#include "mobility-building-info.h" + #include "ns3/double.h" #include "ns3/enum.h" #include "ns3/log.h" #include "ns3/mobility-model.h" #include "ns3/pointer.h" #include "ns3/propagation-loss-model.h" -#include #include @@ -159,11 +160,10 @@ BuildingsPropagationLossModel::GetShadowing(Ptr a, Ptr b1 = b->GetObject(); NS_ASSERT_MSG(a1 && b1, "BuildingsPropagationLossModel only works with MobilityBuildingInfo"); - std::map, std::map, ShadowingLoss>>::iterator ait = - m_shadowingLossMap.find(a); + auto ait = m_shadowingLossMap.find(a); if (ait != m_shadowingLossMap.end()) { - std::map, ShadowingLoss>::iterator bit = ait->second.find(b); + auto bit = ait->second.find(b); if (bit != ait->second.end()) { return (bit->second.GetLoss()); diff --git a/src/buildings/model/buildings-propagation-loss-model.h b/src/buildings/model/buildings-propagation-loss-model.h index fe6e7a85c..6ba3d9a74 100644 --- a/src/buildings/model/buildings-propagation-loss-model.h +++ b/src/buildings/model/buildings-propagation-loss-model.h @@ -22,11 +22,12 @@ #ifndef BUILDINGS_PROPAGATION_LOSS_MODEL_H_ #define BUILDINGS_PROPAGATION_LOSS_MODEL_H_ +#include "building.h" +#include "mobility-building-info.h" + #include "ns3/nstime.h" #include "ns3/propagation-loss-model.h" #include "ns3/random-variable-stream.h" -#include -#include namespace ns3 { diff --git a/src/buildings/model/hybrid-buildings-propagation-loss-model.cc b/src/buildings/model/hybrid-buildings-propagation-loss-model.cc index 9b07995fa..9919d3933 100644 --- a/src/buildings/model/hybrid-buildings-propagation-loss-model.cc +++ b/src/buildings/model/hybrid-buildings-propagation-loss-model.cc @@ -21,9 +21,11 @@ #include "hybrid-buildings-propagation-loss-model.h" +#include "itu-r-1238-propagation-loss-model.h" +#include "mobility-building-info.h" + #include "ns3/double.h" #include "ns3/enum.h" -#include "ns3/itu-r-1238-propagation-loss-model.h" #include "ns3/itu-r-1411-los-propagation-loss-model.h" #include "ns3/itu-r-1411-nlos-over-rooftop-propagation-loss-model.h" #include "ns3/kun-2600-mhz-propagation-loss-model.h" @@ -31,7 +33,6 @@ #include "ns3/mobility-model.h" #include "ns3/okumura-hata-propagation-loss-model.h" #include "ns3/pointer.h" -#include #include diff --git a/src/buildings/model/hybrid-buildings-propagation-loss-model.h b/src/buildings/model/hybrid-buildings-propagation-loss-model.h index 5a9c6ca41..edaf6e69a 100644 --- a/src/buildings/model/hybrid-buildings-propagation-loss-model.h +++ b/src/buildings/model/hybrid-buildings-propagation-loss-model.h @@ -22,7 +22,8 @@ #ifndef HYBRID_BUILDINGS_PROPAGATION_LOSS_MODEL_H_ #define HYBRID_BUILDINGS_PROPAGATION_LOSS_MODEL_H_ -#include +#include "buildings-propagation-loss-model.h" + #include namespace ns3 diff --git a/src/buildings/model/itu-r-1238-propagation-loss-model.cc b/src/buildings/model/itu-r-1238-propagation-loss-model.cc index 853cbf95d..0c4dc1c95 100644 --- a/src/buildings/model/itu-r-1238-propagation-loss-model.cc +++ b/src/buildings/model/itu-r-1238-propagation-loss-model.cc @@ -20,11 +20,12 @@ */ #include "itu-r-1238-propagation-loss-model.h" +#include "mobility-building-info.h" + #include "ns3/double.h" #include "ns3/enum.h" #include "ns3/log.h" #include "ns3/mobility-model.h" -#include #include diff --git a/src/buildings/model/mobility-building-info.cc b/src/buildings/model/mobility-building-info.cc index f7c58b359..c6b5f5c08 100644 --- a/src/buildings/model/mobility-building-info.cc +++ b/src/buildings/model/mobility-building-info.cc @@ -18,10 +18,12 @@ * */ +#include "mobility-building-info.h" + +#include "building-list.h" + #include -#include #include -#include #include #include #include @@ -166,7 +168,7 @@ MobilityBuildingInfo::MakeConsistent(Ptr mm) { bool found = false; Vector pos = mm->GetPosition(); - for (BuildingList::Iterator bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) + for (auto bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) { NS_LOG_LOGIC("checking building " << (*bit)->GetId() << " with boundaries " << (*bit)->GetBoundaries()); diff --git a/src/buildings/model/mobility-building-info.h b/src/buildings/model/mobility-building-info.h index ba71f33e9..ab9489b8b 100644 --- a/src/buildings/model/mobility-building-info.h +++ b/src/buildings/model/mobility-building-info.h @@ -20,8 +20,9 @@ #ifndef MOBILITY_BUILDING_INFO_H #define MOBILITY_BUILDING_INFO_H +#include "building.h" + #include -#include #include #include #include diff --git a/src/buildings/model/oh-buildings-propagation-loss-model.cc b/src/buildings/model/oh-buildings-propagation-loss-model.cc index 132831a6d..0ed56b0c3 100644 --- a/src/buildings/model/oh-buildings-propagation-loss-model.cc +++ b/src/buildings/model/oh-buildings-propagation-loss-model.cc @@ -20,6 +20,8 @@ #include "oh-buildings-propagation-loss-model.h" +#include "mobility-building-info.h" + #include "ns3/double.h" #include "ns3/enum.h" #include "ns3/log.h" @@ -27,7 +29,6 @@ #include "ns3/okumura-hata-propagation-loss-model.h" #include "ns3/pointer.h" #include "ns3/propagation-loss-model.h" -#include #include diff --git a/src/buildings/model/oh-buildings-propagation-loss-model.h b/src/buildings/model/oh-buildings-propagation-loss-model.h index 7e7aa10be..a7dd895bc 100644 --- a/src/buildings/model/oh-buildings-propagation-loss-model.h +++ b/src/buildings/model/oh-buildings-propagation-loss-model.h @@ -21,7 +21,7 @@ #ifndef OH_BUILDINGS_PROPAGATION_LOSS_MODEL_H_ #define OH_BUILDINGS_PROPAGATION_LOSS_MODEL_H_ -#include +#include "buildings-propagation-loss-model.h" namespace ns3 { diff --git a/src/buildings/model/random-walk-2d-outdoor-mobility-model.cc b/src/buildings/model/random-walk-2d-outdoor-mobility-model.cc index 6f6fda524..6a2420653 100644 --- a/src/buildings/model/random-walk-2d-outdoor-mobility-model.cc +++ b/src/buildings/model/random-walk-2d-outdoor-mobility-model.cc @@ -20,8 +20,9 @@ */ #include "random-walk-2d-outdoor-mobility-model.h" -#include "ns3/building-list.h" -#include "ns3/building.h" +#include "building-list.h" +#include "building.h" + #include "ns3/double.h" #include "ns3/enum.h" #include "ns3/log.h" @@ -31,6 +32,7 @@ #include "ns3/uinteger.h" #include +#include namespace ns3 { @@ -132,6 +134,11 @@ RandomWalk2dOutdoorMobilityModel::DoInitializePrivate() void RandomWalk2dOutdoorMobilityModel::DoWalk(Time delayLeft) { + if (delayLeft.IsNegative()) + { + NS_LOG_INFO(this << " Ran out of time"); + return; + } NS_LOG_FUNCTION(this << delayLeft.GetSeconds()); Vector position = m_helper.GetCurrentPosition(); @@ -160,7 +167,18 @@ RandomWalk2dOutdoorMobilityModel::DoWalk(Time delayLeft) NS_LOG_LOGIC("NextPosition would lead into a building"); nextPosition = CalculateIntersectionFromOutside(position, nextPosition, building->GetBoundaries()); - Time delay = Seconds((nextPosition.x - position.x) / speed.x); + + double delaySecondsX = std::numeric_limits::max(); + double delaySecondsY = std::numeric_limits::max(); + if (speed.x != 0) + { + delaySecondsX = std::abs((nextPosition.x - position.x) / speed.x); + } + if (speed.y != 0) + { + delaySecondsY = std::abs((nextPosition.y - position.y) / speed.y); + } + Time delay = Seconds(std::min(delaySecondsX, delaySecondsY)); m_event = Simulator::Schedule(delay, &RandomWalk2dOutdoorMobilityModel::AvoidBuilding, this, @@ -179,7 +197,24 @@ RandomWalk2dOutdoorMobilityModel::DoWalk(Time delayLeft) if (outdoor) { - Time delay = Seconds((nextPosition.x - position.x) / speed.x); + double delaySeconds = std::numeric_limits::max(); + if (speed.x != 0) + { + delaySeconds = + std::min(delaySeconds, std::abs((nextPosition.x - position.x) / speed.x)); + } + else if (speed.y != 0) + { + delaySeconds = + std::min(delaySeconds, std::abs((nextPosition.y - position.y) / speed.y)); + } + else + { + NS_ABORT_MSG("RandomWalk2dOutdoorMobilityModel::DoWalk: unable to calculate the " + "rebound time " + "(the node is stationary)."); + } + Time delay = Seconds(delaySeconds); m_event = Simulator::Schedule(delay, &RandomWalk2dOutdoorMobilityModel::Rebound, this, @@ -190,7 +225,28 @@ RandomWalk2dOutdoorMobilityModel::DoWalk(Time delayLeft) NS_LOG_LOGIC("NextPosition would lead into a building"); nextPosition = CalculateIntersectionFromOutside(position, nextPosition, building->GetBoundaries()); - Time delay = Seconds((nextPosition.x - position.x) / speed.x); + + double delaySecondsX = std::numeric_limits::max(); + double delaySecondsY = std::numeric_limits::max(); + if (speed.x != 0) + { + delaySecondsX = + std::min(delaySecondsX, std::abs((nextPosition.x - position.x) / speed.x)); + } + if (speed.y != 0) + { + delaySecondsY = + std::min(delaySecondsY, std::abs((nextPosition.y - position.y) / speed.y)); + } + if (delaySecondsX == std::numeric_limits::max() && + delaySecondsY == std::numeric_limits::max()) + { + NS_ABORT_MSG("RandomWalk2dOutdoorMobilityModel::DoWalk: unable to calculate the " + "rebound time " + "(the node is stationary)."); + } + + Time delay = Seconds(std::min(delaySecondsX, delaySecondsY)); m_event = Simulator::Schedule(delay, &RandomWalk2dOutdoorMobilityModel::AvoidBuilding, this, @@ -215,7 +271,7 @@ RandomWalk2dOutdoorMobilityModel::IsLineClearOfBuildings(Vector currentPosition, double minIntersectionDistance = std::numeric_limits::max(); Ptr minIntersectionDistanceBuilding; - for (BuildingList::Iterator bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) + for (auto bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) { // check if this building intersects the line between the current and next positions // this checks also if the next position is inside the building @@ -250,44 +306,72 @@ RandomWalk2dOutdoorMobilityModel::CalculateIntersectionFromOutside(const Vector& // get the closest side Rectangle rect = Rectangle(boundaries.xMin, boundaries.xMax, boundaries.yMin, boundaries.yMax); - NS_LOG_INFO("rect " << rect); - Rectangle::Side closestSide = rect.GetClosestSide(current); + NS_LOG_DEBUG("rect " << rect); + Rectangle::Side closestSide = rect.GetClosestSideOrCorner(current); double xIntersect = 0; double yIntersect = 0; switch (closestSide) { - case Rectangle::RIGHT: - NS_LOG_INFO("The closest side is RIGHT"); - NS_ABORT_MSG_IF(next.x - current.x == 0, "x position not updated"); + case Rectangle::RIGHTSIDE: + NS_LOG_DEBUG("The closest side is RIGHT"); xIntersect = boundaries.xMax + m_epsilon; + NS_ABORT_MSG_IF(next.x - current.x == 0, "x position not updated"); yIntersect = (next.y - current.y) / (next.x - current.x) * (xIntersect - current.x) + current.y; break; - case Rectangle::LEFT: - NS_LOG_INFO("The closest side is LEFT"); + case Rectangle::LEFTSIDE: + NS_LOG_DEBUG("The closest side is LEFT"); xIntersect = boundaries.xMin - m_epsilon; NS_ABORT_MSG_IF(next.x - current.x == 0, "x position not updated"); yIntersect = (next.y - current.y) / (next.x - current.x) * (xIntersect - current.x) + current.y; break; - case Rectangle::TOP: - NS_LOG_INFO("The closest side is TOP"); + case Rectangle::TOPSIDE: + NS_LOG_DEBUG("The closest side is TOP"); yIntersect = boundaries.yMax + m_epsilon; NS_ABORT_MSG_IF(next.y - current.y == 0, "y position not updated"); xIntersect = (next.x - current.x) / (next.y - current.y) * (yIntersect - current.y) + current.x; break; - case Rectangle::BOTTOM: - NS_LOG_INFO("The closest side is BOTTOM"); + case Rectangle::BOTTOMSIDE: + NS_LOG_DEBUG("The closest side is BOTTOM"); yIntersect = boundaries.yMin - m_epsilon; NS_ABORT_MSG_IF(next.y - current.y == 0, "y position not updated"); xIntersect = (next.x - current.x) / (next.y - current.y) * (yIntersect - current.y) + current.x; break; + case Rectangle::TOPRIGHTCORNER: + NS_LOG_DEBUG("The closest side is TOPRIGHT"); + xIntersect = boundaries.xMax + m_epsilon; + NS_ABORT_MSG_IF(next.x - current.x == 0, "x position not updated"); + yIntersect = boundaries.yMax + m_epsilon; + NS_ABORT_MSG_IF(next.y - current.y == 0, "y position not updated"); + break; + case Rectangle::TOPLEFTCORNER: + NS_LOG_DEBUG("The closest side is TOPLEFT"); + xIntersect = boundaries.xMin - m_epsilon; + NS_ABORT_MSG_IF(next.x - current.x == 0, "x position not updated"); + yIntersect = boundaries.yMax + m_epsilon; + NS_ABORT_MSG_IF(next.y - current.y == 0, "y position not updated"); + break; + case Rectangle::BOTTOMRIGHTCORNER: + NS_LOG_DEBUG("The closest side is BOTTOMRIGHT"); + xIntersect = boundaries.xMax + m_epsilon; + NS_ABORT_MSG_IF(next.x - current.x == 0, "x position not updated"); + yIntersect = boundaries.yMin - m_epsilon; + NS_ABORT_MSG_IF(next.y - current.y == 0, "y position not updated"); + break; + case Rectangle::BOTTOMLEFTCORNER: + NS_LOG_DEBUG("The closest side is BOTTOMLEFT"); + xIntersect = boundaries.xMin - m_epsilon; + NS_ABORT_MSG_IF(next.x - current.x == 0, "x position not updated"); + yIntersect = boundaries.yMin - m_epsilon; + NS_ABORT_MSG_IF(next.y - current.y == 0, "y position not updated"); + break; } - NS_LOG_INFO("xIntersect " << xIntersect << " yIntersect " << yIntersect); + NS_LOG_DEBUG("xIntersect " << xIntersect << " yIntersect " << yIntersect); return Vector(xIntersect, yIntersect, 0); } @@ -298,20 +382,27 @@ RandomWalk2dOutdoorMobilityModel::Rebound(Time delayLeft) m_helper.UpdateWithBounds(m_bounds); Vector position = m_helper.GetCurrentPosition(); Vector speed = m_helper.GetVelocity(); - switch (m_bounds.GetClosestSide(position)) + switch (m_bounds.GetClosestSideOrCorner(position)) { - case Rectangle::RIGHT: - NS_LOG_INFO("The closest side is RIGHT"); - case Rectangle::LEFT: - NS_LOG_INFO("The closest side is LEFT"); + case Rectangle::RIGHTSIDE: + case Rectangle::LEFTSIDE: + NS_LOG_DEBUG("The closest side is RIGHT or LEFT"); speed.x = -speed.x; break; - case Rectangle::TOP: - NS_LOG_INFO("The closest side is TOP"); - case Rectangle::BOTTOM: - NS_LOG_INFO("The closest side is BOTTOM"); + case Rectangle::TOPSIDE: + case Rectangle::BOTTOMSIDE: + NS_LOG_DEBUG("The closest side is TOP or BOTTOM"); speed.y = -speed.y; break; + case Rectangle::TOPRIGHTCORNER: + case Rectangle::BOTTOMRIGHTCORNER: + case Rectangle::TOPLEFTCORNER: + case Rectangle::BOTTOMLEFTCORNER: + NS_LOG_DEBUG("The closest side is a corner"); + auto temp = speed.x; + speed.x = -speed.y; + speed.y = -temp; + break; } m_helper.SetVelocity(speed); m_helper.Unpause(); diff --git a/src/buildings/model/random-walk-2d-outdoor-mobility-model.h b/src/buildings/model/random-walk-2d-outdoor-mobility-model.h index c5b29f17e..1da68f8e6 100644 --- a/src/buildings/model/random-walk-2d-outdoor-mobility-model.h +++ b/src/buildings/model/random-walk-2d-outdoor-mobility-model.h @@ -22,7 +22,8 @@ #ifndef RANDOM_WALK_2D_OUTDOOR_MOBILITY_MODEL_H #define RANDOM_WALK_2D_OUTDOOR_MOBILITY_MODEL_H -#include "ns3/building.h" +#include "building.h" + #include "ns3/constant-velocity-helper.h" #include "ns3/event-id.h" #include "ns3/mobility-model.h" diff --git a/src/buildings/model/three-gpp-v2v-channel-condition-model.cc b/src/buildings/model/three-gpp-v2v-channel-condition-model.cc index 21e02bed2..94256e60a 100644 --- a/src/buildings/model/three-gpp-v2v-channel-condition-model.cc +++ b/src/buildings/model/three-gpp-v2v-channel-condition-model.cc @@ -19,9 +19,10 @@ #include "three-gpp-v2v-channel-condition-model.h" +#include "building-list.h" + #include "ns3/log.h" #include "ns3/mobility-model.h" -#include namespace ns3 { diff --git a/src/buildings/test/building-position-allocator-test.cc b/src/buildings/test/building-position-allocator-test.cc index 94879a592..980a921a7 100644 --- a/src/buildings/test/building-position-allocator-test.cc +++ b/src/buildings/test/building-position-allocator-test.cc @@ -117,7 +117,7 @@ RandomRoomPositionAllocatorTestCase::DoRun() std::map roomCounter; - for (NodeContainer::Iterator it = nodes.Begin(); it != nodes.End(); ++it) + for (auto it = nodes.Begin(); it != nodes.End(); ++it) { Ptr mm = (*it)->GetObject(); NS_ASSERT_MSG(mm, "no mobility model aggregated to this node"); @@ -138,7 +138,7 @@ RandomRoomPositionAllocatorTestCase::DoRun() NS_TEST_ASSERT_MSG_LT(p.z, bmm->GetFloorNumber() + 1, "wrong z value"); } - for (std::map::iterator it = roomCounter.begin(); it != roomCounter.end(); ++it) + for (auto it = roomCounter.begin(); it != roomCounter.end(); ++it) { // random selection is done without replacement until the set of // eligible room is empty, at which point the set is filled @@ -202,7 +202,7 @@ SameRoomPositionAllocatorTestCase::DoRun() std::map roomCounter; - for (NodeContainer::Iterator it = copyNodes.Begin(); it != copyNodes.End(); ++it) + for (auto it = copyNodes.Begin(); it != copyNodes.End(); ++it) { Ptr mm = (*it)->GetObject(); NS_ASSERT_MSG(mm, "no mobility model aggregated to this node"); @@ -215,7 +215,7 @@ SameRoomPositionAllocatorTestCase::DoRun() ++(roomCounter[r]); } - for (std::map::iterator it = roomCounter.begin(); it != roomCounter.end(); ++it) + for (auto it = roomCounter.begin(); it != roomCounter.end(); ++it) { NS_TEST_ASSERT_MSG_EQ(it->second, 4, "expected 4 nodes per room"); } diff --git a/src/buildings/test/outdoor-random-walk-test.cc b/src/buildings/test/outdoor-random-walk-test.cc index f6db0a306..ebb3f3240 100644 --- a/src/buildings/test/outdoor-random-walk-test.cc +++ b/src/buildings/test/outdoor-random-walk-test.cc @@ -21,6 +21,7 @@ #include "ns3/building.h" #include "ns3/config.h" #include "ns3/double.h" +#include "ns3/enum.h" #include "ns3/log.h" #include "ns3/mobility-helper.h" #include "ns3/pointer.h" @@ -82,6 +83,10 @@ OutdoorRandomWalkTestCase::CheckPositionOutdoor(Ptr position = CreateObject(); @@ -139,18 +148,16 @@ OutdoorRandomWalkTestCase::DoRun() auto mobilityModel = nodes.Get(0)->GetObject(); - // get maxChecks positions, check if they are outdoors - double testStep = 10; // s - int maxChecks = 1000; - for (int i = 0; i < maxChecks; ++i) + // get MAX_CHECKS positions, check if they are outdoors + for (int i = 0; i < MAX_CHECKS; i++) { - Simulator::Schedule(Seconds(i * testStep), + Simulator::Schedule(Seconds(i * TEST_STEP_S), &OutdoorRandomWalkTestCase::CheckPositionOutdoor, this, mobilityModel); } - Simulator::Stop(Seconds(maxChecks * testStep + 1)); + Simulator::Stop(Seconds(MAX_CHECKS * TEST_STEP_S + 1)); Simulator::Run(); Simulator::Destroy(); } diff --git a/src/click/examples/nsclick-defines.cc b/src/click/examples/nsclick-defines.cc index dd1a0e619..db3d11976 100644 --- a/src/click/examples/nsclick-defines.cc +++ b/src/click/examples/nsclick-defines.cc @@ -28,7 +28,6 @@ NS_LOG_COMPONENT_DEFINE("NsclickRouting"); int main(int argc, char* argv[]) { -#ifdef NS3_CLICK std::string clickConfigFolder = "src/click/examples"; CommandLine cmd(__FILE__); @@ -66,9 +65,6 @@ main(int argc, char* argv[]) Simulator::Run(); Simulator::Destroy(); NS_LOG_INFO("Done."); -#else - NS_FATAL_ERROR("Can't use ns-3-click without NSCLICK compiled in"); -#endif return 0; } diff --git a/src/click/examples/nsclick-raw-wlan.cc b/src/click/examples/nsclick-raw-wlan.cc index 47c669fcb..ab3a3b628 100644 --- a/src/click/examples/nsclick-raw-wlan.cc +++ b/src/click/examples/nsclick-raw-wlan.cc @@ -44,7 +44,6 @@ ReceivePacket(Ptr socket) int main(int argc, char* argv[]) { -#ifdef NS3_CLICK double rss = -80; std::string clickConfigFolder = "src/click/examples"; @@ -150,9 +149,6 @@ main(int argc, char* argv[]) Simulator::Run(); Simulator::Destroy(); -#else - NS_FATAL_ERROR("Can't use ns-3-click without NSCLICK compiled in"); -#endif return 0; } diff --git a/src/click/examples/nsclick-routing.cc b/src/click/examples/nsclick-routing.cc index 82fd143db..5acdd50c5 100644 --- a/src/click/examples/nsclick-routing.cc +++ b/src/click/examples/nsclick-routing.cc @@ -45,7 +45,6 @@ NS_LOG_COMPONENT_DEFINE("NsclickRouting"); int main(int argc, char* argv[]) { -#ifdef NS3_CLICK std::string clickConfigFolder = "src/click/examples"; CommandLine cmd(__FILE__); @@ -131,9 +130,6 @@ main(int argc, char* argv[]) Simulator::Run(); Simulator::Destroy(); NS_LOG_INFO("Done."); -#else - NS_FATAL_ERROR("Can't use ns-3-click without NSCLICK compiled in"); -#endif return 0; } diff --git a/src/click/examples/nsclick-simple-lan.cc b/src/click/examples/nsclick-simple-lan.cc index fc6f38e42..ed3ee4579 100644 --- a/src/click/examples/nsclick-simple-lan.cc +++ b/src/click/examples/nsclick-simple-lan.cc @@ -43,7 +43,6 @@ ReceivePacket(Ptr socket) int main(int argc, char* argv[]) { -#ifdef NS3_CLICK std::string clickConfigFolder = "src/click/examples"; CommandLine cmd(__FILE__); @@ -104,9 +103,6 @@ main(int argc, char* argv[]) Simulator::Run(); Simulator::Destroy(); -#else - NS_FATAL_ERROR("Can't use ns-3-click without NSCLICK compiled in"); -#endif return 0; } diff --git a/src/click/examples/nsclick-udp-client-server-csma.cc b/src/click/examples/nsclick-udp-client-server-csma.cc index 6a2264234..796a2bf1e 100644 --- a/src/click/examples/nsclick-udp-client-server-csma.cc +++ b/src/click/examples/nsclick-udp-client-server-csma.cc @@ -48,7 +48,6 @@ NS_LOG_COMPONENT_DEFINE("NsclickUdpClientServerCsma"); int main(int argc, char* argv[]) { -#ifdef NS3_CLICK std::string clickConfigFolder = "src/click/examples"; CommandLine cmd(__FILE__); @@ -130,9 +129,6 @@ main(int argc, char* argv[]) Simulator::Run(); Simulator::Destroy(); NS_LOG_INFO("Done."); -#else - NS_FATAL_ERROR("Can't use ns-3-click without NSCLICK compiled in"); -#endif return 0; } diff --git a/src/click/examples/nsclick-udp-client-server-wifi.cc b/src/click/examples/nsclick-udp-client-server-wifi.cc index c601ac2ef..ec3580370 100644 --- a/src/click/examples/nsclick-udp-client-server-wifi.cc +++ b/src/click/examples/nsclick-udp-client-server-wifi.cc @@ -50,7 +50,6 @@ using namespace ns3; NS_LOG_COMPONENT_DEFINE("NsclickUdpClientServerWifi"); -#ifdef NS3_CLICK void ReadArp(Ptr clickRouter) { @@ -66,12 +65,10 @@ WriteArp(Ptr clickRouter) NS_LOG_INFO( clickRouter->WriteHandler("wifi/arpquerier", "insert", "172.16.1.2 00:00:00:00:00:02")); } -#endif int main(int argc, char* argv[]) { -#ifdef NS3_CLICK std::string clickConfigFolder = "src/click/examples"; CommandLine cmd(__FILE__); @@ -216,9 +213,6 @@ main(int argc, char* argv[]) Simulator::Run(); Simulator::Destroy(); NS_LOG_INFO("Done."); -#else - NS_FATAL_ERROR("Can't use ns-3-click without NSCLICK compiled in"); -#endif return 0; } diff --git a/src/click/helper/click-internet-stack-helper.cc b/src/click/helper/click-internet-stack-helper.cc index 1f6f225b8..e9b12e260 100644 --- a/src/click/helper/click-internet-stack-helper.cc +++ b/src/click/helper/click-internet-stack-helper.cc @@ -19,8 +19,6 @@ * Author: Lalith Suresh */ -#ifdef NS3_CLICK - #include "click-internet-stack-helper.h" #include "ns3/arp-l3-protocol.h" @@ -60,13 +58,121 @@ static InterfaceFileMapIpv4 static InterfaceStreamMapIpv4 g_interfaceStreamMapIpv4; /**< A mapping of Ipv4/interface pairs to ascii streams */ +/** + * IPv4 Rx / Tx packet callback. + * + * \param p Packet. + * \param ipv4 IPv4 stack. + * \param interface Interface number. + */ +static void +Ipv4L3ProtocolRxTxSink(Ptr p, Ptr ipv4, uint32_t interface) +{ + NS_LOG_FUNCTION(p << ipv4 << interface); + + // + // Since trace sources are independent of interface, if we hook a source + // on a particular protocol we will get traces for all of its interfaces. + // We need to filter this to only report interfaces for which the user + // has expressed interest. + // + InterfacePairIpv4 pair = std::make_pair(ipv4, interface); + if (g_interfaceFileMapIpv4.find(pair) == g_interfaceFileMapIpv4.end()) + { + NS_LOG_INFO("Ignoring packet to/from interface " << interface); + return; + } + + Ptr file = g_interfaceFileMapIpv4[pair]; + file->Write(Simulator::Now(), p); +} + +/** + * Packet dropped callback without context. + * + * \param stream Output stream. + * \param header IPv4 header. + * \param packet Packet. + * \param reason Packet drop reason. + * \param ipv4 IPv4 stack. + * \param interface Interface number. + */ +static void +Ipv4L3ProtocolDropSinkWithoutContext(Ptr stream, + const Ipv4Header& header, + Ptr packet, + Ipv4L3Protocol::DropReason reason, + Ptr ipv4, + uint32_t interface) +{ + // + // Since trace sources are independent of interface, if we hook a source + // on a particular protocol we will get traces for all of its interfaces. + // We need to filter this to only report interfaces for which the user + // has expressed interest. + // + InterfacePairIpv4 pair = std::make_pair(ipv4, interface); + if (g_interfaceStreamMapIpv4.find(pair) == g_interfaceStreamMapIpv4.end()) + { + NS_LOG_INFO("Ignoring packet to/from interface " << interface); + return; + } + + Ptr p = packet->Copy(); + p->AddHeader(header); + *stream->GetStream() << "d " << Simulator::Now().GetSeconds() << " " << *p << std::endl; +} + +/** + * Packet dropped callback with context. + * + * \param stream Output stream. + * \param context Context. + * \param header IPv4 header. + * \param packet Packet. + * \param reason Packet drop reason. + * \param ipv4 IPv4 stack. + * \param interface Interface number. + */ +static void +Ipv4L3ProtocolDropSinkWithContext(Ptr stream, + std::string context, + const Ipv4Header& header, + Ptr packet, + Ipv4L3Protocol::DropReason reason, + Ptr ipv4, + uint32_t interface) +{ + // + // Since trace sources are independent of interface, if we hook a source + // on a particular protocol we will get traces for all of its interfaces. + // We need to filter this to only report interfaces for which the user + // has expressed interest. + // + InterfacePairIpv4 pair = std::make_pair(ipv4, interface); + if (g_interfaceStreamMapIpv4.find(pair) == g_interfaceStreamMapIpv4.end()) + { + NS_LOG_INFO("Ignoring packet to/from interface " << interface); + return; + } + + Ptr p = packet->Copy(); + p->AddHeader(header); +#ifdef INTERFACE_CONTEXT + *stream->GetStream() << "d " << Simulator::Now().GetSeconds() << " " << context << "(" + << interface << ") " << *p << std::endl; +#else + *stream->GetStream() << "d " << Simulator::Now().GetSeconds() << " " << context << " " << *p + << std::endl; +#endif +} + ClickInternetStackHelper::ClickInternetStackHelper() : m_ipv4Enabled(true) { Initialize(); } -// private method called by both constructor and Reset () void ClickInternetStackHelper::Initialize() { @@ -84,9 +190,9 @@ ClickInternetStackHelper::ClickInternetStackHelper(const ClickInternetStackHelpe ClickInternetStackHelper& ClickInternetStackHelper::operator=(const ClickInternetStackHelper& o) { - if (this == &o) + if (this != &o) { - return *this; + m_ipv4Enabled = o.m_ipv4Enabled; } return *this; } @@ -101,7 +207,7 @@ ClickInternetStackHelper::Reset() void ClickInternetStackHelper::SetClickFile(NodeContainer c, std::string clickfile) { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { SetClickFile(*i, clickfile); } @@ -116,7 +222,7 @@ ClickInternetStackHelper::SetClickFile(Ptr node, std::string clickfile) void ClickInternetStackHelper::SetDefines(NodeContainer c, std::map defines) { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { SetDefines(*i, defines); } @@ -131,7 +237,7 @@ ClickInternetStackHelper::SetDefines(Ptr node, std::map node, std::string rt) void ClickInternetStackHelper::Install(NodeContainer c) const { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Install(*i); } @@ -190,16 +296,14 @@ ClickInternetStackHelper::Install(Ptr node) const // Set routing Ptr ipv4 = node->GetObject(); Ptr ipv4Routing = CreateObject(); - std::map, std::string>::const_iterator it; - it = m_nodeToClickFileMap.find(node); + auto it = m_nodeToClickFileMap.find(node); if (it != m_nodeToClickFileMap.end()) { ipv4Routing->SetClickFile(it->second); } - std::map, std::map>::const_iterator definesIt; - definesIt = m_nodeToDefinesMap.find(node); + auto definesIt = m_nodeToDefinesMap.find(node); if (definesIt != m_nodeToDefinesMap.end()) { ipv4Routing->SetDefines(definesIt->second); @@ -222,34 +326,10 @@ ClickInternetStackHelper::Install(std::string nodeName) const Install(node); } -static void -Ipv4L3ProtocolRxTxSink(Ptr p, Ptr ipv4, uint32_t interface) -{ - NS_LOG_FUNCTION(p << ipv4 << interface); - - // - // Since trace sources are independent of interface, if we hook a source - // on a particular protocol we will get traces for all of its interfaces. - // We need to filter this to only report interfaces for which the user - // has expressed interest. - // - InterfacePairIpv4 pair = std::make_pair(ipv4, interface); - if (g_interfaceFileMapIpv4.find(pair) == g_interfaceFileMapIpv4.end()) - { - NS_LOG_INFO("Ignoring packet to/from interface " << interface); - return; - } - - Ptr file = g_interfaceFileMapIpv4[pair]; - file->Write(Simulator::Now(), p); -} - bool ClickInternetStackHelper::PcapHooked(Ptr ipv4) { - for (InterfaceFileMapIpv4::const_iterator i = g_interfaceFileMapIpv4.begin(); - i != g_interfaceFileMapIpv4.end(); - ++i) + for (auto i = g_interfaceFileMapIpv4.begin(); i != g_interfaceFileMapIpv4.end(); ++i) { if ((*i).first.first == ipv4) { @@ -322,71 +402,10 @@ ClickInternetStackHelper::EnablePcapIpv4Internal(std::string prefix, g_interfaceFileMapIpv4[std::make_pair(ipv4, interface)] = file; } -static void -Ipv4L3ProtocolDropSinkWithoutContext(Ptr stream, - const Ipv4Header& header, - Ptr packet, - Ipv4L3Protocol::DropReason reason, - Ptr ipv4, - uint32_t interface) -{ - // - // Since trace sources are independent of interface, if we hook a source - // on a particular protocol we will get traces for all of its interfaces. - // We need to filter this to only report interfaces for which the user - // has expressed interest. - // - InterfacePairIpv4 pair = std::make_pair(ipv4, interface); - if (g_interfaceStreamMapIpv4.find(pair) == g_interfaceStreamMapIpv4.end()) - { - NS_LOG_INFO("Ignoring packet to/from interface " << interface); - return; - } - - Ptr p = packet->Copy(); - p->AddHeader(header); - *stream->GetStream() << "d " << Simulator::Now().GetSeconds() << " " << *p << std::endl; -} - -static void -Ipv4L3ProtocolDropSinkWithContext(Ptr stream, - std::string context, - const Ipv4Header& header, - Ptr packet, - Ipv4L3Protocol::DropReason reason, - Ptr ipv4, - uint32_t interface) -{ - // - // Since trace sources are independent of interface, if we hook a source - // on a particular protocol we will get traces for all of its interfaces. - // We need to filter this to only report interfaces for which the user - // has expressed interest. - // - InterfacePairIpv4 pair = std::make_pair(ipv4, interface); - if (g_interfaceStreamMapIpv4.find(pair) == g_interfaceStreamMapIpv4.end()) - { - NS_LOG_INFO("Ignoring packet to/from interface " << interface); - return; - } - - Ptr p = packet->Copy(); - p->AddHeader(header); -#ifdef INTERFACE_CONTEXT - *stream->GetStream() << "d " << Simulator::Now().GetSeconds() << " " << context << "(" - << interface << ") " << *p << std::endl; -#else - *stream->GetStream() << "d " << Simulator::Now().GetSeconds() << " " << context << " " << *p - << std::endl; -#endif -} - bool ClickInternetStackHelper::AsciiHooked(Ptr ipv4) { - for (InterfaceStreamMapIpv4::const_iterator i = g_interfaceStreamMapIpv4.begin(); - i != g_interfaceStreamMapIpv4.end(); - ++i) + for (auto i = g_interfaceStreamMapIpv4.begin(); i != g_interfaceStreamMapIpv4.end(); ++i) { if ((*i).first.first == ipv4) { @@ -521,5 +540,3 @@ ClickInternetStackHelper::EnableAsciiIpv4Internal(Ptr strea } } // namespace ns3 - -#endif // NS3_CLICK diff --git a/src/click/helper/click-internet-stack-helper.h b/src/click/helper/click-internet-stack-helper.h index fea68e954..a4f0e919e 100644 --- a/src/click/helper/click-internet-stack-helper.h +++ b/src/click/helper/click-internet-stack-helper.h @@ -18,8 +18,6 @@ * Author: Lalith Suresh */ -#ifdef NS3_CLICK - #ifndef CLICK_INTERNET_STACK_HELPER_H #define CLICK_INTERNET_STACK_HELPER_H @@ -59,7 +57,20 @@ class ClickInternetStackHelper : public PcapHelperForIpv4, public AsciiTraceHelp * Destroy the ClickInternetStackHelper */ ~ClickInternetStackHelper() override; - ClickInternetStackHelper(const ClickInternetStackHelper&); + + /** + * Copy constructor. + * + * \param o Object to copy from. + */ + ClickInternetStackHelper(const ClickInternetStackHelper& o); + + /** + * Assignment operator. + * + * \param o Object to copy from. + * \return Reference to updated object. + */ ClickInternetStackHelper& operator=(const ClickInternetStackHelper& o); /** @@ -145,11 +156,12 @@ class ClickInternetStackHelper : public PcapHelperForIpv4, public AsciiTraceHelp private: /** - * @brief Enable pcap output the indicated Ipv4 and interface pair. + * \brief Enable pcap output the indicated Ipv4 and interface pair. * - * @param prefix Filename prefix to use for pcap files. - * @param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing. - * @param interface Interface ID on the Ipv4 on which you want to enable tracing. + * \param prefix Filename prefix to use for pcap files. + * \param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing. + * \param interface Interface ID on the Ipv4 on which you want to enable tracing. + * \param explicitFilename Whether the filename is explicit or not. */ void EnablePcapIpv4Internal(std::string prefix, Ptr ipv4, @@ -157,13 +169,14 @@ class ClickInternetStackHelper : public PcapHelperForIpv4, public AsciiTraceHelp bool explicitFilename) override; /** - * @brief Enable ascii trace output on the indicated Ipv4 and interface pair. + * \brief Enable ascii trace output on the indicated Ipv4 and interface pair. * - * @param stream An OutputStreamWrapper representing an existing file to use + * \param stream An OutputStreamWrapper representing an existing file to use * when writing trace data. - * @param prefix Filename prefix to use for ascii trace files. - * @param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing. - * @param interface Interface ID on the Ipv4 on which you want to enable tracing. + * \param prefix Filename prefix to use for ascii trace files. + * \param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing. + * \param interface Interface ID on the Ipv4 on which you want to enable tracing. + * \param explicitFilename Whether the filename is explicit or not. */ void EnableAsciiIpv4Internal(Ptr stream, std::string prefix, @@ -171,14 +184,34 @@ class ClickInternetStackHelper : public PcapHelperForIpv4, public AsciiTraceHelp uint32_t interface, bool explicitFilename) override; + /** + * Initialize stack helper. + * Called by both constructor and Reset(). + */ void Initialize(); + /** + * Create and aggregate object from type ID. + * + * \param node Node. + * \param typeId Type ID. + */ static void CreateAndAggregateObjectFromTypeId(Ptr node, const std::string typeId); - static void Cleanup(); - + /** + * Check if PCAP is hooked. + * + * \param ipv4 IPv4 stack. + * \return True if PCAP is hooked. + */ bool PcapHooked(Ptr ipv4); + /** + * Check if ASCII is hooked. + * + * \param ipv4 IPv4 stack. + * \return True if ASCII is hooked. + */ bool AsciiHooked(Ptr ipv4); /** @@ -205,5 +238,3 @@ class ClickInternetStackHelper : public PcapHelperForIpv4, public AsciiTraceHelp } // namespace ns3 #endif /* CLICK_INTERNET_STACK_HELPER_H */ - -#endif /* NS3_CLICK */ diff --git a/src/click/model/ipv4-click-routing.cc b/src/click/model/ipv4-click-routing.cc index e23714e05..b38b89ea9 100644 --- a/src/click/model/ipv4-click-routing.cc +++ b/src/click/model/ipv4-click-routing.cc @@ -17,12 +17,11 @@ * Authors: Lalith Suresh */ -#ifdef NS3_CLICK - #include "ipv4-click-routing.h" +#include "ipv4-l3-click-protocol.h" + #include "ns3/ipv4-interface.h" -#include "ns3/ipv4-l3-click-protocol.h" #include "ns3/log.h" #include "ns3/mac48-address.h" #include "ns3/node.h" @@ -87,7 +86,7 @@ Ipv4ClickRouting::DoInitialize() m_nodeName = name.str(); } - NS_ASSERT(m_clickFile.length() > 0); + NS_ASSERT(!m_clickFile.empty()); // Even though simclick_click_create() will halt programme execution // if it is unable to initialise a Click router, we play safe @@ -397,7 +396,7 @@ Ipv4ClickRouting::Send(Ptr p, Ipv4Address src, Ipv4Address dst) } int len = p->GetSize(); - uint8_t* buf = new uint8_t[len]; + auto buf = new uint8_t[len]; p->CopyData(buf, len); // ... and send the packet on the corresponding Click interface. @@ -425,7 +424,7 @@ Ipv4ClickRouting::Receive(Ptr p, Mac48Address receiverAddr, Mac48Address } int len = p->GetSize(); - uint8_t* buf = new uint8_t[len]; + auto buf = new uint8_t[len]; p->CopyData(buf, len); // ... and send the packet to the corresponding Click interface @@ -817,8 +816,8 @@ simclick_sim_command(simclick_node_t* simnode, int cmd, ...) // Append key/value pair, separated by \0. std::map defines = clickInstance->GetDefines(); - std::map::const_iterator it = defines.begin(); - while (it != defines.end()) + + for (auto it = defines.begin(); it != defines.end(); it++) { size_t available = *size - required; if (it->first.length() + it->second.length() + 2 <= available) @@ -833,7 +832,6 @@ simclick_sim_command(simclick_node_t* simnode, int cmd, ...) { required += it->first.length() + it->second.length() + 2; } - it++; } if (required > *size) { @@ -850,5 +848,3 @@ simclick_sim_command(simclick_node_t* simnode, int cmd, ...) va_end(val); return retval; } - -#endif // NS3_CLICK diff --git a/src/click/model/ipv4-click-routing.h b/src/click/model/ipv4-click-routing.h index aa1943e45..cded799e7 100644 --- a/src/click/model/ipv4-click-routing.h +++ b/src/click/model/ipv4-click-routing.h @@ -54,21 +54,30 @@ class UniformRandomVariable; * \ingroup click * \brief Class to allow a node to use Click for external routing */ - class Ipv4ClickRouting : public Ipv4RoutingProtocol { -#ifdef NS3_CLICK public: // Allow test cases to access private members friend class ::ClickTrivialTest; friend class ::ClickIfidFromNameTest; friend class ::ClickIpMacAddressFromNameTest; + /** + * Get type ID. + * + * \return TypeId. + */ static TypeId GetTypeId(); + /** Constructor. */ Ipv4ClickRouting(); ~Ipv4ClickRouting() override; + /** + * Get the uniform random variable. + * + * \return Uniform random variable. + */ Ptr GetRandomVariable(); protected: @@ -104,27 +113,30 @@ class Ipv4ClickRouting : public Ipv4RoutingProtocol /** * \brief Read Handler interface for a node's Click Elements. * Allows a user to read state information of a Click element. - * \param elementName name of the Click element - * \param handlerName name of the handler to be read + * \param elementName name of the Click element. + * \param handlerName name of the handler to be read. + * \return String read. */ std::string ReadHandler(std::string elementName, std::string handlerName); /** - * \brief Write Handler interface for a node's Click Elements + * \brief Write Handler interface for a node's Click Elements. * Allows a user to modify state information of a Click element. - * \param elementName name of the Click element - * \param handlerName name of the handler to be read - * \param writeString string to be written using the write handler + * \param elementName name of the Click element. + * \param handlerName name of the handler to be read. + * \param writeString string to be written using the write handler. + * \return Write operation status. */ int WriteHandler(std::string elementName, std::string handlerName, std::string writeString); /** - * * \brief Sets an interface to run on promiscuous mode. + * \param ifid Interface ID. */ void SetPromisc(int ifid); private: + /// Pointer to the simclick node simclick_node_t* m_simNode; /** @@ -186,6 +198,7 @@ class Ipv4ClickRouting : public Ipv4RoutingProtocol /** * \brief Provides for SIMCLICK_IF_READY + * \param ifid Interface ID * \return Returns 1, if the interface is ready, -1 if ifid is invalid */ bool IsInterfaceReady(int ifid); @@ -204,7 +217,8 @@ class Ipv4ClickRouting : public Ipv4RoutingProtocol void AddSimNodeToClickMapping(); /** - * \brief Get current simulation time as a timeval + * \brief Get current simulation time as a timeval. + * \return Current simulation time as a timeval. */ struct timeval GetTimevalFromNow() const; @@ -274,20 +288,16 @@ class Ipv4ClickRouting : public Ipv4RoutingProtocol void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address) override; private: - std::string m_clickFile; - std::map m_defines; - std::string m_nodeName; - std::string m_clickRoutingTableElement; + std::string m_clickFile; //!< Name of .click configuration file + std::map m_defines; //!< Defines for .click configuration file parsing + std::string m_nodeName; //!< Name of the node + std::string m_clickRoutingTableElement; //!< Name of the routing table element - std::map m_ifaceIdFromName; - std::map m_ifaceMacFromName; - std::map m_ifaceAddrFromName; - bool m_clickInitialised; - bool m_nonDefaultName; + bool m_clickInitialised; //!< Whether click has been initialized + bool m_nonDefaultName; //!< Whether a non-default name has been set - Ptr m_ipv4; - Ptr m_random; -#endif /* NS3_CLICK */ + Ptr m_ipv4; //!< Pointer to the IPv4 object + Ptr m_random; //!< Uniform random variable }; } // namespace ns3 diff --git a/src/click/model/ipv4-l3-click-protocol.cc b/src/click/model/ipv4-l3-click-protocol.cc index 337b5e47a..7f050c1b8 100644 --- a/src/click/model/ipv4-l3-click-protocol.cc +++ b/src/click/model/ipv4-l3-click-protocol.cc @@ -18,15 +18,14 @@ // Author: Lalith Suresh // -#ifdef NS3_CLICK - #include "ipv4-l3-click-protocol.h" +#include "ipv4-click-routing.h" + #include "ns3/arp-l3-protocol.h" #include "ns3/ethernet-header.h" #include "ns3/icmpv4-l4-protocol.h" #include "ns3/ip-l4-protocol.h" -#include "ns3/ipv4-click-routing.h" #include "ns3/ipv4-raw-socket-impl.h" #include "ns3/llc-snap-header.h" #include "ns3/loopback-net-device.h" @@ -80,13 +79,13 @@ void Ipv4L3ClickProtocol::DoDispose() { NS_LOG_FUNCTION(this); - for (L4List_t::iterator i = m_protocols.begin(); i != m_protocols.end(); ++i) + for (auto i = m_protocols.begin(); i != m_protocols.end(); ++i) { i->second = nullptr; } m_protocols.clear(); - for (Ipv4InterfaceList::iterator i = m_interfaces.begin(); i != m_interfaces.end(); ++i) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); ++i) { *i = nullptr; } @@ -153,8 +152,7 @@ Ipv4L3ClickProtocol::GetInterfaceForAddress(Ipv4Address address) const NS_LOG_FUNCTION(this << address); int32_t interface = 0; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); - i++, interface++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++, interface++) { for (uint32_t j = 0; j < (*i)->GetNAddresses(); j++) { @@ -174,8 +172,7 @@ Ipv4L3ClickProtocol::GetInterfaceForPrefix(Ipv4Address address, Ipv4Mask mask) c NS_LOG_FUNCTION(this << address << mask); int32_t interface = 0; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); - i++, interface++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++, interface++) { for (uint32_t j = 0; j < (*i)->GetNAddresses(); j++) { @@ -194,7 +191,7 @@ Ipv4L3ClickProtocol::GetInterfaceForDevice(Ptr device) const { NS_LOG_FUNCTION(this << device->GetIfIndex()); - Ipv4InterfaceReverseContainer::const_iterator iter = m_reverseInterfacesContainer.find(device); + auto iter = m_reverseInterfacesContainer.find(device); if (iter != m_reverseInterfacesContainer.end()) { return (*iter).second; @@ -275,7 +272,7 @@ Ipv4L3ClickProtocol::SetIpForward(bool forward) { NS_LOG_FUNCTION(this << forward); m_ipForward = forward; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { (*i)->SetForwarding(forward); } @@ -364,7 +361,7 @@ void Ipv4L3ClickProtocol::DeleteRawSocket(Ptr socket) { NS_LOG_FUNCTION(this << socket); - for (SocketList::iterator i = m_sockets.begin(); i != m_sockets.end(); ++i) + for (auto i = m_sockets.begin(); i != m_sockets.end(); ++i) { if ((*i) == socket) { @@ -805,7 +802,7 @@ Ipv4L3ClickProtocol::Receive(Ptr device, } packetForRawSocket->RemoveHeader(ipHeader); - for (SocketList::iterator i = m_sockets.begin(); i != m_sockets.end(); ++i) + for (auto i = m_sockets.begin(); i != m_sockets.end(); ++i) { NS_LOG_LOGIC("Forwarding to raw socket"); Ptr socket = *i; @@ -923,7 +920,7 @@ Ipv4L3ClickProtocol::Remove(Ptr protocol) NS_LOG_FUNCTION(this << protocol); L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), -1); - L4List_t::iterator iter = m_protocols.find(key); + auto iter = m_protocols.find(key); if (iter == m_protocols.end()) { NS_LOG_WARN("Trying to remove an non-existent default protocol " @@ -941,7 +938,7 @@ Ipv4L3ClickProtocol::Remove(Ptr protocol, uint32_t interfaceIndex) NS_LOG_FUNCTION(this << protocol << interfaceIndex); L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), interfaceIndex); - L4List_t::iterator iter = m_protocols.find(key); + auto iter = m_protocols.find(key); if (iter == m_protocols.end()) { NS_LOG_WARN("Trying to remove an non-existent protocol " @@ -968,12 +965,11 @@ Ipv4L3ClickProtocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) con NS_LOG_FUNCTION(this << protocolNumber << interfaceIndex); L4ListKey_t key; - L4List_t::const_iterator i; if (interfaceIndex >= 0) { // try the interface-specific protocol. key = std::make_pair(protocolNumber, interfaceIndex); - i = m_protocols.find(key); + auto i = m_protocols.find(key); if (i != m_protocols.end()) { return i->second; @@ -981,7 +977,7 @@ Ipv4L3ClickProtocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) con } // try the generic protocol. key = std::make_pair(protocolNumber, -1); - i = m_protocols.find(key); + auto i = m_protocols.find(key); if (i != m_protocols.end()) { return i->second; @@ -991,5 +987,3 @@ Ipv4L3ClickProtocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) con } } // namespace ns3 - -#endif // NS3_CLICK diff --git a/src/click/model/ipv4-l3-click-protocol.h b/src/click/model/ipv4-l3-click-protocol.h index 6f36f9cee..d90f5403d 100644 --- a/src/click/model/ipv4-l3-click-protocol.h +++ b/src/click/model/ipv4-l3-click-protocol.h @@ -60,8 +60,12 @@ class Icmpv4L4Protocol; class Ipv4L3ClickProtocol : public Ipv4 { -#ifdef NS3_CLICK public: + /** + * Get Type ID. + * + * \return The type ID. + */ static TypeId GetTypeId(); /** @@ -224,6 +228,12 @@ class Ipv4L3ClickProtocol : public Ipv4 void SetDown(uint32_t i) override; bool IsForwarding(uint32_t i) const override; void SetForwarding(uint32_t i, bool val) override; + + /** + * Sets an interface to run on promiscuous mode. + * + * \param i Interface ID. + */ void SetPromisc(uint32_t i); protected: @@ -236,6 +246,17 @@ class Ipv4L3ClickProtocol : public Ipv4 void NotifyNewAggregate() override; private: + /** + * Build IPv4 header. + * + * \param source IPv4 source address. + * \param destination IPv4 destination address. + * \param protocol Protocol. + * \param payloadSize Payload size. + * \param ttl Time To Live (TTL). + * \param mayFragment Whether the packet can be fragmented or not. + * \return The IPv4 header. + */ Ipv4Header BuildHeader(Ipv4Address source, Ipv4Address destination, uint8_t protocol, @@ -248,32 +269,42 @@ class Ipv4L3ClickProtocol : public Ipv4 void SetWeakEsModel(bool model) override; bool GetWeakEsModel() const override; + /** + * \brief List of IPv4 interfaces. + */ typedef std::vector> Ipv4InterfaceList; + /** * \brief Container of NetDevices registered to IPv4 and their interface indexes. */ typedef std::map, uint32_t> Ipv4InterfaceReverseContainer; + + /** + * \brief List of sockets. + */ typedef std::list> SocketList; + /** * \brief Container of the IPv4 L4 keys: protocol number, interface index */ typedef std::pair L4ListKey_t; + /** * \brief Container of the IPv4 L4 instances. */ typedef std::map> L4List_t; - Ptr m_routingProtocol; - bool m_ipForward; - bool m_weakEsModel; - L4List_t m_protocols; - Ipv4InterfaceList m_interfaces; + Ptr m_routingProtocol; //!< IPv4 routing protocol + bool m_ipForward; //!< Whether IP forwarding is enabled + bool m_weakEsModel; //!< Whether to use weak Es model + L4List_t m_protocols; //!< List of IPv4 L4 protocols + Ipv4InterfaceList m_interfaces; //!< List of interfaces Ipv4InterfaceReverseContainer - m_reverseInterfacesContainer; //!< Container of NetDevice / Interface index associations. - uint8_t m_defaultTtl; - uint16_t m_identification; + m_reverseInterfacesContainer; //!< Container of NetDevice / Interface index associations + uint8_t m_defaultTtl; //!< Default TTL + uint16_t m_identification; //!< Identification - Ptr m_node; + Ptr m_node; //!< Node /** \todo Remove; this TracedCallback is never invoked. */ TracedCallback, uint32_t> m_sendOutgoingTrace; @@ -282,11 +313,9 @@ class Ipv4L3ClickProtocol : public Ipv4 /** \todo This TracedCallback is invoked but not accessible. */ TracedCallback, uint32_t> m_localDeliverTrace; - SocketList m_sockets; + SocketList m_sockets; //!< List of sockets - std::vector m_promiscDeviceList; - -#endif /* NS3_CLICK */ + std::vector m_promiscDeviceList; //!< List of promiscuous devices }; } // namespace ns3 diff --git a/src/click/test/ipv4-click-routing-test.cc b/src/click/test/ipv4-click-routing-test.cc index ba943b034..93c915af3 100644 --- a/src/click/test/ipv4-click-routing-test.cc +++ b/src/click/test/ipv4-click-routing-test.cc @@ -17,8 +17,6 @@ * Authors: Lalith Suresh */ -#ifdef NS3_CLICK - #include "ns3/click-internet-stack-helper.h" #include "ns3/ipv4-click-routing.h" #include "ns3/ipv4-l3-protocol.h" @@ -32,6 +30,17 @@ using namespace ns3; +/** + * \file + * \ingroup click-tests + * Click test suite. + */ + +/** + * Add Click Internet stack. + * + * \param node Node. + */ static void AddClickInternetStack(Ptr node) { @@ -40,6 +49,14 @@ AddClickInternetStack(Ptr node) internet.Install(node); } +/** + * Add network device. + * + * \param node Node. + * \param macaddr MAC address. + * \param ipv4addr IPv4 address. + * \param ipv4mask IPv4 mask. + */ static void AddNetworkDevice(Ptr node, Mac48Address macaddr, Ipv4Address ipv4addr, Ipv4Mask ipv4mask) { @@ -56,6 +73,10 @@ AddNetworkDevice(Ptr node, Mac48Address macaddr, Ipv4Address ipv4addr, Ipv ipv4->SetUp(netdev_idx); } +/** + * \ingroup click-tests + * Click interface ID from name test. + */ class ClickIfidFromNameTest : public TestCase { public: @@ -102,6 +123,10 @@ ClickIfidFromNameTest::DoRun() NS_TEST_EXPECT_MSG_EQ(ret, -1, "No eth1 on node"); } +/** + * \ingroup click-tests + * Click IP MAC address from name test. + */ class ClickIpMacAddressFromNameTest : public TestCase { public: @@ -162,6 +187,10 @@ ClickIpMacAddressFromNameTest::DoRun() delete[] buf; } +/** + * \ingroup click-tests + * Click trivial test. + */ class ClickTrivialTest : public TestCase { public: @@ -206,6 +235,10 @@ ClickTrivialTest::DoRun() delete[] buf; } +/** + * \ingroup click-tests + * Click interface ID from name test. + */ class ClickIfidFromNameTestSuite : public TestSuite { public: @@ -216,6 +249,7 @@ class ClickIfidFromNameTestSuite : public TestSuite AddTestCase(new ClickIfidFromNameTest, TestCase::QUICK); AddTestCase(new ClickIpMacAddressFromNameTest, TestCase::QUICK); } -} g_ipv4ClickRoutingTestSuite; +}; -#endif // NS3_CLICK +/// Static variable for test initialization +static ClickIfidFromNameTestSuite g_ipv4ClickRoutingTestSuite; diff --git a/src/config-store/model/attribute-iterator.cc b/src/config-store/model/attribute-iterator.cc index 3165da3f5..8cb7dff03 100644 --- a/src/config-store/model/attribute-iterator.cc +++ b/src/config-store/model/attribute-iterator.cc @@ -227,8 +227,7 @@ AttributeIterator::DoIterate(Ptr object) for (uint32_t i = 0; i < tid.GetAttributeN(); ++i) { TypeId::AttributeInformation info = tid.GetAttribute(i); - const PointerChecker* ptrChecker = - dynamic_cast(PeekPointer(info.checker)); + const auto ptrChecker = dynamic_cast(PeekPointer(info.checker)); if (ptrChecker != nullptr) { NS_LOG_DEBUG("pointer attribute " << info.name); @@ -246,7 +245,7 @@ AttributeIterator::DoIterate(Ptr object) continue; } // attempt to cast to an object container - const ObjectPtrContainerChecker* vectorChecker = + const auto vectorChecker = dynamic_cast(PeekPointer(info.checker)); if (vectorChecker != nullptr) { diff --git a/src/config-store/model/model-node-creator.cc b/src/config-store/model/model-node-creator.cc index c5df8133e..a3bbfa7a5 100644 --- a/src/config-store/model/model-node-creator.cc +++ b/src/config-store/model/model-node-creator.cc @@ -41,7 +41,7 @@ void ModelCreator::Add(ModelNode* node) { GtkTreeIter* parent = m_iters.back(); - GtkTreeIter* current = g_new(GtkTreeIter, 1); + auto current = g_new(GtkTreeIter, 1); gtk_tree_store_append(m_treestore, current, parent); gtk_tree_store_set(m_treestore, current, COL_NODE, node, -1); m_iters.push_back(current); @@ -58,7 +58,7 @@ ModelCreator::Remove() void ModelCreator::DoVisitAttribute(Ptr object, std::string name) { - ModelNode* node = new ModelNode(); + auto node = new ModelNode(); node->type = ModelNode::NODE_ATTRIBUTE; node->object = object; node->name = name; @@ -69,7 +69,7 @@ ModelCreator::DoVisitAttribute(Ptr object, std::string name) void ModelCreator::DoStartVisitObject(Ptr object) { - ModelNode* node = new ModelNode(); + auto node = new ModelNode(); node->type = ModelNode::NODE_OBJECT; node->object = object; Add(node); @@ -84,7 +84,7 @@ ModelCreator::DoEndVisitObject() void ModelCreator::DoStartVisitPointerAttribute(Ptr object, std::string name, Ptr value) { - ModelNode* node = new ModelNode(); + auto node = new ModelNode(); node->type = ModelNode::NODE_POINTER; node->object = object; node->name = name; @@ -102,7 +102,7 @@ ModelCreator::DoStartVisitArrayAttribute(Ptr object, std::string name, const ObjectPtrContainerValue& vector) { - ModelNode* node = new ModelNode(); + auto node = new ModelNode(); node->type = ModelNode::NODE_VECTOR; node->object = object; node->name = name; @@ -121,8 +121,8 @@ ModelCreator::DoStartVisitArrayItem(const ObjectPtrContainerValue& vector, Ptr item) { GtkTreeIter* parent = m_iters.back(); - GtkTreeIter* current = g_new(GtkTreeIter, 1); - ModelNode* node = new ModelNode(); + auto current = g_new(GtkTreeIter, 1); + auto node = new ModelNode(); node->type = ModelNode::NODE_VECTOR_ITEM; node->object = item; node->index = index; diff --git a/src/config-store/model/model-typeid-creator.cc b/src/config-store/model/model-typeid-creator.cc index fd360eb99..a76b06c81 100644 --- a/src/config-store/model/model-typeid-creator.cc +++ b/src/config-store/model/model-typeid-creator.cc @@ -38,7 +38,7 @@ void ModelTypeidCreator::Add(ModelTypeid* node) { GtkTreeIter* parent = m_iters.back(); - GtkTreeIter* current = g_new(GtkTreeIter, 1); + auto current = g_new(GtkTreeIter, 1); gtk_tree_store_append(m_treestore, current, parent); gtk_tree_store_set(m_treestore, current, COL_TYPEID, node, -1); m_iters.push_back(current); @@ -58,7 +58,7 @@ ModelTypeidCreator::VisitAttribute(TypeId tid, std::string defaultValue, uint32_t index) { - ModelTypeid* node = new ModelTypeid(); + auto node = new ModelTypeid(); node->type = ModelTypeid::NODE_ATTRIBUTE; node->tid = tid; node->name = name; @@ -71,7 +71,7 @@ ModelTypeidCreator::VisitAttribute(TypeId tid, void ModelTypeidCreator::StartVisitTypeId(std::string name) { - ModelTypeid* node = new ModelTypeid(); + auto node = new ModelTypeid(); node->type = ModelTypeid::NODE_TYPEID; node->tid = TypeId::LookupByName(name); Add(node); diff --git a/src/config-store/model/raw-text-config.cc b/src/config-store/model/raw-text-config.cc index 188dd5ef7..7db161f4c 100644 --- a/src/config-store/model/raw-text-config.cc +++ b/src/config-store/model/raw-text-config.cc @@ -131,7 +131,7 @@ void RawTextConfigSave::Global() { NS_LOG_FUNCTION(this); - for (GlobalValue::Iterator i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) + for (auto i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) { StringValue value; (*i)->GetValue(value); diff --git a/src/config-store/model/xml-config.cc b/src/config-store/model/xml-config.cc index 6ea192f00..c8f377d43 100644 --- a/src/config-store/model/xml-config.cc +++ b/src/config-store/model/xml-config.cc @@ -271,7 +271,7 @@ void XmlConfigSave::Global() { int rc; - for (GlobalValue::Iterator i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) + for (auto i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) { StringValue value; (*i)->GetValue(value); diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 3bc9fd689..fb5e1ee1c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,7 +1,5 @@ # Set lib core link dependencies -set(libraries_to_link - ${CMAKE_THREAD_LIBS_INIT} -) +set(libraries_to_link) set(gsl_test_sources) if(${GSL_FOUND}) diff --git a/src/core/examples/CMakeLists.txt b/src/core/examples/CMakeLists.txt index 9befa2b39..0f0d7eeff 100644 --- a/src/core/examples/CMakeLists.txt +++ b/src/core/examples/CMakeLists.txt @@ -47,7 +47,6 @@ build_lib_example( NAME main-test-sync SOURCE_FILES main-test-sync.cc LIBRARIES_TO_LINK ${libnetwork} - ${CMAKE_THREAD_LIBS_INIT} ) build_lib_example( diff --git a/src/core/examples/hash-example.cc b/src/core/examples/hash-example.cc index 514e69197..f7d0e3624 100644 --- a/src/core/examples/hash-example.cc +++ b/src/core/examples/hash-example.cc @@ -296,10 +296,10 @@ class Dictionary return; } - int newPhrases = 0; + bool newPhrases = false; for (auto& collider : m_hashes) { - newPhrases += collider.Add(phrase); + newPhrases |= collider.Add(phrase); } if (newPhrases) @@ -352,7 +352,7 @@ class Dictionary // // Number of buckets = k = 2^bits long double k32 = 0xFFFFFFFF; - long double k64 = static_cast(0xFFFFFFFFFFFFFFFFULL); + auto k64 = static_cast(0xFFFFFFFFFFFFFFFFULL); long double n = m_nphrases; long double Ec32 = n * (n - 1) / (2 * k32) * (1 - (n - 2) / (3 * k32)); diff --git a/src/core/examples/main-random-variable-stream.cc b/src/core/examples/main-random-variable-stream.cc index 43820d6b6..96ef3f8e5 100644 --- a/src/core/examples/main-random-variable-stream.cc +++ b/src/core/examples/main-random-variable-stream.cc @@ -99,7 +99,7 @@ Histogram(Ptr rndvar, data.SetStyle(Gnuplot2dDataset::IMPULSES); } - for (histogram_maptype::const_iterator hi = histogram.begin(); hi != histogram.end(); ++hi) + for (auto hi = histogram.begin(); hi != histogram.end(); ++hi) { data.Add(hi->first, (double)hi->second / (double)probes / precision); } diff --git a/src/core/helper/event-garbage-collector.cc b/src/core/helper/event-garbage-collector.cc index 8fa0d8100..6beed43eb 100644 --- a/src/core/helper/event-garbage-collector.cc +++ b/src/core/helper/event-garbage-collector.cc @@ -65,7 +65,7 @@ EventGarbageCollector::Shrink() void EventGarbageCollector::Cleanup() { - for (EventList::iterator iter = m_events.begin(); iter != m_events.end();) + for (auto iter = m_events.begin(); iter != m_events.end();) { if ((*iter).IsExpired()) { diff --git a/src/core/model/ascii-test.h b/src/core/model/ascii-test.h index 6e313f387..0b1947a31 100644 --- a/src/core/model/ascii-test.h +++ b/src/core/model/ascii-test.h @@ -23,8 +23,7 @@ #define ASCII_TEST_H #include "ascii-file.h" - -#include "ns3/test.h" +#include "test.h" #include diff --git a/src/core/model/attribute-construction-list.cc b/src/core/model/attribute-construction-list.cc index 657db4507..42253c176 100644 --- a/src/core/model/attribute-construction-list.cc +++ b/src/core/model/attribute-construction-list.cc @@ -45,7 +45,7 @@ AttributeConstructionList::Add(std::string name, // vector of values. NS_LOG_FUNCTION(this << name << checker << value); - for (std::list::iterator k = m_list.begin(); k != m_list.end(); k++) + for (auto k = m_list.begin(); k != m_list.end(); k++) { if (k->checker == checker) { @@ -65,7 +65,7 @@ Ptr AttributeConstructionList::Find(Ptr checker) const { NS_LOG_FUNCTION(this << checker); - for (CIterator k = m_list.begin(); k != m_list.end(); k++) + for (auto k = m_list.begin(); k != m_list.end(); k++) { NS_LOG_DEBUG("Found " << k->name << " " << k->checker << " " << k->value); if (k->checker == checker) diff --git a/src/core/model/attribute-container.h b/src/core/model/attribute-container.h index 974abfd6c..547d6fa28 100644 --- a/src/core/model/attribute-container.h +++ b/src/core/model/attribute-container.h @@ -20,8 +20,8 @@ #ifndef ATTRIBUTE_CONTAINER_H #define ATTRIBUTE_CONTAINER_H -#include -#include +#include "attribute-helper.h" +#include "string.h" #include #include diff --git a/src/core/model/attribute.cc b/src/core/model/attribute.cc index 88f21f66d..6553a2353 100644 --- a/src/core/model/attribute.cc +++ b/src/core/model/attribute.cc @@ -69,7 +69,7 @@ AttributeChecker::CreateValidValue(const AttributeValue& value) const return value.Copy(); } // attempt to convert to string. - const StringValue* str = dynamic_cast(&value); + const auto str = dynamic_cast(&value); if (str == nullptr) { return nullptr; diff --git a/src/core/model/calendar-scheduler.cc b/src/core/model/calendar-scheduler.cc index 1807579e2..2cb9e37e9 100644 --- a/src/core/model/calendar-scheduler.cc +++ b/src/core/model/calendar-scheduler.cc @@ -137,8 +137,8 @@ CalendarScheduler::DoInsert(const Event& ev) NS_LOG_LOGIC("insert in bucket=" << bucket); // insert in bucket list. - Bucket::iterator end = m_buckets[bucket].end(); - for (Bucket::iterator i = m_buckets[bucket].begin(); i != end; ++i) + auto end = m_buckets[bucket].end(); + for (auto i = m_buckets[bucket].begin(); i != end; ++i) { if (Order(ev.key, i->key)) { @@ -267,8 +267,8 @@ CalendarScheduler::Remove(const Event& ev) // bucket index of event uint32_t bucket = Hash(ev.key.m_ts); - Bucket::iterator end = m_buckets[bucket].end(); - for (Bucket::iterator i = m_buckets[bucket].begin(); i != end; ++i) + auto end = m_buckets[bucket].end(); + for (auto i = m_buckets[bucket].begin(); i != end; ++i) { if (i->key.m_uid == ev.key.m_uid) { @@ -341,7 +341,7 @@ CalendarScheduler::CalculateNewWidth() samples.push_back(DoRemoveNext()); } // put them back - for (std::list::const_iterator i = samples.begin(); i != samples.end(); ++i) + for (auto i = samples.begin(); i != samples.end(); ++i) { DoInsert(*i); } @@ -353,9 +353,9 @@ CalendarScheduler::CalculateNewWidth() // finally calculate inter-time average over samples. uint64_t totalSeparation = 0; - std::list::const_iterator end = samples.end(); - std::list::const_iterator cur = samples.begin(); - std::list::const_iterator next = cur; + auto end = samples.end(); + auto cur = samples.begin(); + auto next = cur; next++; while (next != end) { @@ -395,8 +395,8 @@ CalendarScheduler::DoResize(uint32_t newSize, uint64_t newWidth) for (uint32_t i = 0; i < oldNBuckets; i++) { - Bucket::iterator end = oldBuckets[i].end(); - for (Bucket::iterator j = oldBuckets[i].begin(); j != end; ++j) + auto end = oldBuckets[i].end(); + for (auto j = oldBuckets[i].begin(); j != end; ++j) { DoInsert(*j); } diff --git a/src/core/model/callback.h b/src/core/model/callback.h index 67655506e..573aa29e6 100644 --- a/src/core/model/callback.h +++ b/src/core/model/callback.h @@ -284,7 +284,7 @@ class CallbackImpl : public CallbackImplBase bool IsEqual(Ptr other) const override { - const CallbackImpl* otherDerived = + const auto otherDerived = dynamic_cast*>(PeekPointer(other)); if (otherDerived == nullptr) @@ -324,7 +324,7 @@ class CallbackImpl : public CallbackImplBase return DoGetTypeid(); } - /** \copydoc GetTypeid(). */ + /** \copydoc GetTypeid() */ static std::string DoGetTypeid() { static std::vector vec = {GetCppTypeid(), GetCppTypeid()...}; @@ -467,7 +467,8 @@ class Callback : public CallbackBase auto f = cb.DoPeekImpl()->GetFunction(); CallbackComponentVector components(cb.DoPeekImpl()->GetComponents()); - components.insert(components.end(), {std::make_shared>(bargs)...}); + components.insert(components.end(), + {std::make_shared>>(bargs)...}); m_impl = Create>( [f, bargs...](auto&&... uargs) -> R { @@ -501,8 +502,9 @@ class Callback : public CallbackBase constexpr bool isComp = std::is_function_v> || std::is_member_pointer_v; - CallbackComponentVector components({std::make_shared>(func), - std::make_shared>(bargs)...}); + CallbackComponentVector components( + {std::make_shared>(func), + std::make_shared>>(bargs)...}); m_impl = Create>( [f, bargs...](auto&&... uargs) -> R { @@ -532,7 +534,7 @@ class Callback : public CallbackBase CallbackComponentVector components(DoPeekImpl()->GetComponents()); components.insert(components.end(), - {std::make_shared>(bargs)...}); + {std::make_shared>>(bargs)...}); cb.m_impl = Create>( [f, bargs...](auto&&... uargs) mutable { diff --git a/src/core/model/config.cc b/src/core/model/config.cc index f6cf3c741..5f6c51aa8 100644 --- a/src/core/model/config.cc +++ b/src/core/model/config.cc @@ -103,7 +103,7 @@ void MatchContainer::Set(std::string name, const AttributeValue& value) { NS_LOG_FUNCTION(this << name << &value); - for (Iterator tmp = Begin(); tmp != End(); ++tmp) + for (auto tmp = Begin(); tmp != End(); ++tmp) { Ptr object = *tmp; // Let ObjectBase::SetAttribute raise any errors @@ -116,7 +116,7 @@ MatchContainer::SetFailSafe(std::string name, const AttributeValue& value) { NS_LOG_FUNCTION(this << name << &value); bool ok = false; - for (Iterator tmp = Begin(); tmp != End(); ++tmp) + for (auto tmp = Begin(); tmp != End(); ++tmp) { Ptr object = *tmp; ok |= object->SetAttributeFailSafe(name, value); @@ -162,7 +162,7 @@ MatchContainer::ConnectWithoutContextFailSafe(std::string name, const CallbackBa { NS_LOG_FUNCTION(this << name << &cb); bool ok = false; - for (Iterator tmp = Begin(); tmp != End(); ++tmp) + for (auto tmp = Begin(); tmp != End(); ++tmp) { Ptr object = *tmp; ok |= object->TraceConnectWithoutContext(name, cb); @@ -187,7 +187,7 @@ void MatchContainer::DisconnectWithoutContext(std::string name, const CallbackBase& cb) { NS_LOG_FUNCTION(this << name << &cb); - for (Iterator tmp = Begin(); tmp != End(); ++tmp) + for (auto tmp = Begin(); tmp != End(); ++tmp) { Ptr object = *tmp; object->TraceDisconnectWithoutContext(name, cb); @@ -423,8 +423,7 @@ Resolver::GetResolvedPath() const NS_LOG_FUNCTION(this); std::string fullPath = "/"; - for (std::vector::const_iterator i = m_workStack.begin(); i != m_workStack.end(); - i++) + for (auto i = m_workStack.begin(); i != m_workStack.end(); i++) { fullPath += *i + "/"; } @@ -549,7 +548,7 @@ Resolver::DoResolve(std::string path, Ptr root) continue; } // attempt to cast to a pointer checker. - const PointerChecker* pChecker = + const auto pChecker = dynamic_cast(PeekPointer(info.checker)); if (pChecker != nullptr) { @@ -572,7 +571,7 @@ Resolver::DoResolve(std::string path, Ptr root) m_workStack.pop_back(); } // attempt to cast to an object vector. - const ObjectPtrContainerChecker* vectorChecker = + const auto vectorChecker = dynamic_cast(PeekPointer(info.checker)); if (vectorChecker != nullptr) { @@ -801,7 +800,7 @@ ConfigImpl::LookupMatches(std::string path) std::vector m_contexts; } resolver = LookupMatchesResolver(path); - for (Roots::const_iterator i = m_roots.begin(); i != m_roots.end(); i++) + for (auto i = m_roots.begin(); i != m_roots.end(); i++) { resolver.Resolve(*i); } @@ -828,7 +827,7 @@ ConfigImpl::UnregisterRootNamespaceObject(Ptr obj) { NS_LOG_FUNCTION(this << obj); - for (std::vector>::iterator i = m_roots.begin(); i != m_roots.end(); i++) + for (auto i = m_roots.begin(); i != m_roots.end(); i++) { if (*i == obj) { @@ -867,7 +866,7 @@ Reset() } } // now, let's reset the initial value of every global value. - for (GlobalValue::Iterator i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) + for (auto i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) { (*i)->ResetInitialValue(); } diff --git a/src/core/model/default-simulator-impl.cc b/src/core/model/default-simulator-impl.cc index b269a3ff1..80742025c 100644 --- a/src/core/model/default-simulator-impl.cc +++ b/src/core/model/default-simulator-impl.cc @@ -319,7 +319,7 @@ DefaultSimulatorImpl::Remove(const EventId& id) if (id.GetUid() == EventId::UID::DESTROY) { // destroy events. - for (DestroyEvents::iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { @@ -365,8 +365,7 @@ DefaultSimulatorImpl::IsExpired(const EventId& id) const return true; } // destroy events. - for (DestroyEvents::const_iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); - i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { diff --git a/src/core/model/deprecated.h b/src/core/model/deprecated.h index 7401151ef..36a787d6e 100644 --- a/src/core/model/deprecated.h +++ b/src/core/model/deprecated.h @@ -74,6 +74,13 @@ */ #define NS_DEPRECATED(msg) [[deprecated(msg)]] +/** + * \ingroup core + * \def NS_DEPRECATED_3_40 + * Tag for things deprecated in version ns-3.40. + */ +#define NS_DEPRECATED_3_40(msg) NS_DEPRECATED(msg) + /** * \ingroup core * \def NS_DEPRECATED_3_39 diff --git a/src/core/model/double.cc b/src/core/model/double.cc index c3d329190..e3ce84c00 100644 --- a/src/core/model/double.cc +++ b/src/core/model/double.cc @@ -66,7 +66,7 @@ MakeDoubleChecker(double min, double max, std::string name) bool Check(const AttributeValue& value) const override { NS_LOG_FUNCTION(&value); - const DoubleValue* v = dynamic_cast(&value); + const auto v = dynamic_cast(&value); if (v == nullptr) { return false; @@ -103,8 +103,8 @@ MakeDoubleChecker(double min, double max, std::string name) bool Copy(const AttributeValue& source, AttributeValue& destination) const override { NS_LOG_FUNCTION(&source << &destination); - const DoubleValue* src = dynamic_cast(&source); - DoubleValue* dst = dynamic_cast(&destination); + const auto src = dynamic_cast(&source); + auto dst = dynamic_cast(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/enum.cc b/src/core/model/enum.cc index 1ca6be73c..907c6fa57 100644 --- a/src/core/model/enum.cc +++ b/src/core/model/enum.cc @@ -73,7 +73,7 @@ std::string EnumValue::SerializeToString(Ptr checker) const { NS_LOG_FUNCTION(this << checker); - const EnumChecker* p = dynamic_cast(PeekPointer(checker)); + const auto p = dynamic_cast(PeekPointer(checker)); NS_ASSERT(p != nullptr); std::string name = p->GetName(m_value); return name; @@ -83,7 +83,7 @@ bool EnumValue::DeserializeFromString(std::string value, Ptr checker) { NS_LOG_FUNCTION(this << value << checker); - const EnumChecker* p = dynamic_cast(PeekPointer(checker)); + const auto p = dynamic_cast(PeekPointer(checker)); NS_ASSERT(p != nullptr); m_value = p->GetValue(value); return true; @@ -150,7 +150,7 @@ bool EnumChecker::Check(const AttributeValue& value) const { NS_LOG_FUNCTION(this << &value); - const EnumValue* p = dynamic_cast(&value); + const auto p = dynamic_cast(&value); if (p == nullptr) { return false; @@ -201,8 +201,8 @@ bool EnumChecker::Copy(const AttributeValue& source, AttributeValue& destination) const { NS_LOG_FUNCTION(this << &source << &destination); - const EnumValue* src = dynamic_cast(&source); - EnumValue* dst = dynamic_cast(&destination); + const auto src = dynamic_cast(&source); + auto dst = dynamic_cast(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/environment-variable.cc b/src/core/model/environment-variable.cc index fa71a3a6d..d6ddd02b2 100644 --- a/src/core/model/environment-variable.cc +++ b/src/core/model/environment-variable.cc @@ -19,7 +19,7 @@ #include "environment-variable.h" -#include "ns3/string.h" +#include "string.h" #include // std::getenv #include // strlen diff --git a/src/core/model/example-as-test.h b/src/core/model/example-as-test.h index 4301817eb..a13c482c1 100644 --- a/src/core/model/example-as-test.h +++ b/src/core/model/example-as-test.h @@ -20,7 +20,7 @@ #ifndef NS3_EXAMPLE_AS_TEST_SUITE_H #define NS3_EXAMPLE_AS_TEST_SUITE_H -#include "ns3/test.h" +#include "test.h" #include diff --git a/src/core/model/global-value.cc b/src/core/model/global-value.cc index aad86274a..679a808dd 100644 --- a/src/core/model/global-value.cc +++ b/src/core/model/global-value.cc @@ -103,7 +103,7 @@ GlobalValue::GetValue(AttributeValue& value) const { return; } - StringValue* str = dynamic_cast(&value); + auto str = dynamic_cast(&value); if (str == nullptr) { NS_FATAL_ERROR("GlobalValue name=" << m_name << ": input value is not a string"); @@ -127,7 +127,7 @@ GlobalValue::SetValue(const AttributeValue& value) Ptr v = m_checker->CreateValidValue(value); if (!v) { - return 0; + return false; } m_currentValue = v; return true; @@ -138,7 +138,7 @@ GlobalValue::Bind(std::string name, const AttributeValue& value) { NS_LOG_FUNCTION(name << &value); - for (Iterator i = Begin(); i != End(); i++) + for (auto i = Begin(); i != End(); i++) { if ((*i)->GetName() == name) { @@ -157,7 +157,7 @@ GlobalValue::BindFailSafe(std::string name, const AttributeValue& value) { NS_LOG_FUNCTION(name << &value); - for (Iterator i = Begin(); i != End(); i++) + for (auto i = Begin(); i != End(); i++) { if ((*i)->GetName() == name) { @@ -193,7 +193,7 @@ bool GlobalValue::GetValueByNameFailSafe(std::string name, AttributeValue& value) { NS_LOG_FUNCTION(name << &value); - for (GlobalValue::Iterator gvit = GlobalValue::Begin(); gvit != GlobalValue::End(); ++gvit) + for (auto gvit = GlobalValue::Begin(); gvit != GlobalValue::End(); ++gvit) { if ((*gvit)->GetName() == name) { diff --git a/src/core/model/int64x64.cc b/src/core/model/int64x64.cc index 54c7dd9f2..a4155328d 100644 --- a/src/core/model/int64x64.cc +++ b/src/core/model/int64x64.cc @@ -74,7 +74,7 @@ operator<<(std::ostream& os, const int64x64_t& value) int64_t hi = absVal.GetHigh(); // Save stream format flags - std::size_t precision = static_cast(os.precision()); + auto precision = static_cast(os.precision()); std::ios_base::fmtflags ff = os.flags(); const bool floatfield = os.flags() & std::ios_base::floatfield; os << std::setw(1) << std::noshowpos; diff --git a/src/core/model/integer.cc b/src/core/model/integer.cc index 6af07bc0b..8dd248ad8 100644 --- a/src/core/model/integer.cc +++ b/src/core/model/integer.cc @@ -65,7 +65,7 @@ MakeIntegerChecker(int64_t min, int64_t max, std::string name) bool Check(const AttributeValue& value) const override { NS_LOG_FUNCTION(&value); - const IntegerValue* v = dynamic_cast(&value); + const auto v = dynamic_cast(&value); if (v == nullptr) { return false; @@ -102,8 +102,8 @@ MakeIntegerChecker(int64_t min, int64_t max, std::string name) bool Copy(const AttributeValue& src, AttributeValue& dst) const override { NS_LOG_FUNCTION(&src << &dst); - const IntegerValue* source = dynamic_cast(&src); - IntegerValue* destination = dynamic_cast(&dst); + const auto source = dynamic_cast(&src); + auto destination = dynamic_cast(&dst); if (source == nullptr || destination == nullptr) { return false; diff --git a/src/core/model/length.cc b/src/core/model/length.cc index 9a65fd354..718c01e27 100644 --- a/src/core/model/length.cc +++ b/src/core/model/length.cc @@ -17,9 +17,9 @@ * Author: Mathew Bielejeski */ -#include "ns3/length.h" +#include "length.h" -#include "ns3/log.h" +#include "log.h" #include #include diff --git a/src/core/model/list-scheduler.cc b/src/core/model/list-scheduler.cc index 9d5020409..ea1685d13 100644 --- a/src/core/model/list-scheduler.cc +++ b/src/core/model/list-scheduler.cc @@ -62,7 +62,7 @@ void ListScheduler::Insert(const Event& ev) { NS_LOG_FUNCTION(this << &ev); - for (EventsI i = m_events.begin(); i != m_events.end(); i++) + for (auto i = m_events.begin(); i != m_events.end(); i++) { if (ev.key < i->key) { @@ -100,7 +100,7 @@ void ListScheduler::Remove(const Event& ev) { NS_LOG_FUNCTION(this << &ev); - for (EventsI i = m_events.begin(); i != m_events.end(); i++) + for (auto i = m_events.begin(); i != m_events.end(); i++) { if (i->key.m_uid == ev.key.m_uid) { diff --git a/src/core/model/log.cc b/src/core/model/log.cc index e2f0507b3..7342615e3 100644 --- a/src/core/model/log.cc +++ b/src/core/model/log.cc @@ -247,7 +247,7 @@ bool LogComponent::IsEnabled(const LogLevel level) const { // LogComponentEnableEnvVar (); - return (level & m_levels) ? 1 : 0; + return level & m_levels; } bool @@ -320,9 +320,7 @@ void LogComponentEnableAll(LogLevel level) { LogComponent::ComponentList* components = LogComponent::GetComponentList(); - for (LogComponent::ComponentList::const_iterator i = components->begin(); - i != components->end(); - i++) + for (auto i = components->begin(); i != components->end(); i++) { i->second->Enable(level); } @@ -344,9 +342,7 @@ void LogComponentDisableAll(LogLevel level) { LogComponent::ComponentList* components = LogComponent::GetComponentList(); - for (LogComponent::ComponentList::const_iterator i = components->begin(); - i != components->end(); - i++) + for (auto i = components->begin(); i != components->end(); i++) { i->second->Disable(level); } diff --git a/src/core/model/map-scheduler.cc b/src/core/model/map-scheduler.cc index fd18503c7..aaa50fd09 100644 --- a/src/core/model/map-scheduler.cc +++ b/src/core/model/map-scheduler.cc @@ -79,7 +79,7 @@ Scheduler::Event MapScheduler::PeekNext() const { NS_LOG_FUNCTION(this); - EventMapCI i = m_list.begin(); + auto i = m_list.begin(); NS_ASSERT(i != m_list.end()); Event ev; @@ -93,7 +93,7 @@ Scheduler::Event MapScheduler::RemoveNext() { NS_LOG_FUNCTION(this); - EventMapI i = m_list.begin(); + auto i = m_list.begin(); NS_ASSERT(i != m_list.end()); Event ev; ev.impl = i->second; @@ -107,7 +107,7 @@ void MapScheduler::Remove(const Event& ev) { NS_LOG_FUNCTION(this << ev.impl << ev.key.m_ts << ev.key.m_uid); - EventMapI i = m_list.find(ev.key); + auto i = m_list.find(ev.key); NS_ASSERT(i->second == ev.impl); m_list.erase(i); } diff --git a/src/core/model/matrix-array.h b/src/core/model/matrix-array.h index c2dca2456..25a816a55 100644 --- a/src/core/model/matrix-array.h +++ b/src/core/model/matrix-array.h @@ -243,8 +243,7 @@ class MatrixArray : public ValArray * \return Returns a new matrix that is the result of the Hermitian transpose */ template >::value && - EnableBool)>::type> + typename = std::enable_if_t<(std::is_same_v> && EnableBool)>> MatrixArray HermitianTranspose() const; protected: diff --git a/src/core/model/names.cc b/src/core/model/names.cc index 6a0976073..c3b40a184 100644 --- a/src/core/model/names.cc +++ b/src/core/model/names.cc @@ -303,8 +303,7 @@ NamesPriv::Clear() // Every name is associated with an object in the object map, so freeing the // NameNodes in this map will free all of the memory allocated for the NameNodes // - for (std::map, NameNode*>::iterator i = m_objectMap.begin(); i != m_objectMap.end(); - ++i) + for (auto i = m_objectMap.begin(); i != m_objectMap.end(); ++i) { delete i->second; i->second = nullptr; @@ -420,7 +419,7 @@ NamesPriv::Add(Ptr context, std::string name, Ptr object) return false; } - NameNode* newNode = new NameNode(node, name, object); + auto newNode = new NameNode(node, name, object); node->m_nameMap[name] = newNode; m_objectMap[object] = newNode; @@ -525,7 +524,7 @@ NamesPriv::Rename(Ptr context, std::string oldname, std::string newname) return false; } - std::map::iterator i = node->m_nameMap.find(oldname); + auto i = node->m_nameMap.find(oldname); if (i == node->m_nameMap.end()) { NS_LOG_LOGIC("Old name does not exist in name map"); @@ -555,7 +554,7 @@ NamesPriv::FindName(Ptr object) { NS_LOG_FUNCTION(this << object); - std::map, NameNode*>::iterator i = m_objectMap.find(object); + auto i = m_objectMap.find(object); if (i == m_objectMap.end()) { NS_LOG_LOGIC("Object does not exist in object map"); @@ -573,7 +572,7 @@ NamesPriv::FindPath(Ptr object) { NS_LOG_FUNCTION(this << object); - std::map, NameNode*>::iterator i = m_objectMap.find(object); + auto i = m_objectMap.find(object); if (i == m_objectMap.end()) { NS_LOG_LOGIC("Object does not exist in object map"); @@ -648,7 +647,7 @@ NamesPriv::Find(std::string path) // There are no remaining slashes so this is the last segment of the // specified name. We're done when we find it // - std::map::iterator i = node->m_nameMap.find(remaining); + auto i = node->m_nameMap.find(remaining); if (i == node->m_nameMap.end()) { NS_LOG_LOGIC("Name does not exist in name map"); @@ -669,7 +668,7 @@ NamesPriv::Find(std::string path) offset = remaining.find('/'); std::string segment = remaining.substr(0, offset); - std::map::iterator i = node->m_nameMap.find(segment); + auto i = node->m_nameMap.find(segment); if (i == node->m_nameMap.end()) { NS_LOG_LOGIC("Name does not exist in name map"); @@ -723,7 +722,7 @@ NamesPriv::Find(Ptr context, std::string name) } } - std::map::iterator i = node->m_nameMap.find(name); + auto i = node->m_nameMap.find(name); if (i == node->m_nameMap.end()) { NS_LOG_LOGIC("Name does not exist in name map"); @@ -741,7 +740,7 @@ NamesPriv::IsNamed(Ptr object) { NS_LOG_FUNCTION(this << object); - std::map, NameNode*>::iterator i = m_objectMap.find(object); + auto i = m_objectMap.find(object); if (i == m_objectMap.end()) { NS_LOG_LOGIC("Object does not exist in object map, returning NameNode 0"); @@ -759,7 +758,7 @@ NamesPriv::IsDuplicateName(NameNode* node, std::string name) { NS_LOG_FUNCTION(this << node << name); - std::map::iterator i = node->m_nameMap.find(name); + auto i = node->m_nameMap.find(name); if (i == node->m_nameMap.end()) { NS_LOG_LOGIC("Name does not exist in name map"); diff --git a/src/core/model/nstime.h b/src/core/model/nstime.h index 294895f7f..de142ccfd 100644 --- a/src/core/model/nstime.h +++ b/src/core/model/nstime.h @@ -580,7 +580,7 @@ class Time NS_ASSERT_MSG(info->isValid, "Attempted a conversion to an unavailable unit."); - int64x64_t retval = int64x64_t(m_data); + int64x64_t retval(m_data); if (info->toMul) { retval *= info->timeTo; @@ -792,21 +792,15 @@ class Time friend Time Rem(const Time& lhs, const Time& rhs); template - friend typename std::enable_if::value, Time>::type operator*( - const Time& lhs, - T rhs); + friend std::enable_if_t, Time> operator*(const Time& lhs, T rhs); // Reversed arg version (forwards to `rhs * lhs`) // Accepts both integers and decimal types template - friend typename std::enable_if::value, Time>::type operator*( - T lhs, - const Time& rhs); + friend std::enable_if_t, Time> operator*(T lhs, const Time& rhs); template - friend typename std::enable_if::value, Time>::type operator/( - const Time& lhs, - T rhs); + friend std::enable_if_t, Time> operator/(const Time& lhs, T rhs); friend Time Abs(const Time& time); friend Time Max(const Time& timeA, const Time& timeB); @@ -816,13 +810,9 @@ class Time // Leave undocumented template - friend typename std::enable_if::value, Time>::type operator*( - const Time& lhs, - T rhs); + friend std::enable_if_t, Time> operator*(const Time& lhs, T rhs); template - friend typename std::enable_if::value, Time>::type operator/( - const Time& lhs, - T rhs); + friend std::enable_if_t, Time> operator/(const Time& lhs, T rhs); /** * \name Compound assignment operators @@ -1017,18 +1007,17 @@ operator*(const int64x64_t& lhs, const Time& rhs) * \returns A new Time instance containing the scaled value */ template -typename std::enable_if::value, Time>::type +std::enable_if_t, Time> operator*(const Time& lhs, T rhs) { - static_assert(!std::is_same::value, - "Multiplying a Time by a boolean is not supported"); + static_assert(!std::is_same_v, "Multiplying a Time by a boolean is not supported"); return Time(lhs.m_data * rhs); } // Leave undocumented template -typename std::enable_if::value, Time>::type +std::enable_if_t, Time> operator*(const Time& lhs, T rhs) { return lhs * int64x64_t(rhs); @@ -1048,7 +1037,7 @@ operator*(const Time& lhs, T rhs) * \returns A new Time instance containing the scaled value */ template -typename std::enable_if::value, Time>::type +std::enable_if_t, Time> operator*(T lhs, const Time& rhs) { return rhs * lhs; @@ -1104,17 +1093,17 @@ operator/(const Time& lhs, const int64x64_t& rhs) * \returns A new Time instance containing the scaled value */ template -typename std::enable_if::value, Time>::type +std::enable_if_t, Time> operator/(const Time& lhs, T rhs) { - static_assert(!std::is_same::value, "Dividing a Time by a boolean is not supported"); + static_assert(!std::is_same_v, "Dividing a Time by a boolean is not supported"); return Time(lhs.m_data / rhs); } // Leave undocumented template -typename std::enable_if::value, Time>::type +std::enable_if_t, Time> operator/(const Time& lhs, T rhs) { return lhs / int64x64_t(rhs); diff --git a/src/core/model/object-base.cc b/src/core/model/object-base.cc index 65cc54c1f..6a9b78df7 100644 --- a/src/core/model/object-base.cc +++ b/src/core/model/object-base.cc @@ -35,6 +35,10 @@ namespace ns3 { +// Explicit instantiation declaration +template Callback MakeCallback(ObjectBase* (*)()); +template Callback::Callback(); +template class CallbackImpl; NS_LOG_COMPONENT_DEFINE("ObjectBase"); @@ -257,7 +261,7 @@ ObjectBase::GetAttribute(std::string name, AttributeValue& value) const { return; } - StringValue* str = dynamic_cast(&value); + auto str = dynamic_cast(&value); if (str == nullptr) { NS_FATAL_ERROR("Attribute name=" << name << " tid=" << tid.GetName() @@ -292,7 +296,7 @@ ObjectBase::GetAttributeFailSafe(std::string name, AttributeValue& value) const { return true; } - StringValue* str = dynamic_cast(&value); + auto str = dynamic_cast(&value); if (str == nullptr) { return false; diff --git a/src/core/model/object-base.h b/src/core/model/object-base.h index 66aa4be1c..c496531cb 100644 --- a/src/core/model/object-base.h +++ b/src/core/model/object-base.h @@ -335,6 +335,15 @@ class ObjectBase const AttributeValue& value); }; +// The following explicit template instantiation declarations prevent all the translation +// units including this header file to implicitly instantiate the callbacks class and +// function templates having ObjectBase as template type parameter that are required to be +// instantiated more often (accorging to the ClangBuildAnalyzer tool). +// These classes and functions are explicitly instantiated in object-base.cc +extern template Callback MakeCallback(ObjectBase* (*)()); +extern template Callback::Callback(); +extern template class CallbackImpl; + } // namespace ns3 #endif /* OBJECT_BASE_H */ diff --git a/src/core/model/object-factory.cc b/src/core/model/object-factory.cc index e6e29effa..7f13067d9 100644 --- a/src/core/model/object-factory.cc +++ b/src/core/model/object-factory.cc @@ -95,7 +95,7 @@ ObjectFactory::Create() const NS_LOG_FUNCTION(this); Callback cb = m_tid.GetConstructor(); ObjectBase* base = cb(); - Object* derived = dynamic_cast(base); + auto derived = dynamic_cast(base); NS_ASSERT(derived != nullptr); derived->SetTypeId(m_tid); derived->Construct(m_parameters); @@ -108,9 +108,7 @@ operator<<(std::ostream& os, const ObjectFactory& factory) { os << factory.m_tid.GetName() << "["; bool first = true; - for (AttributeConstructionList::CIterator i = factory.m_parameters.Begin(); - i != factory.m_parameters.End(); - ++i) + for (auto i = factory.m_parameters.Begin(); i != factory.m_parameters.End(); ++i) { os << i->name << "=" << i->value->SerializeToString(i->checker); if (first) diff --git a/src/core/model/object-map.h b/src/core/model/object-map.h index 1adf11477..0a4c17b8a 100644 --- a/src/core/model/object-map.h +++ b/src/core/model/object-map.h @@ -93,10 +93,10 @@ MakeObjectMapAccessor(U T::*memberVector) std::size_t* index) const override { const T* obj = static_cast(object); - typename U::const_iterator begin = (obj->*m_memberVector).begin(); - typename U::const_iterator end = (obj->*m_memberVector).end(); + auto begin = (obj->*m_memberVector).begin(); + auto end = (obj->*m_memberVector).end(); uint32_t k = 0; - for (typename U::const_iterator j = begin; j != end; j++, k++) + for (auto j = begin; j != end; j++, k++) { if (k == i) { diff --git a/src/core/model/object-ptr-container.cc b/src/core/model/object-ptr-container.cc index b8d5a0619..974f7ef9b 100644 --- a/src/core/model/object-ptr-container.cc +++ b/src/core/model/object-ptr-container.cc @@ -61,7 +61,7 @@ Ptr ObjectPtrContainerValue::Get(std::size_t i) const { NS_LOG_FUNCTION(this << i); - Iterator it = m_objects.find(i); + auto it = m_objects.find(i); Ptr value = nullptr; if (it != m_objects.end()) { @@ -115,7 +115,7 @@ bool ObjectPtrContainerAccessor::Get(const ObjectBase* object, AttributeValue& value) const { NS_LOG_FUNCTION(this << object << &value); - ObjectPtrContainerValue* v = dynamic_cast(&value); + auto v = dynamic_cast(&value); if (v == nullptr) { return false; diff --git a/src/core/model/object-ptr-container.h b/src/core/model/object-ptr-container.h index a924fb6ef..931ad9f32 100644 --- a/src/core/model/object-ptr-container.h +++ b/src/core/model/object-ptr-container.h @@ -208,8 +208,8 @@ class ObjectPtrContainerChecker : public ns3::ObjectPtrContainerChecker bool Copy(const AttributeValue& source, AttributeValue& destination) const override { - const ObjectPtrContainerValue* src = dynamic_cast(&source); - ObjectPtrContainerValue* dst = dynamic_cast(&destination); + const auto src = dynamic_cast(&source); + auto dst = dynamic_cast(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/object-vector.h b/src/core/model/object-vector.h index 30c03a414..36194507c 100644 --- a/src/core/model/object-vector.h +++ b/src/core/model/object-vector.h @@ -93,10 +93,10 @@ MakeObjectVectorAccessor(U T::*memberVector) std::size_t* index) const override { const T* obj = static_cast(object); - typename U::const_iterator begin = (obj->*m_memberVector).begin(); - typename U::const_iterator end = (obj->*m_memberVector).end(); + auto begin = (obj->*m_memberVector).begin(); + auto end = (obj->*m_memberVector).end(); std::size_t k = 0; - for (typename U::const_iterator j = begin; j != end; j++, k++) + for (auto j = begin; j != end; j++, k++) { if (k == i) { diff --git a/src/core/model/object.cc b/src/core/model/object.cc index 4baaa5494..92b485d00 100644 --- a/src/core/model/object.cc +++ b/src/core/model/object.cc @@ -269,8 +269,7 @@ Object::AggregateObject(Ptr o) Object* other = PeekPointer(o); // first create the new aggregate buffer. uint32_t total = m_aggregates->n + other->m_aggregates->n; - Aggregates* aggregates = - (Aggregates*)std::malloc(sizeof(Aggregates) + (total - 1) * sizeof(Object*)); + auto aggregates = (Aggregates*)std::malloc(sizeof(Aggregates) + (total - 1) * sizeof(Object*)); aggregates->n = total; // copy our buffer to the new buffer diff --git a/src/core/model/pair.h b/src/core/model/pair.h index 60d2c6694..460706a58 100644 --- a/src/core/model/pair.h +++ b/src/core/model/pair.h @@ -20,8 +20,8 @@ #ifndef PAIR_H #define PAIR_H -#include -#include +#include "attribute-helper.h" +#include "string.h" #include #include diff --git a/src/core/model/pointer.h b/src/core/model/pointer.h index e14cbe461..228226def 100644 --- a/src/core/model/pointer.h +++ b/src/core/model/pointer.h @@ -129,7 +129,7 @@ class PointerChecker : public ns3::PointerChecker { bool Check(const AttributeValue& val) const override { - const PointerValue* value = dynamic_cast(&val); + const auto value = dynamic_cast(&val); if (value == nullptr) { return false; @@ -166,8 +166,8 @@ class PointerChecker : public ns3::PointerChecker bool Copy(const AttributeValue& source, AttributeValue& destination) const override { - const PointerValue* src = dynamic_cast(&source); - PointerValue* dst = dynamic_cast(&destination); + const auto src = dynamic_cast(&source); + auto dst = dynamic_cast(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/priority-queue-scheduler.h b/src/core/model/priority-queue-scheduler.h index 52f8e8aae..af7e1daf1 100644 --- a/src/core/model/priority-queue-scheduler.h +++ b/src/core/model/priority-queue-scheduler.h @@ -90,7 +90,7 @@ class PriorityQueueScheduler : public Scheduler */ class EventPriorityQueue : public std::priority_queue, - std::greater> + std::greater<>> { public: /** diff --git a/src/core/model/ptr.h b/src/core/model/ptr.h index 9e994b020..0ac19f0a5 100644 --- a/src/core/model/ptr.h +++ b/src/core/model/ptr.h @@ -332,9 +332,7 @@ bool operator==(const Ptr& lhs, const Ptr& rhs); * \copydoc operator==(Ptrconst&,Ptrconst&) */ template -typename std::enable_if::value, bool>::type operator==( - const Ptr& lhs, - T2 rhs); +std::enable_if_t, bool> operator==(const Ptr& lhs, T2 rhs); /** * \ingroup ptr @@ -373,9 +371,7 @@ bool operator!=(const Ptr& lhs, const Ptr& rhs); * \copydoc operator==(Ptrconst&,Ptrconst&) */ template -typename std::enable_if::value, bool>::type operator!=( - const Ptr& lhs, - T2 rhs); +std::enable_if_t, bool> operator!=(const Ptr& lhs, T2 rhs); /** * \ingroup ptr @@ -549,14 +545,14 @@ operator!=(const Ptr& lhs, const Ptr& rhs) } template -typename std::enable_if::value, bool>::type +std::enable_if_t, bool> operator==(const Ptr& lhs, T2 rhs) { return PeekPointer(lhs) == nullptr; } template -typename std::enable_if::value, bool>::type +std::enable_if_t, bool> operator!=(const Ptr& lhs, T2 rhs) { return PeekPointer(lhs) != nullptr; diff --git a/src/core/model/random-variable-stream.cc b/src/core/model/random-variable-stream.cc index cddb88b71..229b96829 100644 --- a/src/core/model/random-variable-stream.cc +++ b/src/core/model/random-variable-stream.cc @@ -421,7 +421,7 @@ double ExponentialRandomVariable::GetValue(double mean, double bound) { NS_LOG_FUNCTION(this << mean << bound); - while (1) + while (true) { // Get a uniform random variable in [0,1]. double v = Peek()->RandU01(); @@ -520,7 +520,7 @@ ParetoRandomVariable::GetValue(double scale, double shape, double bound) // Calculate the scale parameter. NS_LOG_FUNCTION(this << scale << shape << bound); - while (1) + while (true) { // Get a uniform random variable in [0,1]. double v = Peek()->RandU01(); @@ -617,7 +617,7 @@ WeibullRandomVariable::GetValue(double scale, double shape, double bound) { NS_LOG_FUNCTION(this << scale << shape << bound); double exponent = 1.0 / shape; - while (1) + while (true) { // Get a uniform random variable in [0,1]. double v = Peek()->RandU01(); @@ -724,7 +724,7 @@ NormalRandomVariable::GetValue(double mean, double variance, double bound) return x2; } } - while (1) + while (true) { // See Simulation Modeling and Analysis p. 466 (Averill Law) // for algorithm; basically a Box-Muller transform: // http://en.wikipedia.org/wiki/Box-Muller_transform @@ -992,7 +992,7 @@ GammaRandomVariable::GetValue(double alpha, double beta) double d = alpha - 1.0 / 3.0; double c = (1.0 / 3.0) / std::sqrt(d); - while (1) + while (true) { do { @@ -1045,7 +1045,7 @@ GammaRandomVariable::GetNormalValue(double mean, double variance, double bound) return x2; } } - while (1) + while (true) { // See Simulation Modeling and Analysis p. 466 (Averill Law) // for algorithm; basically a Box-Muller transform: // http://en.wikipedia.org/wiki/Box-Muller_transform @@ -1173,7 +1173,7 @@ double ErlangRandomVariable::GetExponentialValue(double mean, double bound) { NS_LOG_FUNCTION(this << mean << bound); - while (1) + while (true) { // Get a uniform random variable in [0,1]. double v = Peek()->RandU01(); @@ -1534,28 +1534,6 @@ DeterministicRandomVariable::GetValue() NS_OBJECT_ENSURE_REGISTERED(EmpiricalRandomVariable); -// ValueCDF methods -EmpiricalRandomVariable::ValueCDF::ValueCDF() - : value(0.0), - cdf(0.0) -{ - NS_LOG_FUNCTION(this); -} - -EmpiricalRandomVariable::ValueCDF::ValueCDF(double v, double c) - : value(v), - cdf(c) -{ - NS_LOG_FUNCTION(this << v << c); - NS_ASSERT(c >= 0.0 && c <= 1.0); -} - -bool -operator<(EmpiricalRandomVariable::ValueCDF a, EmpiricalRandomVariable::ValueCDF b) -{ - return a.cdf < b.cdf; -} - TypeId EmpiricalRandomVariable::GetTypeId() { @@ -1608,14 +1586,14 @@ EmpiricalRandomVariable::PreSample(double& value) value = r; bool valid = false; // check extrema - if (r <= m_emp.front().cdf) + if (r <= m_empCdf.begin()->first) { - value = m_emp.front().value; // Less than first + value = m_empCdf.begin()->second; // Less than first valid = true; } - else if (r >= m_emp.back().cdf) + else if (r >= m_empCdf.rbegin()->first) { - value = m_emp.back().value; // Greater than last + value = m_empCdf.rbegin()->second; // Greater than last valid = true; } return valid; @@ -1649,10 +1627,10 @@ EmpiricalRandomVariable::DoSampleCDF(double r) { NS_LOG_FUNCTION(this << r); - ValueCDF selector(0, r); - auto bound = std::upper_bound(m_emp.begin(), m_emp.end(), selector); + // Find first CDF that is greater than r + auto bound = m_empCdf.upper_bound(r); - return bound->value; + return bound->second; } double @@ -1680,19 +1658,19 @@ EmpiricalRandomVariable::DoInterpolate(double r) // This code based (loosely) on code by Bruce Mah (Thanks Bruce!) // search - ValueCDF selector(0, r); - auto upper = std::upper_bound(m_emp.begin(), m_emp.end(), selector); + auto upper = m_empCdf.upper_bound(r); auto lower = std::prev(upper, 1); - if (upper == m_emp.begin()) + + if (upper == m_empCdf.begin()) { lower = upper; } // Interpolate random value in range [v1..v2) based on [c1 .. r .. c2) - double c1 = lower->cdf; - double c2 = upper->cdf; - double v1 = lower->value; - double v2 = upper->value; + double c1 = lower->first; + double c2 = upper->first; + double v1 = lower->second; + double v2 = upper->second; double value = (v1 + ((v2 - v1) / (c2 - c1)) * (r - c1)); return value; @@ -1701,36 +1679,62 @@ EmpiricalRandomVariable::DoInterpolate(double r) void EmpiricalRandomVariable::CDF(double v, double c) { - // Add a new empirical datapoint to the empirical cdf - // NOTE. These MUST be inserted in non-decreasing order NS_LOG_FUNCTION(this << v << c); - m_emp.emplace_back(v, c); + + auto vPrevious = m_empCdf.find(c); + + if (vPrevious != m_empCdf.end()) + { + NS_LOG_WARN("Empirical CDF already has a value " << vPrevious->second << " for CDF " << c + << ". Overwriting it with value " << v + << "."); + } + + m_empCdf[c] = v; } void EmpiricalRandomVariable::Validate() { NS_LOG_FUNCTION(this); - if (m_emp.empty()) + + if (m_empCdf.empty()) { NS_FATAL_ERROR("CDF is not initialized"); } - ValueCDF prior = m_emp[0]; - for (auto current : m_emp) + + double vPrev = m_empCdf.begin()->second; + + // Check if values are non-decreasing + for (const auto& cdfPair : m_empCdf) { - if (current.value < prior.value || current.cdf < prior.cdf) - { // Error - std::cerr << "Empirical Dist error," - << " current value " << current.value << " prior value " << prior.value - << " current cdf " << current.cdf << " prior cdf " << prior.cdf << std::endl; - NS_FATAL_ERROR("Empirical Dist error"); + const auto& vCurr = cdfPair.second; + + if (vCurr < vPrev) + { + NS_FATAL_ERROR("Empirical distribution has decreasing CDF values. Current CDF: " + << vCurr << ", prior CDF: " << vPrev); } - prior = current; + + vPrev = vCurr; } - if (prior.cdf != 1.0) + + // Bounds check on CDF endpoints + auto firstCdfPair = m_empCdf.begin(); + auto lastCdfPair = m_empCdf.rbegin(); + + if (firstCdfPair->first < 0.0) { - NS_FATAL_ERROR("CDF does not cover the whole distribution"); + NS_FATAL_ERROR("Empirical distribution has invalid first CDF value. CDF: " + << firstCdfPair->first << ", Value: " << firstCdfPair->second); } + + if (lastCdfPair->first > 1.0) + { + NS_FATAL_ERROR("Empirical distribution has invalid last CDF value. CDF: " + << lastCdfPair->first << ", Value: " << lastCdfPair->second); + } + m_validated = true; } diff --git a/src/core/model/random-variable-stream.h b/src/core/model/random-variable-stream.h index 96fcd8601..e7b398995 100644 --- a/src/core/model/random-variable-stream.h +++ b/src/core/model/random-variable-stream.h @@ -29,6 +29,7 @@ #include "object.h" #include "type-id.h" +#include #include /** @@ -1983,7 +1984,6 @@ class EmpiricalRandomVariable : public RandomVariableStream /** * \brief Specifies a point in the empirical distribution - * \note These *MUST* be inserted in ascending order of \p c * * \param [in] v The function value for this point * \param [in] c Probability that the function is less than or equal to \p v @@ -2018,26 +2018,6 @@ class EmpiricalRandomVariable : public RandomVariableStream bool SetInterpolate(bool interpolate); private: - /** \brief Helper to hold one point of the CDF. */ - class ValueCDF - { - public: - /** \brief Constructor. */ - ValueCDF(); - /** - * \brief Construct from values. - * - * \param [in] v The argument value. - * \param [in] c The CDF at the argument value \pname{v} - */ - ValueCDF(double v, double c); - - /** The argument value. */ - double value; - /** The CDF at \pname{value} */ - double cdf; - }; // class ValueCDF - /** * \brief Check that the CDF is valid. * @@ -2078,18 +2058,14 @@ class EmpiricalRandomVariable : public RandomVariableStream */ double DoInterpolate(double r); - /** - * \brief Comparison operator, for use by std::upper_bound - * \param a [in] the first value - * \param b [in] the second value - * \returns \c true if \c a.cdf < \c b.cdf - */ - friend bool operator<(ValueCDF a, ValueCDF b); - /** \c true once the CDF has been validated. */ bool m_validated; - /** The vector of CDF points. */ - std::vector m_emp; + /** + * The map of CDF points (x, F(x)). + * The CDF points are stored in the std::map in reverse order, as follows: + * Key: CDF F(x) [0, 1] | Value: domain value (x) [-inf, inf]. + */ + std::map m_empCdf; /** * If \c true GetValue will interpolate, * otherwise treat CDF as normal histogram. diff --git a/src/core/model/realtime-simulator-impl.cc b/src/core/model/realtime-simulator-impl.cc index 23974dcf8..9c4152dc6 100644 --- a/src/core/model/realtime-simulator-impl.cc +++ b/src/core/model/realtime-simulator-impl.cc @@ -704,7 +704,7 @@ RealtimeSimulatorImpl::Remove(const EventId& id) if (id.GetUid() == EventId::UID::DESTROY) { // destroy events. - for (DestroyEvents::iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { @@ -754,8 +754,7 @@ RealtimeSimulatorImpl::IsExpired(const EventId& id) const return true; } // destroy events. - for (DestroyEvents::const_iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); - i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { diff --git a/src/core/model/simulator.h b/src/core/model/simulator.h index 116f5c377..0a795a3c4 100644 --- a/src/core/model/simulator.h +++ b/src/core/model/simulator.h @@ -228,12 +228,10 @@ class Simulator * @param [in] args Arguments to pass to MakeEvent. * @returns The id for the scheduled event. */ - template < - typename FUNC, - typename std::enable_if>::value, int>::type = 0, - typename std::enable_if::type>::value, - int>::type = 0, - typename... Ts> + template >, int> = 0, + std::enable_if_t>, int> = 0, + typename... Ts> static EventId Schedule(const Time& delay, FUNC f, Ts&&... args); /** @@ -276,12 +274,10 @@ class Simulator * @param [in] f The function to invoke. * @param [in] args Arguments to pass to MakeEvent. */ - template < - typename FUNC, - typename std::enable_if>::value, int>::type = 0, - typename std::enable_if::type>::value, - int>::type = 0, - typename... Ts> + template >, int> = 0, + std::enable_if_t>, int> = 0, + typename... Ts> static void ScheduleWithContext(uint32_t context, const Time& delay, FUNC f, Ts&&... args); /** @@ -321,12 +317,10 @@ class Simulator * @param [in] args Arguments to pass to the invoked function. * @return The EventId of the scheduled event. */ - template < - typename FUNC, - typename std::enable_if>::value, int>::type = 0, - typename std::enable_if::type>::value, - int>::type = 0, - typename... Ts> + template >, int> = 0, + std::enable_if_t>, int> = 0, + typename... Ts> static EventId ScheduleNow(FUNC f, Ts&&... args); /** @@ -365,12 +359,10 @@ class Simulator * @param [in] args Arguments to pass to MakeEvent. * @return The EventId of the scheduled event. */ - template < - typename FUNC, - typename std::enable_if>::value, int>::type = 0, - typename std::enable_if::type>::value, - int>::type = 0, - typename... Ts> + template >, int> = 0, + std::enable_if_t>, int> = 0, + typename... Ts> static EventId ScheduleDestroy(FUNC f, Ts&&... args); /** @@ -558,12 +550,10 @@ namespace ns3 // it treats the in-class declaration as different from the // out of class definition, so makes two entries in the member list. Ugh -template < - typename FUNC, - typename std::enable_if>::value, int>::type, - typename std::enable_if::type>::value, - int>::type, - typename... Ts> +template >, int>, + std::enable_if_t>, int>, + typename... Ts> EventId Simulator::Schedule(const Time& delay, FUNC f, Ts&&... args) { @@ -577,12 +567,10 @@ Simulator::Schedule(const Time& delay, void (*f)(Us...), Ts&&... args) return DoSchedule(delay, MakeEvent(f, std::forward(args)...)); } -template < - typename FUNC, - typename std::enable_if>::value, int>::type, - typename std::enable_if::type>::value, - int>::type, - typename... Ts> +template >, int>, + std::enable_if_t>, int>, + typename... Ts> void Simulator::ScheduleWithContext(uint32_t context, const Time& delay, FUNC f, Ts&&... args) { @@ -596,12 +584,10 @@ Simulator::ScheduleWithContext(uint32_t context, const Time& delay, void (*f)(Us return ScheduleWithContext(context, delay, MakeEvent(f, std::forward(args)...)); } -template < - typename FUNC, - typename std::enable_if>::value, int>::type, - typename std::enable_if::type>::value, - int>::type, - typename... Ts> +template >, int>, + std::enable_if_t>, int>, + typename... Ts> EventId Simulator::ScheduleNow(FUNC f, Ts&&... args) { @@ -615,12 +601,10 @@ Simulator::ScheduleNow(void (*f)(Us...), Ts&&... args) return DoScheduleNow(MakeEvent(f, std::forward(args)...)); } -template < - typename FUNC, - typename std::enable_if>::value, int>::type, - typename std::enable_if::type>::value, - int>::type, - typename... Ts> +template >, int>, + std::enable_if_t>, int>, + typename... Ts> EventId Simulator::ScheduleDestroy(FUNC f, Ts&&... args) { diff --git a/src/core/model/system-path.cc b/src/core/model/system-path.cc index 9265ee501..6ab4927e9 100644 --- a/src/core/model/system-path.cc +++ b/src/core/model/system-path.cc @@ -141,7 +141,7 @@ Dirname(std::string path) { NS_LOG_FUNCTION(path); std::list elements = Split(path); - std::list::const_iterator last = elements.end(); + auto last = elements.end(); last--; return Join(elements.begin(), last); } @@ -268,7 +268,7 @@ Join(std::list::const_iterator begin, std::list::const { NS_LOG_FUNCTION(*begin << *end); std::string retval = ""; - for (std::list::const_iterator i = begin; i != end; i++) + for (auto i = begin; i != end; i++) { if ((*i).empty()) { diff --git a/src/core/model/test.cc b/src/core/model/test.cc index 85d7c5530..1b319c9d4 100644 --- a/src/core/model/test.cc +++ b/src/core/model/test.cc @@ -290,7 +290,7 @@ TestCase::~TestCase() NS_ASSERT(m_runner == nullptr); m_parent = nullptr; delete m_result; - for (std::vector::const_iterator i = m_children.begin(); i != m_children.end(); ++i) + for (auto i = m_children.begin(); i != m_children.end(); ++i) { delete *i; } @@ -353,7 +353,7 @@ TestCase::Run(TestRunnerImpl* runner) m_runner = runner; DoSetup(); m_result->clock.Start(); - for (std::vector::const_iterator i = m_children.begin(); i != m_children.end(); ++i) + for (auto i = m_children.begin(); i != m_children.end(); ++i) { TestCase* test = *i; test->Run(runner); @@ -571,7 +571,7 @@ TestRunnerImpl::IsTopLevelSourceDir(std::string path) const // std::list files = SystemPath::ReadFiles(path); - for (std::list::const_iterator i = files.begin(); i != files.end(); ++i) + for (auto i = files.begin(); i != files.end(); ++i) { if (*i == "VERSION") { @@ -629,7 +629,7 @@ TestRunnerImpl::ReplaceXmlSpecialCharacters(std::string xml) const { char character = xml[i]; - specials_map::const_iterator it = specials.find(character); + auto it = specials.find(character); if (it == specials.end()) { @@ -802,9 +802,9 @@ TestRunnerImpl::PrintTestNameList(std::list::const_iterator begin, label[TestSuite::EXAMPLE] = "example "; label[TestSuite::PERFORMANCE] = "performance "; - for (std::list::const_iterator i = begin; i != end; ++i) + for (auto i = begin; i != end; ++i) { - TestSuite* test = dynamic_cast(*i); + auto test = dynamic_cast(*i); NS_ASSERT(test != nullptr); if (printTestType) { @@ -852,8 +852,7 @@ TestRunnerImpl::FilterTests(std::string testName, } // Remove any test cases that should be skipped. - std::vector::iterator j; - for (j = test->m_children.begin(); j != test->m_children.end();) + for (auto j = test->m_children.begin(); j != test->m_children.end();) { TestCase* testCase = *j; @@ -1090,7 +1089,7 @@ TestRunnerImpl::Run(int argc, char* argv[]) return 1; } - for (std::list::const_iterator i = tests.begin(); i != tests.end(); ++i) + for (auto i = tests.begin(); i != tests.end(); ++i) { TestCase* test = *i; diff --git a/src/core/model/time.cc b/src/core/model/time.cc index f89a95621..69c1078f6 100644 --- a/src/core/model/time.cc +++ b/src/core/model/time.cc @@ -255,7 +255,7 @@ Time::SetResolution(Unit unit, Resolution* resolution, const bool convert /* = t info->isValid = false; continue; } - int64_t factor = static_cast(std::pow(10, std::fabs(shift)) * quotient); + auto factor = static_cast(std::pow(10, std::fabs(shift)) * quotient); double realFactor = std::pow(10, (double)shift) * static_cast(UNIT_COEFF[i]) / UNIT_COEFF[(int)unit]; NS_LOG_DEBUG("SetResolution factor " << factor << " real factor " << realFactor); @@ -333,9 +333,7 @@ Time::Mark(Time* const time) // since earlier test was outside and might be stale. if (g_markingTimes) { - std::pair ret; - - ret = g_markingTimes->insert(time); + auto ret = g_markingTimes->insert(time); NS_LOG_LOGIC("\t[" << g_markingTimes->size() << "] recording " << time); if (!ret.second) @@ -385,7 +383,7 @@ Time::ConvertTimes(const Unit unit) "No MarkedTimes registry. " "Time::SetResolution () called more than once?"); - for (MarkedTimes::iterator it = g_markingTimes->begin(); it != g_markingTimes->end(); it++) + for (auto it = g_markingTimes->begin(); it != g_markingTimes->end(); it++) { Time* const tp = *it; if (!(tp->m_data == std::numeric_limits::min() || @@ -434,7 +432,7 @@ operator<<(std::ostream& os, const TimeWithUnit& timeU) if (unit == Time::AUTO) { - long double value = static_cast(timeU.m_time.GetTimeStep()); + auto value = static_cast(timeU.m_time.GetTimeStep()); // convert to finest scale (fs) value *= Scale(Time::GetResolution()); // find the best unit @@ -547,7 +545,7 @@ MakeTimeChecker(const Time min, const Time max) bool Check(const AttributeValue& value) const override { NS_LOG_FUNCTION(&value); - const TimeValue* v = dynamic_cast(&value); + const auto v = dynamic_cast(&value); if (v == nullptr) { return false; @@ -585,8 +583,8 @@ MakeTimeChecker(const Time min, const Time max) bool Copy(const AttributeValue& source, AttributeValue& destination) const override { NS_LOG_FUNCTION(&source << &destination); - const TimeValue* src = dynamic_cast(&source); - TimeValue* dst = dynamic_cast(&destination); + const auto src = dynamic_cast(&source); + auto dst = dynamic_cast(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/timer-impl.h b/src/core/model/timer-impl.h index 0e0b3dabc..88996f227 100644 --- a/src/core/model/timer-impl.h +++ b/src/core/model/timer-impl.h @@ -1085,7 +1085,7 @@ void TimerImpl::SetArgs(T1 a1) { typedef TimerImplOne::ParameterType> TimerImplBase; - TimerImplBase* impl = dynamic_cast(this); + auto impl = dynamic_cast(this); if (impl == nullptr) { NS_FATAL_ERROR("You tried to set Timer arguments incompatible with its function."); @@ -1101,7 +1101,7 @@ TimerImpl::SetArgs(T1 a1, T2 a2) typedef TimerImplTwo::ParameterType, typename TimerTraits::ParameterType> TimerImplBase; - TimerImplBase* impl = dynamic_cast(this); + auto impl = dynamic_cast(this); if (impl == nullptr) { NS_FATAL_ERROR("You tried to set Timer arguments incompatible with its function."); @@ -1118,7 +1118,7 @@ TimerImpl::SetArgs(T1 a1, T2 a2, T3 a3) typename TimerTraits::ParameterType, typename TimerTraits::ParameterType> TimerImplBase; - TimerImplBase* impl = dynamic_cast(this); + auto impl = dynamic_cast(this); if (impl == nullptr) { NS_FATAL_ERROR("You tried to set Timer arguments incompatible with its function."); @@ -1136,7 +1136,7 @@ TimerImpl::SetArgs(T1 a1, T2 a2, T3 a3, T4 a4) typename TimerTraits::ParameterType, typename TimerTraits::ParameterType> TimerImplBase; - TimerImplBase* impl = dynamic_cast(this); + auto impl = dynamic_cast(this); if (impl == nullptr) { NS_FATAL_ERROR("You tried to set Timer arguments incompatible with its function."); @@ -1155,7 +1155,7 @@ TimerImpl::SetArgs(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) typename TimerTraits::ParameterType, typename TimerTraits::ParameterType> TimerImplBase; - TimerImplBase* impl = dynamic_cast(this); + auto impl = dynamic_cast(this); if (impl == nullptr) { NS_FATAL_ERROR("You tried to set Timer arguments incompatible with its function."); @@ -1175,7 +1175,7 @@ TimerImpl::SetArgs(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) typename TimerTraits::ParameterType, typename TimerTraits::ParameterType> TimerImplBase; - TimerImplBase* impl = dynamic_cast(this); + auto impl = dynamic_cast(this); if (impl == 0) { NS_FATAL_ERROR("You tried to set Timer arguments incompatible with its function."); diff --git a/src/core/model/traced-callback.h b/src/core/model/traced-callback.h index 76bf199c7..1cbc2874f 100644 --- a/src/core/model/traced-callback.h +++ b/src/core/model/traced-callback.h @@ -162,8 +162,7 @@ template void TracedCallback::DisconnectWithoutContext(const CallbackBase& callback) { - for (typename CallbackList::iterator i = m_callbackList.begin(); i != m_callbackList.end(); - /* empty */) + for (auto i = m_callbackList.begin(); i != m_callbackList.end(); /* empty */) { if ((*i).IsEqual(callback)) { @@ -193,9 +192,7 @@ template void TracedCallback::operator()(Ts... args) const { - for (typename CallbackList::const_iterator i = m_callbackList.begin(); - i != m_callbackList.end(); - i++) + for (auto i = m_callbackList.begin(); i != m_callbackList.end(); i++) { (*i)(args...); } diff --git a/src/core/model/tuple.h b/src/core/model/tuple.h index dc044287d..570c2726b 100644 --- a/src/core/model/tuple.h +++ b/src/core/model/tuple.h @@ -20,8 +20,8 @@ #ifndef TUPLE_H #define TUPLE_H -#include -#include +#include "attribute-helper.h" +#include "string.h" #include #include @@ -368,7 +368,7 @@ class TupleChecker : public ns3::TupleChecker bool Check(const AttributeValue& value) const override { - const TupleValue* v = dynamic_cast*>(&value); + const auto v = dynamic_cast*>(&value); if (v == nullptr) { return false; @@ -403,8 +403,8 @@ class TupleChecker : public ns3::TupleChecker bool Copy(const AttributeValue& source, AttributeValue& destination) const override { - const TupleValue* src = dynamic_cast*>(&source); - TupleValue* dst = dynamic_cast*>(&destination); + const auto src = dynamic_cast*>(&source); + auto dst = dynamic_cast*>(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/type-id.cc b/src/core/model/type-id.cc index d847da779..f1929df06 100644 --- a/src/core/model/type-id.cc +++ b/src/core/model/type-id.cc @@ -443,7 +443,7 @@ IidManager::AllocateUid(std::string name) m_information.push_back(information); std::size_t tuid = m_information.size(); NS_ASSERT(tuid <= 0xffff); - uint16_t uid = static_cast(tuid); + auto uid = static_cast(tuid); // Add to both maps: m_namemap.insert(std::make_pair(name, uid)); @@ -512,7 +512,7 @@ IidManager::GetUid(std::string name) const { NS_LOG_FUNCTION(IID << name); uint16_t uid = 0; - namemap_t::const_iterator it = m_namemap.find(name); + auto it = m_namemap.find(name); if (it != m_namemap.end()) { uid = it->second; @@ -525,7 +525,7 @@ uint16_t IidManager::GetUid(TypeId::hash_t hash) const { NS_LOG_FUNCTION(IID << hash); - hashmap_t::const_iterator it = m_hashmap.find(hash); + auto it = m_hashmap.find(hash); uint16_t uid = 0; if (it != m_hashmap.end()) { @@ -627,10 +627,7 @@ IidManager::HasAttribute(uint16_t uid, std::string name) IidInformation* information = LookupInformation(uid); while (true) { - for (std::vector::const_iterator i = - information->attributes.begin(); - i != information->attributes.end(); - ++i) + for (auto i = information->attributes.begin(); i != information->attributes.end(); ++i) { if (i->name == name) { @@ -729,10 +726,7 @@ IidManager::HasTraceSource(uint16_t uid, std::string name) IidInformation* information = LookupInformation(uid); while (true) { - for (std::vector::const_iterator i = - information->traceSources.begin(); - i != information->traceSources.end(); - ++i) + for (auto i = information->traceSources.begin(); i != information->traceSources.end(); ++i) { if (i->name == name) { diff --git a/src/core/model/uinteger.cc b/src/core/model/uinteger.cc index 77a40e029..a320bf3bf 100644 --- a/src/core/model/uinteger.cc +++ b/src/core/model/uinteger.cc @@ -65,7 +65,7 @@ MakeUintegerChecker(uint64_t min, uint64_t max, std::string name) bool Check(const AttributeValue& value) const override { NS_LOG_FUNCTION(&value); - const UintegerValue* v = dynamic_cast(&value); + const auto v = dynamic_cast(&value); if (v == nullptr) { return false; @@ -102,8 +102,8 @@ MakeUintegerChecker(uint64_t min, uint64_t max, std::string name) bool Copy(const AttributeValue& source, AttributeValue& destination) const override { NS_LOG_FUNCTION(&source << &destination); - const UintegerValue* src = dynamic_cast(&source); - UintegerValue* dst = dynamic_cast(&destination); + const auto src = dynamic_cast(&source); + auto dst = dynamic_cast(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/unused.h b/src/core/model/unused.h index 5faa4d514..9973f16aa 100644 --- a/src/core/model/unused.h +++ b/src/core/model/unused.h @@ -20,7 +20,7 @@ #ifndef UNUSED_H #define UNUSED_H -#include "ns3/deprecated.h" +#include "deprecated.h" /** * \file diff --git a/src/core/model/val-array.h b/src/core/model/val-array.h index 609400c7a..c96b24c6a 100644 --- a/src/core/model/val-array.h +++ b/src/core/model/val-array.h @@ -19,8 +19,8 @@ #ifndef VAL_ARRAY_H #define VAL_ARRAY_H -#include -#include +#include "assert.h" +#include "simple-ref-count.h" #include #include diff --git a/src/core/model/version.h b/src/core/model/version.h index a91c97226..1d8ea3269 100644 --- a/src/core/model/version.h +++ b/src/core/model/version.h @@ -20,7 +20,7 @@ #ifndef BUILD_VERSION_H_ #define BUILD_VERSION_H_ -#include "ns3/int64x64.h" +#include "int64x64.h" #include diff --git a/src/core/model/wall-clock-synchronizer.cc b/src/core/model/wall-clock-synchronizer.cc index ea8b87546..0f1d386f7 100644 --- a/src/core/model/wall-clock-synchronizer.cc +++ b/src/core/model/wall-clock-synchronizer.cc @@ -363,7 +363,7 @@ WallClockSynchronizer::DriftCorrect(uint64_t nsNow, uint64_t nsDelay) // have more drift than delay, then we just play catch up as fast as possible // by not delaying at all. // - uint64_t correction = (uint64_t)drift; + auto correction = (uint64_t)drift; if (correction <= nsDelay) { return nsDelay - correction; diff --git a/src/core/test/global-value-test-suite.cc b/src/core/test/global-value-test-suite.cc index d22fbb61c..aabacd289 100644 --- a/src/core/test/global-value-test-suite.cc +++ b/src/core/test/global-value-test-suite.cc @@ -84,7 +84,7 @@ GlobalValueTestCase::DoRun() // Remove the global value for a valgrind clean run // GlobalValue::Vector* vector = GlobalValue::GetVector(); - for (GlobalValue::Vector::iterator i = vector->begin(); i != vector->end(); ++i) + for (auto i = vector->begin(); i != vector->end(); ++i) { if ((*i) == &uint) { diff --git a/src/core/test/int64x64-test-suite.cc b/src/core/test/int64x64-test-suite.cc index b3374563e..cf9933bb8 100644 --- a/src/core/test/int64x64-test-suite.cc +++ b/src/core/test/int64x64-test-suite.cc @@ -620,7 +620,7 @@ Int64x64Bug455TestCase::DoRun() std::cout << std::endl; std::cout << GetParent()->GetName() << " Bug 455: " << GetName() << std::endl; - int64x64_t a = int64x64_t(0.1); + int64x64_t a(0.1); a /= int64x64_t(1.25); Check(a.GetDouble(), 0.08, "The original testcase"); @@ -684,7 +684,7 @@ Int64x64Bug863TestCase::DoRun() std::cout << std::endl; std::cout << GetParent()->GetName() << " Bug 863: " << GetName() << std::endl; - int64x64_t a = int64x64_t(0.9); + int64x64_t a(0.9); a /= int64x64_t(1); Check(a.GetDouble(), 0.9, "The original testcase"); @@ -1033,7 +1033,7 @@ Int64x64InvertTestCase::Check(const int64_t factor) const int64x64_t factorI = one / int64x64_t(factor); const int64x64_t a = int64x64_t::Invert(factor); - int64x64_t b = int64x64_t(factor); + int64x64_t b(factor); double tolerance = 0; if (int64x64_t::implementation == int64x64_t::ld_impl) @@ -1045,15 +1045,15 @@ Int64x64InvertTestCase::Check(const int64_t factor) b.MulByInvert(a); CheckCase(factor, b, one, "x * x^-1 == 1", tolerance); - int64x64_t c = int64x64_t(1); + int64x64_t c(1); c.MulByInvert(a); CheckCase(factor, c, factorI, "1 * x^-1 == 1 / x"); - int64x64_t d = int64x64_t(1); + int64x64_t d(1); d /= (int64x64_t(factor)); CheckCase(factor, d, c, "1/x == x^-1"); - int64x64_t e = int64x64_t(-factor); + int64x64_t e(-factor); e.MulByInvert(a); CheckCase(factor, e, -one, "-x * x^-1 == -1", tolerance); } diff --git a/src/core/test/ptr-test-suite.cc b/src/core/test/ptr-test-suite.cc index 2e9b05cd4..a977ee0e1 100644 --- a/src/core/test/ptr-test-suite.cc +++ b/src/core/test/ptr-test-suite.cc @@ -178,7 +178,7 @@ PtrTestCase::CallTestConst(const Ptr p) void PtrTestCase::DoRun() { - m_nDestroyed = false; + m_nDestroyed = 0; { Ptr p = Create(this); } diff --git a/src/csma-layout/model/csma-star-helper.cc b/src/csma-layout/model/csma-star-helper.cc index ad9462099..d05282c3b 100644 --- a/src/csma-layout/model/csma-star-helper.cc +++ b/src/csma-layout/model/csma-star-helper.cc @@ -13,16 +13,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include +#include "csma-star-helper.h" -// ns3 includes -#include "ns3/csma-star-helper.h" #include "ns3/log.h" #include "ns3/node-list.h" #include "ns3/point-to-point-net-device.h" #include "ns3/vector.h" +#include +#include + namespace ns3 { diff --git a/src/csma/examples/csma-ping.cc b/src/csma/examples/csma-ping.cc index 14389631a..ca663a0f8 100644 --- a/src/csma/examples/csma-ping.cc +++ b/src/csma/examples/csma-ping.cc @@ -100,7 +100,7 @@ main(int argc, char* argv[]) NS_LOG_INFO("Create Source"); Config::SetDefault("ns3::Ipv4RawSocketImpl::Protocol", StringValue("2")); - InetSocketAddress dst = InetSocketAddress(addresses.GetAddress(3)); + InetSocketAddress dst(addresses.GetAddress(3)); OnOffHelper onoff = OnOffHelper("ns3::Ipv4RawSocketFactory", dst); onoff.SetConstantRate(DataRate(15000)); onoff.SetAttribute("PacketSize", UintegerValue(1200)); diff --git a/src/csma/examples/csma-raw-ip-socket.cc b/src/csma/examples/csma-raw-ip-socket.cc index 698baa4a7..2be6a2ac0 100644 --- a/src/csma/examples/csma-raw-ip-socket.cc +++ b/src/csma/examples/csma-raw-ip-socket.cc @@ -93,7 +93,7 @@ main(int argc, char* argv[]) NS_LOG_INFO("Create Source"); // IP protocol configuration Config::SetDefault("ns3::Ipv4RawSocketImpl::Protocol", StringValue("2")); - InetSocketAddress dst = InetSocketAddress(addresses.GetAddress(3)); + InetSocketAddress dst(addresses.GetAddress(3)); OnOffHelper onoff = OnOffHelper("ns3::Ipv4RawSocketFactory", dst); onoff.SetConstantRate(DataRate(dataRate * 1000)); onoff.SetAttribute("PacketSize", UintegerValue(1250)); diff --git a/src/csma/helper/csma-helper.cc b/src/csma/helper/csma-helper.cc index 58549237e..2057b6b37 100644 --- a/src/csma/helper/csma-helper.cc +++ b/src/csma/helper/csma-helper.cc @@ -277,7 +277,7 @@ CsmaHelper::Install(const NodeContainer& c, Ptr channel) const { NetDeviceContainer devs; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { devs.Add(InstallPriv(*i, channel)); } @@ -297,7 +297,7 @@ CsmaHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr csma = DynamicCast(netDevice); diff --git a/src/csma/model/backoff.cc b/src/csma/model/backoff.cc index 656156076..ae40bb717 100644 --- a/src/csma/model/backoff.cc +++ b/src/csma/model/backoff.cc @@ -75,7 +75,7 @@ Backoff::GetBackoffTime() maxSlot = m_maxSlots; } - uint32_t backoffSlots = (uint32_t)m_rng->GetValue(minSlot, maxSlot); + auto backoffSlots = (uint32_t)m_rng->GetValue(minSlot, maxSlot); Time backoff = Time(backoffSlots * m_slotTime); return backoff; diff --git a/src/csma/model/csma-channel.cc b/src/csma/model/csma-channel.cc index 9c9f253a6..2a0defc8c 100644 --- a/src/csma/model/csma-channel.cc +++ b/src/csma/model/csma-channel.cc @@ -86,8 +86,7 @@ CsmaChannel::Reattach(Ptr device) NS_LOG_FUNCTION(this << device); NS_ASSERT(device); - std::vector::iterator it; - for (it = m_deviceList.begin(); it < m_deviceList.end(); it++) + for (auto it = m_deviceList.begin(); it < m_deviceList.end(); it++) { if (it->devicePtr == device) { @@ -161,8 +160,7 @@ CsmaChannel::Detach(Ptr device) NS_LOG_FUNCTION(this << device); NS_ASSERT(device); - std::vector::iterator it; - for (it = m_deviceList.begin(); it < m_deviceList.end(); it++) + for (auto it = m_deviceList.begin(); it < m_deviceList.end(); it++) { if ((it->devicePtr == device) && (it->active)) { @@ -227,8 +225,7 @@ CsmaChannel::TransmitEnd() NS_LOG_LOGIC("Receive"); - std::vector::iterator it; - for (it = m_deviceList.begin(); it < m_deviceList.end(); it++) + for (auto it = m_deviceList.begin(); it < m_deviceList.end(); it++) { if (it->IsActive() && it->devicePtr != m_deviceList[m_currentSrc].devicePtr) { @@ -261,8 +258,7 @@ uint32_t CsmaChannel::GetNumActDevices() { int numActDevices = 0; - std::vector::iterator it; - for (it = m_deviceList.begin(); it < m_deviceList.end(); it++) + for (auto it = m_deviceList.begin(); it < m_deviceList.end(); it++) { if (it->active) { @@ -287,9 +283,8 @@ CsmaChannel::GetCsmaDevice(std::size_t i) const int32_t CsmaChannel::GetDeviceNum(Ptr device) { - std::vector::iterator it; int i = 0; - for (it = m_deviceList.begin(); it < m_deviceList.end(); it++) + for (auto it = m_deviceList.begin(); it < m_deviceList.end(); it++) { if (it->devicePtr == device) { diff --git a/src/csma/model/csma-net-device.h b/src/csma/model/csma-net-device.h index 237daf37e..ff72aad2a 100644 --- a/src/csma/model/csma-net-device.h +++ b/src/csma/model/csma-net-device.h @@ -20,8 +20,9 @@ #ifndef CSMA_NET_DEVICE_H #define CSMA_NET_DEVICE_H +#include "backoff.h" + #include "ns3/address.h" -#include "ns3/backoff.h" #include "ns3/callback.h" #include "ns3/data-rate.h" #include "ns3/mac48-address.h" diff --git a/src/dsdv/model/dsdv-packet-queue.cc b/src/dsdv/model/dsdv-packet-queue.cc index 40c447a14..57ea72f54 100644 --- a/src/dsdv/model/dsdv-packet-queue.cc +++ b/src/dsdv/model/dsdv-packet-queue.cc @@ -56,7 +56,7 @@ PacketQueue::Enqueue(QueueEntry& entry) NS_LOG_FUNCTION("Enqueuing packet destined for" << entry.GetIpv4Header().GetDestination()); Purge(); uint32_t numPacketswithdst; - for (std::vector::const_iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if ((i->GetPacket()->GetUid() == entry.GetPacket()->GetUid()) && (i->GetIpv4Header().GetDestination() == entry.GetIpv4Header().GetDestination())) @@ -86,7 +86,7 @@ PacketQueue::DropPacketWithDst(Ipv4Address dst) { NS_LOG_FUNCTION("Dropping packet to " << dst); Purge(); - for (std::vector::iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -104,7 +104,7 @@ PacketQueue::Dequeue(Ipv4Address dst, QueueEntry& entry) { NS_LOG_FUNCTION("Dequeueing packet destined for" << dst); Purge(); - for (std::vector::iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -119,7 +119,7 @@ PacketQueue::Dequeue(Ipv4Address dst, QueueEntry& entry) bool PacketQueue::Find(Ipv4Address dst) { - for (std::vector::const_iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -134,7 +134,7 @@ uint32_t PacketQueue::GetCountForPacketsWithDst(Ipv4Address dst) { uint32_t count = 0; - for (std::vector::const_iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -166,7 +166,7 @@ PacketQueue::Purge() { // NS_LOG_DEBUG("Purging Queue"); IsExpired pred; - for (std::vector::iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (pred(*i)) { diff --git a/src/dsdv/model/dsdv-routing-protocol.cc b/src/dsdv/model/dsdv-routing-protocol.cc index 85080b221..c5681653b 100644 --- a/src/dsdv/model/dsdv-routing-protocol.cc +++ b/src/dsdv/model/dsdv-routing-protocol.cc @@ -241,9 +241,7 @@ void RoutingProtocol::DoDispose() { m_ipv4 = nullptr; - for (std::map, Ipv4InterfaceAddress>::iterator iter = m_socketAddresses.begin(); - iter != m_socketAddresses.end(); - iter++) + for (auto iter = m_socketAddresses.begin(); iter != m_socketAddresses.end(); iter++) { iter->first->Close(); } @@ -304,9 +302,7 @@ RoutingProtocol::RouteOutput(Ptr p, << ", Destination address in Packet: " << dst); RoutingTableEntry rt; m_routingTable.Purge(removedAddresses); - for (std::map::iterator rmItr = removedAddresses.begin(); - rmItr != removedAddresses.end(); - ++rmItr) + for (auto rmItr = removedAddresses.begin(); rmItr != removedAddresses.end(); ++rmItr) { rmItr->second.SetEntriesChanged(true); rmItr->second.SetSeqNo(rmItr->second.GetSeqNo() + 1); @@ -428,9 +424,7 @@ RoutingProtocol::RouteInput(Ptr p, return true; } } - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ipv4InterfaceAddress iface = j->second; if (origin == iface.GetLocal()) @@ -439,9 +433,7 @@ RoutingProtocol::RouteInput(Ptr p, } } // LOCAL DELIVARY TO DSDV INTERFACES - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ipv4InterfaceAddress iface = j->second; if (m_ipv4->GetInterfaceForAddress(iface.GetLocal()) == iif) @@ -545,7 +537,7 @@ RoutingProtocol::LoopbackRoute(const Ipv4Header& hdr, Ptr oif) const // If RouteOutput() caller specified an outgoing interface, that // further constrains the selection of source address // - std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); + auto j = m_socketAddresses.begin(); if (oif) { // Iterate to find an address on the oif device @@ -592,10 +584,7 @@ RoutingProtocol::RecvDsdv(Ptr socket) packet->RemoveHeader(dsdvHeader); NS_LOG_DEBUG("Processing new update for " << dsdvHeader.GetDst()); /*Verifying if the packets sent by me were returned back to me. If yes, discarding them!*/ - for (std::map, Ipv4InterfaceAddress>::const_iterator j = - m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ipv4InterfaceAddress interface = j->second; if (dsdvHeader.GetDst() == interface.GetLocal()) @@ -661,9 +650,7 @@ RoutingProtocol::RecvDsdv(Ptr socket) RoutingTableEntry tr; std::map allRoutes; m_advRoutingTable.GetListOfAllRoutes(allRoutes); - for (std::map::const_iterator i = allRoutes.begin(); - i != allRoutes.end(); - ++i) + for (auto i = allRoutes.begin(); i != allRoutes.end(); ++i) { NS_LOG_DEBUG("ADV table routes are:" << i->second.GetDestination()); } @@ -800,10 +787,7 @@ RoutingProtocol::RecvDsdv(Ptr socket) advTableEntry.SetSeqNo(dsdvHeader.GetDstSeqno()); advTableEntry.SetEntriesChanged(true); m_advRoutingTable.Update(advTableEntry); - for (std::map::iterator i = - dstsWithNextHopSrc.begin(); - i != dstsWithNextHopSrc.end(); - ++i) + for (auto i = dstsWithNextHopSrc.begin(); i != dstsWithNextHopSrc.end(); ++i) { i->second.SetSeqNo(i->second.GetSeqNo() + 1); i->second.SetEntriesChanged(true); @@ -844,17 +828,13 @@ RoutingProtocol::SendTriggeredUpdate() NS_LOG_FUNCTION(m_mainAddress << " is sending a triggered update"); std::map allRoutes; m_advRoutingTable.GetListOfAllRoutes(allRoutes); - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { DsdvHeader dsdvHeader; Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; Ptr packet = Create(); - for (std::map::const_iterator i = allRoutes.begin(); - i != allRoutes.end(); - ++i) + for (auto i = allRoutes.begin(); i != allRoutes.end(); ++i) { NS_LOG_LOGIC("Destination: " << i->second.GetDestination() << " SeqNo:" << i->second.GetSeqNo() @@ -930,16 +910,12 @@ RoutingProtocol::SendPeriodicUpdate() return; } NS_LOG_FUNCTION(m_mainAddress << " is sending out its periodic update"); - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; Ptr packet = Create(); - for (std::map::const_iterator i = allRoutes.begin(); - i != allRoutes.end(); - ++i) + for (auto i = allRoutes.begin(); i != allRoutes.end(); ++i) { DsdvHeader dsdvHeader; if (i->second.GetHop() == 0) @@ -966,10 +942,7 @@ RoutingProtocol::SendPeriodicUpdate() << ", HopCount:" << dsdvHeader.GetHopCount() << ", LifeTime: " << i->second.GetLifeTime().As(Time::S)); } - for (std::map::const_iterator rmItr = - removedAddresses.begin(); - rmItr != removedAddresses.end(); - ++rmItr) + for (auto rmItr = removedAddresses.begin(); rmItr != removedAddresses.end(); ++rmItr) { DsdvHeader removedHeader; removedHeader.SetDst(rmItr->second.GetDestination()); @@ -1143,9 +1116,7 @@ RoutingProtocol::NotifyRemoveAddress(uint32_t i, Ipv4InterfaceAddress address) Ptr RoutingProtocol::FindSocketWithInterfaceAddress(Ipv4InterfaceAddress addr) const { - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; @@ -1181,9 +1152,7 @@ RoutingProtocol::LookForQueuedPackets() Ptr route; std::map allRoutes; m_routingTable.GetListOfAllRoutes(allRoutes); - for (std::map::const_iterator i = allRoutes.begin(); - i != allRoutes.end(); - ++i) + for (auto i = allRoutes.begin(); i != allRoutes.end(); ++i) { RoutingTableEntry rt; rt = i->second; @@ -1192,20 +1161,20 @@ RoutingProtocol::LookForQueuedPackets() if (rt.GetHop() == 1) { route = rt.GetRoute(); + NS_ASSERT(route); NS_LOG_LOGIC("A route exists from " << route->GetSource() << " to neighboring destination " << route->GetDestination()); - NS_ASSERT(route); } else { RoutingTableEntry newrt; m_routingTable.LookupRoute(rt.GetNextHop(), newrt); route = newrt.GetRoute(); + NS_ASSERT(route); NS_LOG_LOGIC("A route exists from " << route->GetSource() << " to destination " << route->GetDestination() << " via " << rt.GetNextHop()); - NS_ASSERT(route); } SendPacketFromQueue(rt.GetDestination(), route); } @@ -1282,9 +1251,7 @@ RoutingProtocol::MergeTriggerPeriodicUpdates() m_advRoutingTable.GetListOfAllRoutes(allRoutes); if (!allRoutes.empty()) { - for (std::map::const_iterator i = allRoutes.begin(); - i != allRoutes.end(); - ++i) + for (auto i = allRoutes.begin(); i != allRoutes.end(); ++i) { RoutingTableEntry advEntry = i->second; if (advEntry.GetEntriesChanged() && diff --git a/src/dsdv/model/dsdv-rtable.cc b/src/dsdv/model/dsdv-rtable.cc index 18dc1af0b..7f1f392a7 100644 --- a/src/dsdv/model/dsdv-rtable.cc +++ b/src/dsdv/model/dsdv-rtable.cc @@ -80,7 +80,7 @@ RoutingTable::LookupRoute(Ipv4Address id, RoutingTableEntry& rt) { return false; } - std::map::const_iterator i = m_ipv4AddressEntry.find(id); + auto i = m_ipv4AddressEntry.find(id); if (i == m_ipv4AddressEntry.end()) { return false; @@ -96,7 +96,7 @@ RoutingTable::LookupRoute(Ipv4Address id, RoutingTableEntry& rt, bool forRouteIn { return false; } - std::map::const_iterator i = m_ipv4AddressEntry.find(id); + auto i = m_ipv4AddressEntry.find(id); if (i == m_ipv4AddressEntry.end()) { return false; @@ -124,16 +124,14 @@ RoutingTable::RoutingTableSize() bool RoutingTable::AddRoute(RoutingTableEntry& rt) { - std::pair::iterator, bool> result = - m_ipv4AddressEntry.insert(std::make_pair(rt.GetDestination(), rt)); + auto result = m_ipv4AddressEntry.insert(std::make_pair(rt.GetDestination(), rt)); return result.second; } bool RoutingTable::Update(RoutingTableEntry& rt) { - std::map::iterator i = - m_ipv4AddressEntry.find(rt.GetDestination()); + auto i = m_ipv4AddressEntry.find(rt.GetDestination()); if (i == m_ipv4AddressEntry.end()) { return false; @@ -149,12 +147,11 @@ RoutingTable::DeleteAllRoutesFromInterface(Ipv4InterfaceAddress iface) { return; } - for (std::map::iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end();) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end();) { if (i->second.GetInterface() == iface) { - std::map::iterator tmp = i; + auto tmp = i; ++i; m_ipv4AddressEntry.erase(tmp); } @@ -168,9 +165,7 @@ RoutingTable::DeleteAllRoutesFromInterface(Ipv4InterfaceAddress iface) void RoutingTable::GetListOfAllRoutes(std::map& allRoutes) { - for (std::map::iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end(); - ++i) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i) { if (i->second.GetDestination() != Ipv4Address("127.0.0.1") && i->second.GetFlag() == VALID) { @@ -184,9 +179,7 @@ RoutingTable::GetListOfDestinationWithNextHop(Ipv4Address nextHop, std::map& unreachable) { unreachable.clear(); - for (std::map::const_iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end(); - ++i) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i) { if (i->second.GetNextHop() == nextHop) { @@ -234,19 +227,17 @@ RoutingTable::Purge(std::map& removedAddresses) { return; } - for (std::map::iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end();) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end();) { - std::map::iterator itmp = i; + auto itmp = i; if (i->second.GetLifeTime() > m_holddownTime && (i->second.GetHop() > 0)) { - for (std::map::iterator j = m_ipv4AddressEntry.begin(); - j != m_ipv4AddressEntry.end();) + for (auto j = m_ipv4AddressEntry.begin(); j != m_ipv4AddressEntry.end();) { if ((j->second.GetNextHop() == i->second.GetDestination()) && (i->second.GetHop() != j->second.GetHop())) { - std::map::iterator jtmp = j; + auto jtmp = j; removedAddresses.insert(std::make_pair(j->first, j->second)); ++j; m_ipv4AddressEntry.erase(jtmp); @@ -291,9 +282,7 @@ RoutingTable::Print(Ptr stream, Time::Unit unit /*= Time::S *os << std::setw(16) << "SeqNum"; *os << std::setw(16) << "LifeTime"; *os << "SettlingTime" << std::endl; - for (std::map::const_iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end(); - ++i) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i) { i->second.Print(stream, unit); } @@ -305,8 +294,7 @@ RoutingTable::Print(Ptr stream, Time::Unit unit /*= Time::S bool RoutingTable::AddIpv4Event(Ipv4Address address, EventId id) { - std::pair::iterator, bool> result = - m_ipv4Events.insert(std::make_pair(address, id)); + auto result = m_ipv4Events.insert(std::make_pair(address, id)); return result.second; } @@ -314,7 +302,7 @@ bool RoutingTable::AnyRunningEvent(Ipv4Address address) { EventId event; - std::map::const_iterator i = m_ipv4Events.find(address); + auto i = m_ipv4Events.find(address); if (m_ipv4Events.empty()) { return false; @@ -331,7 +319,7 @@ bool RoutingTable::ForceDeleteIpv4Event(Ipv4Address address) { EventId event; - std::map::const_iterator i = m_ipv4Events.find(address); + auto i = m_ipv4Events.find(address); if (m_ipv4Events.empty() || i == m_ipv4Events.end()) { return false; @@ -346,7 +334,7 @@ bool RoutingTable::DeleteIpv4Event(Ipv4Address address) { EventId event; - std::map::const_iterator i = m_ipv4Events.find(address); + auto i = m_ipv4Events.find(address); if (m_ipv4Events.empty() || i == m_ipv4Events.end()) { return false; @@ -372,7 +360,7 @@ RoutingTable::DeleteIpv4Event(Ipv4Address address) EventId RoutingTable::GetEventId(Ipv4Address address) { - std::map::const_iterator i = m_ipv4Events.find(address); + auto i = m_ipv4Events.find(address); if (m_ipv4Events.empty() || i == m_ipv4Events.end()) { return EventId(); diff --git a/src/dsdv/model/dsdv-rtable.h b/src/dsdv/model/dsdv-rtable.h index 4046e2502..6ee6c63a1 100644 --- a/src/dsdv/model/dsdv-rtable.h +++ b/src/dsdv/model/dsdv-rtable.h @@ -317,7 +317,7 @@ class RoutingTableEntry /// A node does that in hope of receiving a better update. Time m_settlingTime; /// Flag to show if any of the routing table entries were changed with the routing update. - uint32_t m_entriesChanged; + bool m_entriesChanged; }; /** diff --git a/src/dsr/helper/dsr-main-helper.cc b/src/dsr/helper/dsr-main-helper.cc index a55be2976..abca309e1 100644 --- a/src/dsr/helper/dsr-main-helper.cc +++ b/src/dsr/helper/dsr-main-helper.cc @@ -30,7 +30,8 @@ #include "dsr-main-helper.h" -#include "ns3/dsr-helper.h" +#include "dsr-helper.h" + #include "ns3/dsr-rcache.h" #include "ns3/dsr-routing.h" #include "ns3/dsr-rreq-table.h" @@ -80,7 +81,7 @@ DsrMainHelper::Install(DsrHelper& dsrHelper, NodeContainer nodes) NS_LOG_DEBUG("Passed node container"); delete m_dsrHelper; m_dsrHelper = dsrHelper.Copy(); - for (NodeContainer::Iterator i = nodes.Begin(); i != nodes.End(); ++i) + for (auto i = nodes.Begin(); i != nodes.End(); ++i) { Install(*i); } diff --git a/src/dsr/helper/dsr-main-helper.h b/src/dsr/helper/dsr-main-helper.h index 465810243..12afe59db 100644 --- a/src/dsr/helper/dsr-main-helper.h +++ b/src/dsr/helper/dsr-main-helper.h @@ -31,7 +31,8 @@ #ifndef DSR_MAIN_HELPER_H #define DSR_MAIN_HELPER_H -#include "ns3/dsr-helper.h" +#include "dsr-helper.h" + #include "ns3/dsr-routing.h" #include "ns3/node-container.h" #include "ns3/node.h" diff --git a/src/dsr/model/dsr-errorbuff.cc b/src/dsr/model/dsr-errorbuff.cc index f52426f77..d5c3440bd 100644 --- a/src/dsr/model/dsr-errorbuff.cc +++ b/src/dsr/model/dsr-errorbuff.cc @@ -56,9 +56,7 @@ bool DsrErrorBuffer::Enqueue(DsrErrorBuffEntry& entry) { Purge(); - for (std::vector::const_iterator i = m_errorBuffer.begin(); - i != m_errorBuffer.end(); - ++i) + for (auto i = m_errorBuffer.begin(); i != m_errorBuffer.end(); ++i) { NS_LOG_INFO("packet id " << i->GetPacket()->GetUid() << " " << entry.GetPacket()->GetUid() << " source " << i->GetSource() << " " << entry.GetSource() @@ -101,9 +99,7 @@ DsrErrorBuffer::DropPacketForErrLink(Ipv4Address source, Ipv4Address nextHop) /* * Drop the packet with the error link source----------nextHop */ - for (std::vector::iterator i = m_errorBuffer.begin(); - i != m_errorBuffer.end(); - ++i) + for (auto i = m_errorBuffer.begin(); i != m_errorBuffer.end(); ++i) { if ((i->GetSource() == link[0]) && (i->GetNextHop() == link[1])) { @@ -127,9 +123,7 @@ DsrErrorBuffer::Dequeue(Ipv4Address dst, DsrErrorBuffEntry& entry) /* * Dequeue the entry with destination address dst */ - for (std::vector::iterator i = m_errorBuffer.begin(); - i != m_errorBuffer.end(); - ++i) + for (auto i = m_errorBuffer.begin(); i != m_errorBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -148,9 +142,7 @@ DsrErrorBuffer::Find(Ipv4Address dst) /* * Make sure if the send buffer contains entry with certain dst */ - for (std::vector::const_iterator i = m_errorBuffer.begin(); - i != m_errorBuffer.end(); - ++i) + for (auto i = m_errorBuffer.begin(); i != m_errorBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -184,9 +176,7 @@ DsrErrorBuffer::Purge() */ NS_LOG_DEBUG("The error buffer size " << m_errorBuffer.size()); IsExpired pred; - for (std::vector::iterator i = m_errorBuffer.begin(); - i != m_errorBuffer.end(); - ++i) + for (auto i = m_errorBuffer.begin(); i != m_errorBuffer.end(); ++i) { if (pred(*i)) { diff --git a/src/dsr/model/dsr-gratuitous-reply-table.cc b/src/dsr/model/dsr-gratuitous-reply-table.cc index 3b92751fd..a8ac5f504 100644 --- a/src/dsr/model/dsr-gratuitous-reply-table.cc +++ b/src/dsr/model/dsr-gratuitous-reply-table.cc @@ -67,7 +67,7 @@ bool DsrGraReply::FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff) { Purge(); // purge the gratuitous reply table - for (std::vector::iterator i = m_graReply.begin(); i != m_graReply.end(); ++i) + for (auto i = m_graReply.begin(); i != m_graReply.end(); ++i) { if ((i->m_replyTo == replyTo) && (i->m_hearFrom == replyFrom)) { diff --git a/src/dsr/model/dsr-maintain-buff.cc b/src/dsr/model/dsr-maintain-buff.cc index e32ddfa0c..f420c80d4 100644 --- a/src/dsr/model/dsr-maintain-buff.cc +++ b/src/dsr/model/dsr-maintain-buff.cc @@ -56,9 +56,7 @@ bool DsrMaintainBuffer::Enqueue(DsrMaintainBuffEntry& entry) { Purge(); - for (std::vector::const_iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { // NS_LOG_INFO ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our // add " << i->GetOurAdd () << " " << entry.GetOurAdd () @@ -106,9 +104,7 @@ bool DsrMaintainBuffer::Dequeue(Ipv4Address nextHop, DsrMaintainBuffEntry& entry) { Purge(); - for (std::vector::iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { if (i->GetNextHop() == nextHop) { @@ -124,9 +120,7 @@ DsrMaintainBuffer::Dequeue(Ipv4Address nextHop, DsrMaintainBuffEntry& entry) bool DsrMaintainBuffer::Find(Ipv4Address nextHop) { - for (std::vector::const_iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { if (i->GetNextHop() == nextHop) { @@ -140,9 +134,7 @@ DsrMaintainBuffer::Find(Ipv4Address nextHop) bool DsrMaintainBuffer::AllEqual(DsrMaintainBuffEntry& entry) { - for (std::vector::iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { // NS_LOG_DEBUG ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our // address " << i->GetOurAdd () << " " << entry.GetOurAdd () @@ -166,9 +158,7 @@ DsrMaintainBuffer::AllEqual(DsrMaintainBuffEntry& entry) bool DsrMaintainBuffer::NetworkEqual(DsrMaintainBuffEntry& entry) { - for (std::vector::iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { // NS_LOG_DEBUG ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our // address " << i->GetOurAdd () << " " << entry.GetOurAdd () @@ -193,9 +183,7 @@ bool DsrMaintainBuffer::PromiscEqual(DsrMaintainBuffEntry& entry) { NS_LOG_DEBUG("The maintenance buffer size " << m_maintainBuffer.size()); - for (std::vector::iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { // NS_LOG_DEBUG ("src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << // i->GetDst () << " " << entry.GetDst () @@ -220,9 +208,7 @@ bool DsrMaintainBuffer::LinkEqual(DsrMaintainBuffEntry& entry) { NS_LOG_DEBUG("The maintenance buffer size " << m_maintainBuffer.size()); - for (std::vector::iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { // NS_LOG_DEBUG ("src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << // i->GetDst () << " " << entry.GetDst () diff --git a/src/dsr/model/dsr-network-queue.cc b/src/dsr/model/dsr-network-queue.cc index f2f53d1d9..f68d2f794 100644 --- a/src/dsr/model/dsr-network-queue.cc +++ b/src/dsr/model/dsr-network-queue.cc @@ -107,9 +107,7 @@ bool DsrNetworkQueue::FindPacketWithNexthop(Ipv4Address nextHop, DsrNetworkQueueEntry& entry) { Cleanup(); - for (std::vector::iterator i = m_dsrNetworkQueue.begin(); - i != m_dsrNetworkQueue.end(); - ++i) + for (auto i = m_dsrNetworkQueue.begin(); i != m_dsrNetworkQueue.end(); ++i) { if (i->GetNextHopAddress() == nextHop) { @@ -125,9 +123,7 @@ bool DsrNetworkQueue::Find(Ipv4Address nextHop) { Cleanup(); - for (std::vector::iterator i = m_dsrNetworkQueue.begin(); - i != m_dsrNetworkQueue.end(); - ++i) + for (auto i = m_dsrNetworkQueue.begin(); i != m_dsrNetworkQueue.end(); ++i) { if (i->GetNextHopAddress() == nextHop) { @@ -158,7 +154,7 @@ DsrNetworkQueue::Dequeue(DsrNetworkQueueEntry& entry) { NS_LOG_FUNCTION(this); Cleanup(); - std::vector::iterator i = m_dsrNetworkQueue.begin(); + auto i = m_dsrNetworkQueue.begin(); if (i == m_dsrNetworkQueue.end()) { // no elements in array @@ -182,8 +178,7 @@ DsrNetworkQueue::Cleanup() Time now = Simulator::Now(); uint32_t n = 0; - for (std::vector::iterator i = m_dsrNetworkQueue.begin(); - i != m_dsrNetworkQueue.end();) + for (auto i = m_dsrNetworkQueue.begin(); i != m_dsrNetworkQueue.end();) { if (i->GetInsertedTimeStamp() + m_maxDelay > now) { diff --git a/src/dsr/model/dsr-option-header.cc b/src/dsr/model/dsr-option-header.cc index 3d2619f0d..fbfb85826 100644 --- a/src/dsr/model/dsr-option-header.cc +++ b/src/dsr/model/dsr-option-header.cc @@ -371,9 +371,7 @@ DsrOptionRreqHeader::Print(std::ostream& os) const { os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << ""; - for (std::vector::const_iterator it = m_ipv4Address.begin(); - it != m_ipv4Address.end(); - it++) + for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++) { os << *it << " "; } @@ -398,8 +396,7 @@ DsrOptionRreqHeader::Serialize(Buffer::Iterator start) const i.WriteHtonU16(m_identification); WriteTo(i, m_target); - for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end(); - it++) + for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++) { it->Serialize(buff); i.Write(buff, 4); @@ -506,9 +503,7 @@ DsrOptionRrepHeader::Print(std::ostream& os) const { os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << ""; - for (std::vector::const_iterator it = m_ipv4Address.begin(); - it != m_ipv4Address.end(); - it++) + for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++) { os << *it << " "; } @@ -533,8 +528,7 @@ DsrOptionRrepHeader::Serialize(Buffer::Iterator start) const i.WriteU8(0); i.WriteU8(0); - for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end(); - it++) + for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++) { it->Serialize(buff); i.Write(buff, 4); @@ -666,9 +660,7 @@ DsrOptionSRHeader::Print(std::ostream& os) const { os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << ""; - for (std::vector::const_iterator it = m_ipv4Address.begin(); - it != m_ipv4Address.end(); - it++) + for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++) { os << *it << " "; } @@ -693,8 +685,7 @@ DsrOptionSRHeader::Serialize(Buffer::Iterator start) const i.WriteU8(m_salvage); i.WriteU8(m_segmentsLeft); - for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end(); - it++) + for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++) { it->Serialize(buff); i.Write(buff, 4); diff --git a/src/dsr/model/dsr-options.cc b/src/dsr/model/dsr-options.cc index e5b248a15..8dd292c80 100644 --- a/src/dsr/model/dsr-options.cc +++ b/src/dsr/model/dsr-options.cc @@ -125,9 +125,9 @@ DsrOptions::ContainAddressAfter(Ipv4Address ipv4Address, std::vector& nodeList) { NS_LOG_FUNCTION(this << ipv4Address << destAddress); - std::vector::iterator it = find(nodeList.begin(), nodeList.end(), destAddress); + auto it = find(nodeList.begin(), nodeList.end(), destAddress); - for (std::vector::iterator i = it; i != nodeList.end(); ++i) + for (auto i = it; i != nodeList.end(); ++i) { if ((ipv4Address == (*i)) && ((*i) != nodeList.back())) { @@ -141,9 +141,9 @@ std::vector DsrOptions::CutRoute(Ipv4Address ipv4Address, std::vector& nodeList) { NS_LOG_FUNCTION(this << ipv4Address); - std::vector::iterator it = find(nodeList.begin(), nodeList.end(), ipv4Address); + auto it = find(nodeList.begin(), nodeList.end(), ipv4Address); std::vector cutRoute; - for (std::vector::iterator i = it; i != nodeList.end(); ++i) + for (auto i = it; i != nodeList.end(); ++i) { cutRoute.push_back(*i); } @@ -190,7 +190,7 @@ DsrOptions::SearchNextHop(Ipv4Address ipv4Address, std::vector& vec << vec.back()); return ipv4Address; } - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { if (ipv4Address == (*i)) { @@ -216,7 +216,7 @@ DsrOptions::ReverseSearchNextHop(Ipv4Address ipv4Address, std::vector::reverse_iterator ri = vec.rbegin(); ri != vec.rend(); ++ri) + for (auto ri = vec.rbegin(); ri != vec.rend(); ++ri) { if (ipv4Address == (*ri)) { @@ -237,7 +237,7 @@ DsrOptions::ReverseSearchNextTwoHop(Ipv4Address ipv4Address, std::vector 2); - for (std::vector::reverse_iterator ri = vec.rbegin(); ri != vec.rend(); ++ri) + for (auto ri = vec.rbegin(); ri != vec.rend(); ++ri) { if (ipv4Address == (*ri)) { @@ -264,7 +264,7 @@ DsrOptions::PrintVector(std::vector& vec) else { NS_LOG_DEBUG("Print all the elements in a vector"); - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { NS_LOG_DEBUG("The ip address " << *i); } @@ -275,9 +275,9 @@ bool DsrOptions::IfDuplicates(std::vector& vec, std::vector& vec2) { NS_LOG_FUNCTION(this); - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { - for (std::vector::const_iterator j = vec2.begin(); j != vec2.end(); ++j) + for (auto j = vec2.begin(); j != vec2.end(); ++j) { if ((*i) == (*j)) { @@ -292,7 +292,7 @@ bool DsrOptions::CheckDuplicates(Ipv4Address ipv4Address, std::vector& vec) { NS_LOG_FUNCTION(this << ipv4Address); - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { if ((*i) == ipv4Address) { @@ -311,7 +311,7 @@ DsrOptions::RemoveDuplicates(std::vector& vec) std::vector vec2(vec); // declare vec2 as a copy of the vec PrintVector(vec2); // Print all the ip address in the route vec.clear(); // clear vec - for (std::vector::const_iterator i = vec2.begin(); i != vec2.end(); ++i) + for (auto i = vec2.begin(); i != vec2.end(); ++i) { if (vec.empty()) { @@ -319,7 +319,7 @@ DsrOptions::RemoveDuplicates(std::vector& vec) continue; } - for (std::vector::iterator j = vec.begin(); j != vec.end(); ++j) + for (auto j = vec.begin(); j != vec.end(); ++j) { if ((*i) == (*j)) { @@ -679,9 +679,7 @@ DsrOptionRreq::Process(Ptr packet, std::vector changeRoute(nodeList); changeRoute.push_back(ipv4Address); // push back our own address m_finalRoute.clear(); // get a clear route vector - for (std::vector::iterator i = changeRoute.begin(); - i != changeRoute.end(); - ++i) + for (auto i = changeRoute.begin(); i != changeRoute.end(); ++i) { m_finalRoute.push_back(*i); // Get the full route from source to destination } @@ -805,8 +803,7 @@ DsrOptionRreq::Process(Ptr packet, /** * push back the intermediate node address from the source to this node */ - for (std::vector::iterator i = saveRoute.begin(); i != saveRoute.end(); - ++i) + for (auto i = saveRoute.begin(); i != saveRoute.end(); ++i) { m_finalRoute.push_back(*i); } @@ -814,7 +811,7 @@ DsrOptionRreq::Process(Ptr packet, * push back the route vector we found in our route cache to destination, including this * node's address */ - for (std::vector::iterator j = ip.begin(); j != ip.end(); ++j) + for (auto j = ip.begin(); j != ip.end(); ++j) { m_finalRoute.push_back(*j); } @@ -1389,7 +1386,7 @@ DsrOptionSR::Process(Ptr packet, // Get the option type value uint32_t size = p->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; p->CopyData(data, size); uint8_t optionType = 0; optionType = *(data); @@ -1560,7 +1557,7 @@ DsrOptionRerr::Process(Ptr packet, << (uint32_t)protocol << isPromisc); Ptr p = packet->Copy(); uint32_t size = p->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; p->CopyData(data, size); uint8_t errorType = *(data + 2); /* diff --git a/src/dsr/model/dsr-passive-buff.cc b/src/dsr/model/dsr-passive-buff.cc index ffd650255..781c8d279 100644 --- a/src/dsr/model/dsr-passive-buff.cc +++ b/src/dsr/model/dsr-passive-buff.cc @@ -76,9 +76,7 @@ bool DsrPassiveBuffer::Enqueue(DsrPassiveBuffEntry& entry) { Purge(); - for (std::vector::const_iterator i = m_passiveBuffer.begin(); - i != m_passiveBuffer.end(); - ++i) + for (auto i = m_passiveBuffer.begin(); i != m_passiveBuffer.end(); ++i) { // NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket // ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource () @@ -119,9 +117,7 @@ DsrPassiveBuffer::Enqueue(DsrPassiveBuffEntry& entry) bool DsrPassiveBuffer::AllEqual(DsrPassiveBuffEntry& entry) { - for (std::vector::iterator i = m_passiveBuffer.begin(); - i != m_passiveBuffer.end(); - ++i) + for (auto i = m_passiveBuffer.begin(); i != m_passiveBuffer.end(); ++i) { // NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket // ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource () @@ -156,9 +152,7 @@ DsrPassiveBuffer::Dequeue(Ipv4Address dst, DsrPassiveBuffEntry& entry) /* * Dequeue the entry with destination address dst */ - for (std::vector::iterator i = m_passiveBuffer.begin(); - i != m_passiveBuffer.end(); - ++i) + for (auto i = m_passiveBuffer.begin(); i != m_passiveBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -177,9 +171,7 @@ DsrPassiveBuffer::Find(Ipv4Address dst) /* * Make sure if the send buffer contains entry with certain dst */ - for (std::vector::const_iterator i = m_passiveBuffer.begin(); - i != m_passiveBuffer.end(); - ++i) + for (auto i = m_passiveBuffer.begin(); i != m_passiveBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -213,9 +205,7 @@ DsrPassiveBuffer::Purge() */ NS_LOG_DEBUG("The passive buffer size " << m_passiveBuffer.size()); IsExpired pred; - for (std::vector::iterator i = m_passiveBuffer.begin(); - i != m_passiveBuffer.end(); - ++i) + for (auto i = m_passiveBuffer.begin(); i != m_passiveBuffer.end(); ++i) { if (pred(*i)) { diff --git a/src/dsr/model/dsr-rcache.cc b/src/dsr/model/dsr-rcache.cc index 240385ae5..b4971be60 100644 --- a/src/dsr/model/dsr-rcache.cc +++ b/src/dsr/model/dsr-rcache.cc @@ -185,8 +185,7 @@ bool DsrRouteCache::UpdateRouteEntry(Ipv4Address dst) { NS_LOG_FUNCTION(this << dst); - std::map>::const_iterator i = - m_sortedRoutes.find(dst); + auto i = m_sortedRoutes.find(dst); if (i == m_sortedRoutes.end()) { NS_LOG_LOGIC("Failed to find the route entry for the destination " << dst); @@ -204,8 +203,7 @@ DsrRouteCache::UpdateRouteEntry(Ipv4Address dst) /* * Save the new route cache along with the destination address in map */ - std::pair>::iterator, bool> result = - m_sortedRoutes.insert(std::make_pair(dst, rtVector)); + auto result = m_sortedRoutes.insert(std::make_pair(dst, rtVector)); return result.second; } return false; @@ -226,32 +224,24 @@ DsrRouteCache::LookupRoute(Ipv4Address id, DsrRouteCacheEntry& rt) NS_LOG_LOGIC("Route to " << id << " not found; m_sortedRoutes is empty"); return false; } - std::map>::const_iterator i = - m_sortedRoutes.find(id); + auto i = m_sortedRoutes.find(id); if (i == m_sortedRoutes.end()) { NS_LOG_LOGIC("No Direct Route to " << id << " found"); - for (std::map>::const_iterator j = - m_sortedRoutes.begin(); - j != m_sortedRoutes.end(); - ++j) + for (auto j = m_sortedRoutes.begin(); j != m_sortedRoutes.end(); ++j) { std::list rtVector = j->second; // The route cache vector linked with destination address /* * Loop through the possibly multiple routes within the route vector */ - for (std::list::const_iterator k = rtVector.begin(); - k != rtVector.end(); - ++k) + for (auto k = rtVector.begin(); k != rtVector.end(); ++k) { // return the first route in the route vector DsrRouteCacheEntry::IP_VECTOR routeVector = k->GetVector(); DsrRouteCacheEntry::IP_VECTOR changeVector; - for (DsrRouteCacheEntry::IP_VECTOR::iterator l = routeVector.begin(); - l != routeVector.end(); - ++l) + for (auto l = routeVector.begin(); l != routeVector.end(); ++l) { changeVector.push_back(*l); @@ -283,8 +273,7 @@ DsrRouteCache::LookupRoute(Ipv4Address id, DsrRouteCacheEntry& rt) } } NS_LOG_INFO("Here we check the route cache again after updated the sub routes"); - std::map>::const_iterator m = - m_sortedRoutes.find(id); + auto m = m_sortedRoutes.find(id); if (m == m_sortedRoutes.end()) { NS_LOG_LOGIC("No updated route till last time"); @@ -336,9 +325,7 @@ DsrRouteCache::RebuildBestRouteTable(Ipv4Address source) std::map d; // @pre preceding node std::map pre; - for (std::map>::iterator i = m_netGraph.begin(); - i != m_netGraph.end(); - ++i) + for (auto i = m_netGraph.begin(); i != m_netGraph.end(); ++i) { if (i->second.find(source) != i->second.end()) { @@ -358,11 +345,11 @@ DsrRouteCache::RebuildBestRouteTable(Ipv4Address source) // the node set which shortest distance has been calculated, if true calculated std::map s; double temp = MAXWEIGHT; - Ipv4Address tempip = Ipv4Address("255.255.255.255"); + Ipv4Address tempip("255.255.255.255"); for (uint32_t i = 0; i < m_netGraph.size(); i++) { temp = MAXWEIGHT; - for (std::map::const_iterator j = d.begin(); j != d.end(); ++j) + for (auto j = d.begin(); j != d.end(); ++j) { Ipv4Address ip = j->first; if (s.find(ip) == s.end()) @@ -380,9 +367,7 @@ DsrRouteCache::RebuildBestRouteTable(Ipv4Address source) if (!tempip.IsBroadcast()) { s[tempip] = true; - for (std::map::const_iterator k = m_netGraph[tempip].begin(); - k != m_netGraph[tempip].end(); - ++k) + for (auto k = m_netGraph[tempip].begin(); k != m_netGraph[tempip].end(); ++k) { if (s.find(k->first) == s.end() && d[k->first] > d[tempip] + k->second) { @@ -398,10 +383,8 @@ DsrRouteCache::RebuildBestRouteTable(Ipv4Address source) */ else if (d[k->first] == d[tempip] + k->second) { - std::map::iterator oldlink = - m_linkCache.find(Link(k->first, pre[k->first])); - std::map::iterator newlink = - m_linkCache.find(Link(k->first, tempip)); + auto oldlink = m_linkCache.find(Link(k->first, pre[k->first])); + auto newlink = m_linkCache.find(Link(k->first, tempip)); if (oldlink != m_linkCache.end() && newlink != m_linkCache.end()) { if (oldlink->second.GetLinkStability() < newlink->second.GetLinkStability()) @@ -421,7 +404,7 @@ DsrRouteCache::RebuildBestRouteTable(Ipv4Address source) } // clean the best route table m_bestRoutesTable_link.clear(); - for (std::map::iterator i = pre.begin(); i != pre.end(); ++i) + for (auto i = pre.begin(); i != pre.end(); ++i) { // loop for all vertices DsrRouteCacheEntry::IP_VECTOR route; @@ -450,8 +433,7 @@ DsrRouteCache::LookupRoute_Link(Ipv4Address id, DsrRouteCacheEntry& rt) NS_LOG_FUNCTION(this << id); /// We need to purge the link node cache PurgeLinkNode(); - std::map::const_iterator i = - m_bestRoutesTable_link.find(id); + auto i = m_bestRoutesTable_link.find(id); if (i == m_bestRoutesTable_link.end()) { NS_LOG_INFO("No route find to " << id); @@ -479,10 +461,10 @@ void DsrRouteCache::PurgeLinkNode() { NS_LOG_FUNCTION(this); - for (std::map::iterator i = m_linkCache.begin(); i != m_linkCache.end();) + for (auto i = m_linkCache.begin(); i != m_linkCache.end();) { NS_LOG_DEBUG("The link stability " << i->second.GetLinkStability().As(Time::S)); - std::map::iterator itmp = i; + auto itmp = i; if (i->second.GetLinkStability() <= Seconds(0)) { ++i; @@ -494,11 +476,10 @@ DsrRouteCache::PurgeLinkNode() } } /// may need to remove them after verify - for (std::map::iterator i = m_nodeCache.begin(); - i != m_nodeCache.end();) + for (auto i = m_nodeCache.begin(); i != m_nodeCache.end();) { NS_LOG_DEBUG("The node stability " << i->second.GetNodeStability().As(Time::S)); - std::map::iterator itmp = i; + auto itmp = i; if (i->second.GetNodeStability() <= Seconds(0)) { ++i; @@ -516,7 +497,7 @@ DsrRouteCache::UpdateNetGraph() { NS_LOG_FUNCTION(this); m_netGraph.clear(); - for (std::map::iterator i = m_linkCache.begin(); i != m_linkCache.end(); ++i) + for (auto i = m_linkCache.begin(); i != m_linkCache.end(); ++i) { // Here the weight is set as 1 /// \todo May need to set different weight for different link here later @@ -530,7 +511,7 @@ bool DsrRouteCache::IncStability(Ipv4Address node) { NS_LOG_FUNCTION(this << node); - std::map::const_iterator i = m_nodeCache.find(node); + auto i = m_nodeCache.find(node); if (i == m_nodeCache.end()) { NS_LOG_INFO("The initial stability " << m_initStability.As(Time::S)); @@ -555,7 +536,7 @@ bool DsrRouteCache::DecStability(Ipv4Address node) { NS_LOG_FUNCTION(this << node); - std::map::const_iterator i = m_nodeCache.find(node); + auto i = m_nodeCache.find(node); if (i == m_nodeCache.end()) { DsrNodeStab ns(m_initStability); @@ -636,7 +617,7 @@ DsrRouteCache::UseExtends(DsrRouteCacheEntry::IP_VECTOR rt) NS_LOG_INFO("The route is too short"); return; } - for (DsrRouteCacheEntry::IP_VECTOR::iterator i = rt.begin(); i != rt.end() - 1; ++i) + for (auto i = rt.begin(); i != rt.end() - 1; ++i) { Link link(*i, *(i + 1)); if (m_linkCache.find(link) != m_linkCache.end()) @@ -655,7 +636,7 @@ DsrRouteCache::UseExtends(DsrRouteCacheEntry::IP_VECTOR rt) } } /// Increase the stability of the node cache - for (DsrRouteCacheEntry::IP_VECTOR::iterator i = rt.begin(); i != rt.end(); ++i) + for (auto i = rt.begin(); i != rt.end(); ++i) { if (m_nodeCache.find(*i) != m_nodeCache.end()) { @@ -682,8 +663,7 @@ DsrRouteCache::AddRoute(DsrRouteCacheEntry& rt) std::vector route = rt.GetVector(); NS_LOG_DEBUG("The route destination we have " << dst); - std::map>::const_iterator i = - m_sortedRoutes.find(dst); + auto i = m_sortedRoutes.find(dst); if (i == m_sortedRoutes.end()) { @@ -692,8 +672,7 @@ DsrRouteCache::AddRoute(DsrRouteCacheEntry& rt) /** * Save the new route cache along with the destination address in map */ - std::pair>::iterator, bool> result = - m_sortedRoutes.insert(std::make_pair(dst, rtVector)); + auto result = m_sortedRoutes.insert(std::make_pair(dst, rtVector)); return result.second; } @@ -734,8 +713,7 @@ DsrRouteCache::AddRoute(DsrRouteCacheEntry& rt) /** * Save the new route cache along with the destination address in map */ - std::pair>::iterator, bool> result = - m_sortedRoutes.insert(std::make_pair(dst, rtVector)); + auto result = m_sortedRoutes.insert(std::make_pair(dst, rtVector)); return result.second; } else @@ -751,7 +729,7 @@ bool DsrRouteCache::FindSameRoute(DsrRouteCacheEntry& rt, std::list& rtVector) { NS_LOG_FUNCTION(this); - for (std::list::iterator i = rtVector.begin(); i != rtVector.end(); ++i) + for (auto i = rtVector.begin(); i != rtVector.end(); ++i) { // return the first route in the route vector DsrRouteCacheEntry::IP_VECTOR routeVector = i->GetVector(); @@ -773,8 +751,7 @@ DsrRouteCache::FindSameRoute(DsrRouteCacheEntry& rt, std::list>::iterator, bool> result = - m_sortedRoutes.insert(std::make_pair(rt.GetDestination(), rtVector)); + auto result = m_sortedRoutes.insert(std::make_pair(rt.GetDestination(), rtVector)); return result.second; } } @@ -819,7 +796,7 @@ DsrRouteCache::DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, m_linkCache.erase(link2); NS_LOG_DEBUG("The link cache size " << m_linkCache.size()); - std::map::iterator i = m_nodeCache.find(errorSrc); + auto i = m_nodeCache.find(errorSrc); if (i == m_nodeCache.end()) { NS_LOG_LOGIC("Update the node stability unsuccessfuly"); @@ -854,17 +831,15 @@ DsrRouteCache::DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, /* * Loop all the routes saved in the route cache */ - for (std::map>::iterator j = - m_sortedRoutes.begin(); - j != m_sortedRoutes.end();) + for (auto j = m_sortedRoutes.begin(); j != m_sortedRoutes.end();) { - std::map>::iterator jtmp = j; + auto jtmp = j; Ipv4Address address = j->first; std::list rtVector = j->second; /* * Loop all the routes for a single destination */ - for (std::list::iterator k = rtVector.begin(); k != rtVector.end();) + for (auto k = rtVector.begin(); k != rtVector.end();) { // return the first route in the route vector DsrRouteCacheEntry::IP_VECTOR routeVector = k->GetVector(); @@ -872,9 +847,7 @@ DsrRouteCache::DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, /* * Loop the ip addresses within a single route entry */ - for (DsrRouteCacheEntry::IP_VECTOR::iterator i = routeVector.begin(); - i != routeVector.end(); - ++i) + for (auto i = routeVector.begin(); i != routeVector.end(); ++i) { if (*i != errorSrc) { @@ -972,7 +945,7 @@ DsrRouteCache::PrintVector(std::vector& vec) else { NS_LOG_DEBUG("Print all the elements in a vector"); - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { NS_LOG_DEBUG("The ip address " << *i); } @@ -983,7 +956,7 @@ void DsrRouteCache::PrintRouteVector(std::list route) { NS_LOG_FUNCTION(this); - for (std::list::iterator i = route.begin(); i != route.end(); i++) + for (auto i = route.begin(); i != route.end(); i++) { std::vector path = i->GetVector(); NS_LOG_INFO("Route NO. "); @@ -1001,11 +974,10 @@ DsrRouteCache::Purge() NS_LOG_DEBUG("The route cache is empty"); return; } - for (std::map>::iterator i = m_sortedRoutes.begin(); - i != m_sortedRoutes.end();) + for (auto i = m_sortedRoutes.begin(); i != m_sortedRoutes.end();) { // Loop of route cache entry with the route size - std::map>::iterator itmp = i; + auto itmp = i; /* * The route cache entry vector */ @@ -1014,7 +986,7 @@ DsrRouteCache::Purge() NS_LOG_DEBUG("The route vector size of 1 " << dst << " " << rtVector.size()); if (!rtVector.empty()) { - for (std::list::iterator j = rtVector.begin(); j != rtVector.end();) + for (auto j = rtVector.begin(); j != rtVector.end();) { NS_LOG_DEBUG("The expire time of every entry with expire time " << j->GetExpireTime()); @@ -1066,9 +1038,7 @@ DsrRouteCache::Print(std::ostream& os) Purge(); os << "\nDSR Route Cache\n" << "Destination\tGateway\t\tInterface\tFlag\tExpire\tHops\n"; - for (std::list::const_iterator i = m_routeEntryVector.begin(); - i != m_routeEntryVector.end(); - ++i) + for (auto i = m_routeEntryVector.begin(); i != m_routeEntryVector.end(); ++i) { i->Print(os); } @@ -1083,7 +1053,7 @@ uint16_t DsrRouteCache::CheckUniqueAckId(Ipv4Address nextHop) { NS_LOG_FUNCTION(this); - std::map::const_iterator i = m_ackIdCache.find(nextHop); + auto i = m_ackIdCache.find(nextHop); if (i == m_ackIdCache.end()) { NS_LOG_LOGIC("No Ack id for " << nextHop @@ -1114,7 +1084,7 @@ DsrRouteCache::IsNeighbor(Ipv4Address addr) { NS_LOG_FUNCTION(this); PurgeMac(); // purge the mac cache - for (std::vector::const_iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_neighborAddress == addr) { @@ -1129,7 +1099,7 @@ DsrRouteCache::GetExpireTime(Ipv4Address addr) { NS_LOG_FUNCTION(this); PurgeMac(); - for (std::vector::const_iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_neighborAddress == addr) { @@ -1143,9 +1113,9 @@ void DsrRouteCache::UpdateNeighbor(std::vector nodeList, Time expire) { NS_LOG_FUNCTION(this); - for (std::vector::iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { - for (std::vector::iterator j = nodeList.begin(); j != nodeList.end(); ++j) + for (auto j = nodeList.begin(); j != nodeList.end(); ++j) { if (i->m_neighborAddress == (*j)) { @@ -1170,7 +1140,7 @@ void DsrRouteCache::AddNeighbor(std::vector nodeList, Ipv4Address ownAddress, Time expire) { NS_LOG_LOGIC("Add neighbor number " << nodeList.size()); - for (std::vector::iterator j = nodeList.begin(); j != nodeList.end();) + for (auto j = nodeList.begin(); j != nodeList.end();) { Ipv4Address addr = *j; if (addr == ownAddress) @@ -1214,7 +1184,7 @@ DsrRouteCache::PurgeMac() CloseNeighbor pred; if (!m_handleLinkFailure.IsNull()) { - for (std::vector::iterator j = m_nb.begin(); j != m_nb.end(); ++j) + for (auto j = m_nb.begin(); j != m_nb.end(); ++j) { if (pred(*j)) { @@ -1252,7 +1222,7 @@ Mac48Address DsrRouteCache::LookupMacAddress(Ipv4Address addr) { Mac48Address hwaddr; - for (std::vector>::const_iterator i = m_arp.begin(); i != m_arp.end(); ++i) + for (auto i = m_arp.begin(); i != m_arp.end(); ++i) { ArpCache::Entry* entry = (*i)->Lookup(addr); if (entry != nullptr && (entry->IsAlive() || entry->IsPermanent()) && !entry->IsExpired()) @@ -1269,7 +1239,7 @@ DsrRouteCache::ProcessTxError(const WifiMacHeader& hdr) { Mac48Address addr = hdr.GetAddr1(); - for (std::vector::iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_hardwareAddress == addr) { diff --git a/src/dsr/model/dsr-rcache.h b/src/dsr/model/dsr-rcache.h index 43572343f..0d6ea3be2 100644 --- a/src/dsr/model/dsr-rcache.h +++ b/src/dsr/model/dsr-rcache.h @@ -356,8 +356,8 @@ class DsrRouteCacheEntry NS_ASSERT(false); return false; } - IP_VECTOR::const_iterator j = o.m_path.begin(); - for (IP_VECTOR::const_iterator i = m_path.begin(); i != m_path.end(); i++, j++) + auto j = o.m_path.begin(); + for (auto i = m_path.begin(); i != m_path.end(); i++, j++) { /* * Verify if neither the entry are not 0 and they equal to each other diff --git a/src/dsr/model/dsr-routing.cc b/src/dsr/model/dsr-routing.cc index 11d1b7847..ddfd8602e 100644 --- a/src/dsr/model/dsr-routing.cc +++ b/src/dsr/model/dsr-routing.cc @@ -443,8 +443,7 @@ DsrRouting::Start() << m_maxNetworkDelay.As(Time::S)); Ptr queue_i = CreateObject(m_maxNetworkSize, m_maxNetworkDelay); - std::pair>::iterator, bool> result_i = - m_priorityQueue.insert(std::make_pair(i, queue_i)); + auto result_i = m_priorityQueue.insert(std::make_pair(i, queue_i)); NS_ASSERT_MSG(result_i.second, "Error in creating queues"); } Ptr rreqTable = CreateObject(); @@ -748,7 +747,7 @@ DsrRouting::PrintVector(std::vector& vec) else { NS_LOG_DEBUG("Print all the elements in a vector"); - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { NS_LOG_DEBUG("The ip address " << *i); } @@ -774,7 +773,7 @@ DsrRouting::SearchNextHop(Ipv4Address ipv4Address, std::vector& vec << vec.back()); return ipv4Address; } - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { if (ipv4Address == (*i)) { @@ -866,8 +865,7 @@ DsrRouting::CheckSendBuffer() NS_LOG_INFO(Simulator::Now().As(Time::S) << " Checking send buffer at " << m_mainAddress << " with size " << m_sendBuffer.GetSize()); - for (std::vector::iterator i = m_sendBuffer.GetBuffer().begin(); - i != m_sendBuffer.GetBuffer().end();) + for (auto i = m_sendBuffer.GetBuffer().begin(); i != m_sendBuffer.GetBuffer().end();) { NS_LOG_DEBUG("Here we try to find the data packet in the send buffer"); Ipv4Address destination = i->GetDestination(); @@ -895,7 +893,7 @@ DsrRouting::CheckSendBuffer() * Peek data to get the option type as well as length and segmentsLeft field */ uint32_t size = copyP->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; copyP->CopyData(data, size); uint8_t optionType = 0; @@ -959,8 +957,7 @@ DsrRouting::CheckSendBuffer() m_ipv4Route->SetOutputDevice(dev); uint32_t priority = GetPriority(DSR_CONTROL_PACKET); /// This will be priority 0 - std::map>::iterator i = - m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_LOGIC("Will be inserting into priority queue number: " << priority); @@ -1175,7 +1172,7 @@ DsrRouting::PromiscReceive(Ptr device, * Peek data to get the option type as well as length and segmentsLeft field */ uint32_t size = pktMinusIpHdr->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; pktMinusIpHdr->CopyData(data, size); uint8_t optionType = 0; optionType = *(data); @@ -1451,7 +1448,7 @@ DsrRouting::SendUnreachError(Ipv4Address unreachNode, << newPacket->GetSize()); uint32_t priority = GetPriority(DSR_CONTROL_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_DEBUG("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority); @@ -1501,7 +1498,7 @@ DsrRouting::ForwardErrPacket(DsrOptionRerrUnreachHeader& rerr, route->SetOutputDevice(dev); uint32_t priority = GetPriority(DSR_CONTROL_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_DEBUG("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority); @@ -1740,7 +1737,7 @@ DsrRouting::SendPacket(Ptr packet, m_ipv4Route->SetOutputDevice(dev); uint32_t priority = GetPriority(DSR_DATA_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_INFO("Will be inserting into priority queue number: " << priority); @@ -1782,7 +1779,7 @@ DsrRouting::PriorityScheduler(uint32_t priority, bool continueWithFirst) // priorities ranging from 0 to m_numPriorityQueues, with 0 as the highest priority for (uint32_t i = priority; numPriorities < m_numPriorityQueues; numPriorities++) { - std::map>::iterator q = m_priorityQueue.find(i); + auto q = m_priorityQueue.find(i); Ptr dsrNetworkQueue = q->second; uint32_t queueSize = dsrNetworkQueue->GetSize(); if (queueSize == 0) @@ -1799,10 +1796,7 @@ DsrRouting::PriorityScheduler(uint32_t priority, bool continueWithFirst) else { uint32_t totalQueueSize = 0; - for (std::map>::iterator j = - m_priorityQueue.begin(); - j != m_priorityQueue.end(); - j++) + for (auto j = m_priorityQueue.begin(); j != m_priorityQueue.end(); j++) { NS_LOG_INFO("The size of the network queue for " << j->first << " is " << j->second->GetSize()); @@ -1854,18 +1848,14 @@ DsrRouting::IncreaseRetransTimer() // We may want to get the queue first and then we need to save a vector of the entries here and // then find uint32_t priority = GetPriority(DSR_DATA_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; std::vector newNetworkQueue = dsrNetworkQueue->GetQueue(); - for (std::vector::iterator i = newNetworkQueue.begin(); - i != newNetworkQueue.end(); - i++) + for (auto i = newNetworkQueue.begin(); i != newNetworkQueue.end(); i++) { Ipv4Address nextHop = i->GetNextHopAddress(); - for (std::map::iterator j = m_addressForwardTimer.begin(); - j != m_addressForwardTimer.end(); - j++) + for (auto j = m_addressForwardTimer.begin(); j != m_addressForwardTimer.end(); j++) { if (nextHop == j->first.m_nextHop) { @@ -2031,7 +2021,7 @@ DsrRouting::SendPacketFromBuffer(const DsrOptionSRHeader& sourceRoute, * Peek data to get the option type as well as length and segmentsLeft field */ uint32_t size = copyP->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; copyP->CopyData(data, size); uint8_t optionType = 0; @@ -2085,8 +2075,7 @@ DsrRouting::SendPacketFromBuffer(const DsrOptionSRHeader& sourceRoute, m_ipv4Route->SetOutputDevice(dev); uint32_t priority = GetPriority(DSR_CONTROL_PACKET); - std::map>::iterator i = - m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_DEBUG("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority); @@ -2259,7 +2248,7 @@ DsrRouting::CancelLinkPacketTimer(DsrMaintainBuffEntry& mb) // TODO if find the linkkey, we need to remove it // Find the network acknowledgment timer - std::map::const_iterator i = m_linkAckTimer.find(linkKey); + auto i = m_linkAckTimer.find(linkKey); if (i == m_linkAckTimer.end()) { NS_LOG_INFO("did not find the link timer"); @@ -2308,7 +2297,7 @@ DsrRouting::CancelNetworkPacketTimer(DsrMaintainBuffEntry& mb) << mb.GetNextHop() << " source " << mb.GetSrc() << " destination " << mb.GetDst() << " segsLeft " << (uint32_t)mb.GetSegsLeft()); // Find the network acknowledgment timer - std::map::const_iterator i = m_addressForwardTimer.find(networkKey); + auto i = m_addressForwardTimer.find(networkKey); if (i == m_addressForwardTimer.end()) { NS_LOG_INFO("did not find the packet timer"); @@ -2349,7 +2338,7 @@ DsrRouting::CancelPassivePacketTimer(DsrMaintainBuffEntry& mb) m_passiveCnt.erase(passiveKey); // Find the passive acknowledgment timer - std::map::const_iterator j = m_passiveAckTimer.find(passiveKey); + auto j = m_passiveAckTimer.find(passiveKey); if (j == m_passiveAckTimer.end()) { NS_LOG_INFO("did not find the passive timer"); @@ -2523,7 +2512,7 @@ DsrRouting::SalvagePacket(Ptr packet, // Send out the data packet uint32_t priority = GetPriority(DSR_DATA_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_DEBUG("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority); @@ -3309,7 +3298,7 @@ DsrRouting::SendRequest(Ptr packet, Ipv4Address source) * The destination address here is directed broadcast address */ uint32_t priority = GetPriority(DSR_CONTROL_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_LOGIC("Inserting into priority queue number: " << priority); @@ -3363,16 +3352,14 @@ DsrRouting::SendGratuitousReply(Ipv4Address source, /** * Push back the node addresses other than those between srcAddress and our own ip address */ - std::vector::iterator before = - find(nodeList.begin(), nodeList.end(), srcAddress); - for (std::vector::iterator i = nodeList.begin(); i != before; ++i) + auto before = find(nodeList.begin(), nodeList.end(), srcAddress); + for (auto i = nodeList.begin(); i != before; ++i) { m_finalRoute.push_back(*i); } m_finalRoute.push_back(srcAddress); - std::vector::iterator after = - find(nodeList.begin(), nodeList.end(), m_mainAddress); - for (std::vector::iterator j = after; j != nodeList.end(); ++j) + auto after = find(nodeList.begin(), nodeList.end(), m_mainAddress); + for (auto j = after; j != nodeList.end(); ++j) { m_finalRoute.push_back(*j); } @@ -3426,7 +3413,7 @@ DsrRouting::SendReply(Ptr packet, NS_LOG_INFO("The output device " << dev << " packet is: " << *packet); uint32_t priority = GetPriority(DSR_CONTROL_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_INFO("Inserting into priority queue number: " << priority); @@ -3509,7 +3496,7 @@ DsrRouting::SendAck(uint16_t ackId, route->SetOutputDevice(dev); uint32_t priority = GetPriority(DSR_CONTROL_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_LOGIC("Will be inserting into priority queue " << dsrNetworkQueue @@ -3568,7 +3555,7 @@ DsrRouting::Receive(Ptr p, const Ipv4Header& ip, Ptr inco * Peek data to get the option type as well as length and segmentsLeft field */ uint32_t size = p->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; p->CopyData(data, size); uint8_t optionType = 0; @@ -3770,7 +3757,7 @@ DsrRouting::Insert(Ptr option) Ptr DsrRouting::GetOption(int optionNumber) { - for (DsrOptionList_t::iterator i = m_options.begin(); i != m_options.end(); ++i) + for (auto i = m_options.begin(); i != m_options.end(); ++i) { if ((*i)->GetOptionNumber() == optionNumber) { diff --git a/src/dsr/model/dsr-rreq-table.cc b/src/dsr/model/dsr-rreq-table.cc index dfb4dc0c1..e3568b211 100644 --- a/src/dsr/model/dsr-rreq-table.cc +++ b/src/dsr/model/dsr-rreq-table.cc @@ -71,9 +71,7 @@ DsrRreqTable::RemoveLeastExpire() NS_LOG_FUNCTION(this); Ipv4Address firstExpire; Time max = Seconds(0.0); - for (std::map::const_iterator i = m_rreqDstMap.begin(); - i != m_rreqDstMap.end(); - ++i) + for (auto i = m_rreqDstMap.begin(); i != m_rreqDstMap.end(); ++i) { Ipv4Address dst = i->first; RreqTableEntry rreqTableEntry = i->second; @@ -90,7 +88,7 @@ void DsrRreqTable::FindAndUpdate(Ipv4Address dst) { NS_LOG_FUNCTION(this << dst); - std::map::const_iterator i = m_rreqDstMap.find(dst); + auto i = m_rreqDstMap.find(dst); if (i == m_rreqDstMap.end()) { NS_LOG_LOGIC("The request table entry for " << dst << " not found"); @@ -123,7 +121,7 @@ void DsrRreqTable::RemoveRreqEntry(Ipv4Address dst) { NS_LOG_FUNCTION(this << dst); - std::map::const_iterator i = m_rreqDstMap.find(dst); + auto i = m_rreqDstMap.find(dst); if (i == m_rreqDstMap.end()) { NS_LOG_LOGIC("The request table entry not found"); @@ -139,7 +137,7 @@ uint32_t DsrRreqTable::GetRreqCnt(Ipv4Address dst) { NS_LOG_FUNCTION(this << dst); - std::map::const_iterator i = m_rreqDstMap.find(dst); + auto i = m_rreqDstMap.find(dst); if (i == m_rreqDstMap.end()) { NS_LOG_LOGIC("Request table entry not found"); @@ -159,7 +157,7 @@ uint32_t DsrRreqTable::CheckUniqueRreqId(Ipv4Address dst) { NS_LOG_LOGIC("The size of id cache " << m_rreqIdCache.size()); - std::map::const_iterator i = m_rreqIdCache.find(dst); + auto i = m_rreqIdCache.find(dst); if (i == m_rreqIdCache.end()) { NS_LOG_LOGIC("No Request id for " << dst << " found, initialize it to 0"); @@ -210,7 +208,7 @@ BlackList* DsrRreqTable::FindUnidirectional(Ipv4Address neighbor) { PurgeNeighbor(); // purge the neighbor cache - for (std::vector::iterator i = m_blackList.begin(); i != m_blackList.end(); ++i) + for (auto i = m_blackList.begin(); i != m_blackList.end(); ++i) { if (i->m_neighborAddress == neighbor) { @@ -224,7 +222,7 @@ bool DsrRreqTable::MarkLinkAsUnidirectional(Ipv4Address neighbor, Time blacklistTimeout) { NS_LOG_LOGIC("Add neighbor address in blacklist " << m_blackList.size()); - for (std::vector::iterator i = m_blackList.begin(); i != m_blackList.end(); i++) + for (auto i = m_blackList.begin(); i != m_blackList.end(); i++) { if (i->m_neighborAddress == neighbor) { @@ -260,8 +258,7 @@ DsrRreqTable::FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id) /* * this function will return false if the entry is not found, true if duplicate entry find */ - std::map>::const_iterator i = - m_sourceRreqMap.find(src); + auto i = m_sourceRreqMap.find(src); if (i == m_sourceRreqMap.end()) { NS_LOG_LOGIC("The source request table entry for " << src << " not found"); @@ -284,9 +281,7 @@ DsrRreqTable::FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id) } // We loop the receive rreq entry to find duplicate - for (std::list::const_iterator j = receivedRreqEntryList.begin(); - j != receivedRreqEntryList.end(); - ++j) + for (auto j = receivedRreqEntryList.begin(); j != receivedRreqEntryList.end(); ++j) { if (*j == rreqEntry) /// Check if we have found one duplication entry or not { diff --git a/src/dsr/model/dsr-rsendbuff.cc b/src/dsr/model/dsr-rsendbuff.cc index 0e256f30f..109624458 100644 --- a/src/dsr/model/dsr-rsendbuff.cc +++ b/src/dsr/model/dsr-rsendbuff.cc @@ -56,9 +56,7 @@ bool DsrSendBuffer::Enqueue(DsrSendBuffEntry& entry) { Purge(); - for (std::vector::const_iterator i = m_sendBuffer.begin(); - i != m_sendBuffer.end(); - ++i) + for (auto i = m_sendBuffer.begin(); i != m_sendBuffer.end(); ++i) { // NS_LOG_DEBUG ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket // ()->GetUid () @@ -94,8 +92,7 @@ DsrSendBuffer::DropPacketWithDst(Ipv4Address dst) /* * Drop the packet with destination address dst */ - for (std::vector::iterator i = m_sendBuffer.begin(); i != m_sendBuffer.end(); - ++i) + for (auto i = m_sendBuffer.begin(); i != m_sendBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -116,8 +113,7 @@ DsrSendBuffer::Dequeue(Ipv4Address dst, DsrSendBuffEntry& entry) /* * Dequeue the entry with destination address dst */ - for (std::vector::iterator i = m_sendBuffer.begin(); i != m_sendBuffer.end(); - ++i) + for (auto i = m_sendBuffer.begin(); i != m_sendBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -136,9 +132,7 @@ DsrSendBuffer::Find(Ipv4Address dst) /* * Make sure if the send buffer contains entry with certain dst */ - for (std::vector::const_iterator i = m_sendBuffer.begin(); - i != m_sendBuffer.end(); - ++i) + for (auto i = m_sendBuffer.begin(); i != m_sendBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -171,8 +165,7 @@ DsrSendBuffer::Purge() */ NS_LOG_INFO("The send buffer size " << m_sendBuffer.size()); IsExpired pred; - for (std::vector::iterator i = m_sendBuffer.begin(); i != m_sendBuffer.end(); - ++i) + for (auto i = m_sendBuffer.begin(); i != m_sendBuffer.end(); ++i) { if (pred(*i)) { diff --git a/src/dsr/test/dsr-test-suite.cc b/src/dsr/test/dsr-test-suite.cc index 260a0aeb3..c77877f47 100644 --- a/src/dsr/test/dsr-test-suite.cc +++ b/src/dsr/test/dsr-test-suite.cc @@ -443,7 +443,7 @@ DsrCacheEntryTest::DoRun() Ipv4Address("0.0.0.1"), }; - Ipv4Address dst = Ipv4Address("0.0.0.1"); + Ipv4Address dst("0.0.0.1"); dsr::DsrRouteCacheEntry entry(ip, dst, Seconds(1)); NS_TEST_EXPECT_MSG_EQ(entry.GetVector().size(), 2, "trivial"); NS_TEST_EXPECT_MSG_EQ(entry.GetDestination(), Ipv4Address("0.0.0.1"), "trivial"); @@ -464,7 +464,7 @@ DsrCacheEntryTest::DoRun() Ipv4Address("1.1.1.1"), }; - Ipv4Address dst2 = Ipv4Address("1.1.1.1"); + Ipv4Address dst2("1.1.1.1"); dsr::DsrRouteCacheEntry entry2(ip2, dst2, Seconds(2)); dsr::DsrRouteCacheEntry newEntry; NS_TEST_EXPECT_MSG_EQ(rcache->AddRoute(entry2), true, "trivial"); @@ -516,7 +516,7 @@ DsrSendBuffTest::DoRun() NS_TEST_EXPECT_MSG_EQ(q.GetSendBufferTimeout(), Seconds(10), "trivial"); Ptr packet = Create(); - Ipv4Address dst1 = Ipv4Address("0.0.0.1"); + Ipv4Address dst1("0.0.0.1"); dsr::DsrSendBuffEntry e1(packet, dst1, Seconds(1)); q.Enqueue(e1); q.Enqueue(e1); @@ -528,7 +528,7 @@ DsrSendBuffTest::DoRun() NS_TEST_EXPECT_MSG_EQ(q.Find(Ipv4Address("0.0.0.1")), false, "trivial"); NS_TEST_EXPECT_MSG_EQ(q.GetSize(), 0, "trivial"); - Ipv4Address dst2 = Ipv4Address("0.0.0.2"); + Ipv4Address dst2("0.0.0.2"); dsr::DsrSendBuffEntry e2(packet, dst2, Seconds(1)); q.Enqueue(e1); q.Enqueue(e2); @@ -541,7 +541,7 @@ DsrSendBuffTest::DoRun() q.Enqueue(e3); NS_TEST_EXPECT_MSG_EQ(q.GetSize(), 2, "trivial"); Ptr packet4 = Create(); - Ipv4Address dst4 = Ipv4Address("0.0.0.4"); + Ipv4Address dst4("0.0.0.4"); dsr::DsrSendBuffEntry e4(packet4, dst4, Seconds(20)); q.Enqueue(e4); NS_TEST_EXPECT_MSG_EQ(q.GetSize(), 3, "trivial"); diff --git a/src/energy/CMakeLists.txt b/src/energy/CMakeLists.txt index 0adcda2d5..d922393e4 100644 --- a/src/energy/CMakeLists.txt +++ b/src/energy/CMakeLists.txt @@ -7,6 +7,7 @@ build_lib( helper/energy-harvester-helper.cc helper/energy-model-helper.cc helper/energy-source-container.cc + helper/generic-battery-model-helper.cc helper/li-ion-energy-source-helper.cc helper/rv-battery-model-helper.cc model/basic-energy-harvester.cc @@ -15,6 +16,7 @@ build_lib( model/device-energy-model.cc model/energy-harvester.cc model/energy-source.cc + model/generic-battery-model.cc model/li-ion-energy-source.cc model/rv-battery-model.cc model/simple-device-energy-model.cc @@ -25,6 +27,7 @@ build_lib( helper/energy-harvester-helper.h helper/energy-model-helper.h helper/energy-source-container.h + helper/generic-battery-model-helper.h helper/li-ion-energy-source-helper.h helper/rv-battery-model-helper.h model/basic-energy-harvester.h @@ -33,6 +36,7 @@ build_lib( model/device-energy-model.h model/energy-harvester.h model/energy-source.h + model/generic-battery-model.h model/li-ion-energy-source.h model/rv-battery-model.h model/simple-device-energy-model.h diff --git a/src/energy/doc/energy.rst b/src/energy/doc/energy.rst index 6ee7308ba..74cb35ada 100644 --- a/src/energy/doc/energy.rst +++ b/src/energy/doc/energy.rst @@ -1,57 +1,58 @@ +.. include:: replace.txt +.. highlight:: cpp +.. highlight:: bash + Energy Framework ---------------- -Energy consumption is a key issue for wireless devices, and wireless -network researchers often need to investigate the energy consumption -at a node or in the overall network while running network simulations -in ns-3. This requires ns-3 to support energy consumption -modeling. Further, as concepts such as fuel cells and energy +Energy is a key issue for wireless devices, and network researchers +often need to investigate the energy consumption at a node or in the +overall network while running network simulations in |ns3|. +This requires |ns3| to support an energy framework. +Further, as concepts such as fuel cells and energy scavenging are becoming viable for low power wireless devices, incorporating the effect of these emerging technologies into -simulations requires support for modeling diverse energy sources in -ns-3. The ns-3 Energy Framework provides the basis for energy -consumption, energy source and energy harvesting modeling. +simulations requires support for modeling diverse energy models in +ns-3. The |ns3| energy framework provides the basis for energy storing +consumption and harvesting. Model Description -================= +***************** +The framework is implemented into the ``src/energy/`` folder. -The source code for the Energy Framework is currently at: ``src/energy``. +The |ns3| energy framework is composed of 3 essential parts: -Design -****** +* **Energy source models.** Represent storing energy sources such as batteries or capacitors. -The ns-3 Energy Framework is composed of 3 parts: Energy Source, -Device Energy Model and Energy Harvester. The framework is -implemented into the ``src/energy/models`` folder. +* **Energy consumption models.** Represent a portion of a device that draws energy from energy sources. Examples of this include sensors, radio transceivers, vehicles, UAV, etc. -Energy Source -############# +* **Energy harvesting models.** Represent devices that provide energy to energy sources. For example, solar panels and chargers. -The Energy Source represents the power supply on each node. A node can -have one or more energy sources, and each energy source can be -connected to multiple device energy models. Connecting an energy -source to a device energy model implies that the corresponding device -draws power from the source. The basic functionality of the Energy -Source is to provide energy for devices on the node. When energy is -completely drained from the Energy Source, it notifies the devices on -node such that each device can react to this event. Further, each node -can access the Energy Source Objects for information such as remaining -energy or energy fraction (battery level). This enables the -implementation of energy aware protocols in ns-3. +.. _fig-energyFramework: -In order to model a wide range of power supplies such as batteries, -the Energy Source must be able to capture characteristics of these -supplies. There are 2 important characteristics or effects related to -practical batteries: +.. figure:: figures/energyFramework.* -Rate Capacity Effect - Decrease of battery lifetime when the current draw is higher - than the rated value of the battery. + |ns3| energy framework -Recovery Effect - Increase of battery lifetime when the battery is alternating - between discharge and idle states. + +Energy Source Models +==================== + +An energy source represents a power supply. In |ns3|, nodes can +have one or more energy sources. Likewise, energy sources can be +connected to multiple energy consuption models (Device energy models). +Connecting an energy source to a device energy model implies that the +corresponding device draws power from the source. +When energy is completely drained from the energy source, it notifies to the device energy models on +the node such that each device energy model can react to this event. Further, each node +can access the energy source objects for information such as remaining capacity , voltage or +state of charge (SoC). This enables the implementation of energy aware protocols in ns-3. + +In order to model a wide range of power supplies such as batteries, the energy source must be able to capture characteristics of these supplies. There are 2 important characteristics or effects related to practical batteries: + +* **Rate Capacity Effect.** Decrease of battery lifetime when the current draw is higher than the rated value of the battery. +* **Recovery Effect.** Increase of battery lifetime when the battery is alternating between discharge and idle states. In order to incorporate the Rate Capacity Effect, the Energy Source uses current draw from all the devices on the same node to calculate @@ -64,47 +65,108 @@ Device Energy Model will notify the Energy Source of this change and new total current draw will be calculated. Similarly, every Energy Harvester update triggers an update to the connected Energy Source. -The Energy Source base class keeps a list of devices (Device Energy -Model objects) and energy harvesters (Energy Harvester objects) that -are using the particular Energy Source as power supply. When energy is -completely drained, the Energy Source will notify all devices on this -list. Each device can then handle this event independently, based on -the desired behavior that should be followed in case of power outage. +The ``EnergySource`` base class keeps a list of devices (``DeviceEnergyModel`` objects) and energy harvesters (``EnergyHarvester`` objects) that are using the particular Energy Source as power supply. When energy is completely drained, the Energy Source will notify all devices on this list. Each device can then handle this event independently, based on the desired behavior that should be followed in case of power outage. + +Generic Batttery Model +###################### + +The Generic battery model is able to represent 4 basic types of batteries +chemestries: Lithium-Ion (LiIon) or Lithium Polymer (LiPo), Nickel Cadmium (NiCd), +Lead Acid, and Nickel-metal hydride (NiMH). The main difference between these batteries +is the shape of the discharge curves when using constant discharge current and that +NiCd and NiMh batteries hysteresis phenomenon is also modeled. Peurket effect, aging, +temperature and variable battery impedance is not considered for all batteries. batteries +with similar discharge behavior might be also represented but one of the 4 basic +arqueotipes must be chosen. + +The Generic Battery Model is directly based by the works of Trembley et al. +Tremblay's model on itself is based on a popular battery model created by Shepherd. +Tremblay's model consist in visually identify a set of points from batteries manufacters' +discharge curves datasheets. + +.. _fig-energyFramework: + +.. figure:: figures/dischargeCurve.* + + |ns3| Generic Battery Model Points in battery discharge curve. + +The 3 basic set of points that require identification in a datasheet are: + +* :math:`V_{full}:` The full battery voltage +* :math:`Q:` The maximum battery capacity + +* :math:`V_{exp}:` The voltage at the end of the exponential zone +* :math:`Q_{exp}:` The capacity at the end of the exponential zone + +* :math:`V_{nom}:` The voltage at the end of the exponential zone +* :math:`Q_{nom}:` The capacity at the end of the exponential zone + +Additionally, it is also necessary to set the values of: + +* :math:`R:` The battery impedance (The battery internal resistance) +* :math:`i_{typical}:` The typical current value used to discharge the battery, this value is used to calculate some of the constants used in the model. +* :math:`cutoffVoltage:` Required if we desired to inform connected energy consumption models that the battery has reached its discharged point. +* :math:`i:` The discharge current used to discharge the battery. This value is provided by the energy consumption model attached to the battery. + +The value of :math:`R` is typically included in the datatsheets, however, because :math:`R` variability is not modeled in |ns3| (The resistance is fixed), it is necessary +to discretely adjust its value to obtain the desired discharge curves. The value :math:`i_{typical}` can +be obtained by inferring its value from the discharged curves shown in datasheets. When modeling +the behavior of a new battery, it is important to chose values that satisfies more than one curve, +trial an error adjustments might be necessary to obtain the desired results. + +Attributes: + +* ``FullVoltage``: Represents the :math:`V_{full}` value. +* ``MaxCapacity``: Represents the :math:`Q` value. +* ``ExponentialVoltage``: Represents the :math:`V_{exp}` value. +* ``ExponentialCapacity``: Represents the :math:`Q_{exp}` value. +* ``NominalVoltage``: Represents the :math:`V_{nom}` value. +* ``NominalCapacity``: Represents the :math:`Q_{nom}` value. +* ``InternalResistance``: Represents the :math:`R` value. +* ``TypicalDischargeCurrent``: Represents the :math:`i_{typical}` value. +* ``CutoffVoltage``: The voltage where the battery is considered depleted. +* ``BatteryType``: Indicates the battery type used. +* ``PeriodicEnergyUpdateInterval``: Indicates how often the update values are obtained. +* ``LowBatteryThreshold``: Additional voltage threshold to indicate when the battery has low energy. + +The process described above can be simplified by installing batteries presents of previously tested +batteries using helpers. Details on helpers usage are detailed in the following sections. -Device Energy Model -################### - -The Device Energy Model is the energy consumption model of a device -installed on the node. It is designed to be a state based model where -each device is assumed to have a number of states, and each state is -associated with a power consumption value. Whenever the state of the -device changes, the corresponding Device Energy Model will notify the -Energy Source of the new current draw of the device. The Energy Source -will then calculate the new total current draw and update the -remaining energy. - -The Device Energy Model can also be used for devices that do not have -finite number of states. For example, in an electric vehicle, the -current draw of the motor is determined by its speed. Since the -vehicle's speed can take continuous values within a certain range, it -is infeasible to define a set of discrete states of -operation. However, by converting the speed value into current -directly, the same set of Device Energy Model APIs can still be used. - -Energy Harvester +RV Battery Model ################ -The energy harvester represents the elements that harvest energy from -the environment and recharge the Energy Source to which it is -connected. The energy harvester includes the complete implementation -of the actual energy harvesting device (e.g., a solar panel) and the -environment (e.g., the solar radiation). This means that in -implementing an energy harvester, the energy contribution of the -environment and the additional energy requirements of the energy -harvesting device such as the conversion efficiency and the internal -power consumption of the device needs to be jointly modeled. +Attributes: +* ``RvBatteryModelPeriodicEnergyUpdateInterval``: RV battery model sampling + interval. +* ``RvBatteryModelOpenCircuitVoltage``: RV battery model open circuit voltage. +* ``RvBatteryModelCutoffVoltage``: RV battery model cutoff voltage. +* ``RvBatteryModelAlphaValue``: RV battery model alpha value. +* ``RvBatteryModelBetaValue``: RV battery model beta value. +* ``RvBatteryModelNumOfTerms``: The number of terms of the infinite sum for estimating battery level. + +Basic Energy Source +################### + +Attributes: + +* ``BasicEnergySourceInitialEnergyJ``: Initial energy stored in + basic energy source. +* ``BasicEnergySupplyVoltageV``: Initial supply voltage for basic energy source. +* ``PeriodicEnergyUpdateInterval``: Time between two consecutive periodic energy updates. + + +Energy Consumption Models +========================= + +A ``DeviceEnergyModel`` is the energy consumption model of a device installed on the node. +It is designed to be a state based model where each device is assumed to have a number of states, and each state is associated with a power consumption value. +Whenever the state of the device changes, the corresponding ``DeviceEnergyModel`` will notify the associated ``EnergySourceModel`` of the new current draw of the device. +The ``EnergySourceModel`` will then calculate the new total current draw and update the remaining energy. A ``DeviceEnergyModel`` can also be used for devices that do not have finite number of states. +For example, in an electric vehicle, the current draw of the motor is determined by its speed. +Since the vehicle's speed can take continuous values within a certain range, it is infeasible to define a set of discrete states of operation. +However, by converting the speed value into current draw directly, the same set of ``DeviceEnergyModel`` APIs can still be used. WiFi Radio Energy Model ####################### @@ -146,53 +208,32 @@ used to install the model on a device, a callback is implicitly made so that the Wifi PHY is resumed from the OFF mode when the energy source is recharged. -Future Work -*********** +Attributes -For Device Energy Models, we are planning to include support for other -PHY layer models provided in ns-3 such as WiMAX, and to model the -energy consumptions of other non communicating devices, like a generic -sensor and a CPU. For Energy Sources, we are planning to included new -types of Energy Sources such as Supercapacitor and Nickel-Metal -Hydride (Ni-MH) battery. For the Energy Harvesters, we are planning to -implement an energy harvester that recharges the energy sources -according to the power levels defined in a user customizable dataset -of real measurements. +* ``IdleCurrentA``: The default radio Idle current in Ampere. +* ``CcaBusyCurrentA``: The default radio CCA Busy State current in Ampere. +* ``TxCurrentA``: The radio Tx current in Ampere. +* ``RxCurrentA``: The radio Rx current in Ampere. +* ``SwitchingCurrentA``: The default radio Channel Switch current in Ampere. +* ``SleepCurrentA``: The radio Sleep current in Ampere. +* ``TxCurrentModel``: A pointer to the attached tx current model. -References -********** +Energy Harvesting Models +======================== -[1] ns-2 Energy model: - https://web.archive.org/web/20130428021737/http://www.cubinlab.ee.unimelb.edu.au/~jrid/Docs/Manuel-NS2/node204.html +The energy harvester represents the elements that supply energy from +the environment and recharge an energy source to which it is +connected. The energy harvester includes the complete implementation +of the actual energy harvesting device (e.g., a solar panel) and the +environment (e.g., the solar radiation). This means that in +implementing an energy harvester, the energy contribution of the +environment and the additional energy requirements of the energy +harvesting device such as the conversion efficiency and the internal +power consumption of the device needs to be jointly modeled. -[2] H. Wu, S. Nabar and R. Poovendran. An Energy Framework for the - Network Simulator 3 (ns-3). - -[3] M. Handy and D. Timmermann. Simulation of mobile wireless - networks with accurate modelling of non-linear battery effects. In - Proc. of Applied simulation and Modeling (ASM), 2003. - -[4] D. N. Rakhmatov and S. B. Vrudhula. An analytical high-level - battery model for use in energy management of portable electronic - systems. In Proc. of IEEE/ACM International Conference on Computer - Aided Design (ICCAD'01), pages 488-493, November 2001. - -[5] D. N. Rakhmatov, S. B. Vrudhula, and D. A. Wallach. Battery - lifetime prediction for energy-aware computing. In Proc. of the 2002 - International Symposium on Low Power Electronics and Design - (ISLPED'02), pages 154-159, 2002. - -[6] C. Tapparello, H. Ayatollahi and W. Heinzelman. Extending the - Energy Framework for Network Simulator 3 (ns-3). Workshop on ns-3 - (WNS3), Poster Session, Atlanta, GA, USA. May, 2014. - -[7] C. Tapparello, H. Ayatollahi and W. Heinzelman. Energy Harvesting - Framework for Network Simulator 3 (ns-3). 2nd International Workshop on - Energy Neutral Sensing Systems (ENSsys), Memphis, TN, USA. November 6, - 2014. Usage -===== +***** The main way that ns-3 users will typically interact with the Energy Framework is through the helper API and through the publicly visible @@ -218,122 +259,214 @@ access to the Energy Harvester objects in order to gather information regarding the current harvestable power and the total energy harvested by the harvester. - -Examples -******** - -The example directories, ``src/examples/energy`` and -``examples/energy``, contain some basic code that shows how to set up -the framework. - Helpers -******* +======= -Energy Source Helper -#################### +**Energy Source Helper:** Base helper class for Energy Source objects, this helper Aggregates Energy Source object onto a node. Child implementation of this class creates the actual Energy Source object. -Device Energy Model Helper -########################## +**Device Energy Model Helper:** Base helper class for Device Energy Model objects, this helper attaches Device Energy Model objects onto Energy Source objects. Child implementation of this class creates the actual Device Energy Model object. -Energy Harvesting Helper -########################## +**Energy Harvesting Helper:** Base helper class for Energy Harvester objects, this helper attaches Energy Harvester objects onto Energy Source objects. Child implementation of this class creates the actual Energy Harvester object. +**Generic Battery Model Helper:** -Attributes -********** +The ``GenericBatteryModelHelper`` can be used to easily install an energy source into a +node or node container of one of four types of chemestries (Li-Ion,Lead Acid, NiCd,NiMH). +Users must use one of the available presets that represent an specific battery. -Attributes differ between Energy Sources, Devices Energy Models and -Energy Harvesters implementations, please look at the specific child -class for details. +.. sourcecode:: cpp -Basic Energy Source -################### + GenericBatteryModelHelper batteryHelper; + EnergySourceContainer + energySourceContainer = batteryHelper.Install(nodeContainer, + PANASONIC_CGR18650DA_LION); + batteryHelper.SetCellPack(energySourceContainer,2,2); -* ``BasicEnergySourceInitialEnergyJ``: Initial energy stored in - basic energy source. -* ``BasicEnergySupplyVoltageV``: Initial supply voltage for basic energy source. -* ``PeriodicEnergyUpdateInterval``: Time between two consecutive periodic - energy updates. +In the previous example, the ``GenericBatteryModelHelper`` was used to install a Panasonic CGR18650DA +Li-Ion battery. Likewise, the helper is used to define a cell pack of 4 batteries. 2 batteries +connected in series and 2 connected in parallel (2S,2P). -RV Battery Model -################ +Another option is to manually configure the values that makes the preset: -* ``RvBatteryModelPeriodicEnergyUpdateInterval``: RV battery model sampling - interval. -* ``RvBatteryModelOpenCircuitVoltage``: RV battery model open circuit voltage. -* ``RvBatteryModelCutoffVoltage``: RV battery model cutoff voltage. -* ``RvBatteryModelAlphaValue``: RV battery model alpha value. -* ``RvBatteryModelBetaValue``: RV battery model beta value. -* ``RvBatteryModelNumOfTerms``: The number of terms of the infinite sum for estimating battery level. +.. sourcecode:: cpp -WiFi Radio Energy Model -####################### + auto node = CreateObject(); + auto devicesEnergyModel = CreateObject(); + batteryModel = CreateObject(); + batteryModel->SetAttribute("FullVoltage", DoubleValue(1.39)); // Qfull + batteryModel->SetAttribute("MaxCapacity", DoubleValue(7.0)); // Q + batteryModel->SetAttribute("NominalVoltage", DoubleValue(1.18)); // Vnom + batteryModel->SetAttribute("NominalCapacity", DoubleValue(6.25)); // QNom + batteryModel->SetAttribute("ExponentialVoltage", DoubleValue(1.28)); // Vexp + batteryModel->SetAttribute("ExponentialCapacity", DoubleValue(1.3)); // Qexp + batteryModel->SetAttribute("InternalResistance", DoubleValue(0.0046)); // R + batteryModel->SetAttribute("TypicalDischargeCurrent", DoubleValue(1.3)); // i typical + batteryModel->SetAttribute("CutoffVoltage", DoubleValue(1.0)); // End of charge. + batteryModel->SetAttribute("BatteryType", EnumValue(NIMH_NICD)); // General battery type + batteryModel = DynamicCast + (batteryHelper.Install(node,PANASONIC_HHR650D_NIMH)); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); -* ``IdleCurrentA``: The default radio Idle current in Ampere. -* ``CcaBusyCurrentA``: The default radio CCA Busy State current in Ampere. -* ``TxCurrentA``: The radio Tx current in Ampere. -* ``RxCurrentA``: The radio Rx current in Ampere. -* ``SwitchingCurrentA``: The default radio Channel Switch current in Ampere. -* ``SleepCurrentA``: The radio Sleep current in Ampere. -* ``TxCurrentModel``: A pointer to the attached tx current model. -Basic Energy Harvester -####################### +Usage of both of these type of configurations are shown in ``generic-battery-discharge-example.cc``. +The following table is a list of the available presents in |ns3|: + + ++---------------------------+-------------------------------------------------+ +| Preset Name | Description | ++===========================+=================================================+ +| PANASONIC_CGR18650DA_LION | Panasonic Li-Ion (3.6V, 2450Ah, Size A) | ++---------------------------+-------------------------------------------------+ +| PANASONIC_HHR650D_NIMH | Panasonic NiMh HHR550D (1.2V 6.5Ah, Size D) | ++---------------------------+-------------------------------------------------+ +| CSB_GP1272_LEADACID | CSB Lead Acid GP1272 (12V,7.2Ah) | ++---------------------------+-------------------------------------------------+ +| PANASONIC_N700AAC_NICD | Panasonic NiCd N-700AAC (1.2V 700mAh, Size: AA) | ++---------------------------+-------------------------------------------------+ +| RSPRO_LGP12100_LEADACID | Rs Pro Lead Acid LGP12100 (12V, 100Ah) | ++---------------------------+-------------------------------------------------+ -* ``PeriodicHarvestedPowerUpdateInterval``: Time between two consecutive - periodic updates of the harvested power. -* ``HarvestablePower``: Random variables that represents the amount of power - that is provided by the energy harvester. Tracing -******* +======= Traced values differ between Energy Sources, Devices Energy Models and Energy Harvesters implementations, please look at the specific child class for details. -Basic Energy Source -################### +**Basic Energy Source** * ``RemainingEnergy``: Remaining energy at BasicEnergySource. -RV Battery Model -################ +**RV Battery Model** * ``RvBatteryModelBatteryLevel``: RV battery model battery level. * ``RvBatteryModelBatteryLifetime``: RV battery model battery lifetime. -WiFi Radio Energy Model -####################### +**WiFi Radio Energy Model** * ``TotalEnergyConsumption``: Total energy consumption of the radio device. -Basic Energy Harvester -####################### +**Basic Energy Harvester** * ``HarvestedPower``: Current power provided by the BasicEnergyHarvester. * ``TotalEnergyHarvested``: Total energy harvested by the BasicEnergyHarvester. +Examples +======== + +The following examples have been written. + +Examples in ``src/energy/examples``: + +* ``basic-energy-model-test.cc``: Demonstrates the use of a Basic energy source with a Wifi radio model. +* ``generic-battery-discharge-example.cc``: Demonstrates the installation of battery energy sources. The output of this example shows the discharge curve of 5 different batteries. +* ``generic-battery-discharge-example.py``: A simplified version of the previous example but using python bindings. +* ``generic-battery-wifiradio-example.cc``: Demonstrates the use and installation of the Generic Battery Model with the WifiRadio model. +* ``rv-battery-model-test.cc``: Discharge example of a RV energy source model. + +Examples in ``examples/energy``: + +* ``energy-model-example.cc`` +* ``energy-model-with-harvesting-example.cc``: Shows the harvesting model usage. Only usable with basicEnergySources. + + +Tests +===== +The following tests have been written, which can be found in ``src/energy/tests/``: + Validation ********** -Comparison of the Energy Framework against actual devices have not -been performed. Current implementation of the Energy Framework is -checked numerically for computation errors. The RV battery model is -validated by comparing results with what was presented in the original -RV battery model paper. +The RV battery model is validated by comparing results with what was presented in the original RV battery model paper. The generic battery model is validated by superimposing the obtained discharge curves with manufacters's datasheets plots. The following shows the results of the ``generic-battery-discharge-example.cc`` superimposed to manufacter's datasheets charts: + + +.. _fig-leadacid: + +.. figure:: figures/leadacid.* + + Lead acid battery discharge curve (CSB GP1272) + +.. _fig-liion: + +.. figure:: figures/liion.* + + Li-Ion battery discharge curve (Panasonic CGR18650DA) + +.. _fig-nicd: + +.. figure:: figures/nicd.* + + NiCd battery discharge curve (Panasonic N-700AAC) + +.. _fig-nimh: + +.. figure:: figures/nimh.* + + NiMH battery discharge curve (Panasonic HHR650D) + + + +Scope and Limitations +===================== + +* In the ``GenericBatteryModel`` charging behavior (voltage as a function of SoC) is included but is not been thoroughly tested. Testing requires the implementation of a harvesting device (A charger) capable of providing a CCCV charging method typically used in batteries. +* In the ``GenericBatteryModel`` impedance (battery resistance) is constant, battery aging or temperature effects are not considered. +* The Rv battery model has some reported issues (See: issue #164) +* The harvesting mode can only be used with basic energy sources because it does not consider the current capacity or voltage of the battery. + +Future Work +=========== + +* Support of device energy models for PHY layers (lr-wpan, WiMax, etc) and other pieces of hardware (UAV, sensors, CPU). +* Support for realistical charging batteries in the ``GenericBatteryModule``. +* Support for device capable of charging batteries (e.g. chargers with CCCV capabilities). +* Implement an energy harvester that recharges the energy sources according to the power levels defined in a user customizable dataset of real measurements. + +References +========== + +Energy source models and energy consumption models: + +[`1 `_] H. Wu, S. Nabar and R. Poovendran. An Energy Framework for the Network Simulator 3 (ns-3). + +[2] M. Handy and D. Timmermann. Simulation of mobile wireless networks with accurate modelling of non-linear battery effects. In Proc. of Applied simulation and Modeling (ASM), 2003. + +[3] D. N. Rakhmatov and S. B. Vrudhula. An analytical high-level battery model for use in energy management of portable electronic systems. In Proc. of IEEE/ACM International Conference on Computer Aided Design (ICCAD'01), pages 488-493, November 2001. + +[4] D. N. Rakhmatov, S. B. Vrudhula, and D. A. Wallach. Battery lifetime prediction for energy-aware computing. In Proc. of the 2002 International Symposium on Low Power Electronics and Design (ISLPED'02), pages 154-159, 2002. + +[`5 `_] Olivier Tremblay and Louis-A. Dessaint. 2009. Experimental Validation of a Battery Dynamic Model for EV Applications. World Electric Vehicle Journal 3, 2 (2009), 289–298. https://doi.org/10.3390/wevj3020289 + +[`6 `_] Olivier Tremblay, Louis-A. Dessaint, and Abdel-Illah Dekkiche. 2007. A Generic Battery Model for the Dynamic Simulation of Hybrid Electric Vehicles. In 2007 IEEE Vehicle Power and Propulsion Conference. 284–289. https://doi.org/10.1109/VPPC.2007.4544139 + +[`7 `_] MatWorks SimuLink Generic Battery Model + +[8] C. M. Shepherd. 1965. Design of Primary and Secondary Cells: II . An Equation Describing Battery Discharge. Journal of The Electrochemical Society 112, 7 (jul 1965), 657. https://doi.org/10.1149/1.2423659 + +[`9 `_] Alberto Gallegos Ramonet, Alexander Guzman Urbina, and Kazuhiko Kinoshita. 2023. Evaluation and Extension of ns-3 Battery Framework. In Proceedings of the 2023 Workshop on ns-3 (WNS3 '23). Association for Computing Machinery, New York, NY, USA, 102–108. https://doi.org/10.1145/3592149.3592156 + + +Energy Harvesting Models: + +[10] C. Tapparello, H. Ayatollahi and W. Heinzelman. Extending the Energy Framework for Network Simulator 3 (ns-3). Workshop on ns-3 (WNS3), Poster Session, Atlanta, GA, USA. May, 2014. + +[11] C. Tapparello, H. Ayatollahi and W. Heinzelman. Energy Harvesting Framework for Network Simulator 3 (ns-3). 2nd International Workshop on Energy Neutral Sensing Systems (ENSsys), Memphis, TN, USA. November 6, 2014. + diff --git a/src/energy/doc/figures/dischargeCurve.png b/src/energy/doc/figures/dischargeCurve.png new file mode 100644 index 000000000..03a46adc5 Binary files /dev/null and b/src/energy/doc/figures/dischargeCurve.png differ diff --git a/src/energy/doc/figures/energyFramework.dia b/src/energy/doc/figures/energyFramework.dia new file mode 100644 index 000000000..fe0dd190c Binary files /dev/null and b/src/energy/doc/figures/energyFramework.dia differ diff --git a/src/energy/doc/figures/leadacid.png b/src/energy/doc/figures/leadacid.png new file mode 100644 index 000000000..3aa15f217 Binary files /dev/null and b/src/energy/doc/figures/leadacid.png differ diff --git a/src/energy/doc/figures/liion.png b/src/energy/doc/figures/liion.png new file mode 100644 index 000000000..a7f1315f3 Binary files /dev/null and b/src/energy/doc/figures/liion.png differ diff --git a/src/energy/doc/figures/nicd.png b/src/energy/doc/figures/nicd.png new file mode 100644 index 000000000..3a3acb281 Binary files /dev/null and b/src/energy/doc/figures/nicd.png differ diff --git a/src/energy/doc/figures/nimh.png b/src/energy/doc/figures/nimh.png new file mode 100644 index 000000000..7b4658dd3 Binary files /dev/null and b/src/energy/doc/figures/nimh.png differ diff --git a/src/energy/examples/CMakeLists.txt b/src/energy/examples/CMakeLists.txt index 8fa2b88f5..1644c8668 100644 --- a/src/energy/examples/CMakeLists.txt +++ b/src/energy/examples/CMakeLists.txt @@ -1,3 +1,22 @@ +build_lib_example( + NAME generic-battery-discharge-example + SOURCE_FILES generic-battery-discharge-example.cc + LIBRARIES_TO_LINK ${libcore} + ${libenergy} +) + +build_example( + NAME generic-battery-wifiradio-example + SOURCE_FILES generic-battery-wifiradio-example.cc + LIBRARIES_TO_LINK + ${libcore} + ${libconfig-store} + ${libenergy} + ${libinternet} + ${libmobility} + ${libwifi} +) + build_lib_example( NAME li-ion-energy-source-example SOURCE_FILES li-ion-energy-source-example.cc diff --git a/src/energy/examples/basic-energy-model-test.cc b/src/energy/examples/basic-energy-model-test.cc index 9763968e7..7221dfec5 100644 --- a/src/energy/examples/basic-energy-model-test.cc +++ b/src/energy/examples/basic-energy-model-test.cc @@ -91,35 +91,35 @@ BasicEnergyUpdateTest::DoRun() // run state switch tests if (StateSwitchTest(WifiPhyState::IDLE)) { - return 1; + return true; std::cerr << "Problem with state switch test (WifiPhy idle)." << std::endl; } if (StateSwitchTest(WifiPhyState::CCA_BUSY)) { - return 1; + return true; std::cerr << "Problem with state switch test (WifiPhy cca busy)." << std::endl; } if (StateSwitchTest(WifiPhyState::TX)) { - return 1; + return true; std::cerr << "Problem with state switch test (WifiPhy tx)." << std::endl; } if (StateSwitchTest(WifiPhyState::RX)) { - return 1; + return true; std::cerr << "Problem with state switch test (WifiPhy rx)." << std::endl; } if (StateSwitchTest(WifiPhyState::SWITCHING)) { - return 1; + return true; std::cerr << "Problem with state switch test (WifiPhy switching)." << std::endl; } if (StateSwitchTest(WifiPhyState::SLEEP)) { - return 1; + return true; std::cerr << "Problem with state switch test (WifiPhy sleep)." << std::endl; } - return 0; + return false; } bool @@ -302,7 +302,7 @@ BasicEnergyDepletionTest::DoRun() /* * Run simulation with different simulation time and update interval. */ - uint8_t ret = 0; + bool ret = false; for (double simTimeS = 0.0; simTimeS <= m_simTimeS; simTimeS += m_timeStepS) { @@ -311,7 +311,7 @@ BasicEnergyDepletionTest::DoRun() { if (DepletionTestCase(simTimeS, updateIntervalS)) { - ret = 1; + ret = true; std::cerr << "Depletion test case problem." << std::endl; } // reset callback count diff --git a/src/energy/examples/generic-battery-discharge-example.cc b/src/energy/examples/generic-battery-discharge-example.cc new file mode 100644 index 000000000..a5a3702a9 --- /dev/null +++ b/src/energy/examples/generic-battery-discharge-example.cc @@ -0,0 +1,565 @@ +/* + * Copyright (c) 2023 Tokushima University + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Alberto Gallegos Ramonet + */ + +#include +#include +#include + +#include +#include +#include + +using namespace ns3; + +/** + * This example shows the use of batteries in ns-3. + * 5 batteries of different chemistries are discharged + * using a constant current. Batteries can be configured + * manually using the necessary parameters or using + * presets. + * + * In this example, only the first battery uses parameters + * to form a NiMh battery. The rest of the batteries in this + * example use defined presets with already tested parameters. + * + * Users can make their own battery presets by setting + * the necessary parameters as in the example in the first + * battery. + * + * Plot files are produced as a result of this example. + * Graphs can be obtained from the plot using: + * + * $> gnuplot .plt + */ + +Gnuplot battDischPlot1 = Gnuplot("BattDisch1.eps"); +Gnuplot2dDataset battDischDataset1; +std::ofstream battDischFile1("BattDischCurve1.plt"); + +Gnuplot battDischPlot2 = Gnuplot("BattDisch2.eps"); +Gnuplot2dDataset battDischDataset2; +std::ofstream battDischFile2("BattDischCurve2.plt"); + +Gnuplot battDischPlot3 = Gnuplot("BattDisch3.eps"); +Gnuplot2dDataset battDischDataset3; +std::ofstream battDischFile3("BattDischCurve3.plt"); + +Gnuplot battDischPlot4 = Gnuplot("BattDisch4.eps"); +Gnuplot2dDataset battDischDataset4; +std::ofstream battDischFile4("BattDischCurve4.plt"); + +Gnuplot battDischPlot5 = Gnuplot("BattDisch5.eps"); +Gnuplot2dDataset battDischDataset5; +std::ofstream battDischFile5("BattDischCurve5.plt"); + +void +GraphBattery1(Ptr es) +{ + // NiMh battery Panasonic HHR650D NiMH + double cellVoltage = es->GetSupplyVoltage(); + Time currentTime = Simulator::Now(); + battDischDataset1.Add(currentTime.GetMinutes(), cellVoltage); + // battDischDataset1.Add(currentTime.GetHours(), cellVoltage); + + if (!Simulator::IsFinished()) + { + Simulator::Schedule(Seconds(20), &GraphBattery1, es); + } +} + +void +GraphBattery2(Ptr es) +{ + // CSB GP1272 Lead Acid + double cellVoltage = es->GetSupplyVoltage(); + Time currentTime = Simulator::Now(); + battDischDataset2.Add(currentTime.GetMinutes(), cellVoltage); + // battDischDataset2.Add(currentTime.GetHours(), cellVoltage); + + if (!Simulator::IsFinished()) + { + Simulator::Schedule(Seconds(20), &GraphBattery2, es); + } +} + +void +GraphBattery3(Ptr es) +{ + // Panasonic CGR18650DA Li-on + double cellVoltage = es->GetSupplyVoltage(); + double dischargeCapacityAh = es->GetDrainedCapacity(); + battDischDataset3.Add(dischargeCapacityAh * 1000, cellVoltage); + + if (!Simulator::IsFinished()) + { + Simulator::Schedule(Seconds(20), &GraphBattery3, es); + } +} + +void +GraphBattery4(Ptr es) +{ + // Rs Pro LGP12100 Lead Acid + double cellVoltage = es->GetSupplyVoltage(); + Time currentTime = Simulator::Now(); + battDischDataset4.Add(currentTime.GetMinutes(), cellVoltage); + // battDischDataset4.Add(currentTime.GetHours(), cellVoltage); + + if (!Simulator::IsFinished()) + { + Simulator::Schedule(Seconds(20), &GraphBattery4, es); + } +} + +void +GraphBattery5(Ptr es) +{ + // Panasonic N-700AAC NiCd + double cellVoltage = es->GetSupplyVoltage(); + Time currentTime = Simulator::Now(); + // battDischDataset5.Add(currentTime.GetMinutes(), cellVoltage); + battDischDataset5.Add(currentTime.GetHours(), cellVoltage); + + if (!Simulator::IsFinished()) + { + Simulator::Schedule(Seconds(20), &GraphBattery5, es); + } +} + +int +main(int argc, char** argv) +{ + CommandLine cmd(__FILE__); + cmd.Parse(argc, argv); + + LogComponentEnable("GenericBatteryModel", LOG_LEVEL_DEBUG); + + Ptr node; + GenericBatteryModelHelper batteryHelper; + Ptr batteryModel; + Ptr devicesEnergyModel; + + //////////////////////// PANASONIC HHR650D NiMH discharge 1C,2C,5C //////////////////// + + // Discharge 6.5A (1C) + battDischDataset1 = Gnuplot2dDataset("Panasonic NiMH HHR650D 6.5 A (1C)"); + + node = CreateObject(); + devicesEnergyModel = CreateObject(); + batteryModel = CreateObject(); + + batteryModel->SetAttribute("FullVoltage", DoubleValue(1.39)); // Vfull + batteryModel->SetAttribute("MaxCapacity", DoubleValue(7.0)); // Q + + batteryModel->SetAttribute("NominalVoltage", DoubleValue(1.18)); // Vnom + batteryModel->SetAttribute("NominalCapacity", DoubleValue(6.25)); // QNom + + batteryModel->SetAttribute("ExponentialVoltage", DoubleValue(1.28)); // Vexp + batteryModel->SetAttribute("ExponentialCapacity", DoubleValue(1.3)); // Qexp + + batteryModel->SetAttribute("InternalResistance", DoubleValue(0.0046)); // R + batteryModel->SetAttribute("TypicalDischargeCurrent", DoubleValue(1.3)); // i typical + batteryModel->SetAttribute("CutoffVoltage", DoubleValue(1.0)); // End of charge. + + // Capacity Ah(qMax) * (Vfull) voltage * 3600 = (7 * 1.39 * 3.6) = 35028 + batteryModel->SetAttribute("BatteryType", EnumValue(NIMH_NICD)); // Battery type + + // The Generic battery model allow users to simulate different types of + // batteries based on some parameters. However, presets of batteries are + // included in ns-3, for example, the previous battery values can be + // configured using a helper to set a NiMh battery preset: + + // batteryModel = DynamicCast + // (batteryHelper.Install(node,PANASONIC_HHR650D_NIMH)); + + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(6.5); + + GraphBattery1(batteryModel); + + battDischPlot1.AddDataset(battDischDataset1); + // 18717 secs around 5.3hrs, 750secs for 32.5 current, or (4200 70 mins) + Simulator::Stop(Seconds(3600)); + Simulator::Run(); + Simulator::Destroy(); + + // Discharge 13A (2C) + battDischDataset1 = Gnuplot2dDataset("Panasonic NiMH HHR650D 13 A (2C)"); + node = CreateObject(); + batteryModel = + DynamicCast(batteryHelper.Install(node, PANASONIC_HHR650D_NIMH)); + + devicesEnergyModel = CreateObject(); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(13); + + GraphBattery1(batteryModel); + + battDischPlot1.AddDataset(battDischDataset1); + Simulator::Stop(Seconds(1853)); + Simulator::Run(); + Simulator::Destroy(); + + // Discharge 32.5A (5C) + battDischDataset1 = Gnuplot2dDataset("Panasonic NiMH HHR650D 32.5 A (5C)"); + node = CreateObject(); + batteryModel = CreateObject(); + batteryModel = + DynamicCast(batteryHelper.Install(node, PANASONIC_HHR650D_NIMH)); + + devicesEnergyModel = CreateObject(); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(32.5); + + GraphBattery1(batteryModel); + battDischPlot1.AddDataset(battDischDataset1); + + Simulator::Stop(Seconds(716)); + Simulator::Run(); + Simulator::Destroy(); + + battDischPlot1.SetTerminal("postscript eps color enh \"Times-BoldItalic\""); + battDischPlot1.SetLegend(" Time (minutes)", "Voltage (V)"); + battDischPlot1.SetExtra("set xrange[0:70]\n\ + set yrange [0.8:1.8]\n\ + set xtics 10\n\ + set ytics 0.1\n\ + set grid\n\ + set style line 1 linewidth 5\n\ + set style line 2 linewidth 5\n\ + set style line 3 linewidth 5\n\ + set style line 4 linewidth 5\n\ + set style line 5 linewidth 5\n\ + set style line 6 linewidth 5\n\ + set style line 7 linewidth 5\n\ + set style line 8 linewidth 5\n\ + set style increment user\n\ + set key reverse Left"); + + battDischPlot1.GenerateOutput(battDischFile1); + battDischFile1.close(); + std::cout << "The end, plotting now\n"; + + //////////////////////// CSB GP1272 Lead Acid discharge 0.5C, 0.9C //////////// + + // Discharge 0.36A (0.05C) + battDischDataset2 = Gnuplot2dDataset("CSB GP1272 0.36 A (0.05C)"); + node = CreateObject(); + batteryModel = + DynamicCast(batteryHelper.Install(node, CSB_GP1272_LEADACID)); + + devicesEnergyModel = CreateObject(); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(0.36); + + GraphBattery2(batteryModel); + battDischPlot2.AddDataset(battDischDataset2); + + Simulator::Stop(Seconds(55000)); + Simulator::Run(); + Simulator::Destroy(); + + // Discharge 0.648A (0.09C) + battDischDataset2 = Gnuplot2dDataset("CSB GP1272 0.648 A (0.09C)"); + node = CreateObject(); + batteryModel = + DynamicCast(batteryHelper.Install(node, CSB_GP1272_LEADACID)); + + devicesEnergyModel = CreateObject(); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(0.648); + + GraphBattery2(batteryModel); + battDischPlot2.AddDataset(battDischDataset2); + + Simulator::Stop(Seconds(30000)); + Simulator::Run(); + Simulator::Destroy(); + + battDischPlot2.SetTerminal("postscript eps color enh \"Times-BoldItalic\""); + battDischPlot2.SetLegend(" Time (Minutes)", "Voltage (V)"); + battDischPlot2.SetExtra("set xrange[1:1800]\n\ + set yrange [7:14]\n\ + set logscale x \n\ + set tics scale 3\n\ + set xtics (1,2,3,5,10,20,30,60,120,180,300,600,1200,1800)\n\ + set ytics (0,8,9,10,11,12,13,14)\n\ + set grid\n\ + set style line 1 linewidth 5\n\ + set style line 2 linewidth 5\n\ + set style line 3 linewidth 5\n\ + set style line 4 linewidth 5\n\ + set style line 5 linewidth 5\n\ + set style line 6 linewidth 5\n\ + set style line 7 linewidth 5\n\ + set style line 8 linewidth 5\n\ + set style increment user\n\ + set key reverse Left"); + battDischPlot2.GenerateOutput(battDischFile2); + battDischFile2.close(); + std::cout << "The end, plotting now\n"; + + //////////////////////// Panasonic Li-on CGR18650DA, discharge 0.2C,1C,2C /////////// + + // Discharge 0.466A (0.2C) + battDischDataset3 = Gnuplot2dDataset("Panasonic Li-on CGR18650DA 0.466 A (0.2C)"); + node = CreateObject(); + batteryModel = + DynamicCast(batteryHelper.Install(node, PANASONIC_CGR18650DA_LION)); + + devicesEnergyModel = CreateObject(); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(0.466); + + GraphBattery3(batteryModel); + battDischPlot3.AddDataset(battDischDataset3); + + Simulator::Stop(Seconds(17720)); + Simulator::Run(); + Simulator::Destroy(); + + // Discharge 2.33A (1C) + battDischDataset3 = Gnuplot2dDataset("Panasonic Li-on CGR18650DA 2.33 A (1C)"); + node = CreateObject(); + batteryModel = + DynamicCast(batteryHelper.Install(node, PANASONIC_CGR18650DA_LION)); + + devicesEnergyModel = CreateObject(); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(2.33); + + GraphBattery3(batteryModel); + battDischPlot3.AddDataset(battDischDataset3); + + Simulator::Stop(Seconds(3528)); + Simulator::Run(); + Simulator::Destroy(); + + // Discharge 4.66A (2C) + battDischDataset3 = Gnuplot2dDataset("Panasonic Li-on CGR18650DA 4.66 A (2C)"); + node = CreateObject(); + batteryModel = + DynamicCast(batteryHelper.Install(node, PANASONIC_CGR18650DA_LION)); + + devicesEnergyModel = CreateObject(); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(4.66); + + GraphBattery3(batteryModel); + battDischPlot3.AddDataset(battDischDataset3); + + Simulator::Stop(Seconds(1744)); + Simulator::Run(); + Simulator::Destroy(); + + battDischPlot3.SetTerminal("postscript eps color enh \"Times-BoldItalic\""); + battDischPlot3.SetLegend(" Discharge Capacity (mAh)", "Voltage (V)"); + battDischPlot3.SetExtra("set xrange[0:2400]\n\ + set yrange [2.6:4.4]\n\ + set xtics 400\n\ + set ytics 0.2\n\ + set grid\n\ + set style line 1 linewidth 5\n\ + set style line 2 linewidth 5\n\ + set style line 3 linewidth 5\n\ + set style line 4 linewidth 5\n\ + set style line 5 linewidth 5\n\ + set style line 6 linewidth 5\n\ + set style line 7 linewidth 5\n\ + set style line 8 linewidth 5\n\ + set style increment user\n\ + set key reverse Left"); + battDischPlot3.GenerateOutput(battDischFile3); + battDischFile3.close(); + std::cout << "The end, plotting now\n"; + + //////////////////////// Rs PRO LGP12100 Lead Acid discharge 0.05C, 1C /////////////// + + // Discharge 0.36A (0.05C) + battDischDataset4 = Gnuplot2dDataset("Rs PRO LGP12100 5A (0.05C)"); + node = CreateObject(); + batteryModel = + DynamicCast(batteryHelper.Install(node, RSPRO_LGP12100_LEADACID)); + + devicesEnergyModel = CreateObject(); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(5); + + GraphBattery4(batteryModel); + battDischPlot4.AddDataset(battDischDataset4); + + Simulator::Stop(Seconds(65000)); + Simulator::Run(); + Simulator::Destroy(); + + // Discharge 100A (1C) + battDischDataset4 = Gnuplot2dDataset("Rs PRO LGP12100 100A (1C)"); + node = CreateObject(); + batteryModel = + DynamicCast(batteryHelper.Install(node, RSPRO_LGP12100_LEADACID)); + + devicesEnergyModel = CreateObject(); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(100); + + GraphBattery4(batteryModel); + battDischPlot4.AddDataset(battDischDataset4); + + Simulator::Stop(Seconds(2800)); + Simulator::Run(); + Simulator::Destroy(); + + battDischPlot4.SetTerminal("postscript eps color enh \"Times-BoldItalic\""); + battDischPlot4.SetLegend(" Time (Minutes)", "Voltage (V)"); + battDischPlot4.SetExtra("set xrange[1:1800]\n\ + set yrange [7:13]\n\ + set logscale \n\ + set tics scale 3\n\ + set xtics (1,2,4,6,8,10,20,40,60,120,240,360,480,600,1200)\n\ + set ytics (7,8,9,10,11,12,13)\n\ + set grid\n\ + set style line 1 linewidth 5\n\ + set style line 2 linewidth 5\n\ + set style line 3 linewidth 5\n\ + set style line 4 linewidth 5\n\ + set style line 5 linewidth 5\n\ + set style line 6 linewidth 5\n\ + set style line 7 linewidth 5\n\ + set style line 8 linewidth 5\n\ + set style increment user\n\ + set key reverse Left"); + battDischPlot4.GenerateOutput(battDischFile4); + battDischFile4.close(); + std::cout << "The end, plotting now\n"; + + //////////////////////// Panasonic N-700AAC NiCd discharge /////////////////////////// + + // Discharge 0.7A (0.1C) + battDischDataset5 = Gnuplot2dDataset("Panasonic N-700AAC 0.7A (0.01C)"); + node = CreateObject(); + batteryModel = + DynamicCast(batteryHelper.Install(node, PANASONIC_N700AAC_NICD)); + + devicesEnergyModel = CreateObject(); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(0.07); + + GraphBattery5(batteryModel); + battDischPlot5.AddDataset(battDischDataset5); + + Simulator::Stop(Seconds(38500)); + Simulator::Run(); + Simulator::Destroy(); + + // Discharge 0.14A (0.2C) + battDischDataset5 = Gnuplot2dDataset("Panasonic N-700AAC 0.14A (0.2C)"); + node = CreateObject(); + batteryModel = + DynamicCast(batteryHelper.Install(node, PANASONIC_N700AAC_NICD)); + + devicesEnergyModel = CreateObject(); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(0.14); + + GraphBattery5(batteryModel); + battDischPlot5.AddDataset(battDischDataset5); + + Simulator::Stop(Seconds(19200)); + Simulator::Run(); + Simulator::Destroy(); + + // Discharge 0.35A (0.5C) + battDischDataset5 = Gnuplot2dDataset("Panasonic N-700AAC 0.35A (0.5C)"); + node = CreateObject(); + batteryModel = + DynamicCast(batteryHelper.Install(node, PANASONIC_N700AAC_NICD)); + + devicesEnergyModel = CreateObject(); + devicesEnergyModel->SetEnergySource(batteryModel); + batteryModel->AppendDeviceEnergyModel(devicesEnergyModel); + devicesEnergyModel->SetNode(node); + + devicesEnergyModel->SetCurrentA(0.35); + + GraphBattery5(batteryModel); + battDischPlot5.AddDataset(battDischDataset5); + + Simulator::Stop(Seconds(7700)); + Simulator::Run(); + Simulator::Destroy(); + + battDischPlot5.SetTerminal("postscript eps color enh \"Times-BoldItalic\""); + battDischPlot5.SetLegend(" Time (Hours)", "Voltage (V)"); + battDischPlot5.SetExtra("set xrange[0:16]\n\ + set yrange [0.7:1.5]\n\ + set tics scale 3\n\ + set xtics 2\n\ + set ytics 0.1\n\ + set grid\n\ + set style line 1 linewidth 5\n\ + set style line 2 linewidth 5\n\ + set style line 3 linewidth 5\n\ + set style line 4 linewidth 5\n\ + set style line 5 linewidth 5\n\ + set style line 6 linewidth 5\n\ + set style line 7 linewidth 5\n\ + set style line 8 linewidth 5\n\ + set style increment user\n\ + set key reverse Left"); + battDischPlot5.GenerateOutput(battDischFile5); + battDischFile5.close(); + std::cout << "The end, plotting now\n"; + return 0; +} diff --git a/src/energy/examples/generic-battery-discharge-example.py b/src/energy/examples/generic-battery-discharge-example.py new file mode 100644 index 000000000..a6dfde1c9 --- /dev/null +++ b/src/energy/examples/generic-battery-discharge-example.py @@ -0,0 +1,70 @@ +# Copyright (c) 2023 Tokushima University +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation; +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Alberto Gallegos Ramonet +# + +# Panasonic HHR650D NiMh battery (single cell) +# Demonstrates the discharge behavior of a NIMH battery discharged with a +# constant current of 6.5 A (1C) + +from ns import ns + +def main(argv): + """The main function in this Battery discharge example + + Parameters: + argv: System parameters to use if necessary + """ + + ns.core.LogComponentEnable("GenericBatteryModel", ns.core.LOG_LEVEL_DEBUG) + + node = ns.network.Node() + batteryHelper = ns.energy.GenericBatteryModelHelper() + batteryModel = ns.CreateObject("GenericBatteryModel") + devicesEnergyModel = ns.energy.SimpleDeviceEnergyModel() + + batteryModel.SetAttribute("FullVoltage", ns.core.DoubleValue(1.39)) # Vfull + batteryModel.SetAttribute("MaxCapacity", ns.core.DoubleValue(7.0)) # Q + + batteryModel.SetAttribute("NominalVoltage", ns.core.DoubleValue(1.18)) # Vnom + batteryModel.SetAttribute("NominalCapacity", ns.core.DoubleValue(6.25)) # QNom + + batteryModel.SetAttribute("ExponentialVoltage", ns.core.DoubleValue(1.28)) # Vexp + batteryModel.SetAttribute("ExponentialCapacity", ns.core.DoubleValue(1.3)) # Qexp + + batteryModel.SetAttribute("InternalResistance", ns.core.DoubleValue(0.0046)) # R + batteryModel.SetAttribute("TypicalDischargeCurrent", ns.core.DoubleValue(1.3)) # i typical + batteryModel.SetAttribute("CutoffVoltage", ns.core.DoubleValue(1.0)) # End of charge. + + batteryModel.SetAttribute("BatteryType", ns.core.EnumValue(ns.NIMH_NICD)) # Battery type + + devicesEnergyModel.SetEnergySource(batteryModel) + batteryModel.AppendDeviceEnergyModel(devicesEnergyModel) + devicesEnergyModel.SetNode(node) + + devicesEnergyModel.SetCurrentA(6.5) + + + ns.core.Simulator.Stop(ns.core.Seconds(3600)) + ns.core.Simulator.Run() + ns.core.Simulator.Destroy() + + + +if __name__ == '__main__': + import sys + main(sys.argv) + diff --git a/src/energy/examples/generic-battery-wifiradio-example.cc b/src/energy/examples/generic-battery-wifiradio-example.cc new file mode 100644 index 000000000..2075676f2 --- /dev/null +++ b/src/energy/examples/generic-battery-wifiradio-example.cc @@ -0,0 +1,293 @@ +/* + * Copyright (c) 2023 Tokushima University, Japan + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Alberto Gallegos Ramonet + */ + +/* + * Node 1 <-------------- distanceToRx ------------> Node2 + * (SoC 89%) (SoC 95%) + * + * This example is based on the basic-energy-model-test created by He Wu. + * The objective is to demonstrate the use of a GenericBatteryModel with + * the WifiRadioEnergyModel. The WifiRadioEnergyModel was created to work + * specifically with the BasicEnergySource, therefore, the current example + * should be considered a prototype until WifiRadioEnergyModel can be + * revised and thoroughly tested with the GenericBatterySource. + * + * In the example, 2 wifi nodes are created each with a GenericBatterySource + * (Li-Ion battery type) is created with 4 cells (2 series, 2 parallel). + * The simulation runs for 3600 secs. Tx, Rx and Idle consumption values + * have been exaggerated for demonstration purposes. At the end of the simulation, + * the State of Charge (Soc %) and remaining capacity in Jouls for each node is + * displayed. + * + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace ns3; + +NS_LOG_COMPONENT_DEFINE("GenericBatteryWifiRadioExample"); + +/** + * Print a received packet + * + * \param from sender address + * \return a string with the details of the packet: dst {IP, port}, time. + */ +inline std::string +PrintReceivedPacket(Address& from) +{ + InetSocketAddress iaddr = InetSocketAddress::ConvertFrom(from); + + std::ostringstream oss; + oss << " Received one packet! Socket: " << iaddr.GetIpv4() << " port: " << iaddr.GetPort() + << "\n"; + + return oss.str(); +} + +/** + * \param socket Pointer to socket. + * + * Packet receiving sink. + */ +void +ReceivePacket(Ptr socket) +{ + Ptr packet; + Address from; + while ((packet = socket->RecvFrom(from))) + { + if (packet->GetSize() > 0) + { + NS_LOG_DEBUG(PrintReceivedPacket(from)); + } + } +} + +/** + * \param socket Pointer to socket. + * \param pktSize Packet size. + * \param n Pointer to node. + * \param pktCount Number of packets to generate. + * \param pktInterval Packet sending interval. + * + * Generate Traffic + */ +static void +GenerateTraffic(Ptr socket, + uint32_t pktSize, + Ptr n, + uint32_t pktCount, + Time pktInterval) +{ + if (pktCount > 0) + { + socket->Send(Create(pktSize)); + Simulator::Schedule(pktInterval, + &GenerateTraffic, + socket, + pktSize, + n, + pktCount - 1, + pktInterval); + } + else + { + socket->Close(); + } +} + +/** + * Trace function for remaining energy at node. + * + * \param oldValue Old value + * \param remainingEnergy New value + */ +void +RemainingEnergy(double oldValue, double remainingEnergy) +{ + NS_LOG_DEBUG(" Remaining energy Node 1 = " << remainingEnergy << " J"); +} + +int +main(int argc, char* argv[]) +{ + LogComponentEnableAll(LogLevel(LOG_PREFIX_TIME | LOG_PREFIX_FUNC)); + LogComponentEnable("GenericBatteryWifiRadioExample", LOG_LEVEL_DEBUG); + + std::string phyMode("DsssRate1Mbps"); + double rss = -80; // dBm + uint32_t packetSize = 200; // bytes + bool verbose = false; + + // simulation parameters + uint32_t numPackets = 10000; // number of packets to send + double interval = 1; // seconds + double startTime = 0.0; // seconds + double distanceToRx = 100.0; // meters + + CommandLine cmd(__FILE__); + cmd.AddValue("phyMode", "Wifi Phy mode", phyMode); + cmd.AddValue("rss", "Intended primary RSS (dBm)", rss); + cmd.AddValue("packetSize", "size of application packet sent (Bytes)", packetSize); + cmd.AddValue("numPackets", "Total number of packets to send", numPackets); + cmd.AddValue("startTime", "Simulation start time (seconds)", startTime); + cmd.AddValue("distanceToRx", "X-Axis distance between nodes (meters)", distanceToRx); + cmd.AddValue("verbose", "Turn on all device log components", verbose); + cmd.Parse(argc, argv); + + Time interPacketInterval = Seconds(interval); + + Config::SetDefault("ns3::WifiRemoteStationManager::FragmentationThreshold", + StringValue("2200")); + Config::SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue("2200")); + Config::SetDefault("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue(phyMode)); + + NodeContainer nodeContainer; + nodeContainer.Create(2); + + WifiHelper wifi; + if (verbose) + { + WifiHelper::EnableLogComponents(); + } + wifi.SetStandard(WIFI_STANDARD_80211b); + + //////////////////////// + // Wifi PHY and MAC // + //////////////////////// + + YansWifiPhyHelper wifiPhy; + YansWifiChannelHelper wifiChannel; + wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel"); + wifiChannel.AddPropagationLoss("ns3::FriisPropagationLossModel"); + + Ptr wifiChannelPtr = wifiChannel.Create(); + wifiPhy.SetChannel(wifiChannelPtr); + + WifiMacHelper wifiMac; + wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", + "DataMode", + StringValue(phyMode), + "ControlMode", + StringValue(phyMode)); + + wifiMac.SetType("ns3::AdhocWifiMac"); + NetDeviceContainer devices = wifi.Install(wifiPhy, wifiMac, nodeContainer); + + ////////////////// + // Mobility // + ////////////////// + + MobilityHelper mobility; + Ptr positionAlloc = CreateObject(); + positionAlloc->Add(Vector(0.0, 0.0, 0.0)); + positionAlloc->Add(Vector(2 * distanceToRx, 0.0, 0.0)); + mobility.SetPositionAllocator(positionAlloc); + mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel"); + mobility.Install(nodeContainer); + + ////////////////////// + // Energy Model // + ////////////////////// + + // Use a preset PANASONIC Li-Ion batteries arranged in a cell pack (2 series, 2 parallel) + GenericBatteryModelHelper batteryHelper; + EnergySourceContainer energySourceContainer = + batteryHelper.Install(nodeContainer, PANASONIC_CGR18650DA_LION); + batteryHelper.SetCellPack(energySourceContainer, 2, 2); + + Ptr battery0 = + DynamicCast(energySourceContainer.Get(0)); + Ptr battery1 = + DynamicCast(energySourceContainer.Get(1)); + + // Energy consumption quantities have been exaggerated for + // demonstration purposes, real consumption values are much smaller. + WifiRadioEnergyModelHelper radioEnergyHelper; + radioEnergyHelper.Set("TxCurrentA", DoubleValue(4.66)); + radioEnergyHelper.Set("RxCurrentA", DoubleValue(0.466)); + radioEnergyHelper.Set("IdleCurrentA", DoubleValue(0.466)); + DeviceEnergyModelContainer deviceModels = + radioEnergyHelper.Install(devices, energySourceContainer); + + ///////////////////// + // Internet stack // + ///////////////////// + + InternetStackHelper internet; + internet.Install(nodeContainer); + + Ipv4AddressHelper ipv4; + ipv4.SetBase("10.1.1.0", "255.255.255.0"); + Ipv4InterfaceContainer i = ipv4.Assign(devices); + + TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory"); + Ptr recvSink = Socket::CreateSocket(nodeContainer.Get(1), tid); // node 1, receiver + InetSocketAddress local = InetSocketAddress(Ipv4Address::GetAny(), 80); + recvSink->Bind(local); + recvSink->SetRecvCallback(MakeCallback(&ReceivePacket)); + + Ptr source = Socket::CreateSocket(nodeContainer.Get(0), tid); // node 0, sender + InetSocketAddress remote = InetSocketAddress(Ipv4Address::GetBroadcast(), 80); + source->SetAllowBroadcast(true); + source->Connect(remote); + + ///////////////////// + // Trace Sources // + ///////////////////// + + battery1->TraceConnectWithoutContext("RemainingEnergy", MakeCallback(&RemainingEnergy)); + + Ptr radioConsumptionModel = + battery1->FindDeviceEnergyModels("ns3::WifiRadioEnergyModel").Get(0); + + ///////////////////// + // Traffic Setup // + ///////////////////// + Simulator::Schedule(Seconds(startTime), + &GenerateTraffic, + source, + packetSize, + nodeContainer.Get(0), + numPackets, + interPacketInterval); + + Simulator::Stop(Seconds(3600)); + Simulator::Run(); + + NS_LOG_DEBUG(" *Remaining Capacity * " + << "| Node 0: " << battery0->GetRemainingEnergy() << " J " + << "| Node 1: " << battery1->GetRemainingEnergy() << " J"); + NS_LOG_DEBUG(" *SoC * " + << "| Node 0: " << battery0->GetStateOfCharge() << " % " + << "| Node 1: " << battery1->GetStateOfCharge() << " % "); + + Simulator::Destroy(); + + return 0; +} diff --git a/src/energy/helper/energy-harvester-container.cc b/src/energy/helper/energy-harvester-container.cc index 35d2d3b3e..b7bce1ae9 100644 --- a/src/energy/helper/energy-harvester-container.cc +++ b/src/energy/helper/energy-harvester-container.cc @@ -105,7 +105,7 @@ void EnergyHarvesterContainer::Add(EnergyHarvesterContainer container) { NS_LOG_FUNCTION(this << &container); - for (Iterator i = container.Begin(); i != container.End(); i++) + for (auto i = container.Begin(); i != container.End(); i++) { m_harvesters.push_back(*i); } @@ -143,9 +143,7 @@ void EnergyHarvesterContainer::DoDispose() { // call Object::Dispose for all EnergyHarvester objects - for (std::vector>::iterator i = m_harvesters.begin(); - i != m_harvesters.end(); - i++) + for (auto i = m_harvesters.begin(); i != m_harvesters.end(); i++) { (*i)->Dispose(); } @@ -156,9 +154,7 @@ void EnergyHarvesterContainer::DoInitialize() { // call Object::Initialize for all EnergyHarvester objects - for (std::vector>::iterator i = m_harvesters.begin(); - i != m_harvesters.end(); - i++) + for (auto i = m_harvesters.begin(); i != m_harvesters.end(); i++) { (*i)->Initialize(); } diff --git a/src/energy/helper/energy-harvester-helper.cc b/src/energy/helper/energy-harvester-helper.cc index afec5ffdf..35c269e16 100644 --- a/src/energy/helper/energy-harvester-helper.cc +++ b/src/energy/helper/energy-harvester-helper.cc @@ -43,8 +43,7 @@ EnergyHarvesterContainer EnergyHarvesterHelper::Install(EnergySourceContainer sourceContainer) const { EnergyHarvesterContainer container; - for (EnergySourceContainer::Iterator i = sourceContainer.Begin(); i != sourceContainer.End(); - ++i) + for (auto i = sourceContainer.Begin(); i != sourceContainer.End(); ++i) { Ptr harvester = DoInstall(*i); container.Add(harvester); diff --git a/src/energy/helper/energy-harvester-helper.h b/src/energy/helper/energy-harvester-helper.h index 5a8966906..3f2c57698 100644 --- a/src/energy/helper/energy-harvester-helper.h +++ b/src/energy/helper/energy-harvester-helper.h @@ -21,10 +21,11 @@ #ifndef ENERGY_HARVESTER_HELPER_H #define ENERGY_HARVESTER_HELPER_H +#include "energy-harvester-container.h" +#include "energy-source-container.h" + #include "ns3/attribute.h" -#include "ns3/energy-harvester-container.h" #include "ns3/energy-harvester.h" -#include "ns3/energy-source-container.h" #include "ns3/energy-source.h" #include "ns3/node-container.h" #include "ns3/object-factory.h" diff --git a/src/energy/helper/energy-model-helper.cc b/src/energy/helper/energy-model-helper.cc index 8325c03f7..3803db71b 100644 --- a/src/energy/helper/energy-model-helper.cc +++ b/src/energy/helper/energy-model-helper.cc @@ -42,7 +42,7 @@ EnergySourceContainer EnergySourceHelper::Install(NodeContainer c) const { EnergySourceContainer container; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr src = DoInstall(*i); container.Add(src); @@ -105,8 +105,8 @@ DeviceEnergyModelHelper::Install(NetDeviceContainer deviceContainer, { NS_ASSERT(deviceContainer.GetN() <= sourceContainer.GetN()); DeviceEnergyModelContainer container; - NetDeviceContainer::Iterator dev = deviceContainer.Begin(); - EnergySourceContainer::Iterator src = sourceContainer.Begin(); + auto dev = deviceContainer.Begin(); + auto src = sourceContainer.Begin(); while (dev != deviceContainer.End()) { // check to make sure source and net device are on the same node diff --git a/src/energy/helper/energy-source-container.cc b/src/energy/helper/energy-source-container.cc index b41f66d26..9794b146e 100644 --- a/src/energy/helper/energy-source-container.cc +++ b/src/energy/helper/energy-source-container.cc @@ -93,7 +93,7 @@ EnergySourceContainer::Get(uint32_t i) const void EnergySourceContainer::Add(EnergySourceContainer container) { - for (Iterator i = container.Begin(); i != container.End(); i++) + for (auto i = container.Begin(); i != container.End(); i++) { m_sources.push_back(*i); } @@ -122,7 +122,7 @@ void EnergySourceContainer::DoDispose() { // call Object::Dispose for all EnergySource objects - for (std::vector>::iterator i = m_sources.begin(); i != m_sources.end(); i++) + for (auto i = m_sources.begin(); i != m_sources.end(); i++) { (*i)->DisposeDeviceModels(); (*i)->Dispose(); @@ -134,7 +134,7 @@ void EnergySourceContainer::DoInitialize() { // call Object::Start for all EnergySource objects - for (std::vector>::iterator i = m_sources.begin(); i != m_sources.end(); i++) + for (auto i = m_sources.begin(); i != m_sources.end(); i++) { (*i)->Initialize(); (*i)->InitializeDeviceModels(); diff --git a/src/energy/helper/generic-battery-model-helper.cc b/src/energy/helper/generic-battery-model-helper.cc new file mode 100644 index 000000000..285b66d2f --- /dev/null +++ b/src/energy/helper/generic-battery-model-helper.cc @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2023 Tokushima University, Japan. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Alberto Gallegos Ramonet + */ + +#include "generic-battery-model-helper.h" + +namespace ns3 +{ + +GenericBatteryModelHelper::GenericBatteryModelHelper() +{ + m_batteryModel.SetTypeId("ns3::GenericBatteryModel"); +} + +GenericBatteryModelHelper::~GenericBatteryModelHelper() +{ +} + +void +GenericBatteryModelHelper::Set(std::string name, const AttributeValue& v) +{ + m_batteryModel.Set(name, v); +} + +Ptr +GenericBatteryModelHelper::DoInstall(Ptr node) const +{ + NS_ASSERT(node != nullptr); + Ptr energySource = m_batteryModel.Create(); + NS_ASSERT(energySource != nullptr); + energySource->SetNode(node); + return energySource; +} + +Ptr +GenericBatteryModelHelper::Install(NodeContainer c) const +{ + Ptr batteryContainer = CreateObject(); + for (auto i = c.Begin(); i != c.End(); i++) + { + batteryContainer->Add(DoInstall(*i)); + } + return batteryContainer; +} + +Ptr +GenericBatteryModelHelper::Install(Ptr node, BatteryModel bm) const +{ + NS_ASSERT(node != nullptr); + Ptr energySource = m_batteryModel.Create(); + NS_ASSERT(energySource != nullptr); + + energySource->SetAttribute("FullVoltage", DoubleValue(g_batteryPreset[bm].vFull)); + energySource->SetAttribute("MaxCapacity", DoubleValue(g_batteryPreset[bm].qMax)); + + energySource->SetAttribute("NominalVoltage", DoubleValue(g_batteryPreset[bm].vNom)); + energySource->SetAttribute("NominalCapacity", DoubleValue(g_batteryPreset[bm].qNom)); + + energySource->SetAttribute("ExponentialVoltage", DoubleValue(g_batteryPreset[bm].vExp)); + energySource->SetAttribute("ExponentialCapacity", DoubleValue(g_batteryPreset[bm].qExp)); + + energySource->SetAttribute("InternalResistance", + DoubleValue(g_batteryPreset[bm].internalResistance)); + energySource->SetAttribute("TypicalDischargeCurrent", + DoubleValue(g_batteryPreset[bm].typicalCurrent)); + energySource->SetAttribute("CutoffVoltage", DoubleValue(g_batteryPreset[bm].cuttoffVoltage)); + + energySource->SetAttribute("BatteryType", EnumValue(g_batteryPreset[bm].batteryType)); + + energySource->SetNode(node); + return energySource; +} + +EnergySourceContainer +GenericBatteryModelHelper::Install(NodeContainer c, BatteryModel bm) const +{ + EnergySourceContainer batteryContainer; + for (auto i = c.Begin(); i != c.End(); i++) + { + Ptr energySource = Install(*i, bm); + batteryContainer.Add(energySource); + } + return batteryContainer; +} + +void +GenericBatteryModelHelper::SetCellPack(Ptr energySource, + uint8_t series, + uint8_t parallel) const +{ + NS_ASSERT_MSG(series > 0, "The value of cells in series must be > 0"); + NS_ASSERT_MSG(parallel > 0, "The value of cells in parallel must be > 0"); + NS_ASSERT(energySource != nullptr); + + DoubleValue vFull; + DoubleValue q; + DoubleValue vExp; + DoubleValue qExp; + DoubleValue vNom; + DoubleValue qNom; + DoubleValue r; + + // Get the present values of the battery cell + energySource->GetAttribute("FullVoltage", vFull); + energySource->GetAttribute("MaxCapacity", q); + + energySource->GetAttribute("NominalVoltage", vNom); + energySource->GetAttribute("NominalCapacity", qNom); + + energySource->GetAttribute("ExponentialVoltage", vExp); + energySource->GetAttribute("ExponentialCapacity", qExp); + + energySource->GetAttribute("InternalResistance", r); + + // Configuring the Cell packs + energySource->SetAttribute("FullVoltage", DoubleValue(vFull.Get() * series)); + energySource->SetAttribute("MaxCapacity", DoubleValue(q.Get() * parallel)); + + energySource->SetAttribute("NominalVoltage", DoubleValue(vNom.Get() * series)); + energySource->SetAttribute("NominalCapacity", DoubleValue(qNom.Get() * parallel)); + + energySource->SetAttribute("ExponentialVoltage", DoubleValue(vExp.Get() * series)); + energySource->SetAttribute("ExponentialCapacity", DoubleValue(qExp.Get() * parallel)); + + energySource->SetAttribute("InternalResistance", DoubleValue(r.Get() * (series / parallel))); +} + +void +GenericBatteryModelHelper::SetCellPack(EnergySourceContainer energySourceContainer, + uint8_t series, + uint8_t parallel) const +{ + NS_ASSERT_MSG(energySourceContainer.GetN() > 0, "This energy container is empty"); + + for (auto i = energySourceContainer.Begin(); i != energySourceContainer.End(); i++) + { + SetCellPack(*i, series, parallel); + } +} + +} // namespace ns3 diff --git a/src/energy/helper/generic-battery-model-helper.h b/src/energy/helper/generic-battery-model-helper.h new file mode 100644 index 000000000..fe6440d3c --- /dev/null +++ b/src/energy/helper/generic-battery-model-helper.h @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2023 Tokushima University, Japan. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Alberto Gallegos Ramonet + */ + +#ifndef GENERIC_BATTERY_MODEL_HELPER_H_ +#define GENERIC_BATTERY_MODEL_HELPER_H_ + +#include "energy-model-helper.h" + +#include +#include + +namespace ns3 +{ + +/** + * \ingroup energy + * \brief Creates and assign an assortment of BatteryModels to Nodes. + * + */ +class GenericBatteryModelHelper : public EnergySourceHelper +{ + public: + GenericBatteryModelHelper(); + ~GenericBatteryModelHelper() override; + + /** + * Sets one of the attributes of underlying EnergySource. + * + * \param name Name of attribute to set. + * \param v Value of the attribute. + */ + void Set(std::string name, const AttributeValue& v) override; + + /** + * This function installs energy sources in a group of nodes in a + * node container. An energy source (Li-Ion battery) with default values + * is used on each node. + * + * \param c The node container + * \returns An EnergySourceContainer which contains all the EnergySources. + */ + Ptr Install(NodeContainer c) const; + + /** + * This function installs an energy source (battery) into a node. + * + * \param node The node object. + * \param bm The battery model that will be install to the node. + * \returns A pointer to the energy source object used. + */ + Ptr Install(Ptr node, BatteryModel bm) const; + + /** + * This function installs energy sources in a group of nodes in a + * node container. + * + * \param c The node container. + * \param bm The battery model that will be install to the nodes in the node container. + * \returns An EnergySourceContainer which contains all the EnergySources. + */ + EnergySourceContainer Install(NodeContainer c, BatteryModel bm) const; + + /** + * This function takes an existing energy source and transform its values to form + * a group of connected identical cells. The values of the newly formed cell block + * depends on the connection of the cells defined by the user + * (number of cells connected in series, number of cells connected in parallel). + * + * \param energySource The energy source used. + * \param series The number of cells connected in series. + * \param parallel The number of cells connected in parallel. + */ + void SetCellPack(Ptr energySource, uint8_t series, uint8_t parallel) const; + + /** + * This function takes an existing energy source container and transform the values + * of each of its containing energy sources to form groups of connected identical cells. + * The values of the newly formed cell blocks for each energy source + * depends on the connection of the cells defined by the user + * (number of cells connected in series, number of cells connected in parallel). + * + * \param energySourceContainer The energy source container used. + * \param series The number of cells connected in series. + * \param parallel The number of cells connected in parallel. + */ + void SetCellPack(EnergySourceContainer energySourceContainer, + uint8_t series, + uint8_t parallel) const; + + private: + /** + * Child classes of EnergySourceHelper only have to implement this function, + * to create and aggregate an EnergySource object onto a single node. Rest of + * the installation process (eg. installing EnergySource on set of nodes) is + * implemented in the EnergySourceHelper base class. + * + * \param node Pointer to node where the energy source is to be installed. + * \returns Pointer to the created EnergySource. + */ + Ptr DoInstall(Ptr node) const override; + + private: + ObjectFactory m_batteryModel; //!< The energy source (battery) used by this helper. +}; + +} // namespace ns3 + +#endif /* GENERIC_BATTERY_MODEL_HELPER_H_ */ diff --git a/src/energy/model/basic-energy-harvester.h b/src/energy/model/basic-energy-harvester.h index 341e04c03..02267c058 100644 --- a/src/energy/model/basic-energy-harvester.h +++ b/src/energy/model/basic-energy-harvester.h @@ -21,17 +21,16 @@ #ifndef BASIC_ENERGY_HARVESTER #define BASIC_ENERGY_HARVESTER -#include - -// include from ns-3 +#include "device-energy-model.h" #include "energy-harvester.h" -#include "ns3/device-energy-model.h" #include "ns3/event-id.h" #include "ns3/nstime.h" #include "ns3/random-variable-stream.h" #include "ns3/traced-value.h" +#include + namespace ns3 { diff --git a/src/energy/model/device-energy-model-container.cc b/src/energy/model/device-energy-model-container.cc index 05208f7d0..a1a5579b6 100644 --- a/src/energy/model/device-energy-model-container.cc +++ b/src/energy/model/device-energy-model-container.cc @@ -89,7 +89,7 @@ void DeviceEnergyModelContainer::Add(DeviceEnergyModelContainer container) { NS_LOG_FUNCTION(this << &container); - for (Iterator i = container.Begin(); i != container.End(); i++) + for (auto i = container.Begin(); i != container.End(); i++) { m_models.push_back(*i); } diff --git a/src/energy/model/device-energy-model-container.h b/src/energy/model/device-energy-model-container.h index 40409e5d2..3804b4fe1 100644 --- a/src/energy/model/device-energy-model-container.h +++ b/src/energy/model/device-energy-model-container.h @@ -22,7 +22,7 @@ #ifndef DEVICE_ENERGY_MODEL_CONTAINER_H #define DEVICE_ENERGY_MODEL_CONTAINER_H -#include "ns3/device-energy-model.h" +#include "device-energy-model.h" #include #include diff --git a/src/energy/model/energy-source.cc b/src/energy/model/energy-source.cc index 84d426539..ba517a9e3 100644 --- a/src/energy/model/energy-source.cc +++ b/src/energy/model/energy-source.cc @@ -22,7 +22,8 @@ * Modifications made by: Cristiano Tapparello */ -#include +#include "energy-source.h" + #include namespace ns3 @@ -171,8 +172,7 @@ EnergySource::CalculateTotalCurrent() { double totalHarvestedPower = 0.0; - std::vector>::const_iterator harvester; - for (harvester = m_harvesters.begin(); harvester != m_harvesters.end(); harvester++) + for (auto harvester = m_harvesters.begin(); harvester != m_harvesters.end(); harvester++) { totalHarvestedPower += (*harvester)->GetPower(); } diff --git a/src/energy/model/energy-source.h b/src/energy/model/energy-source.h index a86dab7fe..3f0c2ea9c 100644 --- a/src/energy/model/energy-source.h +++ b/src/energy/model/energy-source.h @@ -26,8 +26,8 @@ #define ENERGY_SOURCE_H #include "device-energy-model-container.h" // #include "device-energy-model.h" +#include "energy-harvester.h" -#include "ns3/energy-harvester.h" #include "ns3/node.h" #include "ns3/object.h" #include "ns3/ptr.h" diff --git a/src/energy/model/generic-battery-model.cc b/src/energy/model/generic-battery-model.cc new file mode 100644 index 000000000..35e1b5b74 --- /dev/null +++ b/src/energy/model/generic-battery-model.cc @@ -0,0 +1,438 @@ +/* + * Copyright (c) 2010 Andrea Sacco: Li-Ion battery + * Copyright (c) 2023 Tokushima University, Japan: + * NiMh,NiCd,LeaAcid batteries and preset and multicell extensions. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Andrea Sacco + * Alberto Gallegos Ramonet + */ + +#include "generic-battery-model.h" + +#include +#include +#include +#include +#include + +#include + +namespace ns3 +{ + +NS_LOG_COMPONENT_DEFINE("GenericBatteryModel"); + +NS_OBJECT_ENSURE_REGISTERED(GenericBatteryModel); + +TypeId +GenericBatteryModel::GetTypeId() +{ + static TypeId tid = + TypeId("ns3::GenericBatteryModel") + .SetParent() + .SetGroupName("Energy") + .AddConstructor() + .AddAttribute("LowBatteryThreshold", + "Low battery threshold for generic battery model.", + DoubleValue(0.10), // 0.10 as a fraction of the initial energy + MakeDoubleAccessor(&GenericBatteryModel::m_lowBatteryTh), + MakeDoubleChecker()) + .AddAttribute("FullVoltage", + "(Q_full) The voltage of the cell when fully charged (V).", + DoubleValue(4.18), + MakeDoubleAccessor(&GenericBatteryModel::m_vFull), + MakeDoubleChecker()) + .AddAttribute("MaxCapacity", + "(Q) The maximum capacity of the cell (Ah).", + DoubleValue(2.45), + MakeDoubleAccessor(&GenericBatteryModel::m_qMax), + MakeDoubleChecker()) + .AddAttribute("NominalVoltage", + "(V_nom) Nominal voltage of the cell (V).", + DoubleValue(3.59), + MakeDoubleAccessor(&GenericBatteryModel::m_vNom), + MakeDoubleChecker()) + .AddAttribute("NominalCapacity", + "(Q_nom) Cell capacity at the end of the nominal zone (Ah)", + DoubleValue(1.3), + MakeDoubleAccessor(&GenericBatteryModel::m_qNom), + MakeDoubleChecker()) + .AddAttribute("ExponentialVoltage", + "(V_exp) Cell voltage at the end of the exponential zone (V).", + DoubleValue(3.75), + MakeDoubleAccessor(&GenericBatteryModel::m_vExp), + MakeDoubleChecker()) + .AddAttribute("ExponentialCapacity", + "(Q_exp) Cell Capacity at the end of the exponential zone (Ah).", + DoubleValue(0.39), + MakeDoubleAccessor(&GenericBatteryModel::m_qExp), + MakeDoubleChecker()) + .AddAttribute("InternalResistance", + "(R) Internal resistance of the cell (Ohms)", + DoubleValue(0.083), + MakeDoubleAccessor(&GenericBatteryModel::m_internalResistance), + MakeDoubleChecker()) + .AddAttribute("TypicalDischargeCurrent", + "Typical discharge current used in manufacters datasheets (A)", + DoubleValue(2.33), + MakeDoubleAccessor(&GenericBatteryModel::m_typicalCurrent), + MakeDoubleChecker()) + .AddAttribute("CutoffVoltage", + "The voltage where the battery is considered depleted (V).", + DoubleValue(3.3), + MakeDoubleAccessor(&GenericBatteryModel::m_cutoffVoltage), + MakeDoubleChecker()) + .AddAttribute("PeriodicEnergyUpdateInterval", + "Time between two consecutive periodic energy updates.", + TimeValue(Seconds(1.0)), + MakeTimeAccessor(&GenericBatteryModel::SetEnergyUpdateInterval, + &GenericBatteryModel::GetEnergyUpdateInterval), + MakeTimeChecker()) + .AddAttribute("BatteryType", + "Indicates the battery type used by the model", + EnumValue(LION_LIPO), + MakeEnumAccessor(&GenericBatteryModel::m_batteryType), + MakeEnumChecker(LION_LIPO, + "LION_LIPO", + NIMH_NICD, + "NIMH_NICD", + LEADACID, + "LEADACID")) + .AddTraceSource("RemainingEnergy", + "Remaining energy of generic battery", + MakeTraceSourceAccessor(&GenericBatteryModel::m_remainingEnergyJ), + "ns3::TracedValueCallback::Double"); + return tid; +} + +GenericBatteryModel::GenericBatteryModel() + : m_drainedCapacity(0), + m_currentFiltered(0), + m_entn(0), + m_expZone(0), + m_lastUpdateTime(Seconds(0.0)) +{ + NS_LOG_FUNCTION(this); +} + +GenericBatteryModel::~GenericBatteryModel() +{ + NS_LOG_FUNCTION(this); +} + +double +GenericBatteryModel::GetInitialEnergy() const +{ + double initialEnergy = m_qMax * m_vFull * 3600; + return initialEnergy; +} + +double +GenericBatteryModel::GetSupplyVoltage() const +{ + return m_supplyVoltageV; +} + +void +GenericBatteryModel::SetEnergyUpdateInterval(Time interval) +{ + NS_LOG_FUNCTION(this << interval); + m_energyUpdateInterval = interval; +} + +void +GenericBatteryModel::SetDrainedCapacity(double drainedCapacity) +{ + NS_ASSERT(drainedCapacity >= 0 && drainedCapacity < m_qMax); + m_drainedCapacity = drainedCapacity; +} + +double +GenericBatteryModel::GetDrainedCapacity() const +{ + return m_drainedCapacity; +} + +double +GenericBatteryModel::GetStateOfCharge() const +{ + double soc = 100 * (1 - m_drainedCapacity / m_qMax); + return soc; +} + +Time +GenericBatteryModel::GetEnergyUpdateInterval() const +{ + NS_LOG_FUNCTION(this); + return m_energyUpdateInterval; +} + +double +GenericBatteryModel::GetRemainingEnergy() +{ + NS_LOG_FUNCTION(this); + UpdateEnergySource(); + return m_remainingEnergyJ; +} + +double +GenericBatteryModel::GetEnergyFraction() +{ + NS_LOG_FUNCTION(this); + return GetStateOfCharge(); +} + +void +GenericBatteryModel::UpdateEnergySource() +{ + NS_LOG_FUNCTION(this); + + // do not update if simulation has finished + if (Simulator::IsFinished()) + { + return; + } + + m_energyUpdateEvent.Cancel(); + + CalculateRemainingEnergy(); + + m_lastUpdateTime = Simulator::Now(); + + if (m_supplyVoltageV <= m_cutoffVoltage) + { + // check if battery is depleted + BatteryDepletedEvent(); + } + else if (m_supplyVoltageV >= m_vFull) + { + // check if battery has reached full charge + BatteryChargedEvent(); + // TODO: Should battery charging be stopped if full voltage is reached? + // or should it be allowed to continue charging (overcharge)? + } + + m_energyUpdateEvent = + Simulator::Schedule(m_energyUpdateInterval, &GenericBatteryModel::UpdateEnergySource, this); +} + +void +GenericBatteryModel::DoInitialize() +{ + NS_LOG_FUNCTION(this); +} + +void +GenericBatteryModel::DoDispose() +{ + NS_LOG_FUNCTION(this); + BreakDeviceEnergyModelRefCycle(); +} + +void +GenericBatteryModel::BatteryDepletedEvent() +{ + NS_LOG_FUNCTION(this); + // notify DeviceEnergyModel objects, all "usable" energy has been depleted + // (cutoff voltage was reached) + NotifyEnergyDrained(); +} + +void +GenericBatteryModel::BatteryChargedEvent() +{ + NS_LOG_FUNCTION(this); + // notify DeviceEnergyModel objects, the battery has reached its full energy potential. + // (full voltage was reached) + NotifyEnergyRecharged(); +} + +void +GenericBatteryModel::CalculateRemainingEnergy() +{ + NS_LOG_FUNCTION(this); + + double totalCurrentA = CalculateTotalCurrent(); + + m_energyUpdateLapseTime = Simulator::Now() - m_lastUpdateTime; + + NS_ASSERT(m_energyUpdateLapseTime.GetSeconds() >= 0); + + // Calculate i* (current step response) + Time batteryResponseConstant = Seconds(30); + + double responseTime = (Simulator::Now() / batteryResponseConstant).GetDouble(); + m_currentFiltered = totalCurrentA * (1 - 1 / (std::exp(responseTime))); + // TODO: the time in the responseTime should be a time taken since the last *battery current* + // change, in the testing the battery current is only changed at the beginning of the + // simulation therefore, the simulation time can be used. However this must be changed to + // a time counter to allow this value to reset in the middle of the simulation when the + // battery current changes. + + m_drainedCapacity += (totalCurrentA * m_energyUpdateLapseTime).GetHours(); + + if (totalCurrentA < 0) + { + // Charge current (Considered as "Negative" i) + m_supplyVoltageV = GetChargeVoltage(totalCurrentA); + } + else + { + // Discharge current (Considered as "Positive" i) + m_supplyVoltageV = GetVoltage(totalCurrentA); + } +} + +double +GenericBatteryModel::GetChargeVoltage(double i) +{ + // integral of i over time drained capacity in Ah + double it = m_drainedCapacity; + + // empirical factors + double A = m_vFull - m_vExp; + double B = 3 / m_qExp; + + // voltage constant + double E0 = m_vFull + m_internalResistance * m_typicalCurrent - A; + + // voltage of exponential zone when battery is fully charged + double expZoneFull = A * std::exp(-B * m_qNom); + + // Obtain the voltage|resistance polarization constant + double K = (E0 - m_vNom - (m_internalResistance * m_typicalCurrent) + expZoneFull) / + (m_qMax / (m_qMax - m_qNom) * (m_qNom + m_typicalCurrent)); + + double V = 0; + double polResistance = 0; + double polVoltage = 0; + + if (m_batteryType == LION_LIPO) + { // For LiOn & LiPo batteries + + // Calculate exponential zone voltage + m_expZone = A * std::exp(-B * it); + + polResistance = K * m_qMax / (it + 0.1 * m_qMax); + polVoltage = K * m_qMax / (m_qMax - it); + V = E0 - (m_internalResistance * i) - (polResistance * m_currentFiltered) - + (polVoltage * it) + m_expZone; + } + else + { + // Calculate exponential zone voltage + + if (m_expZone == 0) + { + m_expZone = A * std::exp(-B * it); + } + double entnPrime = m_entn; + double expZonePrime = m_expZone; + m_entn = B * std::abs(i) * (-expZonePrime + A); + m_expZone = expZonePrime + (m_energyUpdateLapseTime * entnPrime).GetHours(); + + if (m_batteryType == NIMH_NICD) + { // For NiMH and NiCd batteries + polResistance = K * m_qMax / (std::abs(it) + 0.1 * m_qMax); + } + else if (m_batteryType == LEADACID) + { // For Lead acid batteries + polResistance = K * m_qMax / (it + 0.1 * m_qMax); + } + + polVoltage = K * m_qMax / (m_qMax - it); + + V = E0 - (m_internalResistance * i) - (polResistance * m_currentFiltered) - + (polVoltage * it) + m_expZone; + } + + // Energy in Joules = RemainingCapacity * Voltage * Seconds in an Hour + m_remainingEnergyJ = (m_qMax - it) * V * 3600; + + NS_LOG_DEBUG("* CHARGE *| " << Simulator::Now().As(Time::S) << "| i " << i << " | it " << it + << "| E0 " << E0 << " | polRes " << polResistance << " | polVol " + << polVoltage << "| B " << B << " | ExpZone " << m_expZone + << " | A " << A << "| K " << K << "| i* " << m_currentFiltered + << " | V " << V << " | rmnEnergy " << m_remainingEnergyJ + << "J | SoC " << GetStateOfCharge() << "% "); + + return V; +} + +double +GenericBatteryModel::GetVoltage(double i) +{ + NS_LOG_FUNCTION(this << i); + + // integral of i in dt, drained capacity in Ah + double it = m_drainedCapacity; + + // empirical factors + double A = m_vFull - m_vExp; + + double B = 3 / m_qExp; + + // constant voltage + double E0 = m_vFull + m_internalResistance * m_typicalCurrent - A; + + // voltage of exponential zone when battery is fully charged + double expZoneFull = A * std::exp(-B * m_qNom); + + // Obtain the voltage|resistance polarization constant + double K = (E0 - m_vNom - (m_internalResistance * m_typicalCurrent) + expZoneFull) / + (m_qMax / (m_qMax - m_qNom) * (m_qNom + m_typicalCurrent)); + + double V = 0; + double polResistance = K * (m_qMax / (m_qMax - it)); + double polVoltage = polResistance; + + // Calculate exponential zone voltage according to the battery type + if (m_batteryType == LION_LIPO) + { + m_expZone = A * exp(-B * it); + } + else + { + NS_ASSERT(m_batteryType == NIMH_NICD || m_batteryType == LEADACID); + if (m_expZone == 0) + { + m_expZone = A * exp(-B * it); + } + + double entnPrime = m_entn; + double expZonePrime = m_expZone; + + m_entn = B * std::abs(i) * (-expZonePrime); + m_expZone = expZonePrime + (m_energyUpdateLapseTime * entnPrime).GetHours(); + } + + V = E0 - (m_internalResistance * i) - (polResistance * m_currentFiltered) - (polVoltage * it) + + m_expZone; + + // EnergyJ = RemainingCapacity * Voltage * Seconds in an Hour + m_remainingEnergyJ = (m_qMax - it) * V * 3600; + + NS_LOG_DEBUG("* DISCHARGE *| " << Simulator::Now().As(Time::S) << "| i " << i << " | it " << it + << " | A " << A << " | B " << B << " | ExpZone " << m_expZone + << " | V " << V << " | rmnEnergy " << m_remainingEnergyJ + << "J | SoC " << GetStateOfCharge() << "% " + << "\n" + << " | K " << K << " | E0 " << E0); + + return V; +} + +} // namespace ns3 diff --git a/src/energy/model/generic-battery-model.h b/src/energy/model/generic-battery-model.h new file mode 100644 index 000000000..61731f52c --- /dev/null +++ b/src/energy/model/generic-battery-model.h @@ -0,0 +1,314 @@ +/* + * Copyright (c) 2010 Andrea Sacco: Li-Ion battery + * Copyright (c) 2023 Tokushima University, Japan: + * NiMh,NiCd,LeaAcid batteries and preset and multi-cell extensions. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Andrea Sacco + * Alberto Gallegos Ramonet + */ + +#ifndef GENERIC_BATTERY_MODEL_H +#define GENERIC_BATTERY_MODEL_H + +#include "energy-source.h" + +#include +#include +#include + +namespace ns3 +{ + +/** + * \ingroup energy + * + * Battery types. + * These are grouped according to their chemical characteristics + * present during a charge/discharge curve. + */ +enum GenericBatteryType +{ + LION_LIPO = 0, //!< Lithium-ion and Lithium-polymer batteries + NIMH_NICD = 1, //!< Nickel-metal hydride and Nickel cadmium batteries + LEADACID = 2 //!< Lead Acid Batteries +}; + +/** + * \ingroup energy + * + * Battery models that described the parameters of the the battery presets. + */ +enum BatteryModel +{ + PANASONIC_HHR650D_NIMH = 0, //!< Panasonic HHR650D NiMh battery + CSB_GP1272_LEADACID = 1, //!< CSB GP1272 Lead acid battery + PANASONIC_CGR18650DA_LION = 2, //!< Panasonic CGR18650DA Li-Ion battery + RSPRO_LGP12100_LEADACID = 3, //!< RS Pro LGP12100 Lead acid battery + PANASONIC_N700AAC_NICD = 4 //!< Panasonic N700AAC NiCd battery +}; + +/** + * \ingroup energy + * + * The structure containing the the parameter values that describe a + * battery preset. + */ +struct BatteryPresets +{ + GenericBatteryType batteryType; //!< The type of battery used in the preset. + std::string description; //!< Additional information about the battery. + double vFull; //!< Initial voltage of the battery, in Volts + double qMax; //!< The maximum capacity of the battery, in Ah + double vNom; //!< Nominal voltage of the battery, in Volts + double qNom; //!< Battery capacity at the end of the nominal zone, in Ah + double vExp; //!< Battery voltage at the end of the exponential zone, in Volts + double qExp; //!< Capacity value at the end of the exponential zone, in Ah + double internalResistance; //!< Internal resistance of the battery, in Ohms + double typicalCurrent; //!< Typical discharge current used to fit the curves + double cuttoffVoltage; //!< The threshold voltage where the battery is considered depleted +}; + +/** + * \ingroup energy + * + * Contains the values that form the battery presents available in this module. + */ +static BatteryPresets g_batteryPreset[] = {{NIMH_NICD, + "Panasonic HHR650D | NiMH | 1.2V 6.5Ah | Size: D", + 1.39, + 7.0, + 1.18, + 6.25, + 1.28, + 1.3, + 0.0046, + 1.3, + 1.0}, + {LEADACID, + "CSB GP1272 | Lead Acid | 12V 7.2Ah", + 12.8, + 7.2, + 11.5, + 4.5, + 12.5, + 2, + 0.056, + 0.36, + 8.0}, + {LION_LIPO, + "Panasonic CGR18650DA | Li-Ion | 3.6V 2.45Ah | Size: A", + 4.17, + 2.33, + 3.57, + 2.14, + 3.714, + 1.74, + 0.0830, + 0.466, + 3.0}, + {LEADACID, + "Rs PRO LGP12100 | Lead Acid | 12V 100Ah", + 12.60, + 130, + 12.44, + 12.3, + 12.52, + 12, + 0.00069, + 5, + 11}, + {NIMH_NICD, + "PANASONIC N-700AAC | NiCd | 1.2V 700mAh | Size: AA", + 1.38, + 0.790, + 1.17, + 0.60, + 1.25, + 0.24, + 0.016, + 0.7, + 0.8}}; + +/** + * \ingroup energy + * \brief A generic battery model for Li-Ion, NiCd, NiMh and Lead acid batteries + * + * The generic battery model can be used to describe the discharge behavior of + * the battery chemestries supported by the model. + */ +class GenericBatteryModel : public EnergySource +{ + public: + /** + * \brief Get the type ID. + * \return The object TypeId. + */ + static TypeId GetTypeId(); + + GenericBatteryModel(); + + ~GenericBatteryModel() override; + + /** + * Implements GetInitialEnergy. It returns the amount of energy in Joules stored in the + * battery when fully charged. This energy is different to the total amount of usable energy + * in the battery. This is because the battery cannot be used until Voltage = 0, only until + * it reaches the cutoff voltage. + * + * \return The initial energy stored in the fully charged battery, in Joules. + */ + double GetInitialEnergy() const override; + + /** + * Implements GetSupplyVoltage. + * + * \return Supply voltage at the energy source. + */ + double GetSupplyVoltage() const override; + + /** + * Implements GetRemainingEnergy. + * + * \return Remaining energy in energy source, in Joules + */ + double GetRemainingEnergy() override; + + /** + * Implements GetEnergyFraction. For the generic battery model, energy fraction + * is equivalent to the remaining usable capacity (i.e. The SoC). + * + * \return Energy fraction. + */ + double GetEnergyFraction() override; + + /** + * Implements UpdateEnergySource. + */ + void UpdateEnergySource() override; + + /** + * This function sets the interval between each energy update. + * + * \param interval Energy update interval. + */ + void SetEnergyUpdateInterval(Time interval); + + /** + * This function is used to change the initial capacity in the battery. + * A value of 0 means that the battery is fully charged. The value cannot + * be set to a value bigger than the rated capacity (fully discharged) or + * less than 0 (fully charged). + * + * \param drainedCapacity The capacity drained so far in the battery. + */ + void SetDrainedCapacity(double drainedCapacity); + + /** + * Obtain the amount of drained capacity from the battery based on the + * integral of the current over time (Coulomb counting method). + * + * \return The drainedCapacity (Ah) + */ + double GetDrainedCapacity() const; + + /** + * Calculates an estimate of the State of Charge (SoC). + * In essence, the amount of usable capacity remaining in the battery (%). + * + * \return The percentage of usable capacity remaining in the battery. + */ + double GetStateOfCharge() const; + + /** + * \return The interval between each energy update. + */ + Time GetEnergyUpdateInterval() const; + + private: + void DoInitialize() override; + void DoDispose() override; + + /** + * Handles the battery reaching its cutoff voltage. This function notifies + * all the energy models aggregated to the node about the usable energy in the + * battery has being depleted. Each energy model is then responsible for its own handler. + */ + void BatteryDepletedEvent(); + + /** + * Handles the battery reaching its full voltage. This function notifies + * all the energy models aggregated to the node about the battery reaching its + * full energy charge. + */ + void BatteryChargedEvent(); + + /** + * Calculates remaining energy. This function uses the total current from all + * device models to calculate the amount of energy to decrease. The energy to + * decrease is given by: + * energy to decrease = total current * supply voltage * time duration + * This function subtracts the calculated energy to decrease from remaining + * energy. + */ + void CalculateRemainingEnergy(); + + /** + * Get the battery voltage in function of the discharge current. + * It consider different discharge curves for different discharge currents + * and the remaining energy of the battery. + * + * \param current The actual discharge current value (+i). + * \return The voltage of the battery. + */ + double GetVoltage(double current); + + /** + * Obtain the battery voltage as a result of a charge current. + * + * \param current The actual charge current value (-i). + * \return The voltage of the battery. + */ + double GetChargeVoltage(double current); + + private: + TracedValue m_remainingEnergyJ; //!< Remaining energy, in Joules + double m_drainedCapacity; //!< Capacity drained from the battery, in Ah + double m_currentFiltered; //!< The step response (a.k.a. low pass filter) + double m_entn; //!< The previous value of the exponential zone + //!< in NiMh,NiCd and LeadAcid. + double m_expZone; //!< Voltage value of the exponential zone + Time m_energyUpdateLapseTime; //!< The lapse of time between the last battery energy update and + //!< the current time. + double m_supplyVoltageV; //!< Actual voltage of the battery + double m_lowBatteryTh; //!< Low battery threshold, as a fraction of the initial energy + EventId m_energyUpdateEvent; //!< Energy update event + Time m_lastUpdateTime; //!< Last update time + Time m_energyUpdateInterval; //!< Energy update interval + double m_vFull; //!< Initial voltage of the battery, in Volts + double m_vNom; //!< Nominal voltage of the battery, in Volts + double m_vExp; //!< Battery voltage at the end of the exponential zone, in Volts + double m_internalResistance; //!< Internal resistance of the battery, in Ohms + double m_qMax; //!< The maximum capacity of the battery, in Ah + double m_qNom; //!< Battery capacity at the end of the nominal zone, in Ah + double m_qExp; //!< Capacity value at the end of the exponential zone, in Ah + double m_typicalCurrent; //!< Typical discharge current used to fit the curves + double m_cutoffVoltage; //!< The threshold voltage where the battery is considered depleted + GenericBatteryType m_batteryType; //!< Indicates the battery type used by the model +}; + +} // namespace ns3 + +#endif /* GENERIC_BATTERY_MODEL_H */ diff --git a/src/energy/model/li-ion-energy-source.h b/src/energy/model/li-ion-energy-source.h index 24d2e36be..224e3de82 100644 --- a/src/energy/model/li-ion-energy-source.h +++ b/src/energy/model/li-ion-energy-source.h @@ -20,7 +20,8 @@ #ifndef LI_ION_ENERGY_SOURCE_H #define LI_ION_ENERGY_SOURCE_H -#include "ns3/energy-source.h" +#include "energy-source.h" + #include "ns3/event-id.h" #include "ns3/nstime.h" #include "ns3/traced-value.h" @@ -32,6 +33,9 @@ namespace ns3 * \ingroup energy * \brief Model a generic Lithium Ion Battery basing on [1][2]. * + * \deprecated The LiIonEnergySource was deprecated in ns-3.40 in favor of GenericBatteryModel, and + * will be removed in a future release. + * * The model can be fitted to any type of Li-Ion Battery, simply changing the * model parameters. * The default values are fitted for the Panasonic CGR18650DA Li-Ion Battery [3]. @@ -131,6 +135,7 @@ class LiIonEnergySource : public EnergySource * * Implements DecreaseRemainingEnergy. */ + NS_DEPRECATED_3_40("Use GenericBatteryModel instead") virtual void DecreaseRemainingEnergy(double energyJ); /** @@ -138,6 +143,7 @@ class LiIonEnergySource : public EnergySource * * Implements IncreaseRemainingEnergy. */ + NS_DEPRECATED_3_40("Use GenericBatteryModel instead") virtual void IncreaseRemainingEnergy(double energyJ); /** diff --git a/src/energy/model/simple-device-energy-model.cc b/src/energy/model/simple-device-energy-model.cc index 05982dfab..3e7834536 100644 --- a/src/energy/model/simple-device-energy-model.cc +++ b/src/energy/model/simple-device-energy-model.cc @@ -19,7 +19,8 @@ #include "simple-device-energy-model.h" -#include "ns3/energy-source.h" +#include "energy-source.h" + #include "ns3/log.h" #include "ns3/simulator.h" #include "ns3/trace-source-accessor.h" diff --git a/src/energy/model/simple-device-energy-model.h b/src/energy/model/simple-device-energy-model.h index a3fdd287a..d3baa03ec 100644 --- a/src/energy/model/simple-device-energy-model.h +++ b/src/energy/model/simple-device-energy-model.h @@ -20,7 +20,8 @@ #ifndef SIMPLE_DEVICE_ENERGY_MODEL_H #define SIMPLE_DEVICE_ENERGY_MODEL_H -#include "ns3/device-energy-model.h" +#include "device-energy-model.h" + #include "ns3/nstime.h" #include "ns3/traced-value.h" diff --git a/src/fd-net-device/examples/fd-emu-onoff.cc b/src/fd-net-device/examples/fd-emu-onoff.cc index 4145263f8..e28abcf19 100644 --- a/src/fd-net-device/examples/fd-emu-onoff.cc +++ b/src/fd-net-device/examples/fd-emu-onoff.cc @@ -200,7 +200,7 @@ main(int argc, char* argv[]) #ifdef HAVE_PACKET_H if (emuMode == "raw") { - EmuFdNetDeviceHelper* raw = new EmuFdNetDeviceHelper; + auto raw = new EmuFdNetDeviceHelper; raw->SetDeviceName(deviceName); helper = raw; } diff --git a/src/fd-net-device/examples/fd-emu-ping.cc b/src/fd-net-device/examples/fd-emu-ping.cc index 5693248c9..f41b2a149 100644 --- a/src/fd-net-device/examples/fd-emu-ping.cc +++ b/src/fd-net-device/examples/fd-emu-ping.cc @@ -184,7 +184,7 @@ main(int argc, char* argv[]) #ifdef HAVE_PACKET_H if (emuMode == "raw") { - EmuFdNetDeviceHelper* raw = new EmuFdNetDeviceHelper; + auto raw = new EmuFdNetDeviceHelper; raw->SetDeviceName(deviceName); helper = raw; } diff --git a/src/fd-net-device/examples/fd-emu-send.cc b/src/fd-net-device/examples/fd-emu-send.cc index be6e0cc2a..cea8aa620 100644 --- a/src/fd-net-device/examples/fd-emu-send.cc +++ b/src/fd-net-device/examples/fd-emu-send.cc @@ -57,15 +57,15 @@ Send(Ptr dev, int level, std::string emuMode) int packets = 10000000; - Mac48Address sender = Mac48Address("00:00:00:aa:00:01"); - Mac48Address receiver = Mac48Address("ff:ff:ff:ff:ff:ff"); + Mac48Address sender("00:00:00:aa:00:01"); + Mac48Address receiver("ff:ff:ff:ff:ff:ff"); int packetsSize = 64; Ptr packet = Create(packetsSize); EthernetHeader header; ssize_t len = (size_t)packet->GetSize(); - uint8_t* buffer = (uint8_t*)malloc(len); + auto buffer = (uint8_t*)malloc(len); packet->CopyData(buffer, len); int sent = 0; @@ -166,7 +166,7 @@ main(int argc, char* argv[]) #ifdef HAVE_PACKET_H if (emuMode == "raw") { - EmuFdNetDeviceHelper* raw = new EmuFdNetDeviceHelper; + auto raw = new EmuFdNetDeviceHelper; raw->SetDeviceName(deviceName); helper = raw; } diff --git a/src/fd-net-device/examples/fd-emu-tc.cc b/src/fd-net-device/examples/fd-emu-tc.cc index 2e5cb304d..cab3aa7b3 100644 --- a/src/fd-net-device/examples/fd-emu-tc.cc +++ b/src/fd-net-device/examples/fd-emu-tc.cc @@ -168,11 +168,11 @@ main(int argc, char* argv[]) #ifdef HAVE_PACKET_H if (emuMode == "raw") { - EmuFdNetDeviceHelper* raw0 = new EmuFdNetDeviceHelper; + auto raw0 = new EmuFdNetDeviceHelper; raw0->SetDeviceName(deviceName0); helper0 = raw0; - EmuFdNetDeviceHelper* raw1 = new EmuFdNetDeviceHelper; + auto raw1 = new EmuFdNetDeviceHelper; raw1->SetDeviceName(deviceName1); helper1 = raw1; } diff --git a/src/fd-net-device/examples/fd2fd-onoff.cc b/src/fd-net-device/examples/fd2fd-onoff.cc index a4e9dc59a..fbd222ef8 100644 --- a/src/fd-net-device/examples/fd2fd-onoff.cc +++ b/src/fd-net-device/examples/fd2fd-onoff.cc @@ -64,7 +64,7 @@ main(int argc, char* argv[]) cmd.Parse(argc, argv); std::string factory; - if (tcpMode == 1) + if (tcpMode) { factory = "ns3::TcpSocketFactory"; } diff --git a/src/fd-net-device/helper/dpdk-net-device-helper.h b/src/fd-net-device/helper/dpdk-net-device-helper.h index 848f2a226..d0cb0bdb5 100644 --- a/src/fd-net-device/helper/dpdk-net-device-helper.h +++ b/src/fd-net-device/helper/dpdk-net-device-helper.h @@ -21,7 +21,7 @@ #ifndef DPDK_NET_DEVICE_HELPER_H #define DPDK_NET_DEVICE_HELPER_H -#include "ns3/emu-fd-net-device-helper.h" +#include "emu-fd-net-device-helper.h" namespace ns3 { diff --git a/src/fd-net-device/helper/emu-fd-net-device-helper.h b/src/fd-net-device/helper/emu-fd-net-device-helper.h index d6618fb2b..3a1453967 100644 --- a/src/fd-net-device/helper/emu-fd-net-device-helper.h +++ b/src/fd-net-device/helper/emu-fd-net-device-helper.h @@ -19,8 +19,9 @@ #ifndef EMU_FD_NET_DEVICE_HELPER_H #define EMU_FD_NET_DEVICE_HELPER_H +#include "fd-net-device-helper.h" + #include "ns3/attribute.h" -#include "ns3/fd-net-device-helper.h" #include "ns3/fd-net-device.h" #include "ns3/net-device-container.h" #include "ns3/node-container.h" diff --git a/src/fd-net-device/helper/fd-net-device-helper.cc b/src/fd-net-device/helper/fd-net-device-helper.cc index a4d892a9c..8ea4b7093 100644 --- a/src/fd-net-device/helper/fd-net-device-helper.cc +++ b/src/fd-net-device/helper/fd-net-device-helper.cc @@ -199,7 +199,7 @@ FdNetDeviceHelper::Install(const NodeContainer& c) const { NetDeviceContainer devs; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { devs.Add(InstallPriv(*i)); } diff --git a/src/fd-net-device/helper/netmap-net-device-helper.h b/src/fd-net-device/helper/netmap-net-device-helper.h index 8d312c060..30a9ef89f 100644 --- a/src/fd-net-device/helper/netmap-net-device-helper.h +++ b/src/fd-net-device/helper/netmap-net-device-helper.h @@ -20,8 +20,9 @@ #ifndef NETMAP_NET_DEVICE_HELPER_H #define NETMAP_NET_DEVICE_HELPER_H +#include "fd-net-device-helper.h" + #include "ns3/attribute.h" -#include "ns3/fd-net-device-helper.h" #include "ns3/fd-net-device.h" #include "ns3/net-device-container.h" #include "ns3/netmap-net-device.h" diff --git a/src/fd-net-device/helper/tap-device-creator.cc b/src/fd-net-device/helper/tap-device-creator.cc index 165791427..fc4ff40f4 100644 --- a/src/fd-net-device/helper/tap-device-creator.cc +++ b/src/fd-net-device/helper/tap-device-creator.cc @@ -216,8 +216,8 @@ SetUp(char* deviceName) int CreateTap(char* deviceName, const char* mac, - const int ifftap, - const int iffpi, + bool ifftap, + bool iffpi, const char* ip4, const char* netmask, const char* ip6, @@ -293,8 +293,8 @@ main(int argc, char* argv[]) char* mac = nullptr; char* netmask = nullptr; char* path = nullptr; - int tap = false; - int pi = false; + bool tap = false; + bool pi = false; int prefix = -1; while ((c = getopt(argc, argv, "vd:i:m:n:I:P:thp:")) != -1) diff --git a/src/fd-net-device/helper/tap-fd-net-device-helper.cc b/src/fd-net-device/helper/tap-fd-net-device-helper.cc index 751408339..e7c6eb1bf 100644 --- a/src/fd-net-device/helper/tap-fd-net-device-helper.cc +++ b/src/fd-net-device/helper/tap-fd-net-device-helper.cc @@ -22,7 +22,6 @@ #include "ns3/abort.h" #include "ns3/config.h" #include "ns3/fd-net-device.h" -#include "ns3/internet-module.h" #include "ns3/log.h" #include "ns3/names.h" #include "ns3/object-factory.h" diff --git a/src/fd-net-device/model/dpdk-net-device.cc b/src/fd-net-device/model/dpdk-net-device.cc index e9aeb9a3d..486d3fa1a 100644 --- a/src/fd-net-device/model/dpdk-net-device.cc +++ b/src/fd-net-device/model/dpdk-net-device.cc @@ -144,14 +144,11 @@ DpdkNetDevice::CheckAllPortsLinkStatus() /* print link status if flag set */ if (printFlag == 1) { - if (link.link_status) + if (!link.link_status) { - continue; - } - else - { - printf("Port %d Link Down\n", m_portId); + NS_LOG_INFO("Port " << +m_portId << " Link Down"); } + continue; } /* clear allPortsUp flag if any link down */ @@ -186,7 +183,7 @@ DpdkNetDevice::SignalHandler(int signum) { if (signum == SIGINT || signum == SIGTERM) { - printf("\n\nSignal %d received, preparing to exit...\n", signum); + NS_LOG_INFO("Signal " << signum << " received, preparing to exit..."); m_forceQuit = true; } } @@ -260,7 +257,7 @@ DpdkNetDevice::InitDpdk(int argc, char** argv, std::string dpdkDriver) command.append(dpdkDriver); command.append(" "); command.append(m_deviceName); - printf("Executing: %s\n", command.c_str()); + NS_LOG_INFO("Executing: " << command); if (system(command.c_str())) { rte_exit(EXIT_FAILURE, "Execution failed - bye\n"); diff --git a/src/fd-net-device/model/fd-net-device.cc b/src/fd-net-device/model/fd-net-device.cc index 127441f44..70185637a 100644 --- a/src/fd-net-device/model/fd-net-device.cc +++ b/src/fd-net-device/model/fd-net-device.cc @@ -61,7 +61,7 @@ FdNetDeviceFdReader::DoRead() { NS_LOG_FUNCTION(this); - uint8_t* buf = (uint8_t*)malloc(m_bufferSize); + auto buf = (uint8_t*)malloc(m_bufferSize); NS_ABORT_MSG_IF(buf == nullptr, "malloc() failed"); NS_LOG_LOGIC("Calling read on fd " << m_fd); @@ -350,7 +350,7 @@ static void AddPIHeader(uint8_t*& buf, size_t& len) { // Synthesize PI header for our friend the kernel - uint8_t* buf2 = (uint8_t*)malloc(len + 4); + auto buf2 = (uint8_t*)malloc(len + 4); memcpy(buf2 + 4, buf, len); len += 4; @@ -617,7 +617,7 @@ FdNetDevice::SendFrom(Ptr packet, NS_LOG_LOGIC("calling write"); - size_t len = (size_t)packet->GetSize(); + auto len = (size_t)packet->GetSize(); uint8_t* buffer = AllocateBuffer(len); if (!buffer) { diff --git a/src/flow-monitor/examples/flowmon-parse-results.py b/src/flow-monitor/examples/flowmon-parse-results.py index bbc3c9f8b..00e4fb854 100644 --- a/src/flow-monitor/examples/flowmon-parse-results.py +++ b/src/flow-monitor/examples/flowmon-parse-results.py @@ -179,23 +179,23 @@ class Simulation(object): def main(argv): - file_obj = open(argv[1]) - print("Reading XML file ", end=" ") + with open(argv[1], encoding="utf-8") as file_obj: + print("Reading XML file ", end=" ") - sys.stdout.flush() - level = 0 - sim_list = [] - for event, elem in ElementTree.iterparse(file_obj, events=("start", "end")): - if event == "start": - level += 1 - if event == "end": - level -= 1 - if level == 0 and elem.tag == 'FlowMonitor': - sim = Simulation(elem) - sim_list.append(sim) - elem.clear() # won't need this any more - sys.stdout.write(".") - sys.stdout.flush() + sys.stdout.flush() + level = 0 + sim_list = [] + for event, elem in ElementTree.iterparse(file_obj, events=("start", "end")): + if event == "start": + level += 1 + if event == "end": + level -= 1 + if level == 0 and elem.tag == 'FlowMonitor': + sim = Simulation(elem) + sim_list.append(sim) + elem.clear() # won't need this any more + sys.stdout.write(".") + sys.stdout.flush() print(" done.") diff --git a/src/flow-monitor/helper/flow-monitor-helper.cc b/src/flow-monitor/helper/flow-monitor-helper.cc index c991f5ea0..44b9e5c01 100644 --- a/src/flow-monitor/helper/flow-monitor-helper.cc +++ b/src/flow-monitor/helper/flow-monitor-helper.cc @@ -112,7 +112,7 @@ FlowMonitorHelper::Install(Ptr node) Ptr FlowMonitorHelper::Install(NodeContainer nodes) { - for (NodeContainer::Iterator i = nodes.Begin(); i != nodes.End(); ++i) + for (auto i = nodes.Begin(); i != nodes.End(); ++i) { Ptr node = *i; if (node->GetObject() || node->GetObject()) @@ -126,7 +126,7 @@ FlowMonitorHelper::Install(NodeContainer nodes) Ptr FlowMonitorHelper::InstallAll() { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr node = *i; if (node->GetObject() || node->GetObject()) diff --git a/src/flow-monitor/model/flow-monitor.cc b/src/flow-monitor/model/flow-monitor.cc index de8460876..7e77c25f9 100644 --- a/src/flow-monitor/model/flow-monitor.cc +++ b/src/flow-monitor/model/flow-monitor.cc @@ -105,9 +105,7 @@ FlowMonitor::DoDispose() NS_LOG_FUNCTION(this); Simulator::Cancel(m_startEvent); Simulator::Cancel(m_stopEvent); - for (std::list>::iterator iter = m_classifiers.begin(); - iter != m_classifiers.end(); - iter++) + for (auto iter = m_classifiers.begin(); iter != m_classifiers.end(); iter++) { *iter = nullptr; } @@ -123,8 +121,7 @@ inline FlowMonitor::FlowStats& FlowMonitor::GetStatsForFlow(FlowId flowId) { NS_LOG_FUNCTION(this); - FlowStatsContainerI iter; - iter = m_flowStats.find(flowId); + auto iter = m_flowStats.find(flowId); if (iter == m_flowStats.end()) { FlowMonitor::FlowStats& ref = m_flowStats[flowId]; @@ -210,7 +207,7 @@ FlowMonitor::ReportForwarding(Ptr probe, #endif std::pair key(flowId, packetId); - TrackedPacketMap::iterator tracked = m_trackedPackets.find(key); + auto tracked = m_trackedPackets.find(key); if (tracked == m_trackedPackets.end()) { NS_LOG_WARN("Received packet forward report (flowId=" @@ -250,7 +247,7 @@ FlowMonitor::ReportLastRx(Ptr probe, ; #endif - TrackedPacketMap::iterator tracked = m_trackedPackets.find(std::make_pair(flowId, packetId)); + auto tracked = m_trackedPackets.find(std::make_pair(flowId, packetId)); if (tracked == m_trackedPackets.end()) { NS_LOG_WARN("Received packet last-tx report (flowId=" @@ -346,7 +343,7 @@ FlowMonitor::ReportDrop(Ptr probe, NS_LOG_DEBUG("++stats.packetsDropped[" << reasonCode << "]; // becomes: " << stats.packetsDropped[reasonCode]); - TrackedPacketMap::iterator tracked = m_trackedPackets.find(std::make_pair(flowId, packetId)); + auto tracked = m_trackedPackets.find(std::make_pair(flowId, packetId)); if (tracked != m_trackedPackets.end()) { // we don't need to track this packet anymore @@ -373,13 +370,12 @@ FlowMonitor::CheckForLostPackets(Time maxDelay) NS_LOG_FUNCTION(this << maxDelay.As(Time::S)); Time now = Simulator::Now(); - for (TrackedPacketMap::iterator iter = m_trackedPackets.begin(); - iter != m_trackedPackets.end();) + for (auto iter = m_trackedPackets.begin(); iter != m_trackedPackets.end();) { if (now - iter->second.lastSeenTime >= maxDelay) { // packet is considered lost, add it to the loss statistics - FlowStatsContainerI flow = m_flowStats.find(iter->first.first); + auto flow = m_flowStats.find(iter->first.first); NS_ASSERT(flow != m_flowStats.end()); flow->second.lostPackets++; @@ -492,7 +488,7 @@ FlowMonitor::SerializeToXmlStream(std::ostream& os, indent += 2; os << std::string(indent, ' ') << "\n"; indent += 2; - for (FlowStatsContainerCI flowI = m_flowStats.begin(); flowI != m_flowStats.end(); flowI++) + for (auto flowI = m_flowStats.begin(); flowI != m_flowStats.end(); flowI++) { os << std::string(indent, ' '); #define ATTRIB(name) << " " #name "=\"" << flowI->second.name << "\"" @@ -540,9 +536,7 @@ FlowMonitor::SerializeToXmlStream(std::ostream& os, indent -= 2; os << std::string(indent, ' ') << "\n"; - for (std::list>::iterator iter = m_classifiers.begin(); - iter != m_classifiers.end(); - iter++) + for (auto iter = m_classifiers.begin(); iter != m_classifiers.end(); iter++) { (*iter)->SerializeToXmlStream(os, indent); } diff --git a/src/flow-monitor/model/flow-monitor.h b/src/flow-monitor/model/flow-monitor.h index 5b996d282..3a2082ba8 100644 --- a/src/flow-monitor/model/flow-monitor.h +++ b/src/flow-monitor/model/flow-monitor.h @@ -20,9 +20,10 @@ #ifndef FLOW_MONITOR_H #define FLOW_MONITOR_H +#include "flow-classifier.h" +#include "flow-probe.h" + #include "ns3/event-id.h" -#include "ns3/flow-classifier.h" -#include "ns3/flow-probe.h" #include "ns3/histogram.h" #include "ns3/nstime.h" #include "ns3/object.h" diff --git a/src/flow-monitor/model/flow-probe.cc b/src/flow-monitor/model/flow-probe.cc index 3e1a09f10..827fe7f68 100644 --- a/src/flow-monitor/model/flow-probe.cc +++ b/src/flow-monitor/model/flow-probe.cc @@ -17,9 +17,9 @@ // Author: Gustavo J. A. M. Carneiro // -#include "ns3/flow-probe.h" +#include "flow-probe.h" -#include "ns3/flow-monitor.h" +#include "flow-monitor.h" namespace ns3 { @@ -88,7 +88,7 @@ FlowProbe::SerializeToXmlStream(std::ostream& os, uint16_t indent, uint32_t inde indent += 2; - for (Stats::const_iterator iter = m_stats.begin(); iter != m_stats.end(); iter++) + for (auto iter = m_stats.begin(); iter != m_stats.end(); iter++) { os << std::string(indent, ' '); os << "::iterator, bool> insert = - m_flowMap.insert(std::pair(tuple, 0)); + auto insert = m_flowMap.insert(std::pair(tuple, 0)); // if the insertion succeeded, we need to assign this tuple a new flow identifier if (insert.second) @@ -171,9 +170,8 @@ Ipv4FlowClassifier::Classify(const Ipv4Header& ipHeader, // increment the counter of packets with the same DSCP value Ipv4Header::DscpType dscp = ipHeader.GetDscp(); - std::pair::iterator, bool> dscpInserter = - m_flowDscpMap[insert.first->second].insert( - std::pair(dscp, 1)); + auto dscpInserter = m_flowDscpMap[insert.first->second].insert( + std::pair(dscp, 1)); // if the insertion did not succeed, we need to increment the counter if (!dscpInserter.second) @@ -194,9 +192,7 @@ Ipv4FlowClassifier::Classify(const Ipv4Header& ipHeader, Ipv4FlowClassifier::FiveTuple Ipv4FlowClassifier::FindFlow(FlowId flowId) const { - for (std::map::const_iterator iter = m_flowMap.begin(); - iter != m_flowMap.end(); - iter++) + for (auto iter = m_flowMap.begin(); iter != m_flowMap.end(); iter++) { if (iter->second == flowId) { @@ -218,8 +214,7 @@ Ipv4FlowClassifier::SortByCount::operator()(std::pair> Ipv4FlowClassifier::GetDscpCounts(FlowId flowId) const { - std::map>::const_iterator flow = - m_flowDscpMap.find(flowId); + auto flow = m_flowDscpMap.find(flowId); if (flow == m_flowDscpMap.end()) { @@ -239,9 +234,7 @@ Ipv4FlowClassifier::SerializeToXmlStream(std::ostream& os, uint16_t indent) cons os << "\n"; indent += 2; - for (std::map::const_iterator iter = m_flowMap.begin(); - iter != m_flowMap.end(); - iter++) + for (auto iter = m_flowMap.begin(); iter != m_flowMap.end(); iter++) { Indent(os, indent); os << "second << "\"" @@ -252,14 +245,11 @@ Ipv4FlowClassifier::SerializeToXmlStream(std::ostream& os, uint16_t indent) cons << " destinationPort=\"" << iter->first.destinationPort << "\">\n"; indent += 2; - std::map>::const_iterator flow = - m_flowDscpMap.find(iter->second); + auto flow = m_flowDscpMap.find(iter->second); if (flow != m_flowDscpMap.end()) { - for (std::map::const_iterator i = flow->second.begin(); - i != flow->second.end(); - i++) + for (auto i = flow->second.begin(); i != flow->second.end(); i++) { Indent(os, indent); os << "(i->first) << "\"" diff --git a/src/flow-monitor/model/ipv4-flow-classifier.h b/src/flow-monitor/model/ipv4-flow-classifier.h index c098abd20..33c5e698e 100644 --- a/src/flow-monitor/model/ipv4-flow-classifier.h +++ b/src/flow-monitor/model/ipv4-flow-classifier.h @@ -20,7 +20,8 @@ #ifndef IPV4_FLOW_CLASSIFIER_H #define IPV4_FLOW_CLASSIFIER_H -#include "ns3/flow-classifier.h" +#include "flow-classifier.h" + #include "ns3/ipv4-header.h" #include diff --git a/src/flow-monitor/model/ipv4-flow-probe.cc b/src/flow-monitor/model/ipv4-flow-probe.cc index 896f389cd..77dae4954 100644 --- a/src/flow-monitor/model/ipv4-flow-probe.cc +++ b/src/flow-monitor/model/ipv4-flow-probe.cc @@ -17,12 +17,13 @@ // Author: Gustavo J. A. M. Carneiro // -#include "ns3/ipv4-flow-probe.h" +#include "ipv4-flow-probe.h" + +#include "flow-monitor.h" +#include "ipv4-flow-classifier.h" #include "ns3/config.h" #include "ns3/flow-id-tag.h" -#include "ns3/flow-monitor.h" -#include "ns3/ipv4-flow-classifier.h" #include "ns3/log.h" #include "ns3/node.h" #include "ns3/packet.h" diff --git a/src/flow-monitor/model/ipv4-flow-probe.h b/src/flow-monitor/model/ipv4-flow-probe.h index bfc137a6a..ab208174d 100644 --- a/src/flow-monitor/model/ipv4-flow-probe.h +++ b/src/flow-monitor/model/ipv4-flow-probe.h @@ -20,8 +20,9 @@ #ifndef IPV4_FLOW_PROBE_H #define IPV4_FLOW_PROBE_H -#include "ns3/flow-probe.h" -#include "ns3/ipv4-flow-classifier.h" +#include "flow-probe.h" +#include "ipv4-flow-classifier.h" + #include "ns3/ipv4-l3-protocol.h" #include "ns3/queue-item.h" diff --git a/src/flow-monitor/model/ipv6-flow-classifier.cc b/src/flow-monitor/model/ipv6-flow-classifier.cc index d825d1150..9a51a757f 100644 --- a/src/flow-monitor/model/ipv6-flow-classifier.cc +++ b/src/flow-monitor/model/ipv6-flow-classifier.cc @@ -154,8 +154,7 @@ Ipv6FlowClassifier::Classify(const Ipv6Header& ipHeader, #endif // try to insert the tuple, but check if it already exists - std::pair::iterator, bool> insert = - m_flowMap.insert(std::pair(tuple, 0)); + auto insert = m_flowMap.insert(std::pair(tuple, 0)); // if the insertion succeeded, we need to assign this tuple a new flow identifier if (insert.second) @@ -172,9 +171,8 @@ Ipv6FlowClassifier::Classify(const Ipv6Header& ipHeader, // increment the counter of packets with the same DSCP value Ipv6Header::DscpType dscp = ipHeader.GetDscp(); - std::pair::iterator, bool> dscpInserter = - m_flowDscpMap[insert.first->second].insert( - std::pair(dscp, 1)); + auto dscpInserter = m_flowDscpMap[insert.first->second].insert( + std::pair(dscp, 1)); // if the insertion did not succeed, we need to increment the counter if (!dscpInserter.second) @@ -195,9 +193,7 @@ Ipv6FlowClassifier::Classify(const Ipv6Header& ipHeader, Ipv6FlowClassifier::FiveTuple Ipv6FlowClassifier::FindFlow(FlowId flowId) const { - for (std::map::const_iterator iter = m_flowMap.begin(); - iter != m_flowMap.end(); - iter++) + for (auto iter = m_flowMap.begin(); iter != m_flowMap.end(); iter++) { if (iter->second == flowId) { @@ -219,8 +215,7 @@ Ipv6FlowClassifier::SortByCount::operator()(std::pair> Ipv6FlowClassifier::GetDscpCounts(FlowId flowId) const { - std::map>::const_iterator flow = - m_flowDscpMap.find(flowId); + auto flow = m_flowDscpMap.find(flowId); if (flow == m_flowDscpMap.end()) { @@ -240,9 +235,7 @@ Ipv6FlowClassifier::SerializeToXmlStream(std::ostream& os, uint16_t indent) cons os << "\n"; indent += 2; - for (std::map::const_iterator iter = m_flowMap.begin(); - iter != m_flowMap.end(); - iter++) + for (auto iter = m_flowMap.begin(); iter != m_flowMap.end(); iter++) { Indent(os, indent); os << "second << "\"" @@ -253,14 +246,11 @@ Ipv6FlowClassifier::SerializeToXmlStream(std::ostream& os, uint16_t indent) cons << " destinationPort=\"" << iter->first.destinationPort << "\">\n"; indent += 2; - std::map>::const_iterator flow = - m_flowDscpMap.find(iter->second); + auto flow = m_flowDscpMap.find(iter->second); if (flow != m_flowDscpMap.end()) { - for (std::map::const_iterator i = flow->second.begin(); - i != flow->second.end(); - i++) + for (auto i = flow->second.begin(); i != flow->second.end(); i++) { Indent(os, indent); os << "(i->first) << "\"" diff --git a/src/flow-monitor/model/ipv6-flow-classifier.h b/src/flow-monitor/model/ipv6-flow-classifier.h index f0b0327ce..e1d3d2364 100644 --- a/src/flow-monitor/model/ipv6-flow-classifier.h +++ b/src/flow-monitor/model/ipv6-flow-classifier.h @@ -21,7 +21,8 @@ #ifndef IPV6_FLOW_CLASSIFIER_H #define IPV6_FLOW_CLASSIFIER_H -#include "ns3/flow-classifier.h" +#include "flow-classifier.h" + #include "ns3/ipv6-header.h" #include diff --git a/src/flow-monitor/model/ipv6-flow-probe.cc b/src/flow-monitor/model/ipv6-flow-probe.cc index a8c3c263b..32f7e42f5 100644 --- a/src/flow-monitor/model/ipv6-flow-probe.cc +++ b/src/flow-monitor/model/ipv6-flow-probe.cc @@ -18,12 +18,13 @@ // Modifications: Tommaso Pecorella // -#include "ns3/ipv6-flow-probe.h" +#include "ipv6-flow-probe.h" + +#include "flow-monitor.h" +#include "ipv6-flow-classifier.h" #include "ns3/config.h" #include "ns3/flow-id-tag.h" -#include "ns3/flow-monitor.h" -#include "ns3/ipv6-flow-classifier.h" #include "ns3/log.h" #include "ns3/node.h" #include "ns3/packet.h" diff --git a/src/flow-monitor/model/ipv6-flow-probe.h b/src/flow-monitor/model/ipv6-flow-probe.h index 334bae5e2..576adc0c4 100644 --- a/src/flow-monitor/model/ipv6-flow-probe.h +++ b/src/flow-monitor/model/ipv6-flow-probe.h @@ -21,8 +21,9 @@ #ifndef IPV6_FLOW_PROBE_H #define IPV6_FLOW_PROBE_H -#include "ns3/flow-probe.h" -#include "ns3/ipv6-flow-classifier.h" +#include "flow-probe.h" +#include "ipv6-flow-classifier.h" + #include "ns3/ipv6-l3-protocol.h" #include "ns3/queue-item.h" diff --git a/src/internet-apps/examples/ping-example.cc b/src/internet-apps/examples/ping-example.cc index 80700017e..ca0e4e955 100644 --- a/src/internet-apps/examples/ping-example.cc +++ b/src/internet-apps/examples/ping-example.cc @@ -115,8 +115,8 @@ main(int argc, char* argv[]) if (!destinationStr.empty()) { - Ipv4Address v4Dst = Ipv4Address(destinationStr.c_str()); - Ipv6Address v6Dst = Ipv6Address(destinationStr.c_str()); + Ipv4Address v4Dst(destinationStr.c_str()); + Ipv6Address v6Dst(destinationStr.c_str()); if (v4Dst.IsInitialized()) { useIpv6 = false; @@ -131,8 +131,8 @@ main(int argc, char* argv[]) if (!sourceStr.empty()) { - Ipv4Address v4Src = Ipv4Address(sourceStr.c_str()); - Ipv6Address v6Src = Ipv6Address(sourceStr.c_str()); + Ipv4Address v4Src(sourceStr.c_str()); + Ipv6Address v6Src(sourceStr.c_str()); if (v4Src.IsInitialized()) { source = v4Src; @@ -157,7 +157,7 @@ main(int argc, char* argv[]) } else { - Ipv4Address v4Dst = Ipv4Address(destinationStr.c_str()); + Ipv4Address v4Dst(destinationStr.c_str()); if (v4Dst.IsInitialized() && (v4Dst.IsBroadcast() || v4Dst.IsMulticast())) { std::cout << "Specify a source address to use when pinging broadcast or multicast " diff --git a/src/internet-apps/helper/dhcp-helper.cc b/src/internet-apps/helper/dhcp-helper.cc index 97d4dfdae..fd31acd13 100644 --- a/src/internet-apps/helper/dhcp-helper.cc +++ b/src/internet-apps/helper/dhcp-helper.cc @@ -67,7 +67,7 @@ ApplicationContainer DhcpHelper::InstallDhcpClient(NetDeviceContainer netDevices) const { ApplicationContainer apps; - for (NetDeviceContainer::Iterator i = netDevices.Begin(); i != netDevices.End(); ++i) + for (auto i = netDevices.Begin(); i != netDevices.End(); ++i) { apps.Add(InstallDhcpClientPriv(*i)); } @@ -184,8 +184,7 @@ DhcpHelper::InstallDhcpServer(Ptr netDevice, } // check that the already fixed addresses are not in conflict with the pool - std::list::iterator iter; - for (iter = m_fixedAddresses.begin(); iter != m_fixedAddresses.end(); iter++) + for (auto iter = m_fixedAddresses.begin(); iter != m_fixedAddresses.end(); iter++) { if (iter->Get() >= minAddr.Get() && iter->Get() <= maxAddr.Get()) { @@ -250,8 +249,7 @@ DhcpHelper::InstallFixedAddress(Ptr netDevice, Ipv4Address addr, Ipv4 } // check that the already fixed addresses are not in conflict with the pool - std::list>::iterator iter; - for (iter = m_addressPools.begin(); iter != m_addressPools.end(); iter++) + for (auto iter = m_addressPools.begin(); iter != m_addressPools.end(); iter++) { if (addr.Get() >= iter->first.Get() && addr.Get() <= iter->second.Get()) { diff --git a/src/internet-apps/helper/ping-helper.cc b/src/internet-apps/helper/ping-helper.cc index 2e601fd00..7807831b5 100644 --- a/src/internet-apps/helper/ping-helper.cc +++ b/src/internet-apps/helper/ping-helper.cc @@ -65,7 +65,7 @@ ApplicationContainer PingHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/internet-apps/helper/ping6-helper.cc b/src/internet-apps/helper/ping6-helper.cc index 62c3bd04f..5efccc71c 100644 --- a/src/internet-apps/helper/ping6-helper.cc +++ b/src/internet-apps/helper/ping6-helper.cc @@ -59,7 +59,7 @@ Ping6Helper::Install(NodeContainer c) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr client = m_factory.Create(); diff --git a/src/internet-apps/helper/radvd-helper.cc b/src/internet-apps/helper/radvd-helper.cc index 61b431c5d..0891d51af 100644 --- a/src/internet-apps/helper/radvd-helper.cc +++ b/src/internet-apps/helper/radvd-helper.cc @@ -120,8 +120,7 @@ RadvdHelper::Install(Ptr node) { ApplicationContainer apps; Ptr radvd = m_factory.Create(); - for (RadvdInterfaceMapI iter = m_radvdInterfaces.begin(); iter != m_radvdInterfaces.end(); - iter++) + for (auto iter = m_radvdInterfaces.begin(); iter != m_radvdInterfaces.end(); iter++) { if (!iter->second->GetPrefixes().empty()) { diff --git a/src/internet-apps/helper/v4ping-helper.cc b/src/internet-apps/helper/v4ping-helper.cc index 9428184c4..d018fd8b9 100644 --- a/src/internet-apps/helper/v4ping-helper.cc +++ b/src/internet-apps/helper/v4ping-helper.cc @@ -57,7 +57,7 @@ ApplicationContainer V4PingHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/internet-apps/helper/v4traceroute-helper.cc b/src/internet-apps/helper/v4traceroute-helper.cc index cf968388c..99f249fc3 100644 --- a/src/internet-apps/helper/v4traceroute-helper.cc +++ b/src/internet-apps/helper/v4traceroute-helper.cc @@ -56,7 +56,7 @@ ApplicationContainer V4TraceRouteHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/internet-apps/model/dhcp-header.cc b/src/internet-apps/model/dhcp-header.cc index 6022c9c15..df9d5a603 100644 --- a/src/internet-apps/model/dhcp-header.cc +++ b/src/internet-apps/model/dhcp-header.cc @@ -42,7 +42,7 @@ DhcpHeader::DhcpHeader() m_secs = 0; m_hops = 0; m_flags = 0; - Ipv4Address addr = Ipv4Address("0.0.0.0"); + Ipv4Address addr("0.0.0.0"); m_yiAddr = addr; m_ciAddr = addr; m_siAddr = addr; diff --git a/src/internet-apps/model/dhcp-server.cc b/src/internet-apps/model/dhcp-server.cc index 26dba3a87..43ff27dc6 100644 --- a/src/internet-apps/model/dhcp-server.cc +++ b/src/internet-apps/model/dhcp-server.cc @@ -160,7 +160,7 @@ DhcpServer::StartApplication() uint32_t range = m_maxAddress.Get() - m_minAddress.Get() + 1; for (uint32_t searchSeq = 0; searchSeq < range; searchSeq++) { - Ipv4Address poolAddress = Ipv4Address(m_minAddress.Get() + searchSeq); + Ipv4Address poolAddress(m_minAddress.Get() + searchSeq); if (poolAddress != myOwnAddress) { NS_LOG_LOGIC("Adding " << poolAddress << " to the pool"); @@ -259,7 +259,7 @@ DhcpServer::SendOffer(Ptr iDev, DhcpHeader header, InetSocketAddress NS_LOG_INFO("DHCP DISCOVER from: " << from.GetIpv4() << " source port: " << from.GetPort()); - LeasedAddressIter iter = m_leasedAddresses.find(sourceChaddr); + auto iter = m_leasedAddresses.find(sourceChaddr); if (iter != m_leasedAddresses.end()) { // We know this client from some time ago @@ -425,8 +425,7 @@ DhcpServer::AddStaticDhcpEntry(Address chaddr, Ipv4Address addr) NS_ASSERT_MSG(m_leasedAddresses.find(cleanedCaddr) == m_leasedAddresses.end(), "Client has already an active lease: " << m_leasedAddresses[cleanedCaddr].first); - AvailableAddress::iterator it = - find(m_availableAddresses.begin(), m_availableAddresses.end(), addr); + auto it = find(m_availableAddresses.begin(), m_availableAddresses.end(), addr); NS_ASSERT_MSG( it == m_availableAddresses.end(), "Required address is not available (perhaps it has been already assigned): " << addr); diff --git a/src/internet-apps/model/ping.cc b/src/internet-apps/model/ping.cc index 194afb24d..96af7c094 100644 --- a/src/internet-apps/model/ping.cc +++ b/src/internet-apps/model/ping.cc @@ -206,7 +206,7 @@ Ping::Receive(Ptr socket) NS_LOG_INFO("Packet too short, discarding"); return; } - uint8_t* buf = new uint8_t[dataSize]; + auto buf = new uint8_t[dataSize]; echo.GetData(buf); uint64_t appSignature = Read64(buf); delete[] buf; @@ -286,7 +286,7 @@ Ping::Receive(Ptr socket) switch (type) { case Icmpv6Header::ICMPV6_ECHO_REPLY: { - Icmpv6Echo echo(0); + Icmpv6Echo echo(false); packet->RemoveHeader(echo); if (echo.GetId() != PING_ID) @@ -305,7 +305,7 @@ Ping::Receive(Ptr socket) NS_LOG_INFO("Packet too short, discarding"); return; } - uint8_t* buf = new uint8_t[dataSize]; + auto buf = new uint8_t[dataSize]; packet->CopyData(buf, dataSize); uint64_t appSignature = Read64(buf); delete[] buf; @@ -426,7 +426,7 @@ Ping::Send() // (where any difference would show up anyway) and borrow that code. Don't // be too surprised when you see that this is a little endian convention. // - uint8_t* data = new uint8_t[m_size]; + auto data = new uint8_t[m_size]; memset(data, 0, m_size); NS_ASSERT_MSG(m_size >= 16, "ECHO Payload size must be at least 16 bytes"); @@ -583,8 +583,7 @@ Ping::StartApplication() { if (Ipv4Address::IsMatchingType(m_interfaceAddress)) { - InetSocketAddress senderInet = - InetSocketAddress(Ipv4Address::ConvertFrom(m_interfaceAddress)); + InetSocketAddress senderInet(Ipv4Address::ConvertFrom(m_interfaceAddress)); int status = m_socket->Bind(senderInet); NS_ASSERT_MSG(status == 0, "Failed to bind IPv4 socket"); } diff --git a/src/internet-apps/model/ping6.cc b/src/internet-apps/model/ping6.cc index 9294df421..a08ec697c 100644 --- a/src/internet-apps/model/ping6.cc +++ b/src/internet-apps/model/ping6.cc @@ -210,7 +210,7 @@ Ping6::Send() size = 4; } - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; memset(data, 0, size); data[0] = 0xDE; data[1] = 0xAD; @@ -218,7 +218,7 @@ Ping6::Send() data[3] = 0xEF; Ptr p = Create(data, size); - Icmpv6Echo req(1); + Icmpv6Echo req(true); req.SetId(0xBEEF); req.SetSeq(m_seq); @@ -268,7 +268,7 @@ Ping6::HandleRead(Ptr socket) if (Inet6SocketAddress::IsMatchingType(from)) { Ipv6Header hdr; - Icmpv6Echo reply(0); + Icmpv6Echo reply(false); Icmpv6DestinationUnreachable destUnreach; Icmpv6TimeExceeded timeExceeded; Inet6SocketAddress address = Inet6SocketAddress::ConvertFrom(from); diff --git a/src/internet-apps/model/radvd-interface.cc b/src/internet-apps/model/radvd-interface.cc index 83d67b019..03a079cf3 100644 --- a/src/internet-apps/model/radvd-interface.cc +++ b/src/internet-apps/model/radvd-interface.cc @@ -86,7 +86,7 @@ RadvdInterface::~RadvdInterface() { NS_LOG_FUNCTION(this); /* clear prefixes */ - for (RadvdPrefixListI it = m_prefixes.begin(); it != m_prefixes.end(); ++it) + for (auto it = m_prefixes.begin(); it != m_prefixes.end(); ++it) { (*it) = nullptr; } diff --git a/src/internet-apps/model/radvd.cc b/src/internet-apps/model/radvd.cc index bb9f92d09..b450ad8ab 100644 --- a/src/internet-apps/model/radvd.cc +++ b/src/internet-apps/model/radvd.cc @@ -75,7 +75,7 @@ Radvd::Radvd() Radvd::~Radvd() { NS_LOG_FUNCTION(this); - for (RadvdInterfaceListI it = m_configurations.begin(); it != m_configurations.end(); ++it) + for (auto it = m_configurations.begin(); it != m_configurations.end(); ++it) { *it = nullptr; } @@ -91,7 +91,7 @@ Radvd::DoDispose() m_recvSocket->Close(); m_recvSocket = nullptr; - for (SocketMapI it = m_sendSockets.begin(); it != m_sendSockets.end(); ++it) + for (auto it = m_sendSockets.begin(); it != m_sendSockets.end(); ++it) { it->second->Close(); it->second = nullptr; @@ -120,7 +120,7 @@ Radvd::StartApplication() m_recvSocket->SetRecvPktInfo(true); } - for (RadvdInterfaceListCI it = m_configurations.begin(); it != m_configurations.end(); it++) + for (auto it = m_configurations.begin(); it != m_configurations.end(); it++) { if ((*it)->IsSendAdvert()) { @@ -159,13 +159,13 @@ Radvd::StopApplication() m_recvSocket->SetRecvCallback(MakeNullCallback>()); } - for (EventIdMapI it = m_unsolicitedEventIds.begin(); it != m_unsolicitedEventIds.end(); ++it) + for (auto it = m_unsolicitedEventIds.begin(); it != m_unsolicitedEventIds.end(); ++it) { Simulator::Cancel((*it).second); } m_unsolicitedEventIds.clear(); - for (EventIdMapI it = m_solicitedEventIds.begin(); it != m_solicitedEventIds.end(); ++it) + for (auto it = m_solicitedEventIds.begin(); it != m_solicitedEventIds.end(); ++it) { Simulator::Cancel((*it).second); } @@ -231,8 +231,7 @@ Radvd::Send(Ptr config, Ipv6Address dst, bool reschedule) } /* add list of prefixes */ - for (std::list>::const_iterator jt = prefixes.begin(); jt != prefixes.end(); - jt++) + for (auto jt = prefixes.begin(); jt != prefixes.end(); jt++) { uint8_t flags = 0; prefixHdr = Icmpv6OptionPrefixInformation(); @@ -288,7 +287,7 @@ Radvd::Send(Ptr config, Ipv6Address dst, bool reschedule) if (reschedule) { - uint64_t delay = static_cast( + auto delay = static_cast( m_jitter->GetValue(config->GetMinRtrAdvInterval(), config->GetMaxRtrAdvInterval()) + 0.5); if (config->IsInitialRtrAdv()) @@ -348,9 +347,7 @@ Radvd::HandleRead(Ptr socket) NS_LOG_INFO("Received ICMPv6 Router Solicitation from " << hdr.GetSource() << " code = " << (uint32_t)rsHdr.GetCode()); - for (RadvdInterfaceListCI it = m_configurations.begin(); - it != m_configurations.end(); - it++) + for (auto it = m_configurations.begin(); it != m_configurations.end(); it++) { if (ipInterfaceIndex == (*it)->GetInterface()) { diff --git a/src/internet-apps/model/v4ping.cc b/src/internet-apps/model/v4ping.cc index d18ba208a..9a817a6d0 100644 --- a/src/internet-apps/model/v4ping.cc +++ b/src/internet-apps/model/v4ping.cc @@ -137,11 +137,11 @@ V4Ping::Receive(Ptr socket) { Icmpv4Echo echo; p->RemoveHeader(echo); - std::map::iterator i = m_sent.find(echo.GetSequenceNumber()); + auto i = m_sent.find(echo.GetSequenceNumber()); if (i != m_sent.end() && echo.GetIdentifier() == 0) { - uint32_t* buf = new uint32_t[m_size]; + auto buf = new uint32_t[m_size]; uint32_t dataSize = echo.GetDataSize(); uint32_t nodeId; uint32_t appId; @@ -215,7 +215,7 @@ V4Ping::Send() // (where any difference would show up anyway) and borrow that code. Don't // be too surprised when you see that this is a little endian convention. // - uint8_t* data = new uint8_t[m_size]; + auto data = new uint8_t[m_size]; for (uint32_t i = 0; i < m_size; ++i) { data[i] = 0; diff --git a/src/internet-apps/model/v4traceroute.cc b/src/internet-apps/model/v4traceroute.cc index 1bff07cbd..b63919379 100644 --- a/src/internet-apps/model/v4traceroute.cc +++ b/src/internet-apps/model/v4traceroute.cc @@ -243,7 +243,7 @@ V4TraceRoute::Receive(Ptr socket) recvSeq = (uint16_t)data[7] << 0; recvSeq |= (uint16_t)data[6] << 8; - std::map::iterator i = m_sent.find(recvSeq); + auto i = m_sent.find(recvSeq); if (i != m_sent.end()) { Time sendTime = i->second; @@ -296,7 +296,7 @@ V4TraceRoute::Receive(Ptr socket) Icmpv4Echo echo; p->RemoveHeader(echo); - std::map::iterator i = m_sent.find(echo.GetSequenceNumber()); + auto i = m_sent.find(echo.GetSequenceNumber()); if (i != m_sent.end() && echo.GetIdentifier() == 0) { diff --git a/src/internet-apps/test/ping-test.cc b/src/internet-apps/test/ping-test.cc index 2114d9000..a09327b15 100644 --- a/src/internet-apps/test/ping-test.cc +++ b/src/internet-apps/test/ping-test.cc @@ -576,7 +576,7 @@ PingTestSuite::PingTestSuite() // number sent equals number received, which equals 5. // How validated: PingReport trace is checked for number of packets // transmitted and received (5), and number of drops (0). - PingTestCase* testcase1v4 = new PingTestCase( + auto testcase1v4 = new PingTestCase( "1. Unlimited pings, no losses, StopApplication () with no packets in flight IPv4", USEIPV6_FALSE); testcase1v4->SetStartTime(Seconds(1)); @@ -588,7 +588,7 @@ PingTestSuite::PingTestSuite() testcase1v4->SetDestinationAddress(Ipv4Address("10.0.0.2")); AddTestCase(testcase1v4, TestCase::QUICK); - PingTestCase* testcase1v6 = new PingTestCase( + auto testcase1v6 = new PingTestCase( "1. Unlimited pings, no losses, StopApplication () with no packets in flight IPv6", USEIPV6_TRUE); testcase1v6->SetStartTime(Seconds(1)); @@ -608,7 +608,7 @@ PingTestSuite::PingTestSuite() // to be lost // How validated: PingReport trace is checked for number of packets // transmitted (1) and received (0), and number of drops (0) - PingTestCase* testcase2v4 = new PingTestCase( + auto testcase2v4 = new PingTestCase( "2. Unlimited pings, no losses, StopApplication () with 1 packet in flight IPv4", USEIPV6_FALSE); testcase2v4->SetStartTime(Seconds(1)); @@ -619,7 +619,7 @@ PingTestSuite::PingTestSuite() testcase1v4->SetDestinationAddress(Ipv4Address("10.0.0.2")); AddTestCase(testcase2v4, TestCase::QUICK); - PingTestCase* testcase2v6 = new PingTestCase( + auto testcase2v6 = new PingTestCase( "2. Unlimited pings, no losses, StopApplication () with 1 packet in flight IPv6", USEIPV6_TRUE); testcase2v6->SetStartTime(Seconds(1)); @@ -645,10 +645,9 @@ PingTestSuite::PingTestSuite() // Report time will be MicroSeconds (2020001). uint32_t count = 2; uint32_t expectedTx = 2; - PingTestCase* testcase3v4 = - new PingTestCase("3. Test for operation of count attribute and exit " - "time after all pings were received, IPv4", - USEIPV6_FALSE); + auto testcase3v4 = new PingTestCase("3. Test for operation of count attribute and exit " + "time after all pings were received, IPv4", + USEIPV6_FALSE); testcase3v4->SetStartTime(Seconds(1)); testcase3v4->SetStopTime(Seconds(5)); testcase3v4->SetCount(count); @@ -660,10 +659,9 @@ PingTestSuite::PingTestSuite() testcase3v4->SetDestinationAddress(Ipv4Address("10.0.0.2")); AddTestCase(testcase3v4, TestCase::QUICK); - PingTestCase* testcase3v6 = - new PingTestCase("3. Test for operation of count attribute and exit " - "time after all pings were received, IPv6", - USEIPV6_TRUE); + auto testcase3v6 = new PingTestCase("3. Test for operation of count attribute and exit " + "time after all pings were received, IPv6", + USEIPV6_TRUE); testcase3v6->SetStartTime(Seconds(1)); testcase3v6->SetStopTime(Seconds(5)); testcase3v6->SetCount(count); @@ -685,7 +683,7 @@ PingTestSuite::PingTestSuite() // How validated: PingReport trace is checked for number of packets // transmitted (2) and received (2), and number of drops (0) Time interval = Seconds(3.0); - PingTestCase* testcase4v4 = + auto testcase4v4 = new PingTestCase("4. Test for the operation of interval attribute for IPv4", USEIPV6_FALSE); testcase4v4->SetStartTime(Seconds(1)); testcase4v4->SetStopTime(Seconds(5)); @@ -696,7 +694,7 @@ PingTestSuite::PingTestSuite() testcase4v4->SetDestinationAddress(Ipv4Address("10.0.0.2")); AddTestCase(testcase4v4, TestCase::QUICK); - PingTestCase* testcase4v6 = + auto testcase4v6 = new PingTestCase("4. Test for the operation of interval attribute for IPv6", USEIPV6_TRUE); testcase4v6->SetStartTime(Seconds(1)); testcase4v6->SetStopTime(Seconds(5)); @@ -724,7 +722,7 @@ PingTestSuite::PingTestSuite() // How validated: PingReport trace is checked for number of packets // transmitted (5) and received (0). // The packet loss rate should be checked to be 100 percent - PingTestCase* testcase5v4 = + auto testcase5v4 = new PingTestCase("5. Test for behavior of ping to unreachable IPv4 address", USEIPV6_FALSE); testcase5v4->SetStartTime(Seconds(1)); testcase5v4->SetStopTime(Seconds(5.5)); @@ -734,7 +732,7 @@ PingTestSuite::PingTestSuite() testcase5v4->CheckReportLoss(100); AddTestCase(testcase5v4, TestCase::QUICK); - PingTestCase* testcase5v6 = + auto testcase5v6 = new PingTestCase("5. Test for behavior of ping to unreachable IPv6 address", USEIPV6_TRUE); testcase5v6->SetStartTime(Seconds(1)); testcase5v6->SetStopTime(Seconds(5.5)); @@ -757,7 +755,7 @@ PingTestSuite::PingTestSuite() // How validated: PingReport trace is checked for number of packets // transmitted (2) and received (2),number of drops (0), // Report time will be MicroSeconds (2020001). - PingTestCase* testcase6v4 = + auto testcase6v4 = new PingTestCase("6. Test for behavior of ping to broadcast IPv4 address", USEIPV6_FALSE); testcase6v4->SetStartTime(Seconds(1)); testcase6v4->SetStopTime(Seconds(5.5)); @@ -767,7 +765,7 @@ PingTestSuite::PingTestSuite() testcase6v4->CheckReportLoss(0); AddTestCase(testcase6v4, TestCase::QUICK); - PingTestCase* testcase6v6 = + auto testcase6v6 = new PingTestCase("6. Test for behavior of ping to all-nodes multicast IPv6 address", USEIPV6_TRUE); testcase6v6->SetStartTime(Seconds(1)); @@ -791,7 +789,7 @@ PingTestSuite::PingTestSuite() // transmitted (3) and received (2), loss percentage (33). // Ping Tx trace (3) and Rtt trace (2) are also checked. // Report time will be MicroSeconds (3040000). - PingTestCase* testcase7v4 = new PingTestCase( + auto testcase7v4 = new PingTestCase( "7. Test behavior of first reply lost in a count-limited configuration, IPv4", USEIPV6_FALSE); std::list dropList{0}; @@ -807,7 +805,7 @@ PingTestSuite::PingTestSuite() testcase7v4->CheckReportTime(MicroSeconds(3040000)); AddTestCase(testcase7v4, TestCase::QUICK); - PingTestCase* testcase7v6 = new PingTestCase( + auto testcase7v6 = new PingTestCase( "7. Test behavior of first reply lost in a count-limited configuration, IPv6", USEIPV6_TRUE); testcase7v6->SetDropList(dropList); @@ -836,7 +834,7 @@ PingTestSuite::PingTestSuite() // transmitted (3) and received (2), loss percentage (33). // Ping Tx trace (3) and Rtt trace (2) are also checked. // Report time will be MicroSeconds (3040000). - PingTestCase* testcase8v4 = new PingTestCase( + auto testcase8v4 = new PingTestCase( "8. Test behavior of second reply lost in a count-limited configuration, IPv4", USEIPV6_FALSE); std::list dropList2{1}; @@ -852,7 +850,7 @@ PingTestSuite::PingTestSuite() testcase8v4->CheckReportTime(MicroSeconds(3040000)); AddTestCase(testcase8v4, TestCase::QUICK); - PingTestCase* testcase8v6 = new PingTestCase( + auto testcase8v6 = new PingTestCase( "8. Test behavior of second reply lost in a count-limited configuration, IPv6", USEIPV6_TRUE); testcase8v6->SetDropList(dropList2); @@ -881,7 +879,7 @@ PingTestSuite::PingTestSuite() // transmitted (3) and received (2), loss percentage (33). // Ping Tx trace (3) and Rtt trace (2) are also checked. // Report time will be MicroSeconds (3040000). - PingTestCase* testcase9v4 = new PingTestCase( + auto testcase9v4 = new PingTestCase( "9. Test behavior of last reply lost in a count-limited configuration, IPv4", USEIPV6_FALSE); std::list dropList3{2}; @@ -897,7 +895,7 @@ PingTestSuite::PingTestSuite() testcase9v4->CheckReportTime(MicroSeconds(3040000)); AddTestCase(testcase9v4, TestCase::QUICK); - PingTestCase* testcase9v6 = new PingTestCase( + auto testcase9v6 = new PingTestCase( "9. Test behavior of last reply lost in a count-limited configuration, IPv6", USEIPV6_TRUE); testcase9v6->SetDropList(dropList3); diff --git a/src/internet/doc/tcp.rst b/src/internet/doc/tcp.rst index 445dea31e..bb4a1ca52 100644 --- a/src/internet/doc/tcp.rst +++ b/src/internet/doc/tcp.rst @@ -456,7 +456,7 @@ cwnd, 'bytes_acked' is reduced by the value of cwnd. Next, cwnd is incremented by a full-sized segment (SMSS). In contrast, in ns-3 NewReno, cwnd is increased by (1/cwnd) with a rounding off due to type casting into int. -.. code-block:: +.. code-block:: c++ :caption: Linux Reno `cwnd` update if (m_cWndCnt >= w) @@ -469,7 +469,7 @@ by (1/cwnd) with a rounding off due to type casting into int. } -.. code-block:: +.. code-block:: c++ :caption: New Reno `cwnd` update if (segmentsAcked > 0) @@ -1840,7 +1840,7 @@ advertises a zero window. This can be accomplished by implementing the method CreateReceiverSocket, setting an Rx buffer value of 0 bytes (at line 6 of the following code): -.. code-block:: +.. code-block:: c++ :linenos: :emphasize-lines: 6,7,8 @@ -1987,7 +1987,7 @@ we expect the persistent timer to fire before any rWnd changes. When it fires, the SENDER should send a window probe, and the receiver should reply reporting again a zero window situation. At first, we investigates on what the sender sends: -.. code-block:: +.. code-block:: c++ :linenos: :emphasize-lines: 1,6,7,11 @@ -2020,7 +2020,7 @@ reader: edit the test, getting this value from the Attribute system), we need to check (line 6) between 6.0 and 7.0 simulated seconds that the probe is sent. Only one probe is allowed, and this is the reason for the check at line 11. -.. code-block:: +.. code-block:: c++ :linenos: :emphasize-lines: 6,7 @@ -2072,7 +2072,7 @@ the window should be greater than zero (and precisely, set to 2500): To be sure that the sender receives the window update, we can use the Rx method: -.. code-block:: +.. code-block:: c++ :linenos: :emphasize-lines: 5 @@ -2137,7 +2137,6 @@ To see INFO messages, use a combination of ./ns3 shell and gdb (really useful): .. code-block:: bash - ./ns3 shell && gdb --args ./build/utils/ns3-dev-test-runner-debug --test-name=tcp-zero-window-test --stop-on-failure --fullness=QUICK --assert-on-failure --verbose and then, hit "Run". diff --git a/src/internet/helper/internet-stack-helper.cc b/src/internet/helper/internet-stack-helper.cc index 67b7ecd19..0760a4d57 100644 --- a/src/internet/helper/internet-stack-helper.cc +++ b/src/internet/helper/internet-stack-helper.cc @@ -223,7 +223,7 @@ int64_t InternetStackHelper::AssignStreams(NodeContainer c, int64_t stream) { int64_t currentStream = stream; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr router = node->GetObject(); @@ -267,7 +267,7 @@ InternetStackHelper::AssignStreams(NodeContainer c, int64_t stream) void InternetStackHelper::Install(NodeContainer c) const { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Install(*i); } @@ -404,11 +404,11 @@ Ipv4L3ProtocolRxTxSink(Ptr p, Ptr ipv4, uint32_t interface) bool InternetStackHelper::PcapHooked(Ptr ipv4) { - for (InterfaceFileMapIpv4::const_iterator i = g_interfaceFileMapIpv4.begin(); - i != g_interfaceFileMapIpv4.end(); - ++i) + auto id = ipv4->GetObject()->GetId(); + + for (auto i = g_interfaceFileMapIpv4.begin(); i != g_interfaceFileMapIpv4.end(); ++i) { - if ((*i).first.first == ipv4->GetObject()->GetId()) + if ((*i).first.first == id) { return true; } @@ -510,11 +510,11 @@ Ipv6L3ProtocolRxTxSink(Ptr p, Ptr ipv6, uint32_t interface) bool InternetStackHelper::PcapHooked(Ptr ipv6) { - for (InterfaceFileMapIpv6::const_iterator i = g_interfaceFileMapIpv6.begin(); - i != g_interfaceFileMapIpv6.end(); - ++i) + auto id = ipv6->GetObject()->GetId(); + + for (auto i = g_interfaceFileMapIpv6.begin(); i != g_interfaceFileMapIpv6.end(); ++i) { - if ((*i).first.first == ipv6->GetObject()->GetId()) + if ((*i).first.first == id) { return true; } @@ -774,11 +774,11 @@ Ipv4L3ProtocolRxSinkWithContext(Ptr stream, bool InternetStackHelper::AsciiHooked(Ptr ipv4) { - for (InterfaceStreamMapIpv4::const_iterator i = g_interfaceStreamMapIpv4.begin(); - i != g_interfaceStreamMapIpv4.end(); - ++i) + auto id = ipv4->GetObject()->GetId(); + + for (auto i = g_interfaceStreamMapIpv4.begin(); i != g_interfaceStreamMapIpv4.end(); ++i) { - if ((*i).first.first == ipv4->GetObject()->GetId()) + if ((*i).first.first == id) { return true; } @@ -1118,11 +1118,11 @@ Ipv6L3ProtocolRxSinkWithContext(Ptr stream, bool InternetStackHelper::AsciiHooked(Ptr ipv6) { - for (InterfaceStreamMapIpv6::const_iterator i = g_interfaceStreamMapIpv6.begin(); - i != g_interfaceStreamMapIpv6.end(); - ++i) + auto id = ipv6->GetObject()->GetId(); + + for (auto i = g_interfaceStreamMapIpv6.begin(); i != g_interfaceStreamMapIpv6.end(); ++i) { - if ((*i).first.first == ipv6->GetObject()->GetId()) + if ((*i).first.first == id) { return true; } diff --git a/src/internet/helper/internet-trace-helper.cc b/src/internet/helper/internet-trace-helper.cc index d461fcbc1..c75919b17 100644 --- a/src/internet/helper/internet-trace-helper.cc +++ b/src/internet/helper/internet-trace-helper.cc @@ -57,17 +57,16 @@ PcapHelperForIpv4::EnablePcapIpv4(std::string prefix, void PcapHelperForIpv4::EnablePcapIpv4(std::string prefix, Ipv4InterfaceContainer c) { - for (Ipv4InterfaceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { - std::pair, uint32_t> pair = *i; - EnablePcapIpv4(prefix, pair.first, pair.second, false); + EnablePcapIpv4(prefix, (*i).first, (*i).second, false); } } void PcapHelperForIpv4::EnablePcapIpv4(std::string prefix, NodeContainer n) { - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; Ptr ipv4 = node->GetObject(); @@ -95,7 +94,7 @@ PcapHelperForIpv4::EnablePcapIpv4(std::string prefix, { NodeContainer n = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; if (node->GetId() != nodeid) @@ -198,10 +197,9 @@ AsciiTraceHelperForIpv4::EnableAsciiIpv4Impl(Ptr stream, std::string prefix, Ipv4InterfaceContainer c) { - for (Ipv4InterfaceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { - std::pair, uint32_t> pair = *i; - EnableAsciiIpv4Internal(stream, prefix, pair.first, pair.second, false); + EnableAsciiIpv4Internal(stream, prefix, (*i).first, (*i).second, false); } } @@ -231,7 +229,7 @@ AsciiTraceHelperForIpv4::EnableAsciiIpv4Impl(Ptr stream, std::string prefix, NodeContainer n) { - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; Ptr ipv4 = node->GetObject(); @@ -299,7 +297,7 @@ AsciiTraceHelperForIpv4::EnableAsciiIpv4Impl(Ptr stream, { NodeContainer n = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; if (node->GetId() != nodeid) @@ -339,17 +337,16 @@ PcapHelperForIpv6::EnablePcapIpv6(std::string prefix, void PcapHelperForIpv6::EnablePcapIpv6(std::string prefix, Ipv6InterfaceContainer c) { - for (Ipv6InterfaceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { - std::pair, uint32_t> pair = *i; - EnablePcapIpv6(prefix, pair.first, pair.second, false); + EnablePcapIpv6(prefix, (*i).first, (*i).second, false); } } void PcapHelperForIpv6::EnablePcapIpv6(std::string prefix, NodeContainer n) { - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; Ptr ipv6 = node->GetObject(); @@ -377,7 +374,7 @@ PcapHelperForIpv6::EnablePcapIpv6(std::string prefix, { NodeContainer n = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; if (node->GetId() != nodeid) @@ -480,10 +477,9 @@ AsciiTraceHelperForIpv6::EnableAsciiIpv6Impl(Ptr stream, std::string prefix, Ipv6InterfaceContainer c) { - for (Ipv6InterfaceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { - std::pair, uint32_t> pair = *i; - EnableAsciiIpv6Internal(stream, prefix, pair.first, pair.second, false); + EnableAsciiIpv6Internal(stream, prefix, (*i).first, (*i).second, false); } } @@ -513,7 +509,7 @@ AsciiTraceHelperForIpv6::EnableAsciiIpv6Impl(Ptr stream, std::string prefix, NodeContainer n) { - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; Ptr ipv6 = node->GetObject(); @@ -580,7 +576,7 @@ AsciiTraceHelperForIpv6::EnableAsciiIpv6Impl(Ptr stream, { NodeContainer n = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; if (node->GetId() != nodeid) diff --git a/src/internet/helper/internet-trace-helper.h b/src/internet/helper/internet-trace-helper.h index 28c591e0c..dfd8a5105 100644 --- a/src/internet/helper/internet-trace-helper.h +++ b/src/internet/helper/internet-trace-helper.h @@ -18,10 +18,11 @@ #ifndef INTERNET_TRACE_HELPER_H #define INTERNET_TRACE_HELPER_H +#include "ipv4-interface-container.h" +#include "ipv6-interface-container.h" + #include "ns3/assert.h" -#include "ns3/ipv4-interface-container.h" #include "ns3/ipv4.h" -#include "ns3/ipv6-interface-container.h" #include "ns3/ipv6.h" #include "ns3/trace-helper.h" diff --git a/src/internet/helper/ipv4-global-routing-helper.h b/src/internet/helper/ipv4-global-routing-helper.h index 9007a015c..b3eac3ab9 100644 --- a/src/internet/helper/ipv4-global-routing-helper.h +++ b/src/internet/helper/ipv4-global-routing-helper.h @@ -19,7 +19,8 @@ #ifndef IPV4_GLOBAL_ROUTING_HELPER_H #define IPV4_GLOBAL_ROUTING_HELPER_H -#include "ns3/ipv4-routing-helper.h" +#include "ipv4-routing-helper.h" + #include "ns3/node-container.h" namespace ns3 diff --git a/src/internet/helper/ipv4-interface-container.cc b/src/internet/helper/ipv4-interface-container.cc index 15d589ed6..0a80d6d5c 100644 --- a/src/internet/helper/ipv4-interface-container.cc +++ b/src/internet/helper/ipv4-interface-container.cc @@ -32,9 +32,7 @@ Ipv4InterfaceContainer::Ipv4InterfaceContainer() void Ipv4InterfaceContainer::Add(const Ipv4InterfaceContainer& other) { - for (InterfaceVector::const_iterator i = other.m_interfaces.begin(); - i != other.m_interfaces.end(); - i++) + for (auto i = other.m_interfaces.begin(); i != other.m_interfaces.end(); i++) { m_interfaces.push_back(*i); } diff --git a/src/internet/helper/ipv4-list-routing-helper.cc b/src/internet/helper/ipv4-list-routing-helper.cc index 9f5707d66..22db916e7 100644 --- a/src/internet/helper/ipv4-list-routing-helper.cc +++ b/src/internet/helper/ipv4-list-routing-helper.cc @@ -30,9 +30,7 @@ Ipv4ListRoutingHelper::Ipv4ListRoutingHelper() Ipv4ListRoutingHelper::~Ipv4ListRoutingHelper() { - for (std::list>::iterator i = m_list.begin(); - i != m_list.end(); - ++i) + for (auto i = m_list.begin(); i != m_list.end(); ++i) { delete i->first; } @@ -40,8 +38,7 @@ Ipv4ListRoutingHelper::~Ipv4ListRoutingHelper() Ipv4ListRoutingHelper::Ipv4ListRoutingHelper(const Ipv4ListRoutingHelper& o) { - std::list>::const_iterator i; - for (i = o.m_list.begin(); i != o.m_list.end(); ++i) + for (auto i = o.m_list.begin(); i != o.m_list.end(); ++i) { m_list.emplace_back(const_cast(i->first->Copy()), i->second); } @@ -63,9 +60,7 @@ Ptr Ipv4ListRoutingHelper::Create(Ptr node) const { Ptr list = CreateObject(); - for (std::list>::const_iterator i = m_list.begin(); - i != m_list.end(); - ++i) + for (auto i = m_list.begin(); i != m_list.end(); ++i) { Ptr prot = i->first->Create(node); list->AddRoutingProtocol(prot, i->second); diff --git a/src/internet/helper/ipv4-list-routing-helper.h b/src/internet/helper/ipv4-list-routing-helper.h index 3e151149a..b6b1d2250 100644 --- a/src/internet/helper/ipv4-list-routing-helper.h +++ b/src/internet/helper/ipv4-list-routing-helper.h @@ -19,7 +19,7 @@ #ifndef IPV4_LIST_ROUTING_HELPER_H #define IPV4_LIST_ROUTING_HELPER_H -#include "ns3/ipv4-routing-helper.h" +#include "ipv4-routing-helper.h" #include #include diff --git a/src/internet/helper/ipv4-static-routing-helper.cc b/src/internet/helper/ipv4-static-routing-helper.cc index 12f770eeb..87c8f8854 100644 --- a/src/internet/helper/ipv4-static-routing-helper.cc +++ b/src/internet/helper/ipv4-static-routing-helper.cc @@ -97,7 +97,7 @@ Ipv4StaticRoutingHelper::AddMulticastRoute(Ptr n, // We need to convert the NetDeviceContainer to an array of interface // numbers std::vector outputInterfaces; - for (NetDeviceContainer::Iterator i = output.Begin(); i != output.End(); ++i) + for (auto i = output.Begin(); i != output.End(); ++i) { Ptr nd = *i; int32_t interface = ipv4->GetInterfaceForDevice(nd); diff --git a/src/internet/helper/ipv4-static-routing-helper.h b/src/internet/helper/ipv4-static-routing-helper.h index 2663a2cef..ee685540c 100644 --- a/src/internet/helper/ipv4-static-routing-helper.h +++ b/src/internet/helper/ipv4-static-routing-helper.h @@ -18,8 +18,9 @@ #ifndef IPV4_STATIC_ROUTING_HELPER_H #define IPV4_STATIC_ROUTING_HELPER_H +#include "ipv4-routing-helper.h" + #include "ns3/ipv4-address.h" -#include "ns3/ipv4-routing-helper.h" #include "ns3/ipv4-static-routing.h" #include "ns3/ipv4.h" #include "ns3/net-device-container.h" diff --git a/src/internet/helper/ipv6-address-helper.cc b/src/internet/helper/ipv6-address-helper.cc index ace31bcc3..28db659fc 100644 --- a/src/internet/helper/ipv6-address-helper.cc +++ b/src/internet/helper/ipv6-address-helper.cc @@ -220,11 +220,7 @@ Ipv6InterfaceContainer Ipv6AddressHelper::Assign(const NetDeviceContainer& c) { NS_LOG_FUNCTION(this); - std::vector withConfiguration; - for (uint32_t i = 0; i < c.GetN(); ++i) - { - withConfiguration.push_back(true); - } + std::vector withConfiguration(c.GetN(), true); return Assign(c, withConfiguration); } @@ -232,11 +228,7 @@ Ipv6InterfaceContainer Ipv6AddressHelper::Assign(const NetDeviceContainer& c, std::vector withConfiguration) { NS_LOG_FUNCTION(this); - std::vector onLink; - for (uint32_t i = 0; i < c.GetN(); ++i) - { - onLink.push_back(true); - } + std::vector onLink(c.GetN(), true); return Assign(c, withConfiguration, onLink); } @@ -312,11 +304,7 @@ Ipv6InterfaceContainer Ipv6AddressHelper::AssignWithoutAddress(const NetDeviceContainer& c) { NS_LOG_FUNCTION(this); - std::vector withConfiguration; - for (uint32_t i = 0; i < c.GetN(); ++i) - { - withConfiguration.push_back(false); - } + std::vector withConfiguration(c.GetN(), false); return Assign(c, withConfiguration); } @@ -324,13 +312,10 @@ Ipv6InterfaceContainer Ipv6AddressHelper::AssignWithoutOnLink(const NetDeviceContainer& c) { NS_LOG_FUNCTION(this); - std::vector withConfiguration; - std::vector onLink; - for (uint32_t i = 0; i < c.GetN(); ++i) - { - withConfiguration.push_back(true); - onLink.push_back(false); - } + + std::vector withConfiguration(c.GetN(), true); + std::vector onLink(c.GetN(), false); + return Assign(c, withConfiguration, onLink); } diff --git a/src/internet/helper/ipv6-interface-container.cc b/src/internet/helper/ipv6-interface-container.cc index 9018c3baf..2f9003763 100644 --- a/src/internet/helper/ipv6-interface-container.cc +++ b/src/internet/helper/ipv6-interface-container.cc @@ -81,8 +81,7 @@ Ipv6InterfaceContainer::Add(std::string ipv6Name, uint32_t interface) void Ipv6InterfaceContainer::Add(const Ipv6InterfaceContainer& c) { - for (InterfaceVector::const_iterator it = c.m_interfaces.begin(); it != c.m_interfaces.end(); - it++) + for (auto it = c.m_interfaces.begin(); it != c.m_interfaces.end(); it++) { m_interfaces.push_back(*it); } diff --git a/src/internet/helper/ipv6-list-routing-helper.cc b/src/internet/helper/ipv6-list-routing-helper.cc index 896a00f77..4547ac59f 100644 --- a/src/internet/helper/ipv6-list-routing-helper.cc +++ b/src/internet/helper/ipv6-list-routing-helper.cc @@ -31,9 +31,7 @@ Ipv6ListRoutingHelper::Ipv6ListRoutingHelper() Ipv6ListRoutingHelper::~Ipv6ListRoutingHelper() { - for (std::list>::iterator i = m_list.begin(); - i != m_list.end(); - ++i) + for (auto i = m_list.begin(); i != m_list.end(); ++i) { delete i->first; } @@ -41,8 +39,7 @@ Ipv6ListRoutingHelper::~Ipv6ListRoutingHelper() Ipv6ListRoutingHelper::Ipv6ListRoutingHelper(const Ipv6ListRoutingHelper& o) { - std::list>::const_iterator i; - for (i = o.m_list.begin(); i != o.m_list.end(); ++i) + for (auto i = o.m_list.begin(); i != o.m_list.end(); ++i) { m_list.emplace_back(const_cast(i->first->Copy()), i->second); } @@ -64,9 +61,7 @@ Ptr Ipv6ListRoutingHelper::Create(Ptr node) const { Ptr list = CreateObject(); - for (std::list>::const_iterator i = m_list.begin(); - i != m_list.end(); - ++i) + for (auto i = m_list.begin(); i != m_list.end(); ++i) { Ptr prot = i->first->Create(node); list->AddRoutingProtocol(prot, i->second); diff --git a/src/internet/helper/ipv6-list-routing-helper.h b/src/internet/helper/ipv6-list-routing-helper.h index 58b84b869..e62c5a728 100644 --- a/src/internet/helper/ipv6-list-routing-helper.h +++ b/src/internet/helper/ipv6-list-routing-helper.h @@ -19,7 +19,7 @@ #ifndef IPV6_LIST_ROUTING_HELPER_H #define IPV6_LIST_ROUTING_HELPER_H -#include "ns3/ipv6-routing-helper.h" +#include "ipv6-routing-helper.h" #include #include diff --git a/src/internet/helper/ipv6-static-routing-helper.cc b/src/internet/helper/ipv6-static-routing-helper.cc index 2979782a6..82f886405 100644 --- a/src/internet/helper/ipv6-static-routing-helper.cc +++ b/src/internet/helper/ipv6-static-routing-helper.cc @@ -97,7 +97,7 @@ Ipv6StaticRoutingHelper::AddMulticastRoute(Ptr n, // We need to convert the NetDeviceContainer to an array of interface // numbers std::vector outputInterfaces; - for (NetDeviceContainer::Iterator i = output.Begin(); i != output.End(); ++i) + for (auto i = output.Begin(); i != output.End(); ++i) { Ptr nd = *i; int32_t interface = ipv6->GetInterfaceForDevice(nd); diff --git a/src/internet/helper/ipv6-static-routing-helper.h b/src/internet/helper/ipv6-static-routing-helper.h index 0da049a14..b76a70013 100644 --- a/src/internet/helper/ipv6-static-routing-helper.h +++ b/src/internet/helper/ipv6-static-routing-helper.h @@ -18,8 +18,9 @@ #ifndef IPV6_STATIC_ROUTING_HELPER_H #define IPV6_STATIC_ROUTING_HELPER_H +#include "ipv6-routing-helper.h" + #include "ns3/ipv6-address.h" -#include "ns3/ipv6-routing-helper.h" #include "ns3/ipv6-static-routing.h" #include "ns3/ipv6.h" #include "ns3/net-device-container.h" diff --git a/src/internet/helper/neighbor-cache-helper.h b/src/internet/helper/neighbor-cache-helper.h index a99000c10..c52418ec2 100644 --- a/src/internet/helper/neighbor-cache-helper.h +++ b/src/internet/helper/neighbor-cache-helper.h @@ -20,16 +20,17 @@ #ifndef NEIGHBOR_CACHE_HELPER_H #define NEIGHBOR_CACHE_HELPER_H +#include "ipv4-interface-container.h" +#include "ipv6-interface-container.h" + #include "ns3/arp-cache.h" #include "ns3/arp-header.h" #include "ns3/arp-l3-protocol.h" #include "ns3/channel.h" #include "ns3/icmpv6-l4-protocol.h" #include "ns3/ipv4-address.h" -#include "ns3/ipv4-interface-container.h" #include "ns3/ipv4-interface.h" #include "ns3/ipv4-l3-protocol.h" -#include "ns3/ipv6-interface-container.h" #include "ns3/ipv6-interface.h" #include "ns3/ipv6-l3-protocol.h" #include "ns3/net-device-container.h" diff --git a/src/internet/helper/rip-helper.cc b/src/internet/helper/rip-helper.cc index 3ad46a263..1f7b18842 100644 --- a/src/internet/helper/rip-helper.cc +++ b/src/internet/helper/rip-helper.cc @@ -56,20 +56,18 @@ RipHelper::Create(Ptr node) const { Ptr rip = m_factory.Create(); - std::map, std::set>::const_iterator it = m_interfaceExclusions.find(node); + auto it = m_interfaceExclusions.find(node); if (it != m_interfaceExclusions.end()) { rip->SetInterfaceExclusions(it->second); } - std::map, std::map>::const_iterator iter = - m_interfaceMetrics.find(node); + auto iter = m_interfaceMetrics.find(node); if (iter != m_interfaceMetrics.end()) { - std::map::const_iterator subiter; - for (subiter = iter->second.begin(); subiter != iter->second.end(); subiter++) + for (auto subiter = iter->second.begin(); subiter != iter->second.end(); subiter++) { rip->SetInterfaceMetric(subiter->first, subiter->second); } @@ -90,7 +88,7 @@ RipHelper::AssignStreams(NodeContainer c, int64_t stream) { int64_t currentStream = stream; Ptr node; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); Ptr ipv4 = node->GetObject(); @@ -160,7 +158,7 @@ RipHelper::SetDefaultRouter(Ptr node, Ipv4Address nextHop, uint32_t interf void RipHelper::ExcludeInterface(Ptr node, uint32_t interface) { - std::map, std::set>::iterator it = m_interfaceExclusions.find(node); + auto it = m_interfaceExclusions.find(node); if (it == m_interfaceExclusions.end()) { diff --git a/src/internet/helper/rip-helper.h b/src/internet/helper/rip-helper.h index 92d575d23..dc7064347 100644 --- a/src/internet/helper/rip-helper.h +++ b/src/internet/helper/rip-helper.h @@ -20,7 +20,8 @@ #ifndef RIP_HELPER_H #define RIP_HELPER_H -#include "ns3/ipv4-routing-helper.h" +#include "ipv4-routing-helper.h" + #include "ns3/node-container.h" #include "ns3/node.h" #include "ns3/object-factory.h" diff --git a/src/internet/helper/ripng-helper.cc b/src/internet/helper/ripng-helper.cc index 275fed0e4..de11d924f 100644 --- a/src/internet/helper/ripng-helper.cc +++ b/src/internet/helper/ripng-helper.cc @@ -58,20 +58,18 @@ RipNgHelper::Create(Ptr node) const { Ptr ripng = m_factory.Create(); - std::map, std::set>::const_iterator it = m_interfaceExclusions.find(node); + auto it = m_interfaceExclusions.find(node); if (it != m_interfaceExclusions.end()) { ripng->SetInterfaceExclusions(it->second); } - std::map, std::map>::const_iterator iter = - m_interfaceMetrics.find(node); + auto iter = m_interfaceMetrics.find(node); if (iter != m_interfaceMetrics.end()) { - std::map::const_iterator subiter; - for (subiter = iter->second.begin(); subiter != iter->second.end(); subiter++) + for (auto subiter = iter->second.begin(); subiter != iter->second.end(); subiter++) { ripng->SetInterfaceMetric(subiter->first, subiter->second); } @@ -92,7 +90,7 @@ RipNgHelper::AssignStreams(NodeContainer c, int64_t stream) { int64_t currentStream = stream; Ptr node; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); Ptr ipv6 = node->GetObject(); @@ -162,7 +160,7 @@ RipNgHelper::SetDefaultRouter(Ptr node, Ipv6Address nextHop, uint32_t inte void RipNgHelper::ExcludeInterface(Ptr node, uint32_t interface) { - std::map, std::set>::iterator it = m_interfaceExclusions.find(node); + auto it = m_interfaceExclusions.find(node); if (it == m_interfaceExclusions.end()) { diff --git a/src/internet/helper/ripng-helper.h b/src/internet/helper/ripng-helper.h index e1761ec2d..caf33c07b 100644 --- a/src/internet/helper/ripng-helper.h +++ b/src/internet/helper/ripng-helper.h @@ -20,7 +20,8 @@ #ifndef RIPNG_HELPER_H #define RIPNG_HELPER_H -#include "ns3/ipv6-routing-helper.h" +#include "ipv6-routing-helper.h" + #include "ns3/node-container.h" #include "ns3/node.h" #include "ns3/object-factory.h" diff --git a/src/internet/model/arp-cache.cc b/src/internet/model/arp-cache.cc index 020a5db62..1301b34dd 100644 --- a/src/internet/model/arp-cache.cc +++ b/src/internet/model/arp-cache.cc @@ -199,7 +199,7 @@ ArpCache::HandleWaitReplyTimeout() NS_LOG_FUNCTION(this); ArpCache::Entry* entry; bool restartWaitReplyTimer = false; - for (CacheI i = m_arpCache.begin(); i != m_arpCache.end(); i++) + for (auto i = m_arpCache.begin(); i != m_arpCache.end(); i++) { entry = (*i).second; if (entry != nullptr && entry->IsWaitReply()) @@ -245,7 +245,7 @@ void ArpCache::Flush() { NS_LOG_FUNCTION(this); - for (CacheI i = m_arpCache.begin(); i != m_arpCache.end(); i++) + for (auto i = m_arpCache.begin(); i != m_arpCache.end(); i++) { delete (*i).second; } @@ -264,7 +264,7 @@ ArpCache::PrintArpCache(Ptr stream) NS_LOG_FUNCTION(this << stream); std::ostream* os = stream->GetStream(); - for (CacheI i = m_arpCache.begin(); i != m_arpCache.end(); i++) + for (auto i = m_arpCache.begin(); i != m_arpCache.end(); i++) { *os << i->first << " dev "; std::string found = Names::FindName(m_device); @@ -306,7 +306,7 @@ void ArpCache::RemoveAutoGeneratedEntries() { NS_LOG_FUNCTION(this); - for (CacheI i = m_arpCache.begin(); i != m_arpCache.end();) + for (auto i = m_arpCache.begin(); i != m_arpCache.end();) { if (i->second->IsAutoGenerated()) { @@ -325,7 +325,7 @@ ArpCache::LookupInverse(Address to) NS_LOG_FUNCTION(this << to); std::list entryList; - for (CacheI i = m_arpCache.begin(); i != m_arpCache.end(); i++) + for (auto i = m_arpCache.begin(); i != m_arpCache.end(); i++) { ArpCache::Entry* entry = (*i).second; if (entry->GetMacAddress() == to) @@ -340,7 +340,7 @@ ArpCache::Entry* ArpCache::Lookup(Ipv4Address to) { NS_LOG_FUNCTION(this << to); - CacheI it = m_arpCache.find(to); + auto it = m_arpCache.find(to); if (it != m_arpCache.end()) { return it->second; @@ -354,7 +354,7 @@ ArpCache::Add(Ipv4Address to) NS_LOG_FUNCTION(this << to); NS_ASSERT(m_arpCache.find(to) == m_arpCache.end()); - ArpCache::Entry* entry = new ArpCache::Entry(this); + auto entry = new ArpCache::Entry(this); m_arpCache[to] = entry; entry->SetIpv4Address(to); return entry; @@ -365,7 +365,7 @@ ArpCache::Remove(ArpCache::Entry* entry) { NS_LOG_FUNCTION(this << entry); - for (CacheI i = m_arpCache.begin(); i != m_arpCache.end(); i++) + for (auto i = m_arpCache.begin(); i != m_arpCache.end(); i++) { if ((*i).second == entry) { diff --git a/src/internet/model/arp-l3-protocol.cc b/src/internet/model/arp-l3-protocol.cc index 3031246fc..40de28e9e 100644 --- a/src/internet/model/arp-l3-protocol.cc +++ b/src/internet/model/arp-l3-protocol.cc @@ -131,7 +131,7 @@ void ArpL3Protocol::DoDispose() { NS_LOG_FUNCTION(this); - for (CacheList::iterator i = m_cacheList.begin(); i != m_cacheList.end(); ++i) + for (auto i = m_cacheList.begin(); i != m_cacheList.end(); ++i) { Ptr cache = *i; cache->Dispose(); @@ -160,7 +160,7 @@ Ptr ArpL3Protocol::FindCache(Ptr device) { NS_LOG_FUNCTION(this << device); - for (CacheList::const_iterator i = m_cacheList.begin(); i != m_cacheList.end(); i++) + for (auto i = m_cacheList.begin(); i != m_cacheList.end(); i++) { if ((*i)->GetDevice() == device) { diff --git a/src/internet/model/arp-l3-protocol.h b/src/internet/model/arp-l3-protocol.h index a3833a8d6..f35a6ea15 100644 --- a/src/internet/model/arp-l3-protocol.h +++ b/src/internet/model/arp-l3-protocol.h @@ -19,8 +19,9 @@ #ifndef ARP_L3_PROTOCOL_H #define ARP_L3_PROTOCOL_H +#include "ipv4-header.h" + #include "ns3/address.h" -#include "ns3/ipv4-header.h" #include "ns3/net-device.h" #include "ns3/ptr.h" #include "ns3/random-variable-stream.h" diff --git a/src/internet/model/candidate-queue.cc b/src/internet/model/candidate-queue.cc index 2998f5a4c..b39d867c9 100644 --- a/src/internet/model/candidate-queue.cc +++ b/src/internet/model/candidate-queue.cc @@ -58,12 +58,10 @@ operator<<(std::ostream& os, const SPFVertex::VertexType& t) std::ostream& operator<<(std::ostream& os, const CandidateQueue& q) { - typedef CandidateQueue::CandidateList_t List_t; - typedef List_t::const_iterator CIter_t; const CandidateQueue::CandidateList_t& list = q.m_candidates; os << "*** CandidateQueue Begin () ***" << std::endl; - for (CIter_t iter = list.begin(); iter != list.end(); iter++) + for (auto iter = list.begin(); iter != list.end(); iter++) { os << "<" << (*iter)->GetVertexId() << ", " << (*iter)->GetDistanceFromRoot() << ", " << (*iter)->GetVertexType() << ">" << std::endl; @@ -101,10 +99,10 @@ CandidateQueue::Push(SPFVertex* vNew) { NS_LOG_FUNCTION(this << vNew); - CandidateList_t::iterator i = std::upper_bound(m_candidates.begin(), - m_candidates.end(), - vNew, - &CandidateQueue::CompareSPFVertex); + auto i = std::upper_bound(m_candidates.begin(), + m_candidates.end(), + vNew, + &CandidateQueue::CompareSPFVertex); m_candidates.insert(i, vNew); } @@ -152,7 +150,7 @@ SPFVertex* CandidateQueue::Find(const Ipv4Address addr) const { NS_LOG_FUNCTION(this); - CandidateList_t::const_iterator i = m_candidates.begin(); + auto i = m_candidates.begin(); for (; i != m_candidates.end(); i++) { diff --git a/src/internet/model/global-route-manager-impl.cc b/src/internet/model/global-route-manager-impl.cc index cefa5673c..355649831 100644 --- a/src/internet/model/global-route-manager-impl.cc +++ b/src/internet/model/global-route-manager-impl.cc @@ -62,9 +62,8 @@ operator<<(std::ostream& os, const SPFVertex::NodeExit_t& exit) std::ostream& operator<<(std::ostream& os, const SPFVertex::ListOfSPFVertex_t& vs) { - typedef SPFVertex::ListOfSPFVertex_t::const_iterator CIter_t; os << "{"; - for (CIter_t iter = vs.begin(); iter != vs.end();) + for (auto iter = vs.begin(); iter != vs.end();) { os << (*iter)->m_vertexId; if (++iter != vs.end()) @@ -133,7 +132,7 @@ SPFVertex::~SPFVertex() // find this node from all its parents and remove the entry of this node // from all its parents - for (ListOfSPFVertex_t::iterator piter = m_parents.begin(); piter != m_parents.end(); piter++) + for (auto piter = m_parents.begin(); piter != m_parents.end(); piter++) { // remove the current vertex from its parent's children list. Check // if the size of the list is reduced, or the child<->parent relation @@ -255,7 +254,7 @@ SPFVertex::GetParent(uint32_t i) const NS_LOG_LOGIC("Index to SPFVertex's parent is out-of-range."); return nullptr; } - ListOfSPFVertex_t::const_iterator iter = m_parents.begin(); + auto iter = m_parents.begin(); while (i-- > 0) { iter++; @@ -302,11 +301,10 @@ SPFVertex::NodeExit_t SPFVertex::GetRootExitDirection(uint32_t i) const { NS_LOG_FUNCTION(this << i); - typedef ListOfNodeExit_t::const_iterator CIter_t; NS_ASSERT_MSG(i < m_ecmpRootExits.size(), "Index out-of-range when accessing SPFVertex::m_ecmpRootExits!"); - CIter_t iter = m_ecmpRootExits.begin(); + auto iter = m_ecmpRootExits.begin(); while (i-- > 0) { iter++; @@ -376,7 +374,7 @@ SPFVertex::GetChild(uint32_t n) const NS_LOG_FUNCTION(this << n); uint32_t j = 0; - for (ListOfSPFVertex_t::const_iterator i = m_children.begin(); i != m_children.end(); i++, j++) + for (auto i = m_children.begin(); i != m_children.end(); i++, j++) { if (j == n) { @@ -436,8 +434,7 @@ GlobalRouteManagerLSDB::GlobalRouteManagerLSDB() GlobalRouteManagerLSDB::~GlobalRouteManagerLSDB() { NS_LOG_FUNCTION(this); - LSDBMap_t::iterator i; - for (i = m_database.begin(); i != m_database.end(); i++) + for (auto i = m_database.begin(); i != m_database.end(); i++) { NS_LOG_LOGIC("free LSA"); GlobalRoutingLSA* temp = i->second; @@ -457,8 +454,7 @@ void GlobalRouteManagerLSDB::Initialize() { NS_LOG_FUNCTION(this); - LSDBMap_t::iterator i; - for (i = m_database.begin(); i != m_database.end(); i++) + for (auto i = m_database.begin(); i != m_database.end(); i++) { GlobalRoutingLSA* temp = i->second; temp->SetStatus(GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED); @@ -500,8 +496,7 @@ GlobalRouteManagerLSDB::GetLSA(Ipv4Address addr) const // // Look up an LSA by its address. // - LSDBMap_t::const_iterator i; - for (i = m_database.begin(); i != m_database.end(); i++) + for (auto i = m_database.begin(); i != m_database.end(); i++) { if (i->first == addr) { @@ -518,8 +513,7 @@ GlobalRouteManagerLSDB::GetLSAByLinkData(Ipv4Address addr) const // // Look up an LSA by its address. // - LSDBMap_t::const_iterator i; - for (i = m_database.begin(); i != m_database.end(); i++) + for (auto i = m_database.begin(); i != m_database.end(); i++) { GlobalRoutingLSA* temp = i->second; // Iterate among temp's Link Records @@ -573,8 +567,7 @@ void GlobalRouteManagerImpl::DeleteGlobalRoutes() { NS_LOG_FUNCTION(this); - NodeList::Iterator listEnd = NodeList::End(); - for (NodeList::Iterator i = NodeList::Begin(); i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; Ptr router = node->GetObject(); @@ -621,8 +614,7 @@ GlobalRouteManagerImpl::BuildGlobalRoutingDatabase() // Walk the list of nodes looking for the GlobalRouter Interface. Nodes with // global router interfaces are, not too surprisingly, our routers. // - NodeList::Iterator listEnd = NodeList::End(); - for (NodeList::Iterator i = NodeList::Begin(); i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; @@ -648,7 +640,7 @@ GlobalRouteManagerImpl::BuildGlobalRoutingDatabase() for (uint32_t j = 0; j < numLSAs; ++j) { - GlobalRoutingLSA* lsa = new GlobalRoutingLSA(); + auto lsa = new GlobalRoutingLSA(); // // This is the call to actually fetch a Link State Advertisement from the // router. @@ -704,8 +696,7 @@ GlobalRouteManagerImpl::InitializeRoutes() // Walk the list of nodes in the system. // NS_LOG_INFO("About to start SPF calculation"); - NodeList::Iterator listEnd = NodeList::End(); - for (NodeList::Iterator i = NodeList::Begin(); i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; // @@ -1563,9 +1554,7 @@ GlobalRouteManagerImpl::SPFAddASExternal(GlobalRoutingLSA* extlsa, SPFVertex* v) // ID corresponding to the root vertex. This is the one we're going to write // the routing information to. // - NodeList::Iterator i = NodeList::Begin(); - NodeList::Iterator listEnd = NodeList::End(); - for (; i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; // @@ -1729,9 +1718,7 @@ GlobalRouteManagerImpl::SPFIntraAddStub(GlobalRoutingLinkRecord* l, SPFVertex* v // ID corresponding to the root vertex. This is the one we're going to write // the routing information to. // - NodeList::Iterator i = NodeList::Begin(); - NodeList::Iterator listEnd = NodeList::End(); - for (; i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; // @@ -1851,9 +1838,7 @@ GlobalRouteManagerImpl::FindOutgoingInterfaceId(Ipv4Address a, Ipv4Mask amask) // the node at the root of the SPF tree. This is the node for which we are // building the routing table. // - NodeList::Iterator i = NodeList::Begin(); - NodeList::Iterator listEnd = NodeList::End(); - for (; i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; @@ -1940,9 +1925,7 @@ GlobalRouteManagerImpl::SPFIntraAddRouter(SPFVertex* v) // ID corresponding to the root vertex. This is the one we're going to write // the routing information to. // - NodeList::Iterator i = NodeList::Begin(); - NodeList::Iterator listEnd = NodeList::End(); - for (; i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; // @@ -2084,9 +2067,7 @@ GlobalRouteManagerImpl::SPFIntraAddTransit(SPFVertex* v) // ID corresponding to the root vertex. This is the one we're going to write // the routing information to. // - NodeList::Iterator i = NodeList::Begin(); - NodeList::Iterator listEnd = NodeList::End(); - for (; i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; // diff --git a/src/internet/model/global-router-interface.cc b/src/internet/model/global-router-interface.cc index 1836cd777..2e83ebe12 100644 --- a/src/internet/model/global-router-interface.cc +++ b/src/internet/model/global-router-interface.cc @@ -193,12 +193,10 @@ void GlobalRoutingLSA::CopyLinkRecords(const GlobalRoutingLSA& lsa) { NS_LOG_FUNCTION(this << &lsa); - for (ListOfLinkRecords_t::const_iterator i = lsa.m_linkRecords.begin(); - i != lsa.m_linkRecords.end(); - i++) + for (auto i = lsa.m_linkRecords.begin(); i != lsa.m_linkRecords.end(); i++) { GlobalRoutingLinkRecord* pSrc = *i; - GlobalRoutingLinkRecord* pDst = new GlobalRoutingLinkRecord; + auto pDst = new GlobalRoutingLinkRecord; pDst->SetLinkType(pSrc->GetLinkType()); pDst->SetLinkId(pSrc->GetLinkId()); @@ -222,7 +220,7 @@ void GlobalRoutingLSA::ClearLinkRecords() { NS_LOG_FUNCTION(this); - for (ListOfLinkRecords_t::iterator i = m_linkRecords.begin(); i != m_linkRecords.end(); i++) + for (auto i = m_linkRecords.begin(); i != m_linkRecords.end(); i++) { NS_LOG_LOGIC("Free link record"); @@ -256,8 +254,7 @@ GlobalRoutingLSA::GetLinkRecord(uint32_t n) const { NS_LOG_FUNCTION(this << n); uint32_t j = 0; - for (ListOfLinkRecords_t::const_iterator i = m_linkRecords.begin(); i != m_linkRecords.end(); - i++, j++) + for (auto i = m_linkRecords.begin(); i != m_linkRecords.end(); i++, j++) { if (j == n) { @@ -358,9 +355,7 @@ GlobalRoutingLSA::GetAttachedRouter(uint32_t n) const { NS_LOG_FUNCTION(this << n); uint32_t j = 0; - for (ListOfAttachedRouters_t::const_iterator i = m_attachedRouters.begin(); - i != m_attachedRouters.end(); - i++, j++) + for (auto i = m_attachedRouters.begin(); i != m_attachedRouters.end(); i++, j++) { if (j == n) { @@ -422,9 +417,7 @@ GlobalRoutingLSA::Print(std::ostream& os) const if (m_lsType == GlobalRoutingLSA::RouterLSA) { - for (ListOfLinkRecords_t::const_iterator i = m_linkRecords.begin(); - i != m_linkRecords.end(); - i++) + for (auto i = m_linkRecords.begin(); i != m_linkRecords.end(); i++) { GlobalRoutingLinkRecord* p = *i; @@ -469,9 +462,7 @@ GlobalRoutingLSA::Print(std::ostream& os) const { os << "---------- NetworkLSA Link Record ----------" << std::endl; os << "m_networkLSANetworkMask = " << m_networkLSANetworkMask << std::endl; - for (ListOfAttachedRouters_t::const_iterator i = m_attachedRouters.begin(); - i != m_attachedRouters.end(); - i++) + for (auto i = m_attachedRouters.begin(); i != m_attachedRouters.end(); i++) { Ipv4Address p = *i; os << "attachedRouter = " << p << std::endl; @@ -545,7 +536,7 @@ GlobalRouter::DoDispose() { NS_LOG_FUNCTION(this); m_routingProtocol = nullptr; - for (InjectedRoutesI k = m_injectedRoutes.begin(); k != m_injectedRoutes.end(); + for (auto k = m_injectedRoutes.begin(); k != m_injectedRoutes.end(); k = m_injectedRoutes.erase(k)) { delete (*k); @@ -557,7 +548,7 @@ void GlobalRouter::ClearLSAs() { NS_LOG_FUNCTION(this); - for (ListOfLSAs_t::iterator i = m_LSAs.begin(); i != m_LSAs.end(); i++) + for (auto i = m_LSAs.begin(); i != m_LSAs.end(); i++) { NS_LOG_LOGIC("Free LSA"); @@ -614,7 +605,7 @@ GlobalRouter::DiscoverLSAs() // // Every router node originates a Router-LSA // - GlobalRoutingLSA* pLSA = new GlobalRoutingLSA; + auto pLSA = new GlobalRoutingLSA; pLSA->SetLSType(GlobalRoutingLSA::RouterLSA); pLSA->SetLinkStateId(m_routerId); pLSA->SetAdvertisingRouter(m_routerId); @@ -717,9 +708,9 @@ GlobalRouter::DiscoverLSAs() // Build injected route LSAs as external routes // RFC 2328, section 12.4.4 // - for (InjectedRoutesCI i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) + for (auto i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) { - GlobalRoutingLSA* pLSA = new GlobalRoutingLSA; + auto pLSA = new GlobalRoutingLSA; pLSA->SetLSType(GlobalRoutingLSA::ASExternalLSAs); pLSA->SetLinkStateId((*i)->GetDestNetwork()); pLSA->SetAdvertisingRouter(m_routerId); @@ -752,7 +743,7 @@ GlobalRouter::ProcessSingleBroadcastLink(Ptr nd, { NS_LOG_FUNCTION(this << nd << pLSA << &c); - GlobalRoutingLinkRecord* plr = new GlobalRoutingLinkRecord; + auto plr = new GlobalRoutingLinkRecord; NS_ABORT_MSG_IF(plr == nullptr, "GlobalRouter::ProcessSingleBroadcastLink(): Can't alloc link record"); @@ -1193,7 +1184,7 @@ GlobalRouter::BuildNetworkLSAs(NetDeviceContainer c) Ipv4Address addrLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetLocal(); Ipv4Mask maskLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetMask(); - GlobalRoutingLSA* pLSA = new GlobalRoutingLSA; + auto pLSA = new GlobalRoutingLSA; NS_ABORT_MSG_IF(pLSA == nullptr, "GlobalRouter::BuildNetworkLSAs(): Can't alloc link record"); @@ -1604,7 +1595,7 @@ GlobalRouter::GetLSA(uint32_t n, GlobalRoutingLSA& lsa) const // walk the list of link state advertisements created there and return the // one the client is interested in. // - ListOfLSAs_t::const_iterator i = m_LSAs.begin(); + auto i = m_LSAs.begin(); uint32_t j = 0; for (; i != m_LSAs.end(); i++, j++) @@ -1624,7 +1615,7 @@ void GlobalRouter::InjectRoute(Ipv4Address network, Ipv4Mask networkMask) { NS_LOG_FUNCTION(this << network << networkMask); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); + auto route = new Ipv4RoutingTableEntry(); // // Interface number does not matter here, using 1. // @@ -1639,7 +1630,7 @@ GlobalRouter::GetInjectedRoute(uint32_t index) if (index < m_injectedRoutes.size()) { uint32_t tmp = 0; - for (InjectedRoutesCI i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) + for (auto i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) { if (tmp == index) { @@ -1666,7 +1657,7 @@ GlobalRouter::RemoveInjectedRoute(uint32_t index) NS_LOG_FUNCTION(this << index); NS_ASSERT(index < m_injectedRoutes.size()); uint32_t tmp = 0; - for (InjectedRoutesI i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) + for (auto i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) { if (tmp == index) { @@ -1683,7 +1674,7 @@ bool GlobalRouter::WithdrawRoute(Ipv4Address network, Ipv4Mask networkMask) { NS_LOG_FUNCTION(this << network << networkMask); - for (InjectedRoutesI i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) + for (auto i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) { if ((*i)->GetDestNetwork() == network && (*i)->GetDestNetworkMask() == networkMask) { @@ -1791,8 +1782,7 @@ GlobalRouter::ClearBridgesVisited() const bool GlobalRouter::BridgeHasAlreadyBeenVisited(Ptr bridgeNetDevice) const { - std::vector>::iterator iter; - for (iter = m_bridgesVisited.begin(); iter != m_bridgesVisited.end(); ++iter) + for (auto iter = m_bridgesVisited.begin(); iter != m_bridgesVisited.end(); ++iter) { if (bridgeNetDevice == *iter) { diff --git a/src/internet/model/global-router-interface.h b/src/internet/model/global-router-interface.h index c412c9e32..5b0af67a9 100644 --- a/src/internet/model/global-router-interface.h +++ b/src/internet/model/global-router-interface.h @@ -21,11 +21,12 @@ #ifndef GLOBAL_ROUTER_INTERFACE_H #define GLOBAL_ROUTER_INTERFACE_H +#include "global-route-manager.h" +#include "ipv4-routing-table-entry.h" + #include "ns3/bridge-net-device.h" #include "ns3/channel.h" -#include "ns3/global-route-manager.h" #include "ns3/ipv4-address.h" -#include "ns3/ipv4-routing-table-entry.h" #include "ns3/net-device-container.h" #include "ns3/node.h" #include "ns3/object.h" diff --git a/src/internet/model/icmpv4.h b/src/internet/model/icmpv4.h index 39292d4b5..b3c110aed 100644 --- a/src/internet/model/icmpv4.h +++ b/src/internet/model/icmpv4.h @@ -20,8 +20,9 @@ #ifndef ICMPV4_H #define ICMPV4_H +#include "ipv4-header.h" + #include "ns3/header.h" -#include "ns3/ipv4-header.h" #include "ns3/ptr.h" #include diff --git a/src/internet/model/icmpv6-header.cc b/src/internet/model/icmpv6-header.cc index e119d8eb9..3f12240fd 100644 --- a/src/internet/model/icmpv6-header.cc +++ b/src/internet/model/icmpv6-header.cc @@ -346,9 +346,9 @@ Icmpv6NA::Icmpv6NA() SetType(ICMPV6_ND_NEIGHBOR_ADVERTISEMENT); SetCode(0); SetReserved(0); - SetFlagR(0); - SetFlagS(0); - SetFlagO(0); + SetFlagR(false); + SetFlagS(false); + SetFlagO(false); m_checksum = 0; } @@ -545,9 +545,9 @@ Icmpv6RA::Icmpv6RA() NS_LOG_FUNCTION(this); SetType(ICMPV6_ND_ROUTER_ADVERTISEMENT); SetCode(0); - SetFlagM(0); - SetFlagO(0); - SetFlagH(0); + SetFlagM(false); + SetFlagO(false); + SetFlagH(false); SetCurHopLimit(0); SetLifeTime(0); SetRetransmissionTime(0); @@ -1192,7 +1192,7 @@ Icmpv6DestinationUnreachable::Serialize(Buffer::Iterator start) const iter.WriteU32(0); uint32_t size = m_packet->GetSize(); - uint8_t* buf = new uint8_t[size]; + auto buf = new uint8_t[size]; m_packet->CopyData(buf, size); iter.Write(buf, size); delete[] buf; @@ -1308,7 +1308,7 @@ Icmpv6TooBig::Serialize(Buffer::Iterator start) const iter.WriteHtonU32(GetMtu()); uint32_t size = m_packet->GetSize(); - uint8_t* buf = new uint8_t[size]; + auto buf = new uint8_t[size]; m_packet->CopyData(buf, size); iter.Write(buf, size); delete[] buf; @@ -1410,7 +1410,7 @@ Icmpv6TimeExceeded::Serialize(Buffer::Iterator start) const iter.WriteU32(0); uint32_t size = m_packet->GetSize(); - uint8_t* buf = new uint8_t[size]; + auto buf = new uint8_t[size]; m_packet->CopyData(buf, size); iter.Write(buf, size); delete[] buf; @@ -1527,7 +1527,7 @@ Icmpv6ParameterError::Serialize(Buffer::Iterator start) const iter.WriteHtonU32(GetPtr()); uint32_t size = m_packet->GetSize(); - uint8_t* buf = new uint8_t[size]; + auto buf = new uint8_t[size]; m_packet->CopyData(buf, size); iter.Write(buf, size); delete[] buf; @@ -2128,7 +2128,7 @@ Icmpv6OptionRedirected::Serialize(Buffer::Iterator start) const i.WriteU32(0); uint32_t size = m_packet->GetSize(); - uint8_t* buf = new uint8_t[size]; + auto buf = new uint8_t[size]; m_packet->CopyData(buf, size); i.Write(buf, size); delete[] buf; @@ -2147,7 +2147,7 @@ Icmpv6OptionRedirected::Deserialize(Buffer::Iterator start) i.ReadU32(); uint32_t len2 = (GetLength() - 1) * 8; - uint8_t* buff = new uint8_t[len2]; + auto buff = new uint8_t[len2]; i.Read(buff, len2); m_packet = Create(buff, len2); delete[] buff; diff --git a/src/internet/model/icmpv6-l4-protocol.cc b/src/internet/model/icmpv6-l4-protocol.cc index 69277526b..878da2695 100644 --- a/src/internet/model/icmpv6-l4-protocol.cc +++ b/src/internet/model/icmpv6-l4-protocol.cc @@ -168,7 +168,7 @@ void Icmpv6L4Protocol::DoDispose() { NS_LOG_FUNCTION(this); - for (CacheList::const_iterator it = m_cacheList.begin(); it != m_cacheList.end(); it++) + for (auto it = m_cacheList.begin(); it != m_cacheList.end(); it++) { Ptr cache = *it; cache->Dispose(); @@ -397,7 +397,7 @@ Icmpv6L4Protocol::HandleEchoRequest(Ptr packet, { NS_LOG_FUNCTION(this << packet << src << dst << interface); Icmpv6Echo request; - uint8_t* buf = new uint8_t[packet->GetSize()]; + auto buf = new uint8_t[packet->GetSize()]; packet->RemoveHeader(request); /* XXX IPv6 extension: obtain a fresh copy of data otherwise it crash... */ @@ -522,9 +522,7 @@ Icmpv6L4Protocol::ReceiveLLA(Icmpv6OptionLinkLayerAddress lla, waiting = entry->MarkReachable(lla.GetAddress()); entry->StartReachableTimer(); // send out waiting packet - for (std::list::const_iterator it = waiting.begin(); - it != waiting.end(); - it++) + for (auto it = waiting.begin(); it != waiting.end(); it++) { cache->GetInterface()->Send(it->first, it->second, src); } @@ -558,10 +556,7 @@ Icmpv6L4Protocol::ReceiveLLA(Icmpv6OptionLinkLayerAddress lla, { entry->StopNudTimer(); waiting = entry->MarkReachable(lla.GetAddress()); - for (std::list::const_iterator it = - waiting.begin(); - it != waiting.end(); - it++) + for (auto it = waiting.begin(); it != waiting.end(); it++) { cache->GetInterface()->Send(it->first, it->second, src); } @@ -605,7 +600,7 @@ Icmpv6L4Protocol::HandleRS(Ptr packet, Icmpv6RS rsHeader; packet->RemoveHeader(rsHeader); Address hardwareAddress; - Icmpv6OptionLinkLayerAddress lla(1); + Icmpv6OptionLinkLayerAddress lla(true); NdiscCache::Entry* entry = nullptr; Ptr cache = FindCache(interface->GetDevice()); @@ -786,7 +781,7 @@ Icmpv6L4Protocol::ForgeRS(Ipv6Address src, Ipv6Address dst, Address hardwareAddr if (!src.IsAny()) { Icmpv6OptionLinkLayerAddress llOption( - 1, + true, hardwareAddress); /* we give our mac address in response */ p->AddHeader(llOption); } @@ -813,7 +808,7 @@ Icmpv6L4Protocol::ForgeEchoRequest(Ipv6Address src, NS_LOG_FUNCTION(this << src << dst << id << seq << data); Ptr p = data->Copy(); Ipv6Header ipHeader; - Icmpv6Echo req(1); + Icmpv6Echo req(true); req.SetId(id); req.SetSeq(seq); @@ -841,7 +836,7 @@ Icmpv6L4Protocol::HandleNA(Ptr packet, { NS_LOG_FUNCTION(this << packet << src << dst << interface); Icmpv6NA naHeader; - Icmpv6OptionLinkLayerAddress lla(1); + Icmpv6OptionLinkLayerAddress lla(true); packet->RemoveHeader(naHeader); Ipv6Address target = naHeader.GetIpv6Target(); @@ -911,9 +906,7 @@ Icmpv6L4Protocol::HandleNA(Ptr packet, waiting = entry->MarkReachable(lla.GetAddress()); entry->StartReachableTimer(); /* send out waiting packet */ - for (std::list::const_iterator it = waiting.begin(); - it != waiting.end(); - it++) + for (auto it = waiting.begin(); it != waiting.end(); it++) { cache->GetInterface()->Send(it->first, it->second, src); } @@ -978,10 +971,7 @@ Icmpv6L4Protocol::HandleNA(Ptr packet, if (naHeader.GetFlagS()) { waiting = entry->MarkReachable(lla.GetAddress()); - for (std::list::const_iterator it = - waiting.begin(); - it != waiting.end(); - it++) + for (auto it = waiting.begin(); it != waiting.end(); it++) { cache->GetInterface()->Send(it->first, it->second, src); } @@ -1022,7 +1012,7 @@ Icmpv6L4Protocol::HandleRedirection(Ptr packet, NS_LOG_FUNCTION(this << packet << src << dst << interface); bool hasLla = false; Ptr p = packet->Copy(); - Icmpv6OptionLinkLayerAddress llOptionHeader(0); + Icmpv6OptionLinkLayerAddress llOptionHeader(false); Icmpv6Redirection redirectionHeader; p->RemoveHeader(redirectionHeader); @@ -1255,7 +1245,7 @@ Icmpv6L4Protocol::SendNA(Ipv6Address src, Ipv6Address dst, Address* hardwareAddr NS_LOG_FUNCTION(this << src << dst << hardwareAddress << static_cast(flags)); Ptr p = Create(); Icmpv6NA na; - Icmpv6OptionLinkLayerAddress llOption(0, *hardwareAddress); /* not a source link layer */ + Icmpv6OptionLinkLayerAddress llOption(false, *hardwareAddress); /* not a source link layer */ NS_LOG_LOGIC("Send NA ( from " << src << " to " << dst << " target " << src << ")"); na.SetIpv6Target(src); @@ -1289,7 +1279,7 @@ Icmpv6L4Protocol::SendEchoReply(Ipv6Address src, { NS_LOG_FUNCTION(this << src << dst << id << seq << data); Ptr p = data->Copy(); - Icmpv6Echo reply(0); /* echo reply */ + Icmpv6Echo reply(false); /* echo reply */ reply.SetId(id); reply.SetSeq(seq); @@ -1313,7 +1303,7 @@ Icmpv6L4Protocol::SendNS(Ipv6Address src, /* Ipv6Header ipHeader; */ Icmpv6NS ns(target); Icmpv6OptionLinkLayerAddress llOption( - 1, + true, hardwareAddress); /* we give our mac address in response */ /* if the source is unspec, multicast the NA to all-nodes multicast */ @@ -1356,10 +1346,21 @@ Icmpv6L4Protocol::SendRS(Ipv6Address src, Ipv6Address dst, Address hardwareAddre // unspecified address. Otherwise, it SHOULD be included on link layers that have addresses. if (!src.IsAny()) { - Icmpv6OptionLinkLayerAddress llOption(1, hardwareAddress); + Icmpv6OptionLinkLayerAddress llOption(true, hardwareAddress); p->AddHeader(llOption); } + if (!src.IsAny()) + { + Ptr ipv6 = m_node->GetObject(); + if (ipv6->GetInterfaceForAddress(src) == -1) + { + NS_LOG_INFO("Preventing RS from being sent or rescheduled because the source address " + << src << " has been removed"); + return; + } + } + NS_LOG_LOGIC("Send RS (from " << src << " to " << dst << ")"); rs.CalculatePseudoHeaderChecksum(src, dst, p->GetSize() + rs.GetSerializedSize(), PROT_NUMBER); @@ -1548,7 +1549,7 @@ Icmpv6L4Protocol::SendRedirection(Ptr redirectedPacket, uint32_t llaSize = 0; Ptr p = Create(); uint32_t redirectedPacketSize = redirectedPacket->GetSize(); - Icmpv6OptionLinkLayerAddress llOption(0); + Icmpv6OptionLinkLayerAddress llOption(false); NS_LOG_LOGIC("Send Redirection ( to " << dst << " target " << redirTarget << " destination " << redirDestination << " )"); @@ -1606,7 +1607,7 @@ Icmpv6L4Protocol::ForgeNA(Ipv6Address src, Ipv6Address dst, Address* hardwareAdd Ipv6Header ipHeader; Icmpv6NA na; Icmpv6OptionLinkLayerAddress llOption( - 0, + false, *hardwareAddress); /* we give our mac address in response */ NS_LOG_LOGIC("Send NA ( from " << src << " to " << dst << ")"); @@ -1653,7 +1654,7 @@ Icmpv6L4Protocol::ForgeNS(Ipv6Address src, Ipv6Header ipHeader; Icmpv6NS ns(target); Icmpv6OptionLinkLayerAddress llOption( - 1, + true, hardwareAddress); /* we give our mac address in response */ NS_LOG_LOGIC("Send NS ( from " << src << " to " << dst << " target " << target << ")"); @@ -1676,7 +1677,7 @@ Icmpv6L4Protocol::FindCache(Ptr device) { NS_LOG_FUNCTION(this << device); - for (CacheList::const_iterator i = m_cacheList.begin(); i != m_cacheList.end(); i++) + for (auto i = m_cacheList.begin(); i != m_cacheList.end(); i++) { if ((*i)->GetDevice() == device) { diff --git a/src/internet/model/ipv4-address-generator.cc b/src/internet/model/ipv4-address-generator.cc index e6b6cf468..9181f8c02 100644 --- a/src/internet/model/ipv4-address-generator.cc +++ b/src/internet/model/ipv4-address-generator.cc @@ -342,8 +342,8 @@ Ipv4AddressGeneratorImpl::NextAddress(const Ipv4Mask mask) NS_ABORT_MSG_UNLESS(m_netTable[index].addr <= m_netTable[index].addrMax, "Ipv4AddressGeneratorImpl::NextAddress(): Address overflow"); - Ipv4Address addr = Ipv4Address((m_netTable[index].network << m_netTable[index].shift) | - m_netTable[index].addr); + Ipv4Address addr((m_netTable[index].network << m_netTable[index].shift) | + m_netTable[index].addr); ++m_netTable[index].addr; // @@ -404,7 +404,7 @@ Ipv4AddressGeneratorImpl::AddAllocated(const Ipv4Address address) // if (addr == (*i).addrHigh + 1) { - std::list::iterator j = i; + auto j = i; ++j; if (j != m_entries.end()) @@ -459,9 +459,7 @@ Ipv4AddressGeneratorImpl::IsAddressAllocated(const Ipv4Address address) addr, "Ipv4AddressGeneratorImpl::IsAddressAllocated(): Don't check for the broadcast address..."); - std::list::iterator i; - - for (i = m_entries.begin(); i != m_entries.end(); ++i) + for (auto i = m_entries.begin(); i != m_entries.end(); ++i) { NS_LOG_LOGIC("examine entry: " << Ipv4Address((*i).addrLow) << " to " << Ipv4Address((*i).addrHigh)); @@ -469,10 +467,10 @@ Ipv4AddressGeneratorImpl::IsAddressAllocated(const Ipv4Address address) { NS_LOG_LOGIC("Ipv4AddressGeneratorImpl::IsAddressAllocated(): Address Collision: " << Ipv4Address(addr)); - return false; + return true; } } - return true; + return false; } bool @@ -485,14 +483,12 @@ Ipv4AddressGeneratorImpl::IsNetworkAllocated(const Ipv4Address address, const Ip "Ipv4AddressGeneratorImpl::IsNetworkAllocated(): network address and mask don't match " << address << " " << mask); - std::list::iterator i; - - for (i = m_entries.begin(); i != m_entries.end(); ++i) + for (auto i = m_entries.begin(); i != m_entries.end(); ++i) { NS_LOG_LOGIC("examine entry: " << Ipv4Address((*i).addrLow) << " to " << Ipv4Address((*i).addrHigh)); - Ipv4Address low = Ipv4Address((*i).addrLow); - Ipv4Address high = Ipv4Address((*i).addrHigh); + Ipv4Address low((*i).addrLow); + Ipv4Address high((*i).addrHigh); if (address == low.CombineMask(mask) || address == high.CombineMask(mask)) { diff --git a/src/internet/model/ipv4-end-point-demux.cc b/src/internet/model/ipv4-end-point-demux.cc index 058e1569b..c23018a07 100644 --- a/src/internet/model/ipv4-end-point-demux.cc +++ b/src/internet/model/ipv4-end-point-demux.cc @@ -40,7 +40,7 @@ Ipv4EndPointDemux::Ipv4EndPointDemux() Ipv4EndPointDemux::~Ipv4EndPointDemux() { NS_LOG_FUNCTION(this); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { Ipv4EndPoint* endPoint = *i; delete endPoint; @@ -52,7 +52,7 @@ bool Ipv4EndPointDemux::LookupPortLocal(uint16_t port) { NS_LOG_FUNCTION(this << port); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() == port) { @@ -66,7 +66,7 @@ bool Ipv4EndPointDemux::LookupLocal(Ptr boundNetDevice, Ipv4Address addr, uint16_t port) { NS_LOG_FUNCTION(this << addr << port); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() == port && (*i)->GetLocalAddress() == addr && (*i)->GetBoundNetDevice() == boundNetDevice) @@ -87,7 +87,7 @@ Ipv4EndPointDemux::Allocate() NS_LOG_WARN("Ephemeral port allocation failed."); return nullptr; } - Ipv4EndPoint* endPoint = new Ipv4EndPoint(Ipv4Address::GetAny(), port); + auto endPoint = new Ipv4EndPoint(Ipv4Address::GetAny(), port); m_endPoints.push_back(endPoint); NS_LOG_DEBUG("Now have >>" << m_endPoints.size() << "<< endpoints."); return endPoint; @@ -103,7 +103,7 @@ Ipv4EndPointDemux::Allocate(Ipv4Address address) NS_LOG_WARN("Ephemeral port allocation failed."); return nullptr; } - Ipv4EndPoint* endPoint = new Ipv4EndPoint(address, port); + auto endPoint = new Ipv4EndPoint(address, port); m_endPoints.push_back(endPoint); NS_LOG_DEBUG("Now have >>" << m_endPoints.size() << "<< endpoints."); return endPoint; @@ -126,7 +126,7 @@ Ipv4EndPointDemux::Allocate(Ptr boundNetDevice, Ipv4Address address, NS_LOG_WARN("Duplicated endpoint."); return nullptr; } - Ipv4EndPoint* endPoint = new Ipv4EndPoint(address, port); + auto endPoint = new Ipv4EndPoint(address, port); m_endPoints.push_back(endPoint); NS_LOG_DEBUG("Now have >>" << m_endPoints.size() << "<< endpoints."); return endPoint; @@ -140,7 +140,7 @@ Ipv4EndPointDemux::Allocate(Ptr boundNetDevice, uint16_t peerPort) { NS_LOG_FUNCTION(this << localAddress << localPort << peerAddress << peerPort << boundNetDevice); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() == localPort && (*i)->GetLocalAddress() == localAddress && (*i)->GetPeerPort() == peerPort && (*i)->GetPeerAddress() == peerAddress && @@ -150,7 +150,7 @@ Ipv4EndPointDemux::Allocate(Ptr boundNetDevice, return nullptr; } } - Ipv4EndPoint* endPoint = new Ipv4EndPoint(localAddress, localPort); + auto endPoint = new Ipv4EndPoint(localAddress, localPort); endPoint->SetPeer(peerAddress, peerPort); m_endPoints.push_back(endPoint); @@ -163,7 +163,7 @@ void Ipv4EndPointDemux::DeAllocate(Ipv4EndPoint* endPoint) { NS_LOG_FUNCTION(this << endPoint); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if (*i == endPoint) { @@ -183,7 +183,7 @@ Ipv4EndPointDemux::GetAllEndPoints() NS_LOG_FUNCTION(this); EndPoints ret; - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { Ipv4EndPoint* endP = *i; ret.push_back(endP); @@ -211,7 +211,7 @@ Ipv4EndPointDemux::Lookup(Ipv4Address daddr, EndPoints retval4; // Exact match on all 4 NS_LOG_DEBUG("Looking up endpoint for destination address " << daddr << ":" << dport); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { Ipv4EndPoint* endP = *i; @@ -376,7 +376,7 @@ Ipv4EndPointDemux::SimpleLookup(Ipv4Address daddr, // function. uint32_t genericity = 3; Ipv4EndPoint* generic = nullptr; - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() != dport) { diff --git a/src/internet/model/ipv4-end-point.h b/src/internet/model/ipv4-end-point.h index ef87228cf..ba96bbfb2 100644 --- a/src/internet/model/ipv4-end-point.h +++ b/src/internet/model/ipv4-end-point.h @@ -20,10 +20,11 @@ #ifndef IPV4_END_POINT_H #define IPV4_END_POINT_H +#include "ipv4-header.h" +#include "ipv4-interface.h" + #include "ns3/callback.h" #include "ns3/ipv4-address.h" -#include "ns3/ipv4-header.h" -#include "ns3/ipv4-interface.h" #include "ns3/net-device.h" #include diff --git a/src/internet/model/ipv4-global-routing.cc b/src/internet/model/ipv4-global-routing.cc index ae018d6cb..bf8f5deb1 100644 --- a/src/internet/model/ipv4-global-routing.cc +++ b/src/internet/model/ipv4-global-routing.cc @@ -87,7 +87,7 @@ void Ipv4GlobalRouting::AddHostRouteTo(Ipv4Address dest, Ipv4Address nextHop, uint32_t interface) { NS_LOG_FUNCTION(this << dest << nextHop << interface); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); + auto route = new Ipv4RoutingTableEntry(); *route = Ipv4RoutingTableEntry::CreateHostRouteTo(dest, nextHop, interface); m_hostRoutes.push_back(route); } @@ -96,7 +96,7 @@ void Ipv4GlobalRouting::AddHostRouteTo(Ipv4Address dest, uint32_t interface) { NS_LOG_FUNCTION(this << dest << interface); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); + auto route = new Ipv4RoutingTableEntry(); *route = Ipv4RoutingTableEntry::CreateHostRouteTo(dest, interface); m_hostRoutes.push_back(route); } @@ -108,7 +108,7 @@ Ipv4GlobalRouting::AddNetworkRouteTo(Ipv4Address network, uint32_t interface) { NS_LOG_FUNCTION(this << network << networkMask << nextHop << interface); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); + auto route = new Ipv4RoutingTableEntry(); *route = Ipv4RoutingTableEntry::CreateNetworkRouteTo(network, networkMask, nextHop, interface); m_networkRoutes.push_back(route); } @@ -117,7 +117,7 @@ void Ipv4GlobalRouting::AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, uint32_t interface) { NS_LOG_FUNCTION(this << network << networkMask << interface); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); + auto route = new Ipv4RoutingTableEntry(); *route = Ipv4RoutingTableEntry::CreateNetworkRouteTo(network, networkMask, interface); m_networkRoutes.push_back(route); } @@ -129,7 +129,7 @@ Ipv4GlobalRouting::AddASExternalRouteTo(Ipv4Address network, uint32_t interface) { NS_LOG_FUNCTION(this << network << networkMask << nextHop << interface); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); + auto route = new Ipv4RoutingTableEntry(); *route = Ipv4RoutingTableEntry::CreateNetworkRouteTo(network, networkMask, nextHop, interface); m_ASexternalRoutes.push_back(route); } @@ -145,7 +145,7 @@ Ipv4GlobalRouting::LookupGlobal(Ipv4Address dest, uint32_t flowHash, PtrGetDestNetworkMask(); Ipv4Address entry = (*j)->GetDestNetwork(); @@ -186,7 +186,7 @@ Ipv4GlobalRouting::LookupGlobal(Ipv4Address dest, uint32_t flowHash, PtrGetDestNetworkMask(); Ipv4Address entry = (*k)->GetDestNetwork(); @@ -259,7 +259,7 @@ Ipv4GlobalRouting::GetRoute(uint32_t index) const if (index < m_hostRoutes.size()) { uint32_t tmp = 0; - for (HostRoutesCI i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i++) + for (auto i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i++) { if (tmp == index) { @@ -272,7 +272,7 @@ Ipv4GlobalRouting::GetRoute(uint32_t index) const uint32_t tmp = 0; if (index < m_networkRoutes.size()) { - for (NetworkRoutesCI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { if (tmp == index) { @@ -283,7 +283,7 @@ Ipv4GlobalRouting::GetRoute(uint32_t index) const } index -= m_networkRoutes.size(); tmp = 0; - for (ASExternalRoutesCI k = m_ASexternalRoutes.begin(); k != m_ASexternalRoutes.end(); k++) + for (auto k = m_ASexternalRoutes.begin(); k != m_ASexternalRoutes.end(); k++) { if (tmp == index) { @@ -303,7 +303,7 @@ Ipv4GlobalRouting::RemoveRoute(uint32_t index) if (index < m_hostRoutes.size()) { uint32_t tmp = 0; - for (HostRoutesI i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i++) + for (auto i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i++) { if (tmp == index) { @@ -319,7 +319,7 @@ Ipv4GlobalRouting::RemoveRoute(uint32_t index) } index -= m_hostRoutes.size(); uint32_t tmp = 0; - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { if (tmp == index) { @@ -334,7 +334,7 @@ Ipv4GlobalRouting::RemoveRoute(uint32_t index) } index -= m_networkRoutes.size(); tmp = 0; - for (ASExternalRoutesI k = m_ASexternalRoutes.begin(); k != m_ASexternalRoutes.end(); k++) + for (auto k = m_ASexternalRoutes.begin(); k != m_ASexternalRoutes.end(); k++) { if (tmp == index) { @@ -362,16 +362,15 @@ void Ipv4GlobalRouting::DoDispose() { NS_LOG_FUNCTION(this); - for (HostRoutesI i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i = m_hostRoutes.erase(i)) + for (auto i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i = m_hostRoutes.erase(i)) { delete (*i); } - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); - j = m_networkRoutes.erase(j)) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j = m_networkRoutes.erase(j)) { delete (*j); } - for (ASExternalRoutesI l = m_ASexternalRoutes.begin(); l != m_ASexternalRoutes.end(); + for (auto l = m_ASexternalRoutes.begin(); l != m_ASexternalRoutes.end(); l = m_ASexternalRoutes.erase(l)) { delete (*l); diff --git a/src/internet/model/ipv4-global-routing.h b/src/internet/model/ipv4-global-routing.h index 4f0039497..bb7d59250 100644 --- a/src/internet/model/ipv4-global-routing.h +++ b/src/internet/model/ipv4-global-routing.h @@ -19,10 +19,11 @@ #ifndef IPV4_GLOBAL_ROUTING_H #define IPV4_GLOBAL_ROUTING_H +#include "ipv4-header.h" +#include "ipv4-routing-protocol.h" +#include "ipv4.h" + #include "ns3/ipv4-address.h" -#include "ns3/ipv4-header.h" -#include "ns3/ipv4-routing-protocol.h" -#include "ns3/ipv4.h" #include "ns3/ptr.h" #include "ns3/random-variable-stream.h" diff --git a/src/internet/model/ipv4-interface.cc b/src/internet/model/ipv4-interface.cc index 8790e1409..9848e1fee 100644 --- a/src/internet/model/ipv4-interface.cc +++ b/src/internet/model/ipv4-interface.cc @@ -232,7 +232,7 @@ Ipv4Interface::Send(Ptr p, const Ipv4Header& hdr, Ipv4Address dest) NS_ASSERT(m_tc); // is this packet aimed at a local interface ? - for (Ipv4InterfaceAddressListCI i = m_ifaddrs.begin(); i != m_ifaddrs.end(); ++i) + for (auto i = m_ifaddrs.begin(); i != m_ifaddrs.end(); ++i) { if (dest == (*i).GetLocal()) { @@ -271,7 +271,7 @@ Ipv4Interface::Send(Ptr p, const Ipv4Header& hdr, Ipv4Address dest) } else { - for (Ipv4InterfaceAddressListCI i = m_ifaddrs.begin(); i != m_ifaddrs.end(); ++i) + for (auto i = m_ifaddrs.begin(); i != m_ifaddrs.end(); ++i) { if (dest.IsSubnetDirectedBroadcast((*i).GetMask())) { @@ -335,7 +335,7 @@ Ipv4Interface::GetAddress(uint32_t index) const if (index < m_ifaddrs.size()) { uint32_t tmp = 0; - for (Ipv4InterfaceAddressListCI i = m_ifaddrs.begin(); i != m_ifaddrs.end(); i++) + for (auto i = m_ifaddrs.begin(); i != m_ifaddrs.end(); i++) { if (tmp == index) { @@ -360,7 +360,7 @@ Ipv4Interface::RemoveAddress(uint32_t index) { NS_FATAL_ERROR("Bug in Ipv4Interface::RemoveAddress"); } - Ipv4InterfaceAddressListI i = m_ifaddrs.begin(); + auto i = m_ifaddrs.begin(); uint32_t tmp = 0; while (i != m_ifaddrs.end()) { @@ -393,7 +393,7 @@ Ipv4Interface::RemoveAddress(Ipv4Address address) return Ipv4InterfaceAddress(); } - for (Ipv4InterfaceAddressListI it = m_ifaddrs.begin(); it != m_ifaddrs.end(); it++) + for (auto it = m_ifaddrs.begin(); it != m_ifaddrs.end(); it++) { if ((*it).GetLocal() == address) { diff --git a/src/internet/model/ipv4-l3-protocol.cc b/src/internet/model/ipv4-l3-protocol.cc index 489eb94bd..9903c7784 100644 --- a/src/internet/model/ipv4-l3-protocol.cc +++ b/src/internet/model/ipv4-l3-protocol.cc @@ -176,7 +176,7 @@ Ipv4L3Protocol::Remove(Ptr protocol) NS_LOG_FUNCTION(this << protocol); L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), -1); - L4List_t::iterator iter = m_protocols.find(key); + auto iter = m_protocols.find(key); if (iter == m_protocols.end()) { NS_LOG_WARN("Trying to remove an non-existent default protocol " @@ -194,7 +194,7 @@ Ipv4L3Protocol::Remove(Ptr protocol, uint32_t interfaceIndex) NS_LOG_FUNCTION(this << protocol << interfaceIndex); L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), interfaceIndex); - L4List_t::iterator iter = m_protocols.find(key); + auto iter = m_protocols.find(key); if (iter == m_protocols.end()) { NS_LOG_WARN("Trying to remove an non-existent protocol " @@ -220,21 +220,19 @@ Ipv4L3Protocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) const { NS_LOG_FUNCTION(this << protocolNumber << interfaceIndex); - L4ListKey_t key; - L4List_t::const_iterator i; if (interfaceIndex >= 0) { // try the interface-specific protocol. - key = std::make_pair(protocolNumber, interfaceIndex); - i = m_protocols.find(key); + auto key = std::make_pair(protocolNumber, interfaceIndex); + auto i = m_protocols.find(key); if (i != m_protocols.end()) { return i->second; } } // try the generic protocol. - key = std::make_pair(protocolNumber, -1); - i = m_protocols.find(key); + auto key = std::make_pair(protocolNumber, -1); + auto i = m_protocols.find(key); if (i != m_protocols.end()) { return i->second; @@ -266,7 +264,7 @@ void Ipv4L3Protocol::DeleteRawSocket(Ptr socket) { NS_LOG_FUNCTION(this << socket); - for (SocketList::iterator i = m_sockets.begin(); i != m_sockets.end(); ++i) + for (auto i = m_sockets.begin(); i != m_sockets.end(); ++i) { if ((*i) == socket) { @@ -316,13 +314,13 @@ void Ipv4L3Protocol::DoDispose() { NS_LOG_FUNCTION(this); - for (L4List_t::iterator i = m_protocols.begin(); i != m_protocols.end(); ++i) + for (auto i = m_protocols.begin(); i != m_protocols.end(); ++i) { i->second = nullptr; } m_protocols.clear(); - for (Ipv4InterfaceList::iterator i = m_interfaces.begin(); i != m_interfaces.end(); ++i) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); ++i) { *i = nullptr; } @@ -333,7 +331,7 @@ Ipv4L3Protocol::DoDispose() m_node = nullptr; m_routingProtocol = nullptr; - for (MapFragments_t::iterator it = m_fragments.begin(); it != m_fragments.end(); it++) + for (auto it = m_fragments.begin(); it != m_fragments.end(); it++) { it->second = nullptr; } @@ -464,8 +462,7 @@ Ipv4L3Protocol::GetInterfaceForAddress(Ipv4Address address) const { NS_LOG_FUNCTION(this << address); int32_t interface = 0; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); - i++, interface++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++, interface++) { for (uint32_t j = 0; j < (*i)->GetNAddresses(); j++) { @@ -484,8 +481,7 @@ Ipv4L3Protocol::GetInterfaceForPrefix(Ipv4Address address, Ipv4Mask mask) const { NS_LOG_FUNCTION(this << address << mask); int32_t interface = 0; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); - i++, interface++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++, interface++) { for (uint32_t j = 0; j < (*i)->GetNAddresses(); j++) { @@ -504,7 +500,7 @@ Ipv4L3Protocol::GetInterfaceForDevice(Ptr device) const { NS_LOG_FUNCTION(this << device); - Ipv4InterfaceReverseContainer::const_iterator iter = m_reverseInterfacesContainer.find(device); + auto iter = m_reverseInterfacesContainer.find(device); if (iter != m_reverseInterfacesContainer.end()) { return (*iter).second; @@ -650,8 +646,7 @@ Ipv4L3Protocol::Receive(Ptr device, // addresses. In doubt, update all of them. Note: it's a confirmed behavior for Linux // routers. std::list entryList = arpCache->LookupInverse(from); - std::list::iterator iter; - for (iter = entryList.begin(); iter != entryList.end(); iter++) + for (auto iter = entryList.begin(); iter != entryList.end(); iter++) { if ((*iter)->IsAlive()) { @@ -661,7 +656,7 @@ Ipv4L3Protocol::Receive(Ptr device, } } - for (SocketList::iterator i = m_sockets.begin(); i != m_sockets.end(); ++i) + for (auto i = m_sockets.begin(); i != m_sockets.end(); ++i) { NS_LOG_LOGIC("Forwarding to raw socket"); Ptr socket = *i; @@ -834,8 +829,7 @@ Ipv4L3Protocol::Send(Ptr packet, { NS_LOG_LOGIC("Ipv4L3Protocol::Send case 2: limited broadcast - no route"); uint32_t ifaceIndex = 0; - for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin(); - ifaceIter != m_interfaces.end(); + for (auto ifaceIter = m_interfaces.begin(); ifaceIter != m_interfaces.end(); ifaceIter++, ifaceIndex++) { Ptr outInterface = *ifaceIter; @@ -866,9 +860,7 @@ Ipv4L3Protocol::Send(Ptr packet, } // 3) check: packet is destined to a subnet-directed broadcast address - for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin(); - ifaceIter != m_interfaces.end(); - ifaceIter++) + for (auto ifaceIter = m_interfaces.begin(); ifaceIter != m_interfaces.end(); ifaceIter++) { Ptr outInterface = *ifaceIter; uint32_t ifaceIndex = GetInterfaceForDevice(outInterface->GetDevice()); @@ -1019,9 +1011,7 @@ Ipv4L3Protocol::SendRealOut(Ptr route, Ptr packet, const Ipv4 { std::list listFragments; DoFragmentation(packet, ipHeader, outInterface->GetDevice()->GetMtu(), listFragments); - for (std::list::iterator it = listFragments.begin(); - it != listFragments.end(); - it++) + for (auto it = listFragments.begin(); it != listFragments.end(); it++) { NS_LOG_LOGIC("Sending fragment " << *(it->first)); CallTxTrace(it->second, it->first, this, interface); @@ -1046,9 +1036,8 @@ Ipv4L3Protocol::IpMulticastForward(Ptr mrtentry, NS_LOG_LOGIC("Multicast forwarding logic for node: " << m_node->GetId()); std::map ttlMap = mrtentry->GetOutputTtlMap(); - std::map::iterator mapIter; - for (mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++) + for (auto mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++) { uint32_t interface = mapIter->first; // uint32_t outputTtl = mapIter->second; // Unused for now @@ -1435,7 +1424,7 @@ Ipv4L3Protocol::SetIpForward(bool forward) { NS_LOG_FUNCTION(this << forward); m_ipForward = forward; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { (*i)->SetForwarding(forward); } @@ -1577,13 +1566,13 @@ Ipv4L3Protocol::ProcessFragment(Ptr& packet, Ipv4Header& ipHeader, uint3 Ptr fragments; - MapFragments_t::iterator it = m_fragments.find(key); + auto it = m_fragments.find(key); if (it == m_fragments.end()) { fragments = Create(); m_fragments.insert(std::make_pair(key, fragments)); - FragmentsTimeoutsListI_t iter = SetTimeout(key, ipHeader, iif); + auto iter = SetTimeout(key, ipHeader, iif); fragments->SetTimeoutIter(iter); } else @@ -1609,7 +1598,7 @@ Ipv4L3Protocol::ProcessFragment(Ptr& packet, Ipv4Header& ipHeader, uint3 } Ipv4L3Protocol::Fragments::Fragments() - : m_moreFragment(0) + : m_moreFragment(false) { NS_LOG_FUNCTION(this); } @@ -1650,9 +1639,7 @@ Ipv4L3Protocol::Fragments::IsEntire() const { uint16_t lastEndOffset = 0; - for (std::list, uint16_t>>::const_iterator it = m_fragments.begin(); - it != m_fragments.end(); - it++) + for (auto it = m_fragments.begin(); it != m_fragments.end(); it++) { // overlapping fragments do exist NS_LOG_LOGIC("Checking overlaps " << lastEndOffset << " - " << it->second); @@ -1676,7 +1663,7 @@ Ipv4L3Protocol::Fragments::GetPacket() const { NS_LOG_FUNCTION(this); - std::list, uint16_t>>::const_iterator it = m_fragments.begin(); + auto it = m_fragments.begin(); Ptr p = it->first->Copy(); uint16_t lastEndOffset = p->GetSize(); @@ -1714,7 +1701,7 @@ Ipv4L3Protocol::Fragments::GetPartialPacket() const { NS_LOG_FUNCTION(this); - std::list, uint16_t>>::const_iterator it = m_fragments.begin(); + auto it = m_fragments.begin(); Ptr p = Create(); uint16_t lastEndOffset = 0; @@ -1761,7 +1748,7 @@ Ipv4L3Protocol::HandleFragmentsTimeout(FragmentKey_t key, Ipv4Header& ipHeader, { NS_LOG_FUNCTION(this << &key << &ipHeader << iif); - MapFragments_t::iterator it = m_fragments.find(key); + auto it = m_fragments.find(key); Ptr packet = it->second->GetPartialPacket(); // if we have at least 8 bytes, we can send an ICMP. @@ -1837,11 +1824,8 @@ Ipv4L3Protocol::UpdateDuplicate(Ptr p, const Ipv4Header& header) << std::get<3>(key) << ")"); // place a new entry, on collision the existing entry iterator is returned - DupMap_t::iterator iter; - bool inserted; - bool isDup; - std::tie(iter, inserted) = m_dups.emplace(key, Seconds(0)); - isDup = !inserted && iter->second > Simulator::Now(); + auto [iter, inserted] = m_dups.emplace(key, Seconds(0)); + bool isDup = !inserted && iter->second > Simulator::Now(); // set the expiration event iter->second = Simulator::Now() + m_expire; @@ -1894,7 +1878,7 @@ Ipv4L3Protocol::SetTimeout(FragmentKey_t key, Ipv4Header ipHeader, uint32_t iif) } m_timeoutEventList.emplace_back(now, key, ipHeader, iif); - Ipv4L3Protocol::FragmentsTimeoutsListI_t iter = --m_timeoutEventList.end(); + auto iter = --m_timeoutEventList.end(); return (iter); } diff --git a/src/internet/model/ipv4-l3-protocol.h b/src/internet/model/ipv4-l3-protocol.h index 94327765d..b59e7292f 100644 --- a/src/internet/model/ipv4-l3-protocol.h +++ b/src/internet/model/ipv4-l3-protocol.h @@ -20,10 +20,11 @@ #ifndef IPV4_L3_PROTOCOL_H #define IPV4_L3_PROTOCOL_H +#include "ipv4-header.h" +#include "ipv4-routing-protocol.h" +#include "ipv4.h" + #include "ns3/ipv4-address.h" -#include "ns3/ipv4-header.h" -#include "ns3/ipv4-routing-protocol.h" -#include "ns3/ipv4.h" #include "ns3/net-device.h" #include "ns3/nstime.h" #include "ns3/ptr.h" diff --git a/src/internet/model/ipv4-list-routing.cc b/src/internet/model/ipv4-list-routing.cc index dad69ebc9..b3bd1e306 100644 --- a/src/internet/model/ipv4-list-routing.cc +++ b/src/internet/model/ipv4-list-routing.cc @@ -56,8 +56,7 @@ void Ipv4ListRouting::DoDispose() { NS_LOG_FUNCTION(this); - for (Ipv4RoutingProtocolList::iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { // Note: Calling dispose on these protocols causes memory leak @@ -77,9 +76,7 @@ Ipv4ListRouting::PrintRoutingTable(Ptr stream, Time::Unit u << ", Time: " << Now().As(unit) << ", Local time: " << m_ipv4->GetObject()->GetLocalTime().As(unit) << ", Ipv4ListRouting table" << std::endl; - for (Ipv4RoutingProtocolList::const_iterator i = m_routingProtocols.begin(); - i != m_routingProtocols.end(); - i++) + for (auto i = m_routingProtocols.begin(); i != m_routingProtocols.end(); i++) { *stream->GetStream() << " Priority: " << (*i).first << " Protocol: " << (*i).second->GetInstanceTypeId() << std::endl; @@ -91,8 +88,7 @@ void Ipv4ListRouting::DoInitialize() { NS_LOG_FUNCTION(this); - for (Ipv4RoutingProtocolList::iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { Ptr protocol = (*rprotoIter).second; @@ -110,9 +106,7 @@ Ipv4ListRouting::RouteOutput(Ptr p, NS_LOG_FUNCTION(this << p << header.GetDestination() << header.GetSource() << oif << sockerr); Ptr route; - for (Ipv4RoutingProtocolList::const_iterator i = m_routingProtocols.begin(); - i != m_routingProtocols.end(); - i++) + for (auto i = m_routingProtocols.begin(); i != m_routingProtocols.end(); i++) { NS_LOG_LOGIC("Checking protocol " << (*i).second->GetInstanceTypeId() << " with priority " << (*i).first); @@ -182,8 +176,7 @@ Ipv4ListRouting::RouteInput(Ptr p, { downstreamLcb = MakeNullCallback, const Ipv4Header&, uint32_t>(); } - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { if ((*rprotoIter).second->RouteInput(p, header, idev, ucb, mcb, downstreamLcb, ecb)) @@ -201,8 +194,7 @@ void Ipv4ListRouting::NotifyInterfaceUp(uint32_t interface) { NS_LOG_FUNCTION(this << interface); - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyInterfaceUp(interface); @@ -213,8 +205,7 @@ void Ipv4ListRouting::NotifyInterfaceDown(uint32_t interface) { NS_LOG_FUNCTION(this << interface); - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyInterfaceDown(interface); @@ -225,8 +216,7 @@ void Ipv4ListRouting::NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) { NS_LOG_FUNCTION(this << interface << address); - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyAddAddress(interface, address); @@ -237,8 +227,7 @@ void Ipv4ListRouting::NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address) { NS_LOG_FUNCTION(this << interface << address); - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyRemoveAddress(interface, address); @@ -250,8 +239,7 @@ Ipv4ListRouting::SetIpv4(Ptr ipv4) { NS_LOG_FUNCTION(this << ipv4); NS_ASSERT(!m_ipv4); - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->SetIpv4(ipv4); @@ -288,8 +276,7 @@ Ipv4ListRouting::GetRoutingProtocol(uint32_t index, int16_t& priority) const << " out of range"); } uint32_t i = 0; - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++, i++) { if (i == index) diff --git a/src/internet/model/ipv4-list-routing.h b/src/internet/model/ipv4-list-routing.h index 08d2e881e..2eefd6afe 100644 --- a/src/internet/model/ipv4-list-routing.h +++ b/src/internet/model/ipv4-list-routing.h @@ -18,7 +18,8 @@ #ifndef IPV4_LIST_ROUTING_H #define IPV4_LIST_ROUTING_H -#include "ns3/ipv4-routing-protocol.h" +#include "ipv4-routing-protocol.h" + #include "ns3/nstime.h" #include "ns3/simulator.h" diff --git a/src/internet/model/ipv4-packet-probe.h b/src/internet/model/ipv4-packet-probe.h index 0d56a7a3f..400e30033 100644 --- a/src/internet/model/ipv4-packet-probe.h +++ b/src/internet/model/ipv4-packet-probe.h @@ -23,9 +23,10 @@ #ifndef IPV4_PACKET_PROBE_H #define IPV4_PACKET_PROBE_H +#include "ipv4.h" + #include "ns3/boolean.h" #include "ns3/callback.h" -#include "ns3/ipv4.h" #include "ns3/nstime.h" #include "ns3/object.h" #include "ns3/packet.h" diff --git a/src/internet/model/ipv4-raw-socket-factory-impl.h b/src/internet/model/ipv4-raw-socket-factory-impl.h index 887b01cc0..552c272e3 100644 --- a/src/internet/model/ipv4-raw-socket-factory-impl.h +++ b/src/internet/model/ipv4-raw-socket-factory-impl.h @@ -20,7 +20,7 @@ #ifndef IPV4_RAW_SOCKET_FACTORY_IMPL_H #define IPV4_RAW_SOCKET_FACTORY_IMPL_H -#include "ns3/ipv4-raw-socket-factory.h" +#include "ipv4-raw-socket-factory.h" namespace ns3 { diff --git a/src/internet/model/ipv4-raw-socket-impl.cc b/src/internet/model/ipv4-raw-socket-impl.cc index c4f98fc0b..86e4a547d 100644 --- a/src/internet/model/ipv4-raw-socket-impl.cc +++ b/src/internet/model/ipv4-raw-socket-impl.cc @@ -400,7 +400,7 @@ Ipv4RawSocketImpl::GetRxAvailable() const { NS_LOG_FUNCTION(this); uint32_t rx = 0; - for (std::list::const_iterator i = m_recv.begin(); i != m_recv.end(); ++i) + for (auto i = m_recv.begin(); i != m_recv.end(); ++i) { rx += (i->packet)->GetSize(); } diff --git a/src/internet/model/ipv4-raw-socket-impl.h b/src/internet/model/ipv4-raw-socket-impl.h index 2bd93e0a7..a718e0481 100644 --- a/src/internet/model/ipv4-raw-socket-impl.h +++ b/src/internet/model/ipv4-raw-socket-impl.h @@ -1,9 +1,10 @@ #ifndef IPV4_RAW_SOCKET_IMPL_H #define IPV4_RAW_SOCKET_IMPL_H -#include "ns3/ipv4-header.h" -#include "ns3/ipv4-interface.h" -#include "ns3/ipv4-route.h" +#include "ipv4-header.h" +#include "ipv4-interface.h" +#include "ipv4-route.h" + #include "ns3/socket.h" #include diff --git a/src/internet/model/ipv4-route.cc b/src/internet/model/ipv4-route.cc index 0ac391236..4182cfd34 100644 --- a/src/internet/model/ipv4-route.cc +++ b/src/internet/model/ipv4-route.cc @@ -151,8 +151,7 @@ Ipv4MulticastRoute::SetOutputTtl(uint32_t oif, uint32_t ttl) if (ttl >= MAX_TTL) { // This TTL value effectively disables the interface - std::map::iterator iter; - iter = m_ttls.find(oif); + auto iter = m_ttls.find(oif); if (iter != m_ttls.end()) { m_ttls.erase(iter); diff --git a/src/internet/model/ipv4-routing-protocol.h b/src/internet/model/ipv4-routing-protocol.h index ffee409e7..ba5f7b976 100644 --- a/src/internet/model/ipv4-routing-protocol.h +++ b/src/internet/model/ipv4-routing-protocol.h @@ -18,10 +18,10 @@ #define IPV4_ROUTING_PROTOCOL_H #include "ipv4-header.h" +#include "ipv4-interface-address.h" #include "ipv4.h" #include "ns3/callback.h" -#include "ns3/ipv4-interface-address.h" #include "ns3/nstime.h" #include "ns3/object.h" #include "ns3/output-stream-wrapper.h" diff --git a/src/internet/model/ipv4-static-routing.cc b/src/internet/model/ipv4-static-routing.cc index 781c88f4e..2d81e8d36 100644 --- a/src/internet/model/ipv4-static-routing.cc +++ b/src/internet/model/ipv4-static-routing.cc @@ -78,7 +78,7 @@ Ipv4StaticRouting::AddNetworkRouteTo(Ipv4Address network, if (!LookupRoute(route, metric)) { - Ipv4RoutingTableEntry* routePtr = new Ipv4RoutingTableEntry(route); + auto routePtr = new Ipv4RoutingTableEntry(route); m_networkRoutes.emplace_back(routePtr, metric); } } @@ -95,7 +95,7 @@ Ipv4StaticRouting::AddNetworkRouteTo(Ipv4Address network, Ipv4RoutingTableEntry::CreateNetworkRouteTo(network, networkMask, interface); if (!LookupRoute(route, metric)) { - Ipv4RoutingTableEntry* routePtr = new Ipv4RoutingTableEntry(route); + auto routePtr = new Ipv4RoutingTableEntry(route); m_networkRoutes.emplace_back(routePtr, metric); } @@ -133,7 +133,7 @@ Ipv4StaticRouting::AddMulticastRoute(Ipv4Address origin, { NS_LOG_FUNCTION(this << origin << " " << group << " " << inputInterface << " " << &outputInterfaces); - Ipv4MulticastRoutingTableEntry* route = new Ipv4MulticastRoutingTableEntry(); + auto route = new Ipv4MulticastRoutingTableEntry(); *route = Ipv4MulticastRoutingTableEntry::CreateMulticastRoute(origin, group, inputInterface, @@ -148,9 +148,9 @@ void Ipv4StaticRouting::SetDefaultMulticastRoute(uint32_t outputInterface) { NS_LOG_FUNCTION(this << outputInterface); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); - Ipv4Address network = Ipv4Address("224.0.0.0"); - Ipv4Mask networkMask = Ipv4Mask("240.0.0.0"); + auto route = new Ipv4RoutingTableEntry(); + Ipv4Address network("224.0.0.0"); + Ipv4Mask networkMask("240.0.0.0"); *route = Ipv4RoutingTableEntry::CreateNetworkRouteTo(network, networkMask, outputInterface); m_networkRoutes.emplace_back(route, 0); } @@ -172,7 +172,7 @@ Ipv4StaticRouting::GetMulticastRoute(uint32_t index) const if (index < m_multicastRoutes.size()) { uint32_t tmp = 0; - for (MulticastRoutesCI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { if (tmp == index) { @@ -190,7 +190,7 @@ Ipv4StaticRouting::RemoveMulticastRoute(Ipv4Address origin, uint32_t inputInterface) { NS_LOG_FUNCTION(this << origin << " " << group << " " << inputInterface); - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { Ipv4MulticastRoutingTableEntry* route = *i; if (origin == route->GetOrigin() && group == route->GetGroup() && @@ -209,7 +209,7 @@ Ipv4StaticRouting::RemoveMulticastRoute(uint32_t index) { NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { if (tmp == index) { @@ -224,7 +224,7 @@ Ipv4StaticRouting::RemoveMulticastRoute(uint32_t index) bool Ipv4StaticRouting::LookupRoute(const Ipv4RoutingTableEntry& route, uint32_t metric) { - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { Ipv4RoutingTableEntry* rtentry = j->first; @@ -261,7 +261,7 @@ Ipv4StaticRouting::LookupStatic(Ipv4Address dest, Ptr oif) return rtentry; } - for (NetworkRoutesI i = m_networkRoutes.begin(); i != m_networkRoutes.end(); i++) + for (auto i = m_networkRoutes.begin(); i != m_networkRoutes.end(); i++) { Ipv4RoutingTableEntry* j = i->first; uint32_t metric = i->second; @@ -328,7 +328,7 @@ Ipv4StaticRouting::LookupStatic(Ipv4Address origin, Ipv4Address group, uint32_t NS_LOG_FUNCTION(this << origin << " " << group << " " << interface); Ptr mrtentry = nullptr; - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { Ipv4MulticastRoutingTableEntry* route = *i; // @@ -385,7 +385,7 @@ Ipv4StaticRouting::GetDefaultRoute() Ipv4Address dest("0.0.0.0"); uint32_t shortest_metric = 0xffffffff; Ipv4RoutingTableEntry* result = nullptr; - for (NetworkRoutesI i = m_networkRoutes.begin(); i != m_networkRoutes.end(); i++) + for (auto i = m_networkRoutes.begin(); i != m_networkRoutes.end(); i++) { Ipv4RoutingTableEntry* j = i->first; uint32_t metric = i->second; @@ -417,7 +417,7 @@ Ipv4StaticRouting::GetRoute(uint32_t index) const { NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (NetworkRoutesCI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { if (tmp == index) { @@ -435,7 +435,7 @@ Ipv4StaticRouting::GetMetric(uint32_t index) const { NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (NetworkRoutesCI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { if (tmp == index) { @@ -453,7 +453,7 @@ Ipv4StaticRouting::RemoveRoute(uint32_t index) { NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { if (tmp == index) { @@ -588,12 +588,11 @@ void Ipv4StaticRouting::DoDispose() { NS_LOG_FUNCTION(this); - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); - j = m_networkRoutes.erase(j)) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j = m_networkRoutes.erase(j)) { delete (j->first); } - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i = m_multicastRoutes.erase(i)) { delete (*i); @@ -628,7 +627,7 @@ Ipv4StaticRouting::NotifyInterfaceDown(uint32_t i) { NS_LOG_FUNCTION(this << i); // Remove all static routes that are going through this interface - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end();) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end();) { if (it->first->GetInterface() == i) { @@ -671,7 +670,7 @@ Ipv4StaticRouting::NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress Ipv4Mask networkMask = address.GetMask(); // Remove all static routes that are going through this interface // which reference this network - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end();) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end();) { if (it->first->GetInterface() == interface && it->first->IsNetwork() && it->first->GetDestNetwork() == networkAddress && diff --git a/src/internet/model/ipv4-static-routing.h b/src/internet/model/ipv4-static-routing.h index c96007f00..8efde3a82 100644 --- a/src/internet/model/ipv4-static-routing.h +++ b/src/internet/model/ipv4-static-routing.h @@ -21,10 +21,11 @@ #ifndef IPV4_STATIC_ROUTING_H #define IPV4_STATIC_ROUTING_H +#include "ipv4-header.h" +#include "ipv4-routing-protocol.h" +#include "ipv4.h" + #include "ns3/ipv4-address.h" -#include "ns3/ipv4-header.h" -#include "ns3/ipv4-routing-protocol.h" -#include "ns3/ipv4.h" #include "ns3/ptr.h" #include "ns3/socket.h" diff --git a/src/internet/model/ipv6-address-generator.cc b/src/internet/model/ipv6-address-generator.cc index c01efafda..f1836f6ec 100644 --- a/src/internet/model/ipv6-address-generator.cc +++ b/src/internet/model/ipv6-address-generator.cc @@ -515,7 +515,7 @@ Ipv6AddressGeneratorImpl::AddAllocated(const Ipv6Address address) taddr[15] += 1; if (Ipv6Address(addr) == Ipv6Address(taddr)) { - std::list::iterator j = i; + auto j = i; ++j; if (j != m_entries.end()) @@ -581,9 +581,7 @@ Ipv6AddressGeneratorImpl::IsAddressAllocated(const Ipv6Address address) uint8_t addr[16]; address.GetBytes(addr); - std::list::iterator i; - - for (i = m_entries.begin(); i != m_entries.end(); ++i) + for (auto i = m_entries.begin(); i != m_entries.end(); ++i) { NS_LOG_LOGIC("examine entry: " << Ipv6Address((*i).addrLow) << " to " << Ipv6Address((*i).addrHigh)); @@ -594,10 +592,10 @@ Ipv6AddressGeneratorImpl::IsAddressAllocated(const Ipv6Address address) { NS_LOG_LOGIC("Ipv6AddressGeneratorImpl::IsAddressAllocated(): Address Collision: " << Ipv6Address(addr)); - return false; + return true; } } - return true; + return false; } bool @@ -610,9 +608,7 @@ Ipv6AddressGeneratorImpl::IsNetworkAllocated(const Ipv6Address address, const Ip "Ipv6AddressGeneratorImpl::IsNetworkAllocated(): network address and mask don't match " << address << " " << prefix); - std::list::iterator i; - - for (i = m_entries.begin(); i != m_entries.end(); ++i) + for (auto i = m_entries.begin(); i != m_entries.end(); ++i) { NS_LOG_LOGIC("examine entry: " << Ipv6Address((*i).addrLow) << " to " << Ipv6Address((*i).addrHigh)); diff --git a/src/internet/model/ipv6-end-point-demux.cc b/src/internet/model/ipv6-end-point-demux.cc index 94a3944fa..f22a72811 100644 --- a/src/internet/model/ipv6-end-point-demux.cc +++ b/src/internet/model/ipv6-end-point-demux.cc @@ -39,7 +39,7 @@ Ipv6EndPointDemux::Ipv6EndPointDemux() Ipv6EndPointDemux::~Ipv6EndPointDemux() { NS_LOG_FUNCTION(this); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { Ipv6EndPoint* endPoint = *i; delete endPoint; @@ -51,7 +51,7 @@ bool Ipv6EndPointDemux::LookupPortLocal(uint16_t port) { NS_LOG_FUNCTION(this << port); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() == port) { @@ -65,7 +65,7 @@ bool Ipv6EndPointDemux::LookupLocal(Ptr boundNetDevice, Ipv6Address addr, uint16_t port) { NS_LOG_FUNCTION(this << addr << port); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() == port && (*i)->GetLocalAddress() == addr && (*i)->GetBoundNetDevice() == boundNetDevice) @@ -86,7 +86,7 @@ Ipv6EndPointDemux::Allocate() NS_LOG_WARN("Ephemeral port allocation failed."); return nullptr; } - Ipv6EndPoint* endPoint = new Ipv6EndPoint(Ipv6Address::GetAny(), port); + auto endPoint = new Ipv6EndPoint(Ipv6Address::GetAny(), port); m_endPoints.push_back(endPoint); NS_LOG_DEBUG("Now have >>" << m_endPoints.size() << "<< endpoints."); return endPoint; @@ -102,7 +102,7 @@ Ipv6EndPointDemux::Allocate(Ipv6Address address) NS_LOG_WARN("Ephemeral port allocation failed."); return nullptr; } - Ipv6EndPoint* endPoint = new Ipv6EndPoint(address, port); + auto endPoint = new Ipv6EndPoint(address, port); m_endPoints.push_back(endPoint); NS_LOG_DEBUG("Now have >>" << m_endPoints.size() << "<< endpoints."); return endPoint; @@ -125,7 +125,7 @@ Ipv6EndPointDemux::Allocate(Ptr boundNetDevice, Ipv6Address address, NS_LOG_WARN("Duplicated endpoint."); return nullptr; } - Ipv6EndPoint* endPoint = new Ipv6EndPoint(address, port); + auto endPoint = new Ipv6EndPoint(address, port); m_endPoints.push_back(endPoint); NS_LOG_DEBUG("Now have >>" << m_endPoints.size() << "<< endpoints."); return endPoint; @@ -139,7 +139,7 @@ Ipv6EndPointDemux::Allocate(Ptr boundNetDevice, uint16_t peerPort) { NS_LOG_FUNCTION(this << boundNetDevice << localAddress << localPort << peerAddress << peerPort); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() == localPort && (*i)->GetLocalAddress() == localAddress && (*i)->GetPeerPort() == peerPort && (*i)->GetPeerAddress() == peerAddress && @@ -149,7 +149,7 @@ Ipv6EndPointDemux::Allocate(Ptr boundNetDevice, return nullptr; } } - Ipv6EndPoint* endPoint = new Ipv6EndPoint(localAddress, localPort); + auto endPoint = new Ipv6EndPoint(localAddress, localPort); endPoint->SetPeer(peerAddress, peerPort); m_endPoints.push_back(endPoint); @@ -162,7 +162,7 @@ void Ipv6EndPointDemux::DeAllocate(Ipv6EndPoint* endPoint) { NS_LOG_FUNCTION(this); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if (*i == endPoint) { @@ -193,7 +193,7 @@ Ipv6EndPointDemux::Lookup(Ipv6Address daddr, EndPoints retval4; /* Exact match on all 4 */ NS_LOG_DEBUG("Looking up endpoint for destination address " << daddr); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { Ipv6EndPoint* endP = *i; @@ -313,7 +313,7 @@ Ipv6EndPointDemux::SimpleLookup(Ipv6Address dst, uint16_t dport, Ipv6Address src uint32_t genericity = 3; Ipv6EndPoint* generic = nullptr; - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { uint32_t tmp = 0; diff --git a/src/internet/model/ipv6-end-point.h b/src/internet/model/ipv6-end-point.h index 3dc0fe200..e7d3dfd4a 100644 --- a/src/internet/model/ipv6-end-point.h +++ b/src/internet/model/ipv6-end-point.h @@ -20,10 +20,11 @@ #ifndef IPV6_END_POINT_H #define IPV6_END_POINT_H +#include "ipv6-header.h" +#include "ipv6-interface.h" + #include "ns3/callback.h" #include "ns3/ipv6-address.h" -#include "ns3/ipv6-header.h" -#include "ns3/ipv6-interface.h" #include "ns3/net-device.h" #include diff --git a/src/internet/model/ipv6-extension-demux.cc b/src/internet/model/ipv6-extension-demux.cc index be715e54a..f7e9eb45d 100644 --- a/src/internet/model/ipv6-extension-demux.cc +++ b/src/internet/model/ipv6-extension-demux.cc @@ -58,7 +58,7 @@ Ipv6ExtensionDemux::~Ipv6ExtensionDemux() void Ipv6ExtensionDemux::DoDispose() { - for (Ipv6ExtensionList_t::iterator it = m_extensions.begin(); it != m_extensions.end(); it++) + for (auto it = m_extensions.begin(); it != m_extensions.end(); it++) { (*it)->Dispose(); *it = nullptr; @@ -83,7 +83,7 @@ Ipv6ExtensionDemux::Insert(Ptr extension) Ptr Ipv6ExtensionDemux::GetExtension(uint8_t extensionNumber) { - for (Ipv6ExtensionList_t::iterator i = m_extensions.begin(); i != m_extensions.end(); ++i) + for (auto i = m_extensions.begin(); i != m_extensions.end(); ++i) { if ((*i)->GetExtensionNumber() == extensionNumber) { diff --git a/src/internet/model/ipv6-extension-header.cc b/src/internet/model/ipv6-extension-header.cc index a53eb88bf..dc1fc12fc 100644 --- a/src/internet/model/ipv6-extension-header.cc +++ b/src/internet/model/ipv6-extension-header.cc @@ -118,7 +118,7 @@ Ipv6ExtensionHeader::Deserialize(Buffer::Iterator start) m_length = i.ReadU8(); uint32_t dataLength = GetLength() - 2; - uint8_t* data = new uint8_t[dataLength]; + auto data = new uint8_t[dataLength]; i.Read(data, dataLength); if (dataLength > m_data.GetSize()) @@ -175,7 +175,7 @@ OptionField::Serialize(Buffer::Iterator start) const uint32_t OptionField::Deserialize(Buffer::Iterator start, uint32_t length) { - uint8_t* buf = new uint8_t[length]; + auto buf = new uint8_t[length]; start.Read(buf, length); m_optionData = Buffer(); m_optionData.AddAtEnd(length); @@ -613,9 +613,7 @@ Ipv6ExtensionLooseRoutingHeader::Print(std::ostream& os) const << " typeRouting = " << (uint32_t)GetTypeRouting() << " segmentsLeft = " << (uint32_t)GetSegmentsLeft() << " "; - for (std::vector::const_iterator it = m_routersAddress.begin(); - it != m_routersAddress.end(); - it++) + for (auto it = m_routersAddress.begin(); it != m_routersAddress.end(); it++) { os << *it << " "; } @@ -643,9 +641,7 @@ Ipv6ExtensionLooseRoutingHeader::Serialize(Buffer::Iterator start) const i.WriteU8(GetSegmentsLeft()); i.WriteU32(0); - for (VectorIpv6Address_t::const_iterator it = m_routersAddress.begin(); - it != m_routersAddress.end(); - it++) + for (auto it = m_routersAddress.begin(); it != m_routersAddress.end(); it++) { it->Serialize(buff); i.Write(buff, 16); diff --git a/src/internet/model/ipv6-extension.cc b/src/internet/model/ipv6-extension.cc index c8157a126..5126f971f 100644 --- a/src/internet/model/ipv6-extension.cc +++ b/src/internet/model/ipv6-extension.cc @@ -109,7 +109,7 @@ Ipv6Extension::ProcessOptions(Ptr& packet, uint8_t processedSize = 0; uint32_t size = p->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; p->CopyData(data, size); uint8_t optionType = 0; @@ -354,7 +354,7 @@ Ipv6ExtensionFragment::DoDispose() { NS_LOG_FUNCTION(this); - for (MapFragments_t::iterator it = m_fragments.begin(); it != m_fragments.end(); it++) + for (auto it = m_fragments.begin(); it != m_fragments.end(); it++) { it->second = nullptr; } @@ -408,7 +408,7 @@ Ipv6ExtensionFragment::Process(Ptr& packet, Ipv6Header ipHeader = ipv6Header; ipHeader.SetNextHeader(fragmentHeader.GetNextHeader()); - MapFragments_t::iterator it = m_fragments.find(fragmentKey); + auto it = m_fragments.find(fragmentKey); if (it == m_fragments.end()) { fragments = Create(); @@ -416,7 +416,7 @@ Ipv6ExtensionFragment::Process(Ptr& packet, NS_LOG_DEBUG("Insert new fragment key: src: " << src << " IP hdr id " << identification << " m_fragments.size() " << m_fragments.size() << " offset " << fragmentOffset); - FragmentsTimeoutsListI_t iter = SetTimeout(fragmentKey, ipHeader); + auto iter = SetTimeout(fragmentKey, ipHeader); fragments->SetTimeoutIter(iter); } else @@ -487,7 +487,7 @@ Ipv6ExtensionFragment::GetFragments(Ptr packet, { if (nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP) { - Ipv6ExtensionHopByHopHeader* hopbyhopHeader = new Ipv6ExtensionHopByHopHeader(); + auto hopbyhopHeader = new Ipv6ExtensionHopByHopHeader(); p->RemoveHeader(*hopbyhopHeader); nextHeader = hopbyhopHeader->GetNextHeader(); @@ -541,8 +541,7 @@ Ipv6ExtensionFragment::GetFragments(Ptr packet, } else if (nextHeader == Ipv6Header::IPV6_EXT_DESTINATION) { - Ipv6ExtensionDestinationHeader* destinationHeader = - new Ipv6ExtensionDestinationHeader(); + auto destinationHeader = new Ipv6ExtensionDestinationHeader(); p->RemoveHeader(*destinationHeader); nextHeader = destinationHeader->GetNextHeader(); @@ -572,7 +571,7 @@ Ipv6ExtensionFragment::GetFragments(Ptr packet, uint32_t currentFragmentablePartSize = 0; bool moreFragment = true; - uint32_t identification = (uint32_t)m_uvar->GetValue(0, (uint32_t)-1); + auto identification = (uint32_t)m_uvar->GetValue(0, (uint32_t)-1); uint16_t offset = 0; do @@ -599,29 +598,23 @@ Ipv6ExtensionFragment::GetFragments(Ptr packet, fragment->AddHeader(fragmentHeader); - for (std::list>::iterator it = - unfragmentablePart.begin(); - it != unfragmentablePart.end(); - it++) + for (auto it = unfragmentablePart.begin(); it != unfragmentablePart.end(); it++) { if (it->second == Ipv6Header::IPV6_EXT_HOP_BY_HOP) { - Ipv6ExtensionHopByHopHeader* p = - dynamic_cast(it->first); + auto p = dynamic_cast(it->first); NS_ASSERT(p != nullptr); fragment->AddHeader(*p); } else if (it->second == Ipv6Header::IPV6_EXT_ROUTING) { - Ipv6ExtensionLooseRoutingHeader* p = - dynamic_cast(it->first); + auto p = dynamic_cast(it->first); NS_ASSERT(p != nullptr); fragment->AddHeader(*p); } else if (it->second == Ipv6Header::IPV6_EXT_DESTINATION) { - Ipv6ExtensionDestinationHeader* p = - dynamic_cast(it->first); + auto p = dynamic_cast(it->first); NS_ASSERT(p != nullptr); fragment->AddHeader(*p); } @@ -636,10 +629,7 @@ Ipv6ExtensionFragment::GetFragments(Ptr packet, listFragments.emplace_back(fragment, ipv6Header); } while (moreFragment); - for (std::list>::iterator it = - unfragmentablePart.begin(); - it != unfragmentablePart.end(); - it++) + for (auto it = unfragmentablePart.begin(); it != unfragmentablePart.end(); it++) { delete it->first; } @@ -653,7 +643,7 @@ Ipv6ExtensionFragment::HandleFragmentsTimeout(FragmentKey_t fragmentKey, Ipv6Hea NS_LOG_FUNCTION(this << fragmentKey.first << fragmentKey.second << ipHeader); Ptr fragments; - MapFragments_t::iterator it = m_fragments.find(fragmentKey); + auto it = m_fragments.find(fragmentKey); NS_ASSERT_MSG(it != m_fragments.end(), "IPv6 Fragment timeout reached for non-existent fragment"); fragments = it->second; @@ -694,7 +684,7 @@ Ipv6ExtensionFragment::SetTimeout(FragmentKey_t key, Ipv6Header ipHeader) << key.second); m_timeoutEventList.emplace_back(Simulator::Now() + m_fragmentExpirationTimeout, key, ipHeader); - Ipv6ExtensionFragment::FragmentsTimeoutsListI_t iter = --m_timeoutEventList.end(); + auto iter = --m_timeoutEventList.end(); return (iter); } @@ -730,7 +720,7 @@ Ipv6ExtensionFragment::HandleTimeout() } Ipv6ExtensionFragment::Fragments::Fragments() - : m_moreFragment(0) + : m_moreFragment(false) { } @@ -778,10 +768,7 @@ Ipv6ExtensionFragment::Fragments::IsEntire() const { uint16_t lastEndOffset = 0; - for (std::list, uint16_t>>::const_iterator it = - m_packetFragments.begin(); - it != m_packetFragments.end(); - it++) + for (auto it = m_packetFragments.begin(); it != m_packetFragments.end(); it++) { if (lastEndOffset != it->second) { @@ -801,9 +788,7 @@ Ipv6ExtensionFragment::Fragments::GetPacket() const { Ptr p = m_unfragmentable->Copy(); - for (std::list, uint16_t>>::const_iterator it = m_packetFragments.begin(); - it != m_packetFragments.end(); - it++) + for (auto it = m_packetFragments.begin(); it != m_packetFragments.end(); it++) { p->AddAtEnd(it->first); } @@ -827,9 +812,7 @@ Ipv6ExtensionFragment::Fragments::GetPartialPacket() const uint16_t lastEndOffset = 0; - for (std::list, uint16_t>>::const_iterator it = m_packetFragments.begin(); - it != m_packetFragments.end(); - it++) + for (auto it = m_packetFragments.begin(); it != m_packetFragments.end(); it++) { if (lastEndOffset != it->second) { @@ -993,9 +976,7 @@ void Ipv6ExtensionRoutingDemux::DoDispose() { NS_LOG_FUNCTION(this); - for (Ipv6ExtensionRoutingList_t::iterator it = m_extensionsRouting.begin(); - it != m_extensionsRouting.end(); - it++) + for (auto it = m_extensionsRouting.begin(); it != m_extensionsRouting.end(); it++) { (*it)->Dispose(); *it = nullptr; @@ -1310,7 +1291,7 @@ Ipv6ExtensionAH::Process(Ptr& packet, /** \todo */ - return true; + return 1; } } /* namespace ns3 */ diff --git a/src/internet/model/ipv6-extension.h b/src/internet/model/ipv6-extension.h index 5c6af5b64..627978633 100644 --- a/src/internet/model/ipv6-extension.h +++ b/src/internet/model/ipv6-extension.h @@ -21,12 +21,12 @@ #define IPV6_EXTENSION_H #include "ipv6-extension-header.h" +#include "ipv6-header.h" #include "ipv6-interface.h" +#include "ipv6-l3-protocol.h" #include "ns3/buffer.h" #include "ns3/ipv6-address.h" -#include "ns3/ipv6-header.h" -#include "ns3/ipv6-l3-protocol.h" #include "ns3/node.h" #include "ns3/object.h" #include "ns3/packet.h" diff --git a/src/internet/model/ipv6-interface.cc b/src/internet/model/ipv6-interface.cc index 3e137a5d4..dd6d36ae8 100644 --- a/src/internet/model/ipv6-interface.cc +++ b/src/internet/model/ipv6-interface.cc @@ -215,7 +215,7 @@ Ipv6Interface::AddAddress(Ipv6InterfaceAddress iface) /* DAD handling */ if (!addr.IsAny()) { - for (Ipv6InterfaceAddressListCI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (it->first.GetAddress() == addr) { @@ -282,7 +282,7 @@ Ipv6Interface::IsSolicitedMulticastAddress(Ipv6Address address) const /* IPv6 interface has always at least one IPv6 Solicited Multicast address */ NS_LOG_FUNCTION(this << address); - for (Ipv6InterfaceAddressListCI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (it->second == address) { @@ -301,7 +301,7 @@ Ipv6Interface::GetAddress(uint32_t index) const if (m_addresses.size() > index) { - for (Ipv6InterfaceAddressListCI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (i == index) { @@ -336,7 +336,7 @@ Ipv6Interface::RemoveAddress(uint32_t index) NS_FATAL_ERROR("Removing index that does not exist in Ipv6Interface::RemoveAddress"); } - for (Ipv6InterfaceAddressListI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (i == index) { @@ -367,7 +367,7 @@ Ipv6Interface::RemoveAddress(Ipv6Address address) return Ipv6InterfaceAddress(); } - for (Ipv6InterfaceAddressListI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (it->first.GetAddress() == address) { @@ -388,8 +388,7 @@ Ipv6Interface::GetAddressMatchingDestination(Ipv6Address dst) { NS_LOG_FUNCTION(this << dst); - for (Ipv6InterfaceAddressList::const_iterator it = m_addresses.begin(); it != m_addresses.end(); - ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { Ipv6InterfaceAddress ifaddr = it->first; @@ -431,7 +430,7 @@ Ipv6Interface::Send(Ptr p, const Ipv6Header& hdr, Ipv6Address dest) NS_ASSERT(m_tc); /* check if destination is for one of our interface */ - for (Ipv6InterfaceAddressListCI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (dest == it->first.GetAddress()) { @@ -559,7 +558,7 @@ Ipv6Interface::SetState(Ipv6Address address, Ipv6InterfaceAddress::State_e state { NS_LOG_FUNCTION(this << address << state); - for (Ipv6InterfaceAddressListI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (it->first.GetAddress() == address) { @@ -575,7 +574,7 @@ Ipv6Interface::SetNsDadUid(Ipv6Address address, uint32_t uid) { NS_LOG_FUNCTION(this << address << uid); - for (Ipv6InterfaceAddressListI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (it->first.GetAddress() == address) { diff --git a/src/internet/model/ipv6-l3-protocol.cc b/src/internet/model/ipv6-l3-protocol.cc index 4ee84f1f5..512653ec8 100644 --- a/src/internet/model/ipv6-l3-protocol.cc +++ b/src/internet/model/ipv6-l3-protocol.cc @@ -150,14 +150,14 @@ Ipv6L3Protocol::DoDispose() NS_LOG_FUNCTION(this); /* clear protocol and interface list */ - for (L4List_t::iterator it = m_protocols.begin(); it != m_protocols.end(); ++it) + for (auto it = m_protocols.begin(); it != m_protocols.end(); ++it) { it->second = nullptr; } m_protocols.clear(); /* remove interfaces */ - for (Ipv6InterfaceList::iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it) + for (auto it = m_interfaces.begin(); it != m_interfaces.end(); ++it) { *it = nullptr; } @@ -165,14 +165,14 @@ Ipv6L3Protocol::DoDispose() m_reverseInterfacesContainer.clear(); /* remove raw sockets */ - for (SocketList::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) + for (auto it = m_sockets.begin(); it != m_sockets.end(); ++it) { *it = nullptr; } m_sockets.clear(); /* remove list of prefix */ - for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin(); it != m_prefixes.end(); ++it) + for (auto it = m_prefixes.begin(); it != m_prefixes.end(); ++it) { (*it)->StopValidTimer(); (*it)->StopPreferredTimer(); @@ -263,8 +263,7 @@ Ipv6L3Protocol::GetInterfaceForAddress(Ipv6Address address) const NS_LOG_FUNCTION(this << address); int32_t index = 0; - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin(); it != m_interfaces.end(); - it++) + for (auto it = m_interfaces.begin(); it != m_interfaces.end(); it++) { uint32_t j = 0; uint32_t max = (*it)->GetNAddresses(); @@ -287,8 +286,7 @@ Ipv6L3Protocol::GetInterfaceForPrefix(Ipv6Address address, Ipv6Prefix mask) cons NS_LOG_FUNCTION(this << address << mask); int32_t index = 0; - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin(); it != m_interfaces.end(); - it++) + for (auto it = m_interfaces.begin(); it != m_interfaces.end(); it++) { uint32_t j = 0; for (j = 0; j < (*it)->GetNAddresses(); j++) @@ -316,7 +314,7 @@ Ipv6L3Protocol::GetInterfaceForDevice(Ptr device) const { NS_LOG_FUNCTION(this << device); - Ipv6InterfaceReverseContainer::const_iterator iter = m_reverseInterfacesContainer.find(device); + auto iter = m_reverseInterfacesContainer.find(device); if (iter != m_reverseInterfacesContainer.end()) { return (*iter).second; @@ -361,7 +359,7 @@ Ipv6L3Protocol::AddAutoconfiguredAddress(uint32_t interface, address.SetOnLink(onLink); /* see if we have already the prefix */ - for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin(); it != m_prefixes.end(); ++it) + for (auto it = m_prefixes.begin(); it != m_prefixes.end(); ++it) { if ((*it)->GetInterface() == interface && (*it)->GetPrefix() == network && (*it)->GetMask() == mask) @@ -421,7 +419,7 @@ Ipv6L3Protocol::RemoveAutoconfiguredAddress(uint32_t interface, } /* remove from list of autoconfigured address */ - for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin(); it != m_prefixes.end(); ++it) + for (auto it = m_prefixes.begin(); it != m_prefixes.end(); ++it) { if ((*it)->GetInterface() == interface && (*it)->GetPrefix() == network && (*it)->GetMask() == mask) @@ -721,8 +719,7 @@ Ipv6L3Protocol::SetIpForward(bool forward) NS_LOG_FUNCTION(this << forward); m_ipForward = forward; - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin(); it != m_interfaces.end(); - it++) + for (auto it = m_interfaces.begin(); it != m_interfaces.end(); it++) { (*it)->SetForwarding(forward); } @@ -823,7 +820,7 @@ Ipv6L3Protocol::Remove(Ptr protocol) NS_LOG_FUNCTION(this << protocol); L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), -1); - L4List_t::iterator iter = m_protocols.find(key); + auto iter = m_protocols.find(key); if (iter == m_protocols.end()) { NS_LOG_WARN("Trying to remove an non-existent default protocol " @@ -841,7 +838,7 @@ Ipv6L3Protocol::Remove(Ptr protocol, uint32_t interfaceIndex) NS_LOG_FUNCTION(this << protocol << interfaceIndex); L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), interfaceIndex); - L4List_t::iterator iter = m_protocols.find(key); + auto iter = m_protocols.find(key); if (iter == m_protocols.end()) { NS_LOG_WARN("Trying to remove an non-existent protocol " @@ -867,21 +864,19 @@ Ipv6L3Protocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) const { NS_LOG_FUNCTION(this << protocolNumber << interfaceIndex); - L4ListKey_t key; - L4List_t::const_iterator i; if (interfaceIndex >= 0) { // try the interface-specific protocol. - key = std::make_pair(protocolNumber, interfaceIndex); - i = m_protocols.find(key); + auto key = std::make_pair(protocolNumber, interfaceIndex); + auto i = m_protocols.find(key); if (i != m_protocols.end()) { return i->second; } } // try the generic protocol. - key = std::make_pair(protocolNumber, -1); - i = m_protocols.find(key); + auto key = std::make_pair(protocolNumber, -1); + auto i = m_protocols.find(key); if (i != m_protocols.end()) { return i->second; @@ -905,7 +900,7 @@ Ipv6L3Protocol::DeleteRawSocket(Ptr socket) { NS_LOG_FUNCTION(this << socket); - for (SocketList::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) + for (auto it = m_sockets.begin(); it != m_sockets.end(); ++it) { if ((*it) == socket) { @@ -1089,8 +1084,7 @@ Ipv6L3Protocol::Receive(Ptr device, // addresses. In doubt, update all of them. Note: it's a confirmed behavior for Linux // routers. std::list entryList = ndiscCache->LookupInverse(from); - std::list::iterator iter; - for (iter = entryList.begin(); iter != entryList.end(); iter++) + for (auto iter = entryList.begin(); iter != entryList.end(); iter++) { (*iter)->UpdateReachableTimer(); } @@ -1098,7 +1092,7 @@ Ipv6L3Protocol::Receive(Ptr device, } /* forward up to IPv6 raw sockets */ - for (SocketList::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) + for (auto it = m_sockets.begin(); it != m_sockets.end(); ++it) { Ptr socket = *it; socket->ForwardUp(packet, hdr, device); @@ -1301,10 +1295,7 @@ Ipv6L3Protocol::SendRealOut(Ptr route, Ptr packet, const Ipv6 { std::ostringstream oss; - for (std::list::const_iterator it = - fragments.begin(); - it != fragments.end(); - it++) + for (auto it = fragments.begin(); it != fragments.end(); it++) { CallTxTrace(it->second, it->first, this, interface); outInterface->Send(it->first, it->second, route->GetGateway()); @@ -1332,10 +1323,7 @@ Ipv6L3Protocol::SendRealOut(Ptr route, Ptr packet, const Ipv6 { std::ostringstream oss; - for (std::list::const_iterator it = - fragments.begin(); - it != fragments.end(); - it++) + for (auto it = fragments.begin(); it != fragments.end(); it++) { CallTxTrace(it->second, it->first, this, interface); outInterface->Send(it->first, it->second, ipHeader.GetDestination()); @@ -1458,9 +1446,8 @@ Ipv6L3Protocol::IpMulticastForward(Ptr idev, NS_LOG_LOGIC("Multicast forwarding logic for node: " << m_node->GetId()); std::map ttlMap = mrtentry->GetOutputTtlMap(); - std::map::iterator mapIter; - for (mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++) + for (auto mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++) { uint32_t interfaceId = mapIter->first; // uint32_t outputTtl = mapIter->second; // Unused for now @@ -1788,7 +1775,7 @@ Ipv6L3Protocol::IsRegisteredMulticastAddress(Ipv6Address address, uint32_t inter NS_LOG_FUNCTION(address << interface); Ipv6RegisteredMulticastAddressKey_t key = std::make_pair(address, interface); - Ipv6RegisteredMulticastAddressCIter_t iter = m_multicastAddresses.find(key); + auto iter = m_multicastAddresses.find(key); return iter != m_multicastAddresses.end(); } @@ -1798,8 +1785,7 @@ Ipv6L3Protocol::IsRegisteredMulticastAddress(Ipv6Address address) const { NS_LOG_FUNCTION(address); - Ipv6RegisteredMulticastAddressNoInterfaceCIter_t iter = - m_multicastAddressesNoInterface.find(address); + auto iter = m_multicastAddressesNoInterface.find(address); return iter != m_multicastAddressesNoInterface.end(); } @@ -1837,9 +1823,7 @@ Ipv6L3Protocol::ReachabilityHint(uint32_t ipInterfaceIndex, Ipv6Address address) // we just confirm the entry's MAC address to get the waiting packets (if any) std::list waiting = entry->MarkReachable(entry->GetMacAddress()); - for (std::list::const_iterator it = waiting.begin(); - it != waiting.end(); - it++) + for (auto it = waiting.begin(); it != waiting.end(); it++) { ndiscCache->GetInterface()->Send(it->first, it->second, it->second.GetSource()); } diff --git a/src/internet/model/ipv6-l3-protocol.h b/src/internet/model/ipv6-l3-protocol.h index 12db07b77..cfbc4942d 100644 --- a/src/internet/model/ipv6-l3-protocol.h +++ b/src/internet/model/ipv6-l3-protocol.h @@ -20,11 +20,12 @@ #ifndef IPV6_L3_PROTOCOL_H #define IPV6_L3_PROTOCOL_H +#include "ipv6-header.h" +#include "ipv6-pmtu-cache.h" +#include "ipv6-routing-protocol.h" +#include "ipv6.h" + #include "ns3/ipv6-address.h" -#include "ns3/ipv6-header.h" -#include "ns3/ipv6-pmtu-cache.h" -#include "ns3/ipv6-routing-protocol.h" -#include "ns3/ipv6.h" #include "ns3/net-device.h" #include "ns3/traced-callback.h" diff --git a/src/internet/model/ipv6-list-routing.cc b/src/internet/model/ipv6-list-routing.cc index f6f0b4829..32b041b2e 100644 --- a/src/internet/model/ipv6-list-routing.cc +++ b/src/internet/model/ipv6-list-routing.cc @@ -57,8 +57,7 @@ void Ipv6ListRouting::DoDispose() { NS_LOG_FUNCTION(this); - for (Ipv6RoutingProtocolList::iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { // Note: Calling dispose on these protocols causes memory leak @@ -79,9 +78,7 @@ Ipv6ListRouting::RouteOutput(Ptr p, NS_LOG_FUNCTION(this << header.GetDestination() << header.GetSource() << oif); Ptr route; - for (Ipv6RoutingProtocolList::const_iterator i = m_routingProtocols.begin(); - i != m_routingProtocols.end(); - i++) + for (auto i = m_routingProtocols.begin(); i != m_routingProtocols.end(); i++) { NS_LOG_LOGIC("Checking protocol " << (*i).second->GetInstanceTypeId() << " with priority " << (*i).first); @@ -131,8 +128,7 @@ Ipv6ListRouting::RouteInput(Ptr p, ErrorCallback nullEcb = MakeNullCallback, const Ipv6Header&, Socket::SocketErrno>(); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { if ((*rprotoIter).second->RouteInput(p, header, idev, ucb, mcb, lcb, nullEcb)) @@ -150,8 +146,7 @@ void Ipv6ListRouting::NotifyInterfaceUp(uint32_t interface) { NS_LOG_FUNCTION(this << interface); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyInterfaceUp(interface); @@ -162,8 +157,7 @@ void Ipv6ListRouting::NotifyInterfaceDown(uint32_t interface) { NS_LOG_FUNCTION(this << interface); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyInterfaceDown(interface); @@ -174,8 +168,7 @@ void Ipv6ListRouting::NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address) { NS_LOG_FUNCTION(this << interface << address); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyAddAddress(interface, address); @@ -186,8 +179,7 @@ void Ipv6ListRouting::NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address) { NS_LOG_FUNCTION(this << interface << address); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyRemoveAddress(interface, address); @@ -202,8 +194,7 @@ Ipv6ListRouting::NotifyAddRoute(Ipv6Address dst, Ipv6Address prefixToUse) { NS_LOG_FUNCTION(this << dst << mask << nextHop << interface); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyAddRoute(dst, mask, nextHop, interface, prefixToUse); @@ -218,8 +209,7 @@ Ipv6ListRouting::NotifyRemoveRoute(Ipv6Address dst, Ipv6Address prefixToUse) { NS_LOG_FUNCTION(this << dst << mask << nextHop << interface); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyRemoveRoute(dst, mask, nextHop, interface, prefixToUse); @@ -235,9 +225,7 @@ Ipv6ListRouting::PrintRoutingTable(Ptr stream, Time::Unit u << ", Time: " << Now().As(unit) << ", Local time: " << m_ipv6->GetObject()->GetLocalTime().As(unit) << ", Ipv6ListRouting table" << std::endl; - for (Ipv6RoutingProtocolList::const_iterator i = m_routingProtocols.begin(); - i != m_routingProtocols.end(); - i++) + for (auto i = m_routingProtocols.begin(); i != m_routingProtocols.end(); i++) { *stream->GetStream() << " Priority: " << (*i).first << " Protocol: " << (*i).second->GetInstanceTypeId() << std::endl; @@ -250,8 +238,7 @@ Ipv6ListRouting::SetIpv6(Ptr ipv6) { NS_LOG_FUNCTION(this << ipv6); NS_ASSERT(!m_ipv6); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->SetIpv6(ipv6); @@ -288,8 +275,7 @@ Ipv6ListRouting::GetRoutingProtocol(uint32_t index, int16_t& priority) const << " out of range"); } uint32_t i = 0; - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++, i++) { if (i == index) diff --git a/src/internet/model/ipv6-list-routing.h b/src/internet/model/ipv6-list-routing.h index 24abc7552..7d54820bf 100644 --- a/src/internet/model/ipv6-list-routing.h +++ b/src/internet/model/ipv6-list-routing.h @@ -18,7 +18,7 @@ #ifndef IPV6_LIST_ROUTING_H #define IPV6_LIST_ROUTING_H -#include "ns3/ipv6-routing-protocol.h" +#include "ipv6-routing-protocol.h" #include diff --git a/src/internet/model/ipv6-option-demux.cc b/src/internet/model/ipv6-option-demux.cc index c333d1011..4f8ea668a 100644 --- a/src/internet/model/ipv6-option-demux.cc +++ b/src/internet/model/ipv6-option-demux.cc @@ -57,7 +57,7 @@ Ipv6OptionDemux::~Ipv6OptionDemux() void Ipv6OptionDemux::DoDispose() { - for (Ipv6OptionList_t::iterator it = m_options.begin(); it != m_options.end(); it++) + for (auto it = m_options.begin(); it != m_options.end(); it++) { (*it)->Dispose(); *it = nullptr; @@ -82,7 +82,7 @@ Ipv6OptionDemux::Insert(Ptr option) Ptr Ipv6OptionDemux::GetOption(int optionNumber) { - for (Ipv6OptionList_t::iterator i = m_options.begin(); i != m_options.end(); ++i) + for (auto i = m_options.begin(); i != m_options.end(); ++i) { if ((*i)->GetOptionNumber() == optionNumber) { diff --git a/src/internet/model/ipv6-option.h b/src/internet/model/ipv6-option.h index 3d09a0c9f..5b4bb17cf 100644 --- a/src/internet/model/ipv6-option.h +++ b/src/internet/model/ipv6-option.h @@ -20,11 +20,11 @@ #ifndef IPV6_OPTION_H #define IPV6_OPTION_H +#include "ipv6-header.h" #include "ipv6-interface.h" #include "ns3/buffer.h" #include "ns3/ipv6-address.h" -#include "ns3/ipv6-header.h" #include "ns3/node.h" #include "ns3/object.h" #include "ns3/packet.h" diff --git a/src/internet/model/ipv6-packet-probe.h b/src/internet/model/ipv6-packet-probe.h index 769db10ed..7016ce6c0 100644 --- a/src/internet/model/ipv6-packet-probe.h +++ b/src/internet/model/ipv6-packet-probe.h @@ -24,9 +24,10 @@ #ifndef IPV6_PACKET_PROBE_H #define IPV6_PACKET_PROBE_H +#include "ipv6.h" + #include "ns3/boolean.h" #include "ns3/callback.h" -#include "ns3/ipv6.h" #include "ns3/nstime.h" #include "ns3/object.h" #include "ns3/packet.h" diff --git a/src/internet/model/ipv6-pmtu-cache.cc b/src/internet/model/ipv6-pmtu-cache.cc index f8c58a298..3f5c156e8 100644 --- a/src/internet/model/ipv6-pmtu-cache.cc +++ b/src/internet/model/ipv6-pmtu-cache.cc @@ -56,7 +56,7 @@ Ipv6PmtuCache::~Ipv6PmtuCache() void Ipv6PmtuCache::DoDispose() { - for (pathMtuTimerIter iter = m_pathMtuTimer.begin(); iter != m_pathMtuTimer.end(); iter++) + for (auto iter = m_pathMtuTimer.begin(); iter != m_pathMtuTimer.end(); iter++) { iter->second.Cancel(); } diff --git a/src/internet/model/ipv6-raw-socket-factory-impl.h b/src/internet/model/ipv6-raw-socket-factory-impl.h index 073a5d843..050cf1904 100644 --- a/src/internet/model/ipv6-raw-socket-factory-impl.h +++ b/src/internet/model/ipv6-raw-socket-factory-impl.h @@ -20,7 +20,7 @@ #ifndef IPV6_RAW_SOCKET_FACTORY_IMPL_H #define IPV6_RAW_SOCKET_FACTORY_IMPL_H -#include "ns3/ipv6-raw-socket-factory.h" +#include "ipv6-raw-socket-factory.h" namespace ns3 { diff --git a/src/internet/model/ipv6-raw-socket-impl.cc b/src/internet/model/ipv6-raw-socket-impl.cc index 4ff166993..85560782e 100644 --- a/src/internet/model/ipv6-raw-socket-impl.cc +++ b/src/internet/model/ipv6-raw-socket-impl.cc @@ -293,7 +293,7 @@ Ipv6RawSocketImpl::SendTo(Ptr p, uint32_t flags, const Address& toAddres p->CopyData(&type, sizeof(type)); if (type == Icmpv6Header::ICMPV6_ECHO_REQUEST) { - Icmpv6Echo hdr(1); + Icmpv6Echo hdr(true); p->RemoveHeader(hdr); hdr.CalculatePseudoHeaderChecksum(route->GetSource(), dst, @@ -421,7 +421,7 @@ Ipv6RawSocketImpl::GetRxAvailable() const NS_LOG_FUNCTION(this); uint32_t rx = 0; - for (std::list::const_iterator it = m_data.begin(); it != m_data.end(); ++it) + for (auto it = m_data.begin(); it != m_data.end(); ++it) { rx += (it->packet)->GetSize(); } diff --git a/src/internet/model/ipv6-raw-socket-impl.h b/src/internet/model/ipv6-raw-socket-impl.h index 2b23819ab..8d8d31d71 100644 --- a/src/internet/model/ipv6-raw-socket-impl.h +++ b/src/internet/model/ipv6-raw-socket-impl.h @@ -20,8 +20,9 @@ #ifndef IPV6_RAW_SOCKET_IMPL_H #define IPV6_RAW_SOCKET_IMPL_H +#include "ipv6-header.h" + #include "ns3/ipv6-address.h" -#include "ns3/ipv6-header.h" #include "ns3/socket.h" #include diff --git a/src/internet/model/ipv6-route.cc b/src/internet/model/ipv6-route.cc index 0543cd3d8..9161e6d40 100644 --- a/src/internet/model/ipv6-route.cc +++ b/src/internet/model/ipv6-route.cc @@ -141,8 +141,7 @@ Ipv6MulticastRoute::SetOutputTtl(uint32_t oif, uint32_t ttl) if (ttl >= MAX_TTL) { // This TTL value effectively disables the interface - std::map::iterator iter; - iter = m_ttls.find(oif); + auto iter = m_ttls.find(oif); if (iter != m_ttls.end()) { m_ttls.erase(iter); diff --git a/src/internet/model/ipv6-static-routing.cc b/src/internet/model/ipv6-static-routing.cc index f6a752296..82dd4c06e 100644 --- a/src/internet/model/ipv6-static-routing.cc +++ b/src/internet/model/ipv6-static-routing.cc @@ -181,7 +181,7 @@ Ipv6StaticRouting::AddNetworkRouteTo(Ipv6Address network, if (!LookupRoute(route, metric)) { - Ipv6RoutingTableEntry* routePtr = new Ipv6RoutingTableEntry(route); + auto routePtr = new Ipv6RoutingTableEntry(route); m_networkRoutes.emplace_back(routePtr, metric); } } @@ -208,7 +208,7 @@ Ipv6StaticRouting::AddNetworkRouteTo(Ipv6Address network, prefixToUse); if (!LookupRoute(route, metric)) { - Ipv6RoutingTableEntry* routePtr = new Ipv6RoutingTableEntry(route); + auto routePtr = new Ipv6RoutingTableEntry(route); m_networkRoutes.emplace_back(routePtr, metric); } } @@ -225,7 +225,7 @@ Ipv6StaticRouting::AddNetworkRouteTo(Ipv6Address network, Ipv6RoutingTableEntry::CreateNetworkRouteTo(network, networkPrefix, interface); if (!LookupRoute(route, metric)) { - Ipv6RoutingTableEntry* routePtr = new Ipv6RoutingTableEntry(route); + auto routePtr = new Ipv6RoutingTableEntry(route); m_networkRoutes.emplace_back(routePtr, metric); } } @@ -252,7 +252,7 @@ Ipv6StaticRouting::AddMulticastRoute(Ipv6Address origin, std::vector outputInterfaces) { NS_LOG_FUNCTION(this << origin << group << inputInterface); - Ipv6MulticastRoutingTableEntry* route = new Ipv6MulticastRoutingTableEntry(); + auto route = new Ipv6MulticastRoutingTableEntry(); *route = Ipv6MulticastRoutingTableEntry::CreateMulticastRoute(origin, group, inputInterface, @@ -264,7 +264,7 @@ void Ipv6StaticRouting::SetDefaultMulticastRoute(uint32_t outputInterface) { NS_LOG_FUNCTION(this << outputInterface); - Ipv6RoutingTableEntry* route = new Ipv6RoutingTableEntry(); + auto route = new Ipv6RoutingTableEntry(); Ipv6Address network = Ipv6Address("ff00::"); /* RFC 3513 */ Ipv6Prefix networkMask = Ipv6Prefix(8); *route = Ipv6RoutingTableEntry::CreateNetworkRouteTo(network, networkMask, outputInterface); @@ -288,7 +288,7 @@ Ipv6StaticRouting::GetMulticastRoute(uint32_t index) const if (index < m_multicastRoutes.size()) { uint32_t tmp = 0; - for (MulticastRoutesCI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { if (tmp == index) { @@ -306,7 +306,7 @@ Ipv6StaticRouting::RemoveMulticastRoute(Ipv6Address origin, uint32_t inputInterface) { NS_LOG_FUNCTION(this << origin << group << inputInterface); - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { Ipv6MulticastRoutingTableEntry* route = *i; if (origin == route->GetOrigin() && group == route->GetGroup() && @@ -326,7 +326,7 @@ Ipv6StaticRouting::RemoveMulticastRoute(uint32_t index) NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { if (tmp == index) { @@ -344,7 +344,7 @@ Ipv6StaticRouting::HasNetworkDest(Ipv6Address network, uint32_t interfaceIndex) NS_LOG_FUNCTION(this << network << interfaceIndex); /* in the network table */ - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { Ipv6RoutingTableEntry* rtentry = j->first; Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix(); @@ -363,7 +363,7 @@ Ipv6StaticRouting::HasNetworkDest(Ipv6Address network, uint32_t interfaceIndex) bool Ipv6StaticRouting::LookupRoute(const Ipv6RoutingTableEntry& route, uint32_t metric) { - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { Ipv6RoutingTableEntry* rtentry = j->first; @@ -402,7 +402,7 @@ Ipv6StaticRouting::LookupStatic(Ipv6Address dst, Ptr interface) return rtentry; } - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) { Ipv6RoutingTableEntry* j = it->first; uint32_t metric = it->second; @@ -485,14 +485,13 @@ Ipv6StaticRouting::DoDispose() { NS_LOG_FUNCTION(this); - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); - j = m_networkRoutes.erase(j)) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j = m_networkRoutes.erase(j)) { delete j->first; } m_networkRoutes.clear(); - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i = m_multicastRoutes.erase(i)) { delete (*i); @@ -509,7 +508,7 @@ Ipv6StaticRouting::LookupStatic(Ipv6Address origin, Ipv6Address group, uint32_t NS_LOG_FUNCTION(this << origin << group << interface); Ptr mrtentry = nullptr; - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { Ipv6MulticastRoutingTableEntry* route = *i; @@ -569,7 +568,7 @@ Ipv6StaticRouting::GetDefaultRoute() uint32_t shortestMetric = 0xffffffff; Ipv6RoutingTableEntry* result = nullptr; - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) { Ipv6RoutingTableEntry* j = it->first; uint32_t metric = it->second; @@ -606,7 +605,7 @@ Ipv6StaticRouting::GetRoute(uint32_t index) const NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (NetworkRoutesCI it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) { if (tmp == index) { @@ -625,7 +624,7 @@ Ipv6StaticRouting::GetMetric(uint32_t index) const NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (NetworkRoutesCI it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) { if (tmp == index) { @@ -644,7 +643,7 @@ Ipv6StaticRouting::RemoveRoute(uint32_t index) NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) { if (tmp == index) { @@ -665,7 +664,7 @@ Ipv6StaticRouting::RemoveRoute(Ipv6Address network, { NS_LOG_FUNCTION(this << network << prefix << ifIndex); - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) { Ipv6RoutingTableEntry* rtentry = it->first; if (network == rtentry->GetDest() && rtentry->GetInterface() == ifIndex && @@ -809,7 +808,7 @@ Ipv6StaticRouting::NotifyInterfaceDown(uint32_t i) NS_LOG_FUNCTION(this << i); /* remove all static routes that are going through this interface */ - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end();) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end();) { if (it->first->GetInterface() == i) { @@ -845,7 +844,7 @@ Ipv6StaticRouting::NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress // Remove all static routes that are going through this interface // which reference this network - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end();) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end();) { if (it->first->GetInterface() == interface && it->first->IsNetwork() && it->first->GetDestNetwork() == networkAddress && @@ -868,7 +867,7 @@ Ipv6StaticRouting::NotifyAddRoute(Ipv6Address dst, uint32_t interface, Ipv6Address prefixToUse) { - NS_LOG_INFO(this << dst << mask << nextHop << interface << prefixToUse); + NS_LOG_FUNCTION(this << dst << mask << nextHop << interface << prefixToUse); if (nextHop == Ipv6Address::GetZero()) { AddNetworkRouteTo(dst, mask, interface); @@ -901,7 +900,7 @@ Ipv6StaticRouting::NotifyRemoveRoute(Ipv6Address dst, NS_LOG_FUNCTION(this << dst << mask << nextHop << interface); if (dst != Ipv6Address::GetZero()) { - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end();) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end();) { Ipv6RoutingTableEntry* rtentry = j->first; Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix(); diff --git a/src/internet/model/ipv6-static-routing.h b/src/internet/model/ipv6-static-routing.h index f1a3273a2..bac08249e 100644 --- a/src/internet/model/ipv6-static-routing.h +++ b/src/internet/model/ipv6-static-routing.h @@ -20,10 +20,11 @@ #ifndef IPV6_STATIC_ROUTING_H #define IPV6_STATIC_ROUTING_H +#include "ipv6-header.h" +#include "ipv6-routing-protocol.h" +#include "ipv6.h" + #include "ns3/ipv6-address.h" -#include "ns3/ipv6-header.h" -#include "ns3/ipv6-routing-protocol.h" -#include "ns3/ipv6.h" #include "ns3/ptr.h" #include diff --git a/src/internet/model/ndisc-cache.cc b/src/internet/model/ndisc-cache.cc index 935eacda9..3f9b97095 100644 --- a/src/internet/model/ndisc-cache.cc +++ b/src/internet/model/ndisc-cache.cc @@ -118,7 +118,7 @@ NdiscCache::LookupInverse(Address dst) NS_LOG_FUNCTION(this << dst); std::list entryList; - for (CacheI i = m_ndCache.begin(); i != m_ndCache.end(); i++) + for (auto i = m_ndCache.begin(); i != m_ndCache.end(); i++) { NdiscCache::Entry* entry = (*i).second; if (entry->GetMacAddress() == dst) @@ -136,7 +136,7 @@ NdiscCache::Add(Ipv6Address to) NS_LOG_FUNCTION(this << to); NS_ASSERT(m_ndCache.find(to) == m_ndCache.end()); - NdiscCache::Entry* entry = new NdiscCache::Entry(this); + auto entry = new NdiscCache::Entry(this); entry->SetIpv6Address(to); m_ndCache[to] = entry; return entry; @@ -147,7 +147,7 @@ NdiscCache::Remove(NdiscCache::Entry* entry) { NS_LOG_FUNCTION(this << entry); - for (CacheI i = m_ndCache.begin(); i != m_ndCache.end(); i++) + for (auto i = m_ndCache.begin(); i != m_ndCache.end(); i++) { if ((*i).second == entry) { @@ -164,7 +164,7 @@ NdiscCache::Flush() { NS_LOG_FUNCTION(this); - for (CacheI i = m_ndCache.begin(); i != m_ndCache.end(); i++) + for (auto i = m_ndCache.begin(); i != m_ndCache.end(); i++) { delete (*i).second; /* delete the pointer NdiscCache::Entry */ } @@ -192,7 +192,7 @@ NdiscCache::PrintNdiscCache(Ptr stream) NS_LOG_FUNCTION(this << stream); std::ostream* os = stream->GetStream(); - for (CacheI i = m_ndCache.begin(); i != m_ndCache.end(); i++) + for (auto i = m_ndCache.begin(); i != m_ndCache.end(); i++) { *os << i->first << " dev "; std::string found = Names::FindName(m_device); @@ -717,7 +717,7 @@ void NdiscCache::RemoveAutoGeneratedEntries() { NS_LOG_FUNCTION(this); - for (CacheI i = m_ndCache.begin(); i != m_ndCache.end();) + for (auto i = m_ndCache.begin(); i != m_ndCache.end();) { if (i->second->IsAutoGenerated()) { diff --git a/src/internet/model/rip-header.cc b/src/internet/model/rip-header.cc index 2833fb111..766412e86 100644 --- a/src/internet/model/rip-header.cc +++ b/src/internet/model/rip-header.cc @@ -197,8 +197,7 @@ void RipHeader::Print(std::ostream& os) const { os << "command " << int(m_command); - for (std::list::const_iterator iter = m_rteList.begin(); iter != m_rteList.end(); - iter++) + for (auto iter = m_rteList.begin(); iter != m_rteList.end(); iter++) { os << " | "; iter->Print(os); @@ -221,8 +220,7 @@ RipHeader::Serialize(Buffer::Iterator start) const i.WriteU8(2); i.WriteU16(0); - for (std::list::const_iterator iter = m_rteList.begin(); iter != m_rteList.end(); - iter++) + for (auto iter = m_rteList.begin(); iter != m_rteList.end(); iter++) { iter->Serialize(i); i.Next(iter->GetSerializedSize()); diff --git a/src/internet/model/rip-header.h b/src/internet/model/rip-header.h index d876bac96..7a6f75959 100644 --- a/src/internet/model/rip-header.h +++ b/src/internet/model/rip-header.h @@ -20,9 +20,10 @@ #ifndef RIP_HEADER_H #define RIP_HEADER_H +#include "ipv4-header.h" + #include "ns3/header.h" #include "ns3/ipv4-address.h" -#include "ns3/ipv4-header.h" #include "ns3/packet.h" #include diff --git a/src/internet/model/rip.cc b/src/internet/model/rip.cc index f51a36f28..f6f155764 100644 --- a/src/internet/model/rip.cc +++ b/src/internet/model/rip.cc @@ -346,7 +346,7 @@ Rip::NotifyInterfaceUp(uint32_t i) } bool sendSocketFound = false; - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { if (iter->second == i) { @@ -406,7 +406,7 @@ Rip::NotifyInterfaceDown(uint32_t interface) NS_LOG_FUNCTION(this << interface); /* remove all routes that are going through this interface */ - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first->GetInterface() == interface) { @@ -414,7 +414,7 @@ Rip::NotifyInterfaceDown(uint32_t interface) } } - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { NS_LOG_INFO("Checking socket for interface " << interface); if (iter->second == interface) @@ -478,7 +478,7 @@ Rip::NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address) // Remove all routes that are going through this interface // which reference this network - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first->GetInterface() == interface && it->first->IsNetwork() && it->first->GetDestNetwork() == networkAddress && @@ -536,7 +536,7 @@ Rip::PrintRoutingTable(Ptr stream, Time::Unit unit) const { *os << "Destination Gateway Genmask Flags Metric Ref Use Iface" << std::endl; - for (RoutesCI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { RipRoutingTableEntry* route = it->first; RipRoutingTableEntry::Status_e status = route->GetRouteStatus(); @@ -592,7 +592,7 @@ Rip::DoDispose() { NS_LOG_FUNCTION(this); - for (RoutesI j = m_routes.begin(); j != m_routes.end(); j = m_routes.erase(j)) + for (auto j = m_routes.begin(); j != m_routes.end(); j = m_routes.erase(j)) { delete j->first; } @@ -603,7 +603,7 @@ Rip::DoDispose() m_nextTriggeredUpdate = EventId(); m_nextUnsolicitedUpdate = EventId(); - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { iter->first->Close(); } @@ -639,7 +639,7 @@ Rip::Lookup(Ipv4Address dst, bool setSource, Ptr interface) return rtentry; } - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { RipRoutingTableEntry* j = it->first; @@ -708,8 +708,7 @@ Rip::AddNetworkRouteTo(Ipv4Address network, { NS_LOG_FUNCTION(this << network << networkPrefix << nextHop << interface); - RipRoutingTableEntry* route = - new RipRoutingTableEntry(network, networkPrefix, nextHop, interface); + auto route = new RipRoutingTableEntry(network, networkPrefix, nextHop, interface); route->SetRouteMetric(1); route->SetRouteStatus(RipRoutingTableEntry::RIP_VALID); route->SetRouteChanged(true); @@ -722,7 +721,7 @@ Rip::AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkPrefix, uint32_t int { NS_LOG_FUNCTION(this << network << networkPrefix << interface); - RipRoutingTableEntry* route = new RipRoutingTableEntry(network, networkPrefix, interface); + auto route = new RipRoutingTableEntry(network, networkPrefix, interface); route->SetRouteMetric(1); route->SetRouteStatus(RipRoutingTableEntry::RIP_VALID); route->SetRouteChanged(true); @@ -735,7 +734,7 @@ Rip::InvalidateRoute(RipRoutingTableEntry* route) { NS_LOG_FUNCTION(this << *route); - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first == route) { @@ -759,7 +758,7 @@ Rip::DeleteRoute(RipRoutingTableEntry* route) { NS_LOG_FUNCTION(this << *route); - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first == route) { @@ -869,8 +868,7 @@ Rip::HandleRequests(RipHeader requestHdr, // we use one of the sending sockets, as they're bound to the right interface // and the local address might be used on different interfaces. Ptr sendingSocket; - for (SocketListI iter = m_unicastSocketList.begin(); - iter != m_unicastSocketList.end(); + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { if (iter->second == incomingInterface) @@ -903,7 +901,7 @@ Rip::HandleRequests(RipHeader requestHdr, RipHeader hdr; hdr.SetCommand(RipHeader::RESPONSE); - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { bool splitHorizoning = (rtIter->first->GetInterface() == incomingInterface); @@ -976,10 +974,10 @@ Rip::HandleRequests(RipHeader requestHdr, RipHeader hdr; hdr.SetCommand(RipHeader::RESPONSE); - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { bool found = false; - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { Ipv4InterfaceAddress rtDestAddr = Ipv4InterfaceAddress(rtIter->first->GetDestNetwork(), @@ -1033,7 +1031,7 @@ Rip::HandleResponses(RipHeader hdr, std::list rtes = hdr.GetRteList(); // validate the RTEs before processing - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { if (iter->GetRouteMetric() == 0 || iter->GetRouteMetric() > m_linkDown) { @@ -1051,7 +1049,7 @@ Rip::HandleResponses(RipHeader hdr, bool changed = false; - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { Ipv4Mask rtePrefixMask = iter->GetSubnetMask(); Ipv4Address rteAddr = iter->GetPrefix().CombineMask(rtePrefixMask); @@ -1081,10 +1079,10 @@ Rip::HandleResponses(RipHeader hdr, { if (senderAddress != it->first->GetGateway()) { - RipRoutingTableEntry* route = new RipRoutingTableEntry(rteAddr, - rtePrefixMask, - senderAddress, - incomingInterface); + auto route = new RipRoutingTableEntry(rteAddr, + rtePrefixMask, + senderAddress, + incomingInterface); delete it->first; it->first = route; } @@ -1111,11 +1109,10 @@ Rip::HandleResponses(RipHeader hdr, { if (Simulator::GetDelayLeft(it->second) < m_timeoutDelay / 2) { - RipRoutingTableEntry* route = - new RipRoutingTableEntry(rteAddr, - rtePrefixMask, - senderAddress, - incomingInterface); + auto route = new RipRoutingTableEntry(rteAddr, + rtePrefixMask, + senderAddress, + incomingInterface); route->SetRouteMetric(rteMetric); route->SetRouteStatus(RipRoutingTableEntry::RIP_VALID); route->SetRouteTag(iter->GetRouteTag()); @@ -1159,7 +1156,7 @@ Rip::HandleResponses(RipHeader hdr, { NS_LOG_LOGIC("Received a RTE with new route, adding."); - RipRoutingTableEntry* route = + auto route = new RipRoutingTableEntry(rteAddr, rtePrefixMask, senderAddress, incomingInterface); route->SetRouteMetric(rteMetric); route->SetRouteStatus(RipRoutingTableEntry::RIP_VALID); @@ -1183,7 +1180,7 @@ Rip::DoSendRouteUpdate(bool periodic) { NS_LOG_FUNCTION(this << (periodic ? " periodic" : " triggered")); - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { uint32_t interface = iter->second; @@ -1202,7 +1199,7 @@ Rip::DoSendRouteUpdate(bool periodic) RipHeader hdr; hdr.SetCommand(RipHeader::RESPONSE); - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { bool splitHorizoning = (rtIter->first->GetInterface() == interface); Ipv4InterfaceAddress rtDestAddr = @@ -1270,7 +1267,7 @@ Rip::DoSendRouteUpdate(bool periodic) } } } - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { rtIter->first->SetRouteChanged(false); } @@ -1344,7 +1341,7 @@ Rip::GetInterfaceMetric(uint32_t interface) const { NS_LOG_FUNCTION(this << interface); - std::map::const_iterator iter = m_interfaceMetrics.find(interface); + auto iter = m_interfaceMetrics.find(interface); if (iter != m_interfaceMetrics.end()) { return iter->second; @@ -1385,7 +1382,7 @@ Rip::SendRouteRequest() hdr.AddRte(rte); p->AddHeader(hdr); - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { uint32_t interface = iter->second; diff --git a/src/internet/model/rip.h b/src/internet/model/rip.h index 850c3d8c9..ba3908944 100644 --- a/src/internet/model/rip.h +++ b/src/internet/model/rip.h @@ -20,13 +20,14 @@ #ifndef RIP_H #define RIP_H +#include "ipv4-interface.h" +#include "ipv4-l3-protocol.h" +#include "ipv4-routing-protocol.h" +#include "ipv4-routing-table-entry.h" +#include "rip-header.h" + #include "ns3/inet-socket-address.h" -#include "ns3/ipv4-interface.h" -#include "ns3/ipv4-l3-protocol.h" -#include "ns3/ipv4-routing-protocol.h" -#include "ns3/ipv4-routing-table-entry.h" #include "ns3/random-variable-stream.h" -#include "ns3/rip-header.h" #include diff --git a/src/internet/model/ripng-header.cc b/src/internet/model/ripng-header.cc index 854525b46..3deb38d71 100644 --- a/src/internet/model/ripng-header.cc +++ b/src/internet/model/ripng-header.cc @@ -179,8 +179,7 @@ void RipNgHeader::Print(std::ostream& os) const { os << "command " << int(m_command); - for (std::list::const_iterator iter = m_rteList.begin(); iter != m_rteList.end(); - iter++) + for (auto iter = m_rteList.begin(); iter != m_rteList.end(); iter++) { os << " | "; iter->Print(os); @@ -203,8 +202,7 @@ RipNgHeader::Serialize(Buffer::Iterator start) const i.WriteU8(1); i.WriteU16(0); - for (std::list::const_iterator iter = m_rteList.begin(); iter != m_rteList.end(); - iter++) + for (auto iter = m_rteList.begin(); iter != m_rteList.end(); iter++) { iter->Serialize(i); i.Next(iter->GetSerializedSize()); diff --git a/src/internet/model/ripng-header.h b/src/internet/model/ripng-header.h index b342db968..1351f6b2b 100644 --- a/src/internet/model/ripng-header.h +++ b/src/internet/model/ripng-header.h @@ -20,9 +20,10 @@ #ifndef RIPNG_HEADER_H #define RIPNG_HEADER_H +#include "ipv6-header.h" + #include "ns3/header.h" #include "ns3/ipv6-address.h" -#include "ns3/ipv6-header.h" #include "ns3/packet.h" #include diff --git a/src/internet/model/ripng.cc b/src/internet/model/ripng.cc index 6fae1a8fe..1bff980ae 100644 --- a/src/internet/model/ripng.cc +++ b/src/internet/model/ripng.cc @@ -313,7 +313,7 @@ RipNg::NotifyInterfaceUp(uint32_t i) } bool sendSocketFound = false; - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { if (iter->second == i) { @@ -374,7 +374,7 @@ RipNg::NotifyInterfaceDown(uint32_t interface) NS_LOG_FUNCTION(this << interface); /* remove all routes that are going through this interface */ - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first->GetInterface() == interface) { @@ -382,7 +382,7 @@ RipNg::NotifyInterfaceDown(uint32_t interface) } } - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { NS_LOG_INFO("Checking socket for interface " << interface); if (iter->second == interface) @@ -446,7 +446,7 @@ RipNg::NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address) // Remove all routes that are going through this interface // which reference this network - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first->GetInterface() == interface && it->first->IsNetwork() && it->first->GetDestNetwork() == networkAddress && @@ -522,7 +522,7 @@ RipNg::PrintRoutingTable(Ptr stream, Time::Unit unit) const { *os << "Destination Next Hop Flag Met Ref Use If" << std::endl; - for (RoutesCI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { RipNgRoutingTableEntry* route = it->first; RipNgRoutingTableEntry::Status_e status = route->GetRouteStatus(); @@ -576,7 +576,7 @@ RipNg::DoDispose() { NS_LOG_FUNCTION(this); - for (RoutesI j = m_routes.begin(); j != m_routes.end(); j = m_routes.erase(j)) + for (auto j = m_routes.begin(); j != m_routes.end(); j = m_routes.erase(j)) { delete j->first; } @@ -587,7 +587,7 @@ RipNg::DoDispose() m_nextTriggeredUpdate = EventId(); m_nextUnsolicitedUpdate = EventId(); - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { iter->first->Close(); } @@ -624,7 +624,7 @@ RipNg::Lookup(Ipv6Address dst, bool setSource, Ptr interface) return rtentry; } - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { RipNgRoutingTableEntry* j = it->first; @@ -705,7 +705,7 @@ RipNg::AddNetworkRouteTo(Ipv6Address network, NS_LOG_WARN("Ripng::AddNetworkRouteTo - Next hop should be link-local"); } - RipNgRoutingTableEntry* route = + auto route = new RipNgRoutingTableEntry(network, networkPrefix, nextHop, interface, prefixToUse); route->SetRouteMetric(1); route->SetRouteStatus(RipNgRoutingTableEntry::RIPNG_VALID); @@ -719,7 +719,7 @@ RipNg::AddNetworkRouteTo(Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t { NS_LOG_FUNCTION(this << network << networkPrefix << interface); - RipNgRoutingTableEntry* route = new RipNgRoutingTableEntry(network, networkPrefix, interface); + auto route = new RipNgRoutingTableEntry(network, networkPrefix, interface); route->SetRouteMetric(1); route->SetRouteStatus(RipNgRoutingTableEntry::RIPNG_VALID); route->SetRouteChanged(true); @@ -732,7 +732,7 @@ RipNg::InvalidateRoute(RipNgRoutingTableEntry* route) { NS_LOG_FUNCTION(this << *route); - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first == route) { @@ -756,7 +756,7 @@ RipNg::DeleteRoute(RipNgRoutingTableEntry* route) { NS_LOG_FUNCTION(this << *route); - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first == route) { @@ -851,8 +851,7 @@ RipNg::HandleRequests(RipNgHeader requestHdr, // we use one of the sending sockets, as they're bound to the right interface // and the local address might be used on different interfaces. Ptr sendingSocket; - for (SocketListI iter = m_unicastSocketList.begin(); - iter != m_unicastSocketList.end(); + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { if (iter->second == incomingInterface) @@ -878,7 +877,7 @@ RipNg::HandleRequests(RipNgHeader requestHdr, RipNgHeader hdr; hdr.SetCommand(RipNgHeader::RESPONSE); - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { bool splitHorizoning = (rtIter->first->GetInterface() == incomingInterface); @@ -940,8 +939,7 @@ RipNg::HandleRequests(RipNgHeader requestHdr, Ptr sendingSocket; if (senderAddress.IsLinkLocal()) { - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); - iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { if (iter->second == incomingInterface) { @@ -963,10 +961,10 @@ RipNg::HandleRequests(RipNgHeader requestHdr, RipNgHeader hdr; hdr.SetCommand(RipNgHeader::RESPONSE); - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { bool found = false; - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { Ipv6InterfaceAddress rtDestAddr = Ipv6InterfaceAddress(rtIter->first->GetDestNetwork(), @@ -1032,7 +1030,7 @@ RipNg::HandleResponses(RipNgHeader hdr, std::list rtes = hdr.GetRteList(); // validate the RTEs before processing - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { if (iter->GetRouteMetric() == 0 || iter->GetRouteMetric() > m_linkDown) { @@ -1056,7 +1054,7 @@ RipNg::HandleResponses(RipNgHeader hdr, bool changed = false; - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { Ipv6Prefix rtePrefix = Ipv6Prefix(iter->GetPrefixLen()); Ipv6Address rteAddr = iter->GetPrefix().CombinePrefix(rtePrefix); @@ -1085,12 +1083,11 @@ RipNg::HandleResponses(RipNgHeader hdr, { if (senderAddress != it->first->GetGateway()) { - RipNgRoutingTableEntry* route = - new RipNgRoutingTableEntry(rteAddr, - rtePrefix, - senderAddress, - incomingInterface, - Ipv6Address::GetAny()); + auto route = new RipNgRoutingTableEntry(rteAddr, + rtePrefix, + senderAddress, + incomingInterface, + Ipv6Address::GetAny()); delete it->first; it->first = route; } @@ -1119,12 +1116,11 @@ RipNg::HandleResponses(RipNgHeader hdr, { if (Simulator::GetDelayLeft(it->second) < m_timeoutDelay / 2) { - RipNgRoutingTableEntry* route = - new RipNgRoutingTableEntry(rteAddr, - rtePrefix, - senderAddress, - incomingInterface, - Ipv6Address::GetAny()); + auto route = new RipNgRoutingTableEntry(rteAddr, + rtePrefix, + senderAddress, + incomingInterface, + Ipv6Address::GetAny()); route->SetRouteMetric(rteMetric); route->SetRouteStatus(RipNgRoutingTableEntry::RIPNG_VALID); route->SetRouteTag(iter->GetRouteTag()); @@ -1168,11 +1164,11 @@ RipNg::HandleResponses(RipNgHeader hdr, { NS_LOG_LOGIC("Received a RTE with new route, adding."); - RipNgRoutingTableEntry* route = new RipNgRoutingTableEntry(rteAddr, - rtePrefix, - senderAddress, - incomingInterface, - Ipv6Address::GetAny()); + auto route = new RipNgRoutingTableEntry(rteAddr, + rtePrefix, + senderAddress, + incomingInterface, + Ipv6Address::GetAny()); route->SetRouteMetric(rteMetric); route->SetRouteStatus(RipNgRoutingTableEntry::RIPNG_VALID); route->SetRouteChanged(true); @@ -1195,7 +1191,7 @@ RipNg::DoSendRouteUpdate(bool periodic) { NS_LOG_FUNCTION(this << (periodic ? " periodic" : " triggered")); - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { uint32_t interface = iter->second; @@ -1215,7 +1211,7 @@ RipNg::DoSendRouteUpdate(bool periodic) RipNgHeader hdr; hdr.SetCommand(RipNgHeader::RESPONSE); - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { bool splitHorizoning = (rtIter->first->GetInterface() == interface); Ipv6InterfaceAddress rtDestAddr = @@ -1271,7 +1267,7 @@ RipNg::DoSendRouteUpdate(bool periodic) } } } - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { rtIter->first->SetRouteChanged(false); } @@ -1345,7 +1341,7 @@ RipNg::GetInterfaceMetric(uint32_t interface) const { NS_LOG_FUNCTION(this << interface); - std::map::const_iterator iter = m_interfaceMetrics.find(interface); + auto iter = m_interfaceMetrics.find(interface); if (iter != m_interfaceMetrics.end()) { return iter->second; @@ -1386,7 +1382,7 @@ RipNg::SendRouteRequest() hdr.AddRte(rte); p->AddHeader(hdr); - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { uint32_t interface = iter->second; diff --git a/src/internet/model/ripng.h b/src/internet/model/ripng.h index 08802a23b..da1365709 100644 --- a/src/internet/model/ripng.h +++ b/src/internet/model/ripng.h @@ -20,13 +20,14 @@ #ifndef RIPNG_H #define RIPNG_H +#include "ipv6-interface.h" +#include "ipv6-l3-protocol.h" +#include "ipv6-routing-protocol.h" +#include "ipv6-routing-table-entry.h" +#include "ripng-header.h" + #include "ns3/inet6-socket-address.h" -#include "ns3/ipv6-interface.h" -#include "ns3/ipv6-l3-protocol.h" -#include "ns3/ipv6-routing-protocol.h" -#include "ns3/ipv6-routing-table-entry.h" #include "ns3/random-variable-stream.h" -#include "ns3/ripng-header.h" #include diff --git a/src/internet/model/tcp-bbr.h b/src/internet/model/tcp-bbr.h index 3143287b0..0955bd8fd 100644 --- a/src/internet/model/tcp-bbr.h +++ b/src/internet/model/tcp-bbr.h @@ -22,11 +22,12 @@ #ifndef TCPBBR_H #define TCPBBR_H +#include "tcp-congestion-ops.h" +#include "windowed-filter.h" + #include "ns3/data-rate.h" #include "ns3/random-variable-stream.h" -#include "ns3/tcp-congestion-ops.h" #include "ns3/traced-value.h" -#include "ns3/windowed-filter.h" class TcpBbrCheckGainValuesTest; diff --git a/src/internet/model/tcp-bic.h b/src/internet/model/tcp-bic.h index 05ba90d15..87c8b0aa0 100644 --- a/src/internet/model/tcp-bic.h +++ b/src/internet/model/tcp-bic.h @@ -19,8 +19,8 @@ #ifndef TCPBIC_H #define TCPBIC_H -#include "ns3/tcp-congestion-ops.h" -#include "ns3/tcp-recovery-ops.h" +#include "tcp-congestion-ops.h" +#include "tcp-recovery-ops.h" class TcpBicIncrementTest; class TcpBicDecrementTest; diff --git a/src/internet/model/tcp-cubic.h b/src/internet/model/tcp-cubic.h index 8802df62e..c395b3888 100644 --- a/src/internet/model/tcp-cubic.h +++ b/src/internet/model/tcp-cubic.h @@ -19,8 +19,8 @@ #ifndef TCPCUBIC_H #define TCPCUBIC_H -#include "ns3/tcp-congestion-ops.h" -#include "ns3/tcp-socket-base.h" +#include "tcp-congestion-ops.h" +#include "tcp-socket-base.h" namespace ns3 { diff --git a/src/internet/model/tcp-dctcp.h b/src/internet/model/tcp-dctcp.h index dc25ea6a1..37ea0f870 100644 --- a/src/internet/model/tcp-dctcp.h +++ b/src/internet/model/tcp-dctcp.h @@ -21,8 +21,9 @@ #ifndef TCP_DCTCP_H #define TCP_DCTCP_H -#include "ns3/tcp-congestion-ops.h" -#include "ns3/tcp-linux-reno.h" +#include "tcp-congestion-ops.h" +#include "tcp-linux-reno.h" + #include "ns3/traced-callback.h" namespace ns3 diff --git a/src/internet/model/tcp-header.cc b/src/internet/model/tcp-header.cc index 3fa09ec19..bb782bf9d 100644 --- a/src/internet/model/tcp-header.cc +++ b/src/internet/model/tcp-header.cc @@ -35,25 +35,6 @@ NS_LOG_COMPONENT_DEFINE("TcpHeader"); NS_OBJECT_ENSURE_REGISTERED(TcpHeader); -TcpHeader::TcpHeader() - : m_sourcePort(0), - m_destinationPort(0), - m_sequenceNumber(0), - m_ackNumber(0), - m_length(5), - m_flags(0), - m_windowSize(0xffff), - m_urgentPointer(0), - m_calcChecksum(false), - m_goodChecksum(true), - m_optionsLen(0) -{ -} - -TcpHeader::~TcpHeader() -{ -} - std::string TcpHeader::FlagsToString(uint8_t flags, const std::string& delimiter) { @@ -63,7 +44,7 @@ TcpHeader::FlagsToString(uint8_t flags, const std::string& delimiter) { if (flags & (1 << i)) { - if (flagsDescription.length() > 0) + if (!flagsDescription.empty()) { flagsDescription += delimiter; } @@ -286,9 +267,7 @@ TcpHeader::Print(std::ostream& os) const os << " Seq=" << m_sequenceNumber << " Ack=" << m_ackNumber << " Win=" << m_windowSize; - TcpOptionList::const_iterator op; - - for (op = m_options.begin(); op != m_options.end(); ++op) + for (auto op = m_options.begin(); op != m_options.end(); ++op) { os << " " << (*op)->GetInstanceTypeId().GetName() << "("; (*op)->Print(os); @@ -319,8 +298,8 @@ TcpHeader::Serialize(Buffer::Iterator start) const // This implementation does not presently try to align options on word // boundaries using NOP options uint32_t optionLen = 0; - TcpOptionList::const_iterator op; - for (op = m_options.begin(); op != m_options.end(); ++op) + + for (auto op = m_options.begin(); op != m_options.end(); ++op) { optionLen += (*op)->GetSerializedSize(); (*op)->Serialize(i); @@ -436,9 +415,8 @@ uint8_t TcpHeader::CalculateHeaderLength() const { uint32_t len = 20; - TcpOptionList::const_iterator i; - for (i = m_options.begin(); i != m_options.end(); ++i) + for (auto i = m_options.begin(); i != m_options.end(); ++i) { len += (*i)->GetSerializedSize(); } @@ -485,9 +463,7 @@ TcpHeader::GetOptionList() const Ptr TcpHeader::GetOption(uint8_t kind) const { - TcpOptionList::const_iterator i; - - for (i = m_options.begin(); i != m_options.end(); ++i) + for (auto i = m_options.begin(); i != m_options.end(); ++i) { if ((*i)->GetKind() == kind) { @@ -501,9 +477,7 @@ TcpHeader::GetOption(uint8_t kind) const bool TcpHeader::HasOption(uint8_t kind) const { - TcpOptionList::const_iterator i; - - for (i = m_options.begin(); i != m_options.end(); ++i) + for (auto i = m_options.begin(); i != m_options.end(); ++i) { if ((*i)->GetKind() == kind) { diff --git a/src/internet/model/tcp-header.h b/src/internet/model/tcp-header.h index 96c9aef04..fa2500c52 100644 --- a/src/internet/model/tcp-header.h +++ b/src/internet/model/tcp-header.h @@ -20,13 +20,14 @@ #ifndef TCP_HEADER_H #define TCP_HEADER_H +#include "tcp-option.h" +#include "tcp-socket-factory.h" + #include "ns3/buffer.h" #include "ns3/header.h" #include "ns3/ipv4-address.h" #include "ns3/ipv6-address.h" #include "ns3/sequence-number.h" -#include "ns3/tcp-option.h" -#include "ns3/tcp-socket-factory.h" #include @@ -45,9 +46,6 @@ namespace ns3 class TcpHeader : public Header { public: - TcpHeader(); - ~TcpHeader() override; - typedef std::list> TcpOptionList; //!< List of TcpOption /** @@ -331,25 +329,25 @@ class TcpHeader : public Header */ uint8_t CalculateHeaderLength() const; - uint16_t m_sourcePort; //!< Source port - uint16_t m_destinationPort; //!< Destination port - SequenceNumber32 m_sequenceNumber; //!< Sequence number - SequenceNumber32 m_ackNumber; //!< ACK number - uint8_t m_length; //!< Length (really a uint4_t) in words. - uint8_t m_flags; //!< Flags (really a uint6_t) - uint16_t m_windowSize; //!< Window size - uint16_t m_urgentPointer; //!< Urgent pointer + uint16_t m_sourcePort{0}; //!< Source port + uint16_t m_destinationPort{0}; //!< Destination port + SequenceNumber32 m_sequenceNumber{0}; //!< Sequence number + SequenceNumber32 m_ackNumber{0}; //!< ACK number + uint8_t m_length{5}; //!< Length (really a uint4_t) in words. + uint8_t m_flags{0}; //!< Flags (really a uint6_t) + uint16_t m_windowSize{0xffff}; //!< Window size + uint16_t m_urgentPointer{0}; //!< Urgent pointer Address m_source; //!< Source IP address Address m_destination; //!< Destination IP address - uint8_t m_protocol; //!< Protocol number + uint8_t m_protocol{6}; //!< Protocol number - bool m_calcChecksum; //!< Flag to calculate checksum - bool m_goodChecksum; //!< Flag to indicate that checksum is correct + bool m_calcChecksum{false}; //!< Flag to calculate checksum + bool m_goodChecksum{true}; //!< Flag to indicate that checksum is correct static const uint8_t m_maxOptionsLen = 40; //!< Maximum options length TcpOptionList m_options; //!< TcpOption present in the header - uint8_t m_optionsLen; //!< Tcp options length. + uint8_t m_optionsLen{0}; //!< Tcp options length. }; } // namespace ns3 diff --git a/src/internet/model/tcp-htcp.cc b/src/internet/model/tcp-htcp.cc index 488b1c96a..f6af49841 100644 --- a/src/internet/model/tcp-htcp.cc +++ b/src/internet/model/tcp-htcp.cc @@ -182,7 +182,7 @@ TcpHtcp::GetSsThresh(Ptr tcb, uint32_t bytesInFlight) UpdateAlpha(); uint32_t segWin = 2 * tcb->m_segmentSize; - uint32_t bFlight = static_cast(bytesInFlight * m_beta); + auto bFlight = static_cast(bytesInFlight * m_beta); uint32_t ssThresh = std::max(segWin, bFlight); m_minRtt = Time::Max(); m_maxRtt = Time::Min(); diff --git a/src/internet/model/tcp-hybla.cc b/src/internet/model/tcp-hybla.cc index 29f6f4f7a..8d50c710a 100644 --- a/src/internet/model/tcp-hybla.cc +++ b/src/internet/model/tcp-hybla.cc @@ -106,7 +106,7 @@ TcpHybla::SlowStart(Ptr tcb, uint32_t segmentsAcked) */ double increment = std::pow(2, m_rho) - 1.0; - uint32_t incr = static_cast(increment * tcb->m_segmentSize); + auto incr = static_cast(increment * tcb->m_segmentSize); NS_LOG_INFO("Slow start: inc=" << increment); tcb->m_cWnd = std::min(tcb->m_cWnd + incr, tcb->m_ssThresh); @@ -145,7 +145,7 @@ TcpHybla::CongestionAvoidance(Ptr tcb, uint32_t segmentsAcked) if (m_cWndCnt >= 1.0) { // double to int truncates every time. - uint32_t inc = static_cast(m_cWndCnt); + auto inc = static_cast(m_cWndCnt); m_cWndCnt -= inc; NS_ASSERT(m_cWndCnt >= 0.0); diff --git a/src/internet/model/tcp-ledbat.cc b/src/internet/model/tcp-ledbat.cc index 2bab9ba4f..03244c74c 100644 --- a/src/internet/model/tcp-ledbat.cc +++ b/src/internet/model/tcp-ledbat.cc @@ -288,7 +288,7 @@ TcpLedbat::UpdateBaseDelay(uint32_t owd) } else { - uint32_t last = static_cast(m_baseHistory.buffer.size() - 1); + auto last = static_cast(m_baseHistory.buffer.size() - 1); if (owd < m_baseHistory.buffer[last]) { m_baseHistory.buffer[last] = owd; diff --git a/src/internet/model/tcp-linux-reno.h b/src/internet/model/tcp-linux-reno.h index 3bf489d6e..792aea7d2 100644 --- a/src/internet/model/tcp-linux-reno.h +++ b/src/internet/model/tcp-linux-reno.h @@ -22,8 +22,8 @@ #ifndef TCPLINUXRENO_H #define TCPLINUXRENO_H -#include "ns3/tcp-congestion-ops.h" -#include "ns3/tcp-socket-state.h" +#include "tcp-congestion-ops.h" +#include "tcp-socket-state.h" namespace ns3 { diff --git a/src/internet/model/tcp-option-rfc793.h b/src/internet/model/tcp-option-rfc793.h index 1f746412c..67c990bd6 100644 --- a/src/internet/model/tcp-option-rfc793.h +++ b/src/internet/model/tcp-option-rfc793.h @@ -19,7 +19,7 @@ #ifndef TCPOPTIONRFC793_H #define TCPOPTIONRFC793_H -#include "ns3/tcp-option.h" +#include "tcp-option.h" namespace ns3 { diff --git a/src/internet/model/tcp-option-sack-permitted.h b/src/internet/model/tcp-option-sack-permitted.h index 6c359526c..28edd1217 100644 --- a/src/internet/model/tcp-option-sack-permitted.h +++ b/src/internet/model/tcp-option-sack-permitted.h @@ -25,7 +25,7 @@ #ifndef TCP_OPTION_SACK_PERMITTED_H #define TCP_OPTION_SACK_PERMITTED_H -#include "ns3/tcp-option.h" +#include "tcp-option.h" namespace ns3 { diff --git a/src/internet/model/tcp-option-sack.cc b/src/internet/model/tcp-option-sack.cc index f4bf62fb2..3a95ab718 100644 --- a/src/internet/model/tcp-option-sack.cc +++ b/src/internet/model/tcp-option-sack.cc @@ -62,7 +62,7 @@ void TcpOptionSack::Print(std::ostream& os) const { os << "blocks: " << GetNumSackBlocks() << ","; - for (SackList::const_iterator it = m_sackList.begin(); it != m_sackList.end(); ++it) + for (auto it = m_sackList.begin(); it != m_sackList.end(); ++it) { os << "[" << it->first << "," << it->second << "]"; } @@ -82,10 +82,10 @@ TcpOptionSack::Serialize(Buffer::Iterator start) const NS_LOG_FUNCTION(this); Buffer::Iterator i = start; i.WriteU8(GetKind()); // Kind - uint8_t length = static_cast(GetNumSackBlocks() * 8 + 2); + auto length = static_cast(GetNumSackBlocks() * 8 + 2); i.WriteU8(length); // Length - for (SackList::const_iterator it = m_sackList.begin(); it != m_sackList.end(); ++it) + for (auto it = m_sackList.begin(); it != m_sackList.end(); ++it) { SequenceNumber32 leftEdge = it->first; SequenceNumber32 rightEdge = it->second; @@ -112,8 +112,8 @@ TcpOptionSack::Deserialize(Buffer::Iterator start) uint8_t sackCount = (size - 2) / 8; while (sackCount) { - SequenceNumber32 leftEdge = SequenceNumber32(i.ReadNtohU32()); - SequenceNumber32 rightEdge = SequenceNumber32(i.ReadNtohU32()); + SequenceNumber32 leftEdge(i.ReadNtohU32()); + SequenceNumber32 rightEdge(i.ReadNtohU32()); SackBlock s(leftEdge, rightEdge); AddSackBlock(s); sackCount--; diff --git a/src/internet/model/tcp-option-sack.h b/src/internet/model/tcp-option-sack.h index 6ebdea747..93b6f7769 100644 --- a/src/internet/model/tcp-option-sack.h +++ b/src/internet/model/tcp-option-sack.h @@ -25,8 +25,9 @@ #ifndef TCP_OPTION_SACK_H #define TCP_OPTION_SACK_H +#include "tcp-option.h" + #include "ns3/sequence-number.h" -#include "ns3/tcp-option.h" namespace ns3 { diff --git a/src/internet/model/tcp-option-ts.h b/src/internet/model/tcp-option-ts.h index 68c224950..59c4ebdaf 100644 --- a/src/internet/model/tcp-option-ts.h +++ b/src/internet/model/tcp-option-ts.h @@ -20,7 +20,8 @@ #ifndef TCP_OPTION_TS_H #define TCP_OPTION_TS_H -#include "ns3/tcp-option.h" +#include "tcp-option.h" + #include "ns3/timer.h" namespace ns3 diff --git a/src/internet/model/tcp-option-winscale.h b/src/internet/model/tcp-option-winscale.h index 675974394..b8231beea 100644 --- a/src/internet/model/tcp-option-winscale.h +++ b/src/internet/model/tcp-option-winscale.h @@ -21,7 +21,7 @@ #ifndef TCP_OPTION_WINSCALE_H #define TCP_OPTION_WINSCALE_H -#include "ns3/tcp-option.h" +#include "tcp-option.h" namespace ns3 { diff --git a/src/internet/model/tcp-prr-recovery.h b/src/internet/model/tcp-prr-recovery.h index 86ed144f0..ba3a6a200 100644 --- a/src/internet/model/tcp-prr-recovery.h +++ b/src/internet/model/tcp-prr-recovery.h @@ -22,7 +22,7 @@ #ifndef TCP_PRR_RECOVERY_H #define TCP_PRR_RECOVERY_H -#include "ns3/tcp-recovery-ops.h" +#include "tcp-recovery-ops.h" namespace ns3 { diff --git a/src/internet/model/tcp-rate-ops.h b/src/internet/model/tcp-rate-ops.h index 69cb5407d..102dc520b 100644 --- a/src/internet/model/tcp-rate-ops.h +++ b/src/internet/model/tcp-rate-ops.h @@ -18,9 +18,10 @@ #ifndef TCP_RATE_OPS_H #define TCP_RATE_OPS_H +#include "tcp-tx-item.h" + #include "ns3/data-rate.h" #include "ns3/object.h" -#include "ns3/tcp-tx-item.h" #include "ns3/traced-callback.h" #include "ns3/traced-value.h" diff --git a/src/internet/model/tcp-rx-buffer.cc b/src/internet/model/tcp-rx-buffer.cc index 6bb9c6068..dda76e070 100644 --- a/src/internet/model/tcp-rx-buffer.cc +++ b/src/internet/model/tcp-rx-buffer.cc @@ -172,7 +172,7 @@ TcpRxBuffer::Add(Ptr p, const TcpHeader& tcph) } } // Remove overlapped bytes from packet - BufIterator i = m_data.begin(); + auto i = m_data.begin(); while (i != m_data.end() && i->first <= tailSeq) { SequenceNumber32 lastByteSeq = i->first + SequenceNumber32(i->second->GetSize()); @@ -204,7 +204,7 @@ TcpRxBuffer::Add(Ptr p, const TcpHeader& tcph) else { uint32_t start = static_cast(headSeq - tcph.GetSequenceNumber()); - uint32_t length = static_cast(tailSeq - headSeq); + auto length = static_cast(tailSeq - headSeq); p = p->CreateFragment(start, length); NS_ASSERT(length == p->GetSize()); } @@ -292,7 +292,7 @@ TcpRxBuffer::UpdateSackList(const SequenceNumber32& head, const SequenceNumber32 // We have inserted the block at the beginning of the list. Now, we should // check if any existing blocks overlap with that. bool updated = false; - TcpOptionSack::SackList::iterator it = m_sackList.begin(); + auto it = m_sackList.begin(); TcpOptionSack::SackBlock begin = *it; TcpOptionSack::SackBlock merged; ++it; @@ -353,8 +353,7 @@ TcpRxBuffer::ClearSackList(const SequenceNumber32& seq) { NS_LOG_FUNCTION(this << seq); - TcpOptionSack::SackList::iterator it; - for (it = m_sackList.begin(); it != m_sackList.end();) + for (auto it = m_sackList.begin(); it != m_sackList.end();) { TcpOptionSack::SackBlock block = *it; NS_ASSERT(block.first < block.second); diff --git a/src/internet/model/tcp-rx-buffer.h b/src/internet/model/tcp-rx-buffer.h index c8aee7e09..7dc32b03c 100644 --- a/src/internet/model/tcp-rx-buffer.h +++ b/src/internet/model/tcp-rx-buffer.h @@ -20,10 +20,11 @@ #ifndef TCP_RX_BUFFER_H #define TCP_RX_BUFFER_H +#include "tcp-header.h" +#include "tcp-option-sack.h" + #include "ns3/ptr.h" #include "ns3/sequence-number.h" -#include "ns3/tcp-header.h" -#include "ns3/tcp-option-sack.h" #include "ns3/trace-source-accessor.h" #include "ns3/traced-value.h" diff --git a/src/internet/model/tcp-socket-base.cc b/src/internet/model/tcp-socket-base.cc index 49cba7a6e..c305f278d 100644 --- a/src/internet/model/tcp-socket-base.cc +++ b/src/internet/model/tcp-socket-base.cc @@ -1851,7 +1851,7 @@ TcpSocketBase::ReceivedAck(Ptr packet, const TcpHeader& tcpHeader) m_txBuffer->DiscardUpTo(ackNumber, MakeCallback(&TcpRateOps::SkbDelivered, m_rateOps)); - uint32_t currentDelivered = + auto currentDelivered = static_cast(m_rateOps->GetConnectionRate().m_delivered - previousDelivered); m_tcb->m_lastAckedSackedBytes = currentDelivered; @@ -3272,7 +3272,7 @@ TcpSocketBase::UpdateRttHistory(const SequenceNumber32& seq, uint32_t sz, bool i } else { // This is a retransmit, find in list and mark as re-tx - for (std::deque::iterator i = m_history.begin(); i != m_history.end(); ++i) + for (auto i = m_history.begin(); i != m_history.end(); ++i) { if ((seq >= i->seq) && (seq < (i->seq + SequenceNumber32(i->count)))) { // Found it @@ -3291,13 +3291,13 @@ TcpSocketBase::SendPendingData(bool withAck) NS_LOG_FUNCTION(this << withAck); if (m_txBuffer->Size() == 0) { - return false; // Nothing to send + return 0; // Nothing to send } if (m_endPoint == nullptr && m_endPoint6 == nullptr) { NS_LOG_INFO( "TcpSocketBase::SendPendingData: No endpoint; m_shutdownSend=" << m_shutdownSend); - return false; // Is this the right way to handle this condition? + return 0; // Is this the right way to handle this condition? } uint32_t nPacketsSent = 0; @@ -3370,7 +3370,7 @@ TcpSocketBase::SendPendingData(bool withAck) uint32_t s = std::min(availableWindow, m_tcb->m_segmentSize); // NextSeg () may have further constrained the segment size - uint32_t maxSizeToSend = static_cast(nextHigh - next); + auto maxSizeToSend = static_cast(nextHigh - next); s = std::min(s, maxSizeToSend); // (C.2) If any of the data octets sent in (C.1) are below HighData, @@ -4317,8 +4317,8 @@ TcpSocketBase::AddOptionSack(TcpHeader& header) // Append the allowed number of SACK blocks Ptr option = CreateObject(); - TcpOptionSack::SackList::iterator i; - for (i = sackList.begin(); allowedSackBlocks > 0 && i != sackList.end(); ++i) + + for (auto i = sackList.begin(); allowedSackBlocks > 0 && i != sackList.end(); ++i) { option->AddSackBlock(*i); allowedSackBlocks--; diff --git a/src/internet/model/tcp-socket-base.h b/src/internet/model/tcp-socket-base.h index a0efecb19..1f0a3afc0 100644 --- a/src/internet/model/tcp-socket-base.h +++ b/src/internet/model/tcp-socket-base.h @@ -20,13 +20,14 @@ #ifndef TCP_SOCKET_BASE_H #define TCP_SOCKET_BASE_H +#include "ipv4-header.h" +#include "ipv6-header.h" +#include "tcp-socket-state.h" +#include "tcp-socket.h" + #include "ns3/data-rate.h" -#include "ns3/ipv4-header.h" -#include "ns3/ipv6-header.h" #include "ns3/node.h" #include "ns3/sequence-number.h" -#include "ns3/tcp-socket-state.h" -#include "ns3/tcp-socket.h" #include "ns3/timer.h" #include "ns3/traced-value.h" diff --git a/src/internet/model/tcp-socket-factory-impl.h b/src/internet/model/tcp-socket-factory-impl.h index fd55659e2..766cecf04 100644 --- a/src/internet/model/tcp-socket-factory-impl.h +++ b/src/internet/model/tcp-socket-factory-impl.h @@ -19,8 +19,9 @@ #ifndef TCP_SOCKET_FACTORY_IMPL_H #define TCP_SOCKET_FACTORY_IMPL_H +#include "tcp-socket-factory.h" + #include "ns3/ptr.h" -#include "ns3/tcp-socket-factory.h" namespace ns3 { diff --git a/src/internet/model/tcp-tx-buffer.cc b/src/internet/model/tcp-tx-buffer.cc index 105833b76..99ff8af00 100644 --- a/src/internet/model/tcp-tx-buffer.cc +++ b/src/internet/model/tcp-tx-buffer.cc @@ -68,16 +68,14 @@ TcpTxBuffer::TcpTxBuffer(uint32_t n) TcpTxBuffer::~TcpTxBuffer() { - PacketList::iterator it; - - for (it = m_sentList.begin(); it != m_sentList.end(); ++it) + for (auto it = m_sentList.begin(); it != m_sentList.end(); ++it) { TcpTxItem* item = *it; m_sentSize -= item->m_packet->GetSize(); delete item; } - for (it = m_appList.begin(); it != m_appList.end(); ++it) + for (auto it = m_appList.begin(); it != m_appList.end(); ++it) { TcpTxItem* item = *it; m_size -= item->m_packet->GetSize(); @@ -189,7 +187,7 @@ TcpTxBuffer::Add(Ptr p) { if (p->GetSize() > 0) { - TcpTxItem* item = new TcpTxItem(); + auto item = new TcpTxItem(); item->m_packet = p->Copy(); m_appList.insert(m_appList.end(), item); m_size += p->GetSize(); @@ -437,7 +435,7 @@ TcpTxBuffer::GetPacketFromList(PacketList& list, Ptr currentPacket = nullptr; TcpTxItem* currentItem = nullptr; TcpTxItem* outItem = nullptr; - PacketList::iterator it = list.begin(); + auto it = list.begin(); SequenceNumber32 beginOfCurrentPacket = listStartFrom; while (it != list.end()) @@ -469,7 +467,7 @@ TcpTxBuffer::GetPacketFromList(PacketList& list, NS_LOG_INFO("we are at " << beginOfCurrentPacket << " searching for " << seq << " and now we recurse because packet ends at " << beginOfCurrentPacket + currentPacket->GetSize()); - TcpTxItem* firstPart = new TcpTxItem(); + auto firstPart = new TcpTxItem(); SplitItems(firstPart, currentItem, seq - beginOfCurrentPacket); // insert firstPart before currentItem @@ -535,7 +533,7 @@ TcpTxBuffer::GetPacketFromList(PacketList& list, { // the end is inside the current packet, but it isn't exactly // the packet end. Just fragment, fix the list, and return. - TcpTxItem* firstPart = new TcpTxItem(); + auto firstPart = new TcpTxItem(); SplitItems(firstPart, currentItem, numBytes); // insert firstPart before currentItem @@ -603,14 +601,14 @@ TcpTxBuffer::MergeItems(TcpTxItem* t1, TcpTxItem* t2) const { if (t1->m_retrans) { - TcpTxBuffer* self = const_cast(this); + auto self = const_cast(this); self->m_retrans -= t1->m_packet->GetSize(); t1->m_retrans = false; } else { NS_ASSERT(t2->m_retrans); - TcpTxBuffer* self = const_cast(this); + auto self = const_cast(this); self->m_retrans -= t2->m_packet->GetSize(); t2->m_retrans = false; } @@ -681,7 +679,7 @@ TcpTxBuffer::DiscardUpTo(const SequenceNumber32& seq, const Callback 0 && offset > 0) { if (i == m_sentList.end()) @@ -790,7 +788,7 @@ TcpTxBuffer::Update(const TcpOptionSack::SackList& list, const Callback= m_highestSack.second) { @@ -938,7 +935,7 @@ TcpTxBuffer::IsLost(const SequenceNumber32& seq) const // In theory, using a map and hints when inserting elements can improve // performance - for (it = m_sentList.begin(); it != m_sentList.end(); ++it) + for (auto it = m_sentList.begin(); it != m_sentList.end(); ++it) { // Search for the right iterator before calling IsLost() if (beginOfCurrentPacket >= seq) @@ -980,13 +977,12 @@ TcpTxBuffer::NextSeg(SequenceNumber32* seq, SequenceNumber32* seqHigh, bool isRe * * (1.c) IsLost (S2) returns true. */ - PacketList::const_iterator it; TcpTxItem* item; SequenceNumber32 seqPerRule3; bool isSeqPerRule3Valid = false; SequenceNumber32 beginOfCurrentPkt = m_firstByteSeq; - for (it = m_sentList.begin(); it != m_sentList.end(); ++it) + for (auto it = m_sentList.begin(); it != m_sentList.end(); ++it) { item = *it; @@ -1092,7 +1088,6 @@ TcpTxBuffer::BytesInFlight() const uint32_t TcpTxBuffer::BytesInFlightRFC() const { - PacketList::const_iterator it; TcpTxItem* item; uint32_t size = 0; // "pipe" in RFC SequenceNumber32 beginOfCurrentPkt = m_firstByteSeq; @@ -1104,7 +1099,7 @@ TcpTxBuffer::BytesInFlightRFC() const // After initializing pipe to zero, the following steps are taken for each // octet 'S1' in the sequence space between HighACK and HighData that has not // been SACKed: - for (it = m_sentList.begin(); it != m_sentList.end(); ++it) + for (auto it = m_sentList.begin(); it != m_sentList.end(); ++it) { item = *it; totalSize += item->m_packet->GetSize(); @@ -1472,14 +1467,13 @@ operator<<(std::ostream& os, const TcpTxItem& item) std::ostream& operator<<(std::ostream& os, const TcpTxBuffer& tcpTxBuf) { - TcpTxBuffer::PacketList::const_iterator it; std::stringstream ss; SequenceNumber32 beginOfCurrentPacket = tcpTxBuf.m_firstByteSeq; uint32_t sentSize = 0; uint32_t appSize = 0; Ptr p; - for (it = tcpTxBuf.m_sentList.begin(); it != tcpTxBuf.m_sentList.end(); ++it) + for (auto it = tcpTxBuf.m_sentList.begin(); it != tcpTxBuf.m_sentList.end(); ++it) { p = (*it)->GetPacket(); ss << "{"; @@ -1489,7 +1483,7 @@ operator<<(std::ostream& os, const TcpTxBuffer& tcpTxBuf) beginOfCurrentPacket += p->GetSize(); } - for (it = tcpTxBuf.m_appList.begin(); it != tcpTxBuf.m_appList.end(); ++it) + for (auto it = tcpTxBuf.m_appList.begin(); it != tcpTxBuf.m_appList.end(); ++it) { appSize += (*it)->GetPacket()->GetSize(); } diff --git a/src/internet/model/tcp-tx-buffer.h b/src/internet/model/tcp-tx-buffer.h index e1962d3fe..f37d1adf4 100644 --- a/src/internet/model/tcp-tx-buffer.h +++ b/src/internet/model/tcp-tx-buffer.h @@ -21,10 +21,11 @@ #ifndef TCP_TX_BUFFER_H #define TCP_TX_BUFFER_H +#include "tcp-option-sack.h" +#include "tcp-tx-item.h" + #include "ns3/object.h" #include "ns3/sequence-number.h" -#include "ns3/tcp-option-sack.h" -#include "ns3/tcp-tx-item.h" #include "ns3/traced-value.h" namespace ns3 diff --git a/src/internet/model/tcp-westwood-plus.h b/src/internet/model/tcp-westwood-plus.h index 0518d196b..0de9d993e 100644 --- a/src/internet/model/tcp-westwood-plus.h +++ b/src/internet/model/tcp-westwood-plus.h @@ -33,10 +33,10 @@ #define TCP_WESTWOOD_H #include "tcp-congestion-ops.h" +#include "tcp-recovery-ops.h" #include "ns3/data-rate.h" #include "ns3/event-id.h" -#include "ns3/tcp-recovery-ops.h" #include "ns3/traced-value.h" namespace ns3 diff --git a/src/internet/model/tcp-yeah.cc b/src/internet/model/tcp-yeah.cc index 1cc8d1648..f09486a6e 100644 --- a/src/internet/model/tcp-yeah.cc +++ b/src/internet/model/tcp-yeah.cc @@ -249,7 +249,7 @@ TcpYeah::IncreaseWindow(Ptr tcb, uint32_t segmentsAcked) // queue = rttQueue * bw = rttQueue * (cwnd/RTTmin) double bw = segCwnd / m_minRtt.GetSeconds(); - uint32_t queue = static_cast(bw * rttQueue.GetSeconds()); + auto queue = static_cast(bw * rttQueue.GetSeconds()); NS_LOG_DEBUG("Queue backlog = " << queue << " given by cwnd = " << segCwnd << ", minRtt = " << m_minRtt.GetMilliSeconds() << " ms, baseRtt = " << m_baseRtt.GetMilliSeconds() diff --git a/src/internet/model/tcp-yeah.h b/src/internet/model/tcp-yeah.h index 0b67100ed..0857c4763 100644 --- a/src/internet/model/tcp-yeah.h +++ b/src/internet/model/tcp-yeah.h @@ -26,8 +26,8 @@ #ifndef TCPYEAH_H #define TCPYEAH_H -#include "ns3/tcp-recovery-ops.h" -#include "ns3/tcp-scalable.h" +#include "tcp-recovery-ops.h" +#include "tcp-scalable.h" namespace ns3 { diff --git a/src/internet/model/udp-header.cc b/src/internet/model/udp-header.cc index 1c7a1052d..ec03f19ba 100644 --- a/src/internet/model/udp-header.cc +++ b/src/internet/model/udp-header.cc @@ -26,27 +26,6 @@ namespace ns3 NS_OBJECT_ENSURE_REGISTERED(UdpHeader); -/* The magic values below are used only for debugging. - * They can be used to easily detect memory corruption - * problems so you can see the patterns in memory. - */ -UdpHeader::UdpHeader() - : m_sourcePort(0xfffd), - m_destinationPort(0xfffd), - m_payloadSize(0), - m_checksum(0), - m_calcChecksum(false), - m_goodChecksum(true) -{ -} - -UdpHeader::~UdpHeader() -{ - m_sourcePort = 0xfffe; - m_destinationPort = 0xfffe; - m_payloadSize = 0xfffe; -} - void UdpHeader::EnableChecksums() { @@ -150,7 +129,7 @@ UdpHeader::ForceChecksum(uint16_t checksum) void UdpHeader::ForcePayloadSize(uint16_t payloadSize) { - m_payloadSize = payloadSize; + m_forcedPayloadSize = payloadSize; } TypeId @@ -189,13 +168,13 @@ UdpHeader::Serialize(Buffer::Iterator start) const i.WriteHtonU16(m_sourcePort); i.WriteHtonU16(m_destinationPort); - if (m_payloadSize == 0) + if (m_forcedPayloadSize == 0) { i.WriteHtonU16(start.GetSize()); } else { - i.WriteHtonU16(m_payloadSize); + i.WriteHtonU16(m_forcedPayloadSize); } if (m_checksum == 0) diff --git a/src/internet/model/udp-header.h b/src/internet/model/udp-header.h index 65a46bae8..52400714f 100644 --- a/src/internet/model/udp-header.h +++ b/src/internet/model/udp-header.h @@ -40,14 +40,6 @@ namespace ns3 class UdpHeader : public Header { public: - /** - * \brief Constructor - * - * Creates a null header - */ - UdpHeader(); - ~UdpHeader() override; - /** * \brief Enable checksum calculation for UDP */ @@ -167,16 +159,21 @@ class UdpHeader : public Header * \returns the checksum */ uint16_t CalculateHeaderChecksum(uint16_t size) const; - uint16_t m_sourcePort; //!< Source port - uint16_t m_destinationPort; //!< Destination port - uint16_t m_payloadSize; //!< Payload size - Address m_source; //!< Source IP address - Address m_destination; //!< Destination IP address - uint8_t m_protocol; //!< Protocol number - uint16_t m_checksum; //!< Forced Checksum value - bool m_calcChecksum; //!< Flag to calculate checksum - bool m_goodChecksum; //!< Flag to indicate that checksum is correct + // The magic values below are used only for debugging. + // They can be used to easily detect memory corruption + // problems so you can see the patterns in memory. + uint16_t m_sourcePort{0xfffd}; //!< Source port + uint16_t m_destinationPort{0xfffd}; //!< Destination port + uint16_t m_payloadSize{0}; //!< Payload size + uint16_t m_forcedPayloadSize{0}; //!< Payload size (forced) + + Address m_source; //!< Source IP address + Address m_destination; //!< Destination IP address + uint8_t m_protocol{17}; //!< Protocol number + uint16_t m_checksum{0}; //!< Forced Checksum value + bool m_calcChecksum{false}; //!< Flag to calculate checksum + bool m_goodChecksum{true}; //!< Flag to indicate that checksum is correct }; } // namespace ns3 diff --git a/src/internet/model/udp-l4-protocol.cc b/src/internet/model/udp-l4-protocol.cc index 9442b530c..ff290207c 100644 --- a/src/internet/model/udp-l4-protocol.cc +++ b/src/internet/model/udp-l4-protocol.cc @@ -382,8 +382,7 @@ UdpL4Protocol::Receive(Ptr packet, const Ipv4Header& header, PtrRemoveHeader(udpHeader); - for (Ipv4EndPointDemux::EndPointsI endPoint = endPoints.begin(); endPoint != endPoints.end(); - endPoint++) + for (auto endPoint = endPoints.begin(); endPoint != endPoints.end(); endPoint++) { (*endPoint)->ForwardUp(packet->Copy(), header, udpHeader.GetSourcePort(), interface); } @@ -422,8 +421,7 @@ UdpL4Protocol::Receive(Ptr packet, const Ipv6Header& header, PtrForwardUp(packet->Copy(), header, udpHeader.GetSourcePort(), interface); } diff --git a/src/internet/model/udp-socket-factory-impl.h b/src/internet/model/udp-socket-factory-impl.h index f31bccbd8..5c7023456 100644 --- a/src/internet/model/udp-socket-factory-impl.h +++ b/src/internet/model/udp-socket-factory-impl.h @@ -19,8 +19,9 @@ #ifndef UDP_SOCKET_FACTORY_IMPL_H #define UDP_SOCKET_FACTORY_IMPL_H +#include "udp-socket-factory.h" + #include "ns3/ptr.h" -#include "ns3/udp-socket-factory.h" namespace ns3 { diff --git a/src/internet/model/udp-socket-impl.h b/src/internet/model/udp-socket-impl.h index d50d9cce3..6daf8e46b 100644 --- a/src/internet/model/udp-socket-impl.h +++ b/src/internet/model/udp-socket-impl.h @@ -20,14 +20,14 @@ #define UDP_SOCKET_IMPL_H #include "icmpv4.h" +#include "ipv4-interface.h" +#include "udp-socket.h" #include "ns3/callback.h" #include "ns3/ipv4-address.h" -#include "ns3/ipv4-interface.h" #include "ns3/ptr.h" #include "ns3/socket.h" #include "ns3/traced-callback.h" -#include "ns3/udp-socket.h" #include #include diff --git a/src/internet/test/global-route-manager-impl-test-suite.cc b/src/internet/test/global-route-manager-impl-test-suite.cc index 991d6652b..0210ed46a 100644 --- a/src/internet/test/global-route-manager-impl-test-suite.cc +++ b/src/internet/test/global-route-manager-impl-test-suite.cc @@ -60,7 +60,7 @@ GlobalRouteManagerImplTestCase::DoRun() for (int i = 0; i < 100; ++i) { - SPFVertex* v = new SPFVertex; + auto v = new SPFVertex; v->SetDistanceFromRoot(std::rand() % 100); candidate.Push(v); } @@ -88,18 +88,17 @@ GlobalRouteManagerImplTestCase::DoRun() // link2: 10.1.3.1/30, 10.1.3.2/30 // // Router 0 - GlobalRoutingLinkRecord* lr0 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, - "0.0.0.2", // router ID 0.0.0.2 - "10.1.1.1", // local ID - 1); // metric + auto lr0 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, + "0.0.0.2", // router ID 0.0.0.2 + "10.1.1.1", // local ID + 1); // metric - GlobalRoutingLinkRecord* lr1 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, - "10.1.1.1", - "255.255.255.252", - 1); + auto lr1 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, + "10.1.1.1", + "255.255.255.252", + 1); - GlobalRoutingLSA* lsa0 = new GlobalRoutingLSA(); + auto lsa0 = new GlobalRoutingLSA(); lsa0->SetLSType(GlobalRoutingLSA::RouterLSA); lsa0->SetLinkStateId("0.0.0.0"); lsa0->SetAdvertisingRouter("0.0.0.0"); @@ -107,18 +106,17 @@ GlobalRouteManagerImplTestCase::DoRun() lsa0->AddLinkRecord(lr1); // Router 1 - GlobalRoutingLinkRecord* lr2 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, - "0.0.0.2", - "10.1.2.1", - 1); + auto lr2 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, + "0.0.0.2", + "10.1.2.1", + 1); - GlobalRoutingLinkRecord* lr3 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, - "10.1.2.1", - "255.255.255.252", - 1); + auto lr3 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, + "10.1.2.1", + "255.255.255.252", + 1); - GlobalRoutingLSA* lsa1 = new GlobalRoutingLSA(); + auto lsa1 = new GlobalRoutingLSA(); lsa1->SetLSType(GlobalRoutingLSA::RouterLSA); lsa1->SetLinkStateId("0.0.0.1"); lsa1->SetAdvertisingRouter("0.0.0.1"); @@ -126,40 +124,37 @@ GlobalRouteManagerImplTestCase::DoRun() lsa1->AddLinkRecord(lr3); // Router 2 - GlobalRoutingLinkRecord* lr4 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, - "0.0.0.0", - "10.1.1.2", - 1); + auto lr4 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, + "0.0.0.0", + "10.1.1.2", + 1); - GlobalRoutingLinkRecord* lr5 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, - "10.1.1.2", - "255.255.255.252", - 1); + auto lr5 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, + "10.1.1.2", + "255.255.255.252", + 1); - GlobalRoutingLinkRecord* lr6 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, - "0.0.0.1", - "10.1.2.2", - 1); + auto lr6 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, + "0.0.0.1", + "10.1.2.2", + 1); - GlobalRoutingLinkRecord* lr7 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, - "10.1.2.2", - "255.255.255.252", - 1); + auto lr7 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, + "10.1.2.2", + "255.255.255.252", + 1); - GlobalRoutingLinkRecord* lr8 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, - "0.0.0.3", - "10.1.3.2", - 1); + auto lr8 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, + "0.0.0.3", + "10.1.3.2", + 1); - GlobalRoutingLinkRecord* lr9 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, - "10.1.3.2", - "255.255.255.252", - 1); + auto lr9 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, + "10.1.3.2", + "255.255.255.252", + 1); - GlobalRoutingLSA* lsa2 = new GlobalRoutingLSA(); + auto lsa2 = new GlobalRoutingLSA(); lsa2->SetLSType(GlobalRoutingLSA::RouterLSA); lsa2->SetLinkStateId("0.0.0.2"); lsa2->SetAdvertisingRouter("0.0.0.2"); @@ -171,19 +166,17 @@ GlobalRouteManagerImplTestCase::DoRun() lsa2->AddLinkRecord(lr9); // Router 3 - GlobalRoutingLinkRecord* lr10 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, - "0.0.0.2", - "10.1.2.1", - 1); + auto lr10 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, + "0.0.0.2", + "10.1.2.1", + 1); - GlobalRoutingLinkRecord* lr11 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, - "10.1.2.1", - "255.255.255.252", - 1); + auto lr11 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, + "10.1.2.1", + "255.255.255.252", + 1); - GlobalRoutingLSA* lsa3 = new GlobalRoutingLSA(); + auto lsa3 = new GlobalRoutingLSA(); lsa3->SetLSType(GlobalRoutingLSA::RouterLSA); lsa3->SetLinkStateId("0.0.0.3"); lsa3->SetAdvertisingRouter("0.0.0.3"); @@ -191,7 +184,7 @@ GlobalRouteManagerImplTestCase::DoRun() lsa3->AddLinkRecord(lr11); // Test the database - GlobalRouteManagerLSDB* srmlsdb = new GlobalRouteManagerLSDB(); + auto srmlsdb = new GlobalRouteManagerLSDB(); srmlsdb->Insert(lsa0->GetLinkStateId(), lsa0); srmlsdb->Insert(lsa1->GetLinkStateId(), lsa1); srmlsdb->Insert(lsa2->GetLinkStateId(), lsa2); @@ -201,7 +194,7 @@ GlobalRouteManagerImplTestCase::DoRun() "The Ipv4Address is not stored as the link state ID"); // next, calculate routes based on the manually created LSDB - GlobalRouteManagerImpl* srm = new GlobalRouteManagerImpl(); + auto srm = new GlobalRouteManagerImpl(); srm->DebugUseLsdb(srmlsdb); // manually add in an LSDB // Note-- this will succeed without any nodes in the topology // because the NodeList is empty diff --git a/src/internet/test/icmp-test.cc b/src/internet/test/icmp-test.cc index 037793790..964348056 100644 --- a/src/internet/test/icmp-test.cc +++ b/src/internet/test/icmp-test.cc @@ -399,7 +399,7 @@ void IcmpV6EchoReplyTestCase::SendData(Ptr socket, Ipv6Address dst) { Ptr p = Create(); - Icmpv6Echo echo(1); + Icmpv6Echo echo(true); echo.SetSeq(1); echo.SetId(0XB1ED); p->AddHeader(echo); @@ -537,7 +537,7 @@ void IcmpV6TimeExceedTestCase::SendData(Ptr socket, Ipv6Address dst) { Ptr p = Create(); - Icmpv6Echo echo(1); + Icmpv6Echo echo(true); echo.SetSeq(1); echo.SetId(0XB1ED); p->AddHeader(echo); diff --git a/src/internet/test/ipv4-address-generator-test-suite.cc b/src/internet/test/ipv4-address-generator-test-suite.cc index 8f649c34a..7702b948c 100644 --- a/src/internet/test/ipv4-address-generator-test-suite.cc +++ b/src/internet/test/ipv4-address-generator-test-suite.cc @@ -323,18 +323,28 @@ AddressCollisionTestCase::DoRun() Ipv4AddressGenerator::AddAllocated("0.0.0.16"); Ipv4AddressGenerator::TestMode(); + bool allocated = Ipv4AddressGenerator::IsAddressAllocated("0.0.0.21"); + NS_TEST_EXPECT_MSG_EQ(allocated, false, "0.0.0.21 should not be already allocated"); bool added = Ipv4AddressGenerator::AddAllocated("0.0.0.21"); NS_TEST_EXPECT_MSG_EQ(added, true, "400"); + allocated = Ipv4AddressGenerator::IsAddressAllocated("0.0.0.4"); + NS_TEST_EXPECT_MSG_EQ(allocated, true, "0.0.0.4 should be already allocated"); added = Ipv4AddressGenerator::AddAllocated("0.0.0.4"); NS_TEST_EXPECT_MSG_EQ(added, false, "401"); + allocated = Ipv4AddressGenerator::IsAddressAllocated("0.0.0.9"); + NS_TEST_EXPECT_MSG_EQ(allocated, true, "0.0.0.9 should be already allocated"); added = Ipv4AddressGenerator::AddAllocated("0.0.0.9"); NS_TEST_EXPECT_MSG_EQ(added, false, "402"); + allocated = Ipv4AddressGenerator::IsAddressAllocated("0.0.0.16"); + NS_TEST_EXPECT_MSG_EQ(allocated, true, "0.0.0.16 should be already allocated"); added = Ipv4AddressGenerator::AddAllocated("0.0.0.16"); NS_TEST_EXPECT_MSG_EQ(added, false, "403"); + allocated = Ipv4AddressGenerator::IsAddressAllocated("0.0.0.21"); + NS_TEST_EXPECT_MSG_EQ(allocated, true, "0.0.0.21 should be already allocated"); added = Ipv4AddressGenerator::AddAllocated("0.0.0.21"); NS_TEST_EXPECT_MSG_EQ(added, false, "404"); } diff --git a/src/internet/test/ipv4-global-routing-test-suite.cc b/src/internet/test/ipv4-global-routing-test-suite.cc index 5f257af86..9498512fa 100644 --- a/src/internet/test/ipv4-global-routing-test-suite.cc +++ b/src/internet/test/ipv4-global-routing-test-suite.cc @@ -894,9 +894,7 @@ Ipv4DynamicGlobalRoutingTestCase::Ipv4DynamicGlobalRoutingTestCase() Ipv4DynamicGlobalRoutingTestCase::~Ipv4DynamicGlobalRoutingTestCase() { - std::vector, bool>>::iterator iter; - - for (iter = m_sendSocks.begin(); iter != m_sendSocks.end(); iter++) + for (auto iter = m_sendSocks.begin(); iter != m_sendSocks.end(); iter++) { if (iter->second) { diff --git a/src/internet/test/ipv4-rip-test.cc b/src/internet/test/ipv4-rip-test.cc index 1945d02fb..010236c13 100644 --- a/src/internet/test/ipv4-rip-test.cc +++ b/src/internet/test/ipv4-rip-test.cc @@ -558,7 +558,7 @@ Ipv4RipSplitHorizonStrategyTest::ReceivePktProbe(Ptr socket) std::list rtes = hdr.GetRteList(); // validate the RTEs before processing - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { if (iter->GetPrefix() == "10.0.1.0") { diff --git a/src/internet/test/ipv6-address-generator-test-suite.cc b/src/internet/test/ipv6-address-generator-test-suite.cc index 3896e4f22..cfad9ef01 100644 --- a/src/internet/test/ipv6-address-generator-test-suite.cc +++ b/src/internet/test/ipv6-address-generator-test-suite.cc @@ -315,18 +315,28 @@ AddressCollision6TestCase::DoRun() Ipv6AddressGenerator::AddAllocated("0::0:16"); Ipv6AddressGenerator::TestMode(); + bool allocated = Ipv6AddressGenerator::IsAddressAllocated("0::0:21"); + NS_TEST_EXPECT_MSG_EQ(allocated, false, "0::0:21 should not be already allocated"); bool added = Ipv6AddressGenerator::AddAllocated("0::0:21"); NS_TEST_EXPECT_MSG_EQ(added, true, "address should get allocated"); + allocated = Ipv6AddressGenerator::IsAddressAllocated("0::0:4"); + NS_TEST_EXPECT_MSG_EQ(allocated, true, "0::0:4 should be already allocated"); added = Ipv6AddressGenerator::AddAllocated("0::0:4"); NS_TEST_EXPECT_MSG_EQ(added, false, "address should not get allocated"); + allocated = Ipv6AddressGenerator::IsAddressAllocated("0::0:9"); + NS_TEST_EXPECT_MSG_EQ(allocated, true, "0::0:9 should be already allocated"); added = Ipv6AddressGenerator::AddAllocated("0::0:9"); NS_TEST_EXPECT_MSG_EQ(added, false, "address should not get allocated"); + allocated = Ipv6AddressGenerator::IsAddressAllocated("0::0:16"); + NS_TEST_EXPECT_MSG_EQ(allocated, true, "0::0:16 should be already allocated"); added = Ipv6AddressGenerator::AddAllocated("0::0:16"); NS_TEST_EXPECT_MSG_EQ(added, false, "address should not get allocated"); + allocated = Ipv6AddressGenerator::IsAddressAllocated("0::0:21"); + NS_TEST_EXPECT_MSG_EQ(allocated, true, "0::0:21 should be already allocated"); added = Ipv6AddressGenerator::AddAllocated("0::0:21"); NS_TEST_EXPECT_MSG_EQ(added, false, "address should not get allocated"); } diff --git a/src/internet/test/ipv6-ripng-test.cc b/src/internet/test/ipv6-ripng-test.cc index a070fcafc..c378a9ef9 100644 --- a/src/internet/test/ipv6-ripng-test.cc +++ b/src/internet/test/ipv6-ripng-test.cc @@ -556,7 +556,7 @@ Ipv6RipngSplitHorizonStrategyTest::ReceivePktProbe(Ptr socket) std::list rtes = hdr.GetRteList(); // validate the RTEs before processing - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { if (iter->GetPrefix() == "2001:1::") { diff --git a/src/internet/test/tcp-advertised-window-test.cc b/src/internet/test/tcp-advertised-window-test.cc index 292b9d1f4..fb0c0f2cd 100644 --- a/src/internet/test/tcp-advertised-window-test.cc +++ b/src/internet/test/tcp-advertised-window-test.cc @@ -447,7 +447,7 @@ Ptr TcpAdvWindowOnLossTest::CreateReceiverErrorModel() { Ptr m_errorModel = CreateObject(); - for (std::vector::iterator it = m_toDrop.begin(); it != m_toDrop.end(); ++it) + for (auto it = m_toDrop.begin(); it != m_toDrop.end(); ++it) { m_errorModel->AddSeqToKill(SequenceNumber32(*it)); } diff --git a/src/internet/test/tcp-bytes-in-flight-test.cc b/src/internet/test/tcp-bytes-in-flight-test.cc index 59072c56d..526aedf33 100644 --- a/src/internet/test/tcp-bytes-in-flight-test.cc +++ b/src/internet/test/tcp-bytes-in-flight-test.cc @@ -141,7 +141,7 @@ Ptr TcpBytesInFlightTest::CreateReceiverErrorModel() { Ptr m_errorModel = CreateObject(); - for (std::vector::iterator it = m_toDrop.begin(); it != m_toDrop.end(); ++it) + for (auto it = m_toDrop.begin(); it != m_toDrop.end(); ++it) { m_errorModel->AddSeqToKill(SequenceNumber32(*it)); } @@ -236,7 +236,7 @@ TcpBytesInFlightTest::Tx(const Ptr p, const TcpHeader& h, SocketWh { if (who == SENDER) { - static SequenceNumber32 retr = SequenceNumber32(0); + static SequenceNumber32 retr(0); static uint32_t times = 0; if (m_greatestSeqSent <= h.GetSequenceNumber()) diff --git a/src/internet/test/tcp-fast-retr-test.cc b/src/internet/test/tcp-fast-retr-test.cc index 25aeae88d..fb8ee33fd 100644 --- a/src/internet/test/tcp-fast-retr-test.cc +++ b/src/internet/test/tcp-fast-retr-test.cc @@ -443,7 +443,7 @@ class TcpFastRetrTestSuite : public TestSuite types.insert(types.begin(), TcpWestwoodPlus::GetTypeId()); types.insert(types.begin(), TcpNewReno::GetTypeId()); - for (std::list::iterator it = types.begin(); it != types.end(); ++it) + for (auto it = types.begin(); it != types.end(); ++it) { AddTestCase(new TcpFastRetrTest((*it), 5001, "Fast Retransmit testing"), TestCase::QUICK); diff --git a/src/internet/test/tcp-rate-ops-test.cc b/src/internet/test/tcp-rate-ops-test.cc index 6c5f57b19..5ab857265 100644 --- a/src/internet/test/tcp-rate-ops-test.cc +++ b/src/internet/test/tcp-rate-ops-test.cc @@ -343,7 +343,7 @@ Ptr TcpRateLinuxWithSocketsTest::CreateReceiverErrorModel() { Ptr m_errorModel = CreateObject(); - for (std::vector::iterator it = m_toDrop.begin(); it != m_toDrop.end(); ++it) + for (auto it = m_toDrop.begin(); it != m_toDrop.end(); ++it) { m_errorModel->AddSeqToKill(SequenceNumber32(*it)); } diff --git a/src/internet/test/tcp-rtt-estimation.cc b/src/internet/test/tcp-rtt-estimation.cc index 2285ce039..2abc2a939 100644 --- a/src/internet/test/tcp-rtt-estimation.cc +++ b/src/internet/test/tcp-rtt-estimation.cc @@ -232,9 +232,7 @@ TcpRttEstimationWithLossTest::CreateReceiverErrorModel() { Ptr errorModel = CreateObject(); - std::vector::iterator it; - - for (it = m_toDrop.begin(); it != m_toDrop.end(); ++it) + for (auto it = m_toDrop.begin(); it != m_toDrop.end(); ++it) { errorModel->AddSeqToKill(SequenceNumber32((*it))); } diff --git a/src/internet/test/tcp-rx-buffer-test.cc b/src/internet/test/tcp-rx-buffer-test.cc index d64c80d5e..5ba345ca2 100644 --- a/src/internet/test/tcp-rx-buffer-test.cc +++ b/src/internet/test/tcp-rx-buffer-test.cc @@ -60,7 +60,6 @@ TcpRxBufferTestCase::TestUpdateSACKList() { TcpRxBuffer rxBuf; TcpOptionSack::SackList sackList; - TcpOptionSack::SackList::iterator it; Ptr p = Create(100); TcpHeader h; @@ -83,7 +82,7 @@ TcpRxBufferTestCase::TestUpdateSACKList() "Sequence number differs from expected"); sackList = rxBuf.GetSackList(); NS_TEST_ASSERT_MSG_EQ(sackList.size(), 1, "SACK list should contain one element"); - it = sackList.begin(); + auto it = sackList.begin(); NS_TEST_ASSERT_MSG_EQ(it->first, SequenceNumber32(501), "SACK block different than expected"); NS_TEST_ASSERT_MSG_EQ(it->second, SequenceNumber32(601), "SACK block different than expected"); diff --git a/src/internet/test/tcp-test.cc b/src/internet/test/tcp-test.cc index 8a6af9e4f..3024e4bcf 100644 --- a/src/internet/test/tcp-test.cc +++ b/src/internet/test/tcp-test.cc @@ -220,7 +220,7 @@ TcpTestCase::DoRun() m_serverRxPayload = new uint8_t[m_totalBytes]; for (uint32_t i = 0; i < m_totalBytes; ++i) { - uint8_t m = (uint8_t)(97 + (i % 26)); + auto m = (uint8_t)(97 + (i % 26)); m_sourceTxPayload[i] = m; } memset(m_sourceRxPayload, 0, m_totalBytes); diff --git a/src/lr-wpan/doc/lr-wpan.rst b/src/lr-wpan/doc/lr-wpan.rst index 25d2bee6b..192a15f2d 100644 --- a/src/lr-wpan/doc/lr-wpan.rst +++ b/src/lr-wpan/doc/lr-wpan.rst @@ -220,7 +220,10 @@ reference packets (11 bytes MAC header + 7 bytes payload (MSDU) + FCS 2 bytes). have the effect to receive more packets (and at a greater distance) but it raises the probability to have dropped packets at the MAC layer or the probability of corrupted packets. By default, the receiver sensitivity is set to the maximum theoretical possible value of -106.58 dBm for the supported IEEE 802.15.4 O-QPSK 250kps. This rx sensitivity is set for the "perfect radio" which only considers the floor noise, in essence, this do not include the noise factor (noise introduced by imperfections in the demodulator chip or external factors). -The receiver sensitivity can be changed to different values using ``SetRxSensitivity`` function in the PHY to simulate the hearing capabilities of different compliant radio transceivers (the standard minimum compliant Rx sensitivity is -85 dBm).::: +The receiver sensitivity can be changed to different values using ``SetRxSensitivity`` function in the PHY to simulate the hearing capabilities of different compliant radio transceivers (the standard minimum compliant Rx sensitivity is -85 dBm).: + +:: + (defined by the standard) NoiseFloor Max Sensitivity Min Sensitivity -106.987dBm -106.58dBm -85dBm diff --git a/src/lr-wpan/examples/lr-wpan-bootstrap.cc b/src/lr-wpan/examples/lr-wpan-bootstrap.cc index 28b17279d..787287219 100644 --- a/src/lr-wpan/examples/lr-wpan-bootstrap.cc +++ b/src/lr-wpan/examples/lr-wpan-bootstrap.cc @@ -381,7 +381,7 @@ main(int argc, char* argv[]) lrWpanHelper.SetExtendedAddresses(lrwpanDevices); // Devices hooks & MAC MLME-scan primitive set - for (NodeContainer::Iterator i = nodes.Begin(); i != nodes.End(); i++) + for (auto i = nodes.Begin(); i != nodes.End(); i++) { Ptr node = *i; Ptr netDevice = node->GetDevice(0); @@ -416,7 +416,7 @@ main(int argc, char* argv[]) } // Coordinator hooks - for (NodeContainer::Iterator i = coordinators.Begin(); i != coordinators.End(); i++) + for (auto i = coordinators.Begin(); i != coordinators.End(); i++) { Ptr coor = *i; Ptr netDevice = coor->GetDevice(0); diff --git a/src/lr-wpan/helper/lr-wpan-helper.cc b/src/lr-wpan/helper/lr-wpan-helper.cc index 0f73ab867..797be0194 100644 --- a/src/lr-wpan/helper/lr-wpan-helper.cc +++ b/src/lr-wpan/helper/lr-wpan-helper.cc @@ -179,7 +179,7 @@ NetDeviceContainer LrWpanHelper::Install(NodeContainer c) { NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { Ptr node = *i; @@ -218,7 +218,7 @@ LrWpanHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr lrwpan = DynamicCast(netDevice); @@ -242,7 +242,7 @@ LrWpanHelper::CreateAssociatedPan(NetDeviceContainer c, uint16_t panId) Mac16Address coordShortAddr; Mac64Address coordExtAddr; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { if (id < 0x0001 || id > 0xFFFD) { @@ -285,7 +285,7 @@ LrWpanHelper::SetExtendedAddresses(NetDeviceContainer c) uint8_t idBuf[8] = {0, 0, 0, 0, 0, 0, 0, 0}; Mac64Address address64; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { Ptr device = DynamicCast(*i); if (device) diff --git a/src/lr-wpan/model/lr-wpan-csmaca.h b/src/lr-wpan/model/lr-wpan-csmaca.h index 13c7ab4a3..ec8352a96 100644 --- a/src/lr-wpan/model/lr-wpan-csmaca.h +++ b/src/lr-wpan/model/lr-wpan-csmaca.h @@ -23,8 +23,9 @@ #ifndef LR_WPAN_CSMACA_H #define LR_WPAN_CSMACA_H +#include "lr-wpan-mac.h" + #include -#include #include namespace ns3 diff --git a/src/lr-wpan/model/lr-wpan-fields.cc b/src/lr-wpan/model/lr-wpan-fields.cc index 59829e815..7898c5a0e 100644 --- a/src/lr-wpan/model/lr-wpan-fields.cc +++ b/src/lr-wpan/model/lr-wpan-fields.cc @@ -492,6 +492,39 @@ CapabilityField::CapabilityField() m_allocAddr = true; } +CapabilityField::CapabilityField(uint8_t bitmap) +{ + SetCapability(bitmap); +} + +uint8_t +CapabilityField::GetCapability() const +{ + uint8_t capability; + + capability = (m_reservedBit0) & (0x01); //!< Bit 0 (reserved) + capability |= (m_deviceType << 1) & (0x01 << 1); //!< Bit 1 + capability |= (m_powerSource << 2) & (0x01 << 2); //!< Bit 2 + capability |= (m_receiverOnWhenIdle << 3) & (0x01 << 3); //!< Bit 3 + capability |= (m_reservedBit45 << 4) & (0x03 << 4); //!< Bit 4-5 (reserved) + capability |= (m_securityCap << 6) & (0x01 << 6); //!< Bit 6 + capability |= (m_allocAddr << 7) & (0x01 << 7); //!< Bit 7 + + return capability; +} + +void +CapabilityField::SetCapability(uint8_t bitmap) +{ + m_reservedBit0 = (bitmap) & (0x01); //!< Bit 0 (reserved) + m_deviceType = (bitmap >> 1) & (0x01); //!< Bit 1 + m_powerSource = (bitmap >> 2) & (0x01); //!< Bit 2 + m_receiverOnWhenIdle = (bitmap >> 3) & (0x01); //!< Bit 3 + m_reservedBit45 = (bitmap >> 4) & (0x03); //!< Bit 4-5 (reserved) + m_securityCap = (bitmap >> 6) & (0x01); //!< Bit 6 + m_allocAddr = (bitmap >> 7) & (0x01); //!< Bit 7 +} + uint32_t CapabilityField::GetSerializedSize() const { @@ -501,16 +534,7 @@ CapabilityField::GetSerializedSize() const Buffer::Iterator CapabilityField::Serialize(Buffer::Iterator i) const { - uint8_t capability; - - capability = 0; //!< Bit 0 (reserved) - capability = (m_deviceType << 1) & (0x01 << 1); //!< Bit 1 - capability |= (m_powerSource << 2) & (0x01 << 2); //!< Bit 2 - capability |= (m_receiverOnWhenIdle << 3) & (0x01 << 3); //!< Bit 3 - //!< Bit 4-5 (reserved) - capability |= (m_securityCap << 6) & (0x01 << 6); //!< Bit 6 - capability |= (m_allocAddr << 7) & (0x01 << 7); //!< Bit 7 - i.WriteU8(capability); + i.WriteU8(GetCapability()); return i; } @@ -518,14 +542,7 @@ Buffer::Iterator CapabilityField::Deserialize(Buffer::Iterator i) { uint8_t capability = i.ReadU8(); - //!< Bit 0 (reserved) - m_deviceType = (capability >> 1) & (0x01); //!< Bit 1 - m_powerSource = (capability >> 2) & (0x01); //!< Bit 2 - m_receiverOnWhenIdle = (capability >> 3) & (0x01); //!< Bit 3 - //!< Bit 4-5 (reserved) - m_securityCap = (capability >> 6) & (0x01); //!< Bit 6 - m_allocAddr = (capability >> 7) & (0x01); //!< Bit 7 - + SetCapability(capability); return i; } diff --git a/src/lr-wpan/model/lr-wpan-fields.h b/src/lr-wpan/model/lr-wpan-fields.h index b322d717a..79f3079e5 100644 --- a/src/lr-wpan/model/lr-wpan-fields.h +++ b/src/lr-wpan/model/lr-wpan-fields.h @@ -355,88 +355,137 @@ class CapabilityField { public: CapabilityField(); + + /** + * Construct a Capability field based on a bitmap. + * + * \param bitmap The bitmap representing the capability + */ + CapabilityField(uint8_t bitmap); + + /** + * Get the bitmap representing the device capability. + * + * \return The bitmap representing the device capability. + */ + uint8_t GetCapability() const; + + /** + * Set the bitmap representing the device capability. + * + * \param bitmap The bitmap representing the capability + */ + void SetCapability(uint8_t bitmap); + /** * Get the size of the serialized Capability Information Field. + * * \return the size of the serialized field. */ uint32_t GetSerializedSize() const; + /** * Serialize the entire Capability Information Field. + * * \param i an iterator which points to where the Capability information field * should be written. * \return an iterator. */ Buffer::Iterator Serialize(Buffer::Iterator i) const; + /** * Deserialize the entire Capability Information Field. + * * \param i an iterator which points to where the Capability information field should be read. * \return an iterator. */ Buffer::Iterator Deserialize(Buffer::Iterator i); + /** * True if the device type is a Full Functional Device (FFD) false if is a Reduced Functional * Device (RFD). + * * \return True if the device type is a Full Functional Device (FFD) false if is a Reduced * Functional Device (RFD). */ bool IsDeviceTypeFfd() const; + /** * True if the device is receiving power from alternating current mains. + * * \return True if the device is receiving power from alternating current mains. */ bool IsPowSrcAvailable() const; + /** * True if the device does not disable its receiver to conserve power during idle periods. + * * \return True if the device does not disable its receiver to conserve power during idle * periods. */ bool IsReceiverOnWhenIdle() const; + /** * True if the device is capable of sending and receiving cryptographically protected MAC * frames. + * * \return True if the device is capable of sending and receiving cryptographically protected * MAC frames. */ bool IsSecurityCapability() const; + /** * True if the device wishes the coordinator to allocate a short address as result of the * association procedure. + * * \return True if the device wishes the coordinator to allocate a short address as result of * the association procedure. */ bool IsShortAddrAllocOn() const; + /** * Set the Device type in the Capability Information Field. * True = full functional device (FFD) False = reduced functional device (RFD). + * * \param devType The device type described in the Capability Information Field. */ void SetFfdDevice(bool devType); + /** * Set the Power Source available flag in the Capability Information Field. + * * \param pow Set true if a Power Source is available in the Capability Information Field. */ void SetPowSrcAvailable(bool pow); + /** * Indicate if the receiver is On on Idle + * * \param rxIdle Set true if the receiver is on when Idle */ void SetRxOnWhenIdle(bool rxIdle); + /** * Set the Security Capability flag in the Capability Information Field. + * * \param sec Set true if the device have Security Capabilities. */ void SetSecurityCap(bool sec); + /** * Set the Short Address Flag in the Capability Information Field. + * * \param addrAlloc Describes whether or not the coordinator should allocate a short * address in the association process. */ void SetShortAddrAllocOn(bool addrAlloc); private: + bool m_reservedBit0; //!< Capability Information Field, Reserved (bit 0) bool m_deviceType; //!< Capability Information Field, Device Type (bit 1) bool m_powerSource; //!< Capability Information Field, Power Source (bit 2) bool m_receiverOnWhenIdle; //!< Capability Information Field, Receiver On When Idle (bit 3) + uint8_t m_reservedBit45; //!< Capability Information Field, Reserved (bit 4 & 5) bool m_securityCap; //!< Capability Information Field, Security Capability (bit 6) bool m_allocAddr; //!< Capability Information Field, Allocate Address (bit 7) }; diff --git a/src/lr-wpan/model/lr-wpan-interference-helper.cc b/src/lr-wpan/model/lr-wpan-interference-helper.cc index beba86404..7c1605be6 100644 --- a/src/lr-wpan/model/lr-wpan-interference-helper.cc +++ b/src/lr-wpan/model/lr-wpan-interference-helper.cc @@ -95,9 +95,8 @@ LrWpanInterferenceHelper::GetSignalPsd() const if (m_dirty) { // Sum up the current interference PSD. - std::set>::const_iterator it; m_signal = Create(m_spectrumModel); - for (it = m_signals.begin(); it != m_signals.end(); ++it) + for (auto it = m_signals.begin(); it != m_signals.end(); ++it) { *m_signal += *(*it); } diff --git a/src/lr-wpan/model/lr-wpan-mac-trailer.cc b/src/lr-wpan/model/lr-wpan-mac-trailer.cc index 47ba4c16b..7827e6fb2 100644 --- a/src/lr-wpan/model/lr-wpan-mac-trailer.cc +++ b/src/lr-wpan/model/lr-wpan-mac-trailer.cc @@ -93,7 +93,7 @@ LrWpanMacTrailer::SetFcs(Ptr p) if (m_calcFcs) { uint16_t size = p->GetSize(); - uint8_t* serial_packet = new uint8_t[size]; + auto serial_packet = new uint8_t[size]; p->CopyData(serial_packet, size); @@ -115,7 +115,7 @@ LrWpanMacTrailer::CheckFcs(Ptr p) { uint16_t checkFcs; uint16_t size = p->GetSize(); - uint8_t* serial_packet = new uint8_t[size]; + auto serial_packet = new uint8_t[size]; p->CopyData(serial_packet, size); diff --git a/src/lr-wpan/model/lr-wpan-mac.cc b/src/lr-wpan/model/lr-wpan-mac.cc index 94cd8d45a..4d6a43f1e 100644 --- a/src/lr-wpan/model/lr-wpan-mac.cc +++ b/src/lr-wpan/model/lr-wpan-mac.cc @@ -183,6 +183,7 @@ LrWpanMac::LrWpanMac() m_numCsmacaRetry = 0; m_txPkt = nullptr; m_rxPkt = nullptr; + m_lastRxFrameLqi = 0; m_ifs = 0; m_macLIFSPeriod = 40; @@ -847,7 +848,7 @@ LrWpanMac::MlmeSyncRequest(MlmeSyncRequestParams params) NS_LOG_FUNCTION(this); NS_ASSERT(params.m_logCh <= 26 && m_macPanId != 0xffff); - uint64_t symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second + auto symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second // change phy current logical channel Ptr pibAttr = Create(); pibAttr->phyCurrentChannel = params.m_logCh; @@ -1659,7 +1660,7 @@ LrWpanMac::AwaitBeacon() void LrWpanMac::BeaconSearchTimeout() { - uint64_t symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second + auto symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second if (m_numLostBeacons > lrwpan::aMaxLostBeacons) { @@ -1871,8 +1872,8 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) // srcPanId = m_macPanId if only srcAddr field in Data or Command frame,accept frame if // srcPanId=m_macPanId - Ptr originalPkt = p->Copy(); // because we will strip headers - uint64_t symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second + Ptr originalPkt = p->Copy(); // because we will strip headers + auto symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second m_promiscSnifferTrace(originalPkt); m_macPromiscRxTrace(originalPkt); @@ -1974,21 +1975,6 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) (m_macPanId == 0xffff && receivedMacHdr.IsCommand()); } - if (acceptFrame && (receivedMacHdr.GetShortDstAddr() == Mac16Address("FF:FF"))) - { - // TODO: shouldn't this be filtered by the PHY? - // A broadcast message (e.g. beacons, orphan notifications) should not be received - // by the device who issues it. - if (receivedMacHdr.GetSrcAddrMode() == EXT_ADDR) - { - acceptFrame = (receivedMacHdr.GetExtSrcAddr() != GetExtendedAddress()); - } - else - { - acceptFrame = (receivedMacHdr.GetShortSrcAddr() != GetShortAddress()); - } - } - if (acceptFrame && (receivedMacHdr.GetDstAddrMode() == SHORT_ADDR)) { if (receivedMacHdr.GetShortDstAddr() == m_shortAddress) @@ -2108,9 +2094,10 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) m_setMacState.Cancel(); ChangeMacState(MAC_IDLE); - // save received packet to process the appropriate indication/response after - // sending ACK (PD-DATA.confirm) + // save received packet and LQI to process the appropriate indication/response + // after sending ACK (PD-DATA.confirm) m_rxPkt = originalPkt->Copy(); + m_lastRxFrameLqi = lqi; // LOG Commands with ACK required. CommandPayloadHeader receivedMacPayload; @@ -2680,7 +2667,7 @@ LrWpanMac::AckWaitTimeout() void LrWpanMac::IfsWaitTimeout(Time ifsTime) { - uint64_t symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); + auto symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); Time lifsTime = Seconds((double)m_macLIFSPeriod / symbolRate); Time sifsTime = Seconds((double)m_macSIFSPeriod / symbolRate); @@ -2947,34 +2934,37 @@ LrWpanMac::PurgeInd() } void -LrWpanMac::PrintPendTxQ(std::ostream& os) const +LrWpanMac::PrintPendingTxQueue(std::ostream& os) const { LrWpanMacHeader peekedMacHdr; os << "Pending Transaction List [" << GetShortAddress() << " | " << GetExtendedAddress() << "] | CurrentTime: " << Simulator::Now().As(Time::S) << "\n" - << " Destination | Sequence Number | Frame type | Expire time\n"; + << " Destination |" + << " Sequence Number |" + << " Frame type |" + << " Expire time\n"; - for (uint32_t i = 0; i < m_indTxQueue.size(); i++) + for (auto transaction : m_indTxQueue) { - m_indTxQueue[i]->txQPkt->PeekHeader(peekedMacHdr); - os << m_indTxQueue[i]->dstExtAddress << " " - << static_cast(m_indTxQueue[i]->seqNum) << " "; + transaction->txQPkt->PeekHeader(peekedMacHdr); + os << transaction->dstExtAddress << " " + << static_cast(transaction->seqNum) << " "; if (peekedMacHdr.IsCommand()) { - os << "Cmd Frame "; + os << " Command Frame "; } else if (peekedMacHdr.IsData()) { - os << "Data Frame "; + os << " Data Frame "; } else { - os << "Unk Frame "; + os << " Unknown Frame "; } - os << m_indTxQueue[i]->expireTime.As(Time::S) << "\n"; + os << transaction->expireTime.As(Time::S) << "\n"; } } @@ -2985,11 +2975,14 @@ LrWpanMac::PrintTxQueue(std::ostream& os) const os << "\nTx Queue [" << GetShortAddress() << " | " << GetExtendedAddress() << "] | CurrentTime: " << Simulator::Now().As(Time::S) << "\n" - << " Destination | Sequence Number | Dst PAN id | Frame type |\n"; + << " Destination |" + << " Sequence Number |" + << " Dst PAN id |" + << " Frame type |\n"; - for (uint32_t i = 0; i < m_indTxQueue.size(); i++) + for (auto transaction : m_txQueue) { - m_txQueue[i]->txQPkt->PeekHeader(peekedMacHdr); + transaction->txQPkt->PeekHeader(peekedMacHdr); os << "[" << peekedMacHdr.GetShortDstAddr() << "]" << ", [" << peekedMacHdr.GetExtDstAddr() << "] " @@ -2998,15 +2991,15 @@ LrWpanMac::PrintTxQueue(std::ostream& os) const if (peekedMacHdr.IsCommand()) { - os << "Cmd Frame "; + os << " Command Frame "; } else if (peekedMacHdr.IsData()) { - os << "Data Frame "; + os << " Data Frame "; } else { - os << "Unk Frame "; + os << " Unknown Frame "; } os << "\n"; @@ -3185,9 +3178,13 @@ LrWpanMac::PdDataConfirm(LrWpanPhyEnumeration status) { if (!m_mlmeAssociateIndicationCallback.IsNull()) { + // NOTE: The LQI parameter is not part of the standard but found + // in some implementations as is required for higher layers (See Zboss + // implementation). MlmeAssociateIndicationParams associateParams; associateParams.capabilityInfo = receivedMacPayload.GetCapabilityField(); associateParams.m_extDevAddr = receivedMacHdr.GetExtSrcAddr(); + associateParams.lqi = m_lastRxFrameLqi; m_mlmeAssociateIndicationCallback(associateParams); } @@ -3202,15 +3199,13 @@ LrWpanMac::PdDataConfirm(LrWpanPhyEnumeration status) switch (receivedMacPayload.GetAssociationStatus()) { case CommandPayloadHeader::SUCCESSFUL: - confirmParams.m_status = - LrWpanMlmeAssociateConfirmStatus::MLMEASSOC_SUCCESS; - // The original short address used in the association - // used in the association request - confirmParams.m_assocShortAddr = GetShortAddress(); - // The assigned short address by the coordinator SetShortAddress(receivedMacPayload.GetShortAddr()); m_macPanId = receivedMacHdr.GetSrcPanId(); + + confirmParams.m_status = + LrWpanMlmeAssociateConfirmStatus::MLMEASSOC_SUCCESS; + confirmParams.m_assocShortAddr = GetShortAddress(); break; case CommandPayloadHeader::FULL_CAPACITY: confirmParams.m_status = @@ -3424,7 +3419,7 @@ LrWpanMac::PlmeSetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttribu { if (status == LrWpanPhyEnumeration::IEEE_802_15_4_PHY_SUCCESS) { - uint64_t symbolRate = static_cast(m_phy->GetDataOrSymbolRate(false)); + auto symbolRate = static_cast(m_phy->GetDataOrSymbolRate(false)); Time nextScanTime; if (m_scanParams.m_scanType == MLMESCAN_ORPHAN) diff --git a/src/lr-wpan/model/lr-wpan-mac.h b/src/lr-wpan/model/lr-wpan-mac.h index 02022f19e..a90cfac34 100644 --- a/src/lr-wpan/model/lr-wpan-mac.h +++ b/src/lr-wpan/model/lr-wpan-mac.h @@ -25,9 +25,10 @@ #ifndef LR_WPAN_MAC_H #define LR_WPAN_MAC_H +#include "lr-wpan-fields.h" +#include "lr-wpan-phy.h" + #include -#include -#include #include #include #include @@ -447,9 +448,11 @@ struct McpsDataIndicationParams */ struct MlmeAssociateIndicationParams { - Mac64Address m_extDevAddr; //!< The extended address of the device requesting association - CapabilityField - capabilityInfo; //!< The operational capabilities of the device requesting association. + Mac64Address m_extDevAddr; //!< The extended address of the device requesting association + CapabilityField capabilityInfo; //!< The operational capabilities of + //!< the device requesting association. + uint8_t lqi{0}; //!< The link quality indicator of the received associate request command + //!< (Not officially supported in the standard but found in implementations) }; /** @@ -1584,7 +1587,7 @@ class LrWpanMac : public Object * Print the Pending transaction list. * \param os The reference to the output stream used by this print function. */ - void PrintPendTxQ(std::ostream& os) const; + void PrintPendingTxQueue(std::ostream& os) const; /** * Print the Transmit Queue. @@ -2218,6 +2221,11 @@ class LrWpanMac : public Object */ uint8_t m_numCsmacaRetry; + /** + * Keep track of the last received frame Link Quality Indicator + */ + uint8_t m_lastRxFrameLqi; + /** * Scheduler event for the ACK timeout of the currently transmitted data * packet. diff --git a/src/lr-wpan/model/lr-wpan-net-device.h b/src/lr-wpan/model/lr-wpan-net-device.h index 5d7ff5891..a607008f8 100644 --- a/src/lr-wpan/model/lr-wpan-net-device.h +++ b/src/lr-wpan/model/lr-wpan-net-device.h @@ -22,7 +22,8 @@ #ifndef LR_WPAN_NET_DEVICE_H #define LR_WPAN_NET_DEVICE_H -#include +#include "lr-wpan-mac.h" + #include #include diff --git a/src/lr-wpan/test/lr-wpan-mac-test.cc b/src/lr-wpan/test/lr-wpan-mac-test.cc index 9f77df6f8..c7cedfa21 100644 --- a/src/lr-wpan/test/lr-wpan-mac-test.cc +++ b/src/lr-wpan/test/lr-wpan-mac-test.cc @@ -308,6 +308,7 @@ class TestActiveScanPanDescriptors : public TestCase * \param params MLME scan confirm parameters */ void ScanConfirm(MlmeScanConfirmParams params); + /** * Function used to notify the reception of a beacon with payload. * @@ -380,9 +381,16 @@ TestActiveScanPanDescriptors::DoRun() Ptr endNodeNetDevice = CreateObject(); Ptr coord2NetDevice = CreateObject(); - coord1NetDevice->SetAddress(Mac16Address("00:01")); - endNodeNetDevice->SetAddress(Mac16Address("00:02")); - coord2NetDevice->SetAddress(Mac16Address("00:03")); + // PAN coordinators typically have a short address = 00:00 (e.g. Zigbee networks) + coord1NetDevice->GetMac()->SetExtendedAddress("00:00:00:00:00:00:CA:FE"); + coord1NetDevice->GetMac()->SetShortAddress(Mac16Address("00:00")); + + coord2NetDevice->GetMac()->SetExtendedAddress("00:00:00:00:00:00:BE:BE"); + coord2NetDevice->GetMac()->SetShortAddress(Mac16Address("00:00")); + + // An end device currently not associated (short address = ff:ff) + endNodeNetDevice->GetMac()->SetExtendedAddress("00:00:00:00:00:00:00:03"); + endNodeNetDevice->GetMac()->SetShortAddress(Mac16Address("ff:ff")); // Configure Spectrum channel Ptr channel = CreateObject(); diff --git a/src/lte/examples/lena-cc-helper.cc b/src/lte/examples/lena-cc-helper.cc index 066cc8fa8..db7ce5d97 100644 --- a/src/lte/examples/lena-cc-helper.cc +++ b/src/lte/examples/lena-cc-helper.cc @@ -44,10 +44,8 @@ main(int argc, char* argv[]) std::map ccm = cch->EquallySpacedCcs(); - std::map::iterator it; - std::cout << " CcMap size " << ccm.size() << std::endl; - for (it = ccm.begin(); it != ccm.end(); it++) + for (auto it = ccm.begin(); it != ccm.end(); it++) { Print(it->second); } diff --git a/src/lte/examples/lena-deactivate-bearer.cc b/src/lte/examples/lena-deactivate-bearer.cc index 01805ed69..466162fd1 100644 --- a/src/lte/examples/lena-deactivate-bearer.cc +++ b/src/lte/examples/lena-deactivate-bearer.cc @@ -69,7 +69,7 @@ main(int argc, char* argv[]) Ptr pgw = epcHelper->GetPgwNode(); // Enable Logging - LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); + auto logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); LogComponentEnable("BearerDeactivateExample", LOG_LEVEL_ALL); LogComponentEnable("LteHelper", logLevel); diff --git a/src/lte/examples/lena-distributed-ffr.cc b/src/lte/examples/lena-distributed-ffr.cc index 599911000..25e15b36d 100644 --- a/src/lte/examples/lena-distributed-ffr.cc +++ b/src/lte/examples/lena-distributed-ffr.cc @@ -45,7 +45,7 @@ PrintGnuplottableUeListToFile(std::string filename) NS_LOG_ERROR("Can't open file " << filename); return; } - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); @@ -74,7 +74,7 @@ PrintGnuplottableEnbListToFile(std::string filename) NS_LOG_ERROR("Can't open file " << filename); return; } - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); diff --git a/src/lte/examples/lena-dual-stripe.cc b/src/lte/examples/lena-dual-stripe.cc index 9df5111ea..1bb612ddf 100644 --- a/src/lte/examples/lena-dual-stripe.cc +++ b/src/lte/examples/lena-dual-stripe.cc @@ -158,7 +158,7 @@ FemtocellBlockAllocator::Create() bool FemtocellBlockAllocator::OverlapsWithAnyPrevious(Box box) { - for (std::list::iterator it = m_previousBlocks.begin(); it != m_previousBlocks.end(); ++it) + for (auto it = m_previousBlocks.begin(); it != m_previousBlocks.end(); ++it) { if (AreOverlapping(*it, box)) { @@ -184,7 +184,7 @@ PrintGnuplottableBuildingListToFile(std::string filename) return; } uint32_t index = 0; - for (BuildingList::Iterator it = BuildingList::Begin(); it != BuildingList::End(); ++it) + for (auto it = BuildingList::Begin(); it != BuildingList::End(); ++it) { ++index; Box box = (*it)->GetBoundaries(); @@ -208,7 +208,7 @@ PrintGnuplottableUeListToFile(std::string filename) NS_LOG_ERROR("Can't open file " << filename); return; } - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); @@ -242,7 +242,7 @@ PrintGnuplottableEnbListToFile(std::string filename) NS_LOG_ERROR("Can't open file " << filename); return; } - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); @@ -714,7 +714,7 @@ main(int argc, char* argv[]) // forcing initialization so we don't have to wait for Nodes to // start before positions are assigned (which is needed to // output node positions to file and to make AttachToClosestEnb work) - for (NodeContainer::Iterator it = macroUes.Begin(); it != macroUes.End(); ++it) + for (auto it = macroUes.Begin(); it != macroUes.End(); ++it) { (*it)->Initialize(); } diff --git a/src/lte/examples/lena-frequency-reuse.cc b/src/lte/examples/lena-frequency-reuse.cc index 926039584..5d727349a 100644 --- a/src/lte/examples/lena-frequency-reuse.cc +++ b/src/lte/examples/lena-frequency-reuse.cc @@ -41,7 +41,7 @@ PrintGnuplottableUeListToFile(std::string filename) NS_LOG_ERROR("Can't open file " << filename); return; } - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); @@ -70,7 +70,7 @@ PrintGnuplottableEnbListToFile(std::string filename) NS_LOG_ERROR("Can't open file " << filename); return; } - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); diff --git a/src/lte/examples/lena-radio-link-failure.cc b/src/lte/examples/lena-radio-link-failure.cc index 5f73b87f9..f9f8be365 100644 --- a/src/lte/examples/lena-radio-link-failure.cc +++ b/src/lte/examples/lena-radio-link-failure.cc @@ -49,7 +49,7 @@ uint32_t oldByteCounter = 0; //!< Old Byte counter, void PrintUePosition(uint64_t imsi) { - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); @@ -381,7 +381,7 @@ main(int argc, char* argv[]) if (enableNsLogs) { - LogLevel logLevel = + auto logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_NODE | LOG_PREFIX_TIME | LOG_LEVEL_ALL); LogComponentEnable("LteUeRrc", logLevel); LogComponentEnable("LteUeMac", logLevel); @@ -632,7 +632,7 @@ main(int argc, char* argv[]) Config::ConnectWithoutContext(oss.str(), MakeCallback(&ReceivePacket)); bool firstWrite = true; - std::string rrcType = useIdealRrc == 1 ? "ideal_rrc" : "real_rrc"; + std::string rrcType = useIdealRrc ? "ideal_rrc" : "real_rrc"; std::string fileName = "rlf_dl_thrput_" + std::to_string(enbNodes.GetN()) + "_eNB_" + rrcType; Time binSize = Seconds(0.2); Simulator::Schedule(Seconds(0.47), &Throughput, firstWrite, binSize, fileName); diff --git a/src/lte/helper/lte-global-pathloss-database.cc b/src/lte/helper/lte-global-pathloss-database.cc index 8804dca00..c360712f9 100644 --- a/src/lte/helper/lte-global-pathloss-database.cc +++ b/src/lte/helper/lte-global-pathloss-database.cc @@ -38,14 +38,9 @@ void LteGlobalPathlossDatabase::Print() { NS_LOG_FUNCTION(this); - for (std::map>::const_iterator cellIdIt = - m_pathlossMap.begin(); - cellIdIt != m_pathlossMap.end(); - ++cellIdIt) + for (auto cellIdIt = m_pathlossMap.begin(); cellIdIt != m_pathlossMap.end(); ++cellIdIt) { - for (std::map::const_iterator imsiIt = cellIdIt->second.begin(); - imsiIt != cellIdIt->second.end(); - ++imsiIt) + for (auto imsiIt = cellIdIt->second.begin(); imsiIt != cellIdIt->second.end(); ++imsiIt) { std::cout << "CellId: " << cellIdIt->first << " IMSI: " << imsiIt->first << " pathloss: " << imsiIt->second << " dB" << std::endl; @@ -57,12 +52,12 @@ double LteGlobalPathlossDatabase::GetPathloss(uint16_t cellId, uint64_t imsi) { NS_LOG_FUNCTION(this); - std::map>::iterator cellIt = m_pathlossMap.find(cellId); + auto cellIt = m_pathlossMap.find(cellId); if (cellIt == m_pathlossMap.end()) { return std::numeric_limits::infinity(); } - std::map::iterator ueIt = cellIt->second.find(imsi); + auto ueIt = cellIt->second.find(imsi); if (ueIt == cellIt->second.end()) { return std::numeric_limits::infinity(); diff --git a/src/lte/helper/lte-helper.cc b/src/lte/helper/lte-helper.cc index e2a1cc784..08f1eb978 100644 --- a/src/lte/helper/lte-helper.cc +++ b/src/lte/helper/lte-helper.cc @@ -487,7 +487,7 @@ LteHelper::InstallEnbDevice(NodeContainer c) NS_LOG_FUNCTION(this); Initialize(); // will run DoInitialize () if necessary NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr device = InstallSingleEnbDevice(node); @@ -501,7 +501,7 @@ LteHelper::InstallUeDevice(NodeContainer c) { NS_LOG_FUNCTION(this); NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr device = InstallSingleUeDevice(node); @@ -531,8 +531,7 @@ LteHelper::InstallSingleEnbDevice(Ptr n) << ")"); // create component carrier map for this eNb device std::map> ccMap; - for (std::map::iterator it = m_componentCarrierPhyParams.begin(); - it != m_componentCarrierPhyParams.end(); + for (auto it = m_componentCarrierPhyParams.begin(); it != m_componentCarrierPhyParams.end(); ++it) { Ptr cc = CreateObject(); @@ -752,7 +751,7 @@ LteHelper::InstallSingleEnbDevice(Ptr n) dev->SetAttribute("CellId", UintegerValue(cellId)); dev->SetAttribute("LteEnbComponentCarrierManager", PointerValue(ccmEnbManager)); dev->SetCcMap(ccMap); - std::map>::iterator it = ccMap.begin(); + auto it = ccMap.begin(); dev->SetAttribute("LteEnbRrc", PointerValue(rrc)); dev->SetAttribute("LteHandoverAlgorithm", PointerValue(handoverAlgorithm)); dev->SetAttribute( @@ -848,8 +847,7 @@ LteHelper::InstallSingleUeDevice(Ptr n) << ")"); std::map> ueCcMap; - for (std::map::iterator it = m_componentCarrierPhyParams.begin(); - it != m_componentCarrierPhyParams.end(); + for (auto it = m_componentCarrierPhyParams.begin(); it != m_componentCarrierPhyParams.end(); ++it) { Ptr cc = CreateObject(); @@ -867,9 +865,7 @@ LteHelper::InstallSingleUeDevice(Ptr n) // CC map is not needed anymore m_componentCarrierPhyParams.clear(); - for (std::map>::iterator it = ueCcMap.begin(); - it != ueCcMap.end(); - ++it) + for (auto it = ueCcMap.begin(); it != ueCcMap.end(); ++it) { Ptr dlPhy = CreateObject(); Ptr ulPhy = CreateObject(); @@ -971,9 +967,7 @@ LteHelper::InstallSingleUeDevice(Ptr n) nas->SetAsSapProvider(rrc->GetAsSapProvider()); rrc->SetAsSapUser(nas->GetAsSapUser()); - for (std::map>::iterator it = ueCcMap.begin(); - it != ueCcMap.end(); - ++it) + for (auto it = ueCcMap.begin(); it != ueCcMap.end(); ++it) { rrc->SetLteUeCmacSapProvider(it->second->GetMac()->GetLteUeCmacSapProvider(), it->first); it->second->GetMac()->SetLteUeCmacSapUser(rrc->GetLteUeCmacSapUser(it->first)); @@ -1009,9 +1003,7 @@ LteHelper::InstallSingleUeDevice(Ptr n) // when the default PDP context is created. This is a simplification. dev->SetAddress(Mac64Address::Allocate()); - for (std::map>::iterator it = ueCcMap.begin(); - it != ueCcMap.end(); - ++it) + for (auto it = ueCcMap.begin(); it != ueCcMap.end(); ++it) { Ptr ccPhy = it->second->GetPhy(); ccPhy->SetDevice(dev); @@ -1047,7 +1039,7 @@ void LteHelper::Attach(NetDeviceContainer ueDevices) { NS_LOG_FUNCTION(this); - for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i) + for (auto i = ueDevices.Begin(); i != ueDevices.End(); ++i) { Attach(*i); } @@ -1089,7 +1081,7 @@ void LteHelper::Attach(NetDeviceContainer ueDevices, Ptr enbDevice) { NS_LOG_FUNCTION(this); - for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i) + for (auto i = ueDevices.Begin(); i != ueDevices.End(); ++i) { Attach(*i, enbDevice); } @@ -1130,7 +1122,7 @@ void LteHelper::AttachToClosestEnb(NetDeviceContainer ueDevices, NetDeviceContainer enbDevices) { NS_LOG_FUNCTION(this); - for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i) + for (auto i = ueDevices.Begin(); i != ueDevices.End(); ++i) { AttachToClosestEnb(*i, enbDevices); } @@ -1144,7 +1136,7 @@ LteHelper::AttachToClosestEnb(Ptr ueDevice, NetDeviceContainer enbDev Vector uepos = ueDevice->GetNode()->GetObject()->GetPosition(); double minDistance = std::numeric_limits::infinity(); Ptr closestEnbDevice; - for (NetDeviceContainer::Iterator i = enbDevices.Begin(); i != enbDevices.End(); ++i) + for (auto i = enbDevices.Begin(); i != enbDevices.End(); ++i) { Vector enbpos = (*i)->GetNode()->GetObject()->GetPosition(); double distance = CalculateDistance(uepos, enbpos); @@ -1164,7 +1156,7 @@ LteHelper::ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, Ptr tft) { NS_LOG_FUNCTION(this); - for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i) + for (auto i = ueDevices.Begin(); i != ueDevices.End(); ++i) { uint8_t bearerId = ActivateDedicatedEpsBearer(*i, bearer, tft); return bearerId; @@ -1324,9 +1316,9 @@ LteHelper::AddX2Interface(NodeContainer enbNodes) NS_ASSERT_MSG(m_epcHelper, "X2 interfaces cannot be set up when the EPC is not used"); - for (NodeContainer::Iterator i = enbNodes.Begin(); i != enbNodes.End(); ++i) + for (auto i = enbNodes.Begin(); i != enbNodes.End(); ++i) { - for (NodeContainer::Iterator j = i + 1; j != enbNodes.End(); ++j) + for (auto j = i + 1; j != enbNodes.End(); ++j) { AddX2Interface(*i, *j); } @@ -1444,7 +1436,7 @@ void LteHelper::ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer) { NS_LOG_FUNCTION(this); - for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i) + for (auto i = ueDevices.Begin(); i != ueDevices.End(); ++i) { ActivateDataRadioBearer(*i, bearer); } @@ -1585,15 +1577,14 @@ LteHelper::AssignStreams(NetDeviceContainer c, int64_t stream) } } Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr lteEnb = DynamicCast(netDevice); if (lteEnb) { std::map> tmpMap = lteEnb->GetCcMap(); - std::map>::iterator it; - it = tmpMap.begin(); + auto it = tmpMap.begin(); Ptr dlPhy = DynamicCast(it->second)->GetPhy()->GetDownlinkSpectrumPhy(); Ptr ulPhy = @@ -1605,8 +1596,7 @@ LteHelper::AssignStreams(NetDeviceContainer c, int64_t stream) if (lteUe) { std::map> tmpMap = lteUe->GetCcMap(); - std::map>::iterator it; - it = tmpMap.begin(); + auto it = tmpMap.begin(); Ptr dlPhy = it->second->GetPhy()->GetDownlinkSpectrumPhy(); Ptr ulPhy = it->second->GetPhy()->GetUplinkSpectrumPhy(); Ptr ueMac = lteUe->GetMac(); diff --git a/src/lte/helper/no-backhaul-epc-helper.cc b/src/lte/helper/no-backhaul-epc-helper.cc index 0c7648bef..e66ef52ce 100644 --- a/src/lte/helper/no-backhaul-epc-helper.cc +++ b/src/lte/helper/no-backhaul-epc-helper.cc @@ -540,7 +540,7 @@ NoBackhaulEpcHelper::AssignUeIpv4Address(NetDeviceContainer ueDevices) Ipv6InterfaceContainer NoBackhaulEpcHelper::AssignUeIpv6Address(NetDeviceContainer ueDevices) { - for (NetDeviceContainer::Iterator iter = ueDevices.Begin(); iter != ueDevices.End(); iter++) + for (auto iter = ueDevices.Begin(); iter != ueDevices.End(); iter++) { Ptr icmpv6 = (*iter)->GetNode()->GetObject(); icmpv6->SetAttribute("DAD", BooleanValue(false)); diff --git a/src/lte/helper/radio-bearer-stats-calculator.cc b/src/lte/helper/radio-bearer-stats-calculator.cc index 55d639cd5..8ac0d00c0 100644 --- a/src/lte/helper/radio-bearer-stats-calculator.cc +++ b/src/lte/helper/radio-bearer-stats-calculator.cc @@ -189,7 +189,7 @@ RadioBearerStatsCalculator::UlRxPdu(uint16_t cellId, m_ulRxPackets[p]++; m_ulRxData[p] += packetSize; - Uint64StatsMap::iterator it = m_ulDelay.find(p); + auto it = m_ulDelay.find(p); if (it == m_ulDelay.end()) { NS_LOG_DEBUG(this << " Creating UL stats calculators for IMSI " << p.m_imsi @@ -220,7 +220,7 @@ RadioBearerStatsCalculator::DlRxPdu(uint16_t cellId, m_dlRxPackets[p]++; m_dlRxData[p] += packetSize; - Uint64StatsMap::iterator it = m_dlDelay.find(p); + auto it = m_dlDelay.find(p); if (it == m_dlDelay.end()) { NS_LOG_DEBUG(this << " Creating DL stats calculators for IMSI " << p.m_imsi @@ -298,7 +298,7 @@ RadioBearerStatsCalculator::WriteUlResults(std::ofstream& outFile) // Get the unique IMSI/LCID pairs list std::vector pairVector; - for (Uint32Map::iterator it = m_ulTxPackets.begin(); it != m_ulTxPackets.end(); ++it) + for (auto it = m_ulTxPackets.begin(); it != m_ulTxPackets.end(); ++it) { if (find(pairVector.begin(), pairVector.end(), (*it).first) == pairVector.end()) { @@ -306,7 +306,7 @@ RadioBearerStatsCalculator::WriteUlResults(std::ofstream& outFile) } } - for (Uint32Map::iterator it = m_ulRxPackets.begin(); it != m_ulRxPackets.end(); ++it) + for (auto it = m_ulRxPackets.begin(); it != m_ulRxPackets.end(); ++it) { if (find(pairVector.begin(), pairVector.end(), (*it).first) == pairVector.end()) { @@ -315,11 +315,10 @@ RadioBearerStatsCalculator::WriteUlResults(std::ofstream& outFile) } Time endTime = m_startTime + m_epochDuration; - for (std::vector::iterator it = pairVector.begin(); it != pairVector.end(); - ++it) + for (auto it = pairVector.begin(); it != pairVector.end(); ++it) { ImsiLcidPair_t p = *it; - FlowIdMap::const_iterator flowIdIt = m_flowId.find(p); + auto flowIdIt = m_flowId.find(p); NS_ASSERT_MSG(flowIdIt != m_flowId.end(), "FlowId (imsi " << p.m_imsi << " lcid " << (uint32_t)p.m_lcId << ") is missing"); @@ -337,12 +336,12 @@ RadioBearerStatsCalculator::WriteUlResults(std::ofstream& outFile) outFile << GetUlRxPackets(p.m_imsi, p.m_lcId) << "\t"; outFile << GetUlRxData(p.m_imsi, p.m_lcId) << "\t"; std::vector stats = GetUlDelayStats(p.m_imsi, p.m_lcId); - for (std::vector::iterator it = stats.begin(); it != stats.end(); ++it) + for (auto it = stats.begin(); it != stats.end(); ++it) { outFile << (*it) * 1e-9 << "\t"; } stats = GetUlPduSizeStats(p.m_imsi, p.m_lcId); - for (std::vector::iterator it = stats.begin(); it != stats.end(); ++it) + for (auto it = stats.begin(); it != stats.end(); ++it) { outFile << (*it) << "\t"; } @@ -359,7 +358,7 @@ RadioBearerStatsCalculator::WriteDlResults(std::ofstream& outFile) // Get the unique IMSI/LCID pairs list std::vector pairVector; - for (Uint32Map::iterator it = m_dlTxPackets.begin(); it != m_dlTxPackets.end(); ++it) + for (auto it = m_dlTxPackets.begin(); it != m_dlTxPackets.end(); ++it) { if (find(pairVector.begin(), pairVector.end(), (*it).first) == pairVector.end()) { @@ -367,7 +366,7 @@ RadioBearerStatsCalculator::WriteDlResults(std::ofstream& outFile) } } - for (Uint32Map::iterator it = m_dlRxPackets.begin(); it != m_dlRxPackets.end(); ++it) + for (auto it = m_dlRxPackets.begin(); it != m_dlRxPackets.end(); ++it) { if (find(pairVector.begin(), pairVector.end(), (*it).first) == pairVector.end()) { @@ -376,11 +375,10 @@ RadioBearerStatsCalculator::WriteDlResults(std::ofstream& outFile) } Time endTime = m_startTime + m_epochDuration; - for (std::vector::iterator pair = pairVector.begin(); pair != pairVector.end(); - ++pair) + for (auto pair = pairVector.begin(); pair != pairVector.end(); ++pair) { ImsiLcidPair_t p = *pair; - FlowIdMap::const_iterator flowIdIt = m_flowId.find(p); + auto flowIdIt = m_flowId.find(p); NS_ASSERT_MSG(flowIdIt != m_flowId.end(), "FlowId (imsi " << p.m_imsi << " lcid " << (uint32_t)p.m_lcId << ") is missing"); @@ -398,12 +396,12 @@ RadioBearerStatsCalculator::WriteDlResults(std::ofstream& outFile) outFile << GetDlRxPackets(p.m_imsi, p.m_lcId) << "\t"; outFile << GetDlRxData(p.m_imsi, p.m_lcId) << "\t"; std::vector stats = GetDlDelayStats(p.m_imsi, p.m_lcId); - for (std::vector::iterator it = stats.begin(); it != stats.end(); ++it) + for (auto it = stats.begin(); it != stats.end(); ++it) { outFile << (*it) * 1e-9 << "\t"; } stats = GetDlPduSizeStats(p.m_imsi, p.m_lcId); - for (std::vector::iterator it = stats.begin(); it != stats.end(); ++it) + for (auto it = stats.begin(); it != stats.end(); ++it) { outFile << (*it) << "\t"; } @@ -492,7 +490,7 @@ RadioBearerStatsCalculator::GetUlDelay(uint64_t imsi, uint8_t lcid) { NS_LOG_FUNCTION(this << imsi << (uint16_t)lcid); ImsiLcidPair_t p(imsi, lcid); - Uint64StatsMap::iterator it = m_ulDelay.find(p); + auto it = m_ulDelay.find(p); if (it == m_ulDelay.end()) { NS_LOG_ERROR("UL delay for " << imsi << " - " << (uint16_t)lcid << " not found"); @@ -507,7 +505,7 @@ RadioBearerStatsCalculator::GetUlDelayStats(uint64_t imsi, uint8_t lcid) NS_LOG_FUNCTION(this << imsi << (uint16_t)lcid); ImsiLcidPair_t p(imsi, lcid); std::vector stats; - Uint64StatsMap::iterator it = m_ulDelay.find(p); + auto it = m_ulDelay.find(p); if (it == m_ulDelay.end()) { stats.push_back(0.0); @@ -529,7 +527,7 @@ RadioBearerStatsCalculator::GetUlPduSizeStats(uint64_t imsi, uint8_t lcid) NS_LOG_FUNCTION(this << imsi << (uint16_t)lcid); ImsiLcidPair_t p(imsi, lcid); std::vector stats; - Uint32StatsMap::iterator it = m_ulPduSize.find(p); + auto it = m_ulPduSize.find(p); if (it == m_ulPduSize.end()) { stats.push_back(0.0); @@ -598,7 +596,7 @@ RadioBearerStatsCalculator::GetDlDelay(uint64_t imsi, uint8_t lcid) { NS_LOG_FUNCTION(this << imsi << (uint16_t)lcid); ImsiLcidPair_t p(imsi, lcid); - Uint64StatsMap::iterator it = m_dlDelay.find(p); + auto it = m_dlDelay.find(p); if (it == m_dlDelay.end()) { NS_LOG_ERROR("DL delay for " << imsi << " not found"); @@ -613,7 +611,7 @@ RadioBearerStatsCalculator::GetDlDelayStats(uint64_t imsi, uint8_t lcid) NS_LOG_FUNCTION(this << imsi << (uint16_t)lcid); ImsiLcidPair_t p(imsi, lcid); std::vector stats; - Uint64StatsMap::iterator it = m_dlDelay.find(p); + auto it = m_dlDelay.find(p); if (it == m_dlDelay.end()) { stats.push_back(0.0); @@ -635,7 +633,7 @@ RadioBearerStatsCalculator::GetDlPduSizeStats(uint64_t imsi, uint8_t lcid) NS_LOG_FUNCTION(this << imsi << (uint16_t)lcid); ImsiLcidPair_t p(imsi, lcid); std::vector stats; - Uint32StatsMap::iterator it = m_dlPduSize.find(p); + auto it = m_dlPduSize.find(p); if (it == m_dlPduSize.end()) { stats.push_back(0.0); diff --git a/src/lte/helper/radio-bearer-stats-connector.cc b/src/lte/helper/radio-bearer-stats-connector.cc index 8087eda10..42d073c23 100644 --- a/src/lte/helper/radio-bearer-stats-connector.cc +++ b/src/lte/helper/radio-bearer-stats-connector.cc @@ -259,7 +259,7 @@ RadioBearerStatsConnector::ConnectTracesSrb0(std::string context, CellIdRnti key; key.cellId = cellId; key.rnti = rnti; - std::map::iterator it = m_ueManagerPathByCellIdRnti.find(key); + auto it = m_ueManagerPathByCellIdRnti.find(key); NS_ASSERT(it != m_ueManagerPathByCellIdRnti.end()); std::string ueManagerPath = it->second; NS_LOG_LOGIC("ueManagerPath = " << ueManagerPath); @@ -290,7 +290,7 @@ RadioBearerStatsConnector::ConnectTracesSrb1(std::string context, CellIdRnti key; key.cellId = cellId; key.rnti = rnti; - std::map::iterator it = m_ueManagerPathByCellIdRnti.find(key); + auto it = m_ueManagerPathByCellIdRnti.find(key); NS_ASSERT(it != m_ueManagerPathByCellIdRnti.end()); std::string ueManagerPath = it->second; NS_LOG_LOGIC("ueManagerPath = " << ueManagerPath); diff --git a/src/lte/helper/radio-environment-map-helper.cc b/src/lte/helper/radio-environment-map-helper.cc index ace923ab1..fbec81832 100644 --- a/src/lte/helper/radio-environment-map-helper.cc +++ b/src/lte/helper/radio-environment-map-helper.cc @@ -306,7 +306,7 @@ void RadioEnvironmentMapHelper::RunOneIteration(double xMin, double xMax, double yMin, double yMax) { NS_LOG_FUNCTION(this << xMin << xMax << yMin << yMax); - std::list::iterator remIt = m_rem.begin(); + auto remIt = m_rem.begin(); double x = 0.0; double y = 0.0; for (x = xMin; x < xMax + 0.5 * m_xStep; x += m_xStep) @@ -342,7 +342,7 @@ RadioEnvironmentMapHelper::PrintAndReset() { NS_LOG_FUNCTION(this); - for (std::list::iterator it = m_rem.begin(); it != m_rem.end(); ++it) + for (auto it = m_rem.begin(); it != m_rem.end(); ++it) { if (!(it->phy->IsActive())) { diff --git a/src/lte/model/a2-a4-rsrq-handover-algorithm.cc b/src/lte/model/a2-a4-rsrq-handover-algorithm.cc index 0b0f93d37..46b0012c4 100644 --- a/src/lte/model/a2-a4-rsrq-handover-algorithm.cc +++ b/src/lte/model/a2-a4-rsrq-handover-algorithm.cc @@ -149,8 +149,7 @@ A2A4RsrqHandoverAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults { if (measResults.haveMeasResultNeighCells && !measResults.measResultListEutra.empty()) { - for (std::list::iterator it = - measResults.measResultListEutra.begin(); + for (auto it = measResults.measResultListEutra.begin(); it != measResults.measResultListEutra.end(); ++it) { @@ -177,8 +176,7 @@ A2A4RsrqHandoverAlgorithm::EvaluateHandover(uint16_t rnti, uint8_t servingCellRs { NS_LOG_FUNCTION(this << rnti << (uint16_t)servingCellRsrq); - MeasurementTable_t::iterator it1; - it1 = m_neighbourCellMeasures.find(rnti); + auto it1 = m_neighbourCellMeasures.find(rnti); if (it1 == m_neighbourCellMeasures.end()) { @@ -191,8 +189,7 @@ A2A4RsrqHandoverAlgorithm::EvaluateHandover(uint16_t rnti, uint8_t servingCellRs NS_LOG_LOGIC("Number of neighbour cells = " << it1->second.size()); uint16_t bestNeighbourCellId = 0; uint8_t bestNeighbourRsrq = 0; - MeasurementRow_t::iterator it2; - for (it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) + for (auto it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { if ((it2->second->m_rsrq > bestNeighbourRsrq) && IsValidNeighbour(it2->first)) { @@ -239,23 +236,20 @@ void A2A4RsrqHandoverAlgorithm::UpdateNeighbourMeasurements(uint16_t rnti, uint16_t cellId, uint8_t rsrq) { NS_LOG_FUNCTION(this << rnti << cellId << (uint16_t)rsrq); - MeasurementTable_t::iterator it1; - it1 = m_neighbourCellMeasures.find(rnti); + auto it1 = m_neighbourCellMeasures.find(rnti); if (it1 == m_neighbourCellMeasures.end()) { // insert a new UE entry MeasurementRow_t row; - std::pair ret; - ret = m_neighbourCellMeasures.insert(std::pair(rnti, row)); + auto ret = m_neighbourCellMeasures.insert(std::pair(rnti, row)); NS_ASSERT(ret.second); it1 = ret.first; } NS_ASSERT(it1 != m_neighbourCellMeasures.end()); Ptr neighbourCellMeasures; - std::map>::iterator it2; - it2 = it1->second.find(cellId); + auto it2 = it1->second.find(cellId); if (it2 != it1->second.end()) { diff --git a/src/lte/model/a3-rsrp-handover-algorithm.cc b/src/lte/model/a3-rsrp-handover-algorithm.cc index 32e117b62..fb15c6ff4 100644 --- a/src/lte/model/a3-rsrp-handover-algorithm.cc +++ b/src/lte/model/a3-rsrp-handover-algorithm.cc @@ -135,8 +135,7 @@ A3RsrpHandoverAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults me uint16_t bestNeighbourCellId = 0; uint8_t bestNeighbourRsrp = 0; - for (std::list::iterator it = - measResults.measResultListEutra.begin(); + for (auto it = measResults.measResultListEutra.begin(); it != measResults.measResultListEutra.end(); ++it) { diff --git a/src/lte/model/cqa-ff-mac-scheduler.cc b/src/lte/model/cqa-ff-mac-scheduler.cc index 4707e5704..d04b27c47 100644 --- a/src/lte/model/cqa-ff-mac-scheduler.cc +++ b/src/lte/model/cqa-ff-mac-scheduler.cc @@ -248,7 +248,7 @@ CqaFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -300,9 +300,7 @@ CqaFfMacScheduler::DoCschedLcConfigReq( // LTE MAC scheduler specification if (params.m_reconfigureFlag) { - std::vector::const_iterator lcit; - - for (lcit = params.m_logicalChannelConfigList.begin(); + for (auto lcit = params.m_logicalChannelConfigList.begin(); lcit != params.m_logicalChannelConfigList.end(); lcit++) { @@ -322,9 +320,7 @@ CqaFfMacScheduler::DoCschedLcConfigReq( } // else new UE is added else { - std::vector::const_iterator lcit; - - for (lcit = params.m_logicalChannelConfigList.begin(); + for (auto lcit = params.m_logicalChannelConfigList.begin(); lcit != params.m_logicalChannelConfigList.end(); lcit++) { @@ -334,11 +330,9 @@ CqaFfMacScheduler::DoCschedLcConfigReq( } } - std::map::iterator it; - for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -382,9 +376,9 @@ CqaFfMacScheduler::DoCschedLcReleaseReq( const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); - std::vector::const_iterator it; - for (it = params.m_logicalChannelIdentity.begin(); it != params.m_logicalChannelIdentity.end(); + for (auto it = params.m_logicalChannelIdentity.begin(); + it != params.m_logicalChannelIdentity.end(); it++) { LteFlowId_t flowId = LteFlowId_t(params.m_rnti, *it); @@ -404,15 +398,13 @@ CqaFfMacScheduler::DoCschedLcReleaseReq( for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -453,14 +445,12 @@ CqaFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -482,11 +472,9 @@ CqaFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -533,9 +521,8 @@ CqaFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int CqaFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -556,13 +543,12 @@ CqaFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -586,13 +572,12 @@ CqaFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -621,8 +606,7 @@ CqaFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -632,8 +616,7 @@ CqaFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -667,7 +650,6 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( int numberOfRBGs = m_cschedCellConfig.m_dlBandwidth / rbgSize; std::map> allocationMapPerRntiPerLCId; - std::map>::iterator itMap; allocationMapPerRntiPerLCId.clear(); bool (*key_function_pointer_groups)(int, int) = CqaGroupDescComparator; t_map_HOLgroupToUEs map_GBRHOLgroupToUE(key_function_pointer_groups); @@ -681,7 +663,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); - for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) + for (auto it = rbgMap.begin(); it != rbgMap.end(); it++) { if (*it) { @@ -691,9 +673,9 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -709,7 +691,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( uint16_t tmpFfrRbStartOffset = 0; uint16_t index = 0; - for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) + for (auto it = ulRbMap.begin(); it != ulRbMap.end(); it++) { if (*it) { @@ -740,8 +722,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -805,15 +786,13 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -855,7 +834,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -883,8 +862,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -905,16 +883,14 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1001,8 +977,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -1079,8 +1054,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -1093,15 +1067,14 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -1127,13 +1100,11 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( return; } - std::map::iterator itLogicalChannels; - - for (itLogicalChannels = m_ueLogicalChannelsConfigList.begin(); + for (auto itLogicalChannels = m_ueLogicalChannelsConfigList.begin(); itLogicalChannels != m_ueLogicalChannelsConfigList.end(); itLogicalChannels++) { - std::set::iterator itRnti = rntiAllocated.find(itLogicalChannels->first.m_rnti); + auto itRnti = rntiAllocated.find(itLogicalChannels->first.m_rnti); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability(itLogicalChannels->first.m_rnti))) { @@ -1151,8 +1122,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::map::iterator - itRlcBufferReq = m_rlcBufferReq.find(itLogicalChannels->first); + auto itRlcBufferReq = m_rlcBufferReq.find(itLogicalChannels->first); if (itRlcBufferReq == m_rlcBufferReq.end()) { continue; @@ -1219,17 +1189,12 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( // channels) that belong to the same RNTI std::map sbCqiSum; - for (std::map::iterator - itrbr = m_rlcBufferReq.begin(); - itrbr != m_rlcBufferReq.end(); - itrbr++) + for (auto itrbr = m_rlcBufferReq.begin(); itrbr != m_rlcBufferReq.end(); itrbr++) { LteFlowId_t flowId = itrbr->first; // Prepare data for the scheduling mechanism // check first the channel conditions for this UE, if CQI!=0 - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itrbr).first.m_rnti); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itrbr).first.m_rnti); + auto itCqi = m_a30CqiRxed.find((*itrbr).first.m_rnti); + auto itTxMode = m_uesTxMode.find((*itrbr).first.m_rnti); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itrbr).first.m_rnti); @@ -1270,10 +1235,8 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( uint8_t sum = 0; for (int i = 0; i < numberOfRBGs; i++) { - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itrbr).first.m_rnti); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itrbr).first.m_rnti); + auto itCqi = m_a30CqiRxed.find((*itrbr).first.m_rnti); + auto itTxMode = m_uesTxMode.find((*itrbr).first.m_rnti); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itrbr).first.m_rnti); @@ -1282,10 +1245,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( std::vector sbCqis; if (itCqi == m_a30CqiRxed.end()) { - for (uint8_t k = 0; k < nLayer; k++) - { - sbCqis.push_back(1); // start with lowest value - } + sbCqis = std::vector(nLayer, 1); // start with lowest value } else { @@ -1332,8 +1292,8 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( } } - t_it_HOLgroupToUEs itGBRgroups = map_GBRHOLgroupToUE.begin(); - t_it_HOLgroupToUEs itnonGBRgroups = map_nonGBRHOLgroupToUE.begin(); + auto itGBRgroups = map_GBRHOLgroupToUE.begin(); + auto itnonGBRgroups = map_nonGBRHOLgroupToUE.begin(); // while there are more resources available, loop through the users that are grouped by HOL // value @@ -1380,9 +1340,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( // Iterate through the users and calculate which user will use the best of the current // resource block.end() and assign to that user. - for (std::set::iterator it = itCurrentGroup->second.begin(); - it != itCurrentGroup->second.end(); - it++) + for (auto it = itCurrentGroup->second.begin(); it != itCurrentGroup->second.end(); it++) { LteFlowId_t flowId = *it; uint8_t cqi_value = 1; // higher better, maximum is 15 @@ -1393,10 +1351,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( int numberOfRBGAllocatedForThisUser = 0; LogicalChannelConfigListElement_s lc = m_ueLogicalChannelsConfigList.find(flowId)->second; - std::map::iterator itRntiCQIsMap = - m_a30CqiRxed.find(flowId.m_rnti); - - std::map::iterator itStats; + auto itRntiCQIsMap = m_a30CqiRxed.find(flowId.m_rnti); if (!m_ffrSapProvider->IsDlRbgAvailableForUe(currentRB, flowId.m_rnti)) { @@ -1409,7 +1364,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( } currentRBchecked = true; - itStats = m_flowStatsDl.find(flowId.m_rnti); + auto itStats = m_flowStatsDl.find(flowId.m_rnti); double tbr_weight = (*itStats).second.targetThroughput / (*itStats).second.lastAveragedThroughput; if (tbr_weight < 1.0) @@ -1419,9 +1374,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( if (itRntiCQIsMap != m_a30CqiRxed.end()) { - for (std::set::iterator it = availableRBGs.begin(); - it != availableRBGs.end(); - it++) + for (auto it = availableRBGs.begin(); it != availableRBGs.end(); it++) { try { @@ -1462,7 +1415,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( numberOfRBGAllocatedForThisUser = (allocationMapPerRntiPerLCId.find(flowId.m_rnti)->second.size()); - for (std::multimap::iterator itRBG = + for (auto itRBG = allocationMapPerRntiPerLCId.find(flowId.m_rnti)->second.begin(); itRBG != allocationMapPerRntiPerLCId.find(flowId.m_rnti)->second.end(); itRBG++) @@ -1564,7 +1517,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( s.cqi_value_for_lc = UeToCQIValue.find(userWithMaximumMetric)->second; s.resource_block_index = currentRB; - itMap = allocationMapPerRntiPerLCId.find(userWithMaximumMetric.m_rnti); + auto itMap = allocationMapPerRntiPerLCId.find(userWithMaximumMetric.m_rnti); if (itMap == allocationMapPerRntiPerLCId.end()) { @@ -1598,8 +1551,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( } // while there are more groups of users // reset TTI stats of users - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.lastTtiBytesTransmitted = 0; } @@ -1607,7 +1559,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( // 3) Creating the correspondent DCIs (Generate the transmission opportunities by grouping the // RBGs of the same RNTI) // FfMacSchedSapUser::SchedDlConfigIndParameters ret; - itMap = allocationMapPerRntiPerLCId.begin(); + auto itMap = allocationMapPerRntiPerLCId.begin(); std::map m_rnti_per_ratio; while (itMap != allocationMapPerRntiPerLCId.end()) @@ -1632,15 +1584,10 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( double doubleRbgNum = numberOfRBGs; double rrRatio = doubleRBgPerRnti / doubleRbgNum; m_rnti_per_ratio.insert(std::pair((*itMap).first, rrRatio)); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); uint8_t worstCqi = 15; // assign the worst value of CQI that user experienced on any of its subbands - for (std::multimap::iterator it = - (*itMap).second.begin(); - it != (*itMap).second.end(); - it++) + for (auto it = (*itMap).second.begin(); it != (*itMap).second.end(); it++) { if (it->second.cqi_value_for_lc < worstCqi) { @@ -1655,8 +1602,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( newDci.m_resAlloc = 0; // only allocation type 0 at this stage newDci.m_rbBitmap = 0; // TBD (32 bit bitmap see 7.1.6 of 36.213) uint32_t rbgMask = 0; - std::multimap::iterator itRBGsPerRNTI; - for (itRBGsPerRNTI = (*itMap).second.begin(); itRBGsPerRNTI != (*itMap).second.end(); + for (auto itRBGsPerRNTI = (*itMap).second.begin(); itRBGsPerRNTI != (*itMap).second.end(); itRBGsPerRNTI++) { rbgMask = rbgMask + (0x1 << itRBGsPerRNTI->second.resource_block_index); @@ -1664,9 +1610,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // NOTE: In this first version of CqaFfMacScheduler, it is assumed one flow per user. // create the rlc PDUs -> equally divide resources among active LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1689,8 +1633,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1720,8 +1663,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1729,8 +1671,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1742,8 +1683,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( ret.m_buildDataList.push_back(newEl); // update UE stats - std::map::iterator it; - it = m_flowStatsDl.find((*itMap).first); + auto it = m_flowStatsDl.find((*itMap).first); if (it != m_flowStatsDl.end()) { (*it).second.lastTtiBytesTransmitted = tbSize; @@ -1759,7 +1699,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( // update UEs stats NS_LOG_INFO(this << " Update UEs statistics"); - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { if (allocationMapPerRntiPerLCId.find(itStats->first) != allocationMapPerRntiPerLCId.end()) { @@ -1782,8 +1722,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( m_schedSapUser->SchedDlConfigInd(ret); int count_allocated_resource_blocks = 0; - for (std::map>::iterator itMap = - allocationMapPerRntiPerLCId.begin(); + for (auto itMap = allocationMapPerRntiPerLCId.begin(); itMap != allocationMapPerRntiPerLCId.end(); itMap++) { @@ -1814,9 +1753,8 @@ CqaFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1831,17 +1769,15 @@ CqaFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1854,8 +1790,7 @@ CqaFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1869,7 +1804,7 @@ CqaFfMacScheduler::DoSchedDlCqiInfoReq( double CqaFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1922,7 +1857,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( rbMap = m_ffrSapProvider->GetAvailableUlRbg(); - for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) + for (auto it = rbMap.begin(); it != rbMap.end(); it++) { if (*it) { @@ -1952,8 +1887,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1961,16 +1895,14 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -2030,7 +1962,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -2063,7 +1995,6 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( } int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -2085,7 +2016,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -2178,7 +2109,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( break; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -2249,15 +2180,13 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -2265,8 +2194,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -2282,7 +2210,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( << (uint16_t)harqId); // update TTI UE stats - itStats = m_flowStatsUl.find((*it).first); + auto itStats = m_flowStatsUl.find((*it).first); if (itStats != m_flowStatsUl.end()) { (*itStats).second.lastTtiBytesTransmitted = uldci.m_tbSize; @@ -2308,7 +2236,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( // Update global UE stats // update UEs stats - for (itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) + for (auto itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTransmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -2345,8 +2273,6 @@ CqaFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -2367,7 +2293,7 @@ CqaFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -2413,11 +2339,9 @@ CqaFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -2426,7 +2350,7 @@ CqaFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2456,8 +2380,7 @@ CqaFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2480,8 +2403,7 @@ CqaFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2508,8 +2430,7 @@ CqaFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2529,7 +2450,7 @@ void CqaFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -2537,12 +2458,12 @@ CqaFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -2554,7 +2475,7 @@ CqaFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -2562,12 +2483,12 @@ CqaFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -2583,7 +2504,7 @@ void CqaFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -2591,13 +2512,13 @@ CqaFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -2612,9 +2533,8 @@ CqaFfMacScheduler::RefreshUlCqiMaps() void CqaFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2669,7 +2589,7 @@ void CqaFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/epc-enb-application.cc b/src/lte/model/epc-enb-application.cc index 0b48d5c41..04f5e4e8b 100644 --- a/src/lte/model/epc-enb-application.cc +++ b/src/lte/model/epc-enb-application.cc @@ -164,9 +164,7 @@ EpcEnbApplication::DoPathSwitchRequest(EpcEnbS1SapProvider::PathSwitchRequestPar uint16_t gci = params.cellId; std::list erabToBeSwitchedInDownlinkList; - for (std::list::iterator bit = - params.bearersToBeSwitched.begin(); - bit != params.bearersToBeSwitched.end(); + for (auto bit = params.bearersToBeSwitched.begin(); bit != params.bearersToBeSwitched.end(); ++bit) { EpsFlowId_t flowId; @@ -193,12 +191,10 @@ void EpcEnbApplication::DoUeContextRelease(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map>::iterator rntiIt = m_rbidTeidMap.find(rnti); + auto rntiIt = m_rbidTeidMap.find(rnti); if (rntiIt != m_rbidTeidMap.end()) { - for (std::map::iterator bidIt = rntiIt->second.begin(); - bidIt != rntiIt->second.end(); - ++bidIt) + for (auto bidIt = rntiIt->second.begin(); bidIt != rntiIt->second.end(); ++bidIt) { uint32_t teid = bidIt->second; m_teidRbidMap.erase(teid); @@ -218,13 +214,11 @@ EpcEnbApplication::DoInitialContextSetupRequest( NS_LOG_FUNCTION(this); uint64_t imsi = mmeUeS1Id; - std::map::iterator imsiIt = m_imsiRntiMap.find(imsi); + auto imsiIt = m_imsiRntiMap.find(imsi); NS_ASSERT_MSG(imsiIt != m_imsiRntiMap.end(), "unknown IMSI"); uint16_t rnti = imsiIt->second; - for (std::list::iterator erabIt = erabToBeSetupList.begin(); - erabIt != erabToBeSetupList.end(); - ++erabIt) + for (auto erabIt = erabToBeSetupList.begin(); erabIt != erabToBeSetupList.end(); ++erabIt) { // request the RRC to setup a radio bearer EpcEnbS1SapUser::DataRadioBearerSetupRequestParameters params; @@ -256,7 +250,7 @@ EpcEnbApplication::DoPathSwitchRequestAcknowledge( NS_LOG_FUNCTION(this); uint64_t imsi = mmeUeS1Id; - std::map::iterator imsiIt = m_imsiRntiMap.find(imsi); + auto imsiIt = m_imsiRntiMap.find(imsi); NS_ASSERT_MSG(imsiIt != m_imsiRntiMap.end(), "unknown IMSI"); uint16_t rnti = imsiIt->second; EpcEnbS1SapUser::PathSwitchRequestAcknowledgeParameters params; @@ -283,15 +277,15 @@ EpcEnbApplication::RecvFromLteSocket(Ptr socket) NS_ASSERT(found); uint16_t rnti = tag.GetRnti(); uint8_t bid = tag.GetBid(); - NS_LOG_LOGIC("received packet with RNTI=" << (uint32_t)rnti << ", BID=" << (uint32_t)bid); - std::map>::iterator rntiIt = m_rbidTeidMap.find(rnti); + NS_LOG_INFO("Received packet with RNTI: " << rnti << ", BID: " << +bid); + auto rntiIt = m_rbidTeidMap.find(rnti); if (rntiIt == m_rbidTeidMap.end()) { NS_LOG_WARN("UE context not found, discarding packet"); } else { - std::map::iterator bidIt = rntiIt->second.find(bid); + auto bidIt = rntiIt->second.find(bid); NS_ASSERT(bidIt != rntiIt->second.end()); uint32_t teid = bidIt->second; m_rxLteSocketPktTrace(packet->Copy()); @@ -308,7 +302,8 @@ EpcEnbApplication::RecvFromS1uSocket(Ptr socket) GtpuHeader gtpu; packet->RemoveHeader(gtpu); uint32_t teid = gtpu.GetTeid(); - std::map::iterator it = m_teidRbidMap.find(teid); + NS_LOG_INFO("Received packet from S1-U interface with GTP TEID: " << teid); + auto it = m_teidRbidMap.find(teid); if (it == m_teidRbidMap.end()) { NS_LOG_WARN("UE context at cell id " << m_cellId << " not found, discarding packet"); @@ -323,9 +318,10 @@ EpcEnbApplication::RecvFromS1uSocket(Ptr socket) void EpcEnbApplication::SendToLteSocket(Ptr packet, uint16_t rnti, uint8_t bid) { - NS_LOG_FUNCTION(this << packet << rnti << (uint16_t)bid << packet->GetSize()); + NS_LOG_FUNCTION(this << packet << rnti << bid << packet->GetSize()); EpsBearerTag tag(rnti, bid); packet->AddPacketTag(tag); + NS_LOG_INFO("Add EpsBearerTag with RNTI " << rnti << " and bearer ID " << +bid); uint8_t ipType; packet->CopyData(&ipType, 1); @@ -334,10 +330,12 @@ EpcEnbApplication::SendToLteSocket(Ptr packet, uint16_t rnti, uint8_t bi int sentBytes; if (ipType == 0x04) { + NS_LOG_INFO("Forward packet from eNB's S1-U to LTE stack via IPv4 socket."); sentBytes = m_lteSocket->Send(packet); } else if (ipType == 0x06) { + NS_LOG_INFO("Forward packet from eNB's S1-U to LTE stack via IPv6 socket."); sentBytes = m_lteSocket6->Send(packet); } else @@ -359,6 +357,7 @@ EpcEnbApplication::SendToS1uSocket(Ptr packet, uint32_t teid) gtpu.SetLength(packet->GetSize() + gtpu.GetSerializedSize() - 8); packet->AddHeader(gtpu); uint32_t flags = 0; + NS_LOG_INFO("Forward packet from eNB's LTE to S1-U stack with TEID: " << teid); m_s1uSocket->SendTo(packet, flags, InetSocketAddress(m_sgwS1uAddress, m_gtpuUdpPort)); } diff --git a/src/lte/model/epc-mme-application.cc b/src/lte/model/epc-mme-application.cc index eb70b4e55..8b8156ae7 100644 --- a/src/lte/model/epc-mme-application.cc +++ b/src/lte/model/epc-mme-application.cc @@ -103,7 +103,7 @@ uint8_t EpcMmeApplication::AddBearer(uint64_t imsi, Ptr tft, EpsBearer bearer) { NS_LOG_FUNCTION(this << imsi); - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); NS_ASSERT_MSG(it->second->bearerCounter < 11, "too many bearers already! " << it->second->bearerCounter); @@ -124,7 +124,7 @@ EpcMmeApplication::DoInitialUeMessage(uint64_t mmeUeS1Id, uint16_t gci) { NS_LOG_FUNCTION(this << mmeUeS1Id << enbUeS1Id << imsi << gci); - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); it->second->cellId = gci; @@ -139,7 +139,7 @@ EpcMmeApplication::DoInitialUeMessage(uint64_t mmeUeS1Id, msg.SetSenderCpFteid(mmeS11Fteid); // S11 MME GTP-C F-TEID std::list bearerContexts; - for (std::list::iterator bit = it->second->bearersToBeActivated.begin(); + for (auto bit = it->second->bearersToBeActivated.begin(); bit != it->second->bearersToBeActivated.end(); ++bit) { @@ -180,7 +180,7 @@ EpcMmeApplication::DoPathSwitchRequest( { NS_LOG_FUNCTION(this << mmeUeS1Id << enbUeS1Id << gci); uint64_t imsi = mmeUeS1Id; - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); NS_LOG_INFO("IMSI " << imsi << " old eNB: " << it->second->cellId << ", new eNB: " << gci); it->second->cellId = gci; @@ -221,7 +221,7 @@ EpcMmeApplication::DoErabReleaseIndication( { NS_LOG_FUNCTION(this << mmeUeS1Id << enbUeS1Id); uint64_t imsi = mmeUeS1Id; - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); GtpcDeleteBearerCommandMessage msg; @@ -247,7 +247,7 @@ void EpcMmeApplication::RemoveBearer(Ptr ueInfo, uint8_t epsBearerId) { NS_LOG_FUNCTION(this << epsBearerId); - std::list::iterator bit = ueInfo->bearersToBeActivated.begin(); + auto bit = ueInfo->bearersToBeActivated.begin(); while (bit != ueInfo->bearersToBeActivated.end()) { if (bit->bearerId == epsBearerId) @@ -296,13 +296,13 @@ EpcMmeApplication::DoRecvCreateSessionResponse(GtpcHeader& header, Ptr p NS_LOG_FUNCTION(this << header); uint64_t imsi = header.GetTeid(); NS_LOG_DEBUG("TEID/IMSI " << imsi); - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); uint16_t cellId = it->second->cellId; uint16_t enbUeS1Id = it->second->enbUeS1Id; uint64_t mmeUeS1Id = it->second->mmeUeS1Id; NS_LOG_DEBUG("cellId " << cellId << " mmeUeS1Id " << mmeUeS1Id << " enbUeS1Id " << enbUeS1Id); - std::map>::iterator jt = m_enbInfoMap.find(cellId); + auto jt = m_enbInfoMap.find(cellId); NS_ASSERT_MSG(jt != m_enbInfoMap.end(), "could not find any eNB with CellId " << cellId); GtpcCreateSessionResponseMessage msg; @@ -337,7 +337,7 @@ EpcMmeApplication::DoRecvModifyBearerResponse(GtpcHeader& header, Ptr pa uint64_t imsi = header.GetTeid(); NS_LOG_DEBUG("TEID/IMSI " << imsi); - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); uint16_t cellId = it->second->cellId; uint16_t enbUeS1Id = it->second->enbUeS1Id; @@ -345,7 +345,7 @@ EpcMmeApplication::DoRecvModifyBearerResponse(GtpcHeader& header, Ptr pa NS_LOG_DEBUG("cellId " << cellId << " mmeUeS1Id " << mmeUeS1Id << " enbUeS1Id " << enbUeS1Id); std::list erabToBeSwitchedInUplinkList; // unused for now - std::map>::iterator jt = m_enbInfoMap.find(cellId); + auto jt = m_enbInfoMap.find(cellId); NS_ASSERT_MSG(jt != m_enbInfoMap.end(), "could not find any eNB with CellId " << cellId); NS_LOG_DEBUG("Send PathSwitchRequestAcknowledge to eNB " << jt->second->s1apSapEnb); @@ -361,7 +361,7 @@ EpcMmeApplication::DoRecvDeleteBearerRequest(GtpcHeader& header, Ptr pac NS_LOG_FUNCTION(this << header); uint64_t imsi = header.GetTeid(); NS_LOG_DEBUG("TEID/IMSI " << imsi); - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); GtpcDeleteBearerRequestMessage msg; diff --git a/src/lte/model/epc-pgw-application.cc b/src/lte/model/epc-pgw-application.cc index f5805ff84..2038b301c 100644 --- a/src/lte/model/epc-pgw-application.cc +++ b/src/lte/model/epc-pgw-application.cc @@ -58,7 +58,7 @@ void EpcPgwApplication::UeInfo::RemoveBearer(uint8_t bearerId) { NS_LOG_FUNCTION(this << (uint16_t)bearerId); - std::map::iterator it = m_teidByBearerIdMap.find(bearerId); + auto it = m_teidByBearerIdMap.find(bearerId); m_tftClassifier.Delete(it->second); // delete tft m_teidByBearerIdMap.erase(bearerId); } @@ -180,7 +180,7 @@ EpcPgwApplication::RecvFromTunDevice(Ptr packet, NS_LOG_LOGIC("packet addressed to UE " << ueAddr); // find corresponding UeInfo address - std::map>::iterator it = m_ueInfoByAddrMap.find(ueAddr); + auto it = m_ueInfoByAddrMap.find(ueAddr); if (it == m_ueInfoByAddrMap.end()) { NS_LOG_WARN("unknown UE address " << ueAddr); @@ -207,7 +207,7 @@ EpcPgwApplication::RecvFromTunDevice(Ptr packet, NS_LOG_LOGIC("packet addressed to UE " << ueAddr); // find corresponding UeInfo address - std::map>::iterator it = m_ueInfoByAddrMap6.find(ueAddr); + auto it = m_ueInfoByAddrMap6.find(ueAddr); if (it == m_ueInfoByAddrMap6.end()) { NS_LOG_WARN("unknown UE address " << ueAddr); @@ -298,7 +298,7 @@ EpcPgwApplication::DoRecvCreateSessionRequest(Ptr packet) uint16_t cellId = msg.GetUliEcgi(); NS_LOG_DEBUG("cellId " << cellId << " IMSI " << imsi); - std::map>::iterator ueit = m_ueInfoByImsiMap.find(imsi); + auto ueit = m_ueInfoByImsiMap.find(imsi); NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI " << imsi); ueit->second->SetSgwAddr(m_sgwS5Addr); @@ -360,7 +360,7 @@ EpcPgwApplication::DoRecvModifyBearerRequest(Ptr packet) uint16_t cellId = msg.GetUliEcgi(); NS_LOG_DEBUG("cellId " << cellId << " IMSI " << imsi); - std::map>::iterator ueit = m_ueInfoByImsiMap.find(imsi); + auto ueit = m_ueInfoByImsiMap.find(imsi); NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI " << imsi); ueit->second->SetSgwAddr(m_sgwS5Addr); @@ -422,7 +422,7 @@ EpcPgwApplication::DoRecvDeleteBearerResponse(Ptr packet) packet->RemoveHeader(msg); uint64_t imsi = msg.GetTeid(); - std::map>::iterator ueit = m_ueInfoByImsiMap.find(imsi); + auto ueit = m_ueInfoByImsiMap.find(imsi); NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI " << imsi); for (auto& epsBearerId : msg.GetEpsBearerIds()) @@ -498,7 +498,7 @@ void EpcPgwApplication::SetUeAddress(uint64_t imsi, Ipv4Address ueAddr) { NS_LOG_FUNCTION(this << imsi << ueAddr); - std::map>::iterator ueit = m_ueInfoByImsiMap.find(imsi); + auto ueit = m_ueInfoByImsiMap.find(imsi); NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI" << imsi); ueit->second->SetUeAddr(ueAddr); m_ueInfoByAddrMap[ueAddr] = ueit->second; @@ -508,7 +508,7 @@ void EpcPgwApplication::SetUeAddress6(uint64_t imsi, Ipv6Address ueAddr) { NS_LOG_FUNCTION(this << imsi << ueAddr); - std::map>::iterator ueit = m_ueInfoByImsiMap.find(imsi); + auto ueit = m_ueInfoByImsiMap.find(imsi); NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI " << imsi); m_ueInfoByAddrMap6[ueAddr] = ueit->second; ueit->second->SetUeAddr6(ueAddr); diff --git a/src/lte/model/epc-sgw-application.cc b/src/lte/model/epc-sgw-application.cc index c02c2c7db..35009c480 100644 --- a/src/lte/model/epc-sgw-application.cc +++ b/src/lte/model/epc-sgw-application.cc @@ -235,7 +235,7 @@ EpcSgwApplication::DoRecvCreateSessionRequest(Ptr packet) uint16_t cellId = msg.GetUliEcgi(); NS_LOG_DEBUG("cellId " << cellId << " IMSI " << imsi); - std::map::iterator enbit = m_enbInfoByCellId.find(cellId); + auto enbit = m_enbInfoByCellId.find(cellId); NS_ASSERT_MSG(enbit != m_enbInfoByCellId.end(), "unknown CellId " << cellId); Ipv4Address enbAddr = enbit->second.enbAddr; NS_LOG_DEBUG("eNB " << enbAddr); @@ -301,7 +301,7 @@ EpcSgwApplication::DoRecvModifyBearerRequest(Ptr packet) uint16_t cellId = msg.GetUliEcgi(); NS_LOG_DEBUG("cellId " << cellId << " IMSI " << imsi); - std::map::iterator enbit = m_enbInfoByCellId.find(cellId); + auto enbit = m_enbInfoByCellId.find(cellId); NS_ASSERT_MSG(enbit != m_enbInfoByCellId.end(), "unknown CellId " << cellId); Ipv4Address enbAddr = enbit->second.enbAddr; NS_LOG_DEBUG("eNB " << enbAddr); @@ -321,7 +321,7 @@ EpcSgwApplication::DoRecvModifyBearerRequest(Ptr packet) uint32_t teid = bearerContext.fteid.teid; Ipv4Address enbAddr = bearerContext.fteid.addr; NS_LOG_DEBUG("bearerId " << (uint16_t)bearerContext.epsBearerId << " TEID " << teid); - std::map::iterator addrit = m_enbByTeidMap.find(teid); + auto addrit = m_enbByTeidMap.find(teid); NS_ASSERT_MSG(addrit != m_enbByTeidMap.end(), "unknown TEID " << teid); addrit->second = enbAddr; GtpcModifyBearerRequestMessage::BearerContextToBeModified bearerContextOut; diff --git a/src/lte/model/epc-tft-classifier.cc b/src/lte/model/epc-tft-classifier.cc index d0d9b31e2..b527f2fda 100644 --- a/src/lte/model/epc-tft-classifier.cc +++ b/src/lte/model/epc-tft-classifier.cc @@ -187,9 +187,7 @@ EpcTftClassifier::Classify(Ptr p, EpcTft::Direction direction, uint16_t protocol, ipv4Header.GetIdentification()); - std::map, - std::pair>::iterator it = - m_classifiedIpv4Fragments.find(fragmentKey); + auto it = m_classifiedIpv4Fragments.find(fragmentKey); if (it != m_classifiedIpv4Fragments.end()) { diff --git a/src/lte/model/epc-tft.cc b/src/lte/model/epc-tft.cc index efccd9f0b..a04336b30 100644 --- a/src/lte/model/epc-tft.cc +++ b/src/lte/model/epc-tft.cc @@ -265,7 +265,7 @@ EpcTft::Matches(Direction direction, { NS_LOG_FUNCTION(this << direction << remoteAddress << localAddress << std::dec << remotePort << localPort << (uint16_t)typeOfService); - for (std::list::iterator it = m_filters.begin(); it != m_filters.end(); ++it) + for (auto it = m_filters.begin(); it != m_filters.end(); ++it) { if (it->Matches(direction, remoteAddress, @@ -290,7 +290,7 @@ EpcTft::Matches(Direction direction, { NS_LOG_FUNCTION(this << direction << remoteAddress << localAddress << std::dec << remotePort << localPort << (uint16_t)typeOfService); - for (std::list::iterator it = m_filters.begin(); it != m_filters.end(); ++it) + for (auto it = m_filters.begin(); it != m_filters.end(); ++it) { if (it->Matches(direction, remoteAddress, diff --git a/src/lte/model/epc-ue-nas.cc b/src/lte/model/epc-ue-nas.cc index b00ba3246..7101b4361 100644 --- a/src/lte/model/epc-ue-nas.cc +++ b/src/lte/model/epc-ue-nas.cc @@ -206,7 +206,7 @@ EpcUeNas::Send(Ptr packet, uint16_t protocolNumber) case ACTIVE: { uint32_t id = m_tftClassifier.Classify(packet, EpcTft::UPLINK, protocolNumber); NS_ASSERT((id & 0xFFFFFF00) == 0); - uint8_t bid = (uint8_t)(id & 0x000000FF); + auto bid = (uint8_t)(id & 0x000000FF); if (bid == 0) { return false; @@ -295,8 +295,7 @@ EpcUeNas::SwitchToState(State newState) switch (m_state) { case ACTIVE: - for (std::list::iterator it = m_bearersToBeActivatedList.begin(); - it != m_bearersToBeActivatedList.end(); + for (auto it = m_bearersToBeActivatedList.begin(); it != m_bearersToBeActivatedList.end(); m_bearersToBeActivatedList.erase(it++)) { DoActivateEpsBearer(it->bearer, it->tft); diff --git a/src/lte/model/epc-x2-header.cc b/src/lte/model/epc-x2-header.cc index 94e064299..82c53c80a 100644 --- a/src/lte/model/epc-x2-header.cc +++ b/src/lte/model/epc-x2-header.cc @@ -1209,8 +1209,7 @@ EpcX2LoadInformationHeader::Deserialize(Buffer::Iterator start) m_headerLength += 2; for (int k = 0; k < sz2; k++) { - EpcX2Sap::UlInterferenceOverloadIndicationItem item = - (EpcX2Sap::UlInterferenceOverloadIndicationItem)i.ReadU8(); + auto item = (EpcX2Sap::UlInterferenceOverloadIndicationItem)i.ReadU8(); cellInfoItem.ulInterferenceOverloadIndicationList.push_back(item); } m_headerLength += sz2; diff --git a/src/lte/model/fdbet-ff-mac-scheduler.cc b/src/lte/model/fdbet-ff-mac-scheduler.cc index 78de191a5..72b4710d3 100644 --- a/src/lte/model/fdbet-ff-mac-scheduler.cc +++ b/src/lte/model/fdbet-ff-mac-scheduler.cc @@ -159,7 +159,7 @@ FdBetFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -205,10 +205,9 @@ FdBetFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::map::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -235,15 +234,13 @@ FdBetFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -273,14 +270,12 @@ FdBetFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -302,11 +297,9 @@ FdBetFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -353,9 +346,8 @@ FdBetFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int FdBetFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -376,13 +368,12 @@ FdBetFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -406,13 +397,12 @@ FdBetFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -441,8 +431,7 @@ FdBetFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -452,8 +441,7 @@ FdBetFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -493,9 +481,9 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -504,8 +492,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -569,15 +556,13 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -619,7 +604,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -647,8 +632,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -669,16 +653,14 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -765,8 +747,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -843,8 +824,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -857,15 +837,14 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -891,15 +870,13 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( return; } - std::map::iterator itFlow; std::map estAveThr; // store expected average throughput for UE - std::map::iterator itMax = estAveThr.end(); - std::map::iterator it; + auto itMax = estAveThr.end(); std::map rbgPerRntiLog; // record the number of RBG assigned to UE double metricMax = 0.0; - for (itFlow = m_flowStatsDl.begin(); itFlow != m_flowStatsDl.end(); itFlow++) + for (auto itFlow = m_flowStatsDl.begin(); itFlow != m_flowStatsDl.end(); itFlow++) { - std::set::iterator itRnti = rntiAllocated.find((*itFlow).first); + auto itRnti = rntiAllocated.find((*itFlow).first); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*itFlow).first))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -915,10 +892,8 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } // check first what are channel conditions for this UE, if CQI!=0 - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*itFlow).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itFlow).first); + auto itCqi = m_p10CqiRxed.find((*itFlow).first); + auto itTxMode = m_uesTxMode.find((*itFlow).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itFlow).first); @@ -951,7 +926,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( if (!estAveThr.empty()) { // Find UE with largest priority metric - for (it = estAveThr.begin(); it != estAveThr.end(); it++) + for (auto it = estAveThr.begin(); it != estAveThr.end(); it++) { double metric = 1 / (*it).second; if (metric > metricMax) @@ -970,9 +945,8 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( if (!rbgMap.at(i)) { // allocate one RBG to current UE - std::map>::iterator itMap; std::vector tempMap; - itMap = allocationMap.find((*itMax).first); + auto itMap = allocationMap.find((*itMax).first); if (itMap == allocationMap.end()) { tempMap.push_back(i); @@ -985,10 +959,8 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } // calculate expected throughput for current UE - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*itMax).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMax).first); + auto itCqi = m_p10CqiRxed.find((*itMax).first); + auto itTxMode = m_uesTxMode.find((*itMax).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMax).first); @@ -1007,10 +979,8 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } } - std::map::iterator itRbgPerRntiLog; - itRbgPerRntiLog = rbgPerRntiLog.find((*itMax).first); - std::map::iterator itPastAveThr; - itPastAveThr = m_flowStatsDl.find((*itMax).first); + auto itRbgPerRntiLog = rbgPerRntiLog.find((*itMax).first); + auto itPastAveThr = m_flowStatsDl.find((*itMax).first); uint32_t bytesTxed = 0; for (uint8_t j = 0; j < nLayer; j++) { @@ -1030,7 +1000,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( // find new UE with largest priority metric metricMax = 0.0; - for (it = estAveThr.begin(); it != estAveThr.end(); it++) + for (auto it = estAveThr.begin(); it != estAveThr.end(); it++) { double metric = 1 / (*it).second; if (metric > metricMax) @@ -1051,15 +1021,14 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } // end if estAveThr // reset TTI stats of users - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.lastTtiBytesTrasmitted = 0; } // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -1078,10 +1047,8 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_p10CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1117,9 +1084,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1141,8 +1106,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1171,8 +1135,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1180,8 +1143,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1193,8 +1155,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( ret.m_buildDataList.push_back(newEl); // update UE stats - std::map::iterator it; - it = m_flowStatsDl.find((*itMap).first); + auto it = m_flowStatsDl.find((*itMap).first); if (it != m_flowStatsDl.end()) { (*it).second.lastTtiBytesTrasmitted = bytesTxed; @@ -1211,7 +1172,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( // update UEs stats NS_LOG_INFO(this << " Update UEs statistics"); - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -1248,9 +1209,8 @@ FdBetFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1265,17 +1225,15 @@ FdBetFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1288,8 +1246,7 @@ FdBetFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1303,7 +1260,7 @@ FdBetFfMacScheduler::DoSchedDlCqiInfoReq( double FdBetFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1370,8 +1327,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1379,16 +1335,14 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1446,7 +1400,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1476,7 +1430,6 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( } int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -1498,7 +1451,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1583,7 +1536,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( return; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1654,15 +1607,13 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1670,8 +1621,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1687,7 +1637,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( << (uint16_t)harqId); // update TTI UE stats - itStats = m_flowStatsUl.find((*it).first); + auto itStats = m_flowStatsUl.find((*it).first); if (itStats != m_flowStatsUl.end()) { (*itStats).second.lastTtiBytesTrasmitted = uldci.m_tbSize; @@ -1713,7 +1663,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( // Update global UE stats // update UEs stats - for (itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) + for (auto itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -1750,8 +1700,6 @@ FdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1772,7 +1720,7 @@ FdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1818,11 +1766,9 @@ FdBetFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1831,7 +1777,7 @@ FdBetFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1861,8 +1807,7 @@ FdBetFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1883,8 +1828,7 @@ FdBetFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1911,8 +1855,7 @@ FdBetFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1932,7 +1875,7 @@ void FdBetFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -1940,12 +1883,12 @@ FdBetFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -1957,7 +1900,7 @@ FdBetFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -1965,12 +1908,12 @@ FdBetFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -1986,7 +1929,7 @@ void FdBetFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -1994,13 +1937,13 @@ FdBetFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -2015,9 +1958,8 @@ FdBetFfMacScheduler::RefreshUlCqiMaps() void FdBetFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2072,7 +2014,7 @@ void FdBetFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/fdmt-ff-mac-scheduler.cc b/src/lte/model/fdmt-ff-mac-scheduler.cc index 32bebcab0..e87a04b85 100644 --- a/src/lte/model/fdmt-ff-mac-scheduler.cc +++ b/src/lte/model/fdmt-ff-mac-scheduler.cc @@ -158,7 +158,7 @@ FdMtFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -204,10 +204,9 @@ FdMtFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::set::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -224,15 +223,13 @@ FdMtFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -262,14 +259,12 @@ FdMtFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -291,11 +286,9 @@ FdMtFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -342,9 +335,8 @@ FdMtFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int FdMtFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -365,13 +357,12 @@ FdMtFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -395,13 +386,12 @@ FdMtFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -430,8 +420,7 @@ FdMtFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -441,8 +430,7 @@ FdMtFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -482,9 +470,9 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -493,8 +481,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -558,15 +545,13 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -608,7 +593,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -636,8 +621,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -658,16 +642,14 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -754,8 +736,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -832,8 +813,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -846,15 +826,14 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -885,12 +864,11 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( NS_LOG_INFO(this << " ALLOCATION for RBG " << i << " of " << rbgNum); if (!rbgMap.at(i)) { - std::set::iterator it; - std::set::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double rcqiMax = 0.0; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it)); + auto itRnti = rntiAllocated.find((*it)); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it)))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -905,10 +883,8 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it)); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it)); + auto itCqi = m_a30CqiRxed.find((*it)); + auto itTxMode = m_uesTxMode.find((*it)); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it)); @@ -917,10 +893,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( std::vector sbCqi; if (itCqi == m_a30CqiRxed.end()) { - for (uint8_t k = 0; k < nLayer; k++) - { - sbCqi.push_back(1); // start with lowest value - } + sbCqi = std::vector(nLayer, 1); // start with lowest value } else { @@ -978,8 +951,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( else { rbgMap.at(i) = true; - std::map>::iterator itMap; - itMap = allocationMap.find((*itMax)); + auto itMap = allocationMap.find((*itMax)); if (itMap == allocationMap.end()) { // insert new element @@ -999,7 +971,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -1018,10 +990,8 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_a30CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1104,9 +1074,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1128,8 +1096,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1158,8 +1125,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1167,8 +1133,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1208,9 +1173,8 @@ FdMtFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1225,17 +1189,15 @@ FdMtFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1248,8 +1210,7 @@ FdMtFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1263,7 +1224,7 @@ FdMtFfMacScheduler::DoSchedDlCqiInfoReq( double FdMtFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1330,8 +1291,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1339,16 +1299,14 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1406,7 +1364,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1457,7 +1415,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1542,7 +1500,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( return; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1613,15 +1571,13 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1629,8 +1585,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1684,8 +1639,6 @@ FdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1706,7 +1659,7 @@ FdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1752,11 +1705,9 @@ FdMtFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1765,7 +1716,7 @@ FdMtFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1795,8 +1746,7 @@ FdMtFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1817,8 +1767,7 @@ FdMtFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1845,8 +1794,7 @@ FdMtFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1866,7 +1814,7 @@ void FdMtFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -1874,12 +1822,12 @@ FdMtFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -1891,7 +1839,7 @@ FdMtFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -1899,12 +1847,12 @@ FdMtFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -1920,7 +1868,7 @@ void FdMtFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -1928,13 +1876,13 @@ FdMtFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -1949,9 +1897,8 @@ FdMtFfMacScheduler::RefreshUlCqiMaps() void FdMtFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2006,7 +1953,7 @@ void FdMtFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/fdtbfq-ff-mac-scheduler.cc b/src/lte/model/fdtbfq-ff-mac-scheduler.cc index 96e94698c..7684b4170 100644 --- a/src/lte/model/fdtbfq-ff-mac-scheduler.cc +++ b/src/lte/model/fdtbfq-ff-mac-scheduler.cc @@ -184,7 +184,7 @@ FdTbfqFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -230,10 +230,9 @@ FdTbfqFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::map::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -289,15 +288,13 @@ FdTbfqFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -327,14 +324,12 @@ FdTbfqFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -356,11 +351,9 @@ FdTbfqFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -407,9 +400,8 @@ FdTbfqFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int FdTbfqFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -430,13 +422,12 @@ FdTbfqFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -460,13 +451,12 @@ FdTbfqFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -495,8 +485,7 @@ FdTbfqFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -506,8 +495,7 @@ FdTbfqFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -547,7 +535,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); - for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) + for (auto it = rbgMap.begin(); it != rbgMap.end(); it++) { if (*it) { @@ -558,8 +546,8 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( FfMacSchedSapUser::SchedDlConfigIndParameters ret; // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -575,7 +563,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( uint16_t tmpFfrRbStartOffset = 0; uint16_t index = 0; - for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) + for (auto it = ulRbMap.begin(); it != ulRbMap.end(); it++) { if (*it) { @@ -606,8 +594,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -671,15 +658,13 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -721,7 +706,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -749,8 +734,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -771,16 +755,14 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -867,8 +849,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -945,8 +926,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -959,15 +939,14 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -994,8 +973,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // update token pool, counter and bank size - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { if ((*itStats).second.tokenGenerationRate / 1000 + (*itStats).second.tokenPoolSize > (*itStats).second.maxTokenPoolSize) @@ -1021,12 +999,12 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( { // select UE with largest metric std::map::iterator it; - std::map::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double metricMax = 0.0; bool firstRnti = true; for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it).first))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -1041,10 +1019,8 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( continue; } // check first the channel conditions for this UE, if CQI!=0 - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_a30CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1078,8 +1054,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::set::iterator rnti; - rnti = allocatedRnti.find((*it).first); + auto rnti = allocatedRnti.find((*it).first); if (rnti != allocatedRnti.end()) // already allocated RBGs to this UE { continue; @@ -1139,9 +1114,8 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( // calculate rlc buffer size uint32_t rlcBufSize = 0; uint8_t lcid = 0; - std::map::iterator - itRlcBuf; - for (itRlcBuf = m_rlcBufferReq.begin(); itRlcBuf != m_rlcBufferReq.end(); itRlcBuf++) + for (auto itRlcBuf = m_rlcBufferReq.begin(); itRlcBuf != m_rlcBufferReq.end(); + itRlcBuf++) { if ((*itRlcBuf).first.m_rnti == (*itMax).first) { @@ -1149,7 +1123,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( } } LteFlowId_t flow((*itMax).first, lcid); - itRlcBuf = m_rlcBufferReq.find(flow); + auto itRlcBuf = m_rlcBufferReq.find(flow); if (itRlcBuf != m_rlcBufferReq.end()) { rlcBufSize = (*itRlcBuf).second.m_rlcTransmissionQueueSize + @@ -1172,10 +1146,8 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( { totalRbg++; - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMax).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMax).first); + auto itCqi = m_a30CqiRxed.find((*itMax).first); + auto itTxMode = m_uesTxMode.find((*itMax).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1187,8 +1159,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( rbgIndex = rbgNum; for (int k = 0; k < rbgNum; k++) { - std::set::iterator rbg; - rbg = allocatedRbg.find(k); + auto rbg = allocatedRbg.find(k); if (rbg != allocatedRbg.end()) // RBGs are already allocated to this UE { continue; @@ -1207,10 +1178,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( std::vector sbCqi; if (itCqi == m_a30CqiRxed.end()) { - for (uint8_t k = 0; k < nLayer; k++) - { - sbCqi.push_back(1); // start with lowest value - } + sbCqi = std::vector(nLayer, 1); // start with lowest value } else { @@ -1268,8 +1236,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // assign this RBG to UE - std::map>::iterator itMap; - itMap = allocationMap.find((*itMax).first); + auto itMap = allocationMap.find((*itMax).first); uint16_t RbgPerRnti; if (itMap == allocationMap.end()) { @@ -1355,8 +1322,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( { NS_LOG_DEBUG("budget: " << budget << " bytesTxed: " << bytesTxed << " at " << Simulator::Now().As(Time::MS)); - std::map>::iterator itMap; - itMap = allocationMap.find((*itMax).first); + auto itMap = allocationMap.find((*itMax).first); (*itMap).second.pop_back(); allocatedRbg.erase(rbgIndex); bytesTxed = bytesTxedTmp; // recovery bytesTxed @@ -1397,7 +1363,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { NS_LOG_DEBUG("Preparing DCI for RNTI " << (*itMap).first); @@ -1417,10 +1383,8 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_a30CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1503,9 +1467,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1527,8 +1489,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1557,8 +1518,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1566,8 +1526,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1608,9 +1567,8 @@ FdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1625,17 +1583,15 @@ FdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1648,8 +1604,7 @@ FdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1663,7 +1618,7 @@ FdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( double FdTbfqFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1716,7 +1671,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( rbMap = m_ffrSapProvider->GetAvailableUlRbg(); - for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) + for (auto it = rbMap.begin(); it != rbMap.end(); it++) { if (*it) { @@ -1746,8 +1701,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1755,16 +1709,14 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1823,7 +1775,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1856,7 +1808,6 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( } int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -1878,7 +1829,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1971,7 +1922,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( break; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -2042,15 +1993,13 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -2058,8 +2007,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -2113,8 +2061,6 @@ FdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -2135,7 +2081,7 @@ FdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -2181,11 +2127,9 @@ FdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -2194,7 +2138,7 @@ FdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2224,8 +2168,7 @@ FdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2246,8 +2189,7 @@ FdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2274,8 +2216,7 @@ FdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2295,7 +2236,7 @@ void FdTbfqFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -2303,12 +2244,12 @@ FdTbfqFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -2320,7 +2261,7 @@ FdTbfqFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -2328,12 +2269,12 @@ FdTbfqFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -2349,7 +2290,7 @@ void FdTbfqFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -2357,13 +2298,13 @@ FdTbfqFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -2378,9 +2319,8 @@ FdTbfqFfMacScheduler::RefreshUlCqiMaps() void FdTbfqFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2435,7 +2375,7 @@ void FdTbfqFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/lte-amc.cc b/src/lte/model/lte-amc.cc index eb161a7c3..4e5cfddff 100644 --- a/src/lte/model/lte-amc.cc +++ b/src/lte/model/lte-amc.cc @@ -554,11 +554,10 @@ LteAmc::CreateCqiFeedbacks(const SpectrumValue& sinr, uint8_t rbgSize) NS_LOG_FUNCTION(this); std::vector cqi; - Values::const_iterator it; if (m_amcModel == PiroEW2010) { - for (it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) + for (auto it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) { double sinr_ = (*it); if (sinr_ == 0.0) @@ -594,7 +593,7 @@ LteAmc::CreateCqiFeedbacks(const SpectrumValue& sinr, uint8_t rbgSize) NS_ASSERT_MSG(rbgSize > 0, " LteAmc-Vienna: RBG size must be greater than 0"); std::vector rbgMap; int rbId = 0; - for (it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) + for (auto it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) { rbgMap.push_back(rbId++); if ((rbId % rbgSize == 0) || ((it + 1) == sinr.ConstValuesEnd())) diff --git a/src/lte/model/lte-anr.cc b/src/lte/model/lte-anr.cc index 7424386c6..b74d1adc2 100644 --- a/src/lte/model/lte-anr.cc +++ b/src/lte/model/lte-anr.cc @@ -97,7 +97,7 @@ LteAnr::RemoveNeighbourRelation(uint16_t cellId) { NS_LOG_FUNCTION(this << m_servingCellId << cellId); - NeighbourRelationTable_t::iterator it = m_neighbourRelationTable.find(cellId); + auto it = m_neighbourRelationTable.find(cellId); if (it != m_neighbourRelationTable.end()) { NS_FATAL_ERROR("Cell ID " << cellId << " cannot be found in NRT"); @@ -157,8 +157,7 @@ LteAnr::DoReportUeMeas(LteRrcSap::MeasResults measResults) { if (measResults.haveMeasResultNeighCells && !(measResults.measResultListEutra.empty())) { - for (std::list::iterator it = - measResults.measResultListEutra.begin(); + for (auto it = measResults.measResultListEutra.begin(); it != measResults.measResultListEutra.end(); ++it) { @@ -167,8 +166,7 @@ LteAnr::DoReportUeMeas(LteRrcSap::MeasResults measResults) "RSRQ measure missing for cellId " << it->physCellId); // Update Neighbour Relation Table - NeighbourRelationTable_t::iterator itNrt = - m_neighbourRelationTable.find(it->physCellId); + auto itNrt = m_neighbourRelationTable.find(it->physCellId); if (itNrt != m_neighbourRelationTable.end()) { // Update neighbour relation entry @@ -243,7 +241,7 @@ LteAnr::DoGetNoX2(uint16_t cellId) const const LteAnr::NeighbourRelation_t* LteAnr::Find(uint16_t cellId) const { - NeighbourRelationTable_t::const_iterator it = m_neighbourRelationTable.find(cellId); + auto it = m_neighbourRelationTable.find(cellId); if (it == m_neighbourRelationTable.end()) { NS_FATAL_ERROR("Cell ID " << cellId << " cannot be found in NRT"); diff --git a/src/lte/model/lte-asn1-header.cc b/src/lte/model/lte-asn1-header.cc index 18cf50c7f..72e5c56b1 100644 --- a/src/lte/model/lte-asn1-header.cc +++ b/src/lte/model/lte-asn1-header.cc @@ -23,7 +23,6 @@ #include #include -#include namespace ns3 { @@ -165,7 +164,7 @@ Asn1Header::SerializeBitset(std::bitset data) const // Clause 16.11 ITU-T X.691 else { - printf("FRAGMENTATION NEEDED!\n"); + NS_LOG_DEBUG("Fragmentation needed!"); } } diff --git a/src/lte/model/lte-chunk-processor.cc b/src/lte/model/lte-chunk-processor.cc index cd7adfe99..ef0f4da6f 100644 --- a/src/lte/model/lte-chunk-processor.cc +++ b/src/lte/model/lte-chunk-processor.cc @@ -72,8 +72,8 @@ LteChunkProcessor::End() NS_LOG_FUNCTION(this); if (m_totDuration.GetSeconds() > 0) { - std::vector::iterator it; - for (it = m_lteChunkProcessorCallbacks.begin(); it != m_lteChunkProcessorCallbacks.end(); + for (auto it = m_lteChunkProcessorCallbacks.begin(); + it != m_lteChunkProcessorCallbacks.end(); it++) { (*it)((*m_sumValues) / m_totDuration.GetSeconds()); diff --git a/src/lte/model/lte-common.cc b/src/lte/model/lte-common.cc index c3903ce67..c5de4717e 100644 --- a/src/lte/model/lte-common.cc +++ b/src/lte/model/lte-common.cc @@ -143,7 +143,7 @@ LteFfConverter::double2fpS11dot3(double val) { val = -4096; } - int16_t valFp = (int16_t)(val * 8); + auto valFp = (int16_t)(val * 8); return (valFp); } @@ -361,7 +361,7 @@ EutranMeasurementMapping::IeValue2ActualQQualMin(int8_t qQualMinIeValue) << " for Q-QualMin IE value"); } - double actual = static_cast(qQualMinIeValue); + auto actual = static_cast(qQualMinIeValue); NS_ASSERT(actual >= -34.0); NS_ASSERT(actual <= -3.0); return actual; diff --git a/src/lte/model/lte-enb-component-carrier-manager.cc b/src/lte/model/lte-enb-component-carrier-manager.cc index 51b05deb2..9b116a233 100644 --- a/src/lte/model/lte-enb-component-carrier-manager.cc +++ b/src/lte/model/lte-enb-component-carrier-manager.cc @@ -84,8 +84,7 @@ LteEnbComponentCarrierManager::SetMacSapProvider(uint8_t componentCarrierId, Lte { NS_LOG_FUNCTION(this); bool res = false; - std::map::iterator it = - m_macSapProvidersMap.find(componentCarrierId); + auto it = m_macSapProvidersMap.find(componentCarrierId); if ((uint16_t)componentCarrierId > m_noOfComponentCarriers) { NS_FATAL_ERROR("Inconsistent componentCarrierId or you didn't call " @@ -110,8 +109,7 @@ LteEnbComponentCarrierManager::SetCcmMacSapProviders(uint8_t componentCarrierId, { NS_LOG_FUNCTION(this); bool res = false; - std::map::iterator it = - m_ccmMacSapProviderMap.find(componentCarrierId); + auto it = m_ccmMacSapProviderMap.find(componentCarrierId); if (it == m_ccmMacSapProviderMap.end()) { diff --git a/src/lte/model/lte-enb-mac.cc b/src/lte/model/lte-enb-mac.cc index 63f9bf32b..7685d4099 100644 --- a/src/lte/model/lte-enb-mac.cc +++ b/src/lte/model/lte-enb-mac.cc @@ -499,8 +499,7 @@ LteEnbMac::DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo) // process received RACH preambles and notify the scheduler FfMacSchedSapProvider::SchedDlRachInfoReqParameters rachInfoReqParams; NS_ASSERT(subframeNo > 0 && subframeNo <= 10); // subframe in 1..10 - for (std::map::const_iterator it = m_receivedRachPreambleCount.begin(); - it != m_receivedRachPreambleCount.end(); + for (auto it = m_receivedRachPreambleCount.begin(); it != m_receivedRachPreambleCount.end(); ++it) { NS_LOG_INFO(this << " preambleId " << (uint32_t)it->first << ": " << it->second @@ -515,8 +514,7 @@ LteEnbMac::DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo) else { uint16_t rnti; - std::map::iterator jt = - m_allocatedNcRaPreambleMap.find(it->first); + auto jt = m_allocatedNcRaPreambleMap.find(it->first); if (jt != m_allocatedNcRaPreambleMap.end()) { rnti = jt->second.rnti; @@ -716,10 +714,9 @@ LteEnbMac::DoReceivePhyPdu(Ptr p) // store info of the packet received - // std::map ::iterator it; // u_int rnti = tag.GetRnti (); - // u_int lcid = tag.GetLcid (); - // it = m_ulInfoListElements.find (tag.GetRnti ()); + // u_int lcid = tag.GetLcid (); + // auto it = m_ulInfoListElements.find (tag.GetRnti ()); // if (it == m_ulInfoListElements.end ()) // { // // new RNTI @@ -749,10 +746,9 @@ LteEnbMac::DoReceivePhyPdu(Ptr p) // forward the packet to the correspondent RLC uint16_t rnti = tag.GetRnti(); uint8_t lcid = tag.GetLcid(); - std::map>::iterator rntiIt = - m_rlcAttached.find(rnti); + auto rntiIt = m_rlcAttached.find(rnti); NS_ASSERT_MSG(rntiIt != m_rlcAttached.end(), "could not find RNTI" << rnti); - std::map::iterator lcidIt = rntiIt->second.find(lcid); + auto lcidIt = rntiIt->second.find(lcid); // NS_ASSERT_MSG (lcidIt != rntiIt->second.end (), "could not find LCID" << lcid); LteMacSapUser::ReceivePduParameters rxPduParams; @@ -789,7 +785,7 @@ LteEnbMac::DoAddUe(uint16_t rnti) { NS_LOG_FUNCTION(this << " rnti=" << rnti); std::map empty; - std::pair>::iterator, bool> ret = + auto ret = m_rlcAttached.insert(std::pair>(rnti, empty)); NS_ASSERT_MSG(ret.second, "element already present, RNTI already existed"); @@ -833,13 +829,12 @@ LteEnbMac::DoRemoveUe(uint16_t rnti) NS_LOG_DEBUG("start checking for unprocessed preamble for rnti: " << rnti); // remove unprocessed preamble received for RACH during handover - std::map::iterator jt = m_allocatedNcRaPreambleMap.begin(); + auto jt = m_allocatedNcRaPreambleMap.begin(); while (jt != m_allocatedNcRaPreambleMap.end()) { if (jt->second.rnti == rnti) { - std::map::const_iterator it = - m_receivedRachPreambleCount.find(jt->first); + auto it = m_receivedRachPreambleCount.find(jt->first); if (it != m_receivedRachPreambleCount.end()) { m_receivedRachPreambleCount.erase(it->first); @@ -852,7 +847,7 @@ LteEnbMac::DoRemoveUe(uint16_t rnti) } } - std::vector::iterator itCeRxd = m_ulCeReceived.begin(); + auto itCeRxd = m_ulCeReceived.begin(); while (itCeRxd != m_ulCeReceived.end()) { if (itCeRxd->m_rnti == rnti) @@ -871,14 +866,11 @@ LteEnbMac::DoAddLc(LteEnbCmacSapProvider::LcInfo lcinfo, LteMacSapUser* msu) { NS_LOG_FUNCTION(this << lcinfo.rnti << (uint16_t)lcinfo.lcId); - std::map::iterator it; - LteFlowId_t flow(lcinfo.rnti, lcinfo.lcId); - std::map>::iterator rntiIt = - m_rlcAttached.find(lcinfo.rnti); + auto rntiIt = m_rlcAttached.find(lcinfo.rnti); NS_ASSERT_MSG(rntiIt != m_rlcAttached.end(), "RNTI not found"); - std::map::iterator lcidIt = rntiIt->second.find(lcinfo.lcId); + auto lcidIt = rntiIt->second.find(lcinfo.lcId); if (lcidIt == rntiIt->second.end()) { rntiIt->second.insert(std::pair(lcinfo.lcId, msu)); @@ -928,8 +920,7 @@ LteEnbMac::DoReleaseLc(uint16_t rnti, uint8_t lcid) NS_LOG_FUNCTION(this); // Find user based on rnti and then erase lcid stored against the same - std::map>::iterator rntiIt = - m_rlcAttached.find(rnti); + auto rntiIt = m_rlcAttached.find(rnti); rntiIt->second.erase(lcid); FfMacCschedSapProvider::CschedLcReleaseReqParameters params; @@ -969,8 +960,7 @@ LteEnbMac::DoAllocateNcRaPreamble(uint16_t rnti) uint8_t preambleId; for (preambleId = m_numberOfRaPreambles; preambleId < 64; ++preambleId) { - std::map::iterator it = - m_allocatedNcRaPreambleMap.find(preambleId); + auto it = m_allocatedNcRaPreambleMap.find(preambleId); /** * Allocate preamble only if its free. The non-contention preamble * assigned to UE during handover or PDCCH order is valid only until the @@ -1036,8 +1026,7 @@ LteEnbMac::DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params) params.pdu->AddPacketTag(tag); params.componentCarrierId = m_componentCarrierId; // Store pkt in HARQ buffer - std::map::iterator it = - m_miDlHarqProcessesPackets.find(params.rnti); + auto it = m_miDlHarqProcessesPackets.find(params.rnti); NS_ASSERT(it != m_miDlHarqProcessesPackets.end()); NS_LOG_DEBUG(this << " LAYER " << (uint16_t)tag.GetLayer() << " HARQ ID " << (uint16_t)params.harqProcessId); @@ -1072,7 +1061,6 @@ LteEnbMac::DoSchedDlConfigInd(FfMacSchedSapUser::SchedDlConfigIndParameters ind) NS_LOG_FUNCTION(this); // Create DL PHY PDU Ptr pb = CreateObject(); - std::map::iterator it; LteMacSapUser::TxOpportunityParameters txOpParams; for (std::size_t i = 0; i < ind.m_buildDataList.size(); i++) @@ -1082,8 +1070,7 @@ LteEnbMac::DoSchedDlConfigInd(FfMacSchedSapUser::SchedDlConfigIndParameters ind) if (ind.m_buildDataList.at(i).m_dci.m_ndi.at(layer) == 1) { // new data -> force emptying correspondent harq pkt buffer - std::map::iterator it = - m_miDlHarqProcessesPackets.find(ind.m_buildDataList.at(i).m_rnti); + auto it = m_miDlHarqProcessesPackets.find(ind.m_buildDataList.at(i).m_rnti); NS_ASSERT(it != m_miDlHarqProcessesPackets.end()); for (std::size_t lcId = 0; lcId < (*it).second.size(); lcId++) { @@ -1102,10 +1089,9 @@ LteEnbMac::DoSchedDlConfigInd(FfMacSchedSapUser::SchedDlConfigIndParameters ind) uint16_t rnti = ind.m_buildDataList.at(i).m_rnti; uint8_t lcid = ind.m_buildDataList.at(i).m_rlcPduList.at(j).at(k).m_logicalChannelIdentity; - std::map>::iterator rntiIt = - m_rlcAttached.find(rnti); + auto rntiIt = m_rlcAttached.find(rnti); NS_ASSERT_MSG(rntiIt != m_rlcAttached.end(), "could not find RNTI" << rnti); - std::map::iterator lcidIt = rntiIt->second.find(lcid); + auto lcidIt = rntiIt->second.find(lcid); NS_ASSERT_MSG(lcidIt != rntiIt->second.end(), "could not find LCID" << (uint32_t)lcid << " carrier id:" << (uint16_t)m_componentCarrierId); @@ -1124,13 +1110,11 @@ LteEnbMac::DoSchedDlConfigInd(FfMacSchedSapUser::SchedDlConfigIndParameters ind) if (ind.m_buildDataList.at(i).m_dci.m_tbsSize.at(k) > 0) { // HARQ retransmission -> retrieve TB from HARQ buffer - std::map::iterator it = - m_miDlHarqProcessesPackets.find(ind.m_buildDataList.at(i).m_rnti); + auto it = m_miDlHarqProcessesPackets.find(ind.m_buildDataList.at(i).m_rnti); NS_ASSERT(it != m_miDlHarqProcessesPackets.end()); Ptr pb = (*it).second.at(k).at(ind.m_buildDataList.at(i).m_dci.m_harqProcess); - for (std::list>::const_iterator j = pb->Begin(); j != pb->End(); - ++j) + for (auto j = pb->Begin(); j != pb->End(); ++j) { Ptr pkt = (*j)->Copy(); m_enbPhySapProvider->SendMacPdu(pkt); @@ -1198,8 +1182,7 @@ LteEnbMac::DoSchedDlConfigInd(FfMacSchedSapUser::SchedDlConfigIndParameters ind) rarMsg->SetRaRnti(raRnti); for (unsigned int i = 0; i < ind.m_buildRarList.size(); i++) { - std::map::iterator itRapId = - m_rapIdRntiMap.find(ind.m_buildRarList.at(i).m_rnti); + auto itRapId = m_rapIdRntiMap.find(ind.m_buildRarList.at(i).m_rnti); if (itRapId == m_rapIdRntiMap.end()) { NS_FATAL_ERROR("Unable to find rapId of RNTI " << ind.m_buildRarList.at(i).m_rnti); @@ -1309,8 +1292,7 @@ LteEnbMac::DoDlInfoListElementHarqFeedback(DlInfoListElement_s params) { NS_LOG_FUNCTION(this); // Update HARQ buffer - std::map::iterator it = - m_miDlHarqProcessesPackets.find(params.m_rnti); + auto it = m_miDlHarqProcessesPackets.find(params.m_rnti); NS_ASSERT(it != m_miDlHarqProcessesPackets.end()); for (std::size_t layer = 0; layer < params.m_harqStatus.size(); layer++) { diff --git a/src/lte/model/lte-enb-phy.cc b/src/lte/model/lte-enb-phy.cc index bb07f2b7a..d2538b6ae 100644 --- a/src/lte/model/lte-enb-phy.cc +++ b/src/lte/model/lte-enb-phy.cc @@ -378,8 +378,7 @@ bool LteEnbPhy::AddUePhy(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::set::iterator it; - it = m_ueAttached.find(rnti); + auto it = m_ueAttached.find(rnti); if (it == m_ueAttached.end()) { m_ueAttached.insert(rnti); @@ -396,8 +395,7 @@ bool LteEnbPhy::DeleteUePhy(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::set::iterator it; - it = m_ueAttached.find(rnti); + auto it = m_ueAttached.find(rnti); if (it == m_ueAttached.end()) { NS_LOG_ERROR("UE not attached"); @@ -461,7 +459,7 @@ LteEnbPhy::GeneratePowerAllocationMap(uint16_t rnti, int rbId) NS_LOG_FUNCTION(this); double rbgTxPower = m_txPower; - std::map::iterator it = m_paMap.find(rnti); + auto it = m_paMap.find(rnti); if (it != m_paMap.end()) { rbgTxPower = m_txPower + it->second; @@ -525,8 +523,7 @@ void LteEnbPhy::ReceiveLteControlMessageList(std::list> msgList) { NS_LOG_FUNCTION(this); - std::list>::iterator it; - for (it = msgList.begin(); it != msgList.end(); it++) + for (auto it = msgList.begin(); it != msgList.end(); it++) { switch ((*it)->GetMessageType()) { @@ -626,12 +623,10 @@ LteEnbPhy::StartSubFrame() // update info on TB to be received std::list uldcilist = DequeueUlDci(); - std::list::iterator dciIt = uldcilist.begin(); NS_LOG_DEBUG(this << " eNB Expected TBs " << uldcilist.size()); - for (dciIt = uldcilist.begin(); dciIt != uldcilist.end(); dciIt++) + for (auto dciIt = uldcilist.begin(); dciIt != uldcilist.end(); dciIt++) { - std::set::iterator it2; - it2 = m_ueAttached.find((*dciIt).GetDci().m_rnti); + auto it2 = m_ueAttached.find((*dciIt).GetDci().m_rnti); if (it2 == m_ueAttached.end()) { @@ -674,8 +669,7 @@ LteEnbPhy::StartSubFrame() m_dlPowerAllocationMap.clear(); if (!ctrlMsg.empty()) { - std::list>::iterator it; - it = ctrlMsg.begin(); + auto it = ctrlMsg.begin(); while (it != ctrlMsg.end()) { Ptr msg = (*it); @@ -726,10 +720,7 @@ LteEnbPhy::StartSubFrame() else if (msg->GetMessageType() == LteControlMessage::RAR) { Ptr rarMsg = DynamicCast(msg); - for (std::list::const_iterator it = - rarMsg->RarListBegin(); - it != rarMsg->RarListEnd(); - ++it) + for (auto it = rarMsg->RarListBegin(); it != rarMsg->RarListEnd(); ++it) { if (it->rarPayload.m_grant.m_ulDelay) { @@ -870,10 +861,9 @@ FfMacSchedSapProvider::SchedUlCqiInfoReqParameters LteEnbPhy::CreatePuschCqiReport(const SpectrumValue& sinr) { NS_LOG_FUNCTION(this << sinr); - Values::const_iterator it; FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqi; ulcqi.m_ulCqi.m_type = UlCqi_s::PUSCH; - for (it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) + for (auto it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) { double sinrdb = 10 * std::log10((*it)); // NS_LOG_DEBUG ("ULCQI RB " << i << " value " << sinrdb); @@ -936,7 +926,7 @@ LteEnbPhy::DoRemoveUe(uint16_t rnti) NS_ASSERT_MSG(success, "DeleteUePhy() failed"); // remove also P_A value - std::map::iterator it = m_paMap.find(rnti); + auto it = m_paMap.find(rnti); if (it != m_paMap.end()) { m_paMap.erase(it); @@ -945,7 +935,7 @@ LteEnbPhy::DoRemoveUe(uint16_t rnti) // additional data to be removed m_uplinkSpectrumPhy->RemoveExpectedTb(rnti); // remove srs info to avoid trace errors - std::map::iterator sit = m_srsSampleCounterMap.find(rnti); + auto sit = m_srsSampleCounterMap.find(rnti); if (sit != m_srsSampleCounterMap.end()) { m_srsSampleCounterMap.erase(rnti); @@ -955,7 +945,7 @@ LteEnbPhy::DoRemoveUe(uint16_t rnti) for (auto& ctrlMessageList : m_controlMessagesQueue) { - std::list>::iterator ctrlMsgListIt = ctrlMessageList.begin(); + auto ctrlMsgListIt = ctrlMessageList.begin(); while (ctrlMsgListIt != ctrlMessageList.end()) { Ptr msg = (*ctrlMsgListIt); @@ -1000,7 +990,7 @@ LteEnbPhy::DoSetPa(uint16_t rnti, double pa) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_paMap.find(rnti); + auto it = m_paMap.find(rnti); if (it == m_paMap.end()) { @@ -1016,12 +1006,11 @@ FfMacSchedSapProvider::SchedUlCqiInfoReqParameters LteEnbPhy::CreateSrsCqiReport(const SpectrumValue& sinr) { NS_LOG_FUNCTION(this << sinr); - Values::const_iterator it; FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqi; ulcqi.m_ulCqi.m_type = UlCqi_s::SRS; int i = 0; double srsSum = 0.0; - for (it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) + for (auto it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) { double sinrdb = 10 * log10((*it)); // NS_LOG_DEBUG ("ULCQI RB " << i << " value " << sinrdb); @@ -1048,7 +1037,7 @@ void LteEnbPhy::CreateSrsReport(uint16_t rnti, double srs) { NS_LOG_FUNCTION(this << rnti << srs); - std::map::iterator it = m_srsSampleCounterMap.find(rnti); + auto it = m_srsSampleCounterMap.find(rnti); if (it == m_srsSampleCounterMap.end()) { // create new entry @@ -1119,7 +1108,7 @@ LteEnbPhy::DoSetSrsConfigurationIndex(uint16_t rnti, uint16_t srcCi) NS_LOG_DEBUG(this << " ENB SRS P " << m_srsPeriodicity << " RNTI " << rnti << " offset " << GetSrsSubframeOffset(srcCi) << " CI " << srcCi); - std::map::iterator it = m_srsCounter.find(rnti); + auto it = m_srsCounter.find(rnti); if (it != m_srsCounter.end()) { (*it).second = GetSrsSubframeOffset(srcCi) + 1; diff --git a/src/lte/model/lte-enb-rrc.cc b/src/lte/model/lte-enb-rrc.cc index e11c1cff3..f1e690823 100644 --- a/src/lte/model/lte-enb-rrc.cc +++ b/src/lte/model/lte-enb-rrc.cc @@ -320,9 +320,7 @@ UeManager::DoDispose() { delete m_drbPdcpSapUser; // delete eventual X2-U TEIDs - for (std::map>::iterator it = m_drbMap.begin(); - it != m_drbMap.end(); - ++it) + for (auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it) { m_rrc->m_x2uTeidInfoMap.erase(it->second->m_gtpTeid); } @@ -425,9 +423,8 @@ UeManager::SetupDataRadioBearer(EpsBearer bearer, LteEnbRrc::X2uTeidInfo x2uTeidInfo; x2uTeidInfo.rnti = m_rnti; x2uTeidInfo.drbid = drbid; - std::pair::iterator, bool> ret = - m_rrc->m_x2uTeidInfoMap.insert( - std::pair(gtpTeid, x2uTeidInfo)); + auto ret = m_rrc->m_x2uTeidInfoMap.insert( + std::pair(gtpTeid, x2uTeidInfo)); NS_ASSERT_MSG(ret.second == true, "overwriting a pre-existing entry in m_x2uTeidInfoMap"); } @@ -478,7 +475,7 @@ UeManager::SetupDataRadioBearer(EpsBearer bearer, // lcinfo.gbrDl = bearer.gbrQosInfo.gbrDl; // use a for cycle to send the AddLc to the appropriate Mac Sap // if the sap is not initialized the appropriated method has to be called - std::vector::iterator itLcOnCcMapping = lcOnCcMapping.begin(); + auto itLcOnCcMapping = lcOnCcMapping.begin(); NS_ASSERT_MSG(itLcOnCcMapping != lcOnCcMapping.end(), "Problem"); for (itLcOnCcMapping = lcOnCcMapping.begin(); itLcOnCcMapping != lcOnCcMapping.end(); ++itLcOnCcMapping) @@ -523,9 +520,7 @@ void UeManager::RecordDataRadioBearersToBeStarted() { NS_LOG_FUNCTION(this << (uint32_t)m_rnti); - for (std::map>::iterator it = m_drbMap.begin(); - it != m_drbMap.end(); - ++it) + for (auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it) { m_drbsToBeStarted.push_back(it->first); } @@ -535,11 +530,9 @@ void UeManager::StartDataRadioBearers() { NS_LOG_FUNCTION(this << (uint32_t)m_rnti); - for (std::list::iterator drbIdIt = m_drbsToBeStarted.begin(); - drbIdIt != m_drbsToBeStarted.end(); - ++drbIdIt) + for (auto drbIdIt = m_drbsToBeStarted.begin(); drbIdIt != m_drbsToBeStarted.end(); ++drbIdIt) { - std::map>::iterator drbIt = m_drbMap.find(*drbIdIt); + auto drbIt = m_drbMap.find(*drbIdIt); NS_ASSERT(drbIt != m_drbMap.end()); drbIt->second->m_rlc->Initialize(); if (drbIt->second->m_pdcp) @@ -555,7 +548,7 @@ UeManager::ReleaseDataRadioBearer(uint8_t drbid) { NS_LOG_FUNCTION(this << (uint32_t)m_rnti << (uint32_t)drbid); uint8_t lcid = Drbid2Lcid(drbid); - std::map>::iterator it = m_drbMap.find(drbid); + auto it = m_drbMap.find(drbid); NS_ASSERT_MSG(it != m_drbMap.end(), "request to remove radio bearer with unknown drbid " << drbid); @@ -565,7 +558,7 @@ UeManager::ReleaseDataRadioBearer(uint8_t drbid) m_drbMap.erase(it); std::vector ccToRelease = m_rrc->m_ccmRrcSapProvider->ReleaseDataRadioBearer(m_rnti, lcid); - std::vector::iterator itCcToRelease = ccToRelease.begin(); + auto itCcToRelease = ccToRelease.begin(); NS_ASSERT_MSG(itCcToRelease != ccToRelease.end(), "request to remove radio bearer with unknown drbid (ComponentCarrierManager)"); for (itCcToRelease = ccToRelease.begin(); itCcToRelease != ccToRelease.end(); ++itCcToRelease) @@ -856,9 +849,7 @@ UeManager::RecvHandoverRequestAck(EpcX2SapUser::HandoverRequestAckParams params) sst.newEnbUeX2apId = params.newEnbUeX2apId; sst.sourceCellId = params.sourceCellId; sst.targetCellId = params.targetCellId; - for (std::map>::iterator drbIt = m_drbMap.begin(); - drbIt != m_drbMap.end(); - ++drbIt) + for (auto drbIt = m_drbMap.begin(); drbIt != m_drbMap.end(); ++drbIt) { // SN status transfer is only for AM RLC if (drbIt->second->m_rlc->GetObject()) @@ -939,12 +930,13 @@ UeManager::SendPacket(uint8_t bid, Ptr p) params.lcid = Bid2Lcid(bid); uint8_t drbid = Bid2Drbid(bid); // Transmit PDCP sdu only if DRB ID found in drbMap - std::map>::iterator it = m_drbMap.find(drbid); + auto it = m_drbMap.find(drbid); if (it != m_drbMap.end()) { Ptr bearerInfo = GetDataRadioBearerInfo(drbid); if (bearerInfo) { + NS_LOG_INFO("Send packet to PDCP layer"); LtePdcpSapProvider* pdcpSapProvider = bearerInfo->m_pdcp->GetLtePdcpSapProvider(); pdcpSapProvider->TransmitPdcpSdu(params); } @@ -967,20 +959,20 @@ UeManager::SendData(uint8_t bid, Ptr p) case CONNECTION_REESTABLISHMENT: case HANDOVER_PREPARATION: case HANDOVER_PATH_SWITCH: { - NS_LOG_LOGIC("queueing data on PDCP for transmission over the air"); + NS_LOG_INFO("queueing data on PDCP for transmission over the air"); SendPacket(bid, p); } break; case HANDOVER_JOINING: { // Buffer data until RRC Connection Reconfiguration Complete message is received - NS_LOG_LOGIC("buffering data"); + NS_LOG_INFO("buffering data"); m_packetBuffer.emplace_back(bid, p); } break; case HANDOVER_LEAVING: { - NS_LOG_LOGIC("forwarding data to target eNB over X2-U"); + NS_LOG_INFO("forwarding data to target eNB over X2-U"); uint8_t drbid = Bid2Drbid(bid); EpcX2Sap::UeDataParams params; params.sourceCellId = m_rrc->ComponentCarrierToCellId(m_componentCarrierId); @@ -1002,9 +994,7 @@ UeManager::GetErabList() { NS_LOG_FUNCTION(this); std::vector ret; - for (std::map>::iterator it = m_drbMap.begin(); - it != m_drbMap.end(); - ++it) + for (auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it) { EpcX2Sap::ErabToBeSetupItem etbsi; etbsi.erabId = it->second->m_epsBearerIdentity; @@ -1079,8 +1069,7 @@ void UeManager::RecvSnStatusTransfer(EpcX2SapUser::SnStatusTransferParams params) { NS_LOG_FUNCTION(this); - for (std::vector::iterator erabIt = - params.erabsSubjectToStatusTransferList.begin(); + for (auto erabIt = params.erabsSubjectToStatusTransferList.begin(); erabIt != params.erabsSubjectToStatusTransferList.end(); ++erabIt) { @@ -1088,7 +1077,7 @@ UeManager::RecvSnStatusTransfer(EpcX2SapUser::SnStatusTransferParams params) // status.txSn = erabIt->dlPdcpSn; // status.rxSn = erabIt->ulPdcpSn; // uint8_t drbId = Bid2Drbid (erabIt->erabId); - // std::map >::iterator drbIt = m_drbMap.find (drbId); + // auto drbIt = m_drbMap.find (drbId); // NS_ASSERT_MSG (drbIt != m_drbMap.end (), "could not find DRBID " << (uint32_t) drbId); // drbIt->second->m_pdcp->SetStatus (status); } @@ -1293,9 +1282,7 @@ UeManager::RecvRrcConnectionReconfigurationCompleted( params.cellId = m_rrc->ComponentCarrierToCellId(m_componentCarrierId); params.mmeUeS1Id = m_imsi; SwitchToState(HANDOVER_PATH_SWITCH); - for (std::map>::iterator it = m_drbMap.begin(); - it != m_drbMap.end(); - ++it) + for (auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it) { EpcEnbS1SapProvider::BearerToBeSwitched b; b.epsBearerId = it->second->m_epsBearerIdentity; @@ -1362,8 +1349,7 @@ UeManager::RecvMeasurementReport(LteRrcSap::MeasurementReport msg) << (uint16_t)msg.measResults.measResultPCell.rsrpResult << " RSRQ " << (uint16_t)msg.measResults.measResultPCell.rsrqResult); - for (std::list::iterator it = - msg.measResults.measResultListEutra.begin(); + for (auto it = msg.measResults.measResultListEutra.begin(); it != msg.measResults.measResultListEutra.end(); ++it) { @@ -1586,7 +1572,7 @@ UeManager::GetDataRadioBearerInfo(uint8_t drbid) { NS_LOG_FUNCTION(this << (uint32_t)drbid); NS_ASSERT(0 != drbid); - std::map>::iterator it = m_drbMap.find(drbid); + auto it = m_drbMap.find(drbid); NS_ABORT_IF(it == m_drbMap.end()); return it->second; } @@ -1595,7 +1581,7 @@ void UeManager::RemoveDataRadioBearerInfo(uint8_t drbid) { NS_LOG_FUNCTION(this << (uint32_t)drbid); - std::map>::iterator it = m_drbMap.find(drbid); + auto it = m_drbMap.find(drbid); NS_ASSERT_MSG(it != m_drbMap.end(), "request to remove radio bearer with unknown drbid " << drbid); m_drbMap.erase(it); @@ -1642,9 +1628,7 @@ UeManager::BuildRadioResourceConfigDedicated() rrcd.srbToAddModList.push_back(stam); } - for (std::map>::iterator it = m_drbMap.begin(); - it != m_drbMap.end(); - ++it) + for (auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it) { LteRrcSap::DrbToAddMod dtam; dtam.epsBearerIdentity = it->second->m_epsBearerIdentity; @@ -1939,7 +1923,6 @@ LteEnbRrc::DoDispose() TypeId LteEnbRrc::GetTypeId() { - NS_LOG_FUNCTION("LteEnbRrc::GetTypeId"); static TypeId tid = TypeId("ns3::LteEnbRrc") .SetParent() @@ -2351,7 +2334,7 @@ bool LteEnbRrc::HasUeManager(uint16_t rnti) const { NS_LOG_FUNCTION(this << (uint32_t)rnti); - std::map>::const_iterator it = m_ueMap.find(rnti); + auto it = m_ueMap.find(rnti); return (it != m_ueMap.end()); } @@ -2360,7 +2343,7 @@ LteEnbRrc::GetUeManager(uint16_t rnti) { NS_LOG_FUNCTION(this << (uint32_t)rnti); NS_ASSERT(0 != rnti); - std::map>::iterator it = m_ueMap.find(rnti); + auto it = m_ueMap.find(rnti); NS_ASSERT_MSG(it != m_ueMap.end(), "UE manager for RNTI " << rnti << " not found"); return it->second; } @@ -2616,11 +2599,14 @@ bool LteEnbRrc::SendData(Ptr packet) { NS_LOG_FUNCTION(this << packet); - EpsBearerTag tag; bool found = packet->RemovePacketTag(tag); NS_ASSERT_MSG(found, "no EpsBearerTag found in packet to be sent"); Ptr ueManager = GetUeManager(tag.GetRnti()); + + NS_LOG_INFO("Sending a packet of " << packet->GetSize() << " bytes to IMSI " + << ueManager->GetImsi() << ", RNTI " << ueManager->GetRnti() + << ", BID " << (uint16_t)tag.GetBid()); ueManager->SendData(tag.GetBid(), packet); return true; @@ -2916,9 +2902,7 @@ LteEnbRrc::DoRecvHandoverRequest(EpcX2SapUser::HandoverRequestParams req) ackParams.sourceCellId = req.sourceCellId; ackParams.targetCellId = req.targetCellId; - for (std::vector::iterator it = req.bearers.begin(); - it != req.bearers.end(); - ++it) + for (auto it = req.bearers.begin(); it != req.bearers.end(); ++it) { ueManager->SetupDataRadioBearer(it->erabLevelQosParameters, it->erabId, @@ -3083,7 +3067,7 @@ LteEnbRrc::DoRecvUeData(EpcX2SapUser::UeDataParams params) NS_LOG_LOGIC("ueData = " << params.ueData); NS_LOG_LOGIC("ueData size = " << params.ueData->GetSize()); - std::map::iterator teidInfoIt = m_x2uTeidInfoMap.find(params.gtpTeid); + auto teidInfoIt = m_x2uTeidInfoMap.find(params.gtpTeid); if (teidInfoIt != m_x2uTeidInfoMap.end()) { GetUeManager(teidInfoIt->second.rnti)->SendData(teidInfoIt->second.drbid, params.ueData); @@ -3276,7 +3260,7 @@ void LteEnbRrc::RemoveUe(uint16_t rnti) { NS_LOG_FUNCTION(this << (uint32_t)rnti); - std::map>::iterator it = m_ueMap.find(rnti); + auto it = m_ueMap.find(rnti); NS_ASSERT_MSG(it != m_ueMap.end(), "request to remove UE info with unknown rnti " << rnti); uint64_t imsi = it->second->GetImsi(); uint16_t srsCi = (*it).second->GetSrsConfigurationIndex(); @@ -3438,7 +3422,7 @@ LteEnbRrc::GetNewSrsConfigurationIndex() else { // find a CI from the available ones - std::set::reverse_iterator rit = m_ueSrsConfigurationIndexSet.rbegin(); + auto rit = m_ueSrsConfigurationIndexSet.rbegin(); NS_ASSERT(rit != m_ueSrsConfigurationIndexSet.rend()); NS_LOG_DEBUG(this << " lower bound " << (*rit) << " of " << g_srsCiHigh[m_srsCurrentPeriodicityId]); @@ -3455,7 +3439,7 @@ LteEnbRrc::GetNewSrsConfigurationIndex() srcCi < g_srsCiHigh[m_srsCurrentPeriodicityId]; srcCi++) { - std::set::iterator it = m_ueSrsConfigurationIndexSet.find(srcCi); + auto it = m_ueSrsConfigurationIndexSet.find(srcCi); if (it == m_ueSrsConfigurationIndexSet.end()) { m_lastAllocatedConfigurationIndex = srcCi; @@ -3472,7 +3456,7 @@ void LteEnbRrc::RemoveSrsConfigurationIndex(uint16_t srcCi) { NS_LOG_FUNCTION(this << srcCi); - std::set::iterator it = m_ueSrsConfigurationIndexSet.find(srcCi); + auto it = m_ueSrsConfigurationIndexSet.find(srcCi); NS_ASSERT_MSG(it != m_ueSrsConfigurationIndexSet.end(), "request to remove unknown SRS CI " << srcCi); m_ueSrsConfigurationIndexSet.erase(it); diff --git a/src/lte/model/lte-ffr-distributed-algorithm.cc b/src/lte/model/lte-ffr-distributed-algorithm.cc index fc2b39b2f..85bea3eb1 100644 --- a/src/lte/model/lte-ffr-distributed-algorithm.cc +++ b/src/lte/model/lte-ffr-distributed-algorithm.cc @@ -247,7 +247,7 @@ LteFfrDistributedAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) bool edgeRbg = m_dlEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -288,7 +288,7 @@ LteFfrDistributedAlgorithm::DoIsUlRbgAvailableForUe(int rbId, uint16_t rnti) bool edgeRbg = m_ulEdgeRbgMap[rbId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -348,7 +348,7 @@ LteFfrDistributedAlgorithm::DoGetTpc(uint16_t rnti) //------------------------------------------------ // here Absolute mode is used - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { return 1; @@ -397,7 +397,7 @@ LteFfrDistributedAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults if (measResults.measId == m_rsrqMeasId) { // check if it is center or edge UE - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -431,7 +431,7 @@ LteFfrDistributedAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults } else if (measResults.measId == m_rsrpMeasId) { - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -444,8 +444,7 @@ LteFfrDistributedAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults if (measResults.haveMeasResultNeighCells && !measResults.measResultListEutra.empty()) { - for (std::list::iterator it = - measResults.measResultListEutra.begin(); + for (auto it = measResults.measResultListEutra.begin(); it != measResults.measResultListEutra.end(); ++it) { @@ -456,9 +455,7 @@ LteFfrDistributedAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults UpdateNeighbourMeasurements(rnti, it->physCellId, it->rsrpResult, it->rsrqResult); bool found = false; - for (std::vector::iterator ncIt = m_neighborCell.begin(); - ncIt != m_neighborCell.end(); - ncIt++) + for (auto ncIt = m_neighborCell.begin(); ncIt != m_neighborCell.end(); ncIt++) { if ((*ncIt) == it->physCellId) { @@ -499,14 +496,11 @@ LteFfrDistributedAlgorithm::Calculate() m_ulEdgeRbgMap.clear(); m_ulEdgeRbgMap.resize(m_ulBandwidth, false); - MeasurementTable_t::iterator it1; - MeasurementRow_t::iterator it2; Ptr servingCellMeasures; Ptr neighbourCellMeasures; uint32_t edgeUeNum = 0; - std::map::iterator areaIt; - for (areaIt = m_ues.begin(); areaIt != m_ues.end(); areaIt++) + for (auto areaIt = m_ues.begin(); areaIt != m_ues.end(); areaIt++) { if (areaIt->second == EdgeArea) { @@ -516,9 +510,9 @@ LteFfrDistributedAlgorithm::Calculate() if (edgeUeNum != 0) { - for (it1 = m_ueMeasures.begin(); it1 != m_ueMeasures.end(); it1++) + for (auto it1 = m_ueMeasures.begin(); it1 != m_ueMeasures.end(); it1++) { - std::map::iterator areaIt = m_ues.find(it1->first); + auto areaIt = m_ues.find(it1->first); if (areaIt->second != EdgeArea) { continue; @@ -527,7 +521,7 @@ LteFfrDistributedAlgorithm::Calculate() servingCellMeasures = nullptr; neighbourCellMeasures = nullptr; - it2 = it1->second.find(m_cellId); + auto it2 = it1->second.find(m_cellId); if (it2 != it1->second.end()) { servingCellMeasures = it2->second; @@ -573,13 +567,12 @@ LteFfrDistributedAlgorithm::Calculate() metricA[i] = 0; } - std::map::iterator cellIt; - for (cellIt = m_cellWeightMap.begin(); cellIt != m_cellWeightMap.end(); cellIt++) + for (auto cellIt = m_cellWeightMap.begin(); cellIt != m_cellWeightMap.end(); cellIt++) { NS_LOG_INFO("CellId: " << m_cellId << " NeighborCellId: " << cellIt->first << " Weight: " << cellIt->second); - std::map>::iterator rntpIt = m_rntp.find(cellIt->first); + auto rntpIt = m_rntp.find(cellIt->first); if (rntpIt == m_rntp.end()) { continue; @@ -596,15 +589,12 @@ LteFfrDistributedAlgorithm::Calculate() std::vector sortedRbgByMetric; std::multimap sortedMetricA; - for (std::map::const_iterator it = metricA.begin(); it != metricA.end(); - ++it) + for (auto it = metricA.begin(); it != metricA.end(); ++it) { sortedMetricA.insert(std::pair(it->second, it->first)); } - for (std::multimap::const_iterator it = sortedMetricA.begin(); - it != sortedMetricA.end(); - ++it) + for (auto it = sortedMetricA.begin(); it != sortedMetricA.end(); ++it) { sortedRbgByMetric.push_back(it->second); } @@ -625,9 +615,7 @@ LteFfrDistributedAlgorithm::Calculate() } } - for (std::vector::iterator ncIt = m_neighborCell.begin(); - ncIt != m_neighborCell.end(); - ncIt++) + for (auto ncIt = m_neighborCell.begin(); ncIt != m_neighborCell.end(); ncIt++) { SendLoadInformation((*ncIt)); } @@ -674,7 +662,7 @@ LteFfrDistributedAlgorithm::DoRecvLoadInformation(EpcX2Sap::LoadInformationParam } uint16_t neighborCellId = params.cellInformationList[0].sourceCellId; - std::map>::iterator it = m_rntp.find(neighborCellId); + auto it = m_rntp.find(neighborCellId); if (it != m_rntp.end()) { it->second = params.cellInformationList[0].relativeNarrowbandTxBand.rntpPerPrbList; @@ -695,22 +683,19 @@ LteFfrDistributedAlgorithm::UpdateNeighbourMeasurements(uint16_t rnti, { NS_LOG_FUNCTION(this << rnti << cellId << (uint16_t)rsrq); - MeasurementTable_t::iterator it1; - it1 = m_ueMeasures.find(rnti); + auto it1 = m_ueMeasures.find(rnti); if (it1 == m_ueMeasures.end()) { // insert a new UE entry MeasurementRow_t row; - std::pair ret; - ret = m_ueMeasures.insert(std::pair(rnti, row)); + auto ret = m_ueMeasures.insert(std::pair(rnti, row)); NS_ASSERT(ret.second); it1 = ret.first; } NS_ASSERT(it1 != m_ueMeasures.end()); - std::map>::iterator it2; - it2 = it1->second.find(cellId); + auto it2 = it1->second.find(cellId); if (it2 != it1->second.end()) { diff --git a/src/lte/model/lte-ffr-enhanced-algorithm.cc b/src/lte/model/lte-ffr-enhanced-algorithm.cc index 90afde1b6..95b77bde7 100644 --- a/src/lte/model/lte-ffr-enhanced-algorithm.cc +++ b/src/lte/model/lte-ffr-enhanced-algorithm.cc @@ -478,8 +478,7 @@ LteFfrEnhancedAlgorithm::DoGetAvailableDlRbg() std::vector rbgMap = m_dlRbgMap; - std::map>::iterator it; - for (it = m_dlRbgAvailableforUe.begin(); it != m_dlRbgAvailableforUe.end(); it++) + for (auto it = m_dlRbgAvailableforUe.begin(); it != m_dlRbgAvailableforUe.end(); it++) { NS_LOG_INFO("RNTI : " << it->first); std::vector rbgAvailableMap = it->second; @@ -506,7 +505,7 @@ LteFfrEnhancedAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) bool isPrimarySegmentRbg = m_dlPrimarySegmentRbgMap[rbgId]; bool isSecondarySegmentRbg = m_dlSecondarySegmentRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -541,7 +540,7 @@ LteFfrEnhancedAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) { // check if RB can be used by UE based on CQI information NS_LOG_INFO("SECONDARY SEGMENT RNTI: " << rnti << " rbgId: " << rbgId); - std::map>::iterator it = m_dlRbgAvailableforUe.find(rnti); + auto it = m_dlRbgAvailableforUe.find(rnti); if (it != m_dlRbgAvailableforUe.end()) { NS_LOG_INFO("RNTI: " << rnti << " rbgId: " << rbgId @@ -574,8 +573,7 @@ LteFfrEnhancedAlgorithm::DoGetAvailableUlRbg() std::vector rbgMap = m_ulRbgMap; - std::map>::iterator it; - for (it = m_ulRbAvailableforUe.begin(); it != m_ulRbAvailableforUe.end(); it++) + for (auto it = m_ulRbAvailableforUe.begin(); it != m_ulRbAvailableforUe.end(); it++) { NS_LOG_INFO("RNTI : " << it->first); std::vector rbAvailableMap = it->second; @@ -607,7 +605,7 @@ LteFfrEnhancedAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) bool isPrimarySegmentRbg = m_ulPrimarySegmentRbgMap[rbgId]; bool isSecondarySegmentRbg = m_ulSecondarySegmentRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -641,7 +639,7 @@ LteFfrEnhancedAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) { // check if RB can be used by UE based on CQI information NS_LOG_INFO("UL SECONDARY SEGMENT RNTI: " << rnti << " rbgId: " << rbgId); - std::map>::iterator it = m_ulRbAvailableforUe.find(rnti); + auto it = m_ulRbAvailableforUe.find(rnti); if (it != m_ulRbAvailableforUe.end()) { NS_LOG_INFO("RNTI: " << rnti << " rbgId: " << rbgId @@ -670,10 +668,9 @@ LteFfrEnhancedAlgorithm::DoReportDlCqiInfo( { NS_LOG_INFO("subband CQI reporting high layer configured"); // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - std::map::iterator ueIt = m_ues.find(rnti); + auto ueIt = m_ues.find(rnti); if (ueIt != m_ues.end()) { if (ueIt->second != CenterArea) @@ -686,7 +683,7 @@ LteFfrEnhancedAlgorithm::DoReportDlCqiInfo( continue; } - it = m_dlCqi.find(rnti); + auto it = m_dlCqi.find(rnti); if (it == m_dlCqi.end()) { // create the new entry @@ -708,8 +705,7 @@ LteFfrEnhancedAlgorithm::DoReportDlCqiInfo( uint32_t rbgSize = GetRbgSize(m_dlBandwidth); m_dlRbgAvailableforUe.clear(); - std::map::iterator it; - for (it = m_dlCqi.begin(); it != m_dlCqi.end(); it++) + for (auto it = m_dlCqi.begin(); it != m_dlCqi.end(); it++) { uint16_t rnti = it->first; std::vector rbgAvailableMap; @@ -741,9 +737,7 @@ LteFfrEnhancedAlgorithm::DoReportDlCqiInfo( } m_ulRbAvailableforUe.clear(); - for (std::map>::iterator it = m_dlRbgAvailableforUe.begin(); - it != m_dlRbgAvailableforUe.end(); - it++) + for (auto it = m_dlRbgAvailableforUe.begin(); it != m_dlRbgAvailableforUe.end(); it++) { uint16_t rnti = it->first; std::vector dlRbgAvailableMap = it->second; @@ -796,7 +790,7 @@ LteFfrEnhancedAlgorithm::EstimateUlSinr(uint16_t rnti, uint16_t rb, std::map> ulCqiMap) { - std::map>::iterator itCqi = ulCqiMap.find(rnti); + auto itCqi = ulCqiMap.find(rnti); if (itCqi == ulCqiMap.end()) { // no cqi info about this UE @@ -844,7 +838,7 @@ LteFfrEnhancedAlgorithm::DoGetTpc(uint16_t rnti) //------------------------------------------------ // here Absolute mode is used - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { return 1; @@ -903,7 +897,7 @@ LteFfrEnhancedAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults me } else { - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); diff --git a/src/lte/model/lte-ffr-soft-algorithm.cc b/src/lte/model/lte-ffr-soft-algorithm.cc index a38ae488c..06e7c7344 100644 --- a/src/lte/model/lte-ffr-soft-algorithm.cc +++ b/src/lte/model/lte-ffr-soft-algorithm.cc @@ -424,7 +424,7 @@ LteFfrSoftAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) bool isMediumRbg = m_dlMediumRbgMap[rbgId]; bool isEdgeRbg = m_dlEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -485,7 +485,7 @@ LteFfrSoftAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) bool isMediumRbg = m_ulMediumRbgMap[rbgId]; bool isEdgeRbg = m_ulEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -563,7 +563,7 @@ LteFfrSoftAlgorithm::DoGetTpc(uint16_t rnti) //------------------------------------------------ // here Absolute mode is used - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { return 1; @@ -662,7 +662,7 @@ LteFfrSoftAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measRe } else { - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); diff --git a/src/lte/model/lte-fr-soft-algorithm.cc b/src/lte/model/lte-fr-soft-algorithm.cc index c38e1e886..82b855202 100644 --- a/src/lte/model/lte-fr-soft-algorithm.cc +++ b/src/lte/model/lte-fr-soft-algorithm.cc @@ -359,7 +359,7 @@ LteFrSoftAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) bool edgeRbg = m_dlEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -405,7 +405,7 @@ LteFrSoftAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) bool edgeRbg = m_ulEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -470,7 +470,7 @@ LteFrSoftAlgorithm::DoGetTpc(uint16_t rnti) //------------------------------------------------ // here Absolute mode is used - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { return 1; @@ -536,7 +536,7 @@ LteFrSoftAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measRes } else { - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); diff --git a/src/lte/model/lte-fr-strict-algorithm.cc b/src/lte/model/lte-fr-strict-algorithm.cc index d09a12c07..5ca8da0c7 100644 --- a/src/lte/model/lte-fr-strict-algorithm.cc +++ b/src/lte/model/lte-fr-strict-algorithm.cc @@ -397,7 +397,7 @@ LteFrStrictAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) bool edgeRbg = m_dlEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -438,7 +438,7 @@ LteFrStrictAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) bool edgeRbg = m_ulEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -498,7 +498,7 @@ LteFrStrictAlgorithm::DoGetTpc(uint16_t rnti) //------------------------------------------------ // here Absolute mode is used - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { return 1; @@ -548,7 +548,7 @@ LteFrStrictAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measR } else { - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); diff --git a/src/lte/model/lte-harq-phy.cc b/src/lte/model/lte-harq-phy.cc index 921a75bd1..df5580603 100644 --- a/src/lte/model/lte-harq-phy.cc +++ b/src/lte/model/lte-harq-phy.cc @@ -53,8 +53,7 @@ LteHarqPhy::SubframeIndication(uint32_t frameNo, uint32_t subframeNo) NS_LOG_FUNCTION(this); // left shift UL HARQ buffers - std::map>::iterator it; - for (it = m_miUlHarqProcessesInfoMap.begin(); it != m_miUlHarqProcessesInfoMap.end(); it++) + for (auto it = m_miUlHarqProcessesInfoMap.begin(); it != m_miUlHarqProcessesInfoMap.end(); it++) { (*it).second.erase((*it).second.begin()); HarqProcessInfoList_t h; @@ -87,8 +86,7 @@ LteHarqPhy::GetAccumulatedMiUl(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map>::iterator it; - it = m_miUlHarqProcessesInfoMap.find(rnti); + auto it = m_miUlHarqProcessesInfoMap.find(rnti); NS_ASSERT_MSG(it != m_miUlHarqProcessesInfoMap.end(), " Does not find MI for RNTI"); HarqProcessInfoList_t list = (*it).second.at(0); double mi = 0.0; @@ -103,8 +101,7 @@ HarqProcessInfoList_t LteHarqPhy::GetHarqProcessInfoUl(uint16_t rnti, uint8_t harqProcId) { NS_LOG_FUNCTION(this << rnti << (uint16_t)harqProcId); - std::map>::iterator it; - it = m_miUlHarqProcessesInfoMap.find(rnti); + auto it = m_miUlHarqProcessesInfoMap.find(rnti); if (it == m_miUlHarqProcessesInfoMap.end()) { // new entry @@ -157,8 +154,7 @@ LteHarqPhy::UpdateUlHarqProcessStatus(uint16_t rnti, uint16_t codeBytes) { NS_LOG_FUNCTION(this << rnti << mi); - std::map>::iterator it; - it = m_miUlHarqProcessesInfoMap.find(rnti); + auto it = m_miUlHarqProcessesInfoMap.find(rnti); if (it == m_miUlHarqProcessesInfoMap.end()) { // new entry @@ -199,8 +195,7 @@ void LteHarqPhy::ResetUlHarqProcessStatus(uint16_t rnti, uint8_t id) { NS_LOG_FUNCTION(this << rnti << (uint16_t)id); - std::map>::iterator it; - it = m_miUlHarqProcessesInfoMap.find(rnti); + auto it = m_miUlHarqProcessesInfoMap.find(rnti); if (it == m_miUlHarqProcessesInfoMap.end()) { // new entry diff --git a/src/lte/model/lte-interference.cc b/src/lte/model/lte-interference.cc index 8e332ebe8..f7dd0c846 100644 --- a/src/lte/model/lte-interference.cc +++ b/src/lte/model/lte-interference.cc @@ -72,24 +72,17 @@ LteInterference::StartRx(Ptr rxPsd) m_rxSignal = rxPsd->Copy(); m_lastChangeTime = Now(); m_receiving = true; - for (std::list>::const_iterator it = - m_rsPowerChunkProcessorList.begin(); - it != m_rsPowerChunkProcessorList.end(); + for (auto it = m_rsPowerChunkProcessorList.begin(); it != m_rsPowerChunkProcessorList.end(); ++it) { (*it)->Start(); } - for (std::list>::const_iterator it = - m_interfChunkProcessorList.begin(); - it != m_interfChunkProcessorList.end(); + for (auto it = m_interfChunkProcessorList.begin(); it != m_interfChunkProcessorList.end(); ++it) { (*it)->Start(); } - for (std::list>::const_iterator it = - m_sinrChunkProcessorList.begin(); - it != m_sinrChunkProcessorList.end(); - ++it) + for (auto it = m_sinrChunkProcessorList.begin(); it != m_sinrChunkProcessorList.end(); ++it) { (*it)->Start(); } @@ -117,24 +110,17 @@ LteInterference::EndRx() { ConditionallyEvaluateChunk(); m_receiving = false; - for (std::list>::const_iterator it = - m_rsPowerChunkProcessorList.begin(); - it != m_rsPowerChunkProcessorList.end(); + for (auto it = m_rsPowerChunkProcessorList.begin(); it != m_rsPowerChunkProcessorList.end(); ++it) { (*it)->End(); } - for (std::list>::const_iterator it = - m_interfChunkProcessorList.begin(); - it != m_interfChunkProcessorList.end(); + for (auto it = m_interfChunkProcessorList.begin(); it != m_interfChunkProcessorList.end(); ++it) { (*it)->End(); } - for (std::list>::const_iterator it = - m_sinrChunkProcessorList.begin(); - it != m_sinrChunkProcessorList.end(); - ++it) + for (auto it = m_sinrChunkProcessorList.begin(); it != m_sinrChunkProcessorList.end(); ++it) { (*it)->End(); } @@ -201,23 +187,16 @@ LteInterference::ConditionallyEvaluateChunk() SpectrumValue sinr = (*m_rxSignal) / interf; Time duration = Now() - m_lastChangeTime; - for (std::list>::const_iterator it = - m_sinrChunkProcessorList.begin(); - it != m_sinrChunkProcessorList.end(); - ++it) + for (auto it = m_sinrChunkProcessorList.begin(); it != m_sinrChunkProcessorList.end(); ++it) { (*it)->EvaluateChunk(sinr, duration); } - for (std::list>::const_iterator it = - m_interfChunkProcessorList.begin(); - it != m_interfChunkProcessorList.end(); + for (auto it = m_interfChunkProcessorList.begin(); it != m_interfChunkProcessorList.end(); ++it) { (*it)->EvaluateChunk(interf, duration); } - for (std::list>::const_iterator it = - m_rsPowerChunkProcessorList.begin(); - it != m_rsPowerChunkProcessorList.end(); + for (auto it = m_rsPowerChunkProcessorList.begin(); it != m_rsPowerChunkProcessorList.end(); ++it) { (*it)->EvaluateChunk(*m_rxSignal, duration); diff --git a/src/lte/model/lte-mi-error-model.cc b/src/lte/model/lte-mi-error-model.cc index 946042da0..d0c562ffb 100644 --- a/src/lte/model/lte-mi-error-model.cc +++ b/src/lte/model/lte-mi-error-model.cc @@ -1042,7 +1042,7 @@ LteMiErrorModel::GetPcfichPdcchError(const SpectrumValue& sinr) NS_LOG_FUNCTION(sinr); double MI; double MIsum = 0.0; - Values::const_iterator sinrIt = sinr.ConstValuesBegin(); + auto sinrIt = sinr.ConstValuesBegin(); uint16_t rb = 0; NS_ASSERT(sinrIt != sinr.ConstValuesEnd()); while (sinrIt != sinr.ConstValuesEnd()) diff --git a/src/lte/model/lte-pdcp.cc b/src/lte/model/lte-pdcp.cc index e970535f1..a9e8dd839 100644 --- a/src/lte/model/lte-pdcp.cc +++ b/src/lte/model/lte-pdcp.cc @@ -191,8 +191,6 @@ LtePdcp::DoTransmitPdcpSdu(LtePdcpSapProvider::TransmitPdcpSduParameters params) } pdcpHeader.SetDcBit(LtePdcpHeader::DATA_PDU); - - NS_LOG_LOGIC("PDCP header: " << pdcpHeader); p->AddHeader(pdcpHeader); p->AddByteTag(pdcpTag, 1, pdcpHeader.GetSerializedSize()); @@ -203,6 +201,7 @@ LtePdcp::DoTransmitPdcpSdu(LtePdcpSapProvider::TransmitPdcpSduParameters params) txParams.lcid = m_lcid; txParams.pdcpPdu = p; + NS_LOG_INFO("Transmitting PDCP PDU with header: " << pdcpHeader); m_rlcSapProvider->TransmitPdcpPdu(txParams); } diff --git a/src/lte/model/lte-rlc-am-header.cc b/src/lte/model/lte-rlc-am-header.cc index 56a476ee6..b6408ca10 100644 --- a/src/lte/model/lte-rlc-am-header.cc +++ b/src/lte/model/lte-rlc-am-header.cc @@ -248,8 +248,7 @@ LteRlcAmHeader::IsNackPresent(SequenceNumber10 nack) NS_LOG_FUNCTION(this); NS_ASSERT_MSG(m_dataControlBit == CONTROL_PDU && m_controlPduType == LteRlcAmHeader::STATUS_PDU, "method allowed only for STATUS PDUs"); - for (std::list::iterator nackIt = m_nackSnList.begin(); nackIt != m_nackSnList.end(); - ++nackIt) + for (auto nackIt = m_nackSnList.begin(); nackIt != m_nackSnList.end(); ++nackIt) { if ((*nackIt) == nack.GetValue()) { @@ -301,9 +300,9 @@ LteRlcAmHeader::GetInstanceTypeId() const void LteRlcAmHeader::Print(std::ostream& os) const { - std::list::const_iterator it1 = m_extensionBits.begin(); - std::list::const_iterator it2 = m_lengthIndicators.begin(); - std::list::const_iterator it3 = m_nackSnList.begin(); + auto it1 = m_extensionBits.begin(); + auto it2 = m_lengthIndicators.begin(); + auto it3 = m_nackSnList.begin(); os << "Len=" << m_headerLength; os << " D/C=" << (uint16_t)m_dataControlBit; @@ -362,9 +361,9 @@ LteRlcAmHeader::Serialize(Buffer::Iterator start) const { Buffer::Iterator i = start; - std::list::const_iterator it1 = m_extensionBits.begin(); - std::list::const_iterator it2 = m_lengthIndicators.begin(); - std::list::const_iterator it3 = m_nackSnList.begin(); + auto it1 = m_extensionBits.begin(); + auto it2 = m_lengthIndicators.begin(); + auto it3 = m_nackSnList.begin(); if (m_dataControlBit == DATA_PDU) { diff --git a/src/lte/model/lte-rlc-am.cc b/src/lte/model/lte-rlc-am.cc index d4e8ffc14..03c190e7a 100644 --- a/src/lte/model/lte-rlc-am.cc +++ b/src/lte/model/lte-rlc-am.cc @@ -238,7 +238,6 @@ LteRlcAm::DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParam << m_vrMs.GetValue()); SequenceNumber10 sn; sn.SetModulusBase(m_vrR); - std::map::iterator pduIt; for (sn = m_vrR; sn < m_vrMs; sn++) { NS_LOG_LOGIC("SN = " << sn); @@ -247,7 +246,7 @@ LteRlcAm::DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParam NS_LOG_LOGIC("Can't fit more NACKs in STATUS PDU"); break; } - pduIt = m_rxonBuffer.find(sn.GetValue()); + auto pduIt = m_rxonBuffer.find(sn.GetValue()); if (pduIt == m_rxonBuffer.end() || (!(pduIt->second.m_pduComplete))) { NS_LOG_LOGIC("adding NACK_SN " << sn.GetValue()); @@ -258,7 +257,7 @@ LteRlcAm::DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParam // 3GPP TS 36.322 section 6.2.2.1.4 ACK SN // find the SN of the next not received RLC Data PDU // which is not reported as missing in the STATUS PDU. - pduIt = m_rxonBuffer.find(sn.GetValue()); + auto pduIt = m_rxonBuffer.find(sn.GetValue()); while ((sn < m_vrMs) && (pduIt != m_rxonBuffer.end()) && (pduIt->second.m_pduComplete)) { NS_LOG_LOGIC("SN = " << sn << " < " << m_vrMs << " = " << (sn < m_vrMs)); @@ -660,8 +659,7 @@ LteRlcAm::DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParam // Calculate FramingInfo flag according the status of the SDUs in the DataField uint8_t framingInfo = 0; - std::vector>::iterator it; - it = dataField.begin(); + auto it = dataField.begin(); // FIRST SEGMENT LteRlcSduStatusTag tag; @@ -926,7 +924,7 @@ LteRlcAm::DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) // - discard the duplicate byte segments. // note: re-segmentation of AMD PDU is currently not supported, // so we just check that the segment was not received before - std::map::iterator it = m_rxonBuffer.find(seqNumber.GetValue()); + auto it = m_rxonBuffer.find(seqNumber.GetValue()); if (it != m_rxonBuffer.end()) { NS_ASSERT(!it->second.m_byteSegments.empty()); @@ -959,7 +957,7 @@ LteRlcAm::DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) // - update VR(MS) to the SN of the first AMD PDU with SN > current VR(MS) for // which not all byte segments have been received; - std::map::iterator it = m_rxonBuffer.find(m_vrMs.GetValue()); + auto it = m_rxonBuffer.find(m_vrMs.GetValue()); if (it != m_rxonBuffer.end() && it->second.m_pduComplete) { int firstVrMs = m_vrMs.GetValue(); @@ -986,7 +984,7 @@ LteRlcAm::DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) if (seqNumber == m_vrR) { - std::map::iterator it = m_rxonBuffer.find(seqNumber.GetValue()); + auto it = m_rxonBuffer.find(seqNumber.GetValue()); if (it != m_rxonBuffer.end() && it->second.m_pduComplete) { it = m_rxonBuffer.find(m_vrR.GetValue()); @@ -1243,15 +1241,19 @@ LteRlcAm::ReassembleAndDeliver(Ptr packet) } } while (extensionBit == 1); - std::list>::iterator it; - // Current reassembling state if (m_reassemblingState == WAITING_S0_FULL) + { NS_LOG_LOGIC("Reassembling State = 'WAITING_S0_FULL'"); + } else if (m_reassemblingState == WAITING_SI_SF) + { NS_LOG_LOGIC("Reassembling State = 'WAITING_SI_SF'"); + } else + { NS_LOG_LOGIC("Reassembling State = Unknown state"); + } // Received framing Info NS_LOG_LOGIC("Framing Info = " << (uint16_t)framingInfo); @@ -1271,7 +1273,7 @@ LteRlcAm::ReassembleAndDeliver(Ptr packet) /** * Deliver one or multiple PDUs */ - for (it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) + for (auto it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) { m_rlcSapUser->ReceivePdcpPdu(*it); } @@ -1401,7 +1403,7 @@ LteRlcAm::ReassembleAndDeliver(Ptr packet) /** * Deliver one or multiple PDUs */ - for (it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) + for (auto it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) { m_rlcSapUser->ReceivePdcpPdu(*it); } @@ -1702,7 +1704,7 @@ LteRlcAm::ExpireReorderingTimer() m_vrMs = m_vrX; int firstVrMs = m_vrMs.GetValue(); - std::map::iterator it = m_rxonBuffer.find(m_vrMs.GetValue()); + auto it = m_rxonBuffer.find(m_vrMs.GetValue()); while (it != m_rxonBuffer.end() && it->second.m_pduComplete) { m_vrMs++; diff --git a/src/lte/model/lte-rlc-header.cc b/src/lte/model/lte-rlc-header.cc index 5ed1b6f65..c79828ef6 100644 --- a/src/lte/model/lte-rlc-header.cc +++ b/src/lte/model/lte-rlc-header.cc @@ -127,8 +127,8 @@ LteRlcHeader::GetInstanceTypeId() const void LteRlcHeader::Print(std::ostream& os) const { - std::list::const_iterator it1 = m_extensionBits.begin(); - std::list::const_iterator it2 = m_lengthIndicators.begin(); + auto it1 = m_extensionBits.begin(); + auto it2 = m_lengthIndicators.begin(); os << "Len=" << m_headerLength; os << " FI=" << (uint16_t)m_framingInfo; @@ -168,8 +168,8 @@ LteRlcHeader::Serialize(Buffer::Iterator start) const { Buffer::Iterator i = start; - std::list::const_iterator it1 = m_extensionBits.begin(); - std::list::const_iterator it2 = m_lengthIndicators.begin(); + auto it1 = m_extensionBits.begin(); + auto it2 = m_lengthIndicators.begin(); i.WriteU8(((m_framingInfo << 3) & 0x18) | (((*it1) << 2) & 0x04) | ((m_sequenceNumber.GetValue() >> 8) & 0x0003)); diff --git a/src/lte/model/lte-rlc-um.cc b/src/lte/model/lte-rlc-um.cc index e25debe22..0e19cdfca 100644 --- a/src/lte/model/lte-rlc-um.cc +++ b/src/lte/model/lte-rlc-um.cc @@ -105,7 +105,6 @@ void LteRlcUm::DoTransmitPdcpPdu(Ptr p) { NS_LOG_FUNCTION(this << m_rnti << (uint32_t)m_lcid << p->GetSize()); - if (m_txBufferSize + p->GetSize() <= m_maxTxBufferSize) { if (m_enablePdcpDiscarding) @@ -123,7 +122,7 @@ LteRlcUm::DoTransmitPdcpPdu(Ptr p) NS_LOG_DEBUG("head of line delay in MS:" << headOfLineDelayInMs); if (headOfLineDelayInMs > discardTimerMs) { - NS_LOG_DEBUG("Tx HOL is higher than this packet can allow. RLC SDU discarded"); + NS_LOG_INFO("Tx HOL is higher than this packet can allow. RLC SDU discarded"); NS_LOG_DEBUG("headOfLineDelayInMs = " << headOfLineDelayInMs); NS_LOG_DEBUG("m_packetDelayBudgetMs = " << m_packetDelayBudgetMs); NS_LOG_DEBUG("packet size = " << p->GetSize()); @@ -135,8 +134,7 @@ LteRlcUm::DoTransmitPdcpPdu(Ptr p) LteRlcSduStatusTag tag; tag.SetStatus(LteRlcSduStatusTag::FULL_SDU); p->AddPacketTag(tag); - - NS_LOG_LOGIC("Tx Buffer: New packet added"); + NS_LOG_INFO("Adding RLC SDU to Tx Buffer after adding LteRlcSduStatusTag: FULL_SDU"); m_txBuffer.emplace_back(p, Simulator::Now()); m_txBufferSize += p->GetSize(); NS_LOG_LOGIC("NumOfBuffers = " << m_txBuffer.size()); @@ -145,7 +143,7 @@ LteRlcUm::DoTransmitPdcpPdu(Ptr p) else { // Discard full RLC SDU - NS_LOG_LOGIC("TxBuffer is full. RLC SDU discarded"); + NS_LOG_INFO("Tx Buffer is full. RLC SDU discarded"); NS_LOG_LOGIC("MaxTxBufferSize = " << m_maxTxBufferSize); NS_LOG_LOGIC("txBufferSize = " << m_txBufferSize); NS_LOG_LOGIC("packet size = " << p->GetSize()); @@ -165,11 +163,15 @@ void LteRlcUm::DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParams) { NS_LOG_FUNCTION(this << m_rnti << (uint32_t)m_lcid << txOpParams.bytes); + NS_LOG_INFO("RLC layer is preparing data for the following Tx opportunity of " + << txOpParams.bytes << " bytes for RNTI=" << m_rnti << ", LCID=" << (uint32_t)m_lcid + << ", CCID=" << (uint32_t)txOpParams.componentCarrierId << ", HARQ ID=" + << (uint32_t)txOpParams.harqId << ", MIMO Layer=" << (uint32_t)txOpParams.layer); if (txOpParams.bytes <= 2) { // Stingy MAC: Header fix part is 2 bytes, we need more bytes for the data - NS_LOG_LOGIC("TX opportunity too small = " << txOpParams.bytes); + NS_LOG_INFO("TX opportunity too small - Only " << txOpParams.bytes << " bytes"); return; } @@ -364,8 +366,7 @@ LteRlcUm::DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParam rlcHeader.SetSequenceNumber(m_sequenceNumber++); // Build RLC PDU with DataField and Header - std::vector>::iterator it; - it = dataField.begin(); + auto it = dataField.begin(); uint8_t framingInfo = 0; @@ -431,6 +432,7 @@ LteRlcUm::DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParam params.harqProcessId = txOpParams.harqId; params.componentCarrierId = txOpParams.componentCarrierId; + NS_LOG_INFO("Forward RLC PDU to MAC Layer"); m_macSapProvider->TransmitPdu(params); if (!m_txBuffer.empty()) @@ -557,11 +559,10 @@ LteRlcUm::DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) { NS_LOG_LOGIC("Reception buffer contains SN = " << m_vrUr); - std::map>::iterator it; uint16_t newVrUr; SequenceNumber10 oldVrUr = m_vrUr; - it = m_rxBuffer.find(m_vrUr.GetValue()); + auto it = m_rxBuffer.find(m_vrUr.GetValue()); newVrUr = (it->first) + 1; while (m_rxBuffer.count(newVrUr) > 0) { @@ -693,15 +694,19 @@ LteRlcUm::ReassembleAndDeliver(Ptr packet) } } while (extensionBit == 1); - std::list>::iterator it; - // Current reassembling state if (m_reassemblingState == WAITING_S0_FULL) + { NS_LOG_LOGIC("Reassembling State = 'WAITING_S0_FULL'"); + } else if (m_reassemblingState == WAITING_SI_SF) + { NS_LOG_LOGIC("Reassembling State = 'WAITING_SI_SF'"); + } else + { NS_LOG_LOGIC("Reassembling State = Unknown state"); + } // Received framing Info NS_LOG_LOGIC("Framing Info = " << (uint16_t)framingInfo); @@ -720,7 +725,7 @@ LteRlcUm::ReassembleAndDeliver(Ptr packet) /** * Deliver one or multiple PDUs */ - for (it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) + for (auto it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) { m_rlcSapUser->ReceivePdcpPdu(*it); } @@ -900,7 +905,7 @@ LteRlcUm::ReassembleAndDeliver(Ptr packet) /** * Deliver one or multiple PDUs */ - for (it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) + for (auto it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) { m_rlcSapUser->ReceivePdcpPdu(*it); } @@ -1119,8 +1124,7 @@ LteRlcUm::ReassembleOutsideWindow() { NS_LOG_LOGIC("Reassemble Outside Window"); - std::map>::iterator it; - it = m_rxBuffer.begin(); + auto it = m_rxBuffer.begin(); while ((it != m_rxBuffer.end()) && !IsInsideReorderingWindow(SequenceNumber10(it->first))) { @@ -1129,7 +1133,7 @@ LteRlcUm::ReassembleOutsideWindow() // Reassemble RLC SDUs and deliver the PDCP PDU to upper layer ReassembleAndDeliver(it->second); - std::map>::iterator it_tmp = it; + auto it_tmp = it; ++it; m_rxBuffer.erase(it_tmp); } @@ -1145,15 +1149,13 @@ LteRlcUm::ReassembleSnInterval(SequenceNumber10 lowSeqNumber, SequenceNumber10 h { NS_LOG_LOGIC("Reassemble SN between " << lowSeqNumber << " and " << highSeqNumber); - std::map>::iterator it; - SequenceNumber10 reassembleSn = lowSeqNumber; NS_LOG_LOGIC("reassembleSN = " << reassembleSn); NS_LOG_LOGIC("highSeqNumber = " << highSeqNumber); while (reassembleSn < highSeqNumber) { NS_LOG_LOGIC("reassembleSn < highSeqNumber"); - it = m_rxBuffer.find(reassembleSn.GetValue()); + auto it = m_rxBuffer.find(reassembleSn.GetValue()); NS_LOG_LOGIC("it->first = " << it->first); NS_LOG_LOGIC("it->second = " << it->second); if (it != m_rxBuffer.end()) @@ -1214,10 +1216,9 @@ LteRlcUm::ExpireReorderingTimer() // - start t-Reordering; // - set VR(UX) to VR(UH). - std::map>::iterator it; SequenceNumber10 newVrUr = m_vrUx; - while ((it = m_rxBuffer.find(newVrUr.GetValue())) != m_rxBuffer.end()) + while (m_rxBuffer.find(newVrUr.GetValue()) != m_rxBuffer.end()) { newVrUr++; } diff --git a/src/lte/model/lte-rrc-header.cc b/src/lte/model/lte-rrc-header.cc index 81add7473..73bf1202f 100644 --- a/src/lte/model/lte-rrc-header.cc +++ b/src/lte/model/lte-rrc-header.cc @@ -138,17 +138,17 @@ RrcAsn1Header::SerializeDrbToAddModList(std::list drbToA SerializeSequenceOf(drbToAddModList.size(), MAX_DRB, 1); // Serialize the elements in the sequence-of list - std::list::iterator it = drbToAddModList.begin(); + auto it = drbToAddModList.begin(); for (; it != drbToAddModList.end(); it++) { // Serialize DRB-ToAddMod sequence // 5 optional fields. Extension marker is present. std::bitset<5> drbToAddModListOptionalFieldsPresent = std::bitset<5>(); - drbToAddModListOptionalFieldsPresent.set(4, 1); // eps-BearerIdentity present - drbToAddModListOptionalFieldsPresent.set(3, 0); // pdcp-Config not present - drbToAddModListOptionalFieldsPresent.set(2, 1); // rlc-Config present - drbToAddModListOptionalFieldsPresent.set(1, 1); // logicalChannelIdentity present - drbToAddModListOptionalFieldsPresent.set(0, 1); // logicalChannelConfig present + drbToAddModListOptionalFieldsPresent.set(4, true); // eps-BearerIdentity present + drbToAddModListOptionalFieldsPresent.set(3, false); // pdcp-Config not present + drbToAddModListOptionalFieldsPresent.set(2, true); // rlc-Config present + drbToAddModListOptionalFieldsPresent.set(1, true); // logicalChannelIdentity present + drbToAddModListOptionalFieldsPresent.set(0, true); // logicalChannelConfig present SerializeSequence(drbToAddModListOptionalFieldsPresent, true); // Serialize eps-BearerIdentity::=INTEGER (0..15) @@ -226,14 +226,14 @@ RrcAsn1Header::SerializeSrbToAddModList(std::list srbToA SerializeSequenceOf(srbToAddModList.size(), 2, 1); // Serialize the elements in the sequence-of list - std::list::iterator it = srbToAddModList.begin(); + auto it = srbToAddModList.begin(); for (; it != srbToAddModList.end(); it++) { // Serialize SRB-ToAddMod sequence // 2 optional fields. Extension marker is present. std::bitset<2> srbToAddModListOptionalFieldsPresent = std::bitset<2>(); - srbToAddModListOptionalFieldsPresent.set(1, 0); // rlc-Config not present - srbToAddModListOptionalFieldsPresent.set(0, 1); // logicalChannelConfig present + srbToAddModListOptionalFieldsPresent.set(1, false); // rlc-Config not present + srbToAddModListOptionalFieldsPresent.set(0, true); // logicalChannelConfig present SerializeSequence(srbToAddModListOptionalFieldsPresent, true); // Serialize srb-Identity ::= INTEGER (1..2) @@ -333,19 +333,19 @@ RrcAsn1Header::SerializePhysicalConfigDedicated( optionalFieldsPhysicalConfigDedicated.set( 9, physicalConfigDedicated.havePdschConfigDedicated); // pdsch-ConfigDedicated - optionalFieldsPhysicalConfigDedicated.set(8, 0); // pucch-ConfigDedicated not present - optionalFieldsPhysicalConfigDedicated.set(7, 0); // pusch-ConfigDedicated not present - optionalFieldsPhysicalConfigDedicated.set(6, 0); // uplinkPowerControlDedicated not present - optionalFieldsPhysicalConfigDedicated.set(5, 0); // tpc-PDCCH-ConfigPUCCH not present - optionalFieldsPhysicalConfigDedicated.set(4, 0); // tpc-PDCCH-ConfigPUSCH not present - optionalFieldsPhysicalConfigDedicated.set(3, 0); // cqi-ReportConfig not present + optionalFieldsPhysicalConfigDedicated.set(8, false); // pucch-ConfigDedicated not present + optionalFieldsPhysicalConfigDedicated.set(7, false); // pusch-ConfigDedicated not present + optionalFieldsPhysicalConfigDedicated.set(6, false); // uplinkPowerControlDedicated not present + optionalFieldsPhysicalConfigDedicated.set(5, false); // tpc-PDCCH-ConfigPUCCH not present + optionalFieldsPhysicalConfigDedicated.set(4, false); // tpc-PDCCH-ConfigPUSCH not present + optionalFieldsPhysicalConfigDedicated.set(3, false); // cqi-ReportConfig not present optionalFieldsPhysicalConfigDedicated.set( 2, physicalConfigDedicated.haveSoundingRsUlConfigDedicated); // soundingRS-UL-ConfigDedicated optionalFieldsPhysicalConfigDedicated.set( 1, physicalConfigDedicated.haveAntennaInfoDedicated); // antennaInfo - optionalFieldsPhysicalConfigDedicated.set(0, 0); // schedulingRequestConfig not present + optionalFieldsPhysicalConfigDedicated.set(0, false); // schedulingRequestConfig not present SerializeSequence(optionalFieldsPhysicalConfigDedicated, true); if (physicalConfigDedicated.havePdschConfigDedicated) @@ -443,10 +443,9 @@ RrcAsn1Header::SerializeRadioResourceConfigDedicated( optionalFieldsPresent.set(5, isSrbToAddModListPresent); // srb-ToAddModList present optionalFieldsPresent.set(4, isDrbToAddModListPresent); // drb-ToAddModList present optionalFieldsPresent.set(3, isDrbToReleaseListPresent); // drb-ToReleaseList present - optionalFieldsPresent.set(2, 0); // mac-MainConfig not present - optionalFieldsPresent.set(1, 0); // sps-Config not present - optionalFieldsPresent.set(0, - (radioResourceConfigDedicated.havePhysicalConfigDedicated) ? 1 : 0); + optionalFieldsPresent.set(2, false); // mac-MainConfig not present + optionalFieldsPresent.set(1, false); // sps-Config not present + optionalFieldsPresent.set(0, radioResourceConfigDedicated.havePhysicalConfigDedicated); SerializeSequence(optionalFieldsPresent, true); // Serialize srbToAddModList @@ -465,7 +464,7 @@ RrcAsn1Header::SerializeRadioResourceConfigDedicated( if (isDrbToReleaseListPresent) { SerializeSequenceOf(radioResourceConfigDedicated.drbToReleaseList.size(), MAX_DRB, 1); - std::list::iterator it = radioResourceConfigDedicated.drbToReleaseList.begin(); + auto it = radioResourceConfigDedicated.drbToReleaseList.begin(); for (; it != radioResourceConfigDedicated.drbToReleaseList.end(); it++) { // DRB-Identity ::= INTEGER (1..32) @@ -485,9 +484,9 @@ RrcAsn1Header::SerializeSystemInformationBlockType1( { // 3 optional fields, no extension marker. std::bitset<3> sysInfoBlk1Opts; - sysInfoBlk1Opts.set(2, 0); // p-Max absent - sysInfoBlk1Opts.set(1, 0); // tdd-Config absent - sysInfoBlk1Opts.set(0, 0); // nonCriticalExtension absent + sysInfoBlk1Opts.set(2, false); // p-Max absent + sysInfoBlk1Opts.set(1, false); // tdd-Config absent + sysInfoBlk1Opts.set(0, false); // nonCriticalExtension absent SerializeSequence(sysInfoBlk1Opts, false); // Serialize cellAccessRelatedInfo @@ -548,15 +547,15 @@ RrcAsn1Header::SerializeRadioResourceConfigCommon( { // 9 optional fields. Extension marker yes. std::bitset<9> rrCfgCmmOpts; - rrCfgCmmOpts.set(8, 1); // rach-ConfigCommon is present - rrCfgCmmOpts.set(7, 0); // pdsch-ConfigCommon not present - rrCfgCmmOpts.set(6, 0); // phich-Config not present - rrCfgCmmOpts.set(5, 0); // pucch-ConfigCommon not present - rrCfgCmmOpts.set(4, 0); // soundingRS-UL-ConfigCommon not present - rrCfgCmmOpts.set(3, 0); // uplinkPowerControlCommon not present - rrCfgCmmOpts.set(2, 0); // antennaInfoCommon not present - rrCfgCmmOpts.set(1, 0); // p-Max not present - rrCfgCmmOpts.set(0, 0); // tdd-Config not present + rrCfgCmmOpts.set(8, true); // rach-ConfigCommon is present + rrCfgCmmOpts.set(7, false); // pdsch-ConfigCommon not present + rrCfgCmmOpts.set(6, false); // phich-Config not present + rrCfgCmmOpts.set(5, false); // pucch-ConfigCommon not present + rrCfgCmmOpts.set(4, false); // soundingRS-UL-ConfigCommon not present + rrCfgCmmOpts.set(3, false); // uplinkPowerControlCommon not present + rrCfgCmmOpts.set(2, false); // antennaInfoCommon not present + rrCfgCmmOpts.set(1, false); // p-Max not present + rrCfgCmmOpts.set(0, false); // tdd-Config not present SerializeSequence(rrCfgCmmOpts, true); @@ -719,8 +718,7 @@ RrcAsn1Header::SerializeMeasResults(LteRrcSap::MeasResults measResults) const SerializeSequenceOf(measResults.measResultListEutra.size(), MAX_CELL_REPORT, 1); // serialize MeasResultEutra elements in the list - std::list::iterator it; - for (it = measResults.measResultListEutra.begin(); + for (auto it = measResults.measResultListEutra.begin(); it != measResults.measResultListEutra.end(); it++) { @@ -746,8 +744,7 @@ RrcAsn1Header::SerializeMeasResults(LteRrcSap::MeasResults measResults) const if (!it->cgiInfo.plmnIdentityList.empty()) { SerializeSequenceOf(it->cgiInfo.plmnIdentityList.size(), 5, 1); - std::list::iterator it2; - for (it2 = it->cgiInfo.plmnIdentityList.begin(); + for (auto it2 = it->cgiInfo.plmnIdentityList.begin(); it2 != it->cgiInfo.plmnIdentityList.end(); it2++) { @@ -1142,7 +1139,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!measConfig.measObjectToRemoveList.empty()) { SerializeSequenceOf(measConfig.measObjectToRemoveList.size(), MAX_OBJECT_ID, 1); - for (std::list::iterator it = measConfig.measObjectToRemoveList.begin(); + for (auto it = measConfig.measObjectToRemoveList.begin(); it != measConfig.measObjectToRemoveList.end(); it++) { @@ -1153,8 +1150,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!measConfig.measObjectToAddModList.empty()) { SerializeSequenceOf(measConfig.measObjectToAddModList.size(), MAX_OBJECT_ID, 1); - for (std::list::iterator it = - measConfig.measObjectToAddModList.begin(); + for (auto it = measConfig.measObjectToAddModList.begin(); it != measConfig.measObjectToAddModList.end(); it++) { @@ -1184,8 +1180,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!it->measObjectEutra.cellsToRemoveList.empty()) { SerializeSequenceOf(it->measObjectEutra.cellsToRemoveList.size(), MAX_CELL_MEAS, 1); - for (std::list::iterator it2 = - it->measObjectEutra.cellsToRemoveList.begin(); + for (auto it2 = it->measObjectEutra.cellsToRemoveList.begin(); it2 != it->measObjectEutra.cellsToRemoveList.end(); it2++) { @@ -1196,8 +1191,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!it->measObjectEutra.cellsToAddModList.empty()) { SerializeSequenceOf(it->measObjectEutra.cellsToAddModList.size(), MAX_CELL_MEAS, 1); - for (std::list::iterator it2 = - it->measObjectEutra.cellsToAddModList.begin(); + for (auto it2 = it->measObjectEutra.cellsToAddModList.begin(); it2 != it->measObjectEutra.cellsToAddModList.end(); it2++) { @@ -1219,8 +1213,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const SerializeSequenceOf(it->measObjectEutra.blackCellsToRemoveList.size(), MAX_CELL_MEAS, 1); - for (std::list::iterator it2 = - it->measObjectEutra.blackCellsToRemoveList.begin(); + for (auto it2 = it->measObjectEutra.blackCellsToRemoveList.begin(); it2 != it->measObjectEutra.blackCellsToRemoveList.end(); it2++) { @@ -1233,8 +1226,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const SerializeSequenceOf(it->measObjectEutra.blackCellsToAddModList.size(), MAX_CELL_MEAS, 1); - for (std::list::iterator it2 = - it->measObjectEutra.blackCellsToAddModList.begin(); + for (auto it2 = it->measObjectEutra.blackCellsToAddModList.begin(); it2 != it->measObjectEutra.blackCellsToAddModList.end(); it2++) { @@ -1243,7 +1235,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const // Serialize PhysCellIdRange // range optional - std::bitset<1> rangePresent = std::bitset<1>(it2->physCellIdRange.haveRange); + std::bitset<1> rangePresent(it2->physCellIdRange.haveRange); SerializeSequence(rangePresent, false); SerializeInteger(it2->physCellIdRange.start, 0, 503); if (it2->physCellIdRange.haveRange) @@ -1309,7 +1301,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!measConfig.reportConfigToRemoveList.empty()) { SerializeSequenceOf(measConfig.reportConfigToRemoveList.size(), MAX_REPORT_CONFIG_ID, 1); - for (std::list::iterator it = measConfig.reportConfigToRemoveList.begin(); + for (auto it = measConfig.reportConfigToRemoveList.begin(); it != measConfig.reportConfigToRemoveList.end(); it++) { @@ -1320,8 +1312,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!measConfig.reportConfigToAddModList.empty()) { SerializeSequenceOf(measConfig.reportConfigToAddModList.size(), MAX_REPORT_CONFIG_ID, 1); - for (std::list::iterator it = - measConfig.reportConfigToAddModList.begin(); + for (auto it = measConfig.reportConfigToAddModList.begin(); it != measConfig.reportConfigToAddModList.end(); it++) { @@ -1546,7 +1537,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!measConfig.measIdToRemoveList.empty()) { SerializeSequenceOf(measConfig.measIdToRemoveList.size(), MAX_MEAS_ID, 1); - for (std::list::iterator it = measConfig.measIdToRemoveList.begin(); + for (auto it = measConfig.measIdToRemoveList.begin(); it != measConfig.measIdToRemoveList.end(); it++) { @@ -1557,8 +1548,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!measConfig.measIdToAddModList.empty()) { SerializeSequenceOf(measConfig.measIdToAddModList.size(), MAX_MEAS_ID, 1); - for (std::list::iterator it = - measConfig.measIdToAddModList.begin(); + for (auto it = measConfig.measIdToAddModList.begin(); it != measConfig.measIdToAddModList.end(); it++) { @@ -1573,7 +1563,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const // QuantityConfig sequence // 4 optional fields, only first (EUTRA) present. Extension marker yes. std::bitset<4> quantityConfigOpts(0); - quantityConfigOpts.set(3, 1); + quantityConfigOpts.set(3, true); SerializeSequence(quantityConfigOpts, true); SerializeSequence(std::bitset<0>(), false); @@ -1826,7 +1816,7 @@ RrcAsn1Header::SerializeNonCriticalExtensionConfiguration( !nonCriticalExtension.sCellToAddModList.empty()); // sCellToAddModList-r10 noncriticalExtension_v1020.set( 0, - 0); // No nonCriticalExtension RRCConnectionReconfiguration-v1130-IEs + false); // No nonCriticalExtension RRCConnectionReconfiguration-v1130-IEs SerializeSequence(noncriticalExtension_v1020, false); if (!nonCriticalExtension.sCellToReleaseList.empty()) @@ -1844,9 +1834,9 @@ RrcAsn1Header::SerializeNonCriticalExtensionConfiguration( for (auto& it : nonCriticalExtension.sCellToAddModList) { std::bitset<4> sCellToAddMod_r10; - sCellToAddMod_r10.set(3, 1); // sCellIndex - sCellToAddMod_r10.set(2, 1); // CellIdentification - sCellToAddMod_r10.set(1, 1); // RadioResourceConfigCommonSCell + sCellToAddMod_r10.set(3, true); // sCellIndex + sCellToAddMod_r10.set(2, true); // CellIdentification + sCellToAddMod_r10.set(1, true); // RadioResourceConfigCommonSCell sCellToAddMod_r10.set( 0, it.haveRadioResourceConfigDedicatedSCell); // No nonCriticalExtension RRC @@ -1855,8 +1845,8 @@ RrcAsn1Header::SerializeNonCriticalExtensionConfiguration( // Serialize CellIdentification std::bitset<2> cellIdentification_r10; - cellIdentification_r10.set(1, 1); // phyCellId-r10 - cellIdentification_r10.set(0, 1); // dl-CarrierFreq-r10 + cellIdentification_r10.set(1, true); // phyCellId-r10 + cellIdentification_r10.set(0, true); // dl-CarrierFreq-r10 SerializeSequence(cellIdentification_r10, false); SerializeInteger(it.cellIdentification.physCellId, 1, 65536); @@ -1888,23 +1878,23 @@ RrcAsn1Header::SerializeRadioResourceConfigCommonSCell( { // 5 optional fields. Extension marker not present. std::bitset<5> nonUlConfiguration_r10; - nonUlConfiguration_r10.set(4, 1); // Dl- bandwidth --> convert in enum - nonUlConfiguration_r10.set(3, 1); // AntennaInfoCommon-r10 - nonUlConfiguration_r10.set(2, 0); // phich-Config-r10 Not Implemented - nonUlConfiguration_r10.set(1, 1); // pdschConfigCommon - nonUlConfiguration_r10.set(0, 0); // Tdd-Config-r10 Not Implemented + nonUlConfiguration_r10.set(4, true); // Dl- bandwidth --> convert in enum + nonUlConfiguration_r10.set(3, true); // AntennaInfoCommon-r10 + nonUlConfiguration_r10.set(2, false); // phich-Config-r10 Not Implemented + nonUlConfiguration_r10.set(1, true); // pdschConfigCommon + nonUlConfiguration_r10.set(0, false); // Tdd-Config-r10 Not Implemented SerializeSequence(nonUlConfiguration_r10, false); SerializeInteger(rrccsc.nonUlConfiguration.dlBandwidth, 6, 100); std::bitset<1> antennaInfoCommon_r10; - antennaInfoCommon_r10.set(0, 1); + antennaInfoCommon_r10.set(0, true); SerializeSequence(antennaInfoCommon_r10, false); SerializeInteger(rrccsc.nonUlConfiguration.antennaInfoCommon.antennaPortsCount, 0, 65536); std::bitset<2> pdschConfigCommon_r10; - pdschConfigCommon_r10.set(1, 1); - pdschConfigCommon_r10.set(0, 1); + pdschConfigCommon_r10.set(1, true); + pdschConfigCommon_r10.set(0, true); SerializeSequence(pdschConfigCommon_r10, false); SerializeInteger(rrccsc.nonUlConfiguration.pdschConfigCommon.referenceSignalPower, -60, 50); @@ -1915,20 +1905,20 @@ RrcAsn1Header::SerializeRadioResourceConfigCommonSCell( // Serialize Ul Configuration // 7 optional fields. Extension marker present. std::bitset<7> UlConfiguration_r10; - UlConfiguration_r10.set(6, 1); // ul-Configuration-r10 - UlConfiguration_r10.set(5, 0); // p-Max-r10 Not Implemented - UlConfiguration_r10.set(4, 1); // uplinkPowerControlCommonSCell-r10 - UlConfiguration_r10.set(3, 0); // soundingRS-UL-ConfigCommon-r10 - UlConfiguration_r10.set(2, 0); // ul-CyclicPrefixLength-r10 - UlConfiguration_r10.set(1, 1); // prach-ConfigSCell-r10 - UlConfiguration_r10.set(0, 0); // pusch-ConfigCommon-r10 Not Implemented + UlConfiguration_r10.set(6, true); // ul-Configuration-r10 + UlConfiguration_r10.set(5, false); // p-Max-r10 Not Implemented + UlConfiguration_r10.set(4, true); // uplinkPowerControlCommonSCell-r10 + UlConfiguration_r10.set(3, false); // soundingRS-UL-ConfigCommon-r10 + UlConfiguration_r10.set(2, false); // ul-CyclicPrefixLength-r10 + UlConfiguration_r10.set(1, true); // prach-ConfigSCell-r10 + UlConfiguration_r10.set(0, false); // pusch-ConfigCommon-r10 Not Implemented SerializeSequence(UlConfiguration_r10, true); // Serialize ulFreqInfo std::bitset<3> FreqInfo_r10; - FreqInfo_r10.set(2, 1); // ulCarrierFreq - FreqInfo_r10.set(1, 1); // UlBandwidth - FreqInfo_r10.set(0, 0); // additionalSpectrumEmissionSCell-r10 Not Implemented + FreqInfo_r10.set(2, true); // ulCarrierFreq + FreqInfo_r10.set(1, true); // UlBandwidth + FreqInfo_r10.set(0, false); // additionalSpectrumEmissionSCell-r10 Not Implemented SerializeSequence(FreqInfo_r10, false); SerializeInteger(rrccsc.ulConfiguration.ulFreqInfo.ulCarrierFreq, 0, MAX_EARFCN); @@ -1936,8 +1926,8 @@ RrcAsn1Header::SerializeRadioResourceConfigCommonSCell( // Serialize UlPowerControlCommonSCell std::bitset<2> UlPowerControlCommonSCell_r10; - UlPowerControlCommonSCell_r10.set(1, 0); // p0-NominalPUSCH-r10 Not Implemented - UlPowerControlCommonSCell_r10.set(0, 1); // alpha + UlPowerControlCommonSCell_r10.set(1, false); // p0-NominalPUSCH-r10 Not Implemented + UlPowerControlCommonSCell_r10.set(0, true); // alpha SerializeSequence(UlPowerControlCommonSCell_r10, false); SerializeInteger(rrccsc.ulConfiguration.ulPowerControlCommonSCell.alpha, 0, 65536); @@ -1947,7 +1937,7 @@ RrcAsn1Header::SerializeRadioResourceConfigCommonSCell( // Serialize PrachConfigSCell std::bitset<1> prachConfigSCell_r10; - prachConfigSCell_r10.set(0, 1); + prachConfigSCell_r10.set(0, true); SerializeSequence(prachConfigSCell_r10, false); SerializeInteger(rrccsc.ulConfiguration.prachConfigSCell.index, 0, 256); } @@ -1959,7 +1949,7 @@ RrcAsn1Header::SerializeRadioResourceDedicatedSCell( { // Serialize RadioResourceConfigDedicatedSCell std::bitset<1> RadioResourceConfigDedicatedSCell_r10; - RadioResourceConfigDedicatedSCell_r10.set(0, 1); + RadioResourceConfigDedicatedSCell_r10.set(0, true); SerializeSequence(RadioResourceConfigDedicatedSCell_r10, false); LteRrcSap::PhysicalConfigDedicatedSCell pcdsc = rrcdsc.physicalConfigDedicatedSCell; @@ -1980,8 +1970,8 @@ RrcAsn1Header::SerializePhysicalConfigDedicatedSCell( // Serialize NonUl configuration std::bitset<4> nulOpt; nulOpt.set(3, pcdsc.haveAntennaInfoDedicated); - nulOpt.set(2, 0); // crossCarrierSchedulingConfig-r10 Not Implemented - nulOpt.set(1, 0); // csi-RS-Config-r10 Not Implemented + nulOpt.set(2, false); // crossCarrierSchedulingConfig-r10 Not Implemented + nulOpt.set(1, false); // csi-RS-Config-r10 Not Implemented nulOpt.set(0, pcdsc.havePdschConfigDedicated); // pdsch-ConfigDedicated-r10 SerializeSequence(nulOpt, false); @@ -2024,12 +2014,12 @@ RrcAsn1Header::SerializePhysicalConfigDedicatedSCell( // Serialize Ul Configuration std::bitset<7> ulOpt; ulOpt.set(6, pcdsc.haveAntennaInfoUlDedicated); // antennaInfoUL-r10 - ulOpt.set(5, 0); // pusch-ConfigDedicatedSCell-r10 not present - ulOpt.set(4, 0); // uplinkPowerControlDedicatedSCell-r10 not present - ulOpt.set(3, 0); // cqi-ReportConfigSCell-r10 not present + ulOpt.set(5, false); // pusch-ConfigDedicatedSCell-r10 not present + ulOpt.set(4, false); // uplinkPowerControlDedicatedSCell-r10 not present + ulOpt.set(3, false); // cqi-ReportConfigSCell-r10 not present ulOpt.set(2, pcdsc.haveSoundingRsUlConfigDedicated); // soundingRS-UL-ConfigDedicated-r10 - ulOpt.set(1, 0); // soundingRS-UL-ConfigDedicated-v1020 not present - ulOpt.set(0, 0); // soundingRS-UL-ConfigDedicatedAperiodic-r10 not present + ulOpt.set(1, false); // soundingRS-UL-ConfigDedicated-v1020 not present + ulOpt.set(0, false); // soundingRS-UL-ConfigDedicatedAperiodic-r10 not present SerializeSequence(ulOpt, false); if (pcdsc.haveAntennaInfoUlDedicated) @@ -3068,8 +3058,7 @@ RrcAsn1Header::Print(std::ostream& os, LteRrcSap::RadioResourceConfigDedicated radioResourceConfigDedicated) const { os << " srbToAddModList: " << std::endl; - std::list::iterator it = - radioResourceConfigDedicated.srbToAddModList.begin(); + auto it = radioResourceConfigDedicated.srbToAddModList.begin(); for (; it != radioResourceConfigDedicated.srbToAddModList.end(); it++) { os << " srbIdentity: " << (int)it->srbIdentity << std::endl; @@ -3085,8 +3074,7 @@ RrcAsn1Header::Print(std::ostream& os, os << std::endl; os << " drbToAddModList: " << std::endl; - std::list::iterator it2 = - radioResourceConfigDedicated.drbToAddModList.begin(); + auto it2 = radioResourceConfigDedicated.drbToAddModList.begin(); for (; it2 != radioResourceConfigDedicated.drbToAddModList.end(); it2++) { os << " epsBearerIdentity: " << (int)it2->epsBearerIdentity << std::endl; @@ -3105,7 +3093,7 @@ RrcAsn1Header::Print(std::ostream& os, os << std::endl; os << " drbToReleaseList: "; - std::list::iterator it3 = radioResourceConfigDedicated.drbToReleaseList.begin(); + auto it3 = radioResourceConfigDedicated.drbToReleaseList.begin(); for (; it3 != radioResourceConfigDedicated.drbToReleaseList.end(); it3++) { os << (int)*it3 << ", "; @@ -5336,9 +5324,9 @@ RrcConnectionReconfigurationHeader::PreSerialize() const std::bitset<6> options; options.set(5, m_haveMeasConfig); options.set(4, m_haveMobilityControlInfo); - options.set(3, 0); // No dedicatedInfoNASList + options.set(3, false); // No dedicatedInfoNASList options.set(2, m_haveRadioResourceConfigDedicated); - options.set(1, 0); // No securityConfigHO + options.set(1, false); // No securityConfigHO options.set(0, m_haveNonCriticalExtension); // Implemented nonCriticalExtension because // compatibility with R10 - CA SerializeSequence(options, false); @@ -5356,7 +5344,7 @@ RrcConnectionReconfigurationHeader::PreSerialize() const std::bitset<4> mobCtrlIntoOptional; mobCtrlIntoOptional.set(3, m_mobilityControlInfo.haveCarrierFreq); mobCtrlIntoOptional.set(2, m_mobilityControlInfo.haveCarrierBandwidth); - mobCtrlIntoOptional.set(1, 0); // No additionalSpectrumEmission + mobCtrlIntoOptional.set(1, false); // No additionalSpectrumEmission mobCtrlIntoOptional.set(0, m_mobilityControlInfo.haveRachConfigDedicated); SerializeSequence(mobCtrlIntoOptional, true); @@ -5409,7 +5397,7 @@ RrcConnectionReconfigurationHeader::PreSerialize() const // Serialize NonCriticalExtension RRCConnectionReconfiguration-v890-IEs sequence: // 2 optional fields. Extension marker not present. std::bitset<2> noncriticalExtension_v890; - noncriticalExtension_v890.set(1, 0); // No lateNonCriticalExtension + noncriticalExtension_v890.set(1, false); // No lateNonCriticalExtension noncriticalExtension_v890.set( 0, m_haveNonCriticalExtension); // Implemented nonCriticalExtension because compatibility @@ -5420,8 +5408,8 @@ RrcConnectionReconfigurationHeader::PreSerialize() const // Serialize NonCriticalExtension RRCConnectionReconfiguration-v920-IEs sequence: // 3 optional fields. Extension marker not present. std::bitset<3> noncriticalExtension_v920; - noncriticalExtension_v920.set(1, 0); // No otherConfig-r9 - noncriticalExtension_v920.set(1, 0); // No fullConfig-r9 + noncriticalExtension_v920.set(1, false); // No otherConfig-r9 + noncriticalExtension_v920.set(1, false); // No fullConfig-r9 // Enable RRCCoonectionReconfiguration-v1020-IEs noncriticalExtension_v920.set( 0, @@ -5601,7 +5589,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " measObjectToRemoveList: "; std::list auxList = m_measConfig.measObjectToRemoveList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << (int)*it << ", "; @@ -5612,7 +5600,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " reportConfigToRemoveList: "; std::list auxList = m_measConfig.reportConfigToRemoveList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << (int)*it << ", "; @@ -5623,7 +5611,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " measIdToRemoveList: "; std::list auxList = m_measConfig.measIdToRemoveList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << (int)*it << ", "; @@ -5635,7 +5623,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " measObjectToAddMod: " << std::endl; std::list auxList = m_measConfig.measObjectToAddModList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << " measObjectId: " << (int)it->measObjectId << std::endl; @@ -5652,7 +5640,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " cellsToRemoveList: "; std::list auxList = it->measObjectEutra.cellsToRemoveList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << (int)*it << ", "; @@ -5664,7 +5652,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " blackCellsToRemoveList: "; std::list auxList = it->measObjectEutra.blackCellsToRemoveList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << (int)*it << ", "; @@ -5677,7 +5665,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const os << " cellsToAddModList: " << std::endl; std::list auxList = it->measObjectEutra.cellsToAddModList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << " cellIndex: " << (int)it->cellIndex << std::endl; @@ -5693,7 +5681,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const os << " blackCellsToAddModList: " << std::endl; std::list auxList = it->measObjectEutra.blackCellsToAddModList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << " cellIndex: " << (int)it->cellIndex << std::endl; @@ -5720,7 +5708,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const os << " reportConfigToAddModList: " << std::endl; std::list auxList = m_measConfig.reportConfigToAddModList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << " reportConfigId: " << (int)it->reportConfigId << std::endl; @@ -5778,7 +5766,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " measIdToAddModList: " << std::endl; std::list auxList = m_measConfig.measIdToAddModList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << " measId: " << (int)it->measId << std::endl; @@ -6015,10 +6003,10 @@ HandoverPreparationInfoHeader::PreSerialize() const // Serialize HandoverPreparationInformation-r8-IEs sequence // 4 optional fields, no extension marker. std::bitset<4> handoverPrepInfoOpts; - handoverPrepInfoOpts.set(3, 1); // as-Config present - handoverPrepInfoOpts.set(2, 0); // rrm-Config not present - handoverPrepInfoOpts.set(1, 0); // as-Context not present - handoverPrepInfoOpts.set(0, 0); // nonCriticalExtension not present + handoverPrepInfoOpts.set(3, true); // as-Config present + handoverPrepInfoOpts.set(2, false); // rrm-Config not present + handoverPrepInfoOpts.set(1, false); // as-Context not present + handoverPrepInfoOpts.set(0, false); // nonCriticalExtension not present SerializeSequence(handoverPrepInfoOpts, false); // Serialize ue-RadioAccessCapabilityInfo @@ -7062,7 +7050,7 @@ MeasurementReportHeader::Print(std::ostream& os) const { std::list measResultListEutra = m_measurementReport.measResults.measResultListEutra; - std::list::iterator it = measResultListEutra.begin(); + auto it = measResultListEutra.begin(); for (; it != measResultListEutra.end(); it++) { os << " physCellId =" << (int)it->physCellId << std::endl; @@ -7076,7 +7064,7 @@ MeasurementReportHeader::Print(std::ostream& os) const << std::endl; if (!it->cgiInfo.plmnIdentityList.empty()) { - for (std::list::iterator it2 = it->cgiInfo.plmnIdentityList.begin(); + for (auto it2 = it->cgiInfo.plmnIdentityList.begin(); it2 != it->cgiInfo.plmnIdentityList.end(); it2++) { diff --git a/src/lte/model/lte-rrc-protocol-ideal.cc b/src/lte/model/lte-rrc-protocol-ideal.cc index 7a11813d3..0c304b3e7 100644 --- a/src/lte/model/lte-rrc-protocol-ideal.cc +++ b/src/lte/model/lte-rrc-protocol-ideal.cc @@ -206,9 +206,9 @@ LteUeRrcProtocolIdeal::SetEnbRrcSapProvider() // walk list of all nodes to get the peer eNB Ptr enbDev; - NodeList::Iterator listEnd = NodeList::End(); + auto listEnd = NodeList::End(); bool found = false; - for (NodeList::Iterator i = NodeList::Begin(); (i != listEnd) && (!found); ++i) + for (auto i = NodeList::Begin(); (i != listEnd) && (!found); ++i) { Ptr node = *i; int nDevs = node->GetNDevices(); @@ -288,8 +288,7 @@ LteEnbRrcProtocolIdeal::SetCellId(uint16_t cellId) LteUeRrcSapProvider* LteEnbRrcProtocolIdeal::GetUeRrcSapProvider(uint16_t rnti) { - std::map::const_iterator it; - it = m_enbRrcSapProviderMap.find(rnti); + auto it = m_enbRrcSapProviderMap.find(rnti); NS_ASSERT_MSG(it != m_enbRrcSapProviderMap.end(), "could not find RNTI = " << rnti); return it->second; } @@ -297,8 +296,7 @@ LteEnbRrcProtocolIdeal::GetUeRrcSapProvider(uint16_t rnti) void LteEnbRrcProtocolIdeal::SetUeRrcSapProvider(uint16_t rnti, LteUeRrcSapProvider* p) { - std::map::iterator it; - it = m_enbRrcSapProviderMap.find(rnti); + auto it = m_enbRrcSapProviderMap.find(rnti); // assign UE RRC only if the RNTI is found at eNB if (it != m_enbRrcSapProviderMap.end()) { @@ -359,7 +357,7 @@ LteEnbRrcProtocolIdeal::DoSendSystemInformation(uint16_t cellId, LteRrcSap::Syst NS_LOG_FUNCTION(this << cellId); // walk list of all nodes to get UEs with this cellId Ptr ueRrc; - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr node = *i; int nDevs = node->GetNDevices(); @@ -576,8 +574,7 @@ LteEnbRrcProtocolIdeal::DoDecodeHandoverPreparationInformation(Ptr p) p->RemoveHeader(h); uint32_t msgId = h.GetMsgId(); NS_LOG_INFO(" decoding msgId = " << msgId); - std::map::iterator it = - g_handoverPreparationInfoMsgMap.find(msgId); + auto it = g_handoverPreparationInfoMsgMap.find(msgId); NS_ASSERT_MSG(it != g_handoverPreparationInfoMsgMap.end(), "msgId " << msgId << " not found"); LteRrcSap::HandoverPreparationInfo msg = it->second; g_handoverPreparationInfoMsgMap.erase(it); @@ -699,8 +696,7 @@ LteEnbRrcProtocolIdeal::DoDecodeHandoverCommand(Ptr p) p->RemoveHeader(h); uint32_t msgId = h.GetMsgId(); NS_LOG_INFO(" decoding msgId = " << msgId); - std::map::iterator it = - g_handoverCommandMsgMap.find(msgId); + auto it = g_handoverCommandMsgMap.find(msgId); NS_ASSERT_MSG(it != g_handoverCommandMsgMap.end(), "msgId " << msgId << " not found"); LteRrcSap::RrcConnectionReconfiguration msg = it->second; g_handoverCommandMsgMap.erase(it); diff --git a/src/lte/model/lte-rrc-protocol-real.cc b/src/lte/model/lte-rrc-protocol-real.cc index 13d67cd2c..962978777 100644 --- a/src/lte/model/lte-rrc-protocol-real.cc +++ b/src/lte/model/lte-rrc-protocol-real.cc @@ -269,9 +269,9 @@ LteUeRrcProtocolReal::SetEnbRrcSapProvider() // walk list of all nodes to get the peer eNB Ptr enbDev; - NodeList::Iterator listEnd = NodeList::End(); + auto listEnd = NodeList::End(); bool found = false; - for (NodeList::Iterator i = NodeList::Begin(); (i != listEnd) && (!found); ++i) + for (auto i = NodeList::Begin(); (i != listEnd) && (!found); ++i) { Ptr node = *i; int nDevs = node->GetNDevices(); @@ -400,8 +400,7 @@ LteEnbRrcProtocolReal::DoDispose() { NS_LOG_FUNCTION(this); delete m_enbRrcSapUser; - for (std::map::iterator it = - m_completeSetupUeParametersMap.begin(); + for (auto it = m_completeSetupUeParametersMap.begin(); it != m_completeSetupUeParametersMap.end(); ++it) { @@ -442,8 +441,7 @@ LteEnbRrcProtocolReal::SetCellId(uint16_t cellId) LteUeRrcSapProvider* LteEnbRrcProtocolReal::GetUeRrcSapProvider(uint16_t rnti) { - std::map::const_iterator it; - it = m_enbRrcSapProviderMap.find(rnti); + auto it = m_enbRrcSapProviderMap.find(rnti); NS_ASSERT_MSG(it != m_enbRrcSapProviderMap.end(), "could not find RNTI = " << rnti); return it->second; } @@ -451,8 +449,7 @@ LteEnbRrcProtocolReal::GetUeRrcSapProvider(uint16_t rnti) void LteEnbRrcProtocolReal::SetUeRrcSapProvider(uint16_t rnti, LteUeRrcSapProvider* p) { - std::map::iterator it; - it = m_enbRrcSapProviderMap.find(rnti); + auto it = m_enbRrcSapProviderMap.find(rnti); // assign UE RRC only if the RNTI is found at eNB if (it != m_enbRrcSapProviderMap.end()) { @@ -503,8 +500,7 @@ LteEnbRrcProtocolReal::DoSetupUe(uint16_t rnti, LteEnbRrcSapUser::SetupUeParamet m_setupUeParametersMap[rnti] = params; LteEnbRrcSapProvider::CompleteSetupUeParameters completeSetupUeParameters; - std::map::iterator csupIt = - m_completeSetupUeParametersMap.find(rnti); + auto csupIt = m_completeSetupUeParametersMap.find(rnti); if (csupIt == m_completeSetupUeParametersMap.end()) { // Create LteRlcSapUser, LtePdcpSapUser @@ -527,8 +523,7 @@ void LteEnbRrcProtocolReal::DoRemoveUe(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = - m_completeSetupUeParametersMap.find(rnti); + auto it = m_completeSetupUeParametersMap.find(rnti); NS_ASSERT(it != m_completeSetupUeParametersMap.end()); delete it->second.srb0SapUser; delete it->second.srb1SapUser; @@ -543,7 +538,7 @@ LteEnbRrcProtocolReal::DoSendSystemInformation(uint16_t cellId, LteRrcSap::Syste NS_LOG_FUNCTION(this << cellId); // walk list of all nodes to get UEs with this cellId Ptr ueRrc; - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr node = *i; int nDevs = node->GetNDevices(); diff --git a/src/lte/model/lte-spectrum-phy.cc b/src/lte/model/lte-spectrum-phy.cc index 680969b6b..4aba82900 100644 --- a/src/lte/model/lte-spectrum-phy.cc +++ b/src/lte/model/lte-spectrum-phy.cc @@ -911,11 +911,10 @@ LteSpectrumPhy::AddExpectedTb(uint16_t rnti, TbId_t tbId; tbId.m_rnti = rnti; tbId.m_layer = layer; - expectedTbs_t::iterator it; - it = m_expectedTbs.find(tbId); + auto it = m_expectedTbs.find(tbId); if (it != m_expectedTbs.end()) { - // might be a TB of an unreceived packet (due to high progpalosses) + // might be a TB of an unreceived packet (due to high propagation losses) m_expectedTbs.erase(it); } // insert new entry @@ -933,8 +932,7 @@ LteSpectrumPhy::RemoveExpectedTb(uint16_t rnti) for (uint8_t i = 0; i < 2; i++) { tbId.m_layer = i; - expectedTbs_t::iterator it; - it = m_expectedTbs.find(tbId); + auto it = m_expectedTbs.find(tbId); if (it != m_expectedTbs.end()) { m_expectedTbs.erase(it); @@ -955,7 +953,7 @@ LteSpectrumPhy::EndRxData() m_interferenceData->EndRx(); NS_LOG_DEBUG(this << " No. of burts " << m_rxPacketBurstList.size()); NS_LOG_DEBUG(this << " Expected TBs " << m_expectedTbs.size()); - expectedTbs_t::iterator itTb = m_expectedTbs.begin(); + auto itTb = m_expectedTbs.begin(); // apply transmission mode gain NS_LOG_DEBUG(this << " txMode " << (uint16_t)m_transmissionMode << " gain " @@ -1029,11 +1027,9 @@ LteSpectrumPhy::EndRxData() itTb++; } std::map harqDlInfoMap; - for (std::list>::const_iterator i = m_rxPacketBurstList.begin(); - i != m_rxPacketBurstList.end(); - ++i) + for (auto i = m_rxPacketBurstList.begin(); i != m_rxPacketBurstList.end(); ++i) { - for (std::list>::const_iterator j = (*i)->Begin(); j != (*i)->End(); ++j) + for (auto j = (*i)->Begin(); j != (*i)->End(); ++j) { // retrieve TB info of this packet LteRadioBearerTag tag; @@ -1094,8 +1090,7 @@ LteSpectrumPhy::EndRxData() } else { - std::map::iterator itHarq = - harqDlInfoMap.find(tbId.m_rnti); + auto itHarq = harqDlInfoMap.find(tbId.m_rnti); if (itHarq == harqDlInfoMap.end()) { DlInfoListElement_s harqDlInfo; @@ -1170,8 +1165,7 @@ LteSpectrumPhy::EndRxData() } // send DL HARQ feedback to LtePhy - std::map::iterator itHarq; - for (itHarq = harqDlInfoMap.begin(); itHarq != harqDlInfoMap.end(); itHarq++) + for (auto itHarq = harqDlInfoMap.begin(); itHarq != harqDlInfoMap.end(); itHarq++) { if (!m_ltePhyDlHarqFeedbackCallback.IsNull()) { diff --git a/src/lte/model/lte-spectrum-value-helper.cc b/src/lte/model/lte-spectrum-value-helper.cc index dbf37242e..366f0e1c1 100644 --- a/src/lte/model/lte-spectrum-value-helper.cc +++ b/src/lte/model/lte-spectrum-value-helper.cc @@ -43,7 +43,7 @@ namespace std ostream& operator<<(ostream& os, const vector& v) { - vector::const_iterator it = v.begin(); + auto it = v.begin(); while (it != v.end()) { os << *it << " "; @@ -252,7 +252,7 @@ LteSpectrumValueHelper::GetSpectrumModel(uint32_t earfcn, uint16_t txBandwidthCo NS_LOG_FUNCTION(earfcn << txBandwidthConfiguration); Ptr ret; LteSpectrumModelId key(earfcn, txBandwidthConfiguration); - std::map>::iterator it = g_lteSpectrumModelMap.find(key); + auto it = g_lteSpectrumModelMap.find(key); if (it != g_lteSpectrumModelMap.end()) { ret = it->second; @@ -297,7 +297,7 @@ LteSpectrumValueHelper::CreateTxPowerSpectralDensity(uint32_t earfcn, double txPowerDensity = (powerTxW / (txBandwidthConfiguration * 180000)); - for (std::vector::iterator it = activeRbs.begin(); it != activeRbs.end(); it++) + for (auto it = activeRbs.begin(); it != activeRbs.end(); it++) { int rbId = (*it); (*txPsd)[rbId] = txPowerDensity; @@ -323,11 +323,11 @@ LteSpectrumValueHelper::CreateTxPowerSpectralDensity(uint32_t earfcn, // powerTx is expressed in dBm. We must convert it into natural unit. double basicPowerTxW = std::pow(10., (powerTx - 30) / 10); - for (std::vector::iterator it = activeRbs.begin(); it != activeRbs.end(); it++) + for (auto it = activeRbs.begin(); it != activeRbs.end(); it++) { int rbId = (*it); - std::map::iterator powerIt = powerTxMap.find(rbId); + auto powerIt = powerTxMap.find(rbId); double txPowerDensity; @@ -365,7 +365,7 @@ LteSpectrumValueHelper::CreateUlTxPowerSpectralDensity(uint16_t earfcn, double txPowerDensity = (powerTxW / (activeRbs.size() * 180000)); - for (std::vector::iterator it = activeRbs.begin(); it != activeRbs.end(); it++) + for (auto it = activeRbs.begin(); it != activeRbs.end(); it++) { int rbId = (*it); (*txPsd)[rbId] = txPowerDensity; diff --git a/src/lte/model/lte-ue-component-carrier-manager.cc b/src/lte/model/lte-ue-component-carrier-manager.cc index 7cfc28b95..94db8f7f5 100644 --- a/src/lte/model/lte-ue-component-carrier-manager.cc +++ b/src/lte/model/lte-ue-component-carrier-manager.cc @@ -77,8 +77,7 @@ LteUeComponentCarrierManager::SetComponentCarrierMacSapProviders(uint8_t compone { NS_LOG_FUNCTION(this); bool result = false; - std::map::iterator it; - it = m_macSapProvidersMap.find(componentCarrierId); + auto it = m_macSapProvidersMap.find(componentCarrierId); if (componentCarrierId > m_noOfComponentCarriers) { NS_FATAL_ERROR("Inconsistent componentCarrierId or you didn't call " diff --git a/src/lte/model/lte-ue-mac.cc b/src/lte/model/lte-ue-mac.cc index 5518f3dec..93131db99 100644 --- a/src/lte/model/lte-ue-mac.cc +++ b/src/lte/model/lte-ue-mac.cc @@ -333,9 +333,7 @@ LteUeMac::DoReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters p { NS_LOG_FUNCTION(this << (uint32_t)params.lcid); - std::map::iterator it; - - it = m_ulBsrReceived.find(params.lcid); + auto it = m_ulBsrReceived.find(params.lcid); if (it != m_ulBsrReceived.end()) { // update entry @@ -371,13 +369,11 @@ LteUeMac::SendReportBufferStatus() bsr.m_macCeType = MacCeListElement_s::BSR; // BSR is reported for each LCG - std::map::iterator it; std::vector queue(4, 0); // one value per each of the 4 LCGs, initialized to 0 - for (it = m_ulBsrReceived.begin(); it != m_ulBsrReceived.end(); it++) + for (auto it = m_ulBsrReceived.begin(); it != m_ulBsrReceived.end(); it++) { uint8_t lcid = it->first; - std::map::iterator lcInfoMapIt; - lcInfoMapIt = m_lcInfoMap.find(lcid); + auto lcInfoMapIt = m_lcInfoMap.find(lcid); NS_ASSERT(lcInfoMapIt != m_lcInfoMap.end()); NS_ASSERT_MSG((lcid != 0) || (((*it).second.txQueueSize == 0) && ((*it).second.retxQueueSize == 0) && @@ -462,10 +458,9 @@ LteUeMac::RecvRaResponse(BuildRarListElement_s raResponse) // trigger tx opportunity for Message 3 over LC 0 // this is needed since Message 3's UL GRANT is in the RAR, not in UL-DCIs const uint8_t lc0Lcid = 0; - std::map::iterator lc0InfoIt = m_lcInfoMap.find(lc0Lcid); + auto lc0InfoIt = m_lcInfoMap.find(lc0Lcid); NS_ASSERT(lc0InfoIt != m_lcInfoMap.end()); - std::map::iterator lc0BsrIt = - m_ulBsrReceived.find(lc0Lcid); + auto lc0BsrIt = m_ulBsrReceived.find(lc0Lcid); if ((lc0BsrIt != m_ulBsrReceived.end()) && (lc0BsrIt->second.txQueueSize > 0)) { NS_ASSERT_MSG(raResponse.m_grant.m_tbSize > lc0BsrIt->second.txQueueSize, @@ -596,7 +591,7 @@ void LteUeMac::DoReset() { NS_LOG_FUNCTION(this); - std::map::iterator it = m_lcInfoMap.begin(); + auto it = m_lcInfoMap.begin(); while (it != m_lcInfoMap.end()) { // don't delete CCCH) @@ -633,7 +628,7 @@ LteUeMac::DoReceivePhyPdu(Ptr p) if (tag.GetRnti() == m_rnti) { // packet is for the current user - std::map::const_iterator it = m_lcInfoMap.find(tag.GetLcid()); + auto it = m_lcInfoMap.find(tag.GetLcid()); if (it != m_lcInfoMap.end()) { LteMacSapUser::ReceivePduParameters rxPduParams; @@ -663,10 +658,9 @@ LteUeMac::DoReceiveLteControlMessage(Ptr msg) Ptr pb = CreateObject(); m_miUlHarqProcessesPacket.at(m_harqProcessId) = pb; // Retrieve data from RLC - std::map::iterator itBsr; uint16_t activeLcs = 0; uint32_t statusPduMinSize = 0; - for (itBsr = m_ulBsrReceived.begin(); itBsr != m_ulBsrReceived.end(); itBsr++) + for (auto itBsr = m_ulBsrReceived.begin(); itBsr != m_ulBsrReceived.end(); itBsr++) { if (((*itBsr).second.statusPduSize > 0) || ((*itBsr).second.retxQueueSize > 0) || ((*itBsr).second.txQueueSize > 0)) @@ -688,7 +682,6 @@ LteUeMac::DoReceiveLteControlMessage(Ptr msg) NS_LOG_ERROR(this << " No active flows for this UL-DCI"); return; } - std::map::iterator it; uint32_t bytesPerActiveLc = dci.m_tbSize / activeLcs; bool statusPduPriority = false; if ((statusPduMinSize != 0) && (bytesPerActiveLc < statusPduMinSize)) @@ -709,9 +702,9 @@ LteUeMac::DoReceiveLteControlMessage(Ptr msg) LteMacSapUser::TxOpportunityParameters txOpParams; - for (it = m_lcInfoMap.begin(); it != m_lcInfoMap.end(); it++) + for (auto it = m_lcInfoMap.begin(); it != m_lcInfoMap.end(); it++) { - itBsr = m_ulBsrReceived.find((*it).first); + auto itBsr = m_ulBsrReceived.find((*it).first); NS_LOG_DEBUG(this << " Processing LC " << (uint32_t)(*it).first << " bytesPerActiveLc " << bytesPerActiveLc); if ((itBsr != m_ulBsrReceived.end()) && @@ -849,7 +842,7 @@ LteUeMac::DoReceiveLteControlMessage(Ptr msg) // HARQ retransmission -> retrieve data from HARQ buffer NS_LOG_DEBUG(this << " UE MAC RETX HARQ " << (uint16_t)m_harqProcessId); Ptr pb = m_miUlHarqProcessesPacket.at(m_harqProcessId); - for (std::list>::const_iterator j = pb->Begin(); j != pb->End(); ++j) + for (auto j = pb->Begin(); j != pb->End(); ++j) { Ptr pkt = (*j)->Copy(); m_uePhySapProvider->SendMacPdu(pkt); @@ -867,10 +860,7 @@ LteUeMac::DoReceiveLteControlMessage(Ptr msg) << (uint32_t)m_raRnti); if (raRnti == m_raRnti) // RAR corresponds to TX subframe of preamble { - for (std::list::const_iterator it = - rarMsg->RarListBegin(); - it != rarMsg->RarListEnd(); - ++it) + for (auto it = rarMsg->RarListBegin(); it != rarMsg->RarListEnd(); ++it) { if (it->rapId == m_raPreambleId) // RAR is for me { diff --git a/src/lte/model/lte-ue-net-device.cc b/src/lte/model/lte-ue-net-device.cc index eb21cf1d2..213b36a66 100644 --- a/src/lte/model/lte-ue-net-device.cc +++ b/src/lte/model/lte-ue-net-device.cc @@ -267,8 +267,7 @@ LteUeNetDevice::DoInitialize() m_isConstructed = true; UpdateConfig(); - std::map>::iterator it; - for (it = m_ccMap.begin(); it != m_ccMap.end(); ++it) + for (auto it = m_ccMap.begin(); it != m_ccMap.end(); ++it) { it->second->GetPhy()->Initialize(); it->second->GetMac()->Initialize(); diff --git a/src/lte/model/lte-ue-phy.cc b/src/lte/model/lte-ue-phy.cc index f7ef206e7..9daff28b1 100644 --- a/src/lte/model/lte-ue-phy.cc +++ b/src/lte/model/lte-ue-phy.cc @@ -609,8 +609,8 @@ LteUePhy::GenerateCqiRsrpRsrq(const SpectrumValue& sinr) // RSRP evaluated as averaged received power among RBs double sum = 0.0; uint8_t rbNum = 0; - Values::const_iterator it; - for (it = m_rsReceivedPower.ConstValuesBegin(); it != m_rsReceivedPower.ConstValuesEnd(); + for (auto it = m_rsReceivedPower.ConstValuesBegin(); + it != m_rsReceivedPower.ConstValuesEnd(); it++) { // convert PSD [W/Hz] to linear power [W] for the single RE @@ -648,14 +648,14 @@ LteUePhy::GenerateCqiRsrpRsrq(const SpectrumValue& sinr) // measure instantaneous RSRQ now NS_ASSERT_MSG(m_rsInterferencePowerUpdated, " RS interference power info obsolete"); - std::list::iterator itPss = m_pssList.begin(); + auto itPss = m_pssList.begin(); while (itPss != m_pssList.end()) { uint16_t rbNum = 0; double rssiSum = 0.0; - Values::const_iterator itIntN = m_rsInterferencePower.ConstValuesBegin(); - Values::const_iterator itPj = m_rsReceivedPower.ConstValuesBegin(); + auto itIntN = m_rsInterferencePower.ConstValuesBegin(); + auto itPj = m_rsReceivedPower.ConstValuesBegin(); for (itPj = m_rsReceivedPower.ConstValuesBegin(); itPj != m_rsReceivedPower.ConstValuesEnd(); itIntN++, itPj++) @@ -675,8 +675,7 @@ LteUePhy::GenerateCqiRsrpRsrq(const SpectrumValue& sinr) NS_LOG_INFO(this << " PSS RNTI " << m_rnti << " cellId " << m_cellId << " has RSRQ " << rsrq_dB << " and RBnum " << rbNum); // store measurements - std::map::iterator itMeasMap; - itMeasMap = m_ueMeasurementsMap.find((*itPss).cellId); + auto itMeasMap = m_ueMeasurementsMap.find((*itPss).cellId); if (itMeasMap != m_ueMeasurementsMap.end()) { (*itMeasMap).second.rsrqSum += rsrq_dB; @@ -706,9 +705,8 @@ LteUePhy::ComputeAvgSinr(const SpectrumValue& sinr) // averaged SINR among RBs double sum = 0.0; uint8_t rbNum = 0; - Values::const_iterator it; - for (it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) + for (auto it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) { sum += (*it); rbNum++; @@ -818,8 +816,8 @@ LteUePhy::ReportRsReceivedPower(const SpectrumValue& power) if (m_enableUplinkPowerControl) { double sum = 0; - Values::const_iterator it; - for (it = m_rsReceivedPower.ConstValuesBegin(); it != m_rsReceivedPower.ConstValuesEnd(); + for (auto it = m_rsReceivedPower.ConstValuesBegin(); + it != m_rsReceivedPower.ConstValuesEnd(); it++) { double powerTxW = ((*it) * 180000); @@ -940,8 +938,7 @@ LteUePhy::ReportUeMeasurements() LteUeCphySapUser::UeMeasurementsParameters ret; - std::map::iterator it; - for (it = m_ueMeasurementsMap.begin(); it != m_ueMeasurementsMap.end(); it++) + for (auto it = m_ueMeasurementsMap.begin(); it != m_ueMeasurementsMap.end(); it++) { double avg_rsrp = (*it).second.rsrpSum / (double)(*it).second.rsrpNum; double avg_rsrq = (*it).second.rsrqSum / (double)(*it).second.rsrqNum; @@ -968,7 +965,7 @@ LteUePhy::ReportUeMeasurements() (*it).first, avg_rsrp, avg_rsrq, - ((*it).first == m_cellId ? 1 : 0), + (*it).first == m_cellId, m_componentCarrierId); } @@ -1029,10 +1026,9 @@ LteUePhy::ReceiveLteControlMessageList(std::list> msgList { NS_LOG_FUNCTION(this); - std::list>::iterator it; NS_LOG_DEBUG(this << " I am rnti = " << m_rnti << " and I received msgs " << (uint16_t)msgList.size()); - for (it = msgList.begin(); it != msgList.end(); it++) + for (auto it = msgList.begin(); it != msgList.end(); it++) { Ptr msg = (*it); @@ -1135,10 +1131,7 @@ LteUePhy::ReceiveLteControlMessageList(std::list> msgList Ptr rarMsg = DynamicCast(msg); if (rarMsg->GetRaRnti() == m_raRnti) { - for (std::list::const_iterator it = - rarMsg->RarListBegin(); - it != rarMsg->RarListEnd(); - ++it) + for (auto it = rarMsg->RarListBegin(); it != rarMsg->RarListEnd(); ++it) { if (it->rapId != m_raPreambleId) { @@ -1195,8 +1188,7 @@ LteUePhy::ReceivePss(uint16_t cellId, Ptr p) double sum = 0.0; uint16_t nRB = 0; - Values::const_iterator itPi; - for (itPi = p->ConstValuesBegin(); itPi != p->ConstValuesEnd(); itPi++) + for (auto itPi = p->ConstValuesBegin(); itPi != p->ConstValuesEnd(); itPi++) { // convert PSD [W/Hz] to linear power [W] for the single RE double powerTxW = ((*itPi) * 180000.0) / 12.0; @@ -1211,8 +1203,7 @@ LteUePhy::ReceivePss(uint16_t cellId, Ptr p) // note that m_pssReceptionThreshold does not apply here // store measurements - std::map::iterator itMeasMap = - m_ueMeasurementsMap.find(cellId); + auto itMeasMap = m_ueMeasurementsMap.find(cellId); if (itMeasMap == m_ueMeasurementsMap.end()) { // insert new entry diff --git a/src/lte/model/lte-ue-phy.h b/src/lte/model/lte-ue-phy.h index 81b5e7eda..3b16825da 100644 --- a/src/lte/model/lte-ue-phy.h +++ b/src/lte/model/lte-ue-phy.h @@ -698,7 +698,7 @@ class LteUePhy : public LtePhy uint16_t m_srsPeriodicity; ///< SRS periodicity uint16_t m_srsSubframeOffset; ///< SRS subframe offset - uint16_t m_srsConfigured; ///< SRS configured + bool m_srsConfigured; ///< SRS configured Time m_srsStartTime; ///< SRS start time double m_paLinear; ///< PA linear diff --git a/src/lte/model/lte-ue-rrc.cc b/src/lte/model/lte-ue-rrc.cc index 4e600a86a..ae7ebe879 100644 --- a/src/lte/model/lte-ue-rrc.cc +++ b/src/lte/model/lte-ue-rrc.cc @@ -591,7 +591,7 @@ LteUeRrc::DoSendData(Ptr packet, uint8_t bid) if (drbid != 0) { - std::map>::iterator it = m_drbMap.find(drbid); + auto it = m_drbMap.find(drbid); NS_ASSERT_MSG(it != m_drbMap.end(), "could not find bearer with drbid == " << drbid); LtePdcpSapProvider::TransmitPdcpSduParameters params; @@ -681,8 +681,7 @@ LteUeRrc::DoNotifyRandomAccessSuccessful() m_rrcSapUser->SendRrcConnectionReconfigurationCompleted(msg); // 3GPP TS 36.331 section 5.5.6.1 Measurements related actions upon handover - std::map::iterator measIdIt; - for (measIdIt = m_varMeasConfig.measIdList.begin(); + for (auto measIdIt = m_varMeasConfig.measIdList.begin(); measIdIt != m_varMeasConfig.measIdList.end(); ++measIdIt) { @@ -917,8 +916,7 @@ LteUeRrc::DoReportUeMeasurements(LteUeCphySapUser::UeMeasurementsParameters para // layer 3 filtering does not apply in IDLE mode bool useLayer3Filtering = (m_state == CONNECTED_NORMALLY); bool triggering = true; - std::vector::iterator newMeasIt; - for (newMeasIt = params.m_ueMeasurementsList.begin(); + for (auto newMeasIt = params.m_ueMeasurementsList.begin(); newMeasIt != params.m_ueMeasurementsList.end(); ++newMeasIt) { @@ -943,8 +941,7 @@ LteUeRrc::DoReportUeMeasurements(LteUeCphySapUser::UeMeasurementsParameters para { if (triggering) { - std::map::iterator measIdIt; - for (measIdIt = m_varMeasConfig.measIdList.begin(); + for (auto measIdIt = m_varMeasConfig.measIdList.begin(); measIdIt != m_varMeasConfig.measIdList.end(); ++measIdIt) { @@ -1248,8 +1245,7 @@ LteUeRrc::SynchronizeToStrongestCell() double maxRsrp = -std::numeric_limits::infinity(); double minRsrp = -140.0; // Minimum RSRP in dBm a UE can report - std::map::iterator it; - for (it = m_storedMeasValues.begin(); it != m_storedMeasValues.end(); it++) + for (auto it = m_storedMeasValues.begin(); it != m_storedMeasValues.end(); it++) { /* * This block attempts to find a cell with strongest RSRP and has not @@ -1257,8 +1253,7 @@ LteUeRrc::SynchronizeToStrongestCell() */ if (maxRsrp < it->second.rsrp && it->second.rsrp > minRsrp) { - std::set::const_iterator itCell; - itCell = m_acceptableCell.find(it->first); + auto itCell = m_acceptableCell.find(it->first); if (itCell == m_acceptableCell.end()) { maxRsrpCellId = it->first; @@ -1294,7 +1289,7 @@ LteUeRrc::EvaluateCellForSelection() bool isSuitableCell = false; bool isAcceptableCell = false; - std::map::iterator storedMeasIt = m_storedMeasValues.find(cellId); + auto storedMeasIt = m_storedMeasValues.find(cellId); double qRxLevMeas = storedMeasIt->second.rsrp; double qRxLevMin = EutranMeasurementMapping::IeValue2ActualQRxLevMin(m_lastSib1.cellSelectionInfo.qRxLevMin); @@ -1437,7 +1432,7 @@ LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedica m_cphySapProvider.at(0)->SetPa(paDouble); } - std::list::const_iterator stamIt = rrcd.srbToAddModList.begin(); + auto stamIt = rrcd.srbToAddModList.begin(); if (stamIt != rrcd.srbToAddModList.end()) { if (!m_srb1) @@ -1498,8 +1493,7 @@ LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedica } } - std::list::const_iterator dtamIt; - for (dtamIt = rrcd.drbToAddModList.begin(); dtamIt != rrcd.drbToAddModList.end(); ++dtamIt) + for (auto dtamIt = rrcd.drbToAddModList.begin(); dtamIt != rrcd.drbToAddModList.end(); ++dtamIt) { NS_LOG_INFO(this << " IMSI " << m_imsi << " adding/modifying DRBID " << (uint32_t)dtamIt->drbIdentity << " LC " @@ -1507,8 +1501,7 @@ LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedica NS_ASSERT_MSG(dtamIt->logicalChannelIdentity > 2, "LCID value " << dtamIt->logicalChannelIdentity << " is reserved for SRBs"); - std::map>::iterator drbMapIt = - m_drbMap.find(dtamIt->drbIdentity); + auto drbMapIt = m_drbMap.find(dtamIt->drbIdentity); if (drbMapIt == m_drbMap.end()) { NS_LOG_INFO("New Data Radio Bearer"); @@ -1585,8 +1578,7 @@ LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedica rlc->GetLteMacSapUser()); NS_LOG_DEBUG("Size of lcOnCcMapping vector " << lcOnCcMapping.size()); - std::vector::iterator itLcOnCcMapping = - lcOnCcMapping.begin(); + auto itLcOnCcMapping = lcOnCcMapping.begin(); NS_ASSERT_MSG(itLcOnCcMapping != lcOnCcMapping.end(), "Component carrier manager failed to add LC for data radio bearer"); @@ -1617,12 +1609,12 @@ LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedica } } - std::list::iterator dtdmIt; - for (dtdmIt = rrcd.drbToReleaseList.begin(); dtdmIt != rrcd.drbToReleaseList.end(); ++dtdmIt) + for (auto dtdmIt = rrcd.drbToReleaseList.begin(); dtdmIt != rrcd.drbToReleaseList.end(); + ++dtdmIt) { uint8_t drbid = *dtdmIt; NS_LOG_INFO(this << " IMSI " << m_imsi << " releasing DRB " << (uint32_t)drbid); - std::map>::iterator it = m_drbMap.find(drbid); + auto it = m_drbMap.find(drbid); NS_ASSERT_MSG(it != m_drbMap.end(), "could not find bearer with given lcid"); m_drbMap.erase(it); m_bid2DrbidMap.erase(drbid); @@ -1642,15 +1634,12 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) // perform the actions specified in 3GPP TS 36.331 section 5.5.2.1 // 3GPP TS 36.331 section 5.5.2.4 Measurement object removal - for (std::list::iterator it = mc.measObjectToRemoveList.begin(); - it != mc.measObjectToRemoveList.end(); - ++it) + for (auto it = mc.measObjectToRemoveList.begin(); it != mc.measObjectToRemoveList.end(); ++it) { uint8_t measObjectId = *it; NS_LOG_LOGIC(this << " deleting measObjectId " << (uint32_t)measObjectId); m_varMeasConfig.measObjectList.erase(measObjectId); - std::map::iterator measIdIt = - m_varMeasConfig.measIdList.begin(); + auto measIdIt = m_varMeasConfig.measIdList.begin(); while (measIdIt != m_varMeasConfig.measIdList.end()) { if (measIdIt->second.measObjectId == measObjectId) @@ -1672,9 +1661,7 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) } // 3GPP TS 36.331 section 5.5.2.5 Measurement object addition/ modification - for (std::list::iterator it = mc.measObjectToAddModList.begin(); - it != mc.measObjectToAddModList.end(); - ++it) + for (auto it = mc.measObjectToAddModList.begin(); it != mc.measObjectToAddModList.end(); ++it) { // simplifying assumptions NS_ASSERT_MSG(it->measObjectEutra.cellsToRemoveList.empty(), @@ -1689,14 +1676,12 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) "cellForWhichToReportCGI is not supported"); uint8_t measObjectId = it->measObjectId; - std::map::iterator measObjectIt = - m_varMeasConfig.measObjectList.find(measObjectId); + auto measObjectIt = m_varMeasConfig.measObjectList.find(measObjectId); if (measObjectIt != m_varMeasConfig.measObjectList.end()) { NS_LOG_LOGIC("measObjectId " << (uint32_t)measObjectId << " exists, updating entry"); measObjectIt->second = *it; - for (std::map::iterator measIdIt = - m_varMeasConfig.measIdList.begin(); + for (auto measIdIt = m_varMeasConfig.measIdList.begin(); measIdIt != m_varMeasConfig.measIdList.end(); ++measIdIt) { @@ -1717,15 +1702,13 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) } // 3GPP TS 36.331 section 5.5.2.6 Reporting configuration removal - for (std::list::iterator it = mc.reportConfigToRemoveList.begin(); - it != mc.reportConfigToRemoveList.end(); + for (auto it = mc.reportConfigToRemoveList.begin(); it != mc.reportConfigToRemoveList.end(); ++it) { uint8_t reportConfigId = *it; NS_LOG_LOGIC(this << " deleting reportConfigId " << (uint32_t)reportConfigId); m_varMeasConfig.reportConfigList.erase(reportConfigId); - std::map::iterator measIdIt = - m_varMeasConfig.measIdList.begin(); + auto measIdIt = m_varMeasConfig.measIdList.begin(); while (measIdIt != m_varMeasConfig.measIdList.end()) { if (measIdIt->second.reportConfigId == reportConfigId) @@ -1747,9 +1730,7 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) } // 3GPP TS 36.331 section 5.5.2.7 Reporting configuration addition/ modification - for (std::list::iterator it = - mc.reportConfigToAddModList.begin(); - it != mc.reportConfigToAddModList.end(); + for (auto it = mc.reportConfigToAddModList.begin(); it != mc.reportConfigToAddModList.end(); ++it) { // simplifying assumptions @@ -1757,15 +1738,13 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) "only trigger type EVENT is supported"); uint8_t reportConfigId = it->reportConfigId; - std::map::iterator reportConfigIt = - m_varMeasConfig.reportConfigList.find(reportConfigId); + auto reportConfigIt = m_varMeasConfig.reportConfigList.find(reportConfigId); if (reportConfigIt != m_varMeasConfig.reportConfigList.end()) { NS_LOG_LOGIC("reportConfigId " << (uint32_t)reportConfigId << " exists, updating entry"); m_varMeasConfig.reportConfigList[reportConfigId] = *it; - for (std::map::iterator measIdIt = - m_varMeasConfig.measIdList.begin(); + for (auto measIdIt = m_varMeasConfig.measIdList.begin(); measIdIt != m_varMeasConfig.measIdList.end(); ++measIdIt) { @@ -1805,8 +1784,7 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) NS_LOG_LOGIC(this << " new filter coefficients: aRsrp=" << m_varMeasConfig.aRsrp << ", aRsrq=" << m_varMeasConfig.aRsrq); - for (std::map::iterator measIdIt = - m_varMeasConfig.measIdList.begin(); + for (auto measIdIt = m_varMeasConfig.measIdList.begin(); measIdIt != m_varMeasConfig.measIdList.end(); ++measIdIt) { @@ -1815,9 +1793,7 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) } // 3GPP TS 36.331 section 5.5.2.2 Measurement identity removal - for (std::list::iterator it = mc.measIdToRemoveList.begin(); - it != mc.measIdToRemoveList.end(); - ++it) + for (auto it = mc.measIdToRemoveList.begin(); it != mc.measIdToRemoveList.end(); ++it) { uint8_t measId = *it; NS_LOG_LOGIC(this << " deleting measId " << (uint32_t)measId); @@ -1830,9 +1806,7 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) } // 3GPP TS 36.331 section 5.5.2.3 Measurement identity addition/ modification - for (std::list::iterator it = mc.measIdToAddModList.begin(); - it != mc.measIdToAddModList.end(); - ++it) + for (auto it = mc.measIdToAddModList.begin(); it != mc.measIdToAddModList.end(); ++it) { NS_LOG_LOGIC(this << " measId " << (uint32_t)it->measId << " (measObjectId=" << (uint32_t)it->measObjectId @@ -1842,8 +1816,7 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) NS_ASSERT(m_varMeasConfig.reportConfigList.find(it->reportConfigId) != m_varMeasConfig.reportConfigList.end()); m_varMeasConfig.measIdList[it->measId] = *it; // side effect: create new entry if not exists - std::map::iterator measReportIt = - m_varMeasReportList.find(it->measId); + auto measReportIt = m_varMeasReportList.find(it->measId); if (measReportIt != m_varMeasReportList.end()) { measReportIt->second.periodicReportTimer.Cancel(); @@ -1884,7 +1857,7 @@ LteUeRrc::SaveUeMeasurements(uint16_t cellId, { NS_LOG_FUNCTION(this << cellId << +componentCarrierId << rsrp << rsrq << useLayer3Filtering); - std::map::iterator storedMeasIt = m_storedMeasValues.find(cellId); + auto storedMeasIt = m_storedMeasValues.find(cellId); if (storedMeasIt != m_storedMeasValues.end()) { @@ -1921,8 +1894,7 @@ LteUeRrc::SaveUeMeasurements(uint16_t cellId, v.carrierFreq = m_cphySapProvider.at(componentCarrierId)->GetDlEarfcn(); std::pair val(cellId, v); - std::pair::iterator, bool> ret = - m_storedMeasValues.insert(val); + auto ret = m_storedMeasValues.insert(val); NS_ASSERT_MSG(ret.second == true, "element already existed"); storedMeasIt = ret.first; } @@ -1939,22 +1911,19 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) { NS_LOG_FUNCTION(this << (uint16_t)measId); - std::map::iterator measIdIt = - m_varMeasConfig.measIdList.find(measId); + auto measIdIt = m_varMeasConfig.measIdList.find(measId); NS_ASSERT(measIdIt != m_varMeasConfig.measIdList.end()); NS_ASSERT(measIdIt->first == measIdIt->second.measId); - std::map::iterator reportConfigIt = - m_varMeasConfig.reportConfigList.find(measIdIt->second.reportConfigId); + auto reportConfigIt = m_varMeasConfig.reportConfigList.find(measIdIt->second.reportConfigId); NS_ASSERT(reportConfigIt != m_varMeasConfig.reportConfigList.end()); LteRrcSap::ReportConfigEutra& reportConfigEutra = reportConfigIt->second.reportConfigEutra; - std::map::iterator measObjectIt = - m_varMeasConfig.measObjectList.find(measIdIt->second.measObjectId); + auto measObjectIt = m_varMeasConfig.measObjectList.find(measIdIt->second.measObjectId); NS_ASSERT(measObjectIt != m_varMeasConfig.measObjectList.end()); LteRrcSap::MeasObjectEutra& measObjectEutra = measObjectIt->second.measObjectEutra; - std::map::iterator measReportIt = m_varMeasReportList.find(measId); + auto measReportIt = m_varMeasReportList.find(measId); bool isMeasIdInReportList = (measReportIt != m_varMeasReportList.end()); // we don't check the purpose field, as it is only included for @@ -2202,7 +2171,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) break; } - for (std::map::iterator storedMeasIt = m_storedMeasValues.begin(); + for (auto storedMeasIt = m_storedMeasValues.begin(); storedMeasIt != m_storedMeasValues.end(); ++storedMeasIt) { @@ -2310,7 +2279,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) break; } - for (std::map::iterator storedMeasIt = m_storedMeasValues.begin(); + for (auto storedMeasIt = m_storedMeasValues.begin(); storedMeasIt != m_storedMeasValues.end(); ++storedMeasIt) { @@ -2427,7 +2396,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) if (entryCond) { - for (std::map::iterator storedMeasIt = m_storedMeasValues.begin(); + for (auto storedMeasIt = m_storedMeasValues.begin(); storedMeasIt != m_storedMeasValues.end(); ++storedMeasIt) { @@ -2500,8 +2469,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) { // leaving condition #2 does not have to be checked - for (std::map::iterator storedMeasIt = - m_storedMeasValues.begin(); + for (auto storedMeasIt = m_storedMeasValues.begin(); storedMeasIt != m_storedMeasValues.end(); ++storedMeasIt) { @@ -2523,8 +2491,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) { // leaving condition #2 has to be checked to cancel time-to-trigger - for (std::map::iterator storedMeasIt = - m_storedMeasValues.begin(); + for (auto storedMeasIt = m_storedMeasValues.begin(); storedMeasIt != m_storedMeasValues.end(); ++storedMeasIt) { @@ -2592,8 +2559,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) // check leaving condition #2 - for (std::map::iterator storedMeasIt = - m_storedMeasValues.begin(); + for (auto storedMeasIt = m_storedMeasValues.begin(); storedMeasIt != m_storedMeasValues.end(); ++storedMeasIt) { @@ -2670,8 +2636,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) this, measId, concernedCellsEntry); - std::map>::iterator enteringTriggerIt = - m_enteringTriggerQueue.find(measId); + auto enteringTriggerIt = m_enteringTriggerQueue.find(measId); NS_ASSERT(enteringTriggerIt != m_enteringTriggerQueue.end()); enteringTriggerIt->second.push_back(t); } @@ -2699,8 +2664,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) measId, concernedCellsLeaving, reportOnLeave); - std::map>::iterator leavingTriggerIt = - m_leavingTriggerQueue.find(measId); + auto leavingTriggerIt = m_leavingTriggerQueue.find(measId); NS_ASSERT(leavingTriggerIt != m_leavingTriggerQueue.end()); leavingTriggerIt->second.push_back(t); } @@ -2713,14 +2677,12 @@ LteUeRrc::CancelEnteringTrigger(uint8_t measId) { NS_LOG_FUNCTION(this << (uint16_t)measId); - std::map>::iterator it1 = - m_enteringTriggerQueue.find(measId); + auto it1 = m_enteringTriggerQueue.find(measId); NS_ASSERT(it1 != m_enteringTriggerQueue.end()); if (!it1->second.empty()) { - std::list::iterator it2; - for (it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) + for (auto it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { NS_ASSERT(it2->measId == measId); NS_LOG_LOGIC(this << " canceling entering time-to-trigger event at " @@ -2737,17 +2699,15 @@ LteUeRrc::CancelEnteringTrigger(uint8_t measId, uint16_t cellId) { NS_LOG_FUNCTION(this << (uint16_t)measId << cellId); - std::map>::iterator it1 = - m_enteringTriggerQueue.find(measId); + auto it1 = m_enteringTriggerQueue.find(measId); NS_ASSERT(it1 != m_enteringTriggerQueue.end()); - std::list::iterator it2 = it1->second.begin(); + auto it2 = it1->second.begin(); while (it2 != it1->second.end()) { NS_ASSERT(it2->measId == measId); - ConcernedCells_t::iterator it3; - for (it3 = it2->concernedCells.begin(); it3 != it2->concernedCells.end(); ++it3) + for (auto it3 = it2->concernedCells.begin(); it3 != it2->concernedCells.end(); ++it3) { if (*it3 == cellId) { @@ -2774,14 +2734,12 @@ LteUeRrc::CancelLeavingTrigger(uint8_t measId) { NS_LOG_FUNCTION(this << (uint16_t)measId); - std::map>::iterator it1 = - m_leavingTriggerQueue.find(measId); + auto it1 = m_leavingTriggerQueue.find(measId); NS_ASSERT(it1 != m_leavingTriggerQueue.end()); if (!it1->second.empty()) { - std::list::iterator it2; - for (it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) + for (auto it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { NS_ASSERT(it2->measId == measId); NS_LOG_LOGIC(this << " canceling leaving time-to-trigger event at " @@ -2798,17 +2756,15 @@ LteUeRrc::CancelLeavingTrigger(uint8_t measId, uint16_t cellId) { NS_LOG_FUNCTION(this << (uint16_t)measId << cellId); - std::map>::iterator it1 = - m_leavingTriggerQueue.find(measId); + auto it1 = m_leavingTriggerQueue.find(measId); NS_ASSERT(it1 != m_leavingTriggerQueue.end()); - std::list::iterator it2 = it1->second.begin(); + auto it2 = it1->second.begin(); while (it2 != it1->second.end()) { NS_ASSERT(it2->measId == measId); - ConcernedCells_t::iterator it3; - for (it3 = it2->concernedCells.begin(); it3 != it2->concernedCells.end(); ++it3) + for (auto it3 = it2->concernedCells.begin(); it3 != it2->concernedCells.end(); ++it3) { if (*it3 == cellId) { @@ -2836,23 +2792,21 @@ LteUeRrc::VarMeasReportListAdd(uint8_t measId, ConcernedCells_t enteringCells) NS_LOG_FUNCTION(this << (uint16_t)measId); NS_ASSERT(!enteringCells.empty()); - std::map::iterator measReportIt = m_varMeasReportList.find(measId); + auto measReportIt = m_varMeasReportList.find(measId); if (measReportIt == m_varMeasReportList.end()) { VarMeasReport r; r.measId = measId; std::pair val(measId, r); - std::pair::iterator, bool> ret = - m_varMeasReportList.insert(val); + auto ret = m_varMeasReportList.insert(val); NS_ASSERT_MSG(ret.second == true, "element already existed"); measReportIt = ret.first; } NS_ASSERT(measReportIt != m_varMeasReportList.end()); - for (ConcernedCells_t::const_iterator it = enteringCells.begin(); it != enteringCells.end(); - ++it) + for (auto it = enteringCells.begin(); it != enteringCells.end(); ++it) { measReportIt->second.cellsTriggeredList.insert(*it); } @@ -2870,8 +2824,7 @@ LteUeRrc::VarMeasReportListAdd(uint8_t measId, ConcernedCells_t enteringCells) measId); } - std::map>::iterator enteringTriggerIt = - m_enteringTriggerQueue.find(measId); + auto enteringTriggerIt = m_enteringTriggerQueue.find(measId); NS_ASSERT(enteringTriggerIt != m_enteringTriggerQueue.end()); if (!enteringTriggerIt->second.empty()) { @@ -2890,9 +2843,7 @@ LteUeRrc::VarMeasReportListAdd(uint8_t measId, ConcernedCells_t enteringCells) * we clean up the time-to-trigger queue. This case might occur when * time-to-trigger > 200 ms. */ - for (ConcernedCells_t::const_iterator it = enteringCells.begin(); - it != enteringCells.end(); - ++it) + for (auto it = enteringCells.begin(); it != enteringCells.end(); ++it) { CancelEnteringTrigger(measId, *it); } @@ -2908,10 +2859,10 @@ LteUeRrc::VarMeasReportListErase(uint8_t measId, ConcernedCells_t leavingCells, NS_LOG_FUNCTION(this << (uint16_t)measId); NS_ASSERT(!leavingCells.empty()); - std::map::iterator measReportIt = m_varMeasReportList.find(measId); + auto measReportIt = m_varMeasReportList.find(measId); NS_ASSERT(measReportIt != m_varMeasReportList.end()); - for (ConcernedCells_t::const_iterator it = leavingCells.begin(); it != leavingCells.end(); ++it) + for (auto it = leavingCells.begin(); it != leavingCells.end(); ++it) { measReportIt->second.cellsTriggeredList.erase(*it); } @@ -2928,8 +2879,7 @@ LteUeRrc::VarMeasReportListErase(uint8_t measId, ConcernedCells_t leavingCells, m_varMeasReportList.erase(measReportIt); } - std::map>::iterator leavingTriggerIt = - m_leavingTriggerQueue.find(measId); + auto leavingTriggerIt = m_leavingTriggerQueue.find(measId); NS_ASSERT(leavingTriggerIt != m_leavingTriggerQueue.end()); if (!leavingTriggerIt->second.empty()) { @@ -2948,9 +2898,7 @@ LteUeRrc::VarMeasReportListErase(uint8_t measId, ConcernedCells_t leavingCells, * we clean up the time-to-trigger queue. This case might occur when * time-to-trigger > 200 ms. */ - for (ConcernedCells_t::const_iterator it = leavingCells.begin(); - it != leavingCells.end(); - ++it) + for (auto it = leavingCells.begin(); it != leavingCells.end(); ++it) { CancelLeavingTrigger(measId, *it); } @@ -2966,7 +2914,7 @@ LteUeRrc::VarMeasReportListClear(uint8_t measId) NS_LOG_FUNCTION(this << (uint16_t)measId); // remove the measurement reporting entry for this measId from the VarMeasReportList - std::map::iterator measReportIt = m_varMeasReportList.find(measId); + auto measReportIt = m_varMeasReportList.find(measId); if (measReportIt != m_varMeasReportList.end()) { NS_LOG_LOGIC(this << " deleting existing report for measId " << (uint16_t)measId); @@ -2984,12 +2932,10 @@ LteUeRrc::SendMeasurementReport(uint8_t measId) NS_LOG_FUNCTION(this << (uint16_t)measId); // 3GPP TS 36.331 section 5.5.5 Measurement reporting - std::map::iterator measIdIt = - m_varMeasConfig.measIdList.find(measId); + auto measIdIt = m_varMeasConfig.measIdList.find(measId); NS_ASSERT(measIdIt != m_varMeasConfig.measIdList.end()); - std::map::iterator reportConfigIt = - m_varMeasConfig.reportConfigList.find(measIdIt->second.reportConfigId); + auto reportConfigIt = m_varMeasConfig.reportConfigList.find(measIdIt->second.reportConfigId); NS_ASSERT(reportConfigIt != m_varMeasConfig.reportConfigList.end()); LteRrcSap::ReportConfigEutra& reportConfigEutra = reportConfigIt->second.reportConfigEutra; @@ -2997,14 +2943,14 @@ LteUeRrc::SendMeasurementReport(uint8_t measId) LteRrcSap::MeasResults& measResults = measurementReport.measResults; measResults.measId = measId; - std::map::iterator measReportIt = m_varMeasReportList.find(measId); + auto measReportIt = m_varMeasReportList.find(measId); if (measReportIt == m_varMeasReportList.end()) { NS_LOG_ERROR("no entry found in m_varMeasReportList for measId " << (uint32_t)measId); } else { - std::map::iterator servingMeasIt = m_storedMeasValues.find(m_cellId); + auto servingMeasIt = m_storedMeasValues.find(m_cellId); NS_ASSERT(servingMeasIt != m_storedMeasValues.end()); measResults.measResultPCell.rsrpResult = EutranMeasurementMapping::Dbm2RsrpRange(servingMeasIt->second.rsrp); @@ -3045,16 +2991,14 @@ LteUeRrc::SendMeasurementReport(uint8_t measId) if (!(measReportIt->second.cellsTriggeredList.empty())) { std::multimap sortedNeighCells; - for (std::set::iterator cellsTriggeredIt = - measReportIt->second.cellsTriggeredList.begin(); + for (auto cellsTriggeredIt = measReportIt->second.cellsTriggeredList.begin(); cellsTriggeredIt != measReportIt->second.cellsTriggeredList.end(); ++cellsTriggeredIt) { uint16_t cellId = *cellsTriggeredIt; if (cellId != m_cellId) { - std::map::iterator neighborMeasIt = - m_storedMeasValues.find(cellId); + auto neighborMeasIt = m_storedMeasValues.find(cellId); double triggerValue; switch (reportConfigEutra.triggerQuantity) { @@ -3080,8 +3024,7 @@ LteUeRrc::SendMeasurementReport(uint8_t measId) ++sortedNeighCellsIt, ++count) { uint16_t cellId = sortedNeighCellsIt->second; - std::map::iterator neighborMeasIt = - m_storedMeasValues.find(cellId); + auto neighborMeasIt = m_storedMeasValues.find(cellId); NS_ASSERT(neighborMeasIt != m_storedMeasValues.end()); LteRrcSap::MeasResultEutra measResultEutra; measResultEutra.physCellId = cellId; @@ -3191,8 +3134,7 @@ LteUeRrc::LeaveConnectedMode() m_storedMeasValues.clear(); ResetRlfParams(); - std::map::iterator measIdIt; - for (measIdIt = m_varMeasConfig.measIdList.begin(); + for (auto measIdIt = m_varMeasConfig.measIdList.begin(); measIdIt != m_varMeasConfig.measIdList.end(); ++measIdIt) { @@ -3268,7 +3210,7 @@ LteUeRrc::DisposeOldSrb1() uint8_t LteUeRrc::Bid2Drbid(uint8_t bid) { - std::map::iterator it = m_bid2DrbidMap.find(bid); + auto it = m_bid2DrbidMap.find(bid); // NS_ASSERT_MSG (it != m_bid2DrbidMap.end (), "could not find BID " << bid); if (it == m_bid2DrbidMap.end()) { diff --git a/src/lte/model/no-op-component-carrier-manager.cc b/src/lte/model/no-op-component-carrier-manager.cc index 14d8a0226..4a85bf264 100644 --- a/src/lte/model/no-op-component-carrier-manager.cc +++ b/src/lte/model/no-op-component-carrier-manager.cc @@ -81,8 +81,7 @@ void NoOpComponentCarrierManager::DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params) { NS_LOG_FUNCTION(this); - std::map::iterator it = - m_macSapProvidersMap.find(params.componentCarrierId); + auto it = m_macSapProvidersMap.find(params.componentCarrierId); NS_ASSERT_MSG(it != m_macSapProvidersMap.end(), "could not find Sap for ComponentCarrier " << params.componentCarrierId); // with this algorithm all traffic is on Primary Carrier @@ -95,8 +94,7 @@ NoOpComponentCarrierManager::DoReportBufferStatus( { NS_LOG_FUNCTION(this); auto ueManager = m_ccmRrcSapUser->GetUeManager(params.rnti); - std::map::iterator it = - m_macSapProvidersMap.find(ueManager->GetComponentCarrierId()); + auto it = m_macSapProvidersMap.find(ueManager->GetComponentCarrierId()); NS_ASSERT_MSG(it != m_macSapProvidersMap.end(), "could not find Sap for ComponentCarrier "); it->second->ReportBufferStatus(params); } @@ -138,7 +136,6 @@ void NoOpComponentCarrierManager::DoAddUe(uint16_t rnti, uint8_t state) { NS_LOG_FUNCTION(this << rnti << (uint16_t)state); - std::map::iterator eccIt; // m_enabledComponentCarrier iterator auto ueInfoIt = m_ueInfo.find(rnti); if (ueInfoIt == m_ueInfo.end()) { diff --git a/src/lte/model/pf-ff-mac-scheduler.cc b/src/lte/model/pf-ff-mac-scheduler.cc index 3a0918c8a..34fee7b2d 100644 --- a/src/lte/model/pf-ff-mac-scheduler.cc +++ b/src/lte/model/pf-ff-mac-scheduler.cc @@ -161,7 +161,7 @@ PfFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -207,10 +207,9 @@ PfFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::map::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -237,15 +236,13 @@ PfFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -275,14 +272,12 @@ PfFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -304,11 +299,9 @@ PfFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -355,9 +348,8 @@ PfFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int PfFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -378,13 +370,12 @@ PfFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -408,13 +399,12 @@ PfFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -443,8 +433,7 @@ PfFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -454,8 +443,7 @@ PfFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -495,7 +483,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); - for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) + for (auto it = rbgMap.begin(); it != rbgMap.end(); it++) { if (*it) { @@ -505,9 +493,9 @@ PfFfMacScheduler::DoSchedDlTriggerReq( FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -523,7 +511,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( uint16_t tmpFfrRbStartOffset = 0; uint16_t index = 0; - for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) + for (auto it = ulRbMap.begin(); it != ulRbMap.end(); it++) { if (*it) { @@ -554,8 +542,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -619,15 +606,13 @@ PfFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -669,7 +654,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -697,8 +682,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -719,16 +703,14 @@ PfFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -815,8 +797,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -893,8 +874,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -907,15 +887,14 @@ PfFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -946,17 +925,16 @@ PfFfMacScheduler::DoSchedDlTriggerReq( NS_LOG_INFO(this << " ALLOCATION for RBG " << i << " of " << rbgNum); if (!rbgMap.at(i)) { - std::map::iterator it; - std::map::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double rcqiMax = 0.0; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { if (!m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*it).first)) { continue; } - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if (itRnti != rntiAllocated.end() || !HarqProcessAvailability((*it).first)) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -972,10 +950,8 @@ PfFfMacScheduler::DoSchedDlTriggerReq( } continue; } - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_a30CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -984,10 +960,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( std::vector sbCqi; if (itCqi == m_a30CqiRxed.end()) { - for (uint8_t k = 0; k < nLayer; k++) - { - sbCqi.push_back(1); // start with lowest value - } + sbCqi = std::vector(nLayer, 1); // start with lowest value } else { @@ -1046,8 +1019,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( else { rbgMap.at(i) = true; - std::map>::iterator itMap; - itMap = allocationMap.find((*itMax).first); + auto itMap = allocationMap.find((*itMax).first); if (itMap == allocationMap.end()) { // insert new element @@ -1066,15 +1038,14 @@ PfFfMacScheduler::DoSchedDlTriggerReq( } // end for RBGs // reset TTI stats of users - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.lastTtiBytesTrasmitted = 0; } // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -1093,10 +1064,8 @@ PfFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_a30CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1181,9 +1150,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1205,8 +1172,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1235,8 +1201,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1244,8 +1209,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1257,8 +1221,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( ret.m_buildDataList.push_back(newEl); // update UE stats - std::map::iterator it; - it = m_flowStatsDl.find((*itMap).first); + auto it = m_flowStatsDl.find((*itMap).first); if (it != m_flowStatsDl.end()) { (*it).second.lastTtiBytesTrasmitted = bytesTxed; @@ -1275,7 +1238,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( // update UEs stats NS_LOG_INFO(this << " Update UEs statistics"); - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -1313,9 +1276,8 @@ PfFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1330,17 +1292,15 @@ PfFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1353,8 +1313,7 @@ PfFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1368,7 +1327,7 @@ PfFfMacScheduler::DoSchedDlCqiInfoReq( double PfFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1420,7 +1379,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( rbMap.resize(m_cschedCellConfig.m_ulBandwidth, false); rbMap = m_ffrSapProvider->GetAvailableUlRbg(); - for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) + for (auto it = rbMap.begin(); it != rbMap.end(); it++) { if (*it) { @@ -1451,8 +1410,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1460,16 +1418,14 @@ PfFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1528,7 +1484,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1562,7 +1518,6 @@ PfFfMacScheduler::DoSchedUlTriggerReq( int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -1584,7 +1539,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1676,7 +1631,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( break; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1747,15 +1702,13 @@ PfFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1763,8 +1716,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1780,7 +1732,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( << (uint16_t)harqId); // update TTI UE stats - itStats = m_flowStatsUl.find((*it).first); + auto itStats = m_flowStatsUl.find((*it).first); if (itStats != m_flowStatsUl.end()) { (*itStats).second.lastTtiBytesTrasmitted = uldci.m_tbSize; @@ -1806,7 +1758,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( // Update global UE stats // update UEs stats - for (itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) + for (auto itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -1843,8 +1795,6 @@ PfFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1865,7 +1815,7 @@ PfFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1914,11 +1864,9 @@ PfFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1927,7 +1875,7 @@ PfFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1957,8 +1905,7 @@ PfFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1981,8 +1928,7 @@ PfFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2009,8 +1955,7 @@ PfFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2030,7 +1975,7 @@ void PfFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -2038,12 +1983,12 @@ PfFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -2055,7 +2000,7 @@ PfFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -2063,12 +2008,12 @@ PfFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -2084,7 +2029,7 @@ void PfFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -2092,13 +2037,13 @@ PfFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -2113,9 +2058,8 @@ PfFfMacScheduler::RefreshUlCqiMaps() void PfFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2170,7 +2114,7 @@ void PfFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/pss-ff-mac-scheduler.cc b/src/lte/model/pss-ff-mac-scheduler.cc index 4884a52b1..1802d2e23 100644 --- a/src/lte/model/pss-ff-mac-scheduler.cc +++ b/src/lte/model/pss-ff-mac-scheduler.cc @@ -174,7 +174,7 @@ PssFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -220,10 +220,9 @@ PssFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::map::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -269,15 +268,13 @@ PssFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -307,14 +304,12 @@ PssFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -336,11 +331,9 @@ PssFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -387,9 +380,8 @@ PssFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int PssFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -410,13 +402,12 @@ PssFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -440,13 +431,12 @@ PssFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -475,8 +465,7 @@ PssFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -486,8 +475,7 @@ PssFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -527,7 +515,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); - for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) + for (auto it = rbgMap.begin(); it != rbgMap.end(); it++) { if (*it) { @@ -537,9 +525,9 @@ PssFfMacScheduler::DoSchedDlTriggerReq( FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -555,7 +543,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( uint16_t tmpFfrRbStartOffset = 0; uint16_t index = 0; - for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) + for (auto it = ulRbMap.begin(); it != ulRbMap.end(); it++) { if (*it) { @@ -586,8 +574,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -651,15 +638,13 @@ PssFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -701,7 +686,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -729,8 +714,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -751,16 +735,14 @@ PssFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -847,8 +829,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -925,8 +906,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -939,15 +919,14 @@ PssFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -973,12 +952,11 @@ PssFfMacScheduler::DoSchedDlTriggerReq( return; } - std::map::iterator it; std::map tdUeSet; // the result of TD scheduler // schedulability check std::map ueSet; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { if (LcActivePerFlow((*it).first) > 0) { @@ -992,9 +970,9 @@ PssFfMacScheduler::DoSchedDlTriggerReq( // Time Domain scheduler std::vector> ueSet1; std::vector> ueSet2; - for (it = ueSet.begin(); it != ueSet.end(); it++) + for (auto it = ueSet.begin(); it != ueSet.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it).first))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -1016,10 +994,8 @@ PssFfMacScheduler::DoSchedDlTriggerReq( metric = 1 / (*it).second.lastAveragedThroughput; // check first what are channel conditions for this UE, if CQI!=0 - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_p10CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1046,10 +1022,8 @@ PssFfMacScheduler::DoSchedDlTriggerReq( else { // calculate TD PF metric - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_p10CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1112,19 +1086,16 @@ PssFfMacScheduler::DoSchedDlTriggerReq( } } - std::vector>::iterator itSet; - for (itSet = ueSet1.begin(); itSet != ueSet1.end() && nMux != 0; itSet++) + for (auto itSet = ueSet1.begin(); itSet != ueSet1.end() && nMux != 0; itSet++) { - std::map::iterator itUe; - itUe = m_flowStatsDl.find((*itSet).second); + auto itUe = m_flowStatsDl.find((*itSet).second); tdUeSet.insert(std::pair((*itUe).first, (*itUe).second)); nMux--; } - for (itSet = ueSet2.begin(); itSet != ueSet2.end() && nMux != 0; itSet++) + for (auto itSet = ueSet2.begin(); itSet != ueSet2.end() && nMux != 0; itSet++) { - std::map::iterator itUe; - itUe = m_flowStatsDl.find((*itSet).second); + auto itUe = m_flowStatsDl.find((*itSet).second); tdUeSet.insert(std::pair((*itUe).first, (*itUe).second)); nMux--; } @@ -1133,15 +1104,13 @@ PssFfMacScheduler::DoSchedDlTriggerReq( { // FD scheduler: Carrier over Interference to Average (CoItA) std::map sbCqiSum; - for (it = tdUeSet.begin(); it != tdUeSet.end(); it++) + for (auto it = tdUeSet.begin(); it != tdUeSet.end(); it++) { uint8_t sum = 0; for (int i = 0; i < rbgNum; i++) { - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_a30CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1150,10 +1119,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( std::vector sbCqis; if (itCqi == m_a30CqiRxed.end()) { - for (uint8_t k = 0; k < nLayer; k++) - { - sbCqis.push_back(1); // start with lowest value - } + sbCqis = std::vector(nLayer, 1); // start with lowest value } else { @@ -1198,9 +1164,9 @@ PssFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::map::iterator itMax = tdUeSet.end(); + auto itMax = tdUeSet.end(); double metricMax = 0.0; - for (it = tdUeSet.begin(); it != tdUeSet.end(); it++) + for (auto it = tdUeSet.begin(); it != tdUeSet.end(); it++) { if (!m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*it).first)) { @@ -1215,13 +1181,10 @@ PssFfMacScheduler::DoSchedDlTriggerReq( weight = 1.0; } - std::map::iterator itSbCqiSum; - itSbCqiSum = sbCqiSum.find((*it).first); + auto itSbCqiSum = sbCqiSum.find((*it).first); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_a30CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1230,10 +1193,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( std::vector sbCqis; if (itCqi == m_a30CqiRxed.end()) { - for (uint8_t k = 0; k < nLayer; k++) - { - sbCqis.push_back(1); // start with lowest value - } + sbCqis = std::vector(nLayer, 1); // start with lowest value } else { @@ -1308,9 +1268,9 @@ PssFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::map::iterator itMax = tdUeSet.end(); + auto itMax = tdUeSet.end(); double metricMax = 0.0; - for (it = tdUeSet.begin(); it != tdUeSet.end(); it++) + for (auto it = tdUeSet.begin(); it != tdUeSet.end(); it++) { if (!m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*it).first)) { @@ -1324,10 +1284,8 @@ PssFfMacScheduler::DoSchedDlTriggerReq( weight = 1.0; } - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_a30CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1336,10 +1294,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( std::vector sbCqis; if (itCqi == m_a30CqiRxed.end()) { - for (uint8_t k = 0; k < nLayer; k++) - { - sbCqis.push_back(1); // start with lowest value - } + sbCqis = std::vector(nLayer, 1); // start with lowest value } else { @@ -1406,15 +1361,14 @@ PssFfMacScheduler::DoSchedDlTriggerReq( } // end if ueSet // reset TTI stats of users - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.lastTtiBytesTransmitted = 0; } // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -1433,10 +1387,8 @@ PssFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_a30CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1521,9 +1473,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1545,8 +1495,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1575,8 +1524,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1584,8 +1532,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1597,8 +1544,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( ret.m_buildDataList.push_back(newEl); // update UE stats - std::map::iterator it; - it = m_flowStatsDl.find((*itMap).first); + auto it = m_flowStatsDl.find((*itMap).first); if (it != m_flowStatsDl.end()) { (*it).second.lastTtiBytesTransmitted = bytesTxed; @@ -1615,9 +1561,9 @@ PssFfMacScheduler::DoSchedDlTriggerReq( // update UEs stats NS_LOG_INFO(this << " Update UEs statistics"); - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { - std::map::iterator itUeScheduleted = tdUeSet.end(); + auto itUeScheduleted = tdUeSet.end(); itUeScheduleted = tdUeSet.find((*itStats).first); if (itUeScheduleted != tdUeSet.end()) { @@ -1660,9 +1606,8 @@ PssFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1677,17 +1622,15 @@ PssFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1700,8 +1643,7 @@ PssFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1715,7 +1657,7 @@ PssFfMacScheduler::DoSchedDlCqiInfoReq( double PssFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1768,7 +1710,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( rbMap = m_ffrSapProvider->GetAvailableUlRbg(); - for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) + for (auto it = rbMap.begin(); it != rbMap.end(); it++) { if (*it) { @@ -1798,8 +1740,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1807,16 +1748,14 @@ PssFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1875,7 +1814,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1908,7 +1847,6 @@ PssFfMacScheduler::DoSchedUlTriggerReq( } int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -1930,7 +1868,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -2023,7 +1961,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( break; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -2094,15 +2032,13 @@ PssFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -2110,8 +2046,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -2165,8 +2100,6 @@ PssFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -2187,7 +2120,7 @@ PssFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -2233,11 +2166,9 @@ PssFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -2246,7 +2177,7 @@ PssFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2276,8 +2207,7 @@ PssFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2298,8 +2228,7 @@ PssFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2326,8 +2255,7 @@ PssFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2347,7 +2275,7 @@ void PssFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -2355,12 +2283,12 @@ PssFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -2372,7 +2300,7 @@ PssFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -2380,12 +2308,12 @@ PssFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -2401,7 +2329,7 @@ void PssFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -2409,13 +2337,13 @@ PssFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -2430,9 +2358,8 @@ PssFfMacScheduler::RefreshUlCqiMaps() void PssFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2487,7 +2414,7 @@ void PssFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/rr-ff-mac-scheduler.cc b/src/lte/model/rr-ff-mac-scheduler.cc index 636d98d24..aa0b41e21 100644 --- a/src/lte/model/rr-ff-mac-scheduler.cc +++ b/src/lte/model/rr-ff-mac-scheduler.cc @@ -160,7 +160,7 @@ RrFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -215,8 +215,7 @@ RrFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::list::iterator it = - m_rlcBufferReq.begin(); + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).m_rnti == params.m_rnti) && @@ -248,8 +247,7 @@ RrFfMacScheduler::DoCschedUeReleaseReq( m_ulHarqProcessesStatus.erase(params.m_rnti); m_ulHarqProcessesDciBuffer.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::list::iterator it = - m_rlcBufferReq.begin(); + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).m_rnti == params.m_rnti) @@ -280,8 +278,7 @@ RrFfMacScheduler::DoSchedDlRlcBufferReq( { NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::list::iterator it = - m_rlcBufferReq.begin(); + auto it = m_rlcBufferReq.begin(); bool newLc = true; while (it != m_rlcBufferReq.end()) { @@ -356,13 +353,12 @@ RrFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -386,13 +382,12 @@ RrFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -420,8 +415,7 @@ RrFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -431,8 +425,7 @@ RrFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_INFO(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -468,9 +461,9 @@ RrFfMacScheduler::DoSchedDlTriggerReq( std::set rntiAllocated; rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -479,8 +472,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -544,15 +536,13 @@ RrFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -594,7 +584,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -622,8 +612,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -644,16 +633,14 @@ RrFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Max number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -740,8 +727,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -819,8 +805,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -833,15 +818,14 @@ RrFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ ACK UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -873,11 +857,10 @@ RrFfMacScheduler::DoSchedDlTriggerReq( int nflows = 0; int nTbs = 0; std::map lcActivesPerRnti; // tracks how many active LCs per RNTI there are - std::map::iterator itLcRnti; for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { // remove old entries of this UE-LC - std::set::iterator itRnti = rntiAllocated.find((*it).m_rnti); + auto itRnti = rntiAllocated.find((*it).m_rnti); if ((((*it).m_rlcTransmissionQueueSize > 0) || ((*it).m_rlcRetransmissionQueueSize > 0) || ((*it).m_rlcStatusPduSize > 0)) && (itRnti == rntiAllocated.end()) // UE must not be allocated for HARQ retx @@ -889,7 +872,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( << (*it).m_rlcStatusPduSize << " retx " << (*it).m_rlcRetransmissionQueueSize << " tx " << (*it).m_rlcTransmissionQueueSize); - std::map::iterator itCqi = m_p10CqiRxed.find((*it).m_rnti); + auto itCqi = m_p10CqiRxed.find((*it).m_rnti); uint8_t cqi = 0; if (itCqi != m_p10CqiRxed.end()) { @@ -903,7 +886,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( { // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213) nflows++; - itLcRnti = lcActivesPerRnti.find((*it).m_rnti); + auto itLcRnti = lcActivesPerRnti.find((*it).m_rnti); if (itLcRnti != lcActivesPerRnti.end()) { (*itLcRnti).second++; @@ -966,11 +949,10 @@ RrFfMacScheduler::DoSchedDlTriggerReq( it = m_rlcBufferReq.begin(); m_nextRntiDl = (*it).m_rnti; } - std::map::iterator itTxMode; do { - itLcRnti = lcActivesPerRnti.find((*it).m_rnti); - std::set::iterator itRnti = rntiAllocated.find((*it).m_rnti); + auto itLcRnti = lcActivesPerRnti.find((*it).m_rnti); + auto itRnti = rntiAllocated.find((*it).m_rnti); if ((itLcRnti == lcActivesPerRnti.end()) || (itRnti != rntiAllocated.end())) { // skip this RNTI (no active queue or yet allocated for HARQ) @@ -990,7 +972,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( } continue; } - itTxMode = m_uesTxMode.find((*it).m_rnti); + auto itTxMode = m_uesTxMode.find((*it).m_rnti); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).m_rnti); @@ -1006,7 +988,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( newDci.m_harqProcess = UpdateHarqProcessId((*it).m_rnti); newDci.m_resAlloc = 0; newDci.m_rbBitmap = 0; - std::map::iterator itCqi = m_p10CqiRxed.find(newEl.m_rnti); + auto itCqi = m_p10CqiRxed.find(newEl.m_rnti); for (uint8_t i = 0; i < nLayer; i++) { if (itCqi == m_p10CqiRxed.end()) @@ -1042,8 +1024,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*it).m_rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*it).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1097,8 +1078,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1106,8 +1086,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1144,16 +1123,14 @@ RrFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; for (unsigned int i = 0; i < params.m_cqiList.size(); i++) { if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::P10) { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1168,8 +1145,7 @@ RrFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1225,8 +1201,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1234,16 +1209,14 @@ RrFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in UL-HARQ buffer for UE (might change eNB) " << rnti); } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1296,7 +1269,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ NS_LOG_INFO(this << " UE " << (*it).first << " queue " << (*it).second); if (((*it).second > 0) && (itRnti == rntiAllocated.end())) @@ -1348,7 +1321,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( NS_LOG_INFO(this << " NFlows " << nflows << " RB per Flow " << rbPerFlow); do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1431,7 +1404,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( std::pair>(params.m_sfnSf, rbgAllocationMap)); return; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1495,15 +1468,13 @@ RrFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1511,8 +1482,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1566,8 +1536,6 @@ RrFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1587,7 +1555,7 @@ RrFfMacScheduler::DoSchedUlMacCtrlInfoReq( } uint16_t rnti = params.m_macCeList.at(i).m_rnti; - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1634,9 +1602,7 @@ RrFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { NS_LOG_INFO(this << " Does not find info on allocation, size : " @@ -1647,7 +1613,7 @@ RrFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1675,8 +1641,7 @@ RrFfMacScheduler::DoSchedUlCqiInfoReq( // update the value (*itCqi).second.at(i) = sinr; // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1697,8 +1662,7 @@ RrFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1725,8 +1689,7 @@ RrFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1747,7 +1710,7 @@ RrFfMacScheduler::RefreshDlCqiMaps() { NS_LOG_FUNCTION(this << m_p10CqiTimers.size()); // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -1755,12 +1718,12 @@ RrFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI exired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -1776,7 +1739,7 @@ void RrFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -1784,13 +1747,13 @@ RrFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -1806,8 +1769,7 @@ void RrFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { NS_LOG_FUNCTION(this); - std::list::iterator it; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).m_rnti == rnti) && ((*it).m_logicalChannelIdentity == lcid)) { @@ -1861,7 +1823,7 @@ void RrFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " Update RLC BSR UE " << rnti << " size " << size << " BSR " diff --git a/src/lte/model/simple-ue-component-carrier-manager.cc b/src/lte/model/simple-ue-component-carrier-manager.cc index 724f371f5..52f3e77b4 100644 --- a/src/lte/model/simple-ue-component-carrier-manager.cc +++ b/src/lte/model/simple-ue-component-carrier-manager.cc @@ -182,8 +182,7 @@ void SimpleUeComponentCarrierManager::DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params) { NS_LOG_FUNCTION(this); - std::map::iterator it = - m_macSapProvidersMap.find(params.componentCarrierId); + auto it = m_macSapProvidersMap.find(params.componentCarrierId); NS_ABORT_MSG_IF(it == m_macSapProvidersMap.end(), "could not find Sap for ComponentCarrier " << (uint16_t)params.componentCarrierId); @@ -197,18 +196,17 @@ SimpleUeComponentCarrierManager::DoReportBufferStatus( { NS_LOG_FUNCTION(this); NS_LOG_DEBUG("BSR from RLC for LCID = " << (uint16_t)params.lcid); - std::map::iterator it = m_macSapProvidersMap.find(0); + auto it = m_macSapProvidersMap.find(0); NS_ABORT_MSG_IF(it == m_macSapProvidersMap.end(), "could not find Sap for ComponentCarrier"); NS_LOG_DEBUG("Size of component carrier LC map " << m_componentCarrierLcMap.size()); - for (std::map>::iterator ccLcMapIt = - m_componentCarrierLcMap.begin(); + for (auto ccLcMapIt = m_componentCarrierLcMap.begin(); ccLcMapIt != m_componentCarrierLcMap.end(); ccLcMapIt++) { NS_LOG_DEBUG("BSR from RLC for CC id = " << (uint16_t)ccLcMapIt->first); - std::map::iterator it = ccLcMapIt->second.find(params.lcid); + auto it = ccLcMapIt->second.find(params.lcid); if (it != ccLcMapIt->second.end()) { it->second->ReportBufferStatus(params); @@ -227,7 +225,7 @@ SimpleUeComponentCarrierManager::DoNotifyTxOpportunity( LteMacSapUser::TxOpportunityParameters txOpParams) { NS_LOG_FUNCTION(this); - std::map::iterator lcidIt = m_lcAttached.find(txOpParams.lcid); + auto lcidIt = m_lcAttached.find(txOpParams.lcid); NS_ABORT_MSG_IF(lcidIt == m_lcAttached.end(), "could not find LCID" << (uint16_t)txOpParams.lcid); NS_LOG_DEBUG(this << " lcid = " << (uint32_t)txOpParams.lcid @@ -245,7 +243,7 @@ void SimpleUeComponentCarrierManager::DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) { NS_LOG_FUNCTION(this); - std::map::iterator lcidIt = m_lcAttached.find(rxPduParams.lcid); + auto lcidIt = m_lcAttached.find(rxPduParams.lcid); NS_ABORT_MSG_IF(lcidIt == m_lcAttached.end(), "could not find LCID" << (uint16_t)rxPduParams.lcid); if (lcidIt != m_lcAttached.end()) @@ -265,11 +263,10 @@ SimpleUeComponentCarrierManager::DoRemoveLc(uint8_t lcid) NS_ABORT_MSG_IF(m_lcAttached.find(lcid) == m_lcAttached.end(), "could not find LCID " << lcid); m_lcAttached.erase(lcid); // send back all the configuration to the componentCarrier where we want to remove the Lc - std::map>::iterator it = - m_componentCarrierLcMap.begin(); + auto it = m_componentCarrierLcMap.begin(); while (it != m_componentCarrierLcMap.end()) { - std::map::iterator lcToRemove = it->second.find(lcid); + auto lcToRemove = it->second.find(lcid); if (lcToRemove != it->second.end()) { res.insert(res.end(), it->first); @@ -287,7 +284,7 @@ SimpleUeComponentCarrierManager::DoReset() { NS_LOG_FUNCTION(this); // same semantics as LteUeMac::DoRest - std::map::iterator it = m_lcAttached.begin(); + auto it = m_lcAttached.begin(); while (it != m_lcAttached.end()) { // don't delete CCCH @@ -310,11 +307,10 @@ SimpleUeComponentCarrierManager::DoAddLc(uint8_t lcId, { NS_LOG_FUNCTION(this); std::vector res; - std::map::iterator it = m_lcAttached.find(lcId); + auto it = m_lcAttached.find(lcId); NS_ABORT_MSG_IF(it != m_lcAttached.end(), "Warning, LCID " << lcId << " already exist"); m_lcAttached.insert(std::pair(lcId, msu)); LteUeCcmRrcSapProvider::LcsConfig elem; - std::map>::iterator ccLcMapIt; for (uint8_t ncc = 0; ncc < m_noOfComponentCarriers; ncc++) { elem.componentCarrierId = ncc; @@ -322,7 +318,7 @@ SimpleUeComponentCarrierManager::DoAddLc(uint8_t lcId, elem.msu = m_ccmMacSapUser; res.insert(res.end(), elem); - ccLcMapIt = m_componentCarrierLcMap.find(ncc); + auto ccLcMapIt = m_componentCarrierLcMap.find(ncc); if (ccLcMapIt != m_componentCarrierLcMap.end()) { ccLcMapIt->second.insert( @@ -331,9 +327,8 @@ SimpleUeComponentCarrierManager::DoAddLc(uint8_t lcId, else { std::map empty; - std::pair>::iterator, bool> - ret = m_componentCarrierLcMap.insert( - std::pair>(ncc, empty)); + auto ret = m_componentCarrierLcMap.insert( + std::pair>(ncc, empty)); NS_ABORT_MSG_IF(!ret.second, "element already present, ComponentCarrierId already exist"); ccLcMapIt = m_componentCarrierLcMap.find(ncc); @@ -352,7 +347,7 @@ SimpleUeComponentCarrierManager::DoConfigureSignalBearer( LteMacSapUser* msu) { NS_LOG_FUNCTION(this); - std::map::iterator it = m_lcAttached.find(lcid); + auto it = m_lcAttached.find(lcid); // if the following assert is hit, e.g., in handover scenarios, it means // the DoRest function is not called by UE RRC NS_ABORT_MSG_IF(it != m_lcAttached.end(), @@ -360,10 +355,9 @@ SimpleUeComponentCarrierManager::DoConfigureSignalBearer( m_lcAttached.insert(std::pair(lcid, msu)); - std::map>::iterator ccLcMapIt; for (uint8_t ncc = 0; ncc < m_noOfComponentCarriers; ncc++) { - ccLcMapIt = m_componentCarrierLcMap.find(ncc); + auto ccLcMapIt = m_componentCarrierLcMap.find(ncc); if (ccLcMapIt != m_componentCarrierLcMap.end()) { ccLcMapIt->second.insert( @@ -372,9 +366,8 @@ SimpleUeComponentCarrierManager::DoConfigureSignalBearer( else { std::map empty; - std::pair>::iterator, bool> - ret = m_componentCarrierLcMap.insert( - std::pair>(ncc, empty)); + auto ret = m_componentCarrierLcMap.insert( + std::pair>(ncc, empty)); NS_ABORT_MSG_IF(!ret.second, "element already present, ComponentCarrierId already existed"); ccLcMapIt = m_componentCarrierLcMap.find(ncc); diff --git a/src/lte/model/tdbet-ff-mac-scheduler.cc b/src/lte/model/tdbet-ff-mac-scheduler.cc index f7a61bf6a..4de5bdf72 100644 --- a/src/lte/model/tdbet-ff-mac-scheduler.cc +++ b/src/lte/model/tdbet-ff-mac-scheduler.cc @@ -159,7 +159,7 @@ TdBetFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -205,10 +205,9 @@ TdBetFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::map::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -235,15 +234,13 @@ TdBetFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -273,14 +270,12 @@ TdBetFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -302,11 +297,9 @@ TdBetFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -353,9 +346,8 @@ TdBetFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int TdBetFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -376,13 +368,12 @@ TdBetFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -406,13 +397,12 @@ TdBetFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -441,8 +431,7 @@ TdBetFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -452,8 +441,7 @@ TdBetFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -493,9 +481,9 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -504,8 +492,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -569,15 +556,13 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -619,7 +604,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -647,8 +632,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -669,16 +653,14 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -765,8 +747,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -843,8 +824,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -857,15 +837,14 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -891,16 +870,13 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( return; } - std::map::iterator it; - std::map::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double metricMax = 0.0; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { // check first what are channel conditions for this UE, if CQI!=0 - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_p10CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -925,7 +901,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it).first))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -967,15 +943,14 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( } // reset TTI stats of users - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.lastTtiBytesTrasmitted = 0; } // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -994,10 +969,8 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_p10CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1033,9 +1006,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1057,8 +1028,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1087,8 +1057,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1096,8 +1065,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1109,8 +1077,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( ret.m_buildDataList.push_back(newEl); // update UE stats - std::map::iterator it; - it = m_flowStatsDl.find((*itMap).first); + auto it = m_flowStatsDl.find((*itMap).first); if (it != m_flowStatsDl.end()) { (*it).second.lastTtiBytesTrasmitted = bytesTxed; @@ -1127,7 +1094,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( // update UEs stats NS_LOG_INFO(this << " Update UEs statistics"); - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -1164,9 +1131,8 @@ TdBetFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1181,17 +1147,15 @@ TdBetFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1204,8 +1168,7 @@ TdBetFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1219,7 +1182,7 @@ TdBetFfMacScheduler::DoSchedDlCqiInfoReq( double TdBetFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1286,8 +1249,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1295,16 +1257,14 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1362,7 +1322,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1392,7 +1352,6 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( } int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -1414,7 +1373,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1499,7 +1458,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( return; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1570,15 +1529,13 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1586,8 +1543,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1603,7 +1559,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( << (uint16_t)harqId); // update TTI UE stats - itStats = m_flowStatsUl.find((*it).first); + auto itStats = m_flowStatsUl.find((*it).first); if (itStats != m_flowStatsUl.end()) { (*itStats).second.lastTtiBytesTrasmitted = uldci.m_tbSize; @@ -1629,7 +1585,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( // Update global UE stats // update UEs stats - for (itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) + for (auto itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -1666,8 +1622,6 @@ TdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1688,7 +1642,7 @@ TdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1734,11 +1688,9 @@ TdBetFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1747,7 +1699,7 @@ TdBetFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1777,8 +1729,7 @@ TdBetFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1799,8 +1750,7 @@ TdBetFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1827,8 +1777,7 @@ TdBetFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1848,7 +1797,7 @@ void TdBetFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -1856,12 +1805,12 @@ TdBetFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -1873,7 +1822,7 @@ TdBetFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -1881,12 +1830,12 @@ TdBetFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -1902,7 +1851,7 @@ void TdBetFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -1910,13 +1859,13 @@ TdBetFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -1931,9 +1880,8 @@ TdBetFfMacScheduler::RefreshUlCqiMaps() void TdBetFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -1988,7 +1936,7 @@ void TdBetFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/tdmt-ff-mac-scheduler.cc b/src/lte/model/tdmt-ff-mac-scheduler.cc index 42fc8865f..33c8282b2 100644 --- a/src/lte/model/tdmt-ff-mac-scheduler.cc +++ b/src/lte/model/tdmt-ff-mac-scheduler.cc @@ -158,7 +158,7 @@ TdMtFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -204,10 +204,9 @@ TdMtFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::set::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -224,15 +223,13 @@ TdMtFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -262,14 +259,12 @@ TdMtFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -291,11 +286,9 @@ TdMtFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -342,9 +335,8 @@ TdMtFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int TdMtFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -365,13 +357,12 @@ TdMtFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -395,13 +386,12 @@ TdMtFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -430,8 +420,7 @@ TdMtFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -441,8 +430,7 @@ TdMtFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -482,9 +470,9 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -493,8 +481,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -558,15 +545,13 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -608,7 +593,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -636,8 +621,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -658,16 +642,14 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -754,8 +736,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -832,8 +813,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -846,15 +826,14 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -880,12 +859,11 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( return; } - std::set::iterator it; - std::set::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double metricMax = 0.0; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it)); + auto itRnti = rntiAllocated.find((*it)); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it)))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -901,14 +879,13 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it)); + auto itTxMode = m_uesTxMode.find((*it)); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it)); } auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second); - std::map::iterator itCqi = m_p10CqiRxed.find((*it)); + auto itCqi = m_p10CqiRxed.find((*it)); uint8_t wbCqi = 0; if (itCqi != m_p10CqiRxed.end()) { @@ -978,7 +955,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -997,10 +974,8 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_p10CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1033,9 +1008,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1057,8 +1030,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1087,8 +1059,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1096,8 +1067,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1137,9 +1107,8 @@ TdMtFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1154,17 +1123,15 @@ TdMtFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1177,8 +1144,7 @@ TdMtFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1192,7 +1158,7 @@ TdMtFfMacScheduler::DoSchedDlCqiInfoReq( double TdMtFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1259,8 +1225,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1268,16 +1233,14 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1335,7 +1298,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1386,7 +1349,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1471,7 +1434,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( return; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1542,15 +1505,13 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1558,8 +1519,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1613,8 +1573,6 @@ TdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1635,7 +1593,7 @@ TdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1681,11 +1639,9 @@ TdMtFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1694,7 +1650,7 @@ TdMtFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1724,8 +1680,7 @@ TdMtFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1746,8 +1701,7 @@ TdMtFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1774,8 +1728,7 @@ TdMtFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1795,7 +1748,7 @@ void TdMtFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -1803,12 +1756,12 @@ TdMtFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -1820,7 +1773,7 @@ TdMtFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -1828,12 +1781,12 @@ TdMtFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -1849,7 +1802,7 @@ void TdMtFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -1857,13 +1810,13 @@ TdMtFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -1878,9 +1831,8 @@ TdMtFfMacScheduler::RefreshUlCqiMaps() void TdMtFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -1935,7 +1887,7 @@ void TdMtFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/tdtbfq-ff-mac-scheduler.cc b/src/lte/model/tdtbfq-ff-mac-scheduler.cc index 9d2300390..d746ac00b 100644 --- a/src/lte/model/tdtbfq-ff-mac-scheduler.cc +++ b/src/lte/model/tdtbfq-ff-mac-scheduler.cc @@ -184,7 +184,7 @@ TdTbfqFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -230,10 +230,9 @@ TdTbfqFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::map::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -287,15 +286,13 @@ TdTbfqFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -325,14 +322,12 @@ TdTbfqFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -354,11 +349,9 @@ TdTbfqFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -405,9 +398,8 @@ TdTbfqFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int TdTbfqFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -428,13 +420,12 @@ TdTbfqFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -458,13 +449,12 @@ TdTbfqFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -493,8 +483,7 @@ TdTbfqFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -504,8 +493,7 @@ TdTbfqFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -545,7 +533,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); - for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) + for (auto it = rbgMap.begin(); it != rbgMap.end(); it++) { if (*it) { @@ -555,9 +543,9 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -573,7 +561,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( uint16_t tmpFfrRbStartOffset = 0; uint16_t index = 0; - for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) + for (auto it = ulRbMap.begin(); it != ulRbMap.end(); it++) { if (*it) { @@ -604,8 +592,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -669,15 +656,13 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -719,7 +704,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -747,8 +732,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -769,16 +753,14 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -865,8 +847,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -943,8 +924,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -957,15 +937,14 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -992,8 +971,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // update token pool, counter and bank size - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { if ((*itStats).second.tokenGenerationRate / 1000 + (*itStats).second.tokenPoolSize > (*itStats).second.maxTokenPoolSize) @@ -1012,13 +990,12 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // select UE with largest metric - std::map::iterator it; - std::map::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double metricMax = 0.0; bool firstRnti = true; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it).first))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -1034,10 +1011,8 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // check first the channel conditions for this UE, if CQI!=0 - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_a30CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1124,7 +1099,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -1143,10 +1118,8 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_a30CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1219,9 +1192,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1243,8 +1214,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1273,8 +1243,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1282,8 +1251,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1344,9 +1312,8 @@ TdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1361,17 +1328,15 @@ TdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1384,8 +1349,7 @@ TdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1399,7 +1363,7 @@ TdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( double TdTbfqFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1452,7 +1416,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( rbMap = m_ffrSapProvider->GetAvailableUlRbg(); - for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) + for (auto it = rbMap.begin(); it != rbMap.end(); it++) { if (*it) { @@ -1482,8 +1446,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1491,16 +1454,14 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1559,7 +1520,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1592,7 +1553,6 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( } int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -1614,7 +1574,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1707,7 +1667,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( break; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1778,15 +1738,13 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1794,8 +1752,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1849,8 +1806,6 @@ TdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1871,7 +1826,7 @@ TdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1917,11 +1872,9 @@ TdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1930,7 +1883,7 @@ TdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1960,8 +1913,7 @@ TdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1982,8 +1934,7 @@ TdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2010,8 +1961,7 @@ TdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2031,7 +1981,7 @@ void TdTbfqFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -2039,12 +1989,12 @@ TdTbfqFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -2056,7 +2006,7 @@ TdTbfqFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -2064,12 +2014,12 @@ TdTbfqFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -2085,7 +2035,7 @@ void TdTbfqFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -2093,13 +2043,13 @@ TdTbfqFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -2114,9 +2064,8 @@ TdTbfqFfMacScheduler::RefreshUlCqiMaps() void TdTbfqFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2171,7 +2120,7 @@ void TdTbfqFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/tta-ff-mac-scheduler.cc b/src/lte/model/tta-ff-mac-scheduler.cc index 0b6b58d8e..3b54a5ab4 100644 --- a/src/lte/model/tta-ff-mac-scheduler.cc +++ b/src/lte/model/tta-ff-mac-scheduler.cc @@ -158,7 +158,7 @@ TtaFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -204,10 +204,9 @@ TtaFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::set::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -224,15 +223,13 @@ TtaFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -262,14 +259,12 @@ TtaFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -291,11 +286,9 @@ TtaFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -342,9 +335,8 @@ TtaFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int TtaFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -365,13 +357,12 @@ TtaFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -395,13 +386,12 @@ TtaFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -430,8 +420,7 @@ TtaFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -441,8 +430,7 @@ TtaFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -482,9 +470,9 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -493,8 +481,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -558,15 +545,13 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -608,7 +593,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -636,8 +621,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -658,16 +642,14 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -754,8 +736,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -832,8 +813,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -846,15 +826,14 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -885,12 +864,11 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( NS_LOG_INFO(this << " ALLOCATION for RBG " << i << " of " << rbgNum); if (!rbgMap.at(i)) { - std::set::iterator it; - std::set::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double rcqiMax = 0.0; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it)); + auto itRnti = rntiAllocated.find((*it)); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it)))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -905,13 +883,10 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::map::iterator itSbCqi; - itSbCqi = m_a30CqiRxed.find((*it)); - std::map::iterator itWbCqi; - itWbCqi = m_p10CqiRxed.find((*it)); + auto itSbCqi = m_a30CqiRxed.find((*it)); + auto itWbCqi = m_p10CqiRxed.find((*it)); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it)); + auto itTxMode = m_uesTxMode.find((*it)); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it)); @@ -921,10 +896,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( std::vector sbCqi; if (itSbCqi == m_a30CqiRxed.end()) { - for (uint8_t k = 0; k < nLayer; k++) - { - sbCqi.push_back(1); // start with lowest value - } + sbCqi = std::vector(nLayer, 1); // start with lowest value } else { @@ -995,8 +967,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( else { rbgMap.at(i) = true; - std::map>::iterator itMap; - itMap = allocationMap.find((*itMax)); + auto itMap = allocationMap.find((*itMax)); if (itMap == allocationMap.end()) { // insert new element @@ -1016,7 +987,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -1035,10 +1006,8 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_a30CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1121,9 +1090,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1145,8 +1112,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1175,8 +1141,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1184,8 +1149,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1225,9 +1189,8 @@ TtaFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1242,17 +1205,15 @@ TtaFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1265,8 +1226,7 @@ TtaFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1280,7 +1240,7 @@ TtaFfMacScheduler::DoSchedDlCqiInfoReq( double TtaFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1347,8 +1307,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1356,16 +1315,14 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1423,7 +1380,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1474,7 +1431,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1559,7 +1516,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( return; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1630,15 +1587,13 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1646,8 +1601,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1701,8 +1655,6 @@ TtaFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1723,7 +1675,7 @@ TtaFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1769,11 +1721,9 @@ TtaFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1782,7 +1732,7 @@ TtaFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1812,8 +1762,7 @@ TtaFfMacScheduler::DoSchedUlCqiInfoReq( // NS_LOG_DEBUG (this << " RNTI " << (*itMap).second.at (i) << " RB " << i << " SINR // " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1834,8 +1783,7 @@ TtaFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1862,8 +1810,7 @@ TtaFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1883,7 +1830,7 @@ void TtaFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -1891,12 +1838,12 @@ TtaFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -1908,7 +1855,7 @@ TtaFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -1916,12 +1863,12 @@ TtaFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -1937,7 +1884,7 @@ void TtaFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -1945,13 +1892,13 @@ TtaFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -1966,9 +1913,8 @@ TtaFfMacScheduler::RefreshUlCqiMaps() void TtaFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2023,7 +1969,7 @@ void TtaFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/test/epc-test-gtpu.cc b/src/lte/test/epc-test-gtpu.cc index b0dcb6333..8649892ce 100644 --- a/src/lte/test/epc-test-gtpu.cc +++ b/src/lte/test/epc-test-gtpu.cc @@ -57,7 +57,7 @@ EpsGtpuHeaderTestCase::~EpsGtpuHeaderTestCase() void EpsGtpuHeaderTestCase::DoRun() { - LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); + auto logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); LogComponentEnable("EpcGtpuTest", logLevel); GtpuHeader h1; diff --git a/src/lte/test/epc-test-s1u-downlink.cc b/src/lte/test/epc-test-s1u-downlink.cc index a00e830ec..f18163f0e 100644 --- a/src/lte/test/epc-test-s1u-downlink.cc +++ b/src/lte/test/epc-test-s1u-downlink.cc @@ -154,9 +154,7 @@ EpcS1uDlTestCase::DoRun() uint16_t cellIdCounter = 0; uint64_t imsiCounter = 0; - for (std::vector::iterator enbit = m_enbDlTestData.begin(); - enbit < m_enbDlTestData.end(); - ++enbit) + for (auto enbit = m_enbDlTestData.begin(); enbit < m_enbDlTestData.end(); ++enbit) { Ptr enb = CreateObject(); enbs.Add(enb); @@ -245,12 +243,9 @@ EpcS1uDlTestCase::DoRun() Simulator::Run(); - for (std::vector::iterator enbit = m_enbDlTestData.begin(); - enbit < m_enbDlTestData.end(); - ++enbit) + for (auto enbit = m_enbDlTestData.begin(); enbit < m_enbDlTestData.end(); ++enbit) { - for (std::vector::iterator ueit = enbit->ues.begin(); ueit < enbit->ues.end(); - ++ueit) + for (auto ueit = enbit->ues.begin(); ueit < enbit->ues.end(); ++ueit) { NS_TEST_ASSERT_MSG_EQ(ueit->serverApp->GetTotalRx(), (ueit->numPkts) * (ueit->pktSize), diff --git a/src/lte/test/epc-test-s1u-uplink.cc b/src/lte/test/epc-test-s1u-uplink.cc index 1e80b1c48..bdf0acd6a 100644 --- a/src/lte/test/epc-test-s1u-uplink.cc +++ b/src/lte/test/epc-test-s1u-uplink.cc @@ -366,9 +366,7 @@ EpcS1uUlTestCase::DoRun() uint16_t cellIdCounter = 0; uint64_t imsiCounter = 0; - for (std::vector::iterator enbit = m_enbUlTestData.begin(); - enbit < m_enbUlTestData.end(); - ++enbit) + for (auto enbit = m_enbUlTestData.begin(); enbit < m_enbUlTestData.end(); ++enbit) { Ptr enb = CreateObject(); enbs.Add(enb); @@ -486,12 +484,9 @@ EpcS1uUlTestCase::DoRun() Simulator::Run(); - for (std::vector::iterator enbit = m_enbUlTestData.begin(); - enbit < m_enbUlTestData.end(); - ++enbit) + for (auto enbit = m_enbUlTestData.begin(); enbit < m_enbUlTestData.end(); ++enbit) { - for (std::vector::iterator ueit = enbit->ues.begin(); ueit < enbit->ues.end(); - ++ueit) + for (auto ueit = enbit->ues.begin(); ueit < enbit->ues.end(); ++ueit) { NS_TEST_ASSERT_MSG_EQ(ueit->serverApp->GetTotalRx(), (ueit->numPkts) * (ueit->pktSize), diff --git a/src/lte/test/lte-ffr-simple.cc b/src/lte/test/lte-ffr-simple.cc index 2ebf0e2c6..6a28394e2 100644 --- a/src/lte/test/lte-ffr-simple.cc +++ b/src/lte/test/lte-ffr-simple.cc @@ -279,9 +279,7 @@ LteFfrSimple::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measResults) { NS_LOG_FUNCTION(this << rnti << (uint16_t)measResults.measId); - std::map::iterator it; - - it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { @@ -302,8 +300,7 @@ LteFfrSimple::UpdatePdschConfigDedicated() { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (it = m_ues.begin(); it != m_ues.end(); it++) + for (auto it = m_ues.begin(); it != m_ues.end(); it++) { if (it->second.pa != m_pdschConfigDedicated.pa) { diff --git a/src/lte/test/lte-simple-helper.cc b/src/lte/test/lte-simple-helper.cc index fa98fe77c..d64c8e114 100644 --- a/src/lte/test/lte-simple-helper.cc +++ b/src/lte/test/lte-simple-helper.cc @@ -91,7 +91,7 @@ LteSimpleHelper::InstallEnbDevice(NodeContainer c) NS_LOG_FUNCTION(this); Initialize(); // will run DoInitialize () if necessary NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr device = InstallSingleEnbDevice(node); @@ -105,7 +105,7 @@ LteSimpleHelper::InstallUeDevice(NodeContainer c) { NS_LOG_FUNCTION(this); NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr device = InstallSingleUeDevice(node); @@ -209,8 +209,7 @@ LteSimpleHelper::InstallSingleUeDevice(Ptr n) void LteSimpleHelper::EnableLogComponents() { - LogLevel level = - (LogLevel)(LOG_LEVEL_ALL | LOG_PREFIX_TIME | LOG_PREFIX_NODE | LOG_PREFIX_FUNC); + auto level = (LogLevel)(LOG_LEVEL_ALL | LOG_PREFIX_TIME | LOG_PREFIX_NODE | LOG_PREFIX_FUNC); LogComponentEnable("Config", level); LogComponentEnable("LteSimpleHelper", level); diff --git a/src/lte/test/lte-test-carrier-aggregation.cc b/src/lte/test/lte-test-carrier-aggregation.cc index e80b3eeb8..4268afaa5 100644 --- a/src/lte/test/lte-test-carrier-aggregation.cc +++ b/src/lte/test/lte-test-carrier-aggregation.cc @@ -425,8 +425,7 @@ CarrierAggregationTestCase::DoRun() bool testDownlinkShare = true; - for (std::map::iterator itDownlink = m_ccDownlinkTraffic.begin(); - itDownlink != m_ccDownlinkTraffic.end(); + for (auto itDownlink = m_ccDownlinkTraffic.begin(); itDownlink != m_ccDownlinkTraffic.end(); itDownlink++) { if (itDownlink == m_ccDownlinkTraffic.begin()) @@ -445,9 +444,7 @@ CarrierAggregationTestCase::DoRun() bool testUplinkShare = true; - for (std::map::iterator itUplink = m_ccUplinkTraffic.begin(); - itUplink != m_ccUplinkTraffic.end(); - itUplink++) + for (auto itUplink = m_ccUplinkTraffic.begin(); itUplink != m_ccUplinkTraffic.end(); itUplink++) { if (itUplink == m_ccUplinkTraffic.begin()) { diff --git a/src/lte/test/lte-test-cell-selection.cc b/src/lte/test/lte-test-cell-selection.cc index e993e33ab..cb2a03aef 100644 --- a/src/lte/test/lte-test-cell-selection.cc +++ b/src/lte/test/lte-test-cell-selection.cc @@ -185,7 +185,7 @@ LteCellSelectionTestCase::DoRun() NodeContainer enbNodes; enbNodes.Create(4); NodeContainer ueNodes; - uint16_t nUe = static_cast(m_ueSetupList.size()); + auto nUe = static_cast(m_ueSetupList.size()); ueNodes.Create(nUe); // Assign nodes to position diff --git a/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc b/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc index 00c31222e..1485b7120 100644 --- a/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc @@ -23,15 +23,16 @@ #include "lte-test-cqa-ff-mac-scheduler.h" -#include "ns3/applications-module.h" #include "ns3/double.h" #include "ns3/internet-module.h" #include "ns3/ipv4-global-routing-helper.h" #include "ns3/network-module.h" +#include "ns3/packet-sink-helper.h" #include "ns3/point-to-point-epc-helper.h" #include "ns3/point-to-point-helper.h" #include "ns3/radio-bearer-stats-calculator.h" #include "ns3/string.h" +#include "ns3/udp-client-server-helper.h" #include #include #include @@ -541,7 +542,7 @@ LenaCqaFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-deactivate-bearer.cc b/src/lte/test/lte-test-deactivate-bearer.cc index bee2d6bd5..518354661 100644 --- a/src/lte/test/lte-test-deactivate-bearer.cc +++ b/src/lte/test/lte-test-deactivate-bearer.cc @@ -19,15 +19,16 @@ #include "lte-test-deactivate-bearer.h" -#include "ns3/applications-module.h" #include "ns3/double.h" #include "ns3/internet-module.h" #include "ns3/ipv4-global-routing-helper.h" #include "ns3/network-module.h" +#include "ns3/packet-sink-helper.h" #include "ns3/point-to-point-epc-helper.h" #include "ns3/point-to-point-helper.h" #include "ns3/radio-bearer-stats-calculator.h" #include "ns3/string.h" +#include "ns3/udp-client-server-helper.h" #include #include #include @@ -108,7 +109,7 @@ LenaDeactivateBearerTestCase::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-entities.cc b/src/lte/test/lte-test-entities.cc index f1863b126..86460b436 100644 --- a/src/lte/test/lte-test-entities.cc +++ b/src/lte/test/lte-test-entities.cc @@ -162,7 +162,7 @@ LteTestRrc::DoReceivePdcpSdu(LtePdcpSapUser::ReceivePdcpSduParameters params) // NS_LOG_LOGIC ("PDU received = " << (*p)); uint32_t dataLen = p->GetSize(); - uint8_t* buf = new uint8_t[dataLen]; + auto buf = new uint8_t[dataLen]; // Stats m_rxPdus++; @@ -312,7 +312,7 @@ LteTestPdcp::DoReceivePdcpPdu(Ptr p) NS_LOG_LOGIC("Data = " << (*p)); uint32_t dataLen = p->GetSize(); - uint8_t* buf = new uint8_t[dataLen]; + auto buf = new uint8_t[dataLen]; p->CopyData(buf, dataLen); m_receivedData = std::string((char*)buf, dataLen); @@ -606,7 +606,7 @@ LteTestMac::DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params) // Copy data to a string uint32_t dataLen = params.pdu->GetSize(); - uint8_t* buf = new uint8_t[dataLen]; + auto buf = new uint8_t[dataLen]; params.pdu->CopyData(buf, dataLen); m_receivedData = std::string((char*)buf, dataLen); @@ -623,8 +623,7 @@ LteTestMac::DoReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters if (m_txOpportunityMode == AUTOMATIC_MODE) { // cancel all previously scheduled TxOpps - for (std::list::iterator it = m_nextTxOppList.begin(); it != m_nextTxOppList.end(); - ++it) + for (auto it = m_nextTxOppList.begin(); it != m_nextTxOppList.end(); ++it) { it->Cancel(); } diff --git a/src/lte/test/lte-test-fdbet-ff-mac-scheduler.cc b/src/lte/test/lte-test-fdbet-ff-mac-scheduler.cc index 42b273052..c98b2da52 100644 --- a/src/lte/test/lte-test-fdbet-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-fdbet-ff-mac-scheduler.cc @@ -383,7 +383,7 @@ LenaFdBetFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc b/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc index 94ed69e5f..540d9292e 100644 --- a/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc @@ -21,15 +21,16 @@ #include "lte-test-fdtbfq-ff-mac-scheduler.h" -#include "ns3/applications-module.h" #include "ns3/double.h" #include "ns3/internet-module.h" #include "ns3/ipv4-global-routing-helper.h" #include "ns3/network-module.h" +#include "ns3/packet-sink-helper.h" #include "ns3/point-to-point-epc-helper.h" #include "ns3/point-to-point-helper.h" #include "ns3/radio-bearer-stats-calculator.h" #include "ns3/string.h" +#include "ns3/udp-client-server-helper.h" #include #include #include @@ -547,7 +548,7 @@ LenaFdTbfqFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-frequency-reuse.cc b/src/lte/test/lte-test-frequency-reuse.cc index 00424214e..ed5456869 100644 --- a/src/lte/test/lte-test-frequency-reuse.cc +++ b/src/lte/test/lte-test-frequency-reuse.cc @@ -23,12 +23,13 @@ #include "lte-ffr-simple.h" #include "lte-simple-spectrum-phy.h" -#include "ns3/applications-module.h" #include "ns3/internet-module.h" #include "ns3/lte-helper.h" #include "ns3/mobility-helper.h" +#include "ns3/packet-sink-helper.h" #include "ns3/point-to-point-epc-helper.h" #include "ns3/point-to-point-module.h" +#include "ns3/udp-client-server-helper.h" #include #include #include @@ -479,9 +480,8 @@ void LteFrTestCase::DlDataRxStart(Ptr spectrumValue) { NS_LOG_DEBUG("DL DATA Power allocation :"); - Values::const_iterator it; uint32_t i = 0; - for (it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) + for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) { double power = (*it) * (m_dlBandwidth * 180000); NS_LOG_DEBUG("RB " << i << " POWER: " @@ -499,9 +499,8 @@ void LteFrTestCase::UlDataRxStart(Ptr spectrumValue) { NS_LOG_DEBUG("UL DATA Power allocation :"); - Values::const_iterator it; uint32_t i = 0; - for (it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) + for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) { double power = (*it) * (m_ulBandwidth * 180000); NS_LOG_DEBUG("RB " << i << " POWER: " @@ -821,9 +820,8 @@ LteFrAreaTestCase::DlDataRxStart(Ptr spectrumValue) } NS_LOG_DEBUG("DL DATA Power allocation :"); - Values::const_iterator it; uint32_t i = 0; - for (it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) + for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) { double power = (*it) * (m_dlBandwidth * 180000); NS_LOG_DEBUG("RB " << i << " POWER: " @@ -857,7 +855,6 @@ LteFrAreaTestCase::UlDataRxStart(Ptr spectrumValue) } NS_LOG_DEBUG("UL DATA Power allocation :"); - Values::const_iterator it; uint32_t i = 0; uint32_t numActiveRbs = 0; @@ -865,7 +862,7 @@ LteFrAreaTestCase::UlDataRxStart(Ptr spectrumValue) // of active RBs. This method is independent of the bandwidth // configuration done in a test scenario, thus, it requires // minimum change to the script. - for (it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) + for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) { // Count the RB as active if it is part of // the expected UL RBs and has Power Spectral Density (PSD) > 0 @@ -878,7 +875,7 @@ LteFrAreaTestCase::UlDataRxStart(Ptr spectrumValue) // The uplink power control and the uplink PSD // calculation only consider active resource blocks. - for (it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) + for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) { double power = (*it) * (numActiveRbs * 180000); NS_LOG_DEBUG("RB " << i << " POWER: " << power diff --git a/src/lte/test/lte-test-ipv6-routing.cc b/src/lte/test/lte-test-ipv6-routing.cc index c09559566..1f20f98d0 100644 --- a/src/lte/test/lte-test-ipv6-routing.cc +++ b/src/lte/test/lte-test-ipv6-routing.cc @@ -17,7 +17,6 @@ * Author: Manoj Kumar Rana */ -#include "ns3/applications-module.h" #include "ns3/config-store.h" #include "ns3/core-module.h" #include "ns3/epc-helper.h" @@ -29,6 +28,7 @@ #include "ns3/mobility-module.h" #include "ns3/network-module.h" #include "ns3/point-to-point-helper.h" +#include "ns3/udp-echo-helper.h" #include @@ -164,8 +164,7 @@ LteIpv6RoutingTestCase::Checker() bool b = false; bool check = true; // Extract each received reply packet of the client - for (std::list>::iterator it1 = m_clientRxPkts.begin(); it1 != m_clientRxPkts.end(); - it1++) + for (auto it1 = m_clientRxPkts.begin(); it1 != m_clientRxPkts.end(); it1++) { Ipv6Header ipv6header1; UdpHeader udpHeader1; @@ -174,9 +173,7 @@ LteIpv6RoutingTestCase::Checker() uint64_t uid = p1->GetUid(); p1->RemoveHeader(udpHeader1); // Search each packet in list of sent request packet of the client - for (std::list>::iterator it2 = m_clientTxPkts.begin(); - it2 != m_clientTxPkts.end(); - it2++) + for (auto it2 = m_clientTxPkts.begin(); it2 != m_clientTxPkts.end(); it2++) { Ptr p2 = (*it2)->Copy(); Ipv6Header ipv6header2; diff --git a/src/lte/test/lte-test-pf-ff-mac-scheduler.cc b/src/lte/test/lte-test-pf-ff-mac-scheduler.cc index 86db09f4a..a16909b5a 100644 --- a/src/lte/test/lte-test-pf-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-pf-ff-mac-scheduler.cc @@ -399,7 +399,7 @@ LenaPfFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-phy-error-model.cc b/src/lte/test/lte-test-phy-error-model.cc index 689375394..17317fa1c 100644 --- a/src/lte/test/lte-test-phy-error-model.cc +++ b/src/lte/test/lte-test-phy-error-model.cc @@ -260,7 +260,7 @@ LenaDataPhyErrorModelTestCase::DoRun() // sanity check for whether the tx packets reported by the stats are correct // we expect one packet per TTI - double expectedDlTxPackets = static_cast(statsDuration.GetMilliSeconds()); + auto expectedDlTxPackets = static_cast(statsDuration.GetMilliSeconds()); NS_TEST_ASSERT_MSG_EQ_TOL(dlTxPackets, expectedDlTxPackets, expectedDlTxPackets * 0.005, @@ -422,7 +422,7 @@ LenaDlCtrlPhyErrorModelTestCase::DoRun() // sanity check for whether the tx packets reported by the stats are correct // we expect one packet per TTI - double expectedDlTxPackets = static_cast(statsDuration.GetMilliSeconds()); + auto expectedDlTxPackets = static_cast(statsDuration.GetMilliSeconds()); NS_TEST_ASSERT_MSG_EQ_TOL(dlTxPackets, expectedDlTxPackets, expectedDlTxPackets * 0.005, diff --git a/src/lte/test/lte-test-pss-ff-mac-scheduler.cc b/src/lte/test/lte-test-pss-ff-mac-scheduler.cc index e1a876c94..f175c8b21 100644 --- a/src/lte/test/lte-test-pss-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-pss-ff-mac-scheduler.cc @@ -21,15 +21,16 @@ #include "lte-test-pss-ff-mac-scheduler.h" -#include "ns3/applications-module.h" #include "ns3/double.h" #include "ns3/internet-module.h" #include "ns3/ipv4-global-routing-helper.h" #include "ns3/network-module.h" +#include "ns3/packet-sink-helper.h" #include "ns3/point-to-point-epc-helper.h" #include "ns3/point-to-point-helper.h" #include "ns3/radio-bearer-stats-calculator.h" #include "ns3/string.h" +#include "ns3/udp-client-server-helper.h" #include #include #include @@ -543,7 +544,7 @@ LenaPssFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-radio-link-failure.cc b/src/lte/test/lte-test-radio-link-failure.cc index 1bd902697..f03ee1018 100644 --- a/src/lte/test/lte-test-radio-link-failure.cc +++ b/src/lte/test/lte-test-radio-link-failure.cc @@ -24,7 +24,6 @@ #include "lte-test-radio-link-failure.h" -#include "ns3/applications-module.h" #include "ns3/config-store-module.h" #include "ns3/config-store.h" #include "ns3/core-module.h" @@ -32,7 +31,9 @@ #include "ns3/lte-module.h" #include "ns3/mobility-module.h" #include "ns3/network-module.h" +#include "ns3/packet-sink-helper.h" #include "ns3/point-to-point-module.h" +#include "ns3/udp-client-server-helper.h" #include #include @@ -281,9 +282,7 @@ LteRadioLinkFailureTestCase::DoRun() // Mobility Ptr positionAllocEnb = CreateObject(); - for (std::vector::iterator enbPosIt = m_enbPositionList.begin(); - enbPosIt != m_enbPositionList.end(); - ++enbPosIt) + for (auto enbPosIt = m_enbPositionList.begin(); enbPosIt != m_enbPositionList.end(); ++enbPosIt) { positionAllocEnb->Add(*enbPosIt); } @@ -294,9 +293,7 @@ LteRadioLinkFailureTestCase::DoRun() Ptr positionAllocUe = CreateObject(); - for (std::vector::iterator uePosIt = m_uePositionList.begin(); - uePosIt != m_uePositionList.end(); - ++uePosIt) + for (auto uePosIt = m_uePositionList.begin(); uePosIt != m_uePositionList.end(); ++uePosIt) { positionAllocUe->Add(*uePosIt); } @@ -463,9 +460,7 @@ LteRadioLinkFailureTestCase::CheckConnected(Ptr ueDevice, NetDeviceCo Ptr enbLteDevice; - for (std::vector>::const_iterator enbDevIt = enbDevices.Begin(); - enbDevIt != enbDevices.End(); - ++enbDevIt) + for (auto enbDevIt = enbDevices.Begin(); enbDevIt != enbDevices.End(); ++enbDevIt) { if (((*enbDevIt)->GetObject())->HasCellId(cellId)) { @@ -511,8 +506,8 @@ LteRadioLinkFailureTestCase::CheckConnected(Ptr ueDevice, NetDeviceCo ueRrc->GetAttribute("DataRadioBearerMap", ueDataRadioBearerMapValue); NS_TEST_ASSERT_MSG_EQ(ueDataRadioBearerMapValue.GetN(), 1 + 1, "wrong num bearers at UE"); - ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin(); - ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin(); + auto enbBearerIt = enbDataRadioBearerMapValue.Begin(); + auto ueBearerIt = ueDataRadioBearerMapValue.Begin(); while (enbBearerIt != enbDataRadioBearerMapValue.End() && ueBearerIt != ueDataRadioBearerMapValue.End()) { diff --git a/src/lte/test/lte-test-tdbet-ff-mac-scheduler.cc b/src/lte/test/lte-test-tdbet-ff-mac-scheduler.cc index 0c20b0a58..5bcc4a63a 100644 --- a/src/lte/test/lte-test-tdbet-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-tdbet-ff-mac-scheduler.cc @@ -388,7 +388,7 @@ LenaTdBetFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc b/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc index 40cbcda8e..01450c96c 100644 --- a/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc @@ -21,15 +21,16 @@ #include "lte-test-tdtbfq-ff-mac-scheduler.h" -#include "ns3/applications-module.h" #include "ns3/double.h" #include "ns3/internet-module.h" #include "ns3/ipv4-global-routing-helper.h" #include "ns3/network-module.h" +#include "ns3/packet-sink-helper.h" #include "ns3/point-to-point-epc-helper.h" #include "ns3/point-to-point-helper.h" #include "ns3/radio-bearer-stats-calculator.h" #include "ns3/string.h" +#include "ns3/udp-client-server-helper.h" #include #include #include @@ -546,7 +547,7 @@ LenaTdTbfqFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-ue-measurements.cc b/src/lte/test/lte-test-ue-measurements.cc index 2ade5de4b..530454f14 100644 --- a/src/lte/test/lte-test-ue-measurements.cc +++ b/src/lte/test/lte-test-ue-measurements.cc @@ -1607,8 +1607,7 @@ LteUeMeasurementsPiecewiseTestCase2::RecvMeasurementReportCallback( NS_TEST_ASSERT_MSG_EQ(measResults.haveMeasResultNeighCells, true, "Unexpected report content"); - std::list::iterator it = - measResults.measResultListEutra.begin(); + auto it = measResults.measResultListEutra.begin(); NS_ASSERT(it != measResults.measResultListEutra.end()); NS_ASSERT(it->physCellId == 2); NS_TEST_ASSERT_MSG_EQ(it->haveCgiInfo, @@ -1900,8 +1899,7 @@ LteUeMeasurementsPiecewiseTestCase3::RecvMeasurementReportCallback( NS_TEST_ASSERT_MSG_EQ(measResults.haveMeasResultNeighCells, true, "Unexpected report content"); - std::list::iterator it = - measResults.measResultListEutra.begin(); + auto it = measResults.measResultListEutra.begin(); NS_ASSERT(it != measResults.measResultListEutra.end()); for (const auto& it : measResults.measResultListEutra) { @@ -2402,18 +2400,19 @@ LteUeMeasurementsHandoverTestCase::DoRun() // Setup UE measurement configuration in eNodeBs uint8_t measId; - std::list::const_iterator itReportConfig; Ptr enbRrc1 = enbDevs.Get(0)->GetObject()->GetRrc(); Ptr enbRrc2 = enbDevs.Get(1)->GetObject()->GetRrc(); - for (itReportConfig = m_sourceConfigList.begin(); itReportConfig != m_sourceConfigList.end(); + for (auto itReportConfig = m_sourceConfigList.begin(); + itReportConfig != m_sourceConfigList.end(); itReportConfig++) { measId = enbRrc1->AddUeMeasReportConfig(*itReportConfig).at(0); m_expectedSourceCellMeasId.insert(measId); } - for (itReportConfig = m_targetConfigList.begin(); itReportConfig != m_targetConfigList.end(); + for (auto itReportConfig = m_targetConfigList.begin(); + itReportConfig != m_targetConfigList.end(); itReportConfig++) { measId = enbRrc2->AddUeMeasReportConfig(*itReportConfig).at(0); @@ -2490,12 +2489,12 @@ LteUeMeasurementsHandoverTestCase::RecvMeasurementReportCallback( bool isCorrectMeasId; if (cellId == 1) { - std::set::iterator itMeasId = m_expectedSourceCellMeasId.find(measId); + auto itMeasId = m_expectedSourceCellMeasId.find(measId); isCorrectMeasId = (itMeasId != m_expectedSourceCellMeasId.end()); } else if (cellId == 2) { - std::set::iterator itMeasId = m_expectedTargetCellMeasId.find(measId); + auto itMeasId = m_expectedTargetCellMeasId.find(measId); isCorrectMeasId = (itMeasId != m_expectedTargetCellMeasId.end()); } else @@ -2528,8 +2527,7 @@ LteUeMeasurementsHandoverTestCase::RecvMeasurementReportCallback( NS_TEST_ASSERT_MSG_EQ(measResults.haveMeasResultNeighCells, true, "Unexpected report content"); - std::list::iterator it = - measResults.measResultListEutra.begin(); + auto it = measResults.measResultListEutra.begin(); NS_ASSERT(it != measResults.measResultListEutra.end()); NS_ASSERT(it->physCellId != cellId); NS_ASSERT(it->physCellId <= 2); diff --git a/src/lte/test/test-asn1-encoding.cc b/src/lte/test/test-asn1-encoding.cc index b11f70733..37bf3fe8b 100644 --- a/src/lte/test/test-asn1-encoding.cc +++ b/src/lte/test/test-asn1-encoding.cc @@ -207,9 +207,9 @@ RrcHeaderTestCase::AssertEqualRadioResourceConfigDedicated( "SrbToAddModList different sizes"); std::list srcSrbToAddModList = rrcd1.srbToAddModList; - std::list::iterator it1 = srcSrbToAddModList.begin(); + auto it1 = srcSrbToAddModList.begin(); std::list dstSrbToAddModList = rrcd2.srbToAddModList; - std::list::iterator it2 = dstSrbToAddModList.begin(); + auto it2 = dstSrbToAddModList.begin(); for (; it1 != srcSrbToAddModList.end(); it1++, it2++) { @@ -233,9 +233,9 @@ RrcHeaderTestCase::AssertEqualRadioResourceConfigDedicated( "DrbToAddModList different sizes"); std::list srcDrbToAddModList = rrcd1.drbToAddModList; - std::list::iterator it3 = srcDrbToAddModList.begin(); + auto it3 = srcDrbToAddModList.begin(); std::list dstDrbToAddModList = rrcd2.drbToAddModList; - std::list::iterator it4 = dstDrbToAddModList.begin(); + auto it4 = dstDrbToAddModList.begin(); for (; it3 != srcDrbToAddModList.end(); it3++, it4++) { @@ -267,8 +267,8 @@ RrcHeaderTestCase::AssertEqualRadioResourceConfigDedicated( std::list srcDrbToReleaseList = rrcd1.drbToReleaseList; std::list dstDrbToReleaseList = rrcd2.drbToReleaseList; - std::list::iterator it5 = srcDrbToReleaseList.begin(); - std::list::iterator it6 = dstDrbToReleaseList.begin(); + auto it5 = srcDrbToReleaseList.begin(); + auto it6 = dstDrbToReleaseList.begin(); for (; it5 != srcDrbToReleaseList.end(); it5++, it6++) { @@ -1186,8 +1186,8 @@ MeasurementReportTestCase::DoRun() if (srcMeas.haveMeasResultNeighCells) { - std::list::iterator itsrc = srcMeas.measResultListEutra.begin(); - std::list::iterator itdst = dstMeas.measResultListEutra.begin(); + auto itsrc = srcMeas.measResultListEutra.begin(); + auto itdst = dstMeas.measResultListEutra.begin(); for (; itsrc != srcMeas.measResultListEutra.end(); itsrc++, itdst++) { NS_TEST_ASSERT_MSG_EQ(itsrc->physCellId, itdst->physCellId, "Different physCellId!"); @@ -1210,8 +1210,8 @@ MeasurementReportTestCase::DoRun() if (!itsrc->cgiInfo.plmnIdentityList.empty()) { - std::list::iterator itsrc2 = itsrc->cgiInfo.plmnIdentityList.begin(); - std::list::iterator itdst2 = itdst->cgiInfo.plmnIdentityList.begin(); + auto itsrc2 = itsrc->cgiInfo.plmnIdentityList.begin(); + auto itdst2 = itdst->cgiInfo.plmnIdentityList.begin(); for (; itsrc2 != itsrc->cgiInfo.plmnIdentityList.begin(); itsrc2++, itdst2++) { NS_TEST_ASSERT_MSG_EQ(*itsrc2, *itdst2, "Different plmnId elements!"); diff --git a/src/lte/test/test-lte-epc-e2e-data.cc b/src/lte/test/test-lte-epc-e2e-data.cc index 706c7b0d1..ce23efd75 100644 --- a/src/lte/test/test-lte-epc-e2e-data.cc +++ b/src/lte/test/test-lte-epc-e2e-data.cc @@ -195,13 +195,11 @@ LteEpcE2eDataTestCase::DoRun() StringValue("RowFirst")); enbMobility.Install(enbs); NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice(enbs); - NetDeviceContainer::Iterator enbLteDevIt = enbLteDevs.Begin(); + auto enbLteDevIt = enbLteDevs.Begin(); uint16_t ulPort = 1000; - for (std::vector::iterator enbit = m_enbTestData.begin(); - enbit < m_enbTestData.end(); - ++enbit, ++enbLteDevIt) + for (auto enbit = m_enbTestData.begin(); enbit < m_enbTestData.end(); ++enbit, ++enbLteDevIt) { NS_ABORT_IF(enbLteDevIt == enbLteDevs.End()); @@ -317,12 +315,9 @@ LteEpcE2eDataTestCase::DoRun() uint64_t imsiCounter = 0; - for (std::vector::iterator enbit = m_enbTestData.begin(); - enbit < m_enbTestData.end(); - ++enbit) + for (auto enbit = m_enbTestData.begin(); enbit < m_enbTestData.end(); ++enbit) { - for (std::vector::iterator ueit = enbit->ues.begin(); ueit < enbit->ues.end(); - ++ueit) + for (auto ueit = enbit->ues.begin(); ueit < enbit->ues.end(); ++ueit) { uint64_t imsi = ++imsiCounter; for (uint32_t b = 0; b < ueit->bearers.size(); ++b) diff --git a/src/lte/test/test-lte-rlc-header.cc b/src/lte/test/test-lte-rlc-header.cc index f1aef251b..bc696a2a0 100644 --- a/src/lte/test/test-lte-rlc-header.cc +++ b/src/lte/test/test-lte-rlc-header.cc @@ -151,8 +151,7 @@ RlcAmStatusPduTestCase::DoRun() LteRlcAmHeader h; h.SetControlPdu(LteRlcAmHeader::STATUS_PDU); h.SetAckSn(m_ackSn); - for (std::list::iterator it = m_nackSnList.begin(); it != m_nackSnList.end(); - ++it) + for (auto it = m_nackSnList.begin(); it != m_nackSnList.end(); ++it) { h.PushNack(it->GetValue()); } @@ -170,8 +169,7 @@ RlcAmStatusPduTestCase::DoRun() SequenceNumber10 ackSn = h2.GetAckSn(); NS_TEST_ASSERT_MSG_EQ(ackSn, m_ackSn, "deserialized ACK SN differs from test vector"); - for (std::list::iterator it = m_nackSnList.begin(); it != m_nackSnList.end(); - ++it) + for (auto it = m_nackSnList.begin(); it != m_nackSnList.end(); ++it) { int nackSn = h2.PopNack(); NS_TEST_ASSERT_MSG_GT(nackSn, -1, "not enough elements in deserialized NACK list"); diff --git a/src/lte/test/test-lte-rrc.cc b/src/lte/test/test-lte-rrc.cc index 6210d4375..36c26e3b0 100644 --- a/src/lte/test/test-lte-rrc.cc +++ b/src/lte/test/test-lte-rrc.cc @@ -321,7 +321,7 @@ LteRrcConnectionEstablishmentTestCase::DoRun() // instead of lteHelper->Attach () and lteHelper->ActivateXxx // Set AdmitConnectionRequest attribute - for (NetDeviceContainer::Iterator it = enbDevs.Begin(); it != enbDevs.End(); ++it) + for (auto it = enbDevs.Begin(); it != enbDevs.End(); ++it) { Ptr enbRrc = (*it)->GetObject()->GetRrc(); enbRrc->SetAttribute("AdmitRrcConnectionRequest", @@ -330,7 +330,7 @@ LteRrcConnectionEstablishmentTestCase::DoRun() uint32_t i = 0; uint32_t tmax = 0; - for (NetDeviceContainer::Iterator it = ueDevs.Begin(); it != ueDevs.End(); ++it) + for (auto it = ueDevs.Begin(); it != ueDevs.End(); ++it) { Ptr ueDevice = *it; Ptr enbDevice = enbDevs.Get(0); @@ -494,8 +494,8 @@ LteRrcConnectionEstablishmentTestCase::CheckConnected(Ptr ueDevice, m_nBearers, "wrong num bearers at UE"); - ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin(); - ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin(); + auto enbBearerIt = enbDataRadioBearerMapValue.Begin(); + auto ueBearerIt = ueDataRadioBearerMapValue.Begin(); while (enbBearerIt != enbDataRadioBearerMapValue.End() && ueBearerIt != ueDataRadioBearerMapValue.End()) { @@ -679,7 +679,7 @@ LteRrcConnectionEstablishmentErrorTestCase::DoRun() // instead of lteHelper->Attach () and lteHelper->ActivateXxx // Set AdmitConnectionRequest attribute - for (NetDeviceContainer::Iterator it = enbDevs.Begin(); it != enbDevs.End(); ++it) + for (auto it = enbDevs.Begin(); it != enbDevs.End(); ++it) { Ptr enbRrc = (*it)->GetObject()->GetRrc(); enbRrc->SetAttribute("AdmitRrcConnectionRequest", @@ -688,7 +688,7 @@ LteRrcConnectionEstablishmentErrorTestCase::DoRun() uint32_t i = 0; uint32_t tmax = 0; - for (NetDeviceContainer::Iterator it = ueDevs.Begin(); it != ueDevs.End(); ++it) + for (auto it = ueDevs.Begin(); it != ueDevs.End(); ++it) { Ptr ueDevice = *it; Ptr enbDevice = enbDevs.Get(0); @@ -782,7 +782,7 @@ LteRrcTestSuite::LteRrcTestSuite() NS_LOG_FUNCTION(this); - for (uint32_t useIdealRrc = 0; useIdealRrc <= 1; ++useIdealRrc) + for (auto useIdealRrc : {false, true}) { // <----- all times in ms -----------------> diff --git a/src/lte/test/test-lte-x2-handover-measures.cc b/src/lte/test/test-lte-x2-handover-measures.cc index cf32f7a95..09db4e31d 100644 --- a/src/lte/test/test-lte-x2-handover-measures.cc +++ b/src/lte/test/test-lte-x2-handover-measures.cc @@ -18,13 +18,16 @@ * Manuel Requena */ -#include +#include #include #include #include #include #include +#include +#include #include +#include using namespace ns3; @@ -342,7 +345,7 @@ LteX2HandoverMeasuresTestCase::DoRun() NetDeviceContainer enbDevices; enbDevices = m_lteHelper->InstallEnbDevice(enbNodes); stream += m_lteHelper->AssignStreams(enbDevices, stream); - for (NetDeviceContainer::Iterator it = enbDevices.Begin(); it != enbDevices.End(); ++it) + for (auto it = enbDevices.Begin(); it != enbDevices.End(); ++it) { Ptr enbRrc = (*it)->GetObject()->GetRrc(); enbRrc->SetAttribute("AdmitHandoverRequest", BooleanValue(m_admitHo)); @@ -538,7 +541,7 @@ LteX2HandoverMeasuresTestCase::DoRun() // check initial RRC connection const Time maxRrcConnectionEstablishmentDuration = Seconds(0.080); - for (NetDeviceContainer::Iterator it = ueDevices.Begin(); it != ueDevices.End(); ++it) + for (auto it = ueDevices.Begin(); it != ueDevices.End(); ++it) { NS_LOG_FUNCTION(maxRrcConnectionEstablishmentDuration); Simulator::Schedule(maxRrcConnectionEstablishmentDuration, @@ -551,7 +554,7 @@ LteX2HandoverMeasuresTestCase::DoRun() // schedule the checkpoint events Time stopTime = Seconds(0); - for (std::list::iterator checkPointEventIt = m_checkPointEventList.begin(); + for (auto checkPointEventIt = m_checkPointEventList.begin(); checkPointEventIt != m_checkPointEventList.end(); ++checkPointEventIt) { @@ -639,8 +642,8 @@ LteX2HandoverMeasuresTestCase::CheckConnected(Ptr ueDevice, Ptr::iterator it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); + for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); it != m_ueDataVector.at(ueIndex).bearerDataList.end(); ++it) { @@ -695,7 +698,7 @@ LteX2HandoverMeasuresTestCase::CheckStats(uint32_t ueIndex) { NS_LOG_FUNCTION(ueIndex); uint32_t b = 1; - for (std::list::iterator it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); + for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); it != m_ueDataVector.at(ueIndex).bearerDataList.end(); ++it) { @@ -770,10 +773,9 @@ LteX2HandoverMeasuresTestSuite::LteX2HandoverMeasuresTestSuite() CheckPointEvent(Seconds(25), Seconds(37), checkInterval, 0, 3), }; - int32_t useIdealRrc; std::string sched = "ns3::PfFfMacScheduler"; std::string ho = "ns3::A2A4RsrqHandoverAlgorithm"; - for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc) + for (auto useIdealRrc : {true, false}) { // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, ho, admitHo, idealRrc AddTestCase(new LteX2HandoverMeasuresTestCase(2, @@ -878,7 +880,7 @@ LteX2HandoverMeasuresTestSuite::LteX2HandoverMeasuresTestSuite() } sched = "ns3::RrFfMacScheduler"; - for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc) + for (auto useIdealRrc : {true, false}) { // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc AddTestCase(new LteX2HandoverMeasuresTestCase(2, @@ -918,7 +920,7 @@ LteX2HandoverMeasuresTestSuite::LteX2HandoverMeasuresTestSuite() ho = "ns3::A3RsrpHandoverAlgorithm"; sched = "ns3::PfFfMacScheduler"; - for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc) + for (auto useIdealRrc : {true, false}) { // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc AddTestCase(new LteX2HandoverMeasuresTestCase(2, @@ -957,7 +959,7 @@ LteX2HandoverMeasuresTestSuite::LteX2HandoverMeasuresTestSuite() } sched = "ns3::RrFfMacScheduler"; - for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc) + for (auto useIdealRrc : {true, false}) { // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc AddTestCase(new LteX2HandoverMeasuresTestCase(2, diff --git a/src/lte/test/test-lte-x2-handover.cc b/src/lte/test/test-lte-x2-handover.cc index 7185b48c3..b8cbbb297 100644 --- a/src/lte/test/test-lte-x2-handover.cc +++ b/src/lte/test/test-lte-x2-handover.cc @@ -17,13 +17,15 @@ * Author: Nicola Baldo */ -#include #include #include #include #include #include +#include +#include #include +#include using namespace ns3; @@ -274,7 +276,7 @@ LteX2HandoverTestCase::DoRun() NetDeviceContainer enbDevices; enbDevices = m_lteHelper->InstallEnbDevice(enbNodes); stream += m_lteHelper->AssignStreams(enbDevices, stream); - for (NetDeviceContainer::Iterator it = enbDevices.Begin(); it != enbDevices.End(); ++it) + for (auto it = enbDevices.Begin(); it != enbDevices.End(); ++it) { Ptr enbRrc = (*it)->GetObject()->GetRrc(); enbRrc->SetAttribute("AdmitHandoverRequest", BooleanValue(m_admitHo)); @@ -438,7 +440,7 @@ LteX2HandoverTestCase::DoRun() // check initial RRC connection const Time maxRrcConnectionEstablishmentDuration = Seconds(0.080); - for (NetDeviceContainer::Iterator it = ueDevices.Begin(); it != ueDevices.End(); ++it) + for (auto it = ueDevices.Begin(); it != ueDevices.End(); ++it) { Simulator::Schedule(maxRrcConnectionEstablishmentDuration, &LteX2HandoverTestCase::CheckConnected, @@ -450,8 +452,7 @@ LteX2HandoverTestCase::DoRun() // schedule handover events and corresponding checks Time stopTime = Seconds(0); - for (std::list::iterator hoEventIt = m_handoverEventList.begin(); - hoEventIt != m_handoverEventList.end(); + for (auto hoEventIt = m_handoverEventList.begin(); hoEventIt != m_handoverEventList.end(); ++hoEventIt) { // Teleport the UE between both eNBs just before the handover starts @@ -567,8 +568,8 @@ LteX2HandoverTestCase::CheckConnected(Ptr ueDevice, Ptr en m_nDedicatedBearers + 1, "wrong num bearers at UE"); - ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin(); - ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin(); + auto enbBearerIt = enbDataRadioBearerMapValue.Begin(); + auto ueBearerIt = ueDataRadioBearerMapValue.Begin(); while (enbBearerIt != enbDataRadioBearerMapValue.End() && ueBearerIt != ueDataRadioBearerMapValue.End()) { @@ -619,7 +620,7 @@ LteX2HandoverTestCase::TeleportUeNearTargetEnb(Ptr ueNode, Ptr enbNo void LteX2HandoverTestCase::SaveStatsAfterHandover(uint32_t ueIndex) { - for (std::list::iterator it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); + for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); it != m_ueDataVector.at(ueIndex).bearerDataList.end(); ++it) { @@ -632,7 +633,7 @@ void LteX2HandoverTestCase::CheckStatsAWhileAfterHandover(uint32_t ueIndex) { uint32_t b = 1; - for (std::list::iterator it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); + for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); it != m_ueDataVector.at(ueIndex).bearerDataList.end(); ++it) { @@ -759,11 +760,9 @@ LteX2HandoverTestSuite::LteX2HandoverTestSuite() "ns3::PfFfMacScheduler", }; - for (std::vector::iterator schedIt = schedulers.begin(); - schedIt != schedulers.end(); - ++schedIt) + for (auto schedIt = schedulers.begin(); schedIt != schedulers.end(); ++schedIt) { - for (int32_t useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc) + for (auto useIdealRrc : {true, false}) { // nUes, nDBearers, helist, name, sched, admitHo, idealRrc AddTestCase(new LteX2HandoverTestCase(1, diff --git a/src/mesh/CMakeLists.txt b/src/mesh/CMakeLists.txt index 85c89759d..c362544cf 100644 --- a/src/mesh/CMakeLists.txt +++ b/src/mesh/CMakeLists.txt @@ -68,7 +68,6 @@ build_lib( LIBRARIES_TO_LINK ${libinternet} ${libwifi} - ${libapplications} TEST_SOURCES test/dot11s/dot11s-test-suite.cc test/dot11s/hwmp-proactive-regression.cc diff --git a/src/mesh/examples/mesh.cc b/src/mesh/examples/mesh.cc index 69fcd9787..79c9a3e47 100644 --- a/src/mesh/examples/mesh.cc +++ b/src/mesh/examples/mesh.cc @@ -336,7 +336,7 @@ void MeshTest::Report() { unsigned n(0); - for (NetDeviceContainer::Iterator i = meshDevices.Begin(); i != meshDevices.End(); ++i, ++n) + for (auto i = meshDevices.Begin(); i != meshDevices.End(); ++i, ++n) { std::ostringstream os; os << "mp-report-" << n << ".xml"; diff --git a/src/mesh/helper/dot11s/dot11s-installer.cc b/src/mesh/helper/dot11s/dot11s-installer.cc index 1b4c370e6..45264c10c 100644 --- a/src/mesh/helper/dot11s/dot11s-installer.cc +++ b/src/mesh/helper/dot11s/dot11s-installer.cc @@ -16,7 +16,7 @@ * * Authors: Kirill Andreev */ -#include "ns3/dot11s-installer.h" +#include "dot11s-installer.h" #include "ns3/hwmp-protocol.h" #include "ns3/mesh-wifi-interface-mac.h" @@ -92,7 +92,7 @@ Dot11sStack::Report(const Ptr mp, std::ostream& os) mp->Report(os); std::vector> ifaces = mp->GetInterfaces(); - for (std::vector>::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i) + for (auto i = ifaces.begin(); i != ifaces.end(); ++i) { Ptr device = (*i)->GetObject(); NS_ASSERT(device); @@ -115,7 +115,7 @@ Dot11sStack::ResetStats(const Ptr mp) mp->ResetStats(); std::vector> ifaces = mp->GetInterfaces(); - for (std::vector>::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i) + for (auto i = ifaces.begin(); i != ifaces.end(); ++i) { Ptr device = (*i)->GetObject(); NS_ASSERT(device); diff --git a/src/mesh/helper/flame/flame-installer.cc b/src/mesh/helper/flame/flame-installer.cc index 4728d188c..bcc8a126c 100644 --- a/src/mesh/helper/flame/flame-installer.cc +++ b/src/mesh/helper/flame/flame-installer.cc @@ -17,7 +17,7 @@ * Authors: Kirill Andreev */ -#include "ns3/flame-installer.h" +#include "flame-installer.h" #include "ns3/flame-protocol.h" #include "ns3/mesh-wifi-interface-mac.h" diff --git a/src/mesh/helper/mesh-helper.cc b/src/mesh/helper/mesh-helper.cc index 157823f12..1760cc1f2 100644 --- a/src/mesh/helper/mesh-helper.cc +++ b/src/mesh/helper/mesh-helper.cc @@ -64,7 +64,7 @@ MeshHelper::Install(const WifiPhyHelper& phyHelper, NodeContainer c) const { NetDeviceContainer devices; NS_ASSERT(m_stack); - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; // Create a mesh point device @@ -179,7 +179,7 @@ MeshHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr mpd = DynamicCast(netDevice); @@ -190,7 +190,7 @@ MeshHelper::AssignStreams(NetDeviceContainer c, int64_t stream) currentStream += mpd->AssignStreams(currentStream); // To access, we need the underlying WifiNetDevices std::vector> ifaces = mpd->GetInterfaces(); - for (std::vector>::iterator i = ifaces.begin(); i != ifaces.end(); i++) + for (auto i = ifaces.begin(); i != ifaces.end(); i++) { wifi = DynamicCast(*i); diff --git a/src/mesh/helper/mesh-helper.h b/src/mesh/helper/mesh-helper.h index 9bdffa44f..de8955e66 100644 --- a/src/mesh/helper/mesh-helper.h +++ b/src/mesh/helper/mesh-helper.h @@ -21,7 +21,8 @@ #ifndef MESH_HELPER_H #define MESH_HELPER_H -#include "ns3/mesh-stack-installer.h" +#include "mesh-stack-installer.h" + #include "ns3/object-factory.h" #include "ns3/qos-utils.h" #include "ns3/wifi-standards.h" diff --git a/src/mesh/helper/mesh-stack-installer.cc b/src/mesh/helper/mesh-stack-installer.cc index 28b7a2829..4f9d0bed4 100644 --- a/src/mesh/helper/mesh-stack-installer.cc +++ b/src/mesh/helper/mesh-stack-installer.cc @@ -17,7 +17,7 @@ * Author: Peter D. Barnes, Jr. */ -#include "ns3/mesh-stack-installer.h" +#include "mesh-stack-installer.h" namespace ns3 { diff --git a/src/mesh/model/dot11s/hwmp-protocol-mac.cc b/src/mesh/model/dot11s/hwmp-protocol-mac.cc index 61e265549..f7fd7f328 100644 --- a/src/mesh/model/dot11s/hwmp-protocol-mac.cc +++ b/src/mesh/model/dot11s/hwmp-protocol-mac.cc @@ -120,7 +120,7 @@ HwmpProtocolMac::ReceiveAction(Ptr packet, const WifiMacHeader& header) // this is the last header to remove. packet->RemoveHeader(elements, packet->GetSize()); std::vector failedDestinations; - for (MeshInformationElementVector::Iterator i = elements.Begin(); i != elements.End(); i++) + for (auto i = elements.Begin(); i != elements.End(); i++) { if ((*i)->ElementId() == IE_RANN) { @@ -169,10 +169,7 @@ HwmpProtocolMac::ReceiveAction(Ptr packet, const WifiMacHeader& header) m_stats.rxPerr++; std::vector destinations = perr->GetAddressUnitVector(); - for (std::vector::const_iterator i = - destinations.begin(); - i != destinations.end(); - i++) + for (auto i = destinations.begin(); i != destinations.end(); i++) { failedDestinations.push_back(*i); } @@ -263,7 +260,7 @@ HwmpProtocolMac::SendPreqVector(std::vector preq) NS_LOG_FUNCTION(this); Ptr packet = Create(); MeshInformationElementVector elements; - for (std::vector::iterator i = preq.begin(); i != preq.end(); i++) + for (auto i = preq.begin(); i != preq.end(); i++) { elements.AddInformationElement(Ptr(&(*i))); } @@ -278,7 +275,7 @@ HwmpProtocolMac::SendPreqVector(std::vector preq) hdr.SetAddr3(m_protocol->GetAddress()); // Send Management frame std::vector receivers = m_protocol->GetPreqReceivers(m_ifIndex); - for (std::vector::const_iterator i = receivers.begin(); i != receivers.end(); i++) + for (auto i = receivers.begin(); i != receivers.end(); i++) { hdr.SetAddr1(*i); m_stats.txPreq++; @@ -292,7 +289,7 @@ void HwmpProtocolMac::RequestDestination(Mac48Address dst, uint32_t originator_seqno, uint32_t dst_seqno) { NS_LOG_FUNCTION(this << dst << originator_seqno << dst_seqno); - for (std::vector::iterator i = m_myPreq.begin(); i != m_myPreq.end(); i++) + for (auto i = m_myPreq.begin(); i != m_myPreq.end(); i++) { if (i->IsFull()) { @@ -372,10 +369,7 @@ HwmpProtocolMac::ForwardPerr(std::vector failed Ptr packet = Create(); Ptr perr = Create(); MeshInformationElementVector elements; - for (std::vector::const_iterator i = - failedDestinations.begin(); - i != failedDestinations.end(); - i++) + for (auto i = failedDestinations.begin(); i != failedDestinations.end(); i++) { if (!perr->IsFull()) { @@ -406,7 +400,7 @@ HwmpProtocolMac::ForwardPerr(std::vector failed receivers.push_back(Mac48Address::GetBroadcast()); } // Send Management frame - for (std::vector::const_iterator i = receivers.begin(); i != receivers.end(); i++) + for (auto i = receivers.begin(); i != receivers.end(); i++) { // // 64-bit Intel valgrind complains about hdr.SetAddr1 (*i). It likes this @@ -429,13 +423,10 @@ HwmpProtocolMac::InitiatePerr(std::vector faile // All duplicates in PERR are checked here, and there is no reason to // check it at any other place { - std::vector::const_iterator end = receivers.end(); - for (std::vector::const_iterator i = receivers.begin(); i != end; i++) + for (auto i = receivers.begin(); i != receivers.end(); i++) { bool should_add = true; - for (std::vector::const_iterator j = m_myPerr.receivers.begin(); - j != m_myPerr.receivers.end(); - j++) + for (auto j = m_myPerr.receivers.begin(); j != m_myPerr.receivers.end(); j++) { if ((*i) == (*j)) { @@ -450,17 +441,10 @@ HwmpProtocolMac::InitiatePerr(std::vector faile } } { - std::vector::const_iterator end = failedDestinations.end(); - for (std::vector::const_iterator i = - failedDestinations.begin(); - i != end; - i++) + for (auto i = failedDestinations.begin(); i != failedDestinations.end(); i++) { bool should_add = true; - for (std::vector::const_iterator j = - m_myPerr.destinations.begin(); - j != m_myPerr.destinations.end(); - j++) + for (auto j = m_myPerr.destinations.begin(); j != m_myPerr.destinations.end(); j++) { if (((*i).destination == (*j).destination) && ((*j).seqnum > (*i).seqnum)) { diff --git a/src/mesh/model/dot11s/hwmp-protocol-mac.h b/src/mesh/model/dot11s/hwmp-protocol-mac.h index 7f8c23477..e9ed3d6cd 100644 --- a/src/mesh/model/dot11s/hwmp-protocol-mac.h +++ b/src/mesh/model/dot11s/hwmp-protocol-mac.h @@ -20,7 +20,8 @@ #ifndef HWMP_STATE_H #define HWMP_STATE_H -#include "ns3/hwmp-protocol.h" +#include "hwmp-protocol.h" + #include "ns3/mesh-wifi-interface-mac-plugin.h" namespace ns3 diff --git a/src/mesh/model/dot11s/hwmp-protocol.cc b/src/mesh/model/dot11s/hwmp-protocol.cc index 3d9df4ecf..221acddd6 100644 --- a/src/mesh/model/dot11s/hwmp-protocol.cc +++ b/src/mesh/model/dot11s/hwmp-protocol.cc @@ -201,9 +201,7 @@ void HwmpProtocol::DoDispose() { NS_LOG_FUNCTION(this); - for (std::map::iterator i = m_preqTimeouts.begin(); - i != m_preqTimeouts.end(); - i++) + for (auto i = m_preqTimeouts.begin(); i != m_preqTimeouts.end(); i++) { i->second.preqTimeout.Cancel(); } @@ -263,14 +261,10 @@ HwmpProtocol::RequestRoute(uint32_t sourceIface, m_stats.txBytes += packet->GetSize(); // channel IDs where we have already sent broadcast: std::vector channels; - for (HwmpProtocolMacMap::const_iterator plugin = m_interfaces.begin(); - plugin != m_interfaces.end(); - plugin++) + for (auto plugin = m_interfaces.begin(); plugin != m_interfaces.end(); plugin++) { bool shouldSend = true; - for (std::vector::const_iterator chan = channels.begin(); - chan != channels.end(); - chan++) + for (auto chan = channels.begin(); chan != channels.end(); chan++) { if ((*chan) == plugin->second->GetChannelId()) { @@ -283,9 +277,7 @@ HwmpProtocol::RequestRoute(uint32_t sourceIface, } channels.push_back(plugin->second->GetChannelId()); std::vector receivers = GetBroadcastReceivers(plugin->first); - for (std::vector::const_iterator i = receivers.begin(); - i != receivers.end(); - i++) + for (auto i = receivers.begin(); i != receivers.end(); i++) { Ptr packetCopy = packet->Copy(); // @@ -396,8 +388,7 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, dst_seqno = result.seqnum; } m_stats.initiatedPreq++; - for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); - i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { i->second->RequestDestination(destination, originator_seqno, dst_seqno); } @@ -433,8 +424,7 @@ HwmpProtocol::ReceivePreq(IePreq preq, NS_LOG_FUNCTION(this << from << interface << fromMp << metric); preq.IncrementMetric(metric); // acceptance cretirea: - std::map>::const_iterator i = - m_hwmpSeqnoMetricDatabase.find(preq.GetOriginatorAddress()); + auto i = m_hwmpSeqnoMetricDatabase.find(preq.GetOriginatorAddress()); bool freshInfo(true); if (i != m_hwmpSeqnoMetricDatabase.end()) { @@ -501,9 +491,7 @@ HwmpProtocol::ReceivePreq(IePreq preq, m_routeChangeTraceSource(rChange); ReactivePathResolved(fromMp); } - for (std::vector>::const_iterator i = destinations.begin(); - i != destinations.end(); - i++) + for (auto i = destinations.begin(); i != destinations.end(); i++) { if ((*i)->GetDestinationAddress() == Mac48Address::GetBroadcast()) { @@ -603,7 +591,7 @@ HwmpProtocol::ReceivePreq(IePreq preq, } // Forward PREQ to all interfaces: NS_LOG_DEBUG("I am " << GetAddress() << "retransmitting PREQ:" << preq); - for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { Time forwardingDelay = GetMeshPoint()->GetForwardingDelay(); NS_LOG_DEBUG("Forwarding PREQ from " << from << " with delay " @@ -622,8 +610,7 @@ HwmpProtocol::ReceivePrep(IePrep prep, NS_LOG_FUNCTION(this << from << interface << fromMp << metric); prep.IncrementMetric(metric); // acceptance cretirea: - std::map>::const_iterator i = - m_hwmpSeqnoMetricDatabase.find(prep.GetOriginatorAddress()); + auto i = m_hwmpSeqnoMetricDatabase.find(prep.GetOriginatorAddress()); bool freshInfo(true); uint32_t sequence = prep.GetDestinationSeqNumber(); if (i != m_hwmpSeqnoMetricDatabase.end()) @@ -711,7 +698,7 @@ HwmpProtocol::ReceivePrep(IePrep prep, return; } // Forward PREP - HwmpProtocolMacMap::const_iterator prep_sender = m_interfaces.find(result.ifIndex); + auto prep_sender = m_interfaces.find(result.ifIndex); NS_ASSERT(prep_sender != m_interfaces.end()); Time forwardingDelay = GetMeshPoint()->GetForwardingDelay(); NS_LOG_DEBUG("Forwarding PREP from " << from << " with delay " << forwardingDelay.As(Time::US)); @@ -768,7 +755,7 @@ HwmpProtocol::SendPrep(Mac48Address src, prep.SetMetric(initMetric); prep.SetOriginatorAddress(src); prep.SetOriginatorSeqNumber(originatorDsn); - HwmpProtocolMacMap::const_iterator prep_sender = m_interfaces.find(interface); + auto prep_sender = m_interfaces.find(interface); NS_ASSERT(prep_sender != m_interfaces.end()); prep_sender->second->SendPrep(prep, retransmitter); m_stats.initiatedPrep++; @@ -780,8 +767,7 @@ HwmpProtocol::Install(Ptr mp) NS_LOG_FUNCTION(this << mp); m_mp = mp; std::vector> interfaces = mp->GetInterfaces(); - for (std::vector>::const_iterator i = interfaces.begin(); i != interfaces.end(); - i++) + for (auto i = interfaces.begin(); i != interfaces.end(); i++) { // Checking for compatible net device Ptr wifiNetDev = (*i)->GetObject(); @@ -841,8 +827,7 @@ HwmpProtocol::DropDataFrame(uint32_t seqno, Mac48Address source) NS_LOG_DEBUG("Dropping seqno " << seqno << "; from self"); return true; } - std::map>::const_iterator i = - m_lastDataSeqno.find(source); + const auto i = m_lastDataSeqno.find(source); if (i == m_lastDataSeqno.end()) { m_lastDataSeqno[source] = seqno; @@ -889,7 +874,7 @@ void HwmpProtocol::InitiatePathError(PathError perr) { NS_LOG_FUNCTION(this); - for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { std::vector receivers_for_interface; for (unsigned int j = 0; j < perr.receivers.size(); j++) @@ -907,7 +892,7 @@ void HwmpProtocol::ForwardPathError(PathError perr) { NS_LOG_FUNCTION(this); - for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { std::vector receivers_for_interface; for (unsigned int j = 0; j < perr.receivers.size(); j++) @@ -1021,7 +1006,7 @@ HwmpProtocol::DequeueFirstPacketByDst(Mac48Address dst) NS_LOG_FUNCTION(this << dst); QueuedPacket retval; retval.pkt = nullptr; - for (std::vector::iterator i = m_rqueue.begin(); i != m_rqueue.end(); i++) + for (auto i = m_rqueue.begin(); i != m_rqueue.end(); i++) { if ((*i).dst == dst) { @@ -1051,7 +1036,7 @@ void HwmpProtocol::ReactivePathResolved(Mac48Address dst) { NS_LOG_FUNCTION(this << dst); - std::map::iterator i = m_preqTimeouts.find(dst); + auto i = m_preqTimeouts.find(dst); if (i != m_preqTimeouts.end()) { m_routeDiscoveryTimeCallback(Simulator::Now() - i->second.whenScheduled); @@ -1106,7 +1091,7 @@ bool HwmpProtocol::ShouldSendPreq(Mac48Address dst) { NS_LOG_FUNCTION(this << dst); - std::map::const_iterator i = m_preqTimeouts.find(dst); + auto i = m_preqTimeouts.find(dst); if (i == m_preqTimeouts.end()) { m_preqTimeouts[dst].preqTimeout = @@ -1132,7 +1117,7 @@ HwmpProtocol::RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry) } if (result.retransmitter != Mac48Address::GetBroadcast()) { - std::map::iterator i = m_preqTimeouts.find(dst); + auto i = m_preqTimeouts.find(dst); NS_ASSERT(i != m_preqTimeouts.end()); m_preqTimeouts.erase(i); return; @@ -1152,7 +1137,7 @@ HwmpProtocol::RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry) HwmpRtable::MAX_METRIC); packet = DequeueFirstPacketByDst(dst); } - std::map::iterator i = m_preqTimeouts.find(dst); + auto i = m_preqTimeouts.find(dst); NS_ASSERT(i != m_preqTimeouts.end()); m_routeDiscoveryTimeCallback(Simulator::Now() - i->second.whenScheduled); m_preqTimeouts.erase(i); @@ -1161,7 +1146,7 @@ HwmpProtocol::RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry) numOfRetry++; uint32_t originator_seqno = GetNextHwmpSeqno(); uint32_t dst_seqno = m_rtable->LookupReactiveExpired(dst).seqnum; - for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { i->second->RequestDestination(dst, originator_seqno, dst_seqno); } @@ -1204,7 +1189,7 @@ HwmpProtocol::SendProactivePreq() preq.SetOriginatorAddress(GetAddress()); preq.SetPreqID(GetNextPreqId()); preq.SetOriginatorSeqNumber(GetNextHwmpSeqno()); - for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { i->second->SendPreq(preq); } @@ -1352,9 +1337,7 @@ HwmpProtocol::Report(std::ostream& os) const << "doFlag=\"" << m_doFlag << "\"" << std::endl << "rfFlag=\"" << m_rfFlag << "\">" << std::endl; m_stats.Print(os); - for (HwmpProtocolMacMap::const_iterator plugin = m_interfaces.begin(); - plugin != m_interfaces.end(); - plugin++) + for (auto plugin = m_interfaces.begin(); plugin != m_interfaces.end(); plugin++) { plugin->second->Report(os); } @@ -1366,9 +1349,7 @@ HwmpProtocol::ResetStats() { NS_LOG_FUNCTION(this); m_stats = Statistics(); - for (HwmpProtocolMacMap::const_iterator plugin = m_interfaces.begin(); - plugin != m_interfaces.end(); - plugin++) + for (auto plugin = m_interfaces.begin(); plugin != m_interfaces.end(); plugin++) { plugin->second->ResetStats(); } diff --git a/src/mesh/model/dot11s/hwmp-rtable.cc b/src/mesh/model/dot11s/hwmp-rtable.cc index c397f8cc5..ed3f21d9a 100644 --- a/src/mesh/model/dot11s/hwmp-rtable.cc +++ b/src/mesh/model/dot11s/hwmp-rtable.cc @@ -70,7 +70,7 @@ HwmpRtable::AddReactivePath(Mac48Address destination, { NS_LOG_FUNCTION(this << destination << retransmitter << interface << metric << lifetime.GetSeconds() << seqnum); - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i == m_routes.end()) { ReactiveRoute newroute; @@ -113,7 +113,7 @@ HwmpRtable::AddPrecursor(Mac48Address destination, precursor.interface = precursorInterface; precursor.address = precursorAddress; precursor.whenExpire = Simulator::Now() + lifetime; - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i != m_routes.end()) { bool should_add = true; @@ -161,7 +161,7 @@ void HwmpRtable::DeleteReactivePath(Mac48Address destination) { NS_LOG_FUNCTION(this << destination); - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i != m_routes.end()) { m_routes.erase(i); @@ -172,7 +172,7 @@ HwmpRtable::LookupResult HwmpRtable::LookupReactive(Mac48Address destination) { NS_LOG_FUNCTION(this << destination); - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i == m_routes.end()) { return LookupResult(); @@ -189,7 +189,7 @@ HwmpRtable::LookupResult HwmpRtable::LookupReactiveExpired(Mac48Address destination) { NS_LOG_FUNCTION(this << destination); - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i == m_routes.end()) { return LookupResult(); @@ -232,8 +232,7 @@ HwmpRtable::GetUnreachableDestinations(Mac48Address peerAddress) NS_LOG_FUNCTION(this << peerAddress); HwmpProtocol::FailedDestination dst; std::vector retval; - for (std::map::iterator i = m_routes.begin(); i != m_routes.end(); - i++) + for (auto i = m_routes.begin(); i != m_routes.end(); i++) { if (i->second.retransmitter == peerAddress) { @@ -259,12 +258,10 @@ HwmpRtable::GetPrecursors(Mac48Address destination) NS_LOG_FUNCTION(this << destination); // We suppose that no duplicates here can be PrecursorList retval; - std::map::iterator route = m_routes.find(destination); + auto route = m_routes.find(destination); if (route != m_routes.end()) { - for (std::vector::const_iterator i = route->second.precursors.begin(); - i != route->second.precursors.end(); - i++) + for (auto i = route->second.precursors.begin(); i != route->second.precursors.end(); i++) { if (i->whenExpire > Simulator::Now()) { diff --git a/src/mesh/model/dot11s/hwmp-rtable.h b/src/mesh/model/dot11s/hwmp-rtable.h index 97c1296f8..dde479c19 100644 --- a/src/mesh/model/dot11s/hwmp-rtable.h +++ b/src/mesh/model/dot11s/hwmp-rtable.h @@ -20,7 +20,8 @@ #ifndef HWMP_RTABLE_H #define HWMP_RTABLE_H -#include "ns3/hwmp-protocol.h" +#include "hwmp-protocol.h" + #include "ns3/mac48-address.h" #include "ns3/nstime.h" diff --git a/src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc b/src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc index a6dcfc29c..a203dd8ab 100644 --- a/src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc +++ b/src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc @@ -99,9 +99,7 @@ IeBeaconTiming::AddNeighboursTimingElementUnit(uint16_t aid, Time last_beacon, T return; } // First we lookup if this element already exists - for (NeighboursTimingUnitsList::const_iterator i = m_neighbours.begin(); - i != m_neighbours.end(); - i++) + for (auto i = m_neighbours.begin(); i != m_neighbours.end(); i++) { if (((*i)->GetAid() == AidToU8(aid)) && ((*i)->GetLastBeacon() == TimestampToU16(last_beacon)) && @@ -121,7 +119,7 @@ IeBeaconTiming::AddNeighboursTimingElementUnit(uint16_t aid, Time last_beacon, T void IeBeaconTiming::DelNeighboursTimingElementUnit(uint16_t aid, Time last_beacon, Time beacon_interval) { - for (NeighboursTimingUnitsList::iterator i = m_neighbours.begin(); i != m_neighbours.end(); i++) + for (auto i = m_neighbours.begin(); i != m_neighbours.end(); i++) { if (((*i)->GetAid() == AidToU8(aid)) && ((*i)->GetLastBeacon() == TimestampToU16(last_beacon)) && @@ -137,7 +135,7 @@ IeBeaconTiming::DelNeighboursTimingElementUnit(uint16_t aid, Time last_beacon, T void IeBeaconTiming::ClearTimingElement() { - for (NeighboursTimingUnitsList::iterator j = m_neighbours.begin(); j != m_neighbours.end(); j++) + for (auto j = m_neighbours.begin(); j != m_neighbours.end(); j++) { (*j) = nullptr; } @@ -154,9 +152,7 @@ void IeBeaconTiming::Print(std::ostream& os) const { os << "BeaconTiming=(Number of units=" << (uint16_t)m_numOfUnits; - for (NeighboursTimingUnitsList::const_iterator j = m_neighbours.begin(); - j != m_neighbours.end(); - j++) + for (auto j = m_neighbours.begin(); j != m_neighbours.end(); j++) { os << "(AID=" << (uint16_t)(*j)->GetAid() << ", Last beacon at=" << (*j)->GetLastBeacon() << ", with beacon interval=" << (*j)->GetBeaconInterval() << ")"; @@ -167,9 +163,7 @@ IeBeaconTiming::Print(std::ostream& os) const void IeBeaconTiming::SerializeInformationField(Buffer::Iterator i) const { - for (NeighboursTimingUnitsList::const_iterator j = m_neighbours.begin(); - j != m_neighbours.end(); - j++) + for (auto j = m_neighbours.begin(); j != m_neighbours.end(); j++) { i.WriteU8((*j)->GetAid()); i.WriteHtolsbU16((*j)->GetLastBeacon()); @@ -223,7 +217,7 @@ IeBeaconTiming::operator==(const WifiInformationElement& a) const { try { - const IeBeaconTiming& aa = dynamic_cast(a); + const auto& aa = dynamic_cast(a); if (m_numOfUnits != aa.m_numOfUnits) { diff --git a/src/mesh/model/dot11s/ie-dot11s-perr.cc b/src/mesh/model/dot11s/ie-dot11s-perr.cc index 2c40cbb0a..79555cd95 100644 --- a/src/mesh/model/dot11s/ie-dot11s-perr.cc +++ b/src/mesh/model/dot11s/ie-dot11s-perr.cc @@ -140,9 +140,7 @@ IePerr::GetAddressUnitVector() const void IePerr::DeleteAddressUnit(Mac48Address address) { - for (std::vector::iterator i = m_addressUnits.begin(); - i != m_addressUnits.end(); - i++) + for (auto i = m_addressUnits.begin(); i != m_addressUnits.end(); i++) { if (i->destination == address) { diff --git a/src/mesh/model/dot11s/ie-dot11s-perr.h b/src/mesh/model/dot11s/ie-dot11s-perr.h index 72bc3633d..f5e9316d7 100644 --- a/src/mesh/model/dot11s/ie-dot11s-perr.h +++ b/src/mesh/model/dot11s/ie-dot11s-perr.h @@ -20,7 +20,8 @@ #ifndef PERR_INFORMATION_ELEMENT_H #define PERR_INFORMATION_ELEMENT_H -#include "ns3/hwmp-protocol.h" +#include "hwmp-protocol.h" + #include "ns3/mac48-address.h" #include "ns3/mesh-information-element-vector.h" diff --git a/src/mesh/model/dot11s/ie-dot11s-preq.cc b/src/mesh/model/dot11s/ie-dot11s-preq.cc index 88c2b5688..eef8b546b 100644 --- a/src/mesh/model/dot11s/ie-dot11s-preq.cc +++ b/src/mesh/model/dot11s/ie-dot11s-preq.cc @@ -266,9 +266,7 @@ IePreq::SerializeInformationField(Buffer::Iterator i) const i.WriteHtolsbU32(m_metric); i.WriteU8(m_destCount); int written = 0; - for (std::vector>::const_iterator j = m_destinations.begin(); - j != m_destinations.end(); - j++) + for (auto j = m_destinations.begin(); j != m_destinations.end(); j++) { uint8_t flags = 0; if ((*j)->IsDo()) @@ -386,9 +384,7 @@ IePreq::AddDestinationAddressElement(bool doFlag, Mac48Address dest_address, uint32_t dest_seq_number) { - for (std::vector>::const_iterator i = m_destinations.begin(); - i != m_destinations.end(); - i++) + for (auto i = m_destinations.begin(); i != m_destinations.end(); i++) { if ((*i)->GetDestinationAddress() == dest_address) { @@ -407,9 +403,7 @@ IePreq::AddDestinationAddressElement(bool doFlag, void IePreq::DelDestinationAddressElement(Mac48Address dest_address) { - for (std::vector>::iterator i = m_destinations.begin(); - i != m_destinations.end(); - i++) + for (auto i = m_destinations.begin(); i != m_destinations.end(); i++) { if ((*i)->GetDestinationAddress() == dest_address) { @@ -423,9 +417,7 @@ IePreq::DelDestinationAddressElement(Mac48Address dest_address) void IePreq::ClearDestinationAddressElements() { - for (std::vector>::iterator j = m_destinations.begin(); - j != m_destinations.end(); - j++) + for (auto j = m_destinations.begin(); j != m_destinations.end(); j++) { (*j) = nullptr; } diff --git a/src/mesh/model/dot11s/peer-link.cc b/src/mesh/model/dot11s/peer-link.cc index 0fd4b7412..14bbf5de5 100644 --- a/src/mesh/model/dot11s/peer-link.cc +++ b/src/mesh/model/dot11s/peer-link.cc @@ -19,7 +19,7 @@ * Pavel Boyko */ -#include "ns3/peer-link.h" +#include "peer-link.h" #include "peer-management-protocol-mac.h" diff --git a/src/mesh/model/dot11s/peer-link.h b/src/mesh/model/dot11s/peer-link.h index 321b354ba..89d9d12aa 100644 --- a/src/mesh/model/dot11s/peer-link.h +++ b/src/mesh/model/dot11s/peer-link.h @@ -21,11 +21,12 @@ #ifndef PEER_LINK_H #define PEER_LINK_H +#include "ie-dot11s-beacon-timing.h" +#include "ie-dot11s-configuration.h" +#include "ie-dot11s-peer-management.h" + #include "ns3/callback.h" #include "ns3/event-id.h" -#include "ns3/ie-dot11s-beacon-timing.h" -#include "ns3/ie-dot11s-configuration.h" -#include "ns3/ie-dot11s-peer-management.h" #include "ns3/mac48-address.h" #include "ns3/nstime.h" #include "ns3/object.h" diff --git a/src/mesh/model/dot11s/peer-management-protocol.cc b/src/mesh/model/dot11s/peer-management-protocol.cc index 5f2cb630a..7ab49548a 100644 --- a/src/mesh/model/dot11s/peer-management-protocol.cc +++ b/src/mesh/model/dot11s/peer-management-protocol.cc @@ -18,7 +18,7 @@ * Aleksey Kovalenko */ -#include "ns3/peer-management-protocol.h" +#include "peer-management-protocol.h" #include "ie-dot11s-configuration.h" #include "ie-dot11s-id.h" @@ -105,9 +105,9 @@ PeerManagementProtocol::DoDispose() { // cancel cleanup event and go through the map of peer links, // deleting each - for (PeerLinksMap::iterator j = m_peerLinks.begin(); j != m_peerLinks.end(); j++) + for (auto j = m_peerLinks.begin(); j != m_peerLinks.end(); j++) { - for (PeerLinksOnInterface::iterator i = j->second.begin(); i != j->second.end(); i++) + for (auto i = j->second.begin(); i != j->second.end(); i++) { (*i) = nullptr; } @@ -121,7 +121,7 @@ bool PeerManagementProtocol::Install(Ptr mp) { std::vector> interfaces = mp->GetInterfaces(); - for (std::vector>::iterator i = interfaces.begin(); i != interfaces.end(); i++) + for (auto i = interfaces.begin(); i != interfaces.end(); i++) { Ptr wifiNetDev = (*i)->GetObject(); if (!wifiNetDev) @@ -154,9 +154,9 @@ PeerManagementProtocol::GetBeaconTimingElement(uint32_t interface) return nullptr; } Ptr retval = Create(); - PeerLinksMap::iterator iface = m_peerLinks.find(interface); + auto iface = m_peerLinks.find(interface); NS_ASSERT(iface != m_peerLinks.end()); - for (PeerLinksOnInterface::iterator i = iface->second.begin(); i != iface->second.end(); i++) + for (auto i = iface->second.begin(); i != iface->second.end(); i++) { // If we do not know peer Assoc Id, we shall not add any info // to a beacon timing element @@ -180,8 +180,7 @@ PeerManagementProtocol::ReceiveBeacon(uint32_t interface, { // PM STATE Machine // Check that a given beacon is not from our interface - for (PeerManagementProtocolMacMap::const_iterator i = m_plugins.begin(); i != m_plugins.end(); - i++) + for (auto i = m_plugins.begin(); i != m_plugins.end(); i++) { if (i->second->GetAddress() == peerAddress) { @@ -304,9 +303,9 @@ PeerManagementProtocol::InitiateLink(uint32_t interface, NS_FATAL_ERROR("Peer link must not exist."); } // Plugin must exist - PeerManagementProtocolMacMap::iterator plugin = m_plugins.find(interface); + auto plugin = m_plugins.find(interface); NS_ASSERT(plugin != m_plugins.end()); - PeerLinksMap::iterator iface = m_peerLinks.find(interface); + auto iface = m_peerLinks.find(interface); NS_ASSERT(iface != m_peerLinks.end()); new_link->SetLocalAid(m_lastAssocId++); new_link->SetInterface(interface); @@ -323,9 +322,9 @@ PeerManagementProtocol::InitiateLink(uint32_t interface, Ptr PeerManagementProtocol::FindPeerLink(uint32_t interface, Mac48Address peerAddress) { - PeerLinksMap::iterator iface = m_peerLinks.find(interface); + auto iface = m_peerLinks.find(interface); NS_ASSERT(iface != m_peerLinks.end()); - for (PeerLinksOnInterface::iterator i = iface->second.begin(); i != iface->second.end(); i++) + for (auto i = iface->second.begin(); i != iface->second.end(); i++) { if ((*i)->GetPeerAddress() == peerAddress) { @@ -355,10 +354,9 @@ std::vector PeerManagementProtocol::GetPeers(uint32_t interface) const { std::vector retval; - PeerLinksMap::const_iterator iface = m_peerLinks.find(interface); + auto iface = m_peerLinks.find(interface); NS_ASSERT(iface != m_peerLinks.end()); - for (PeerLinksOnInterface::const_iterator i = iface->second.begin(); i != iface->second.end(); - i++) + for (auto i = iface->second.begin(); i != iface->second.end(); i++) { if ((*i)->LinkIsEstab()) { @@ -373,12 +371,9 @@ PeerManagementProtocol::GetPeerLinks() const { std::vector> links; - for (PeerLinksMap::const_iterator iface = m_peerLinks.begin(); iface != m_peerLinks.end(); - ++iface) + for (auto iface = m_peerLinks.begin(); iface != m_peerLinks.end(); ++iface) { - for (PeerLinksOnInterface::const_iterator i = iface->second.begin(); - i != iface->second.end(); - i++) + for (auto i = iface->second.begin(); i != iface->second.end(); i++) { if ((*i)->LinkIsEstab()) { @@ -426,19 +421,18 @@ PeerManagementProtocol::CheckBeaconCollisions(uint32_t interface) { return; } - PeerLinksMap::iterator iface = m_peerLinks.find(interface); + auto iface = m_peerLinks.find(interface); NS_ASSERT(iface != m_peerLinks.end()); NS_ASSERT(m_plugins.find(interface) != m_plugins.end()); - std::map::const_iterator lastBeacon = m_lastBeacon.find(interface); - std::map::const_iterator beaconInterval = m_beaconInterval.find(interface); + auto lastBeacon = m_lastBeacon.find(interface); + auto beaconInterval = m_beaconInterval.find(interface); if ((lastBeacon == m_lastBeacon.end()) || (beaconInterval == m_beaconInterval.end())) { return; } // my last beacon in 256 us units - uint16_t lastBeaconInTimeElement = - (uint16_t)((lastBeacon->second.GetMicroSeconds() >> 8) & 0xffff); + auto lastBeaconInTimeElement = (uint16_t)((lastBeacon->second.GetMicroSeconds() >> 8) & 0xffff); NS_ASSERT_MSG(TuToTime(m_maxBeaconShift) <= m_beaconInterval[interface], "Wrong beacon shift parameters"); @@ -451,14 +445,12 @@ PeerManagementProtocol::CheckBeaconCollisions(uint32_t interface) } // check whether all my peers receive my beacon and I'am not in collision with other beacons - for (PeerLinksOnInterface::iterator i = iface->second.begin(); i != iface->second.end(); i++) + for (auto i = iface->second.begin(); i != iface->second.end(); i++) { bool myBeaconExists = false; IeBeaconTiming::NeighboursTimingUnitsList neighbors = (*i)->GetBeaconTimingElement().GetNeighboursTimingElementsList(); - for (IeBeaconTiming::NeighboursTimingUnitsList::const_iterator j = neighbors.begin(); - j != neighbors.end(); - j++) + for (auto j = neighbors.begin(); j != neighbors.end(); j++) { if ((*i)->GetPeerAid() == (*j)->GetAid()) { @@ -494,7 +486,7 @@ PeerManagementProtocol::ShiftOwnBeacon(uint32_t interface) shift = (int)m_beaconShift->GetValue(); } while (shift == 0); // Apply beacon shift parameters: - PeerManagementProtocolMacMap::iterator plugin = m_plugins.find(interface); + auto plugin = m_plugins.find(interface); NS_ASSERT(plugin != m_plugins.end()); plugin->second->SetBeaconShift(TuToTime(shift)); } @@ -550,7 +542,7 @@ PeerManagementProtocol::PeerLinkStatus(uint32_t interface, PeerLink::PeerState ostate, PeerLink::PeerState nstate) { - PeerManagementProtocolMacMap::iterator plugin = m_plugins.find(interface); + auto plugin = m_plugins.find(interface); NS_ASSERT(plugin != m_plugins.end()); NS_LOG_DEBUG("Link between me:" << m_address << " my interface:" << plugin->second->GetAddress() << " and peer mesh point:" << peerMeshPointAddress @@ -635,18 +627,14 @@ PeerManagementProtocol::Report(std::ostream& os) const { os << "" << std::endl; m_stats.Print(os); - for (PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin(); - plugins != m_plugins.end(); - plugins++) + for (auto plugins = m_plugins.begin(); plugins != m_plugins.end(); plugins++) { // Take statistics from plugin: plugins->second->Report(os); // Print all active peer links: - PeerLinksMap::const_iterator iface = m_peerLinks.find(plugins->second->m_ifIndex); + auto iface = m_peerLinks.find(plugins->second->m_ifIndex); NS_ASSERT(iface != m_peerLinks.end()); - for (PeerLinksOnInterface::const_iterator i = iface->second.begin(); - i != iface->second.end(); - i++) + for (auto i = iface->second.begin(); i != iface->second.end(); i++) { (*i)->Report(os); } @@ -658,9 +646,7 @@ void PeerManagementProtocol::ResetStats() { m_stats = Statistics(m_stats.linksTotal); // don't reset number of links - for (PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin(); - plugins != m_plugins.end(); - plugins++) + for (auto plugins = m_plugins.begin(); plugins != m_plugins.end(); plugins++) { plugins->second->ResetStats(); } diff --git a/src/mesh/model/flame/flame-protocol.cc b/src/mesh/model/flame/flame-protocol.cc index d4dc1cce1..e046b5b14 100644 --- a/src/mesh/model/flame/flame-protocol.cc +++ b/src/mesh/model/flame/flame-protocol.cc @@ -324,8 +324,7 @@ FlameProtocol::Install(Ptr mp) { m_mp = mp; std::vector> interfaces = mp->GetInterfaces(); - for (std::vector>::const_iterator i = interfaces.begin(); i != interfaces.end(); - i++) + for (auto i = interfaces.begin(); i != interfaces.end(); i++) { // Checking for compatible net device Ptr wifiNetDev = (*i)->GetObject(); @@ -423,8 +422,7 @@ FlameProtocol::Report(std::ostream& os) const << "broadcastInterval=\"" << m_broadcastInterval.GetSeconds() << "\"" << std::endl << "maxCost=\"" << (uint16_t)m_maxCost << "\">" << std::endl; m_stats.Print(os); - for (FlamePluginMap::const_iterator plugin = m_interfaces.begin(); plugin != m_interfaces.end(); - plugin++) + for (auto plugin = m_interfaces.begin(); plugin != m_interfaces.end(); plugin++) { plugin->second->Report(os); } @@ -435,8 +433,7 @@ void FlameProtocol::ResetStats() { m_stats = Statistics(); - for (FlamePluginMap::const_iterator plugin = m_interfaces.begin(); plugin != m_interfaces.end(); - plugin++) + for (auto plugin = m_interfaces.begin(); plugin != m_interfaces.end(); plugin++) { plugin->second->ResetStats(); } diff --git a/src/mesh/model/flame/flame-rtable.cc b/src/mesh/model/flame/flame-rtable.cc index 2bbc097be..e885270c6 100644 --- a/src/mesh/model/flame/flame-rtable.cc +++ b/src/mesh/model/flame/flame-rtable.cc @@ -70,7 +70,7 @@ FlameRtable::AddPath(const Mac48Address destination, const uint8_t cost, const uint16_t seqnum) { - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i == m_routes.end()) { Route newroute; @@ -93,7 +93,7 @@ FlameRtable::AddPath(const Mac48Address destination, FlameRtable::LookupResult FlameRtable::Lookup(Mac48Address destination) { - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i == m_routes.end()) { return LookupResult(); diff --git a/src/mesh/model/mesh-information-element-vector.cc b/src/mesh/model/mesh-information-element-vector.cc index 26a05e654..bb58b0234 100644 --- a/src/mesh/model/mesh-information-element-vector.cc +++ b/src/mesh/model/mesh-information-element-vector.cc @@ -47,7 +47,7 @@ MeshInformationElementVector::MeshInformationElementVector() MeshInformationElementVector::~MeshInformationElementVector() { - for (IE_VECTOR::iterator i = m_elements.begin(); i != m_elements.end(); i++) + for (auto i = m_elements.begin(); i != m_elements.end(); i++) { *i = nullptr; } @@ -79,7 +79,7 @@ MeshInformationElementVector::GetSerializedSize() const void MeshInformationElementVector::Serialize(Buffer::Iterator start) const { - for (IE_VECTOR::const_iterator i = m_elements.begin(); i != m_elements.end(); i++) + for (auto i = m_elements.begin(); i != m_elements.end(); i++) { start = (*i)->Serialize(start); } @@ -164,7 +164,7 @@ MeshInformationElementVector::DeserializeSingleIe(Buffer::Iterator start) void MeshInformationElementVector::Print(std::ostream& os) const { - for (IE_VECTOR::const_iterator i = m_elements.begin(); i != m_elements.end(); i++) + for (auto i = m_elements.begin(); i != m_elements.end(); i++) { os << "("; (*i)->Print(os); @@ -198,7 +198,7 @@ MeshInformationElementVector::AddInformationElement(Ptr Ptr MeshInformationElementVector::FindFirst(WifiInformationElementId id) const { - for (IE_VECTOR::const_iterator i = m_elements.begin(); i != m_elements.end(); i++) + for (auto i = m_elements.begin(); i != m_elements.end(); i++) { if ((*i)->ElementId() == id) { @@ -212,7 +212,7 @@ uint32_t MeshInformationElementVector::GetSize() const { uint32_t size = 0; - for (IE_VECTOR::const_iterator i = m_elements.begin(); i != m_elements.end(); i++) + for (auto i = m_elements.begin(); i != m_elements.end(); i++) { size += (*i)->GetSerializedSize(); } @@ -234,10 +234,8 @@ MeshInformationElementVector::operator==(const MeshInformationElementVector& a) // I'm leaving it like this, however, so that there is the option of // having individual Information Elements implement slightly more // flexible equality operators. - MeshInformationElementVector::IE_VECTOR::const_iterator j = a.m_elements.begin(); - for (MeshInformationElementVector::IE_VECTOR::const_iterator i = m_elements.begin(); - i != m_elements.end(); - i++, j++) + auto j = a.m_elements.begin(); + for (auto i = m_elements.begin(); i != m_elements.end(); i++, j++) { if (!(*(*i) == *(*j))) { diff --git a/src/mesh/model/mesh-l2-routing-protocol.cc b/src/mesh/model/mesh-l2-routing-protocol.cc index 67788dff7..c7a8bf603 100644 --- a/src/mesh/model/mesh-l2-routing-protocol.cc +++ b/src/mesh/model/mesh-l2-routing-protocol.cc @@ -18,10 +18,11 @@ * Pavel Boyko */ -#include "ns3/mesh-l2-routing-protocol.h" +#include "mesh-l2-routing-protocol.h" + +#include "mesh-point-device.h" #include "ns3/log.h" -#include "ns3/mesh-point-device.h" namespace ns3 { diff --git a/src/mesh/model/mesh-point-device.cc b/src/mesh/model/mesh-point-device.cc index 68fe8f8ab..8e6bc37d1 100644 --- a/src/mesh/model/mesh-point-device.cc +++ b/src/mesh/model/mesh-point-device.cc @@ -18,10 +18,11 @@ * Pavel Boyko */ -#include "ns3/mesh-point-device.h" +#include "mesh-point-device.h" + +#include "mesh-wifi-interface-mac.h" #include "ns3/log.h" -#include "ns3/mesh-wifi-interface-mac.h" #include "ns3/packet.h" #include "ns3/pointer.h" #include "ns3/simulator.h" @@ -82,8 +83,7 @@ void MeshPointDevice::DoDispose() { NS_LOG_FUNCTION(this); - for (std::vector>::iterator iter = m_ifaces.begin(); iter != m_ifaces.end(); - iter++) + for (auto iter = m_ifaces.begin(); iter != m_ifaces.end(); iter++) { *iter = nullptr; } @@ -398,7 +398,7 @@ Ptr MeshPointDevice::GetInterface(uint32_t n) const { NS_LOG_FUNCTION(this << n); - for (std::vector>::const_iterator i = m_ifaces.begin(); i != m_ifaces.end(); i++) + for (auto i = m_ifaces.begin(); i != m_ifaces.end(); i++) { if ((*i)->GetIfIndex() == n) { @@ -515,7 +515,7 @@ MeshPointDevice::DoSend(bool success, } else { - for (std::vector>::iterator i = m_ifaces.begin(); i != m_ifaces.end(); i++) + for (auto i = m_ifaces.begin(); i != m_ifaces.end(); i++) { (*i)->SendFrom(packet->Copy(), src, dst, protocol); } diff --git a/src/mesh/model/mesh-point-device.h b/src/mesh/model/mesh-point-device.h index cd72444f1..fc0bbfd21 100644 --- a/src/mesh/model/mesh-point-device.h +++ b/src/mesh/model/mesh-point-device.h @@ -21,9 +21,10 @@ #ifndef L2ROUTING_NET_DEVICE_H #define L2ROUTING_NET_DEVICE_H +#include "mesh-l2-routing-protocol.h" + #include "ns3/bridge-channel.h" #include "ns3/mac48-address.h" -#include "ns3/mesh-l2-routing-protocol.h" #include "ns3/net-device.h" #include "ns3/node.h" #include "ns3/random-variable-stream.h" diff --git a/src/mesh/model/mesh-wifi-beacon.cc b/src/mesh/model/mesh-wifi-beacon.cc index dcbf83124..3ba309823 100644 --- a/src/mesh/model/mesh-wifi-beacon.cc +++ b/src/mesh/model/mesh-wifi-beacon.cc @@ -17,7 +17,7 @@ * Author: Pavel Boyko */ -#include "ns3/mesh-wifi-beacon.h" +#include "mesh-wifi-beacon.h" #include "ns3/nstime.h" #include "ns3/wifi-mac-header.h" diff --git a/src/mesh/model/mesh-wifi-beacon.h b/src/mesh/model/mesh-wifi-beacon.h index d3cb1ce38..60cf0ac99 100644 --- a/src/mesh/model/mesh-wifi-beacon.h +++ b/src/mesh/model/mesh-wifi-beacon.h @@ -20,7 +20,8 @@ #ifndef MESH_WIFI_BEACON_H #define MESH_WIFI_BEACON_H -#include "ns3/mesh-information-element-vector.h" +#include "mesh-information-element-vector.h" + #include "ns3/mgt-headers.h" #include "ns3/object.h" #include "ns3/packet.h" diff --git a/src/mesh/model/mesh-wifi-interface-mac-plugin.h b/src/mesh/model/mesh-wifi-interface-mac-plugin.h index 74dd3366d..2385f3502 100644 --- a/src/mesh/model/mesh-wifi-interface-mac-plugin.h +++ b/src/mesh/model/mesh-wifi-interface-mac-plugin.h @@ -20,8 +20,9 @@ #ifndef MESH_WIFI_INTERFACE_MAC_PLUGIN_H #define MESH_WIFI_INTERFACE_MAC_PLUGIN_H +#include "mesh-wifi-beacon.h" + #include "ns3/mac48-address.h" -#include "ns3/mesh-wifi-beacon.h" #include "ns3/packet.h" #include "ns3/simple-ref-count.h" diff --git a/src/mesh/model/mesh-wifi-interface-mac.cc b/src/mesh/model/mesh-wifi-interface-mac.cc index 540aebc92..4c5be44ac 100644 --- a/src/mesh/model/mesh-wifi-interface-mac.cc +++ b/src/mesh/model/mesh-wifi-interface-mac.cc @@ -18,14 +18,15 @@ * Pavel Boyko */ -#include "ns3/mesh-wifi-interface-mac.h" +#include "mesh-wifi-interface-mac.h" + +#include "mesh-wifi-beacon.h" #include "ns3/boolean.h" #include "ns3/channel-access-manager.h" #include "ns3/double.h" #include "ns3/log.h" #include "ns3/mac-tx-middle.h" -#include "ns3/mesh-wifi-beacon.h" #include "ns3/pointer.h" #include "ns3/qos-txop.h" #include "ns3/random-variable-stream.h" @@ -166,7 +167,7 @@ MeshWifiInterfaceMac::AssignStreams(int64_t stream) NS_LOG_FUNCTION(this << stream); int64_t currentStream = stream; m_coefficient->SetStream(currentStream++); - for (PluginList::const_iterator i = m_plugins.begin(); i < m_plugins.end(); i++) + for (auto i = m_plugins.begin(); i < m_plugins.end(); i++) { currentStream += (*i)->AssignStreams(currentStream); } @@ -239,7 +240,7 @@ MeshWifiInterfaceMac::ForwardDown(Ptr packet, Mac48Address from, Mac48Ad // Address 1 is unknown here. Routing plugin is responsible to correctly set it. hdr.SetAddr1(Mac48Address()); // Filter packet through all installed plugins - for (PluginList::const_iterator i = m_plugins.end() - 1; i != m_plugins.begin() - 1; i--) + for (auto i = m_plugins.end() - 1; i != m_plugins.begin() - 1; i--) { bool drop = !((*i)->UpdateOutcomingFrame(packet, hdr, from, to)); if (drop) @@ -285,7 +286,7 @@ MeshWifiInterfaceMac::SendManagementFrame(Ptr packet, const WifiMacHeade { // Filter management frames: WifiMacHeader header = hdr; - for (PluginList::const_iterator i = m_plugins.end() - 1; i != m_plugins.begin() - 1; i--) + for (auto i = m_plugins.end() - 1; i != m_plugins.begin() - 1; i--) { bool drop = !((*i)->UpdateOutcomingFrame(packet, header, Mac48Address(), Mac48Address())); if (drop) @@ -428,7 +429,7 @@ MeshWifiInterfaceMac::SendBeacon() MeshWifiBeacon beacon(GetSsid(), GetSupportedRates(), m_beaconInterval.GetMicroSeconds()); // Ask all plugins to add their specific information elements to beacon - for (PluginList::const_iterator i = m_plugins.begin(); i != m_plugins.end(); ++i) + for (auto i = m_plugins.begin(); i != m_plugins.end(); ++i) { (*i)->UpdateBeacon(beacon); } @@ -486,7 +487,7 @@ MeshWifiInterfaceMac::Receive(Ptr mpdu, uint8_t linkId) m_stats.recvFrames++; } // Filter frame through all installed plugins - for (PluginList::iterator i = m_plugins.begin(); i != m_plugins.end(); ++i) + for (auto i = m_plugins.begin(); i != m_plugins.end(); ++i) { bool drop = !((*i)->Receive(packet, *hdr)); if (drop) diff --git a/src/mesh/model/mesh-wifi-interface-mac.h b/src/mesh/model/mesh-wifi-interface-mac.h index e6ceaa16e..42871e08f 100644 --- a/src/mesh/model/mesh-wifi-interface-mac.h +++ b/src/mesh/model/mesh-wifi-interface-mac.h @@ -21,10 +21,11 @@ #ifndef MESH_WIFI_INTERFACE_MAC_H #define MESH_WIFI_INTERFACE_MAC_H +#include "mesh-wifi-interface-mac-plugin.h" + #include "ns3/callback.h" #include "ns3/event-id.h" #include "ns3/mac48-address.h" -#include "ns3/mesh-wifi-interface-mac-plugin.h" #include "ns3/mgt-headers.h" #include "ns3/nstime.h" #include "ns3/packet.h" diff --git a/src/mesh/test/dot11s/dot11s-test-suite.cc b/src/mesh/test/dot11s/dot11s-test-suite.cc index 99b0744ec..b1cdaa3b8 100644 --- a/src/mesh/test/dot11s/dot11s-test-suite.cc +++ b/src/mesh/test/dot11s/dot11s-test-suite.cc @@ -186,8 +186,7 @@ HwmpRtableTest::TestExpire() void HwmpRtableTest::TestPrecursorAdd() { - for (std::vector::const_iterator i = precursors.begin(); i != precursors.end(); - i++) + for (auto i = precursors.begin(); i != precursors.end(); i++) { table->AddPrecursor(dst, iface, *i, Seconds(100)); // Check that duplicates are filtered diff --git a/src/mobility/CMakeLists.txt b/src/mobility/CMakeLists.txt index edab43a26..8722eeb32 100644 --- a/src/mobility/CMakeLists.txt +++ b/src/mobility/CMakeLists.txt @@ -50,6 +50,7 @@ build_lib( test/mobility-trace-test-suite.cc test/ns2-mobility-helper-test-suite.cc test/rand-cart-around-geo-test.cc + test/rectangle-closest-border-test.cc test/steady-state-random-waypoint-mobility-model-test.cc test/waypoint-mobility-model-test.cc ) diff --git a/src/mobility/examples/main-grid-topology.cc b/src/mobility/examples/main-grid-topology.cc index 8941b00ea..c1c7fc493 100644 --- a/src/mobility/examples/main-grid-topology.cc +++ b/src/mobility/examples/main-grid-topology.cc @@ -61,7 +61,7 @@ main(int argc, char* argv[]) mobility.Install(nodes); // iterate our nodes and print their position. - for (NodeContainer::Iterator j = nodes.Begin(); j != nodes.End(); ++j) + for (auto j = nodes.Begin(); j != nodes.End(); ++j) { Ptr object = *j; Ptr position = object->GetObject(); diff --git a/src/mobility/helper/group-mobility-helper.cc b/src/mobility/helper/group-mobility-helper.cc index 36f062cba..e7834756e 100644 --- a/src/mobility/helper/group-mobility-helper.cc +++ b/src/mobility/helper/group-mobility-helper.cc @@ -19,7 +19,7 @@ * Adapted from 'mobility-helper.cc' for group mobility by Tom Henderson */ -#include "ns3/group-mobility-helper.h" +#include "group-mobility-helper.h" #include "ns3/config.h" #include "ns3/hierarchical-mobility-model.h" @@ -101,7 +101,7 @@ GroupMobilityHelper::Install(std::string nodeName) void GroupMobilityHelper::Install(NodeContainer c) { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Install(*i); } @@ -114,7 +114,7 @@ GroupMobilityHelper::AssignStreams(NodeContainer c, int64_t stream) Ptr node; bool firstNode = true; Ptr mobility; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); mobility = node->GetObject(); diff --git a/src/mobility/helper/mobility-helper.cc b/src/mobility/helper/mobility-helper.cc index 0374ae75b..7047ce788 100644 --- a/src/mobility/helper/mobility-helper.cc +++ b/src/mobility/helper/mobility-helper.cc @@ -16,7 +16,7 @@ * * Author: Mathieu Lacage */ -#include "ns3/mobility-helper.h" +#include "mobility-helper.h" #include "ns3/config.h" #include "ns3/hierarchical-mobility-model.h" @@ -126,7 +126,7 @@ MobilityHelper::Install(std::string nodeName) const void MobilityHelper::Install(NodeContainer c) const { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Install(*i); } @@ -201,7 +201,7 @@ MobilityHelper::EnableAscii(Ptr stream, uint32_t nodeid) void MobilityHelper::EnableAscii(Ptr stream, NodeContainer n) { - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { EnableAscii(stream, (*i)->GetId()); } @@ -219,7 +219,7 @@ MobilityHelper::AssignStreams(NodeContainer c, int64_t stream) int64_t currentStream = stream; Ptr node; Ptr mobility; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); mobility = node->GetObject(); diff --git a/src/mobility/helper/ns2-mobility-helper.cc b/src/mobility/helper/ns2-mobility-helper.cc index 9a0fe0f88..790a662f8 100644 --- a/src/mobility/helper/ns2-mobility-helper.cc +++ b/src/mobility/helper/ns2-mobility-helper.cc @@ -523,7 +523,7 @@ ParseNs2Line(const std::string& str) { std::string x; s >> x; - if (x.length() == 0) + if (x.empty()) { continue; } diff --git a/src/mobility/model/constant-velocity-helper.cc b/src/mobility/model/constant-velocity-helper.cc index c7efee912..18f669229 100644 --- a/src/mobility/model/constant-velocity-helper.cc +++ b/src/mobility/model/constant-velocity-helper.cc @@ -18,9 +18,10 @@ */ #include "constant-velocity-helper.h" -#include "ns3/box.h" +#include "box.h" +#include "rectangle.h" + #include "ns3/log.h" -#include "ns3/rectangle.h" #include "ns3/simulator.h" namespace ns3 diff --git a/src/mobility/model/constant-velocity-helper.h b/src/mobility/model/constant-velocity-helper.h index 53abe6cb0..dcf9b5891 100644 --- a/src/mobility/model/constant-velocity-helper.h +++ b/src/mobility/model/constant-velocity-helper.h @@ -19,7 +19,8 @@ #ifndef CONSTANT_VELOCITY_HELPER_H #define CONSTANT_VELOCITY_HELPER_H -#include "ns3/box.h" +#include "box.h" + #include "ns3/nstime.h" #include "ns3/vector.h" diff --git a/src/mobility/model/gauss-markov-mobility-model.h b/src/mobility/model/gauss-markov-mobility-model.h index 4d092c8c3..809fdcf00 100644 --- a/src/mobility/model/gauss-markov-mobility-model.h +++ b/src/mobility/model/gauss-markov-mobility-model.h @@ -21,11 +21,11 @@ #ifndef GAUSS_MARKOV_MOBILITY_MODEL_H #define GAUSS_MARKOV_MOBILITY_MODEL_H +#include "box.h" #include "constant-velocity-helper.h" #include "mobility-model.h" #include "position-allocator.h" -#include "ns3/box.h" #include "ns3/event-id.h" #include "ns3/nstime.h" #include "ns3/object.h" diff --git a/src/mobility/model/random-direction-2d-mobility-model.cc b/src/mobility/model/random-direction-2d-mobility-model.cc index 4e87f1faf..b163380f2 100644 --- a/src/mobility/model/random-direction-2d-mobility-model.cc +++ b/src/mobility/model/random-direction-2d-mobility-model.cc @@ -117,23 +117,36 @@ RandomDirection2dMobilityModel::SetDirectionAndSpeed(double direction) void RandomDirection2dMobilityModel::ResetDirectionAndSpeed() { - double direction = m_direction->GetValue(0, M_PI); + double direction = 0; m_helper.UpdateWithBounds(m_bounds); Vector position = m_helper.GetCurrentPosition(); - switch (m_bounds.GetClosestSide(position)) + switch (m_bounds.GetClosestSideOrCorner(position)) { - case Rectangle::RIGHT: + case Rectangle::RIGHTSIDE: + direction = m_direction->GetValue(M_PI_2, M_PI + M_PI_2); + break; + case Rectangle::LEFTSIDE: + direction = m_direction->GetValue(-M_PI_2, M_PI - M_PI_2); + break; + case Rectangle::TOPSIDE: + direction = m_direction->GetValue(M_PI, 2 * M_PI); + break; + case Rectangle::BOTTOMSIDE: + direction = m_direction->GetValue(0, M_PI); + break; + case Rectangle::TOPRIGHTCORNER: + direction = m_direction->GetValue(M_PI, M_PI + M_PI_2); + break; + case Rectangle::TOPLEFTCORNER: + direction = m_direction->GetValue(M_PI + M_PI_2, 2 * M_PI); + break; + case Rectangle::BOTTOMRIGHTCORNER: + direction = m_direction->GetValue(0, M_PI_2); direction += M_PI / 2; break; - case Rectangle::LEFT: - direction += -M_PI / 2; - break; - case Rectangle::TOP: - direction += M_PI; - break; - case Rectangle::BOTTOM: - direction += 0.0; + case Rectangle::BOTTOMLEFTCORNER: + direction = m_direction->GetValue(M_PI_2, M_PI); break; } SetDirectionAndSpeed(direction); diff --git a/src/mobility/model/random-direction-2d-mobility-model.h b/src/mobility/model/random-direction-2d-mobility-model.h index dd35949fc..aa1b039a0 100644 --- a/src/mobility/model/random-direction-2d-mobility-model.h +++ b/src/mobility/model/random-direction-2d-mobility-model.h @@ -21,13 +21,13 @@ #include "constant-velocity-helper.h" #include "mobility-model.h" +#include "rectangle.h" #include "ns3/event-id.h" #include "ns3/nstime.h" #include "ns3/object.h" #include "ns3/ptr.h" #include "ns3/random-variable-stream.h" -#include "ns3/rectangle.h" namespace ns3 { @@ -40,7 +40,7 @@ namespace ns3 * pauses for a specific delay, chooses a random direction and speed and * then travels in the specific direction until it reaches one of * the boundaries of the model. When it reaches the boundary, it pauses, - * selects a new direction and speed, aso. + * and selects a new direction and speed. */ class RandomDirection2dMobilityModel : public MobilityModel { diff --git a/src/mobility/model/random-walk-2d-mobility-model.cc b/src/mobility/model/random-walk-2d-mobility-model.cc index 70e5f59b4..236c3d379 100644 --- a/src/mobility/model/random-walk-2d-mobility-model.cc +++ b/src/mobility/model/random-walk-2d-mobility-model.cc @@ -90,8 +90,46 @@ void RandomWalk2dMobilityModel::DoInitializePrivate() { m_helper.Update(); + Vector position = m_helper.GetCurrentPosition(); + double speed = m_speed->GetValue(); - double direction = m_direction->GetValue(); + double direction = 0; + if (!m_bounds.IsOnTheBorder(position)) + { + direction = m_direction->GetValue(); + } + else + { + Ptr directionOverride = CreateObject(); + switch (m_bounds.GetClosestSideOrCorner(position)) + { + case Rectangle::RIGHTSIDE: + direction = directionOverride->GetValue(M_PI_2, M_PI + M_PI_2); + break; + case Rectangle::LEFTSIDE: + direction = directionOverride->GetValue(-M_PI_2, M_PI - M_PI_2); + break; + case Rectangle::TOPSIDE: + direction = directionOverride->GetValue(M_PI, 2 * M_PI); + break; + case Rectangle::BOTTOMSIDE: + direction = directionOverride->GetValue(0, M_PI); + break; + case Rectangle::TOPRIGHTCORNER: + direction = directionOverride->GetValue(M_PI, M_PI + M_PI_2); + break; + case Rectangle::TOPLEFTCORNER: + direction = directionOverride->GetValue(M_PI + M_PI_2, 2 * M_PI); + break; + case Rectangle::BOTTOMRIGHTCORNER: + direction = directionOverride->GetValue(0, M_PI_2); + direction += M_PI / 2; + break; + case Rectangle::BOTTOMLEFTCORNER: + direction = directionOverride->GetValue(M_PI_2, M_PI); + break; + } + } Vector vector(std::cos(direction) * speed, std::sin(direction) * speed, 0.0); m_helper.SetVelocity(vector); m_helper.Unpause(); @@ -125,7 +163,23 @@ RandomWalk2dMobilityModel::DoWalk(Time delayLeft) else { nextPosition = m_bounds.CalculateIntersection(position, speed); - Time delay = Seconds((nextPosition.x - position.x) / speed.x); + double delaySeconds = std::numeric_limits::max(); + if (speed.x != 0) + { + delaySeconds = + std::min(delaySeconds, std::abs((nextPosition.x - position.x) / speed.x)); + } + else if (speed.y != 0) + { + delaySeconds = + std::min(delaySeconds, std::abs((nextPosition.y - position.y) / speed.y)); + } + else + { + NS_ABORT_MSG("RandomWalk2dMobilityModel::DoWalk: unable to calculate the rebound time " + "(the node is stationary)."); + } + Time delay = Seconds(delaySeconds); m_event = Simulator::Schedule(delay, &RandomWalk2dMobilityModel::Rebound, this, @@ -140,16 +194,24 @@ RandomWalk2dMobilityModel::Rebound(Time delayLeft) m_helper.UpdateWithBounds(m_bounds); Vector position = m_helper.GetCurrentPosition(); Vector speed = m_helper.GetVelocity(); - switch (m_bounds.GetClosestSide(position)) + switch (m_bounds.GetClosestSideOrCorner(position)) { - case Rectangle::RIGHT: - case Rectangle::LEFT: + case Rectangle::RIGHTSIDE: + case Rectangle::LEFTSIDE: speed.x = -speed.x; break; - case Rectangle::TOP: - case Rectangle::BOTTOM: + case Rectangle::TOPSIDE: + case Rectangle::BOTTOMSIDE: speed.y = -speed.y; break; + case Rectangle::TOPRIGHTCORNER: + case Rectangle::BOTTOMRIGHTCORNER: + case Rectangle::TOPLEFTCORNER: + case Rectangle::BOTTOMLEFTCORNER: + auto temp = speed.x; + speed.x = -speed.y; + speed.y = -temp; + break; } m_helper.SetVelocity(speed); m_helper.Unpause(); diff --git a/src/mobility/model/random-walk-2d-mobility-model.h b/src/mobility/model/random-walk-2d-mobility-model.h index 4a7a0f5ae..61cb286ae 100644 --- a/src/mobility/model/random-walk-2d-mobility-model.h +++ b/src/mobility/model/random-walk-2d-mobility-model.h @@ -21,12 +21,12 @@ #include "constant-velocity-helper.h" #include "mobility-model.h" +#include "rectangle.h" #include "ns3/event-id.h" #include "ns3/nstime.h" #include "ns3/object.h" #include "ns3/random-variable-stream.h" -#include "ns3/rectangle.h" namespace ns3 { @@ -42,6 +42,11 @@ namespace ns3 * of the model, we rebound on the boundary with a reflexive angle * and speed. This model is often identified as a brownian motion * model. + * + * The Direction random variable is used for any point strictly + * inside the boundaries. The points on the boundary have their + * direction chosen randomly, without considering the Direction + * Attribute. */ class RandomWalk2dMobilityModel : public MobilityModel { diff --git a/src/mobility/model/rectangle.cc b/src/mobility/model/rectangle.cc index ef612fe2a..6360c7756 100644 --- a/src/mobility/model/rectangle.cc +++ b/src/mobility/model/rectangle.cc @@ -23,6 +23,7 @@ #include "ns3/vector.h" #include +#include #include #include @@ -52,126 +53,99 @@ Rectangle::IsInside(const Vector& position) const position.y >= this->yMin; } -Rectangle::Side -Rectangle::GetClosestSide(const Vector& position) const +bool +Rectangle::IsOnTheBorder(const Vector& position) const { - if (IsInside(position)) + return position.x == this->xMax || position.x == this->xMin || position.y == this->yMax || + position.y == this->yMin; +} + +Rectangle::Side +Rectangle::GetClosestSideOrCorner(const Vector& position) const +{ + std::array distanceFromBorders{ + std::abs(position.x - this->xMin), // left border + std::abs(this->xMax - position.x), // right border + std::abs(position.y - this->yMin), // bottom border + std::abs(this->yMax - position.y), // top border + }; + uint8_t flags = 0; + double minDist = std::numeric_limits::max(); + for (int i = 0; i < 4; i++) { - double xMinDist = std::abs(position.x - this->xMin); - double xMaxDist = std::abs(this->xMax - position.x); - double yMinDist = std::abs(position.y - this->yMin); - double yMaxDist = std::abs(this->yMax - position.y); - double minX = std::min(xMinDist, xMaxDist); - double minY = std::min(yMinDist, yMaxDist); - if (minX < minY) + if (distanceFromBorders[i] > minDist) { - if (xMinDist < xMaxDist) - { - return LEFT; - } - else - { - return RIGHT; - } + continue; } - else + // In case we find a border closer to the position, + // we replace it and mark the flag + if (distanceFromBorders[i] < minDist) { - if (yMinDist < yMaxDist) - { - return BOTTOM; - } - else - { - return TOP; - } + minDist = distanceFromBorders[i]; + flags = 0; } + flags |= (0b1000 >> i); } - else + NS_ASSERT(minDist != std::numeric_limits::max()); + Rectangle::Side side; + switch (flags) { - if (position.x < this->xMin) + // LRBT + case 0b1111: + // Every side is equally distant, so choose any + side = TOPSIDE; + break; + case 0b0011: + // Opposing sides are equally distant, so we need to check the other two + // We also need to check if we're inside or outside. + side = TOPSIDE; + if (!IsInside(position)) { - if (position.y < this->yMin) - { - double yDiff = this->yMin - position.y; - double xDiff = this->xMin - position.x; - if (yDiff > xDiff) - { - return BOTTOM; - } - else - { - return LEFT; - } - } - else if (position.y < this->yMax) - { - return LEFT; - } - else - { - double yDiff = position.y - this->yMax; - double xDiff = this->xMin - position.x; - if (yDiff > xDiff) - { - return TOP; - } - else - { - return LEFT; - } - } + side = (distanceFromBorders[0] > distanceFromBorders[1]) ? RIGHTSIDE : LEFTSIDE; } - else if (position.x < this->xMax) + break; + case 0b1100: + // Opposing sides are equally distant, so we need to check the other two + // We also need to check if we're inside or outside. + side = RIGHTSIDE; + if (!IsInside(position)) { - if (position.y < this->yMin) - { - return BOTTOM; - } - else if (position.y < this->yMax) - { - NS_FATAL_ERROR( - "This region should have been reached if the IsInside check was true"); - return TOP; // silence compiler warning - } - else - { - return TOP; - } - } - else - { - if (position.y < this->yMin) - { - double yDiff = this->yMin - position.y; - double xDiff = position.x - this->xMin; - if (yDiff > xDiff) - { - return BOTTOM; - } - else - { - return RIGHT; - } - } - else if (position.y < this->yMax) - { - return RIGHT; - } - else - { - double yDiff = position.y - this->yMax; - double xDiff = position.x - this->xMin; - if (yDiff > xDiff) - { - return TOP; - } - else - { - return RIGHT; - } - } + side = (distanceFromBorders[2] > distanceFromBorders[3]) ? TOPSIDE : BOTTOMSIDE; } + break; + case 0b0001: + case 0b1101: + side = TOPSIDE; + break; + case 0b0010: + case 0b1110: + side = BOTTOMSIDE; + break; + case 0b0100: + case 0b0111: + side = RIGHTSIDE; + break; + case 0b0101: + side = TOPRIGHTCORNER; + break; + case 0b0110: + side = BOTTOMRIGHTCORNER; + break; + case 0b1000: + case 0b1011: + side = LEFTSIDE; + break; + case 0b1001: + side = TOPLEFTCORNER; + break; + case 0b1010: + side = BOTTOMLEFTCORNER; + break; + default: + NS_FATAL_ERROR("Impossible case"); + break; } + return side; } Vector @@ -247,4 +221,44 @@ operator>>(std::istream& is, Rectangle& rectangle) return is; } +/** + * \brief Stream insertion operator. + * + * \param os the stream + * \param side the rectangle side + * \returns a reference to the stream + */ +std::ostream& +operator<<(std::ostream& os, const Rectangle::Side& side) +{ + switch (side) + { + case Rectangle::RIGHTSIDE: + os << "RIGHTSIDE"; + break; + case Rectangle::LEFTSIDE: + os << "LEFTSIDE"; + break; + case Rectangle::TOPSIDE: + os << "TOPSIDE"; + break; + case Rectangle::BOTTOMSIDE: + os << "BOTTOMSIDE"; + break; + case Rectangle::TOPRIGHTCORNER: + os << "TOPRIGHTCORNER"; + break; + case Rectangle::TOPLEFTCORNER: + os << "TOPLEFTCORNER"; + break; + case Rectangle::BOTTOMRIGHTCORNER: + os << "BOTTOMRIGHTCORNER"; + break; + case Rectangle::BOTTOMLEFTCORNER: + os << "BOTTOMLEFTCORNER"; + break; + } + return os; +} + } // namespace ns3 diff --git a/src/mobility/model/rectangle.h b/src/mobility/model/rectangle.h index c846a7a9e..672ab68aa 100644 --- a/src/mobility/model/rectangle.h +++ b/src/mobility/model/rectangle.h @@ -39,10 +39,14 @@ class Rectangle */ enum Side { - RIGHT, - LEFT, - TOP, - BOTTOM + RIGHTSIDE = 0, + LEFTSIDE, + TOPSIDE, + BOTTOMSIDE, + TOPRIGHTCORNER, + TOPLEFTCORNER, + BOTTOMRIGHTCORNER, + BOTTOMLEFTCORNER }; /** @@ -68,12 +72,34 @@ class Rectangle bool IsInside(const Vector& position) const; /** * \param position the position to test. - * \return the side of the rectangle the input position is closest to. + * \return true if the input position is located on the rectable border, false otherwise. * * This method compares only the x and y coordinates of the input position. * It ignores the z coordinate. */ - Side GetClosestSide(const Vector& position) const; + bool IsOnTheBorder(const Vector& position) const; + /** + * \param position the position to test. + * \return the side of the rectangle the input position is closest to. + * + * This method compares only the x and y coordinates of the input position. + * It ignores the z coordinate. + * + * This method assumes assumes a right-handed Cartesian orientation, so that + * (xMin, yMin) is the BOTTOMLEFTCORNER, the TOP and BOTTOM sides are parallel to + * the x-axis, the LEFT and RIGHT sides are parallel to the y-axis, and the + * (xMax, yMax) point is the TOPRIGHTCORNER. + * + * Beware: the method has an ambiguity in the "center" of the rectangle. Assume + * a rectangle between the points (0, 0) and (4, 2), i.e., wider than taller. + * All the points on the line between (1, 1) and (3, 1) are equally closer to the + * TOP and BOTTOM than to the other sides of the Rectangle. + * These points are classified as TOPSIDE by convention. + * + * Similarly, for a Rectangle taller than wider, the "center" points will be + * classified as RIGHTSIDE, and for a square box, the center will return RIGHTSIDE. + */ + Side GetClosestSideOrCorner(const Vector& position) const; /** * \param current the current position * \param speed the current speed @@ -94,6 +120,7 @@ class Rectangle std::ostream& operator<<(std::ostream& os, const Rectangle& rectangle); std::istream& operator>>(std::istream& is, Rectangle& rectangle); +std::ostream& operator<<(std::ostream& os, const Rectangle::Side& side); ATTRIBUTE_HELPER_HEADER(Rectangle); diff --git a/src/mobility/test/rectangle-closest-border-test.cc b/src/mobility/test/rectangle-closest-border-test.cc new file mode 100644 index 000000000..07f6c9ca5 --- /dev/null +++ b/src/mobility/test/rectangle-closest-border-test.cc @@ -0,0 +1,207 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Gabriel Ferreira + */ + +#include +#include +#include + +using namespace ns3; + +/** + * \ingroup mobility-test + * + * \brief Rectangle detection of closest border to a point, inside or outside. + */ +class RectangleClosestBorderTestSuite : public TestSuite +{ + public: + /** + * Constructor + */ + RectangleClosestBorderTestSuite(); +}; + +/** + * \ingroup mobility-test + * + * \brief TestCase to check the rectangle line intersection + */ +class RectangleClosestBorderTestCase : public TestCase +{ + public: + /** + * \brief Create RectangleClosestBorderTestCase + * \param x Index of the first position to generate + * \param y Index of the second position to generate + * \param rectangle The 2D rectangle + * \param side The expected result of the test + */ + RectangleClosestBorderTestCase(double x, double y, Rectangle rectangle, Rectangle::Side side); + /** + * \brief Builds the test name string based on provided parameter values + * \param x Index of the first position to generate + * \param y Index of the second position to generate + * \param rectangle The 2D rectangle + * \param side The expected result of the test + * + * \return The name string + */ + std::string BuildNameString(double x, double y, Rectangle rectangle, Rectangle::Side side); + /** + * Destructor + */ + ~RectangleClosestBorderTestCase() override; + + private: + /** + * \brief Setup the simulation according to the configuration set by the + * class constructor, run it, and verify the result. + */ + void DoRun() override; + + double m_x{0.0}; //!< X coordinate of the point to be tested + double m_y{0.0}; //!< Y coordinate of the point to be tested + Rectangle m_rectangle; //!< The rectangle to check the intersection with + + /** + * Flag to indicate the intersection. + * True, for intersection, false otherwise. + */ + Rectangle::Side m_side{ns3::Rectangle::TOPSIDE}; +}; + +/** + * This TestSuite tests the intersection of a line segment + * between two 2D positions with a 2D rectangle. It generates two + * positions from a set of predefined positions (see GeneratePosition method), + * and then tests the intersection of a line segments between them with a rectangle + * of predefined dimensions. + */ + +RectangleClosestBorderTestSuite::RectangleClosestBorderTestSuite() + : TestSuite("rectangle-closest-border", UNIT) +{ + // Rectangle in the positive x-plane to check the intersection with. + Rectangle rectangle = Rectangle(0.0, 10.0, 0.0, 10.0); + + /* 2 3 4 + * +----------------------------+ (10,10) + * | 11 16 12 | + * | | + * | | + * 1 | 15 18 17 | 5 + * | | + * | | + * | 10 14 13 | + * +----------------------------+ + * 9 7 + * (0,0) + * + * + * + * 8 + */ + // Left side (1 and 15) + AddTestCase(new RectangleClosestBorderTestCase(-5, 5, rectangle, Rectangle::LEFTSIDE), + TestCase::QUICK); + AddTestCase(new RectangleClosestBorderTestCase(2, 5, rectangle, Rectangle::LEFTSIDE), + TestCase::QUICK); + // Right side (5 and 17) + AddTestCase(new RectangleClosestBorderTestCase(17, 5, rectangle, Rectangle::RIGHTSIDE), + TestCase::QUICK); + AddTestCase(new RectangleClosestBorderTestCase(7, 5, rectangle, Rectangle::RIGHTSIDE), + TestCase::QUICK); + // Bottom side (8 and 14) + AddTestCase(new RectangleClosestBorderTestCase(5, -7, rectangle, Rectangle::BOTTOMSIDE), + TestCase::QUICK); + AddTestCase(new RectangleClosestBorderTestCase(5, 1, rectangle, Rectangle::BOTTOMSIDE), + TestCase::QUICK); + // Top side (3 and 16) + AddTestCase(new RectangleClosestBorderTestCase(5, 15, rectangle, Rectangle::TOPSIDE), + TestCase::QUICK); + AddTestCase(new RectangleClosestBorderTestCase(5, 7, rectangle, Rectangle::TOPSIDE), + TestCase::QUICK); + // Left-Bottom corner (9 and 10) + AddTestCase(new RectangleClosestBorderTestCase(-1, -1, rectangle, Rectangle::BOTTOMLEFTCORNER), + TestCase::QUICK); + AddTestCase(new RectangleClosestBorderTestCase(0, 0, rectangle, Rectangle::BOTTOMLEFTCORNER), + TestCase::QUICK); + // Right-Bottom corner (7 and 13) + AddTestCase(new RectangleClosestBorderTestCase(11, -1, rectangle, Rectangle::BOTTOMRIGHTCORNER), + TestCase::QUICK); + AddTestCase(new RectangleClosestBorderTestCase(9, 1, rectangle, Rectangle::BOTTOMRIGHTCORNER), + TestCase::QUICK); + // Left-Top corner (2 and 11) + AddTestCase(new RectangleClosestBorderTestCase(-1, 11, rectangle, Rectangle::TOPLEFTCORNER), + TestCase::QUICK); + AddTestCase(new RectangleClosestBorderTestCase(1, 9, rectangle, Rectangle::TOPLEFTCORNER), + TestCase::QUICK); + // Right-Top corner (4 and 12) + AddTestCase(new RectangleClosestBorderTestCase(11, 11, rectangle, Rectangle::TOPRIGHTCORNER), + TestCase::QUICK); + AddTestCase(new RectangleClosestBorderTestCase(9, 9, rectangle, Rectangle::TOPRIGHTCORNER), + TestCase::QUICK); + // Central position (18) + AddTestCase(new RectangleClosestBorderTestCase(5, 5, rectangle, Rectangle::TOPSIDE), + TestCase::QUICK); +} + +/** + * \ingroup mobility-test + * Static variable for test initialization + */ +static RectangleClosestBorderTestSuite rectangleClosestBorderTestSuite; + +RectangleClosestBorderTestCase::RectangleClosestBorderTestCase(double x, + double y, + Rectangle rectangle, + Rectangle::Side side) + : TestCase(BuildNameString(x, y, rectangle, side)), + m_x(x), + m_y(y), + m_rectangle(rectangle), + m_side(side) +{ +} + +RectangleClosestBorderTestCase::~RectangleClosestBorderTestCase() +{ +} + +std::string +RectangleClosestBorderTestCase::BuildNameString(double x, + double y, + Rectangle rectangle, + Rectangle::Side side) +{ + std::ostringstream oss; + oss << "Rectangle closest border test : checking" + << " (x,y) = (" << x << "," << y << ") closest border to the rectangle [(" << rectangle.xMin + << ", " << rectangle.yMin << "), (" << rectangle.xMax << ", " << rectangle.yMax + << ")]. The expected side = " << side; + return oss.str(); +} + +void +RectangleClosestBorderTestCase::DoRun() +{ + Vector position(m_x, m_y, 0.0); + Rectangle::Side side = m_rectangle.GetClosestSideOrCorner(position); + + NS_TEST_ASSERT_MSG_EQ(side, m_side, "Unexpected result of rectangle side!"); + Simulator::Destroy(); +} diff --git a/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc b/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc index 19a9200b4..bc9dd8fd7 100644 --- a/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc +++ b/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc @@ -106,11 +106,9 @@ SteadyStateRandomWaypointTest::DistribCompare() double sum_x = 0; double sum_y = 0; double sum_v = 0; - std::vector>::iterator i; - Ptr model; - for (i = mobilityStack.begin(); i != mobilityStack.end(); ++i) + for (auto i = mobilityStack.begin(); i != mobilityStack.end(); ++i) { - model = (*i); + auto model = (*i); velocity = std::sqrt(std::pow(model->GetVelocity().x, 2) + std::pow(model->GetVelocity().y, 2)); sum_x += model->GetPosition().x; @@ -129,9 +127,9 @@ SteadyStateRandomWaypointTest::DistribCompare() sum_y = 0; sum_v = 0; double tmp; - for (i = mobilityStack.begin(); i != mobilityStack.end(); ++i) + for (auto i = mobilityStack.begin(); i != mobilityStack.end(); ++i) { - model = (*i); + auto model = (*i); velocity = std::sqrt(std::pow(model->GetVelocity().x, 2) + std::pow(model->GetVelocity().y, 2)); tmp = model->GetPosition().x - mean_x; diff --git a/src/mobility/test/waypoint-mobility-model-test.cc b/src/mobility/test/waypoint-mobility-model-test.cc index 92704257b..32c92ae41 100644 --- a/src/mobility/test/waypoint-mobility-model-test.cc +++ b/src/mobility/test/waypoint-mobility-model-test.cc @@ -105,15 +105,14 @@ WaypointMobilityModelNotifyTest::DoRun() } // Add the same waypoints to each node - std::vector>::iterator i; - for (i = mobilityStack.begin(); i != mobilityStack.end(); ++i) + for (auto i = mobilityStack.begin(); i != mobilityStack.end(); ++i) { Ptr mob = (*i)->GetObject(); mob->TraceConnectWithoutContext( "CourseChange", MakeCallback(&WaypointMobilityModelNotifyTest::CourseChangeCallback, this)); - for (std::deque::iterator w = waypoints.begin(); w != waypoints.end(); ++w) + for (auto w = waypoints.begin(); w != waypoints.end(); ++w) { mob->AddWaypoint(*w); } @@ -135,8 +134,7 @@ WaypointMobilityModelNotifyTest::DoRun() void WaypointMobilityModelNotifyTest::ForceUpdates() { - std::vector>::iterator i; - for (i = mobilityStack.begin(); i != mobilityStack.end(); ++i) + for (auto i = mobilityStack.begin(); i != mobilityStack.end(); ++i) { Ptr mob = (*i)->GetObject(); mob->Update(); diff --git a/src/mpi/examples/nms-p2p-nix-distributed.cc b/src/mpi/examples/nms-p2p-nix-distributed.cc index 24d42103e..65ede6d47 100644 --- a/src/mpi/examples/nms-p2p-nix-distributed.cc +++ b/src/mpi/examples/nms-p2p-nix-distributed.cc @@ -78,7 +78,7 @@ main(int argc, char* argv[]) uint32_t nCN = 2; uint32_t nLANClients = 10; - bool single = 0; + bool single = false; int nPackets = 10; // Packets sent by OnOff applications bool nix = true; Time stop = Seconds(100); diff --git a/src/mpi/model/distributed-simulator-impl.cc b/src/mpi/model/distributed-simulator-impl.cc index 1c6914639..425d1437e 100644 --- a/src/mpi/model/distributed-simulator-impl.cc +++ b/src/mpi/model/distributed-simulator-impl.cc @@ -172,7 +172,7 @@ DistributedSimulatorImpl::CalculateLookAhead() else { NodeContainer c = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator iter = c.Begin(); iter != c.End(); ++iter) + for (auto iter = c.Begin(); iter != c.End(); ++iter) { if ((*iter)->GetSystemId() != MpiInterface::GetSystemId()) { @@ -553,7 +553,7 @@ DistributedSimulatorImpl::Remove(const EventId& id) if (id.GetUid() == EventId::UID::DESTROY) { // destroy events. - for (DestroyEvents::iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { @@ -599,8 +599,7 @@ DistributedSimulatorImpl::IsExpired(const EventId& id) const return true; } // destroy events. - for (DestroyEvents::const_iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); - i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { diff --git a/src/mpi/model/granted-time-window-mpi-interface.cc b/src/mpi/model/granted-time-window-mpi-interface.cc index 1ab63a92c..26e6bcb7c 100644 --- a/src/mpi/model/granted-time-window-mpi-interface.cc +++ b/src/mpi/model/granted-time-window-mpi-interface.cc @@ -93,7 +93,6 @@ MPI_Request* GrantedTimeWindowMpiInterface::g_requests; char** GrantedTimeWindowMpiInterface::g_pRxBuffers; MPI_Comm GrantedTimeWindowMpiInterface::g_communicator = MPI_COMM_WORLD; bool GrantedTimeWindowMpiInterface::g_freeCommunicator = false; -; #ifdef NS3_MTP std::atomic GrantedTimeWindowMpiInterface::g_sending(false); @@ -231,16 +230,16 @@ GrantedTimeWindowMpiInterface::SendPacket(Ptr p, SentBuffer sendBuf; g_pendingTx.push_back(sendBuf); - std::list::reverse_iterator i = g_pendingTx.rbegin(); // Points to the last element + auto i = g_pendingTx.rbegin(); // Points to the last element uint32_t serializedSize = p->GetSerializedSize(); - uint8_t* buffer = new uint8_t[serializedSize + 16]; + auto buffer = new uint8_t[serializedSize + 16]; i->SetBuffer(buffer); // Add the time, dest node and dest device uint64_t t = rxTime.GetInteger(); - uint64_t* pTime = reinterpret_cast(buffer); + auto pTime = reinterpret_cast(buffer); *pTime++ = t; - uint32_t* pData = reinterpret_cast(pTime); + auto pData = reinterpret_cast(pTime); *pData++ = node; *pData++ = dev; // Serialize the packet @@ -290,9 +289,9 @@ GrantedTimeWindowMpiInterface::ReceiveMessages() g_rxCount++; // Count this receive // Get the meta data first - uint64_t* pTime = reinterpret_cast(g_pRxBuffers[index]); + auto pTime = reinterpret_cast(g_pRxBuffers[index]); uint64_t time = *pTime++; - uint32_t* pData = reinterpret_cast(pTime); + auto pData = reinterpret_cast(pTime); uint32_t node = *pData++; uint32_t dev = *pData++; @@ -346,14 +345,14 @@ GrantedTimeWindowMpiInterface::TestSendComplete() { NS_LOG_FUNCTION_NOARGS(); - std::list::iterator i = g_pendingTx.begin(); + auto i = g_pendingTx.begin(); while (i != g_pendingTx.end()) { MPI_Status status; int flag = 0; MPI_Test(i->GetRequest(), &flag, &status); - std::list::iterator current = i; // Save current for erasing - i++; // Advance to next + auto current = i; // Save current for erasing + i++; // Advance to next if (flag) { // This message is complete g_pendingTx.erase(current); diff --git a/src/mpi/model/null-message-mpi-interface.cc b/src/mpi/model/null-message-mpi-interface.cc index 2c12e7473..7341d8800 100644 --- a/src/mpi/model/null-message-mpi-interface.cc +++ b/src/mpi/model/null-message-mpi-interface.cc @@ -26,12 +26,12 @@ #include "null-message-mpi-interface.h" +#include "mpi-receiver.h" #include "null-message-simulator-impl.h" #include "remote-channel-bundle-manager.h" #include "remote-channel-bundle.h" #include "ns3/log.h" -#include "ns3/mpi-receiver.h" #include "ns3/net-device.h" #include "ns3/node-list.h" #include "ns3/node.h" @@ -270,23 +270,22 @@ NullMessageMpiInterface::SendPacket(Ptr p, const Time& rxTime, uint32_t NullMessageSentBuffer sendBuf; g_pendingTx.push_back(sendBuf); - std::list::reverse_iterator iter = - g_pendingTx.rbegin(); // Points to the last element + auto iter = g_pendingTx.rbegin(); // Points to the last element uint32_t serializedSize = p->GetSerializedSize(); uint32_t bufferSize = serializedSize + (2 * sizeof(uint64_t)) + (2 * sizeof(uint32_t)); - uint8_t* buffer = new uint8_t[bufferSize]; + auto buffer = new uint8_t[bufferSize]; iter->SetBuffer(buffer); // Add the time, dest node and dest device uint64_t t = rxTime.GetInteger(); - uint64_t* pTime = reinterpret_cast(buffer); + auto pTime = reinterpret_cast(buffer); *pTime++ = t; Time guarantee_update = NullMessageSimulatorImpl::GetInstance()->CalculateGuaranteeTime(nodeSysId); *pTime++ = guarantee_update.GetTimeStep(); - uint32_t* pData = reinterpret_cast(pTime); + auto pData = reinterpret_cast(pTime); *pData++ = node; *pData++ = dev; // Serialize the packet @@ -313,17 +312,16 @@ NullMessageMpiInterface::SendNullMessage(const Time& guarantee_update, NullMessageSentBuffer sendBuf; g_pendingTx.push_back(sendBuf); - std::list::reverse_iterator iter = - g_pendingTx.rbegin(); // Points to the last element + auto iter = g_pendingTx.rbegin(); // Points to the last element uint32_t bufferSize = 2 * sizeof(uint64_t) + 2 * sizeof(uint32_t); - uint8_t* buffer = new uint8_t[bufferSize]; + auto buffer = new uint8_t[bufferSize]; iter->SetBuffer(buffer); // Add the time, dest node and dest device - uint64_t* pTime = reinterpret_cast(buffer); + auto pTime = reinterpret_cast(buffer); *pTime++ = 0; *pTime++ = guarantee_update.GetInteger(); - uint32_t* pData = reinterpret_cast(pTime); + auto pData = reinterpret_cast(pTime); *pData++ = 0; *pData++ = 0; @@ -395,11 +393,11 @@ NullMessageMpiInterface::ReceiveMessages(bool blocking) MPI_Get_count(&status, MPI_CHAR, &count); // Get the meta data first - uint64_t* pTime = reinterpret_cast(g_pRxBuffers[index]); + auto pTime = reinterpret_cast(g_pRxBuffers[index]); uint64_t time = *pTime++; uint64_t guaranteeUpdate = *pTime++; - uint32_t* pData = reinterpret_cast(pTime); + auto pData = reinterpret_cast(pTime); uint32_t node = *pData++; uint32_t dev = *pData++; @@ -465,14 +463,14 @@ NullMessageMpiInterface::TestSendComplete() NS_ASSERT(g_enabled); - std::list::iterator iter = g_pendingTx.begin(); + auto iter = g_pendingTx.begin(); while (iter != g_pendingTx.end()) { MPI_Status status; int flag = 0; MPI_Test(iter->GetRequest(), &flag, &status); - std::list::iterator current = iter; // Save current for erasing - ++iter; // Advance to next + auto current = iter; // Save current for erasing + ++iter; // Advance to next if (flag) { // This message is complete g_pendingTx.erase(current); @@ -487,9 +485,7 @@ NullMessageMpiInterface::Disable() if (g_enabled) { - for (std::list::iterator iter = g_pendingTx.begin(); - iter != g_pendingTx.end(); - ++iter) + for (auto iter = g_pendingTx.begin(); iter != g_pendingTx.end(); ++iter) { MPI_Cancel(iter->GetRequest()); MPI_Request_free(iter->GetRequest()); diff --git a/src/mpi/model/null-message-simulator-impl.cc b/src/mpi/model/null-message-simulator-impl.cc index 03d3ad948..59446ab72 100644 --- a/src/mpi/model/null-message-simulator-impl.cc +++ b/src/mpi/model/null-message-simulator-impl.cc @@ -140,7 +140,7 @@ NullMessageSimulatorImpl::CalculateLookAhead() if (MpiInterface::GetSize() > 1) { NodeContainer c = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator iter = c.Begin(); iter != c.End(); ++iter) + for (auto iter = c.Begin(); iter != c.End(); ++iter) { if ((*iter)->GetSystemId() != MpiInterface::GetSystemId()) { @@ -476,7 +476,7 @@ NullMessageSimulatorImpl::Remove(const EventId& id) if (id.GetUid() == EventId::UID::DESTROY) { // destroy events. - for (DestroyEvents::iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { @@ -522,8 +522,7 @@ NullMessageSimulatorImpl::IsExpired(const EventId& id) const return true; } // destroy events. - for (DestroyEvents::const_iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); - i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { diff --git a/src/mpi/model/remote-channel-bundle-manager.cc b/src/mpi/model/remote-channel-bundle-manager.cc index c7d094716..222f5827c 100644 --- a/src/mpi/model/remote-channel-bundle-manager.cc +++ b/src/mpi/model/remote-channel-bundle-manager.cc @@ -41,8 +41,7 @@ ns3::RemoteChannelBundleManager::RemoteChannelMap Ptr RemoteChannelBundleManager::Find(uint32_t systemId) { - ns3::RemoteChannelBundleManager::RemoteChannelMap::iterator kv = - g_remoteChannelBundles.find(systemId); + auto kv = g_remoteChannelBundles.find(systemId); if (kv == g_remoteChannelBundles.end()) { @@ -78,9 +77,7 @@ RemoteChannelBundleManager::InitializeNullMessageEvents() { NS_ASSERT(!g_initialized); - for (RemoteChannelMap::const_iterator iter = g_remoteChannelBundles.begin(); - iter != g_remoteChannelBundles.end(); - ++iter) + for (auto iter = g_remoteChannelBundles.begin(); iter != g_remoteChannelBundles.end(); ++iter) { Ptr bundle = iter->second; bundle->Send(bundle->GetDelay()); @@ -98,9 +95,7 @@ RemoteChannelBundleManager::GetSafeTime() Time safeTime = Simulator::GetMaximumSimulationTime(); - for (RemoteChannelMap::const_iterator kv = g_remoteChannelBundles.begin(); - kv != g_remoteChannelBundles.end(); - ++kv) + for (auto kv = g_remoteChannelBundles.begin(); kv != g_remoteChannelBundles.end(); ++kv) { safeTime = Min(safeTime, kv->second->GetGuaranteeTime()); } diff --git a/src/netanim/doc/animation.rst b/src/netanim/doc/animation.rst index a89a3ef63..e2827d920 100644 --- a/src/netanim/doc/animation.rst +++ b/src/netanim/doc/animation.rst @@ -14,7 +14,7 @@ We will describe the NetAnim method briefly here. NetAnim ******* -NetAnim is a standalone, Qt4-based software executable that uses a trace file generated during +NetAnim is a standalone, Qt5-based software executable that uses a trace file generated during an |ns3| simulation to display the topology and animate the packet flow between nodes. .. figure:: figures/NetAnim_3_105.* @@ -77,33 +77,23 @@ Downloading NetAnim =================== If NetAnim is not already available in the |ns3| package you downloaded, you can do the following: -Please ensure that you have installed mercurial. -The latest version of NetAnim can be downloaded using mercurial with the following command: +The latest version of NetAnim can be downloaded using git with the following command: .. sourcecode:: bash - $ hg clone http://code.nsnam.org/netanim + $ git clone https://gitlab.com/nsnam/netanim.git Building NetAnim ================ Prerequisites ~~~~~~~~~~~~~ -Qt5 (5.4 and over) is required to build NetAnim. This can be obtained using the following ways: +Qt5 (5.4 and over) is required to build NetAnim. The ns-3 Installation Guide +lists some packages to install for some +`Linux `_ systems, +for `macOS `, and +for `Windows `_. -For Ubuntu Linux distributions: - -.. sourcecode:: bash - - $ apt-get install qt5-default - -For Red Hat/Fedora based distribution: - -.. sourcecode:: bash - - $ yum install qt5 - $ yum install qt5-devel - -For Mac/OSX, see https://www.qt.io/download +The `Qt site `_ also provides download options. Build steps ~~~~~~~~~~~ diff --git a/src/netanim/examples/uan-animation.cc b/src/netanim/examples/uan-animation.cc index 7cffc498c..a4f332ba2 100644 --- a/src/netanim/examples/uan-animation.cc +++ b/src/netanim/examples/uan-animation.cc @@ -98,7 +98,7 @@ void NetAnimExperiment::UpdatePositions(NodeContainer& nodes) const { NS_LOG_DEBUG(Simulator::Now().As(Time::S) << " Updating positions"); - NodeContainer::Iterator it = nodes.Begin(); + auto it = nodes.Begin(); Ptr uv = CreateObject(); uv->SetAttribute("Min", DoubleValue(0.0)); uv->SetAttribute("Max", DoubleValue(m_boundary)); diff --git a/src/netanim/model/animation-interface.cc b/src/netanim/model/animation-interface.cc index f4669782e..c5d06908c 100644 --- a/src/netanim/model/animation-interface.cc +++ b/src/netanim/model/animation-interface.cc @@ -38,7 +38,6 @@ #endif #include "animation-interface.h" -#include "ns3/animation-interface.h" #include "ns3/channel.h" #include "ns3/config.h" #include "ns3/constant-position-mobility-model.h" @@ -136,7 +135,7 @@ AnimationInterface::EnableWifiPhyCounters(Time startTime, Time stopTime, Time po m_wifiPhyCountersPollInterval = pollInterval; m_wifiPhyTxDropCounterId = AddNodeCounter("WifiPhy TxDrop", AnimationInterface::DOUBLE_COUNTER); m_wifiPhyRxDropCounterId = AddNodeCounter("WifiPhy RxDrop", AnimationInterface::DOUBLE_COUNTER); - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; m_nodeWifiPhyTxDrop[n->GetId()] = 0; @@ -156,7 +155,7 @@ AnimationInterface::EnableWifiMacCounters(Time startTime, Time stopTime, Time po m_wifiMacTxDropCounterId = AddNodeCounter("WifiMac TxDrop", AnimationInterface::DOUBLE_COUNTER); m_wifiMacRxCounterId = AddNodeCounter("WifiMac Rx", AnimationInterface::DOUBLE_COUNTER); m_wifiMacRxDropCounterId = AddNodeCounter("WifiMac RxDrop", AnimationInterface::DOUBLE_COUNTER); - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; m_nodeWifiMacTx[n->GetId()] = 0; @@ -179,7 +178,7 @@ AnimationInterface::EnableQueueCounters(Time startTime, Time stopTime, Time poll m_queueEnqueueCounterId = AddNodeCounter("Enqueue", AnimationInterface::DOUBLE_COUNTER); m_queueDequeueCounterId = AddNodeCounter("Dequeue", AnimationInterface::DOUBLE_COUNTER); m_queueDropCounterId = AddNodeCounter("Queue Drop", AnimationInterface::DOUBLE_COUNTER); - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; m_nodeQueueEnqueue[n->GetId()] = 0; @@ -200,7 +199,7 @@ AnimationInterface::EnableIpv4L3ProtocolCounters(Time startTime, Time stopTime, m_ipv4L3ProtocolTxCounterId = AddNodeCounter("Ipv4 Tx", AnimationInterface::DOUBLE_COUNTER); m_ipv4L3ProtocolRxCounterId = AddNodeCounter("Ipv4 Rx", AnimationInterface::DOUBLE_COUNTER); m_ipv4L3ProtocolDropCounterId = AddNodeCounter("Ipv4 Drop", AnimationInterface::DOUBLE_COUNTER); - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; m_nodeIpv4Tx[n->GetId()] = 0; @@ -441,7 +440,7 @@ AnimationInterface::UpdateNodeDescription(uint32_t nodeId, std::string descr) double AnimationInterface::GetNodeEnergyFraction(Ptr node) const { - const EnergyFractionMap::const_iterator fractionIter = m_nodeEnergyFraction.find(node->GetId()); + const auto fractionIter = m_nodeEnergyFraction.find(node->GetId()); NS_ASSERT(fractionIter != m_nodeEnergyFraction.end()); return fractionIter->second; } @@ -501,7 +500,7 @@ std::vector> AnimationInterface::GetMovedNodes() { std::vector> movedNodes; - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; NS_ASSERT(n); @@ -574,9 +573,8 @@ AnimationInterface::WriteRoutePath(uint32_t nodeId, { NS_LOG_INFO("Writing Route Path From :" << nodeId << " To: " << destination); WriteXmlRp(nodeId, destination, rpElements); - /*for (Ipv4RoutePathElements::const_iterator i = rpElements.begin (); - i != rpElements.end (); - ++i) + /* + for (auto i = rpElements.begin (); i != rpElements.end (); ++i) { Ipv4RoutePathElement rpElement = *i; NS_LOG_INFO ("Node:" << rpElement.nodeId << "-->" << rpElement.nextHop.c_str ()); @@ -1125,7 +1123,7 @@ AnimationInterface::LteSpectrumPhyTxStart(std::string context, Ptr> pbList = pb->GetPackets(); - for (std::list>::iterator i = pbList.begin(); i != pbList.end(); ++i) + for (auto i = pbList.begin(); i != pbList.end(); ++i) { Ptr p = *i; ++gAnimUid; @@ -1153,7 +1151,7 @@ AnimationInterface::LteSpectrumPhyRxStart(std::string context, Ptr> pbList = pb->GetPackets(); - for (std::list>::iterator i = pbList.begin(); i != pbList.end(); ++i) + for (auto i = pbList.begin(); i != pbList.end(); ++i) { Ptr p = *i; uint64_t animUid = GetAnimUidFromPacket(p); @@ -1326,8 +1324,7 @@ AnimationInterface::PurgePendingPackets(AnimationInterface::ProtocolType protoco return; } std::vector purgeList; - for (AnimUidPacketInfoMap::iterator i = pendingPackets->begin(); i != pendingPackets->end(); - ++i) + for (auto i = pendingPackets->begin(); i != pendingPackets->end(); ++i) { AnimPacketInfo pktInfo = i->second; double delta = (Simulator::Now().GetSeconds() - pktInfo.m_fbTx); @@ -1336,7 +1333,7 @@ AnimationInterface::PurgePendingPackets(AnimationInterface::ProtocolType protoco purgeList.push_back(i->first); } } - for (std::vector::iterator i = purgeList.begin(); i != purgeList.end(); ++i) + for (auto i = purgeList.begin(); i != purgeList.end(); ++i) { pendingPackets->erase(*i); } @@ -1503,9 +1500,7 @@ void AnimationInterface::AddToIpv4AddressNodeIdTable(std::vector ipv4Addresses, uint32_t nodeId) { - for (std::vector::const_iterator i = ipv4Addresses.begin(); - i != ipv4Addresses.end(); - ++i) + for (auto i = ipv4Addresses.begin(); i != ipv4Addresses.end(); ++i) { AddToIpv4AddressNodeIdTable(*i, nodeId); } @@ -1522,9 +1517,7 @@ void AnimationInterface::AddToIpv6AddressNodeIdTable(std::vector ipv6Addresses, uint32_t nodeId) { - for (std::vector::const_iterator i = ipv6Addresses.begin(); - i != ipv6Addresses.end(); - ++i) + for (auto i = ipv6Addresses.begin(); i != ipv6Addresses.end(); ++i) { AddToIpv6AddressNodeIdTable(*i, nodeId); } @@ -1592,7 +1585,7 @@ AnimationInterface::ConnectLteUe(Ptr n, Ptr nd, uint32_t d void AnimationInterface::ConnectLte() { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; NS_ASSERT(n); @@ -1893,12 +1886,11 @@ AnimationInterface::GetIpv6Addresses(Ptr nd) void AnimationInterface::WriteIpv4Addresses() { - for (NodeIdIpv4Map::const_iterator i = m_nodeIdIpv4Map.begin(); i != m_nodeIdIpv4Map.end(); ++i) + for (auto i = m_nodeIdIpv4Map.begin(); i != m_nodeIdIpv4Map.end(); ++i) { std::vector ipv4Addresses; - std::pair iterPair = - m_nodeIdIpv4Map.equal_range(i->first); - for (NodeIdIpv4Map::const_iterator it = iterPair.first; it != iterPair.second; ++it) + auto iterPair = m_nodeIdIpv4Map.equal_range(i->first); + for (auto it = iterPair.first; it != iterPair.second; ++it) { ipv4Addresses.push_back(it->second); } @@ -1909,13 +1901,12 @@ AnimationInterface::WriteIpv4Addresses() void AnimationInterface::WriteIpv6Addresses() { - for (NodeIdIpv6Map::const_iterator i = m_nodeIdIpv6Map.begin(); i != m_nodeIdIpv6Map.end(); + for (auto i = m_nodeIdIpv6Map.begin(); i != m_nodeIdIpv6Map.end(); i = m_nodeIdIpv6Map.upper_bound(i->first)) { std::vector ipv6Addresses; - std::pair iterPair = - m_nodeIdIpv6Map.equal_range(i->first); - for (NodeIdIpv6Map::const_iterator it = iterPair.first; it != iterPair.second; ++it) + auto iterPair = m_nodeIdIpv6Map.equal_range(i->first); + for (auto it = iterPair.first; it != iterPair.second; ++it) { ipv6Addresses.push_back(it->second); } @@ -1926,7 +1917,7 @@ AnimationInterface::WriteIpv6Addresses() void AnimationInterface::WriteLinkProperties() { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; UpdatePosition(n); @@ -2027,7 +2018,7 @@ AnimationInterface::WriteLinkProperties() void AnimationInterface::WriteNodes() { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; NS_LOG_INFO("Update Position for Node: " << n->GetId()); @@ -2039,7 +2030,7 @@ AnimationInterface::WriteNodes() void AnimationInterface::WriteNodeColors() { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; Rgb rgb = {255, 0, 0}; @@ -2054,7 +2045,7 @@ AnimationInterface::WriteNodeColors() void AnimationInterface::WriteNodeSizes() { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; NS_LOG_INFO("Update Size for Node: " << n->GetId()); @@ -2069,7 +2060,7 @@ AnimationInterface::WriteNodeEnergies() { m_remainingEnergyCounterId = AddNodeCounter("RemainingEnergy", AnimationInterface::DOUBLE_COUNTER); - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; if (NodeList::GetNode(n->GetId())->GetObject()) @@ -2145,7 +2136,7 @@ AnimationInterface::TrackQueueCounters() NS_LOG_INFO("TrackQueueCounters Completed"); return; } - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { uint32_t nodeId = Ptr(*i)->GetId(); UpdateNodeCounter(m_queueEnqueueCounterId, nodeId, m_nodeQueueEnqueue[nodeId]); @@ -2163,7 +2154,7 @@ AnimationInterface::TrackWifiMacCounters() NS_LOG_INFO("TrackWifiMacCounters Completed"); return; } - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { uint32_t nodeId = Ptr(*i)->GetId(); UpdateNodeCounter(m_wifiMacTxCounterId, nodeId, m_nodeWifiMacTx[nodeId]); @@ -2184,7 +2175,7 @@ AnimationInterface::TrackWifiPhyCounters() NS_LOG_INFO("TrackWifiPhyCounters Completed"); return; } - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { uint32_t nodeId = Ptr(*i)->GetId(); UpdateNodeCounter(m_wifiPhyTxDropCounterId, nodeId, m_nodeWifiPhyTxDrop[nodeId]); @@ -2203,7 +2194,7 @@ AnimationInterface::TrackIpv4L3ProtocolCounters() NS_LOG_INFO("TrackIpv4L3ProtocolCounters Completed"); return; } - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { uint32_t nodeId = Ptr(*i)->GetId(); UpdateNodeCounter(m_ipv4L3ProtocolTxCounterId, nodeId, m_nodeIpv4Tx[nodeId]); @@ -2224,9 +2215,7 @@ AnimationInterface::TrackIpv4RoutePaths() { return; } - for (std::vector::const_iterator i = m_ipv4RouteTrackElements.begin(); - i != m_ipv4RouteTrackElements.end(); - ++i) + for (auto i = m_ipv4RouteTrackElements.begin(); i != m_ipv4RouteTrackElements.end(); ++i) { Ipv4RouteTrackElement trackElement = *i; Ptr fromNode = NodeList::GetNode(trackElement.fromNodeId); @@ -2301,7 +2290,7 @@ AnimationInterface::TrackIpv4Route() } if (m_routingNc.GetN()) { - for (NodeContainer::Iterator i = m_routingNc.Begin(); i != m_routingNc.End(); ++i) + for (auto i = m_routingNc.Begin(); i != m_routingNc.End(); ++i) { Ptr n = *i; WriteXmlRouting(n->GetId(), GetIpv4RoutingTable(n)); @@ -2309,7 +2298,7 @@ AnimationInterface::TrackIpv4Route() } else { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; WriteXmlRouting(n->GetId(), GetIpv4RoutingTable(n)); @@ -2496,9 +2485,7 @@ AnimationInterface::WriteXmlIpv4Addresses(uint32_t nodeId, std::vector::const_iterator i = ipv4Addresses.begin(); - i != ipv4Addresses.end(); - ++i) + for (auto i = ipv4Addresses.begin(); i != ipv4Addresses.end(); ++i) { AnimXmlElement valueElement("address"); valueElement.SetText(*i); @@ -2512,9 +2499,7 @@ AnimationInterface::WriteXmlIpv6Addresses(uint32_t nodeId, std::vector::const_iterator i = ipv6Addresses.begin(); - i != ipv6Addresses.end(); - ++i) + for (auto i = ipv6Addresses.begin(); i != ipv6Addresses.end(); ++i) { AnimXmlElement valueElement("address"); valueElement.SetText(*i); @@ -2544,7 +2529,7 @@ AnimationInterface::WriteXmlRp(uint32_t nodeId, element.AddAttribute("id", nodeId); element.AddAttribute("d", destination.c_str()); element.AddAttribute("c", rpElements.size()); - for (Ipv4RoutePathElements::const_iterator i = rpElements.begin(); i != rpElements.end(); ++i) + for (auto i = rpElements.begin(); i != rpElements.end(); ++i) { Ipv4RoutePathElement rpElement = *i; AnimXmlElement rpeElement("rpe"); @@ -2754,7 +2739,7 @@ AnimationInterface::AnimXmlElement::AddAttribute(std::string attribute, T value, { attributeString += "=\""; std::string valueStr = oss.str(); - for (std::string::iterator it = valueStr.begin(); it != valueStr.end(); ++it) + for (auto it = valueStr.begin(); it != valueStr.end(); ++it) { switch (*it) { @@ -2804,8 +2789,7 @@ AnimationInterface::AnimXmlElement::ToString(bool autoClose) { std::string elementString = "<" + m_tagName + " "; - for (std::vector::const_iterator i = m_attributes.begin(); i != m_attributes.end(); - ++i) + for (auto i = m_attributes.begin(); i != m_attributes.end(); ++i) { elementString += *i; } @@ -2826,9 +2810,7 @@ AnimationInterface::AnimXmlElement::ToString(bool autoClose) if (!m_children.empty()) { elementString += "\n"; - for (std::vector::const_iterator i = m_children.begin(); - i != m_children.end(); - ++i) + for (auto i = m_children.begin(); i != m_children.end(); ++i) { elementString += *i + "\n"; } diff --git a/src/netanim/test/netanim-test.cc b/src/netanim/test/netanim-test.cc index 75cfcebdd..ed33a8dff 100644 --- a/src/netanim/test/netanim-test.cc +++ b/src/netanim/test/netanim-test.cc @@ -19,7 +19,6 @@ #include "unistd.h" -#include "ns3/applications-module.h" #include "ns3/basic-energy-source.h" #include "ns3/core-module.h" #include "ns3/internet-module.h" @@ -28,6 +27,7 @@ #include "ns3/point-to-point-layout-module.h" #include "ns3/point-to-point-module.h" #include "ns3/simple-device-energy-model.h" +#include "ns3/udp-echo-helper.h" #include diff --git a/src/network/helper/application-container.cc b/src/network/helper/application-container.cc index 16eb51088..13affd00a 100644 --- a/src/network/helper/application-container.cc +++ b/src/network/helper/application-container.cc @@ -69,7 +69,7 @@ ApplicationContainer::Get(uint32_t i) const void ApplicationContainer::Add(ApplicationContainer other) { - for (Iterator i = other.Begin(); i != other.End(); i++) + for (auto i = other.Begin(); i != other.End(); i++) { m_applications.push_back(*i); } @@ -91,7 +91,7 @@ ApplicationContainer::Add(std::string name) void ApplicationContainer::Start(Time start) const { - for (Iterator i = Begin(); i != End(); ++i) + for (auto i = Begin(); i != End(); ++i) { Ptr app = *i; app->SetStartTime(start); @@ -101,7 +101,7 @@ ApplicationContainer::Start(Time start) const void ApplicationContainer::StartWithJitter(Time start, Ptr rv) const { - for (Iterator i = Begin(); i != End(); ++i) + for (auto i = Begin(); i != End(); ++i) { Ptr app = *i; double value = rv->GetValue(); @@ -113,7 +113,7 @@ ApplicationContainer::StartWithJitter(Time start, Ptr rv) void ApplicationContainer::Stop(Time stop) const { - for (Iterator i = Begin(); i != End(); ++i) + for (auto i = Begin(); i != End(); ++i) { Ptr app = *i; app->SetStopTime(stop); diff --git a/src/network/helper/net-device-container.cc b/src/network/helper/net-device-container.cc index 9d93f13eb..893d6fbd7 100644 --- a/src/network/helper/net-device-container.cc +++ b/src/network/helper/net-device-container.cc @@ -72,7 +72,7 @@ NetDeviceContainer::Get(uint32_t i) const void NetDeviceContainer::Add(NetDeviceContainer other) { - for (Iterator i = other.Begin(); i != other.End(); i++) + for (auto i = other.Begin(); i != other.End(); i++) { m_devices.push_back(*i); } diff --git a/src/network/helper/node-container.cc b/src/network/helper/node-container.cc index 2a00ae670..5669b8b84 100644 --- a/src/network/helper/node-container.cc +++ b/src/network/helper/node-container.cc @@ -28,7 +28,7 @@ NodeContainer NodeContainer::GetGlobal() { NodeContainer c; - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { c.Add(*i); } @@ -101,7 +101,7 @@ NodeContainer::Create(uint32_t n, uint32_t systemId) void NodeContainer::Add(const NodeContainer& nc) { - for (Iterator i = nc.Begin(); i != nc.End(); i++) + for (auto i = nc.Begin(); i != nc.End(); i++) { m_nodes.push_back(*i); } diff --git a/src/network/helper/packet-socket-helper.cc b/src/network/helper/packet-socket-helper.cc index d417c1ae5..4869e8a68 100644 --- a/src/network/helper/packet-socket-helper.cc +++ b/src/network/helper/packet-socket-helper.cc @@ -28,7 +28,7 @@ namespace ns3 void PacketSocketHelper::Install(NodeContainer c) const { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Install(*i); } diff --git a/src/network/helper/packet-socket-helper.h b/src/network/helper/packet-socket-helper.h index fbef6cf00..9da511aea 100644 --- a/src/network/helper/packet-socket-helper.h +++ b/src/network/helper/packet-socket-helper.h @@ -20,7 +20,7 @@ #ifndef PACKET_SOCKET_HELPER_H #define PACKET_SOCKET_HELPER_H -#include "ns3/node-container.h" +#include "node-container.h" namespace ns3 { diff --git a/src/network/helper/simple-net-device-helper.cc b/src/network/helper/simple-net-device-helper.cc index df17b023b..846ed0c5e 100644 --- a/src/network/helper/simple-net-device-helper.cc +++ b/src/network/helper/simple-net-device-helper.cc @@ -19,6 +19,8 @@ #include "simple-net-device-helper.h" +#include "trace-helper.h" + #include "ns3/abort.h" #include "ns3/boolean.h" #include "ns3/config.h" @@ -30,7 +32,6 @@ #include "ns3/simple-channel.h" #include "ns3/simple-net-device.h" #include "ns3/simulator.h" -#include "ns3/trace-helper.h" #include @@ -98,7 +99,7 @@ SimpleNetDeviceHelper::Install(const NodeContainer& c, Ptr channe { NetDeviceContainer devs; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { devs.Add(InstallPriv(*i, channel)); } diff --git a/src/network/helper/simple-net-device-helper.h b/src/network/helper/simple-net-device-helper.h index 0154dd0da..68e5b238d 100644 --- a/src/network/helper/simple-net-device-helper.h +++ b/src/network/helper/simple-net-device-helper.h @@ -19,9 +19,10 @@ #ifndef SIMPLE_NETDEVICE_HELPER_H #define SIMPLE_NETDEVICE_HELPER_H +#include "net-device-container.h" +#include "node-container.h" + #include "ns3/attribute.h" -#include "ns3/net-device-container.h" -#include "ns3/node-container.h" #include "ns3/object-factory.h" #include "ns3/queue.h" #include "ns3/simple-channel.h" diff --git a/src/network/helper/trace-helper.cc b/src/network/helper/trace-helper.cc index f2192fc25..6df8cae70 100644 --- a/src/network/helper/trace-helper.cc +++ b/src/network/helper/trace-helper.cc @@ -438,7 +438,7 @@ PcapHelperForDevice::EnablePcap(std::string prefix, void PcapHelperForDevice::EnablePcap(std::string prefix, NetDeviceContainer d, bool promiscuous) { - for (NetDeviceContainer::Iterator i = d.Begin(); i != d.End(); ++i) + for (auto i = d.Begin(); i != d.End(); ++i) { Ptr dev = *i; EnablePcap(prefix, dev, promiscuous); @@ -449,7 +449,7 @@ void PcapHelperForDevice::EnablePcap(std::string prefix, NodeContainer n, bool promiscuous) { NetDeviceContainer devs; - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; for (uint32_t j = 0; j < node->GetNDevices(); ++j) @@ -474,7 +474,7 @@ PcapHelperForDevice::EnablePcap(std::string prefix, { NodeContainer n = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; if (node->GetId() != nodeid) @@ -567,7 +567,7 @@ AsciiTraceHelperForDevice::EnableAsciiImpl(Ptr stream, std::string prefix, NetDeviceContainer d) { - for (NetDeviceContainer::Iterator i = d.Begin(); i != d.End(); ++i) + for (auto i = d.Begin(); i != d.End(); ++i) { Ptr dev = *i; EnableAsciiInternal(stream, prefix, dev, false); @@ -601,7 +601,7 @@ AsciiTraceHelperForDevice::EnableAsciiImpl(Ptr stream, NodeContainer n) { NetDeviceContainer devs; - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; for (uint32_t j = 0; j < node->GetNDevices(); ++j) @@ -665,7 +665,7 @@ AsciiTraceHelperForDevice::EnableAsciiImpl(Ptr stream, { NodeContainer n = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; if (node->GetId() != nodeid) diff --git a/src/network/helper/trace-helper.h b/src/network/helper/trace-helper.h index 6941af33c..3fc4e15f9 100644 --- a/src/network/helper/trace-helper.h +++ b/src/network/helper/trace-helper.h @@ -18,9 +18,10 @@ #ifndef TRACE_HELPER_H #define TRACE_HELPER_H +#include "net-device-container.h" +#include "node-container.h" + #include "ns3/assert.h" -#include "ns3/net-device-container.h" -#include "ns3/node-container.h" #include "ns3/output-stream-wrapper.h" #include "ns3/pcap-file-wrapper.h" #include "ns3/simulator.h" diff --git a/src/network/model/address.h b/src/network/model/address.h index f85be32b1..080023521 100644 --- a/src/network/model/address.h +++ b/src/network/model/address.h @@ -20,9 +20,10 @@ #ifndef ADDRESS_H #define ADDRESS_H +#include "tag-buffer.h" + #include "ns3/attribute-helper.h" #include "ns3/attribute.h" -#include "ns3/tag-buffer.h" #include #include diff --git a/src/network/model/application.cc b/src/network/model/application.cc index 25778f89e..b28a98f31 100644 --- a/src/network/model/application.cc +++ b/src/network/model/application.cc @@ -22,8 +22,9 @@ #include "application.h" +#include "node.h" + #include "ns3/log.h" -#include "ns3/node.h" #include "ns3/nstime.h" #include "ns3/simulator.h" diff --git a/src/network/model/application.h b/src/network/model/application.h index 84fa8c660..bec5b5809 100644 --- a/src/network/model/application.h +++ b/src/network/model/application.h @@ -20,8 +20,9 @@ #ifndef APPLICATION_H #define APPLICATION_H +#include "node.h" + #include "ns3/event-id.h" -#include "ns3/node.h" #include "ns3/nstime.h" #include "ns3/object.h" #include "ns3/ptr.h" diff --git a/src/network/model/buffer.cc b/src/network/model/buffer.cc index 3a1e79388..0dde4a873 100644 --- a/src/network/model/buffer.cc +++ b/src/network/model/buffer.cc @@ -88,7 +88,7 @@ Buffer::LocalStaticDestructor::~LocalStaticDestructor() NS_LOG_FUNCTION(this); if (IS_INITIALIZED(g_freeList)) { - for (Buffer::FreeList::iterator i = g_freeList->begin(); i != g_freeList->end(); i++) + for (auto i = g_freeList->begin(); i != g_freeList->end(); i++) { Buffer::Deallocate(*i); } @@ -176,8 +176,8 @@ Buffer::Allocate(uint32_t reqSize) NS_ASSERT(reqSize >= 1); reqSize += ALLOC_OVER_PROVISION; uint32_t size = reqSize - 1 + sizeof(Buffer::Data); - uint8_t* b = new uint8_t[size]; - Buffer::Data* data = reinterpret_cast(b); + auto b = new uint8_t[size]; + auto data = reinterpret_cast(b); data->m_size = reqSize; data->m_count = 1; return data; @@ -188,7 +188,7 @@ Buffer::Deallocate(Buffer::Data* data) { NS_LOG_FUNCTION(data); NS_ASSERT(data->m_count == 0); - uint8_t* buf = reinterpret_cast(data); + auto buf = reinterpret_cast(data); delete[] buf; } @@ -581,7 +581,7 @@ uint32_t Buffer::Serialize(uint8_t* buffer, uint32_t maxSize) const { NS_LOG_FUNCTION(this << &buffer << maxSize); - uint32_t* p = reinterpret_cast(buffer); + auto p = reinterpret_cast(buffer); uint32_t size = 0; // Add the zero data length @@ -653,7 +653,7 @@ uint32_t Buffer::Deserialize(const uint8_t* buffer, uint32_t size) { NS_LOG_FUNCTION(this << &buffer << size); - const uint32_t* p = reinterpret_cast(buffer); + auto p = reinterpret_cast(buffer); uint32_t sizeCheck = size - 4; NS_ASSERT(sizeCheck >= 4); diff --git a/src/network/model/byte-tag-list.cc b/src/network/model/byte-tag-list.cc index 37b837db7..149db5911 100644 --- a/src/network/model/byte-tag-list.cc +++ b/src/network/model/byte-tag-list.cc @@ -75,9 +75,9 @@ static uint32_t g_maxSize = 0; //!< maximum data size (used for allocation) ByteTagListDataFreeList::~ByteTagListDataFreeList() { NS_LOG_FUNCTION(this); - for (ByteTagListDataFreeList::iterator i = begin(); i != end(); i++) + for (auto i = begin(); i != end(); i++) { - uint8_t* buffer = (uint8_t*)(*i); + auto buffer = (uint8_t*)(*i); delete[] buffer; } } @@ -374,11 +374,11 @@ ByteTagList::Allocate(uint32_t size) data->dirty = 0; return data; } - uint8_t* buffer = (uint8_t*)data; + auto buffer = (uint8_t*)data; delete[] buffer; } - uint8_t* buffer = new uint8_t[std::max(size, g_maxSize) + sizeof(ByteTagListData) - 4]; - ByteTagListData* data = (ByteTagListData*)buffer; + auto buffer = new uint8_t[std::max(size, g_maxSize) + sizeof(ByteTagListData) - 4]; + auto data = (ByteTagListData*)buffer; data->count = 1; data->size = size; data->dirty = 0; @@ -399,7 +399,7 @@ ByteTagList::Deallocate(ByteTagListData* data) { if (g_freeList.size() > FREE_LIST_SIZE || data->size < g_maxSize) { - uint8_t* buffer = (uint8_t*)data; + auto buffer = (uint8_t*)data; delete[] buffer; } else diff --git a/src/network/model/channel-list.cc b/src/network/model/channel-list.cc index bbfcf9cd1..55e397019 100644 --- a/src/network/model/channel-list.cc +++ b/src/network/model/channel-list.cc @@ -162,7 +162,7 @@ void ChannelListPriv::DoDispose() { NS_LOG_FUNCTION(this); - for (std::vector>::iterator i = m_channels.begin(); i != m_channels.end(); i++) + for (auto i = m_channels.begin(); i != m_channels.end(); i++) { Ptr channel = *i; channel->Dispose(); diff --git a/src/network/model/nix-vector.h b/src/network/model/nix-vector.h index b3913b64c..dd1eae66a 100644 --- a/src/network/model/nix-vector.h +++ b/src/network/model/nix-vector.h @@ -20,7 +20,8 @@ #ifndef NIX_VECTOR_H #define NIX_VECTOR_H -#include "ns3/buffer.h" +#include "buffer.h" + #include "ns3/ptr.h" #include "ns3/simple-ref-count.h" diff --git a/src/network/model/node-list.cc b/src/network/model/node-list.cc index 2e796df3f..a602a6c43 100644 --- a/src/network/model/node-list.cc +++ b/src/network/model/node-list.cc @@ -165,7 +165,7 @@ void NodeListPriv::DoDispose() { NS_LOG_FUNCTION(this); - for (std::vector>::iterator i = m_nodes.begin(); i != m_nodes.end(); i++) + for (auto i = m_nodes.begin(); i != m_nodes.end(); i++) { Ptr node = *i; node->Dispose(); diff --git a/src/network/model/node.cc b/src/network/model/node.cc index 7592f345e..4f40b0a0a 100644 --- a/src/network/model/node.cc +++ b/src/network/model/node.cc @@ -23,13 +23,13 @@ #include "application.h" #include "net-device.h" #include "node-list.h" +#include "packet.h" #include "ns3/assert.h" #include "ns3/boolean.h" #include "ns3/global-value.h" #include "ns3/log.h" #include "ns3/object-vector.h" -#include "ns3/packet.h" #include "ns3/simulator.h" #include "ns3/uinteger.h" @@ -206,16 +206,14 @@ Node::DoDispose() NS_LOG_FUNCTION(this); m_deviceAdditionListeners.clear(); m_handlers.clear(); - for (std::vector>::iterator i = m_devices.begin(); i != m_devices.end(); i++) + for (auto i = m_devices.begin(); i != m_devices.end(); i++) { Ptr device = *i; device->Dispose(); *i = nullptr; } m_devices.clear(); - for (std::vector>::iterator i = m_applications.begin(); - i != m_applications.end(); - i++) + for (auto i = m_applications.begin(); i != m_applications.end(); i++) { Ptr application = *i; application->Dispose(); @@ -229,14 +227,12 @@ void Node::DoInitialize() { NS_LOG_FUNCTION(this); - for (std::vector>::iterator i = m_devices.begin(); i != m_devices.end(); i++) + for (auto i = m_devices.begin(); i != m_devices.end(); i++) { Ptr device = *i; device->Initialize(); } - for (std::vector>::iterator i = m_applications.begin(); - i != m_applications.end(); - i++) + for (auto i = m_applications.begin(); i != m_applications.end(); i++) { Ptr application = *i; application->Initialize(); @@ -263,8 +259,7 @@ Node::RegisterProtocolHandler(ProtocolHandler handler, { if (!device) { - for (std::vector>::iterator i = m_devices.begin(); i != m_devices.end(); - i++) + for (auto i = m_devices.begin(); i != m_devices.end(); i++) { Ptr dev = *i; dev->SetPromiscReceiveCallback(MakeCallback(&Node::PromiscReceiveFromDevice, this)); @@ -283,7 +278,7 @@ void Node::UnregisterProtocolHandler(ProtocolHandler handler) { NS_LOG_FUNCTION(this << &handler); - for (ProtocolHandlerList::iterator i = m_handlers.begin(); i != m_handlers.end(); i++) + for (auto i = m_handlers.begin(); i != m_handlers.end(); i++) { if (i->handler.IsEqual(handler)) { @@ -350,7 +345,7 @@ Node::ReceiveFromDevice(Ptr device, << packet->GetUid()); bool found = false; - for (ProtocolHandlerList::iterator i = m_handlers.begin(); i != m_handlers.end(); i++) + for (auto i = m_handlers.begin(); i != m_handlers.end(); i++) { if (!i->device || (i->device == device)) { @@ -373,8 +368,7 @@ Node::RegisterDeviceAdditionListener(DeviceAdditionListener listener) NS_LOG_FUNCTION(this << &listener); m_deviceAdditionListeners.push_back(listener); // and, then, notify the new listener about all existing devices. - for (std::vector>::const_iterator i = m_devices.begin(); i != m_devices.end(); - ++i) + for (auto i = m_devices.begin(); i != m_devices.end(); ++i) { listener(*i); } @@ -384,9 +378,7 @@ void Node::UnregisterDeviceAdditionListener(DeviceAdditionListener listener) { NS_LOG_FUNCTION(this << &listener); - for (DeviceAdditionListenerList::iterator i = m_deviceAdditionListeners.begin(); - i != m_deviceAdditionListeners.end(); - i++) + for (auto i = m_deviceAdditionListeners.begin(); i != m_deviceAdditionListeners.end(); i++) { if ((*i).IsEqual(listener)) { @@ -400,9 +392,7 @@ void Node::NotifyDeviceAdded(Ptr device) { NS_LOG_FUNCTION(this << device); - for (DeviceAdditionListenerList::iterator i = m_deviceAdditionListeners.begin(); - i != m_deviceAdditionListeners.end(); - i++) + for (auto i = m_deviceAdditionListeners.begin(); i != m_deviceAdditionListeners.end(); i++) { (*i)(device); } diff --git a/src/network/model/node.h b/src/network/model/node.h index e308bac7e..2994476be 100644 --- a/src/network/model/node.h +++ b/src/network/model/node.h @@ -20,8 +20,9 @@ #ifndef NODE_H #define NODE_H +#include "net-device.h" + #include "ns3/callback.h" -#include "ns3/net-device.h" #include "ns3/object.h" #include "ns3/ptr.h" diff --git a/src/network/model/packet-metadata.cc b/src/network/model/packet-metadata.cc index 1a0ae4fe1..de41f4bd3 100644 --- a/src/network/model/packet-metadata.cc +++ b/src/network/model/packet-metadata.cc @@ -47,7 +47,7 @@ std::atomic PacketMetadata::m_freeListUsing(false); PacketMetadata::DataFreeList::~DataFreeList() { NS_LOG_FUNCTION(this); - for (iterator i = begin(); i != end(); i++) + for (auto i = begin(); i != end(); i++) { PacketMetadata::Deallocate(*i); } @@ -642,8 +642,8 @@ PacketMetadata::Allocate(uint32_t n) n = PACKET_METADATA_DATA_M_DATA_SIZE; } size += n - PACKET_METADATA_DATA_M_DATA_SIZE; - uint8_t* buf = new uint8_t[size]; - PacketMetadata::Data* data = (PacketMetadata::Data*)buf; + auto buf = new uint8_t[size]; + auto data = (PacketMetadata::Data*)buf; data->m_size = n; data->m_count = 1; data->m_dirtyEnd = 0; @@ -654,7 +654,7 @@ void PacketMetadata::Deallocate(PacketMetadata::Data* data) { NS_LOG_FUNCTION(data); - uint8_t* buf = (uint8_t*)data; + auto buf = (uint8_t*)data; delete[] buf; } diff --git a/src/network/model/packet-tag-list.cc b/src/network/model/packet-tag-list.cc index 5db21d72a..3a960df77 100644 --- a/src/network/model/packet-tag-list.cc +++ b/src/network/model/packet-tag-list.cc @@ -47,7 +47,7 @@ PacketTagList::CreateTagData(size_t dataSize) void* p = std::malloc(sizeof(TagData) + dataSize - 1); // The matching frees are in RemoveAll and RemoveWriter - TagData* tag = new (p) TagData; + auto tag = new (p) TagData; tag->size = dataSize; return tag; } diff --git a/src/network/model/packet.cc b/src/network/model/packet.cc index 3b2d37a79..2a1f6d21b 100644 --- a/src/network/model/packet.cc +++ b/src/network/model/packet.cc @@ -490,7 +490,7 @@ Packet::Print(std::ostream& os) const NS_ASSERT(!constructor.IsNull()); ObjectBase* instance = constructor(); NS_ASSERT(instance != nullptr); - Chunk* chunk = dynamic_cast(instance); + auto chunk = dynamic_cast(instance); NS_ASSERT(chunk != nullptr); if (item.type == PacketMetadata::Item::HEADER) { @@ -662,7 +662,7 @@ Packet::GetSerializedSize() const uint32_t Packet::Serialize(uint8_t* buffer, uint32_t maxSize) const { - uint32_t* p = reinterpret_cast(buffer); + auto p = reinterpret_cast(buffer); uint32_t size = 0; // if nix-vector exists, serialize it @@ -825,7 +825,7 @@ Packet::Deserialize(const uint8_t* buffer, uint32_t size) { NS_LOG_FUNCTION(this); - const uint32_t* p = reinterpret_cast(buffer); + auto p = reinterpret_cast(buffer); // read nix-vector NS_ASSERT(!m_nixVector); @@ -934,7 +934,7 @@ void Packet::AddByteTag(const Tag& tag) const { NS_LOG_FUNCTION(this << tag.GetInstanceTypeId().GetName() << tag.GetSerializedSize()); - ByteTagList* list = const_cast(&m_byteTagList); + auto list = const_cast(&m_byteTagList); TagBuffer buffer = list->Add(tag.GetInstanceTypeId(), tag.GetSerializedSize(), 0, GetSize()); tag.Serialize(buffer); } @@ -944,7 +944,7 @@ Packet::AddByteTag(const Tag& tag, uint32_t start, uint32_t end) const { NS_LOG_FUNCTION(this << tag.GetInstanceTypeId().GetName() << tag.GetSerializedSize()); NS_ABORT_MSG_IF(end < start, "Invalid byte range"); - ByteTagList* list = const_cast(&m_byteTagList); + auto list = const_cast(&m_byteTagList); TagBuffer buffer = list->Add(tag.GetInstanceTypeId(), tag.GetSerializedSize(), static_cast(start), diff --git a/src/network/model/socket.cc b/src/network/model/socket.cc index fd8c2d360..c00f6c90b 100644 --- a/src/network/model/socket.cc +++ b/src/network/model/socket.cc @@ -22,10 +22,10 @@ #include "socket.h" #include "node.h" +#include "packet.h" #include "socket-factory.h" #include "ns3/log.h" -#include "ns3/packet.h" #include diff --git a/src/network/model/socket.h b/src/network/model/socket.h index 2620d5f8d..70633588e 100644 --- a/src/network/model/socket.h +++ b/src/network/model/socket.h @@ -23,14 +23,14 @@ #define NS3_SOCKET_H #include "address.h" +#include "net-device.h" +#include "tag.h" #include "ns3/callback.h" #include "ns3/inet-socket-address.h" #include "ns3/inet6-socket-address.h" -#include "ns3/net-device.h" #include "ns3/object.h" #include "ns3/ptr.h" -#include "ns3/tag.h" #include diff --git a/src/network/model/tag-buffer.cc b/src/network/model/tag-buffer.cc index 03a7b39c8..2d5ec1690 100644 --- a/src/network/model/tag-buffer.cc +++ b/src/network/model/tag-buffer.cc @@ -118,7 +118,7 @@ void TagBuffer::WriteDouble(double v) { NS_LOG_FUNCTION(this << v); - uint8_t* buf = (uint8_t*)&v; + auto buf = (uint8_t*)&v; for (uint32_t i = 0; i < sizeof(double); ++i, ++buf) { WriteU8(*buf); @@ -171,7 +171,7 @@ TagBuffer::ReadDouble() { NS_LOG_FUNCTION(this); double v; - uint8_t* buf = (uint8_t*)&v; + auto buf = (uint8_t*)&v; for (uint32_t i = 0; i < sizeof(double); ++i, ++buf) { *buf = ReadU8(); diff --git a/src/network/test/buffer-test.cc b/src/network/test/buffer-test.cc index 4f1f81e33..93e201abb 100644 --- a/src/network/test/buffer-test.cc +++ b/src/network/test/buffer-test.cc @@ -363,7 +363,7 @@ BufferTest::DoRun() NS_TEST_ASSERT_MSG_EQ(sizeBuffer, ct.size(), "Buffer bad size"); const uint8_t* evilBuffer = buffer.PeekData(); NS_TEST_ASSERT_MSG_NE(evilBuffer, 0, "Buffer PeekData failed"); - uint8_t* cBuf = (uint8_t*)malloc(sizeBuffer); + auto cBuf = (uint8_t*)malloc(sizeBuffer); uint32_t copyLen = buffer.CopyData(cBuf, sizeBuffer); NS_TEST_ASSERT_MSG_EQ(copyLen, sizeBuffer, "CopyData return bad size"); for (uint32_t i = 0; i < sizeBuffer; i++) diff --git a/src/network/test/packet-metadata-test.cc b/src/network/test/packet-metadata-test.cc index 64b723a08..217b98eae 100644 --- a/src/network/test/packet-metadata-test.cc +++ b/src/network/test/packet-metadata-test.cc @@ -381,7 +381,7 @@ PacketMetadataTest::CheckHistory(Ptr p, uint32_t n, ...) if (item.type == PacketMetadata::Item::HEADER) { Callback constructor = item.tid.GetConstructor(); - HistoryHeaderBase* header = dynamic_cast(constructor()); + auto header = dynamic_cast(constructor()); if (header == nullptr) { goto error; @@ -397,7 +397,7 @@ PacketMetadataTest::CheckHistory(Ptr p, uint32_t n, ...) else if (item.type == PacketMetadata::Item::TRAILER) { Callback constructor = item.tid.GetConstructor(); - HistoryTrailerBase* trailer = dynamic_cast(constructor()); + auto trailer = dynamic_cast(constructor()); if (trailer == nullptr) { goto error; @@ -413,7 +413,7 @@ PacketMetadataTest::CheckHistory(Ptr p, uint32_t n, ...) got.push_back(item.currentSize); } - for (std::list::iterator i = got.begin(), j = expected.begin(); i != got.end(); i++, j++) + for (auto i = got.begin(), j = expected.begin(); i != got.end(); i++, j++) { NS_ASSERT(j != expected.end()); if (*j != *i) @@ -425,12 +425,12 @@ PacketMetadataTest::CheckHistory(Ptr p, uint32_t n, ...) error: std::ostringstream failure; failure << "PacketMetadata error. Got:\""; - for (std::list::iterator i = got.begin(); i != got.end(); i++) + for (auto i = got.begin(); i != got.end(); i++) { failure << *i << ", "; } failure << "\", expected: \""; - for (std::list::iterator j = expected.begin(); j != expected.end(); j++) + for (auto j = expected.begin(); j != expected.end(); j++) { failure << *j << ", "; } @@ -872,7 +872,7 @@ PacketMetadataTest::DoRun() REM_HEADER(p3, 2); CHECK_HISTORY(p3, 1, 11); - uint8_t* buf = new uint8_t[p3->GetSize()]; + auto buf = new uint8_t[p3->GetSize()]; p3->CopyData(buf, p3->GetSize()); std::string msg = std::string(reinterpret_cast(buf), p3->GetSize()); delete[] buf; diff --git a/src/network/test/packet-test-suite.cc b/src/network/test/packet-test-suite.cc index 387f00d8c..a4780e162 100644 --- a/src/network/test/packet-test-suite.cc +++ b/src/network/test/packet-test-suite.cc @@ -632,7 +632,7 @@ PacketTest::DoRun() NS_TEST_EXPECT_MSG_EQ(packet->GetSize(), 11, "trivial"); - uint8_t* buf = new uint8_t[packet->GetSize()]; + auto buf = new uint8_t[packet->GetSize()]; packet->CopyData(buf, packet->GetSize()); std::string msg = std::string(reinterpret_cast(buf), packet->GetSize()); @@ -811,7 +811,7 @@ PacketTest::DoRun() p1->AddPacketTag(c1); uint32_t serializedSize = p1->GetSerializedSize(); - uint8_t* buffer = new uint8_t[serializedSize + 16]; + auto buffer = new uint8_t[serializedSize + 16]; p1->Serialize(buffer, serializedSize); Ptr p2 = Create(buffer, serializedSize, true); @@ -846,7 +846,7 @@ PacketTest::DoRun() CHECK(p1, 3, E(10, 0, 1000), E(11, 0, 1000), E(12, 0, 1000)); uint32_t serializedSize = p1->GetSerializedSize(); - uint8_t* buffer = new uint8_t[serializedSize]; + auto buffer = new uint8_t[serializedSize]; p1->Serialize(buffer, serializedSize); Ptr p2 = Create(buffer, serializedSize, true); diff --git a/src/network/utils/drop-tail-queue.h b/src/network/utils/drop-tail-queue.h index 0e89ee8e6..00066480b 100644 --- a/src/network/utils/drop-tail-queue.h +++ b/src/network/utils/drop-tail-queue.h @@ -18,7 +18,7 @@ #ifndef DROPTAIL_H #define DROPTAIL_H -#include "ns3/queue.h" +#include "queue.h" namespace ns3 { diff --git a/src/network/utils/error-channel.cc b/src/network/utils/error-channel.cc index 19aa2adaa..ffe32c3f0 100644 --- a/src/network/utils/error-channel.cc +++ b/src/network/utils/error-channel.cc @@ -19,10 +19,11 @@ #include "error-channel.h" +#include "simple-net-device.h" + #include "ns3/log.h" #include "ns3/node.h" #include "ns3/packet.h" -#include "ns3/simple-net-device.h" #include "ns3/simulator.h" namespace ns3 @@ -86,9 +87,7 @@ ErrorChannel::Send(Ptr p, Ptr sender) { NS_LOG_FUNCTION(p << protocol << to << from << sender); - for (std::vector>::const_iterator i = m_devices.begin(); - i != m_devices.end(); - ++i) + for (auto i = m_devices.begin(); i != m_devices.end(); ++i) { Ptr tmp = *i; if (tmp == sender) diff --git a/src/network/utils/error-channel.h b/src/network/utils/error-channel.h index adacfb9d8..4a3cd821d 100644 --- a/src/network/utils/error-channel.h +++ b/src/network/utils/error-channel.h @@ -19,11 +19,12 @@ #ifndef ERROR_CHANNEL_H #define ERROR_CHANNEL_H +#include "error-model.h" +#include "mac48-address.h" +#include "simple-channel.h" + #include "ns3/channel.h" -#include "ns3/error-model.h" -#include "ns3/mac48-address.h" #include "ns3/nstime.h" -#include "ns3/simple-channel.h" #include diff --git a/src/network/utils/error-model.cc b/src/network/utils/error-model.cc index 11d8d12ab..0a9c48bc1 100644 --- a/src/network/utils/error-model.cc +++ b/src/network/utils/error-model.cc @@ -471,7 +471,7 @@ ListErrorModel::DoCorrupt(Ptr p) return false; } auto uid = p->GetUid(); - for (PacketListCI i = m_packetList.begin(); i != m_packetList.end(); i++) + for (auto i = m_packetList.begin(); i != m_packetList.end(); i++) { if (uid == *i) { @@ -538,7 +538,7 @@ ReceiveListErrorModel::DoCorrupt(Ptr p) return false; } m_timesInvoked += 1; - for (PacketListCI i = m_packetList.begin(); i != m_packetList.end(); i++) + for (auto i = m_packetList.begin(); i != m_packetList.end(); i++) { if (m_timesInvoked - 1 == *i) { diff --git a/src/network/utils/ethernet-header.h b/src/network/utils/ethernet-header.h index f0d57e369..d0dea1696 100644 --- a/src/network/utils/ethernet-header.h +++ b/src/network/utils/ethernet-header.h @@ -20,8 +20,9 @@ #ifndef ETHERNET_HEADER_H #define ETHERNET_HEADER_H +#include "mac48-address.h" + #include "ns3/header.h" -#include "ns3/mac48-address.h" #include diff --git a/src/network/utils/ipv4-address.cc b/src/network/utils/ipv4-address.cc index fd046d80c..32a2855d6 100644 --- a/src/network/utils/ipv4-address.cc +++ b/src/network/utils/ipv4-address.cc @@ -52,7 +52,7 @@ Ipv4Mask::Ipv4Mask(const char* mask) NS_LOG_FUNCTION(this << mask); if (*mask == '/') { - uint32_t plen = static_cast(std::atoi(++mask)); + auto plen = static_cast(std::atoi(++mask)); NS_ASSERT(plen <= 32); if (plen > 0) { @@ -113,7 +113,7 @@ Ipv4Mask Ipv4Mask::GetLoopback() { NS_LOG_FUNCTION_NOARGS(); - static Ipv4Mask loopback = Ipv4Mask("255.0.0.0"); + static Ipv4Mask loopback("255.0.0.0"); return loopback; } @@ -121,7 +121,7 @@ Ipv4Mask Ipv4Mask::GetZero() { NS_LOG_FUNCTION_NOARGS(); - static Ipv4Mask zero = Ipv4Mask("0.0.0.0"); + static Ipv4Mask zero("0.0.0.0"); return zero; } @@ -129,7 +129,7 @@ Ipv4Mask Ipv4Mask::GetOnes() { NS_LOG_FUNCTION_NOARGS(); - static Ipv4Mask ones = Ipv4Mask("255.255.255.255"); + static Ipv4Mask ones("255.255.255.255"); return ones; } diff --git a/src/network/utils/ipv6-address.h b/src/network/utils/ipv6-address.h index 1e1906348..98fa39400 100644 --- a/src/network/utils/ipv6-address.h +++ b/src/network/utils/ipv6-address.h @@ -20,11 +20,11 @@ #ifndef IPV6_ADDRESS_H #define IPV6_ADDRESS_H +#include "ipv4-address.h" #include "mac8-address.h" #include "ns3/address.h" #include "ns3/attribute-helper.h" -#include "ns3/ipv4-address.h" #include #include diff --git a/src/network/utils/mac16-address.cc b/src/network/utils/mac16-address.cc index cc2c3c6e0..fcb8472e0 100644 --- a/src/network/utils/mac16-address.cc +++ b/src/network/utils/mac16-address.cc @@ -201,7 +201,7 @@ Mac16Address::GetBroadcast() { NS_LOG_FUNCTION_NOARGS(); - static Mac16Address broadcast = Mac16Address("ff:ff"); + static Mac16Address broadcast("ff:ff"); return broadcast; } diff --git a/src/network/utils/mac48-address.cc b/src/network/utils/mac48-address.cc index a292922e2..924e77ea2 100644 --- a/src/network/utils/mac48-address.cc +++ b/src/network/utils/mac48-address.cc @@ -201,7 +201,7 @@ Mac48Address Mac48Address::GetBroadcast() { NS_LOG_FUNCTION_NOARGS(); - static Mac48Address broadcast = Mac48Address("ff:ff:ff:ff:ff:ff"); + static Mac48Address broadcast("ff:ff:ff:ff:ff:ff"); return broadcast; } @@ -209,7 +209,7 @@ Mac48Address Mac48Address::GetMulticastPrefix() { NS_LOG_FUNCTION_NOARGS(); - static Mac48Address multicast = Mac48Address("01:00:5e:00:00:00"); + static Mac48Address multicast("01:00:5e:00:00:00"); return multicast; } @@ -217,7 +217,7 @@ Mac48Address Mac48Address::GetMulticast6Prefix() { NS_LOG_FUNCTION_NOARGS(); - static Mac48Address multicast = Mac48Address("33:33:00:00:00:00"); + static Mac48Address multicast("33:33:00:00:00:00"); return multicast; } diff --git a/src/network/utils/net-device-queue-interface.cc b/src/network/utils/net-device-queue-interface.cc index 32b40644e..1bc361039 100644 --- a/src/network/utils/net-device-queue-interface.cc +++ b/src/network/utils/net-device-queue-interface.cc @@ -17,11 +17,12 @@ * Author: Stefano Avallone */ -#include "ns3/net-device-queue-interface.h" +#include "net-device-queue-interface.h" + +#include "queue-item.h" +#include "queue-limits.h" #include "ns3/abort.h" -#include "ns3/queue-item.h" -#include "ns3/queue-limits.h" #include "ns3/uinteger.h" namespace ns3 diff --git a/src/network/utils/output-stream-wrapper.cc b/src/network/utils/output-stream-wrapper.cc index 4fb7d9f49..ef509d707 100644 --- a/src/network/utils/output-stream-wrapper.cc +++ b/src/network/utils/output-stream-wrapper.cc @@ -32,7 +32,7 @@ OutputStreamWrapper::OutputStreamWrapper(std::string filename, std::ios::openmod : m_destroyable(true) { NS_LOG_FUNCTION(this << filename << filemode); - std::ofstream* os = new std::ofstream(); + auto os = new std::ofstream(); os->open(filename, filemode); m_ostream = os; FatalImpl::RegisterStream(m_ostream); diff --git a/src/network/utils/packet-burst.cc b/src/network/utils/packet-burst.cc index 675f2929e..9c1bff671 100644 --- a/src/network/utils/packet-burst.cc +++ b/src/network/utils/packet-burst.cc @@ -50,8 +50,7 @@ PacketBurst::PacketBurst() PacketBurst::~PacketBurst() { NS_LOG_FUNCTION(this); - for (std::list>::const_iterator iter = m_packets.begin(); iter != m_packets.end(); - ++iter) + for (auto iter = m_packets.begin(); iter != m_packets.end(); ++iter) { (*iter)->Unref(); } @@ -70,8 +69,7 @@ PacketBurst::Copy() const NS_LOG_FUNCTION(this); Ptr burst = Create(); - for (std::list>::const_iterator iter = m_packets.begin(); iter != m_packets.end(); - ++iter) + for (auto iter = m_packets.begin(); iter != m_packets.end(); ++iter) { Ptr packet = (*iter)->Copy(); burst->AddPacket(packet); @@ -108,8 +106,7 @@ PacketBurst::GetSize() const { NS_LOG_FUNCTION(this); uint32_t size = 0; - for (std::list>::const_iterator iter = m_packets.begin(); iter != m_packets.end(); - ++iter) + for (auto iter = m_packets.begin(); iter != m_packets.end(); ++iter) { Ptr packet = *iter; size += packet->GetSize(); diff --git a/src/network/utils/packet-data-calculators.cc b/src/network/utils/packet-data-calculators.cc index 18ea532b9..16f511ca5 100644 --- a/src/network/utils/packet-data-calculators.cc +++ b/src/network/utils/packet-data-calculators.cc @@ -19,9 +19,10 @@ #include "packet-data-calculators.h" +#include "mac48-address.h" + #include "ns3/basic-data-calculators.h" #include "ns3/log.h" -#include "ns3/mac48-address.h" #include "ns3/packet.h" using namespace ns3; diff --git a/src/network/utils/packet-data-calculators.h b/src/network/utils/packet-data-calculators.h index d77e2ec26..73b99d16f 100644 --- a/src/network/utils/packet-data-calculators.h +++ b/src/network/utils/packet-data-calculators.h @@ -20,9 +20,10 @@ #ifndef PACKET_DATA_CALCULATORS_H #define PACKET_DATA_CALCULATORS_H +#include "mac48-address.h" + #include "ns3/basic-data-calculators.h" #include "ns3/data-calculator.h" -#include "ns3/mac48-address.h" #include "ns3/packet.h" namespace ns3 diff --git a/src/network/utils/packet-probe.cc b/src/network/utils/packet-probe.cc index 42423e701..eebeeb8ec 100644 --- a/src/network/utils/packet-probe.cc +++ b/src/network/utils/packet-probe.cc @@ -20,7 +20,7 @@ * Modified by: Mitch Watrous (watrous@u.washington.edu) */ -#include "ns3/packet-probe.h" +#include "packet-probe.h" #include "ns3/config.h" #include "ns3/log.h" diff --git a/src/network/utils/packet-socket-client.cc b/src/network/utils/packet-socket-client.cc index dcdcbab08..61eb94f5d 100644 --- a/src/network/utils/packet-socket-client.cc +++ b/src/network/utils/packet-socket-client.cc @@ -19,12 +19,13 @@ #include "packet-socket-client.h" +#include "packet-socket-address.h" +#include "packet-socket-factory.h" +#include "packet-socket.h" + #include "ns3/abort.h" #include "ns3/log.h" #include "ns3/nstime.h" -#include "ns3/packet-socket-address.h" -#include "ns3/packet-socket-factory.h" -#include "ns3/packet-socket.h" #include "ns3/packet.h" #include "ns3/simulator.h" #include "ns3/socket-factory.h" diff --git a/src/network/utils/packet-socket-client.h b/src/network/utils/packet-socket-client.h index 1da59f926..f20d479ea 100644 --- a/src/network/utils/packet-socket-client.h +++ b/src/network/utils/packet-socket-client.h @@ -20,9 +20,10 @@ #ifndef PACKET_SOCKET_CLIENT_H #define PACKET_SOCKET_CLIENT_H +#include "packet-socket-address.h" + #include "ns3/application.h" #include "ns3/event-id.h" -#include "ns3/packet-socket-address.h" #include "ns3/ptr.h" #include "ns3/traced-callback.h" diff --git a/src/network/utils/packet-socket-server.cc b/src/network/utils/packet-socket-server.cc index 932a9ee10..45d384eb0 100644 --- a/src/network/utils/packet-socket-server.cc +++ b/src/network/utils/packet-socket-server.cc @@ -19,12 +19,13 @@ #include "packet-socket-server.h" +#include "packet-socket-address.h" +#include "packet-socket-factory.h" +#include "packet-socket.h" + #include "ns3/abort.h" #include "ns3/log.h" #include "ns3/nstime.h" -#include "ns3/packet-socket-address.h" -#include "ns3/packet-socket-factory.h" -#include "ns3/packet-socket.h" #include "ns3/packet.h" #include "ns3/simulator.h" #include "ns3/socket-factory.h" diff --git a/src/network/utils/packet-socket-server.h b/src/network/utils/packet-socket-server.h index 1960f446a..a3cfcc2ec 100644 --- a/src/network/utils/packet-socket-server.h +++ b/src/network/utils/packet-socket-server.h @@ -20,9 +20,10 @@ #ifndef PACKET_SOCKET_SERVER_H #define PACKET_SOCKET_SERVER_H +#include "packet-socket-address.h" + #include "ns3/application.h" #include "ns3/event-id.h" -#include "ns3/packet-socket-address.h" #include "ns3/ptr.h" #include "ns3/traced-callback.h" diff --git a/src/network/utils/packet-socket.cc b/src/network/utils/packet-socket.cc index 690efe12a..12c03dc08 100644 --- a/src/network/utils/packet-socket.cc +++ b/src/network/utils/packet-socket.cc @@ -659,7 +659,7 @@ void DeviceNameTag::Serialize(TagBuffer i) const { const char* n = m_deviceName.c_str(); - uint8_t l = (uint8_t)m_deviceName.size(); + auto l = (uint8_t)m_deviceName.size(); i.WriteU8(l); i.Write((uint8_t*)n, (uint32_t)l); diff --git a/src/network/utils/packetbb.cc b/src/network/utils/packetbb.cc index 751da7fcd..f820d7d70 100644 --- a/src/network/utils/packetbb.cc +++ b/src/network/utils/packetbb.cc @@ -23,9 +23,10 @@ #include "packetbb.h" +#include "ipv4-address.h" +#include "ipv6-address.h" + #include "ns3/assert.h" -#include "ns3/ipv4-address.h" -#include "ns3/ipv6-address.h" #include "ns3/log.h" static const uint8_t VERSION = 0; @@ -181,7 +182,7 @@ void PbbTlvBlock::Clear() { NS_LOG_FUNCTION(this); - for (Iterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { *iter = nullptr; } @@ -194,7 +195,7 @@ PbbTlvBlock::GetSerializedSize() const NS_LOG_FUNCTION(this); /* tlv size */ uint32_t size = 2; - for (ConstIterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { size += (*iter)->GetSerializedSize(); } @@ -215,7 +216,7 @@ PbbTlvBlock::Serialize(Buffer::Iterator& start) const * position. */ Buffer::Iterator tlvsize = start; start.Next(2); - for (ConstIterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { (*iter)->Serialize(start); } @@ -263,7 +264,7 @@ PbbTlvBlock::Print(std::ostream& os, int level) const os << prefix << "\tsize = " << Size() << std::endl; os << prefix << "\tmembers [" << std::endl; - for (ConstIterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { (*iter)->Print(os, level + 2); } @@ -420,7 +421,7 @@ void PbbAddressTlvBlock::Clear() { NS_LOG_FUNCTION(this); - for (Iterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { *iter = nullptr; } @@ -433,7 +434,7 @@ PbbAddressTlvBlock::GetSerializedSize() const NS_LOG_FUNCTION(this); /* tlv size */ uint32_t size = 2; - for (ConstIterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { size += (*iter)->GetSerializedSize(); } @@ -454,7 +455,7 @@ PbbAddressTlvBlock::Serialize(Buffer::Iterator& start) const * position. */ Buffer::Iterator tlvsize = start; start.Next(2); - for (ConstIterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { (*iter)->Serialize(start); } @@ -502,7 +503,7 @@ PbbAddressTlvBlock::Print(std::ostream& os, int level) const os << prefix << "\tsize = " << Size() << std::endl; os << prefix << "\tmembers [" << std::endl; - for (ConstIterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { (*iter)->Print(os, level + 2); } @@ -821,7 +822,7 @@ void PbbPacket::MessageClear() { NS_LOG_FUNCTION(this); - for (MessageIterator iter = MessageBegin(); iter != MessageEnd(); iter++) + for (auto iter = MessageBegin(); iter != MessageEnd(); iter++) { *iter = nullptr; } @@ -861,7 +862,7 @@ PbbPacket::GetSerializedSize() const size += m_tlvList.GetSerializedSize(); } - for (ConstMessageIterator iter = MessageBegin(); iter != MessageEnd(); iter++) + for (auto iter = MessageBegin(); iter != MessageEnd(); iter++) { size += (*iter)->GetSerializedSize(); } @@ -896,7 +897,7 @@ PbbPacket::Serialize(Buffer::Iterator start) const bufref.WriteU8(flags); - for (ConstMessageIterator iter = MessageBegin(); iter != MessageEnd(); iter++) + for (auto iter = MessageBegin(); iter != MessageEnd(); iter++) { (*iter)->Serialize(start); } @@ -951,7 +952,7 @@ PbbPacket::Print(std::ostream& os) const m_tlvList.Print(os, 1); - for (ConstMessageIterator iter = MessageBegin(); iter != MessageEnd(); iter++) + for (auto iter = MessageBegin(); iter != MessageEnd(); iter++) { (*iter)->Print(os, 1); } @@ -1382,7 +1383,7 @@ void PbbMessage::AddressBlockClear() { NS_LOG_FUNCTION(this); - for (AddressBlockIterator iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) + for (auto iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) { *iter = nullptr; } @@ -1418,7 +1419,7 @@ PbbMessage::GetSerializedSize() const size += m_tlvList.GetSerializedSize(); - for (ConstAddressBlockIterator iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) + for (auto iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) { size += (*iter)->GetSerializedSize(); } @@ -1473,7 +1474,7 @@ PbbMessage::Serialize(Buffer::Iterator& start) const m_tlvList.Serialize(start); - for (ConstAddressBlockIterator iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) + for (auto iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) { (*iter)->Serialize(start); } @@ -1601,7 +1602,7 @@ PbbMessage::Print(std::ostream& os, int level) const m_tlvList.Print(os, level + 1); - for (ConstAddressBlockIterator iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) + for (auto iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) { (*iter)->Print(os, level + 1); } @@ -1721,7 +1722,7 @@ void PbbMessageIpv4::SerializeOriginatorAddress(Buffer::Iterator& start) const { NS_LOG_FUNCTION(this << &start); - uint8_t* buffer = new uint8_t[GetAddressLength() + 1]; + auto buffer = new uint8_t[GetAddressLength() + 1]; Ipv4Address::ConvertFrom(GetOriginatorAddress()).Serialize(buffer); start.Write(buffer, GetAddressLength() + 1); delete[] buffer; @@ -1731,7 +1732,7 @@ Address PbbMessageIpv4::DeserializeOriginatorAddress(Buffer::Iterator& start) const { NS_LOG_FUNCTION(this << &start); - uint8_t* buffer = new uint8_t[GetAddressLength() + 1]; + auto buffer = new uint8_t[GetAddressLength() + 1]; start.Read(buffer, GetAddressLength() + 1); Address result = Ipv4Address::Deserialize(buffer); delete[] buffer; @@ -1772,7 +1773,7 @@ void PbbMessageIpv6::SerializeOriginatorAddress(Buffer::Iterator& start) const { NS_LOG_FUNCTION(this << &start); - uint8_t* buffer = new uint8_t[GetAddressLength() + 1]; + auto buffer = new uint8_t[GetAddressLength() + 1]; Ipv6Address::ConvertFrom(GetOriginatorAddress()).Serialize(buffer); start.Write(buffer, GetAddressLength() + 1); delete[] buffer; @@ -1782,7 +1783,7 @@ Address PbbMessageIpv6::DeserializeOriginatorAddress(Buffer::Iterator& start) const { NS_LOG_FUNCTION(this << &start); - uint8_t* buffer = new uint8_t[GetAddressLength() + 1]; + auto buffer = new uint8_t[GetAddressLength() + 1]; start.Read(buffer, GetAddressLength() + 1); Address res = Ipv6Address::Deserialize(buffer); delete[] buffer; @@ -2174,9 +2175,9 @@ PbbAddressBlock::GetSerializedSize() const } else if (AddressSize() > 0) { - uint8_t* head = new uint8_t[GetAddressLength()]; + auto head = new uint8_t[GetAddressLength()]; uint8_t headlen = 0; - uint8_t* tail = new uint8_t[GetAddressLength()]; + auto tail = new uint8_t[GetAddressLength()]; uint8_t taillen = 0; GetHeadTail(head, headlen, tail, taillen); @@ -2220,7 +2221,7 @@ PbbAddressBlock::Serialize(Buffer::Iterator& start) const if (AddressSize() == 1) { - uint8_t* buf = new uint8_t[GetAddressLength()]; + auto buf = new uint8_t[GetAddressLength()]; SerializeAddress(buf, AddressBegin()); start.Write(buf, GetAddressLength()); @@ -2234,8 +2235,8 @@ PbbAddressBlock::Serialize(Buffer::Iterator& start) const } else if (AddressSize() > 0) { - uint8_t* head = new uint8_t[GetAddressLength()]; - uint8_t* tail = new uint8_t[GetAddressLength()]; + auto head = new uint8_t[GetAddressLength()]; + auto tail = new uint8_t[GetAddressLength()]; uint8_t headlen = 0; uint8_t taillen = 0; @@ -2265,9 +2266,8 @@ PbbAddressBlock::Serialize(Buffer::Iterator& start) const if (headlen + taillen < GetAddressLength()) { - uint8_t* mid = new uint8_t[GetAddressLength()]; - for (PbbAddressBlock::ConstAddressIterator iter = AddressBegin(); iter != AddressEnd(); - iter++) + auto mid = new uint8_t[GetAddressLength()]; + for (auto iter = AddressBegin(); iter != AddressEnd(); iter++) { SerializeAddress(mid, iter); start.Write(mid + headlen, GetAddressLength() - headlen - taillen); @@ -2278,7 +2278,7 @@ PbbAddressBlock::Serialize(Buffer::Iterator& start) const flags |= GetPrefixFlags(); bufref.WriteU8(flags); - for (ConstPrefixIterator iter = PrefixBegin(); iter != PrefixEnd(); iter++) + for (auto iter = PrefixBegin(); iter != PrefixEnd(); iter++) { start.WriteU8(*iter); } @@ -2301,7 +2301,7 @@ PbbAddressBlock::Deserialize(Buffer::Iterator& start) { uint8_t headlen = 0; uint8_t taillen = 0; - uint8_t* addrtmp = new uint8_t[GetAddressLength()]; + auto addrtmp = new uint8_t[GetAddressLength()]; memset(addrtmp, 0, GetAddressLength()); if (flags & AHAS_HEAD) @@ -2363,7 +2363,7 @@ PbbAddressBlock::Print(std::ostream& os, int level) const os << prefix << "PbbAddressBlock {" << std::endl; os << prefix << "\taddresses = " << std::endl; - for (ConstAddressIterator iter = AddressBegin(); iter != AddressEnd(); iter++) + for (auto iter = AddressBegin(); iter != AddressEnd(); iter++) { os << prefix << "\t\t"; PrintAddress(os, iter); @@ -2371,7 +2371,7 @@ PbbAddressBlock::Print(std::ostream& os, int level) const } os << prefix << "\tprefixes = " << std::endl; - for (ConstPrefixIterator iter = PrefixBegin(); iter != PrefixEnd(); iter++) + for (auto iter = PrefixBegin(); iter != PrefixEnd(); iter++) { os << prefix << "\t\t" << (int)(*iter) << std::endl; } @@ -2452,15 +2452,14 @@ PbbAddressBlock::GetHeadTail(uint8_t* head, uint8_t& headlen, uint8_t* tail, uin taillen = headlen; /* Temporary automatic buffers to store serialized addresses */ - uint8_t* buflast = new uint8_t[GetAddressLength()]; - uint8_t* bufcur = new uint8_t[GetAddressLength()]; + auto buflast = new uint8_t[GetAddressLength()]; + auto bufcur = new uint8_t[GetAddressLength()]; uint8_t* tmp; SerializeAddress(buflast, AddressBegin()); /* Skip the first item */ - for (PbbAddressBlock::ConstAddressIterator iter = AddressBegin()++; iter != AddressEnd(); - iter++) + for (auto iter = AddressBegin()++; iter != AddressEnd(); iter++) { SerializeAddress(bufcur, iter); diff --git a/src/network/utils/pcap-file.cc b/src/network/utils/pcap-file.cc index dd022f02c..9470484a7 100644 --- a/src/network/utils/pcap-file.cc +++ b/src/network/utils/pcap-file.cc @@ -404,7 +404,7 @@ PcapFile::Init(uint32_t dataLinkType, // // And set swap mode if requested or we are on a big-endian system. // - m_swapMode = swapMode | bigEndian; + m_swapMode = swapMode || bigEndian; WriteFileHeader(); } @@ -552,8 +552,8 @@ PcapFile::Diff(const std::string& f1, return true; } - uint8_t* data1 = new uint8_t[snapLen](); - uint8_t* data2 = new uint8_t[snapLen](); + auto data1 = new uint8_t[snapLen](); + auto data2 = new uint8_t[snapLen](); uint32_t tsSec1 = 0; uint32_t tsSec2 = 0; uint32_t tsUsec1 = 0; diff --git a/src/network/utils/queue.h b/src/network/utils/queue.h index a42a57ea9..f346649cf 100644 --- a/src/network/utils/queue.h +++ b/src/network/utils/queue.h @@ -22,12 +22,13 @@ #ifndef QUEUE_H #define QUEUE_H +#include "queue-fwd.h" +#include "queue-item.h" +#include "queue-size.h" + #include "ns3/log.h" #include "ns3/object.h" #include "ns3/packet.h" -#include "ns3/queue-fwd.h" -#include "ns3/queue-item.h" -#include "ns3/queue-size.h" #include "ns3/traced-callback.h" #include "ns3/traced-value.h" diff --git a/src/network/utils/simple-channel.cc b/src/network/utils/simple-channel.cc index 5ba3db453..40e34e6ab 100644 --- a/src/network/utils/simple-channel.cc +++ b/src/network/utils/simple-channel.cc @@ -62,9 +62,7 @@ SimpleChannel::Send(Ptr p, Ptr sender) { NS_LOG_FUNCTION(this << p << protocol << to << from << sender); - for (std::vector>::const_iterator i = m_devices.begin(); - i != m_devices.end(); - ++i) + for (auto i = m_devices.begin(); i != m_devices.end(); ++i) { Ptr tmp = *i; if (tmp == sender) @@ -133,8 +131,7 @@ SimpleChannel::UnBlackList(Ptr from, Ptr to) { if (m_blackListedDevices.find(to) != m_blackListedDevices.end()) { - std::vector>::iterator iter; - iter = find(m_blackListedDevices[to].begin(), m_blackListedDevices[to].end(), from); + auto iter = find(m_blackListedDevices[to].begin(), m_blackListedDevices[to].end(), from); if (iter != m_blackListedDevices[to].end()) { m_blackListedDevices[to].erase(iter); diff --git a/src/network/utils/simple-net-device.cc b/src/network/utils/simple-net-device.cc index e58f8a54b..62279614c 100644 --- a/src/network/utils/simple-net-device.cc +++ b/src/network/utils/simple-net-device.cc @@ -18,15 +18,15 @@ */ #include "simple-net-device.h" +#include "error-model.h" +#include "queue.h" #include "simple-channel.h" #include "ns3/boolean.h" -#include "ns3/error-model.h" #include "ns3/log.h" #include "ns3/node.h" #include "ns3/packet.h" #include "ns3/pointer.h" -#include "ns3/queue.h" #include "ns3/simulator.h" #include "ns3/string.h" #include "ns3/tag.h" diff --git a/src/network/utils/simple-net-device.h b/src/network/utils/simple-net-device.h index 0f3dde9b3..86781d669 100644 --- a/src/network/utils/simple-net-device.h +++ b/src/network/utils/simple-net-device.h @@ -19,12 +19,12 @@ #ifndef SIMPLE_NET_DEVICE_H #define SIMPLE_NET_DEVICE_H +#include "data-rate.h" #include "mac48-address.h" +#include "queue-fwd.h" -#include "ns3/data-rate.h" #include "ns3/event-id.h" #include "ns3/net-device.h" -#include "ns3/queue-fwd.h" #include "ns3/traced-callback.h" #include diff --git a/src/nix-vector-routing/examples/nms-p2p-nix.cc b/src/nix-vector-routing/examples/nms-p2p-nix.cc index c44f833e9..7ec60cd43 100644 --- a/src/nix-vector-routing/examples/nms-p2p-nix.cc +++ b/src/nix-vector-routing/examples/nms-p2p-nix.cc @@ -193,7 +193,7 @@ main(int argc, char* argv[]) Array2D nodes_net0(nCN, 3); Array2D nodes_net1(nCN, 6); - NodeContainer* nodes_netLR = new NodeContainer[nCN]; + auto nodes_netLR = new NodeContainer[nCN]; Array2D nodes_net2(nCN, 14); Array3D nodes_net2LAN(nCN, 7, nLANClients); Array2D nodes_net3(nCN, 9); @@ -599,7 +599,7 @@ main(int argc, char* argv[]) if (nCN > 1) { std::cout << "Forming Ring Topology..." << std::endl; - NodeContainer* nodes_ring = new NodeContainer[nCN]; + auto nodes_ring = new NodeContainer[nCN]; for (int z = 0; z < nCN - 1; ++z) { nodes_ring[z].Add(nodes_net0[z][0].Get(0)); @@ -607,7 +607,7 @@ main(int argc, char* argv[]) } nodes_ring[nCN - 1].Add(nodes_net0[nCN - 1][0].Get(0)); nodes_ring[nCN - 1].Add(nodes_net0[0][0].Get(0)); - NetDeviceContainer* ndc_ring = new NetDeviceContainer[nCN]; + auto ndc_ring = new NetDeviceContainer[nCN]; for (int z = 0; z < nCN; ++z) { ndc_ring[z] = p2p_2gb200ms.Install(nodes_ring[z]); diff --git a/src/nix-vector-routing/model/nix-vector-routing.cc b/src/nix-vector-routing/model/nix-vector-routing.cc index fab4ef005..85ef8ffc4 100644 --- a/src/nix-vector-routing/model/nix-vector-routing.cc +++ b/src/nix-vector-routing/model/nix-vector-routing.cc @@ -165,8 +165,7 @@ NixVectorRouting::FlushGlobalNixRoutingCache() const { NS_LOG_FUNCTION_NOARGS(); - NodeList::Iterator listEnd = NodeList::End(); - for (NodeList::Iterator i = NodeList::Begin(); i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; Ptr> rp = node->GetObject(); @@ -265,7 +264,7 @@ NixVectorRouting::GetNixVectorInCache(const IpAddress& address, bool& foundIn CheckCacheStateAndFlush(); - typename NixMap_t::iterator iter = m_nixCache.find(address); + auto iter = m_nixCache.find(address); if (iter != m_nixCache.end()) { NS_LOG_LOGIC("Found Nix-vector in cache."); @@ -286,7 +285,7 @@ NixVectorRouting::GetIpRouteInCache(IpAddress address) CheckCacheStateAndFlush(); - typename IpRouteMap_t::iterator iter = m_ipRouteCache.find(address); + auto iter = m_ipRouteCache.find(address); if (iter != m_ipRouteCache.end()) { NS_LOG_LOGIC("Found IpRoute in cache."); @@ -351,9 +350,7 @@ NixVectorRouting::BuildNixVector(const std::vector>& parentVector, // the index to the nix vector. // the index corresponds to the neighbor index uint32_t offset = 0; - for (NetDeviceContainer::Iterator iter = netDeviceContainer.Begin(); - iter != netDeviceContainer.End(); - iter++) + for (auto iter = netDeviceContainer.Begin(); iter != netDeviceContainer.End(); iter++) { Ptr remoteNode = (*iter)->GetNode(); @@ -483,7 +480,7 @@ NixVectorRouting::BuildIpAddressToNodeMap() const { NS_LOG_FUNCTION_NOARGS(); - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; Ptr ip = node->GetObject(); @@ -562,7 +559,7 @@ NixVectorRouting::GetNodeByIp(IpAddress dest) const Ptr destNode; - typename IpAddressToNodeMap::iterator iter = g_ipAddressToNodeMap.find(dest); + auto iter = g_ipAddressToNodeMap.find(dest); if (iter == g_ipAddressToNodeMap.end()) { @@ -606,7 +603,7 @@ NixVectorRouting::GetInterfaceByNetDevice(Ptr netDevice) const Ptr ipInterface; - typename NetDeviceToIpInterfaceMap::iterator iter = g_netdeviceToIpInterfaceMap.find(netDevice); + auto iter = g_netdeviceToIpInterfaceMap.find(netDevice); if (iter == g_netdeviceToIpInterfaceMap.end()) { @@ -1072,8 +1069,7 @@ NixVectorRouting::PrintRoutingTable(Ptr stream, Time::Un { *os << std::setw(30) << "Destination"; *os << "NixVector" << std::endl; - for (typename NixMap_t::const_iterator it = m_nixCache.begin(); it != m_nixCache.end(); - it++) + for (auto it = m_nixCache.begin(); it != m_nixCache.end(); it++) { std::ostringstream dest; dest << it->first; @@ -1096,9 +1092,7 @@ NixVectorRouting::PrintRoutingTable(Ptr stream, Time::Un *os << std::setw(30) << "Gateway"; *os << std::setw(30) << "Source"; *os << "OutputDevice" << std::endl; - for (typename IpRouteMap_t::const_iterator it = m_ipRouteCache.begin(); - it != m_ipRouteCache.end(); - it++) + for (auto it = m_ipRouteCache.begin(); it != m_ipRouteCache.end(); it++) { std::ostringstream dest; std::ostringstream gw; @@ -1268,9 +1262,7 @@ NixVectorRouting::BFS(uint32_t numberOfNodes, // and scan through them. We push them // to the greyNode queue, if they aren't // already there. - for (NetDeviceContainer::Iterator iter = netDeviceContainer.Begin(); - iter != netDeviceContainer.End(); - iter++) + for (auto iter = netDeviceContainer.Begin(); iter != netDeviceContainer.End(); iter++) { Ptr remoteNode = (*iter)->GetNode(); Ptr remoteIpInterface = GetInterfaceByNetDevice(*iter); @@ -1332,8 +1324,7 @@ NixVectorRouting::BFS(uint32_t numberOfNodes, // and scan through them. We push them // to the greyNode queue, if they aren't // already there. - for (NetDeviceContainer::Iterator iter = netDeviceContainer.Begin(); - iter != netDeviceContainer.End(); + for (auto iter = netDeviceContainer.Begin(); iter != netDeviceContainer.End(); iter++) { Ptr remoteNode = (*iter)->GetNode(); diff --git a/src/olsr/examples/olsr-hna.cc b/src/olsr/examples/olsr-hna.cc index 457ecb23d..e19de7c92 100644 --- a/src/olsr/examples/olsr-hna.cc +++ b/src/olsr/examples/olsr-hna.cc @@ -41,12 +41,12 @@ // One way is to use olsr::RoutingProtocol::SetRoutingTableAssociation () // to use which you may run: // -// ./ns3 run "olsr-hna --assocMethod1=1" +// ./ns3 run "olsr-hna --assocMethod=SetRoutingTable" // // The other way is to use olsr::RoutingProtocol::AddHostNetworkAssociation () // to use which you may run: // -// ./ns3 run "olsr-hna --assocMethod2=1" +// ./ns3 run "olsr-hna --assocMethod=AddHostNetwork" // #include "ns3/config-store-module.h" @@ -102,8 +102,8 @@ main(int argc, char* argv[]) uint32_t numPackets = 1; double interval = 1.0; // seconds bool verbose = false; - bool assocMethod1 = false; - bool assocMethod2 = false; + std::string assocMethod("SetRoutingTable"); + bool reverse = false; CommandLine cmd(__FILE__); @@ -113,8 +113,11 @@ main(int argc, char* argv[]) cmd.AddValue("numPackets", "number of packets generated", numPackets); cmd.AddValue("interval", "interval (seconds) between packets", interval); cmd.AddValue("verbose", "turn on all WifiNetDevice log components", verbose); - cmd.AddValue("assocMethod1", "Use SetRoutingTableAssociation () method", assocMethod1); - cmd.AddValue("assocMethod2", "Use AddHostNetworkAssociation () method", assocMethod2); + cmd.AddValue("assocMethod", + "How to add the host to the HNA table (SetRoutingTable, " + "AddHostNetwork)", + assocMethod); + cmd.AddValue("reverse", "Send packets from CSMA to WiFi if set to true", reverse); cmd.Parse(argc, argv); // Convert to time object @@ -210,34 +213,39 @@ main(int argc, char* argv[]) ipv4.Assign(csmaDevices); TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory"); - Ptr recvSink = Socket::CreateSocket(csmaNodes.Get(0), tid); + Ptr recvSink; + if (!reverse) + { + recvSink = Socket::CreateSocket(csmaNodes.Get(0), tid); + } + else + { + recvSink = Socket::CreateSocket(olsrNodes.Get(0), tid); + } InetSocketAddress local = InetSocketAddress(Ipv4Address::GetAny(), 80); recvSink->Bind(local); recvSink->SetRecvCallback(MakeCallback(&ReceivePacket)); - Ptr source = Socket::CreateSocket(olsrNodes.Get(0), tid); - InetSocketAddress remote = InetSocketAddress(Ipv4Address("172.16.1.1"), 80); - source->Connect(remote); + Ptr source; + if (!reverse) + { + source = Socket::CreateSocket(olsrNodes.Get(0), tid); + InetSocketAddress remote = InetSocketAddress(Ipv4Address("172.16.1.1"), 80); + source->Connect(remote); + } + else + { + source = Socket::CreateSocket(csmaNodes.Get(0), tid); + InetSocketAddress remote = InetSocketAddress(Ipv4Address("10.1.1.1"), 80); + source->Connect(remote); + } // Obtain olsr::RoutingProtocol instance of gateway node // (namely, node B) and add the required association - Ptr stack = olsrNodes.Get(1)->GetObject(); - Ptr rp_Gw = (stack->GetRoutingProtocol()); - Ptr lrp_Gw = DynamicCast(rp_Gw); + Ptr olsrrp_Gw = Ipv4RoutingHelper::GetRouting( + olsrNodes.Get(1)->GetObject()->GetRoutingProtocol()); - Ptr olsrrp_Gw; - - for (uint32_t i = 0; i < lrp_Gw->GetNRoutingProtocols(); i++) - { - int16_t priority; - Ptr temp = lrp_Gw->GetRoutingProtocol(i, priority); - if (DynamicCast(temp)) - { - olsrrp_Gw = DynamicCast(temp); - } - } - - if (assocMethod1) + if (assocMethod == "SetRoutingTable") { // Create a special Ipv4StaticRouting instance for RoutingTableAssociation // Even the Ipv4StaticRouting instance added to list may be used @@ -252,16 +260,26 @@ main(int argc, char* argv[]) uint32_t(1)); olsrrp_Gw->SetRoutingTableAssociation(hnaEntries); } - - if (assocMethod2) + else if (assocMethod == "AddHostNetwork") { // Specify the required associations directly. olsrrp_Gw->AddHostNetworkAssociation(Ipv4Address("172.16.1.0"), Ipv4Mask("255.255.255.0")); } + else + { + std::cout << "invalid HnaMethod option (" << assocMethod << ")" << std::endl; + exit(0); + } + + // Add a default route to the CSMA node (to enable replies) + Ptr staticRoutingProt; + staticRoutingProt = Ipv4RoutingHelper::GetRouting( + csmaNodes.Get(0)->GetObject()->GetRoutingProtocol()); + staticRoutingProt->AddNetworkRouteTo("10.1.1.0", "255.255.255.0", "172.16.1.2", 1); // Tracing - wifiPhy.EnablePcap("olsr-hna", devices); - csma.EnablePcap("olsr-hna", csmaDevices, false); + wifiPhy.EnablePcap("olsr-hna-wifi", devices); + csma.EnablePcap("olsr-hna-csma", csmaDevices, false); AsciiTraceHelper ascii; wifiPhy.EnableAsciiAll(ascii.CreateFileStream("olsr-hna-wifi.tr")); csma.EnableAsciiAll(ascii.CreateFileStream("olsr-hna-csma.tr")); @@ -274,6 +292,10 @@ main(int argc, char* argv[]) numPackets, interPacketInterval); + Ptr routingStream = + Create("olsr-hna.routes", std::ios::out); + Ipv4RoutingHelper::PrintRoutingTableAllAt(Seconds(15), routingStream); + Simulator::Stop(Seconds(20.0)); Simulator::Run(); Simulator::Destroy(); diff --git a/src/olsr/helper/olsr-helper.cc b/src/olsr/helper/olsr-helper.cc index 38be92fef..38c3c2f4a 100644 --- a/src/olsr/helper/olsr-helper.cc +++ b/src/olsr/helper/olsr-helper.cc @@ -47,7 +47,7 @@ OlsrHelper::Copy() const void OlsrHelper::ExcludeInterface(Ptr node, uint32_t interface) { - std::map, std::set>::iterator it = m_interfaceExclusions.find(node); + auto it = m_interfaceExclusions.find(node); if (it == m_interfaceExclusions.end()) { @@ -67,7 +67,7 @@ OlsrHelper::Create(Ptr node) const { Ptr agent = m_agentFactory.Create(); - std::map, std::set>::const_iterator it = m_interfaceExclusions.find(node); + auto it = m_interfaceExclusions.find(node); if (it != m_interfaceExclusions.end()) { @@ -89,7 +89,7 @@ OlsrHelper::AssignStreams(NodeContainer c, int64_t stream) { int64_t currentStream = stream; Ptr node; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); Ptr ipv4 = node->GetObject(); diff --git a/src/olsr/model/olsr-header.cc b/src/olsr/model/olsr-header.cc index b7c865563..632962aea 100644 --- a/src/olsr/model/olsr-header.cc +++ b/src/olsr/model/olsr-header.cc @@ -352,8 +352,7 @@ MessageHeader::Mid::Serialize(Buffer::Iterator start) const { Buffer::Iterator i = start; - for (std::vector::const_iterator iter = this->interfaceAddresses.begin(); - iter != this->interfaceAddresses.end(); + for (auto iter = this->interfaceAddresses.begin(); iter != this->interfaceAddresses.end(); iter++) { i.WriteHtonU32(iter->Get()); @@ -384,9 +383,7 @@ uint32_t MessageHeader::Hello::GetSerializedSize() const { uint32_t size = 4; - for (std::vector::const_iterator iter = this->linkMessages.begin(); - iter != this->linkMessages.end(); - iter++) + for (auto iter = this->linkMessages.begin(); iter != this->linkMessages.end(); iter++) { const LinkMessage& lm = *iter; size += 4; @@ -432,9 +429,7 @@ MessageHeader::Hello::Serialize(Buffer::Iterator start) const i.WriteU8(this->hTime); i.WriteU8(static_cast(this->willingness)); - for (std::vector::const_iterator iter = this->linkMessages.begin(); - iter != this->linkMessages.end(); - iter++) + for (auto iter = this->linkMessages.begin(); iter != this->linkMessages.end(); iter++) { const LinkMessage& lm = *iter; @@ -447,8 +442,7 @@ MessageHeader::Hello::Serialize(Buffer::Iterator start) const // - the end of the message). i.WriteHtonU16(4 + lm.neighborInterfaceAddresses.size() * IPV4_ADDRESS_SIZE); - for (std::vector::const_iterator neigh_iter = - lm.neighborInterfaceAddresses.begin(); + for (auto neigh_iter = lm.neighborInterfaceAddresses.begin(); neigh_iter != lm.neighborInterfaceAddresses.end(); neigh_iter++) { @@ -530,9 +524,7 @@ MessageHeader::Tc::Serialize(Buffer::Iterator start) const i.WriteHtonU16(this->ansn); i.WriteHtonU16(0); // Reserved - for (std::vector::const_iterator iter = this->neighborAddresses.begin(); - iter != this->neighborAddresses.end(); - iter++) + for (auto iter = this->neighborAddresses.begin(); iter != this->neighborAddresses.end(); iter++) { i.WriteHtonU32(iter->Get()); } diff --git a/src/olsr/model/olsr-header.h b/src/olsr/model/olsr-header.h index 0712d08f6..c60743bda 100644 --- a/src/olsr/model/olsr-header.h +++ b/src/olsr/model/olsr-header.h @@ -706,9 +706,7 @@ inline std::ostream& operator<<(std::ostream& os, const MessageList& messages) { os << "["; - for (std::vector::const_iterator messageIter = messages.begin(); - messageIter != messages.end(); - messageIter++) + for (auto messageIter = messages.begin(); messageIter != messages.end(); messageIter++) { messageIter->Print(os); if (messageIter + 1 != messages.end()) diff --git a/src/olsr/model/olsr-routing-protocol.cc b/src/olsr/model/olsr-routing-protocol.cc index e50015987..08efc7320 100644 --- a/src/olsr/model/olsr-routing-protocol.cc +++ b/src/olsr/model/olsr-routing-protocol.cc @@ -306,9 +306,7 @@ RoutingProtocol::DoDispose() m_recvSocket = nullptr; } - for (std::map, Ipv4InterfaceAddress>::iterator iter = m_sendSockets.begin(); - iter != m_sendSockets.end(); - iter++) + for (auto iter = m_sendSockets.begin(); iter != m_sendSockets.end(); iter++) { iter->first->Close(); } @@ -337,12 +335,14 @@ RoutingProtocol::PrintRoutingTable(Ptr stream, Time::Unit u *os << std::setw(16) << "Interface"; *os << "Distance" << std::endl; - for (std::map::const_iterator iter = m_table.begin(); - iter != m_table.end(); - iter++) + for (auto iter = m_table.begin(); iter != m_table.end(); iter++) { - *os << std::setw(16) << iter->first; - *os << std::setw(16) << iter->second.nextAddr; + std::ostringstream dest; + std::ostringstream nextHop; + dest << iter->first; + nextHop << iter->second.nextAddr; + *os << std::setw(16) << dest.str(); + *os << std::setw(16) << nextHop.str(); *os << std::setw(16); if (!Names::FindName(m_ipv4->GetNetDevice(iter->second.interface)).empty()) { @@ -364,7 +364,7 @@ RoutingProtocol::PrintRoutingTable(Ptr stream, Time::Unit u } else { - *os << "HNA Routing Table: empty" << std::endl; + *os << "HNA Routing Table: empty" << std::endl << std::endl; } // Restore the previous ostream state (*os).copyfmt(oldState); @@ -546,8 +546,7 @@ RoutingProtocol::RecvOlsr(Ptr socket) m_rxPacketTrace(olsrPacketHeader, messages); - for (MessageList::const_iterator messageIter = messages.begin(); messageIter != messages.end(); - messageIter++) + for (auto messageIter = messages.begin(); messageIter != messages.end(); messageIter++) { const MessageHeader& messageHeader = *messageIter; // If ttl is less than or equal to zero, or @@ -620,9 +619,7 @@ RoutingProtocol::RecvOlsr(Ptr socket) // If the message has been considered for forwarding, it should // not be retransmitted again - for (std::vector::const_iterator it = duplicated->ifaceList.begin(); - it != duplicated->ifaceList.end(); - it++) + for (auto it = duplicated->ifaceList.begin(); it != duplicated->ifaceList.end(); it++) { if (*it == receiverIfaceAddr) { @@ -662,8 +659,7 @@ int RoutingProtocol::Degree(const NeighborTuple& tuple) { int degree = 0; - for (TwoHopNeighborSet::const_iterator it = m_state.GetTwoHopNeighbors().begin(); - it != m_state.GetTwoHopNeighbors().end(); + for (auto it = m_state.GetTwoHopNeighbors().begin(); it != m_state.GetTwoHopNeighbors().end(); it++) { const TwoHopNeighborTuple& nb2hop_tuple = *it; @@ -694,8 +690,7 @@ CoverTwoHopNeighbors(Ipv4Address neighborMainAddr, TwoHopNeighborSet& N2) { // first gather all 2-hop neighbors to be removed std::set toRemove; - for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin(); twoHopNeigh != N2.end(); - twoHopNeigh++) + for (auto twoHopNeigh = N2.begin(); twoHopNeigh != N2.end(); twoHopNeigh++) { if (twoHopNeigh->neighborMainAddr == neighborMainAddr) { @@ -703,7 +698,7 @@ CoverTwoHopNeighbors(Ipv4Address neighborMainAddr, TwoHopNeighborSet& N2) } } // Now remove all matching records from N2 - for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin(); twoHopNeigh != N2.end();) + for (auto twoHopNeigh = N2.begin(); twoHopNeigh != N2.end();) { if (toRemove.find(twoHopNeigh->twoHopNeighborAddr) != toRemove.end()) { @@ -729,8 +724,7 @@ RoutingProtocol::MprComputation() // N is the subset of neighbors of the node, which are // neighbor "of the interface I" NeighborSet N; - for (NeighborSet::const_iterator neighbor = m_state.GetNeighbors().begin(); - neighbor != m_state.GetNeighbors().end(); + for (auto neighbor = m_state.GetNeighbors().begin(); neighbor != m_state.GetNeighbors().end(); neighbor++) { if (neighbor->status == NeighborTuple::STATUS_SYM) // I think that we need this check @@ -746,7 +740,7 @@ RoutingProtocol::MprComputation() // (iii) all the symmetric neighbors: the nodes for which there exists a symmetric // link to this node on some interface. TwoHopNeighborSet N2; - for (TwoHopNeighborSet::const_iterator twoHopNeigh = m_state.GetTwoHopNeighbors().begin(); + for (auto twoHopNeigh = m_state.GetTwoHopNeighbors().begin(); twoHopNeigh != m_state.GetTwoHopNeighbors().end(); twoHopNeigh++) { @@ -760,7 +754,7 @@ RoutingProtocol::MprComputation() // excluding: // (i) the nodes only reachable by members of N with willingness Willingness::NEVER bool ok = false; - for (NeighborSet::const_iterator neigh = N.begin(); neigh != N.end(); neigh++) + for (auto neigh = N.begin(); neigh != N.end(); neigh++) { if (neigh->neighborMainAddr == twoHopNeigh->neighborMainAddr) { @@ -776,7 +770,7 @@ RoutingProtocol::MprComputation() // excluding: // (iii) all the symmetric neighbors: the nodes for which there exists a symmetric // link to this node on some interface. - for (NeighborSet::const_iterator neigh = N.begin(); neigh != N.end(); neigh++) + for (auto neigh = N.begin(); neigh != N.end(); neigh++) { if (neigh->neighborMainAddr == twoHopNeigh->twoHopNeighborAddr) { @@ -795,9 +789,9 @@ RoutingProtocol::MprComputation() { std::ostringstream os; os << "["; - for (TwoHopNeighborSet::const_iterator iter = N2.begin(); iter != N2.end(); iter++) + for (auto iter = N2.begin(); iter != N2.end(); iter++) { - TwoHopNeighborSet::const_iterator next = iter; + auto next = iter; next++; os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr; if (next != N2.end()) @@ -812,7 +806,7 @@ RoutingProtocol::MprComputation() // 1. Start with an MPR set made of all members of N with // N_willingness equal to Willingness::ALWAYS - for (NeighborSet::const_iterator neighbor = N.begin(); neighbor != N.end(); neighbor++) + for (auto neighbor = N.begin(); neighbor != N.end(); neighbor++) { if (neighbor->willingness == Willingness::ALWAYS) { @@ -829,14 +823,11 @@ RoutingProtocol::MprComputation() // 3. Add to the MPR set those nodes in N, which are the *only* // nodes to provide reachability to a node in N2. std::set coveredTwoHopNeighbors; - for (TwoHopNeighborSet::const_iterator twoHopNeigh = N2.begin(); twoHopNeigh != N2.end(); - twoHopNeigh++) + for (auto twoHopNeigh = N2.begin(); twoHopNeigh != N2.end(); twoHopNeigh++) { bool onlyOne = true; // try to find another neighbor that can reach twoHopNeigh->twoHopNeighborAddr - for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin(); - otherTwoHopNeigh != N2.end(); - otherTwoHopNeigh++) + for (auto otherTwoHopNeigh = N2.begin(); otherTwoHopNeigh != N2.end(); otherTwoHopNeigh++) { if (otherTwoHopNeigh->twoHopNeighborAddr == twoHopNeigh->twoHopNeighborAddr && otherTwoHopNeigh->neighborMainAddr != twoHopNeigh->neighborMainAddr) @@ -854,8 +845,7 @@ RoutingProtocol::MprComputation() mprSet.insert(twoHopNeigh->neighborMainAddr); // take note of all the 2-hop neighbors reachable by the newly elected MPR - for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin(); - otherTwoHopNeigh != N2.end(); + for (auto otherTwoHopNeigh = N2.begin(); otherTwoHopNeigh != N2.end(); otherTwoHopNeigh++) { if (otherTwoHopNeigh->neighborMainAddr == twoHopNeigh->neighborMainAddr) @@ -866,7 +856,7 @@ RoutingProtocol::MprComputation() } } // Remove the nodes from N2 which are now covered by a node in the MPR set. - for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin(); twoHopNeigh != N2.end();) + for (auto twoHopNeigh = N2.begin(); twoHopNeigh != N2.end();) { if (coveredTwoHopNeighbors.find(twoHopNeigh->twoHopNeighborAddr) != coveredTwoHopNeighbors.end()) @@ -892,9 +882,9 @@ RoutingProtocol::MprComputation() { std::ostringstream os; os << "["; - for (TwoHopNeighborSet::const_iterator iter = N2.begin(); iter != N2.end(); iter++) + for (auto iter = N2.begin(); iter != N2.end(); iter++) { - TwoHopNeighborSet::const_iterator next = iter; + auto next = iter; next++; os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr; if (next != N2.end()) @@ -913,11 +903,11 @@ RoutingProtocol::MprComputation() // through this 1-hop neighbor std::map> reachability; std::set rs; - for (NeighborSet::iterator it = N.begin(); it != N.end(); it++) + for (auto it = N.begin(); it != N.end(); it++) { const NeighborTuple& nb_tuple = *it; int r = 0; - for (TwoHopNeighborSet::iterator it2 = N2.begin(); it2 != N2.end(); it2++) + for (auto it2 = N2.begin(); it2 != N2.end(); it2++) { const TwoHopNeighborTuple& nb2hop_tuple = *it2; if (nb_tuple.neighborMainAddr == nb2hop_tuple.neighborMainAddr) @@ -939,16 +929,14 @@ RoutingProtocol::MprComputation() // by a node in the MPR set. const NeighborTuple* max = nullptr; int max_r = 0; - for (std::set::iterator it = rs.begin(); it != rs.end(); it++) + for (auto it = rs.begin(); it != rs.end(); it++) { int r = *it; if (r == 0) { continue; } - for (std::vector::iterator it2 = reachability[r].begin(); - it2 != reachability[r].end(); - it2++) + for (auto it2 = reachability[r].begin(); it2 != reachability[r].end(); it2++) { const NeighborTuple* nb_tuple = *it2; if (max == nullptr || nb_tuple->willingness > max->willingness) @@ -987,9 +975,9 @@ RoutingProtocol::MprComputation() { std::ostringstream os; os << "["; - for (MprSet::const_iterator iter = mprSet.begin(); iter != mprSet.end(); iter++) + for (auto iter = mprSet.begin(); iter != mprSet.end(); iter++) { - MprSet::const_iterator next = iter; + auto next = iter; next++; os << *iter; if (next != mprSet.end()) @@ -1032,7 +1020,7 @@ RoutingProtocol::RoutingTableComputation() // 2. The new routing entries are added starting with the // symmetric neighbors (h=1) as the destination nodes. const NeighborSet& neighborSet = m_state.GetNeighbors(); - for (NeighborSet::const_iterator it = neighborSet.begin(); it != neighborSet.end(); it++) + for (auto it = neighborSet.begin(); it != neighborSet.end(); it++) { const NeighborTuple& nb_tuple = *it; NS_LOG_DEBUG("Looking at neighbor tuple: " << nb_tuple); @@ -1041,7 +1029,7 @@ RoutingProtocol::RoutingTableComputation() bool nb_main_addr = false; const LinkTuple* lt = nullptr; const LinkSet& linkSet = m_state.GetLinks(); - for (LinkSet::const_iterator it2 = linkSet.begin(); it2 != linkSet.end(); it2++) + for (auto it2 = linkSet.begin(); it2 != linkSet.end(); it2++) { const LinkTuple& link_tuple = *it2; NS_LOG_DEBUG("Looking at link tuple: " @@ -1097,9 +1085,7 @@ RoutingProtocol::RoutingTableComputation() // N_neighbor_main_addr correspond to a neighbor node with // willingness different of Willingness::NEVER, const TwoHopNeighborSet& twoHopNeighbors = m_state.GetTwoHopNeighbors(); - for (TwoHopNeighborSet::const_iterator it = twoHopNeighbors.begin(); - it != twoHopNeighbors.end(); - it++) + for (auto it = twoHopNeighbors.begin(); it != twoHopNeighbors.end(); it++) { const TwoHopNeighborTuple& nb2hop_tuple = *it; @@ -1122,9 +1108,7 @@ RoutingProtocol::RoutingTableComputation() // neighbor set where N_neighbor_main_addr correspond to a // neighbor node with willingness different of Willingness::NEVER... bool nb2hopOk = false; - for (NeighborSet::const_iterator neighbor = neighborSet.begin(); - neighbor != neighborSet.end(); - neighbor++) + for (auto neighbor = neighborSet.begin(); neighbor != neighborSet.end(); neighbor++) { if (neighbor->neighborMainAddr == nb2hop_tuple.neighborMainAddr && neighbor->willingness != Willingness::NEVER) @@ -1178,7 +1162,7 @@ RoutingProtocol::RoutingTableComputation() // is equal to h, then a new route entry MUST be recorded in // the routing table (if it does not already exist) const TopologySet& topology = m_state.GetTopologySet(); - for (TopologySet::const_iterator it = topology.begin(); it != topology.end(); it++) + for (auto it = topology.begin(); it != topology.end(); it++) { const TopologyTuple& topology_tuple = *it; NS_LOG_LOGIC("Looking at topology tuple: " << topology_tuple); @@ -1228,7 +1212,7 @@ RoutingProtocol::RoutingTableComputation() // AND there is no routing entry such that: // R_dest_addr == I_iface_addr const IfaceAssocSet& ifaceAssocSet = m_state.GetIfaceAssocSet(); - for (IfaceAssocSet::const_iterator it = ifaceAssocSet.begin(); it != ifaceAssocSet.end(); it++) + for (auto it = ifaceAssocSet.begin(); it != ifaceAssocSet.end(); it++) { const IfaceAssocTuple& tuple = *it; RoutingTableEntry entry1; @@ -1260,8 +1244,7 @@ RoutingProtocol::RoutingTableComputation() m_hnaRoutingTable->RemoveRoute(0); } - for (AssociationSet::const_iterator it = associationSet.begin(); it != associationSet.end(); - it++) + for (auto it = associationSet.begin(); it != associationSet.end(); it++) { const AssociationTuple& tuple = *it; @@ -1271,7 +1254,7 @@ RoutingProtocol::RoutingTableComputation() bool goToNextAssociationTuple = false; const Associations& localHnaAssociations = m_state.GetAssociations(); NS_LOG_DEBUG("Nb local associations: " << localHnaAssociations.size()); - for (Associations::const_iterator assocIterator = localHnaAssociations.begin(); + for (auto assocIterator = localHnaAssociations.begin(); assocIterator != localHnaAssociations.end(); assocIterator++) { @@ -1348,7 +1331,7 @@ RoutingProtocol::ProcessHello(const olsr::MessageHeader& msg, const LinkSet& links = m_state.GetLinks(); NS_LOG_DEBUG(Simulator::Now().As(Time::S) << " ** BEGIN dump Link Set for OLSR Node " << m_mainAddress); - for (LinkSet::const_iterator link = links.begin(); link != links.end(); link++) + for (auto link = links.begin(); link != links.end(); link++) { NS_LOG_DEBUG(*link); } @@ -1357,8 +1340,7 @@ RoutingProtocol::ProcessHello(const olsr::MessageHeader& msg, const NeighborSet& neighbors = m_state.GetNeighbors(); NS_LOG_DEBUG(Simulator::Now().As(Time::S) << " ** BEGIN dump Neighbor Set for OLSR Node " << m_mainAddress); - for (NeighborSet::const_iterator neighbor = neighbors.begin(); neighbor != neighbors.end(); - neighbor++) + for (auto neighbor = neighbors.begin(); neighbor != neighbors.end(); neighbor++) { NS_LOG_DEBUG(*neighbor); } @@ -1374,9 +1356,7 @@ RoutingProtocol::ProcessHello(const olsr::MessageHeader& msg, const TwoHopNeighborSet& twoHopNeighbors = m_state.GetTwoHopNeighbors(); NS_LOG_DEBUG(Simulator::Now().As(Time::S) << " ** BEGIN dump TwoHopNeighbor Set for OLSR Node " << m_mainAddress); - for (TwoHopNeighborSet::const_iterator tuple = twoHopNeighbors.begin(); - tuple != twoHopNeighbors.end(); - tuple++) + for (auto tuple = twoHopNeighbors.begin(); tuple != twoHopNeighbors.end(); tuple++) { NS_LOG_DEBUG(*tuple); } @@ -1422,9 +1402,7 @@ RoutingProtocol::ProcessTc(const olsr::MessageHeader& msg, const Ipv4Address& se // 4. For each of the advertised neighbor main address received in // the TC message: - for (std::vector::const_iterator i = tc.neighborAddresses.begin(); - i != tc.neighborAddresses.end(); - i++) + for (auto i = tc.neighborAddresses.begin(); i != tc.neighborAddresses.end(); i++) { const Ipv4Address& addr = *i; // 4.1. If there exist some tuple in the topology set where: @@ -1467,7 +1445,7 @@ RoutingProtocol::ProcessTc(const olsr::MessageHeader& msg, const Ipv4Address& se const TopologySet& topology = m_state.GetTopologySet(); NS_LOG_DEBUG(Simulator::Now().As(Time::S) << " ** BEGIN dump TopologySet for OLSR Node " << m_mainAddress); - for (TopologySet::const_iterator tuple = topology.begin(); tuple != topology.end(); tuple++) + for (auto tuple = topology.begin(); tuple != topology.end(); tuple++) { NS_LOG_DEBUG(*tuple); } @@ -1496,13 +1474,11 @@ RoutingProtocol::ProcessMid(const olsr::MessageHeader& msg, const Ipv4Address& s } // 2. For each interface address listed in the MID message - for (std::vector::const_iterator i = mid.interfaceAddresses.begin(); - i != mid.interfaceAddresses.end(); - i++) + for (auto i = mid.interfaceAddresses.begin(); i != mid.interfaceAddresses.end(); i++) { bool updated = false; IfaceAssocSet& ifaceAssoc = m_state.GetIfaceAssocSetMutable(); - for (IfaceAssocSet::iterator tuple = ifaceAssoc.begin(); tuple != ifaceAssoc.end(); tuple++) + for (auto tuple = ifaceAssoc.begin(); tuple != ifaceAssoc.end(); tuple++) { if (tuple->ifaceAddr == *i && tuple->mainAddr == msg.GetOriginatorAddress()) { @@ -1531,15 +1507,13 @@ RoutingProtocol::ProcessMid(const olsr::MessageHeader& msg, const Ipv4Address& s // TwoHopNeighborTuples, update the neighbor addresses taking into account // the new MID information. NeighborSet& neighbors = m_state.GetNeighbors(); - for (NeighborSet::iterator neighbor = neighbors.begin(); neighbor != neighbors.end(); - neighbor++) + for (auto neighbor = neighbors.begin(); neighbor != neighbors.end(); neighbor++) { neighbor->neighborMainAddr = GetMainAddress(neighbor->neighborMainAddr); } TwoHopNeighborSet& twoHopNeighbors = m_state.GetTwoHopNeighbors(); - for (TwoHopNeighborSet::iterator twoHopNeighbor = twoHopNeighbors.begin(); - twoHopNeighbor != twoHopNeighbors.end(); + for (auto twoHopNeighbor = twoHopNeighbors.begin(); twoHopNeighbor != twoHopNeighbors.end(); twoHopNeighbor++) { twoHopNeighbor->neighborMainAddr = GetMainAddress(twoHopNeighbor->neighborMainAddr); @@ -1565,10 +1539,7 @@ RoutingProtocol::ProcessHna(const olsr::MessageHeader& msg, const Ipv4Address& s // 2. Otherwise, for each (network address, netmask) pair in the // message: - for (std::vector::const_iterator it = - hna.associations.begin(); - it != hna.associations.end(); - it++) + for (auto it = hna.associations.begin(); it != hna.associations.end(); it++) { AssociationTuple* tuple = m_state.FindAssociationTuple(msg.GetOriginatorAddress(), it->address, it->mask); @@ -1707,9 +1678,7 @@ RoutingProtocol::SendPacket(Ptr packet, const MessageList& containedMess m_txPacketTrace(header, containedMessages); // Send it - for (std::map, Ipv4InterfaceAddress>::const_iterator i = m_sendSockets.begin(); - i != m_sendSockets.end(); - i++) + for (auto i = m_sendSockets.begin(); i != m_sendSockets.end(); i++) { Ptr pkt = packet->Copy(); Ipv4Address bcast = i->second.GetLocal().GetSubnetDirectedBroadcast(i->second.GetMask()); @@ -1727,9 +1696,7 @@ RoutingProtocol::SendQueuedMessages() MessageList msglist; - for (std::vector::const_iterator message = m_queuedMessages.begin(); - message != m_queuedMessages.end(); - message++) + for (auto message = m_queuedMessages.begin(); message != m_queuedMessages.end(); message++) { Ptr p = Create(); p->AddHeader(*message); @@ -1774,8 +1741,7 @@ RoutingProtocol::SendHello() std::vector& linkMessages = hello.linkMessages; const LinkSet& links = m_state.GetLinks(); - for (LinkSet::const_iterator link_tuple = links.begin(); link_tuple != links.end(); - link_tuple++) + for (auto link_tuple = links.begin(); link_tuple != links.end(); link_tuple++) { if (!(GetMainAddress(link_tuple->localIfaceAddr) == m_mainAddress && link_tuple->time >= now)) @@ -1809,7 +1775,7 @@ RoutingProtocol::SendHello() else { bool ok = false; - for (NeighborSet::const_iterator nb_tuple = m_state.GetNeighbors().begin(); + for (auto nb_tuple = m_state.GetNeighbors().begin(); nb_tuple != m_state.GetNeighbors().end(); nb_tuple++) { @@ -1880,7 +1846,7 @@ RoutingProtocol::SendTc() olsr::MessageHeader::Tc& tc = msg.GetTc(); tc.ansn = m_ansn; - for (MprSelectorSet::const_iterator mprsel_tuple = m_state.GetMprSelectors().begin(); + for (auto mprsel_tuple = m_state.GetMprSelectors().begin(); mprsel_tuple != m_state.GetMprSelectors().end(); mprsel_tuple++) { @@ -1951,9 +1917,7 @@ RoutingProtocol::SendHna() // Add all local HNA associations to the HNA message const Associations& localHnaAssociations = m_state.GetAssociations(); - for (Associations::const_iterator it = localHnaAssociations.begin(); - it != localHnaAssociations.end(); - it++) + for (auto it = localHnaAssociations.begin(); it != localHnaAssociations.end(); it++) { olsr::MessageHeader::Hna::Association assoc = {it->networkAddr, it->netmask}; associations.push_back(assoc); @@ -1974,7 +1938,7 @@ RoutingProtocol::AddHostNetworkAssociation(Ipv4Address networkAddr, Ipv4Mask net // Check if the (networkAddr, netmask) tuple already exist // in the list of local HNA associations const Associations& localHnaAssociations = m_state.GetAssociations(); - for (Associations::const_iterator assocIterator = localHnaAssociations.begin(); + for (auto assocIterator = localHnaAssociations.begin(); assocIterator != localHnaAssociations.end(); assocIterator++) { @@ -2048,7 +2012,7 @@ RoutingProtocol::SetRoutingTableAssociation(Ptr routingTable) bool RoutingProtocol::UsesNonOlsrOutgoingInterface(const Ipv4RoutingTableEntry& route) { - std::set::const_iterator ci = m_interfaceExclusions.find(route.GetInterface()); + auto ci = m_interfaceExclusions.find(route.GetInterface()); // The outgoing interface is a non-OLSR interface if a match is found // before reaching the end of the list of excluded interfaces return ci != m_interfaceExclusions.end(); @@ -2088,13 +2052,11 @@ RoutingProtocol::LinkSensing(const olsr::MessageHeader& msg, } link_tuple->asymTime = now + msg.GetVTime(); - for (std::vector::const_iterator linkMessage = - hello.linkMessages.begin(); - linkMessage != hello.linkMessages.end(); + for (auto linkMessage = hello.linkMessages.begin(); linkMessage != hello.linkMessages.end(); linkMessage++) { - LinkType linkType = LinkType(linkMessage->linkCode & 0x03); - NeighborType neighborType = NeighborType((linkMessage->linkCode >> 2) & 0x03); + auto linkType = LinkType(linkMessage->linkCode & 0x03); + auto neighborType = NeighborType((linkMessage->linkCode >> 2) & 0x03); NS_LOG_DEBUG("Looking at HELLO link messages with Link Type " << linkType << " and Neighbor Type " << neighborType); @@ -2108,8 +2070,7 @@ RoutingProtocol::LinkSensing(const olsr::MessageHeader& msg, continue; } - for (std::vector::const_iterator neighIfaceAddr = - linkMessage->neighborInterfaceAddresses.begin(); + for (auto neighIfaceAddr = linkMessage->neighborInterfaceAddresses.begin(); neighIfaceAddr != linkMessage->neighborInterfaceAddresses.end(); neighIfaceAddr++) { @@ -2184,8 +2145,7 @@ RoutingProtocol::PopulateTwoHopNeighborSet(const olsr::MessageHeader& msg, NS_LOG_DEBUG("Olsr node " << m_mainAddress << ": PopulateTwoHopNeighborSet BEGIN"); - for (LinkSet::const_iterator link_tuple = m_state.GetLinks().begin(); - link_tuple != m_state.GetLinks().end(); + for (auto link_tuple = m_state.GetLinks().begin(); link_tuple != m_state.GetLinks().end(); link_tuple++) { NS_LOG_LOGIC("Looking at link tuple: " << *link_tuple); @@ -2207,17 +2167,14 @@ RoutingProtocol::PopulateTwoHopNeighborSet(const olsr::MessageHeader& msg, continue; } - typedef std::vector LinkMessageVec; - for (LinkMessageVec::const_iterator linkMessage = hello.linkMessages.begin(); - linkMessage != hello.linkMessages.end(); + for (auto linkMessage = hello.linkMessages.begin(); linkMessage != hello.linkMessages.end(); linkMessage++) { - NeighborType neighborType = NeighborType((linkMessage->linkCode >> 2) & 0x3); + auto neighborType = NeighborType((linkMessage->linkCode >> 2) & 0x3); NS_LOG_DEBUG( "Looking at Link Message from HELLO message: neighborType=" << neighborType); - for (std::vector::const_iterator nb2hop_addr_iter = - linkMessage->neighborInterfaceAddresses.begin(); + for (auto nb2hop_addr_iter = linkMessage->neighborInterfaceAddresses.begin(); nb2hop_addr_iter != linkMessage->neighborInterfaceAddresses.end(); nb2hop_addr_iter++) { @@ -2292,18 +2249,15 @@ RoutingProtocol::PopulateMprSelectorSet(const olsr::MessageHeader& msg, Time now = Simulator::Now(); - typedef std::vector LinkMessageVec; - for (LinkMessageVec::const_iterator linkMessage = hello.linkMessages.begin(); - linkMessage != hello.linkMessages.end(); + for (auto linkMessage = hello.linkMessages.begin(); linkMessage != hello.linkMessages.end(); linkMessage++) { - NeighborType neighborType = NeighborType(linkMessage->linkCode >> 2); + auto neighborType = NeighborType(linkMessage->linkCode >> 2); if (neighborType == NeighborType::MPR_NEIGH) { NS_LOG_DEBUG("Processing a link message with neighbor type MPR_NEIGH"); - for (std::vector::const_iterator nb_iface_addr = - linkMessage->neighborInterfaceAddresses.begin(); + for (auto nb_iface_addr = linkMessage->neighborInterfaceAddresses.begin(); nb_iface_addr != linkMessage->neighborInterfaceAddresses.end(); nb_iface_addr++) { @@ -2466,7 +2420,7 @@ RoutingProtocol::LinkTupleUpdated(const LinkTuple& tuple, Willingness willingnes bool hasSymmetricLink = false; const LinkSet& linkSet = m_state.GetLinks(); - for (LinkSet::const_iterator it = linkSet.begin(); it != linkSet.end(); it++) + for (auto it = linkSet.begin(); it != linkSet.end(); it++) { const LinkTuple& link_tuple = *it; if (GetMainAddress(link_tuple.neighborIfaceAddr) == nb_tuple->neighborMainAddr && @@ -2886,7 +2840,7 @@ bool RoutingProtocol::Lookup(const Ipv4Address& dest, RoutingTableEntry& outEntry) const { // Get the iterator at "dest" position - std::map::const_iterator it = m_table.find(dest); + auto it = m_table.find(dest); // If there is no route to "dest", return NULL if (it == m_table.end()) { @@ -2923,7 +2877,7 @@ RoutingProtocol::RouteOutput(Ptr p, RoutingTableEntry entry2; bool found = false; - if (Lookup(header.GetDestination(), entry1) != 0) + if (Lookup(header.GetDestination(), entry1)) { bool foundSendEntry = FindSendEntry(entry1, entry2); if (!foundSendEntry) @@ -3098,9 +3052,7 @@ RoutingProtocol::RouteInput(Ptr p, << ": RouteInput for dest=" << header.GetDestination() << " --> NOT FOUND; ** Dumping routing table..."); - for (std::map::const_iterator iter = m_table.begin(); - iter != m_table.end(); - iter++) + for (auto iter = m_table.begin(); iter != m_table.end(); iter++) { NS_LOG_DEBUG("dest=" << iter->first << " --> next=" << iter->second.nextAddr << " via interface " << iter->second.interface); @@ -3184,9 +3136,7 @@ std::vector RoutingProtocol::GetRoutingTableEntries() const { std::vector retval; - for (std::map::const_iterator iter = m_table.begin(); - iter != m_table.end(); - iter++) + for (auto iter = m_table.begin(); iter != m_table.end(); iter++) { retval.push_back(iter->second); } @@ -3240,8 +3190,7 @@ RoutingProtocol::AssignStreams(int64_t stream) bool RoutingProtocol::IsMyOwnAddress(const Ipv4Address& a) const { - std::map, Ipv4InterfaceAddress>::const_iterator j; - for (j = m_sendSockets.begin(); j != m_sendSockets.end(); ++j) + for (auto j = m_sendSockets.begin(); j != m_sendSockets.end(); ++j) { Ipv4InterfaceAddress iface = j->second; if (a == iface.GetLocal()) @@ -3259,14 +3208,12 @@ RoutingProtocol::Dump() Time now = Simulator::Now(); NS_LOG_DEBUG("Dumping for node with main address " << m_mainAddress); NS_LOG_DEBUG(" Neighbor set"); - for (NeighborSet::const_iterator iter = m_state.GetNeighbors().begin(); - iter != m_state.GetNeighbors().end(); - iter++) + for (auto iter = m_state.GetNeighbors().begin(); iter != m_state.GetNeighbors().end(); iter++) { NS_LOG_DEBUG(" " << *iter); } NS_LOG_DEBUG(" Two-hop neighbor set"); - for (TwoHopNeighborSet::const_iterator iter = m_state.GetTwoHopNeighbors().begin(); + for (auto iter = m_state.GetTwoHopNeighbors().begin(); iter != m_state.GetTwoHopNeighbors().end(); iter++) { @@ -3276,9 +3223,7 @@ RoutingProtocol::Dump() } } NS_LOG_DEBUG(" Routing table"); - for (std::map::const_iterator iter = m_table.begin(); - iter != m_table.end(); - iter++) + for (auto iter = m_table.begin(); iter != m_table.end(); iter++) { NS_LOG_DEBUG(" dest=" << iter->first << " --> next=" << iter->second.nextAddr << " via interface " << iter->second.interface); diff --git a/src/olsr/model/olsr-state.cc b/src/olsr/model/olsr-state.cc index ebc318796..5a2874323 100644 --- a/src/olsr/model/olsr-state.cc +++ b/src/olsr/model/olsr-state.cc @@ -37,7 +37,7 @@ namespace olsr MprSelectorTuple* OlsrState::FindMprSelectorTuple(const Ipv4Address& mainAddr) { - for (MprSelectorSet::iterator it = m_mprSelectorSet.begin(); it != m_mprSelectorSet.end(); it++) + for (auto it = m_mprSelectorSet.begin(); it != m_mprSelectorSet.end(); it++) { if (it->mainAddr == mainAddr) { @@ -50,7 +50,7 @@ OlsrState::FindMprSelectorTuple(const Ipv4Address& mainAddr) void OlsrState::EraseMprSelectorTuple(const MprSelectorTuple& tuple) { - for (MprSelectorSet::iterator it = m_mprSelectorSet.begin(); it != m_mprSelectorSet.end(); it++) + for (auto it = m_mprSelectorSet.begin(); it != m_mprSelectorSet.end(); it++) { if (*it == tuple) { @@ -63,7 +63,7 @@ OlsrState::EraseMprSelectorTuple(const MprSelectorTuple& tuple) void OlsrState::EraseMprSelectorTuples(const Ipv4Address& mainAddr) { - for (MprSelectorSet::iterator it = m_mprSelectorSet.begin(); it != m_mprSelectorSet.end();) + for (auto it = m_mprSelectorSet.begin(); it != m_mprSelectorSet.end();) { if (it->mainAddr == mainAddr) { @@ -87,11 +87,9 @@ OlsrState::PrintMprSelectorSet() const { std::ostringstream os; os << "["; - for (MprSelectorSet::const_iterator iter = m_mprSelectorSet.begin(); - iter != m_mprSelectorSet.end(); - iter++) + for (auto iter = m_mprSelectorSet.begin(); iter != m_mprSelectorSet.end(); iter++) { - MprSelectorSet::const_iterator next = iter; + auto next = iter; next++; os << iter->mainAddr; if (next != m_mprSelectorSet.end()) @@ -108,7 +106,7 @@ OlsrState::PrintMprSelectorSet() const NeighborTuple* OlsrState::FindNeighborTuple(const Ipv4Address& mainAddr) { - for (NeighborSet::iterator it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) + for (auto it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) { if (it->neighborMainAddr == mainAddr) { @@ -121,7 +119,7 @@ OlsrState::FindNeighborTuple(const Ipv4Address& mainAddr) const NeighborTuple* OlsrState::FindSymNeighborTuple(const Ipv4Address& mainAddr) const { - for (NeighborSet::const_iterator it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) + for (auto it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) { if (it->neighborMainAddr == mainAddr && it->status == NeighborTuple::STATUS_SYM) { @@ -134,7 +132,7 @@ OlsrState::FindSymNeighborTuple(const Ipv4Address& mainAddr) const NeighborTuple* OlsrState::FindNeighborTuple(const Ipv4Address& mainAddr, Willingness willingness) { - for (NeighborSet::iterator it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) + for (auto it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) { if (it->neighborMainAddr == mainAddr && it->willingness == willingness) { @@ -147,7 +145,7 @@ OlsrState::FindNeighborTuple(const Ipv4Address& mainAddr, Willingness willingnes void OlsrState::EraseNeighborTuple(const NeighborTuple& tuple) { - for (NeighborSet::iterator it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) + for (auto it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) { if (*it == tuple) { @@ -160,7 +158,7 @@ OlsrState::EraseNeighborTuple(const NeighborTuple& tuple) void OlsrState::EraseNeighborTuple(const Ipv4Address& mainAddr) { - for (NeighborSet::iterator it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) + for (auto it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) { if (it->neighborMainAddr == mainAddr) { @@ -173,7 +171,7 @@ OlsrState::EraseNeighborTuple(const Ipv4Address& mainAddr) void OlsrState::InsertNeighborTuple(const NeighborTuple& tuple) { - for (NeighborSet::iterator it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) + for (auto it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) { if (it->neighborMainAddr == tuple.neighborMainAddr) { @@ -191,9 +189,7 @@ TwoHopNeighborTuple* OlsrState::FindTwoHopNeighborTuple(const Ipv4Address& neighborMainAddr, const Ipv4Address& twoHopNeighborAddr) { - for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin(); - it != m_twoHopNeighborSet.end(); - it++) + for (auto it = m_twoHopNeighborSet.begin(); it != m_twoHopNeighborSet.end(); it++) { if (it->neighborMainAddr == neighborMainAddr && it->twoHopNeighborAddr == twoHopNeighborAddr) @@ -207,9 +203,7 @@ OlsrState::FindTwoHopNeighborTuple(const Ipv4Address& neighborMainAddr, void OlsrState::EraseTwoHopNeighborTuple(const TwoHopNeighborTuple& tuple) { - for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin(); - it != m_twoHopNeighborSet.end(); - it++) + for (auto it = m_twoHopNeighborSet.begin(); it != m_twoHopNeighborSet.end(); it++) { if (*it == tuple) { @@ -223,8 +217,7 @@ void OlsrState::EraseTwoHopNeighborTuples(const Ipv4Address& neighborMainAddr, const Ipv4Address& twoHopNeighborAddr) { - for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin(); - it != m_twoHopNeighborSet.end();) + for (auto it = m_twoHopNeighborSet.begin(); it != m_twoHopNeighborSet.end();) { if (it->neighborMainAddr == neighborMainAddr && it->twoHopNeighborAddr == twoHopNeighborAddr) @@ -241,8 +234,7 @@ OlsrState::EraseTwoHopNeighborTuples(const Ipv4Address& neighborMainAddr, void OlsrState::EraseTwoHopNeighborTuples(const Ipv4Address& neighborMainAddr) { - for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin(); - it != m_twoHopNeighborSet.end();) + for (auto it = m_twoHopNeighborSet.begin(); it != m_twoHopNeighborSet.end();) { if (it->neighborMainAddr == neighborMainAddr) { @@ -266,7 +258,7 @@ OlsrState::InsertTwoHopNeighborTuple(const TwoHopNeighborTuple& tuple) bool OlsrState::FindMprAddress(const Ipv4Address& addr) { - MprSet::iterator it = m_mprSet.find(addr); + auto it = m_mprSet.find(addr); return (it != m_mprSet.end()); } @@ -287,7 +279,7 @@ OlsrState::GetMprSet() const DuplicateTuple* OlsrState::FindDuplicateTuple(const Ipv4Address& addr, uint16_t sequenceNumber) { - for (DuplicateSet::iterator it = m_duplicateSet.begin(); it != m_duplicateSet.end(); it++) + for (auto it = m_duplicateSet.begin(); it != m_duplicateSet.end(); it++) { if (it->address == addr && it->sequenceNumber == sequenceNumber) { @@ -300,7 +292,7 @@ OlsrState::FindDuplicateTuple(const Ipv4Address& addr, uint16_t sequenceNumber) void OlsrState::EraseDuplicateTuple(const DuplicateTuple& tuple) { - for (DuplicateSet::iterator it = m_duplicateSet.begin(); it != m_duplicateSet.end(); it++) + for (auto it = m_duplicateSet.begin(); it != m_duplicateSet.end(); it++) { if (*it == tuple) { @@ -321,7 +313,7 @@ OlsrState::InsertDuplicateTuple(const DuplicateTuple& tuple) LinkTuple* OlsrState::FindLinkTuple(const Ipv4Address& ifaceAddr) { - for (LinkSet::iterator it = m_linkSet.begin(); it != m_linkSet.end(); it++) + for (auto it = m_linkSet.begin(); it != m_linkSet.end(); it++) { if (it->neighborIfaceAddr == ifaceAddr) { @@ -334,7 +326,7 @@ OlsrState::FindLinkTuple(const Ipv4Address& ifaceAddr) LinkTuple* OlsrState::FindSymLinkTuple(const Ipv4Address& ifaceAddr, Time now) { - for (LinkSet::iterator it = m_linkSet.begin(); it != m_linkSet.end(); it++) + for (auto it = m_linkSet.begin(); it != m_linkSet.end(); it++) { if (it->neighborIfaceAddr == ifaceAddr) { @@ -354,7 +346,7 @@ OlsrState::FindSymLinkTuple(const Ipv4Address& ifaceAddr, Time now) void OlsrState::EraseLinkTuple(const LinkTuple& tuple) { - for (LinkSet::iterator it = m_linkSet.begin(); it != m_linkSet.end(); it++) + for (auto it = m_linkSet.begin(); it != m_linkSet.end(); it++) { if (*it == tuple) { @@ -376,7 +368,7 @@ OlsrState::InsertLinkTuple(const LinkTuple& tuple) TopologyTuple* OlsrState::FindTopologyTuple(const Ipv4Address& destAddr, const Ipv4Address& lastAddr) { - for (TopologySet::iterator it = m_topologySet.begin(); it != m_topologySet.end(); it++) + for (auto it = m_topologySet.begin(); it != m_topologySet.end(); it++) { if (it->destAddr == destAddr && it->lastAddr == lastAddr) { @@ -389,7 +381,7 @@ OlsrState::FindTopologyTuple(const Ipv4Address& destAddr, const Ipv4Address& las TopologyTuple* OlsrState::FindNewerTopologyTuple(const Ipv4Address& lastAddr, uint16_t ansn) { - for (TopologySet::iterator it = m_topologySet.begin(); it != m_topologySet.end(); it++) + for (auto it = m_topologySet.begin(); it != m_topologySet.end(); it++) { if (it->lastAddr == lastAddr && it->sequenceNumber > ansn) { @@ -402,7 +394,7 @@ OlsrState::FindNewerTopologyTuple(const Ipv4Address& lastAddr, uint16_t ansn) void OlsrState::EraseTopologyTuple(const TopologyTuple& tuple) { - for (TopologySet::iterator it = m_topologySet.begin(); it != m_topologySet.end(); it++) + for (auto it = m_topologySet.begin(); it != m_topologySet.end(); it++) { if (*it == tuple) { @@ -415,7 +407,7 @@ OlsrState::EraseTopologyTuple(const TopologyTuple& tuple) void OlsrState::EraseOlderTopologyTuples(const Ipv4Address& lastAddr, uint16_t ansn) { - for (TopologySet::iterator it = m_topologySet.begin(); it != m_topologySet.end();) + for (auto it = m_topologySet.begin(); it != m_topologySet.end();) { if (it->lastAddr == lastAddr && it->sequenceNumber < ansn) { @@ -439,7 +431,7 @@ OlsrState::InsertTopologyTuple(const TopologyTuple& tuple) IfaceAssocTuple* OlsrState::FindIfaceAssocTuple(const Ipv4Address& ifaceAddr) { - for (IfaceAssocSet::iterator it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); it++) + for (auto it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); it++) { if (it->ifaceAddr == ifaceAddr) { @@ -452,8 +444,7 @@ OlsrState::FindIfaceAssocTuple(const Ipv4Address& ifaceAddr) const IfaceAssocTuple* OlsrState::FindIfaceAssocTuple(const Ipv4Address& ifaceAddr) const { - for (IfaceAssocSet::const_iterator it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); - it++) + for (auto it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); it++) { if (it->ifaceAddr == ifaceAddr) { @@ -466,7 +457,7 @@ OlsrState::FindIfaceAssocTuple(const Ipv4Address& ifaceAddr) const void OlsrState::EraseIfaceAssocTuple(const IfaceAssocTuple& tuple) { - for (IfaceAssocSet::iterator it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); it++) + for (auto it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); it++) { if (*it == tuple) { @@ -486,8 +477,7 @@ std::vector OlsrState::FindNeighborInterfaces(const Ipv4Address& neighborMainAddr) const { std::vector retval; - for (IfaceAssocSet::const_iterator it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); - it++) + for (auto it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); it++) { if (it->mainAddr == neighborMainAddr) { @@ -504,7 +494,7 @@ OlsrState::FindAssociationTuple(const Ipv4Address& gatewayAddr, const Ipv4Address& networkAddr, const Ipv4Mask& netmask) { - for (AssociationSet::iterator it = m_associationSet.begin(); it != m_associationSet.end(); it++) + for (auto it = m_associationSet.begin(); it != m_associationSet.end(); it++) { if (it->gatewayAddr == gatewayAddr and it->networkAddr == networkAddr and it->netmask == netmask) @@ -518,7 +508,7 @@ OlsrState::FindAssociationTuple(const Ipv4Address& gatewayAddr, void OlsrState::EraseAssociationTuple(const AssociationTuple& tuple) { - for (AssociationSet::iterator it = m_associationSet.begin(); it != m_associationSet.end(); it++) + for (auto it = m_associationSet.begin(); it != m_associationSet.end(); it++) { if (*it == tuple) { @@ -537,7 +527,7 @@ OlsrState::InsertAssociationTuple(const AssociationTuple& tuple) void OlsrState::EraseAssociation(const Association& tuple) { - for (Associations::iterator it = m_associations.begin(); it != m_associations.end(); it++) + for (auto it = m_associations.begin(); it != m_associations.end(); it++) { if (*it == tuple) { diff --git a/src/olsr/test/hello-regression-test.cc b/src/olsr/test/hello-regression-test.cc index 4af8deca5..e359a7a54 100644 --- a/src/olsr/test/hello-regression-test.cc +++ b/src/olsr/test/hello-regression-test.cc @@ -139,8 +139,7 @@ HelloRegressionTest::ReceivePktProbeA(Ptr socket) "One Link message on the second and third Hello."); } - std::vector::const_iterator iter; - for (iter = hello.linkMessages.begin(); iter != hello.linkMessages.end(); iter++) + for (auto iter = hello.linkMessages.begin(); iter != hello.linkMessages.end(); iter++) { if (m_countA == 1) { @@ -193,8 +192,7 @@ HelloRegressionTest::ReceivePktProbeB(Ptr socket) "One Link message on the second and third Hello."); } - std::vector::const_iterator iter; - for (iter = hello.linkMessages.begin(); iter != hello.linkMessages.end(); iter++) + for (auto iter = hello.linkMessages.begin(); iter != hello.linkMessages.end(); iter++) { if (m_countA == 1) { diff --git a/src/openflow/examples/openflow-switch.cc b/src/openflow/examples/openflow-switch.cc index 05e09170b..6db416a76 100644 --- a/src/openflow/examples/openflow-switch.cc +++ b/src/openflow/examples/openflow-switch.cc @@ -86,7 +86,6 @@ SetTimeout(const std::string& value) int main(int argc, char* argv[]) { -#ifdef NS3_OPENFLOW // // Allow the user to override any of the defaults and the above Bind() at // run-time, via command-line arguments @@ -223,9 +222,6 @@ main(int argc, char* argv[]) Simulator::Run(); Simulator::Destroy(); NS_LOG_INFO("Done."); -#else - NS_LOG_INFO("NS-3 OpenFlow is not enabled. Cannot run simulation."); -#endif // NS3_OPENFLOW return 0; } diff --git a/src/openflow/helper/openflow-switch-helper.cc b/src/openflow/helper/openflow-switch-helper.cc index 0eee87685..1892e1b02 100644 --- a/src/openflow/helper/openflow-switch-helper.cc +++ b/src/openflow/helper/openflow-switch-helper.cc @@ -16,7 +16,6 @@ * * Author: Blake Hurd */ -#ifdef NS3_OPENFLOW #include "openflow-switch-helper.h" @@ -96,5 +95,3 @@ OpenFlowSwitchHelper::Install(std::string nodeName, NetDeviceContainer c) } } // namespace ns3 - -#endif // NS3_OPENFLOW diff --git a/src/openflow/model/openflow-interface.cc b/src/openflow/model/openflow-interface.cc index 32ab17011..c7610893b 100644 --- a/src/openflow/model/openflow-interface.cc +++ b/src/openflow/model/openflow-interface.cc @@ -14,7 +14,6 @@ * * Author: Blake Hurd */ -#ifdef NS3_OPENFLOW #include "openflow-interface.h" @@ -159,7 +158,7 @@ int Stats::FlowStatsInit(const void* body, int body_len, void** state) { const ofp_flow_stats_request* fsr = (ofp_flow_stats_request*)body; - FlowStatsState* s = (FlowStatsState*)xmalloc(sizeof *s); + auto s = (FlowStatsState*)xmalloc(sizeof(FlowStatsState)); s->table_idx = fsr->table_id == 0xff ? 0 : fsr->table_id; memset(&s->position, 0, sizeof s->position); @@ -171,7 +170,7 @@ Stats::FlowStatsInit(const void* body, int body_len, void** state) int Stats_FlowDumpCallback(sw_flow* flow, void* state) { - Stats::FlowStatsState* s = (Stats::FlowStatsState*)state; + auto s = (Stats::FlowStatsState*)state; // Fill Flow Stats ofp_flow_stats* ofs; @@ -326,7 +325,7 @@ Stats::PortTableStatsDump(Ptr swtch, void* state, ofpbu int Stats::PortStatsInit(const void* body, int body_len, void** state) { - PortStatsState* s = (PortStatsState*)xmalloc(sizeof *s); + auto s = (PortStatsState*)xmalloc(sizeof(PortStatsState)); // the body contains a list of port numbers s->ports = (uint32_t*)xmalloc(body_len); @@ -879,7 +878,7 @@ LearningController::ReceiveFromSwitch(Ptr swtch, ofpbuf dst_addr.CopyFrom(key.flow.dl_dst); if (!dst_addr.IsBroadcast()) { - LearnState_t::iterator st = m_learnState.find(dst_addr); + auto st = m_learnState.find(dst_addr); if (st != m_learnState.end()) { out_port = st->second.port; @@ -916,7 +915,7 @@ LearningController::ReceiveFromSwitch(Ptr swtch, ofpbuf // We can learn a specific port for the source address for future use. Mac48Address src_addr; src_addr.CopyFrom(key.flow.dl_src); - LearnState_t::iterator st = m_learnState.find(src_addr); + auto st = m_learnState.find(src_addr); if (st == m_learnState.end()) // We haven't learned our source MAC yet. { LearnedState ls; @@ -964,7 +963,7 @@ ExecuteActions(Ptr swtch, int prev_port; size_t max_len = 0; // Initialize to make compiler happy uint16_t in_port = key->flow.in_port; // ntohs(key->flow.in_port); - uint8_t* p = (uint8_t*)actions; + auto p = (uint8_t*)actions; prev_port = -1; @@ -1023,7 +1022,7 @@ ExecuteActions(Ptr swtch, uint16_t ValidateActions(const sw_flow_key* key, const ofp_action_header* actions, size_t actions_len) { - uint8_t* p = (uint8_t*)actions; + auto p = (uint8_t*)actions; int err; while (actions_len >= sizeof(ofp_action_header)) @@ -1089,7 +1088,7 @@ ExecuteVPortActions(Ptr swtch, int prev_port; size_t max_len = 0; // Initialize to make compiler happy uint16_t in_port = ntohs(key->flow.in_port); - uint8_t* p = (uint8_t*)actions; + auto p = (uint8_t*)actions; uint16_t type; ofp_action_output* oa; @@ -1131,7 +1130,7 @@ ExecuteVPortActions(Ptr swtch, uint16_t ValidateVPortActions(const ofp_action_header* actions, size_t actions_len) { - uint8_t* p = (uint8_t*)actions; + auto p = (uint8_t*)actions; int err; while (actions_len >= sizeof(ofp_action_header)) @@ -1231,5 +1230,3 @@ ValidateVendor(const sw_flow_key* key, const ofp_action_header* ah, uint16_t len } // namespace ofi } // namespace ns3 - -#endif // NS3_OPENFLOW diff --git a/src/openflow/model/openflow-switch-net-device.cc b/src/openflow/model/openflow-switch-net-device.cc index a8532f9fd..e546c9d0b 100644 --- a/src/openflow/model/openflow-switch-net-device.cc +++ b/src/openflow/model/openflow-switch-net-device.cc @@ -14,7 +14,6 @@ * * Author: Blake Hurd */ -#ifdef NS3_OPENFLOW #include "openflow-switch-net-device.h" @@ -28,6 +27,19 @@ NS_LOG_COMPONENT_DEFINE("OpenFlowSwitchNetDevice"); NS_OBJECT_ENSURE_REGISTERED(OpenFlowSwitchNetDevice); +/** + * Generate an ID. + * + * \return Generated ID. + */ +static uint64_t +GenerateId() +{ + uint8_t ea[ETH_ADDR_LEN]; + eth_addr_random(ea); + return eth_addr_to_uint64(ea); +} + const char* OpenFlowSwitchNetDevice::GetManufacturerDescription() { @@ -52,14 +64,6 @@ OpenFlowSwitchNetDevice::GetSerialNumber() return "N/A"; } -static uint64_t -GenerateId() -{ - uint8_t ea[ETH_ADDR_LEN]; - eth_addr_random(ea); - return eth_addr_to_uint64(ea); -} - TypeId OpenFlowSwitchNetDevice::GetTypeId() { @@ -133,7 +137,7 @@ OpenFlowSwitchNetDevice::DoDispose() { NS_LOG_FUNCTION_NOARGS(); - for (Ports_t::iterator b = m_ports.begin(), e = m_ports.end(); b != e; b++) + for (auto b = m_ports.begin(), e = m_ports.end(); b != e; b++) { SendPortStatus(*b, OFPPR_DELETE); b->netdev = nullptr; @@ -1161,6 +1165,49 @@ OpenFlowSwitchNetDevice::RunThroughVPortTable(uint32_t packet_uid, int port, uin return 0; } +int +OpenFlowSwitchNetDevice::ReceivePortMod(const void* msg) +{ + ofp_port_mod* opm = (ofp_port_mod*)msg; + + int port = opm->port_no; // ntohs(opm->port_no); + if (port < DP_MAX_PORTS) + { + ofi::Port& p = m_ports[port]; + + // Make sure the port id hasn't changed since this was sent + Mac48Address hw_addr = Mac48Address(); + hw_addr.CopyFrom(opm->hw_addr); + if (p.netdev->GetAddress() != hw_addr) + { + return 0; + } + + if (opm->mask) + { + uint32_t config_mask = ntohl(opm->mask); + p.config &= ~config_mask; + p.config |= ntohl(opm->config) & config_mask; + } + + if (opm->mask & htonl(OFPPC_PORT_DOWN)) + { + if ((opm->config & htonl(OFPPC_PORT_DOWN)) && (p.config & OFPPC_PORT_DOWN) == 0) + { + p.config |= OFPPC_PORT_DOWN; + /// \todo Possibly disable the Port's Net Device via the appropriate interface. + } + else if ((opm->config & htonl(OFPPC_PORT_DOWN)) == 0 && (p.config & OFPPC_PORT_DOWN)) + { + p.config &= ~OFPPC_PORT_DOWN; + /// \todo Possibly enable the Port's Net Device via the appropriate interface. + } + } + } + + return 0; +} + int OpenFlowSwitchNetDevice::ReceiveFeaturesRequest(const void* msg) { @@ -1248,49 +1295,6 @@ OpenFlowSwitchNetDevice::ReceivePacketOut(const void* msg) return 0; } -int -OpenFlowSwitchNetDevice::ReceivePortMod(const void* msg) -{ - ofp_port_mod* opm = (ofp_port_mod*)msg; - - int port = opm->port_no; // ntohs(opm->port_no); - if (port < DP_MAX_PORTS) - { - ofi::Port& p = m_ports[port]; - - // Make sure the port id hasn't changed since this was sent - Mac48Address hw_addr = Mac48Address(); - hw_addr.CopyFrom(opm->hw_addr); - if (p.netdev->GetAddress() != hw_addr) - { - return 0; - } - - if (opm->mask) - { - uint32_t config_mask = ntohl(opm->mask); - p.config &= ~config_mask; - p.config |= ntohl(opm->config) & config_mask; - } - - if (opm->mask & htonl(OFPPC_PORT_DOWN)) - { - if ((opm->config & htonl(OFPPC_PORT_DOWN)) && (p.config & OFPPC_PORT_DOWN) == 0) - { - p.config |= OFPPC_PORT_DOWN; - /// \todo Possibly disable the Port's Net Device via the appropriate interface. - } - else if ((opm->config & htonl(OFPPC_PORT_DOWN)) == 0 && (p.config & OFPPC_PORT_DOWN)) - { - p.config &= ~OFPPC_PORT_DOWN; - /// \todo Possibly enable the Port's Net Device via the appropriate interface. - } - } - } - - return 0; -} - // add or remove a virtual port table entry int OpenFlowSwitchNetDevice::ReceiveVPortMod(const void* msg) @@ -1700,5 +1704,3 @@ OpenFlowSwitchNetDevice::GetVPortTable() } } // namespace ns3 - -#endif // NS3_OPENFLOW diff --git a/src/openflow/model/openflow-switch-net-device.h b/src/openflow/model/openflow-switch-net-device.h index 80eb8b618..632c96e4b 100644 --- a/src/openflow/model/openflow-switch-net-device.h +++ b/src/openflow/model/openflow-switch-net-device.h @@ -503,12 +503,12 @@ class OpenFlowSwitchNetDevice : public NetDevice * \param msg The OpenFlow message received. * \return 0 if everything's ok, otherwise an error number. */ + int ReceivePortMod(const void* msg); int ReceiveFeaturesRequest(const void* msg); int ReceiveGetConfigRequest(const void* msg); int ReceiveSetConfig(const void* msg); int ReceivePacketOut(const void* msg); int ReceiveFlow(const void* msg); - int ReceivePortMod(const void* msg); int ReceiveStatsRequest(const void* msg); int ReceiveEchoRequest(const void* msg); int ReceiveEchoReply(const void* msg); @@ -518,7 +518,7 @@ class OpenFlowSwitchNetDevice : public NetDevice /// Rx Callback NetDevice::ReceiveCallback m_rxCallback; - /// Promiscuopus Rx Callback + /// Promiscuous Rx Callback NetDevice::PromiscReceiveCallback m_promiscRxCallback; Mac48Address m_address; ///< Address of this device. diff --git a/src/point-to-point-layout/model/point-to-point-dumbbell.cc b/src/point-to-point-layout/model/point-to-point-dumbbell.cc index f16f4803f..4dbfee001 100644 --- a/src/point-to-point-layout/model/point-to-point-dumbbell.cc +++ b/src/point-to-point-layout/model/point-to-point-dumbbell.cc @@ -17,19 +17,19 @@ // Implement an object to create a dumbbell topology. -#include -#include -#include +#include "point-to-point-dumbbell.h" -// ns3 includes #include "ns3/constant-position-mobility-model.h" #include "ns3/ipv6-address-generator.h" #include "ns3/log.h" #include "ns3/node-list.h" -#include "ns3/point-to-point-dumbbell.h" #include "ns3/point-to-point-net-device.h" #include "ns3/vector.h" +#include +#include +#include + namespace ns3 { @@ -191,7 +191,7 @@ PointToPointDumbbellHelper::AssignIpv6Addresses(Ipv6Address addrBase, Ipv6Prefix ndc.Add(m_leftLeafDevices.Get(i)); ndc.Add(m_leftRouterDevices.Get(i)); Ipv6InterfaceContainer ifc = addressHelper.Assign(ndc); - Ipv6InterfaceContainer::Iterator it = ifc.Begin(); + auto it = ifc.Begin(); m_leftLeafInterfaces6.Add((*it).first, (*it).second); it++; m_leftRouterInterfaces6.Add((*it).first, (*it).second); @@ -207,7 +207,7 @@ PointToPointDumbbellHelper::AssignIpv6Addresses(Ipv6Address addrBase, Ipv6Prefix ndc.Add(m_rightLeafDevices.Get(i)); ndc.Add(m_rightRouterDevices.Get(i)); Ipv6InterfaceContainer ifc = addressHelper.Assign(ndc); - Ipv6InterfaceContainer::Iterator it = ifc.Begin(); + auto it = ifc.Begin(); m_rightLeafInterfaces6.Add((*it).first, (*it).second); it++; m_rightRouterInterfaces6.Add((*it).first, (*it).second); diff --git a/src/point-to-point-layout/model/point-to-point-grid.cc b/src/point-to-point-layout/model/point-to-point-grid.cc index 14ddad53d..831ad8013 100644 --- a/src/point-to-point-layout/model/point-to-point-grid.cc +++ b/src/point-to-point-layout/model/point-to-point-grid.cc @@ -17,7 +17,7 @@ // Implement an object to create a grid topology. -#include "ns3/point-to-point-grid.h" +#include "point-to-point-grid.h" #include "ns3/constant-position-mobility-model.h" #include "ns3/internet-stack-helper.h" diff --git a/src/point-to-point-layout/model/point-to-point-star.cc b/src/point-to-point-layout/model/point-to-point-star.cc index 7ba982cd5..2b416f4b8 100644 --- a/src/point-to-point-layout/model/point-to-point-star.cc +++ b/src/point-to-point-layout/model/point-to-point-star.cc @@ -15,19 +15,19 @@ // Implement an object to create a star topology. -#include -#include -#include +#include "point-to-point-star.h" -// ns3 includes #include "ns3/constant-position-mobility-model.h" #include "ns3/ipv6-address-generator.h" #include "ns3/log.h" #include "ns3/node-list.h" #include "ns3/point-to-point-net-device.h" -#include "ns3/point-to-point-star.h" #include "ns3/vector.h" +#include +#include +#include + namespace ns3 { diff --git a/src/point-to-point/helper/point-to-point-helper.cc b/src/point-to-point/helper/point-to-point-helper.cc index 05cf8e40a..274446441 100644 --- a/src/point-to-point/helper/point-to-point-helper.cc +++ b/src/point-to-point/helper/point-to-point-helper.cc @@ -82,8 +82,7 @@ PointToPointHelper::EnablePcapInternal(std::string prefix, Ptr device = nd->GetObject(); if (!device) { - NS_LOG_INFO("PointToPointHelper::EnablePcapInternal(): Device " - << device << " not of type ns3::PointToPointNetDevice"); + NS_LOG_INFO("Device " << device << " not of type ns3::PointToPointNetDevice"); return; } @@ -117,8 +116,7 @@ PointToPointHelper::EnableAsciiInternal(Ptr stream, Ptr device = nd->GetObject(); if (!device) { - NS_LOG_INFO("PointToPointHelper::EnableAsciiInternal(): Device " - << device << " not of type ns3::PointToPointNetDevice"); + NS_LOG_INFO("Device " << device << " not of type ns3::PointToPointNetDevice"); return; } diff --git a/src/propagation/doc/propagation.rst b/src/propagation/doc/propagation.rst index a57b35a29..1e45fa0e7 100644 --- a/src/propagation/doc/propagation.rst +++ b/src/propagation/doc/propagation.rst @@ -946,7 +946,7 @@ Vehicular fast fading model The fast fading model described in Sec. 6.2.3 of TR 37.885 is based on the one specified in TR 38.901, whose implementation is provided in the ``spectrum`` module -(see the :ref:`spectrum module documentation `). +(see the :ref:`spectrum module documentation <3gpp-fast-fading-model>`). This model is general and includes different parameters which can be tuned to simulate multiple propagation environments. To better model the channel dynamics in vehicular environments, TR 37.885 @@ -956,7 +956,7 @@ To select the parameters for vehicular scenarios, it is necessary to set the attribute "Scenario" of the class :cpp:class:`ThreeGppChannelModel` using the value "V2V-Urban" or "V2V-Highway". -Additionally, TR 37.885 specifies a new equation to compute the Doppler component, +edditionally, TR 37.885 specifies a new equation to compute the Doppler component, which accounts for the mobility of both nodes, as well as scattering from the environment. In particular, the scattering effect is considered by deviating the Doppler @@ -978,7 +978,7 @@ We considered two communicating vehicles moving within the scenario, and computed the SNR experienced during the entire simulation, with a time resolution of 10 ms. The vehicles are equipped with 2x2 antenna arrays modeled using the -:ref:`3GPP antenna model `. +:ref:`3GPP antenna model <3gpp-antenna-model>`. The bearing and the downtilt angles are properly configured and the optimal beamforming vectors are computed at the beginning of the simulation. diff --git a/src/propagation/examples/main-propagation-loss.cc b/src/propagation/examples/main-propagation-loss.cc index fc68317aa..53a12d2f8 100644 --- a/src/propagation/examples/main-propagation-loss.cc +++ b/src/propagation/examples/main-propagation-loss.cc @@ -174,7 +174,7 @@ TestProbabilistic(Ptr model, Simulator::Run(); } - for (rxPowerMapType::const_iterator i = rxPowerMap.begin(); i != rxPowerMap.end(); ++i) + for (auto i = rxPowerMap.begin(); i != rxPowerMap.end(); ++i) { dataset.Add(distance, i->first, (double)i->second / (double)samples); } diff --git a/src/propagation/model/channel-condition-model.h b/src/propagation/model/channel-condition-model.h index a6ee23243..73865c075 100644 --- a/src/propagation/model/channel-condition-model.h +++ b/src/propagation/model/channel-condition-model.h @@ -572,7 +572,7 @@ class ThreeGppChannelConditionModel : public ChannelConditionModel 0}; //!< the threshold for determining what is the ratio of channels with O2I double m_o2iLowLossThreshold{0}; //!< the threshold for determining what is the ratio of low - //!< high O2I building penetration losses - double m_linkO2iConditionToAntennaHeight{ + bool m_linkO2iConditionToAntennaHeight{ false}; //!< the indicator that determines whether the O2I/O2O condition is determined based //!< on the UE height Ptr m_uniformVarO2i; //!< uniform random variable that is used for the diff --git a/src/propagation/model/cost231-propagation-loss-model.cc b/src/propagation/model/cost231-propagation-loss-model.cc index 427844cad..654638abf 100644 --- a/src/propagation/model/cost231-propagation-loss-model.cc +++ b/src/propagation/model/cost231-propagation-loss-model.cc @@ -20,11 +20,12 @@ #include "cost231-propagation-loss-model.h" +#include "propagation-loss-model.h" + #include "ns3/double.h" #include "ns3/log.h" #include "ns3/mobility-model.h" #include "ns3/pointer.h" -#include "ns3/propagation-loss-model.h" #include @@ -155,20 +156,19 @@ Cost231PropagationLossModel::GetLoss(Ptr a, Ptr b) return 0.0; } - double frequency_MHz = m_frequency * 1e-6; + double logFrequencyMhz = std::log10(m_frequency * 1e-6); + double logDistanceKm = std::log10(distance * 1e-3); + double logBSAntennaHeight = std::log10(m_BSAntennaHeight); - double distance_km = distance * 1e-3; - - double C_H = 0.8 + ((1.11 * std::log10(frequency_MHz)) - 0.7) * m_SSAntennaHeight - - (1.56 * std::log10(frequency_MHz)); + double C_H = + 0.8 + ((1.11 * logFrequencyMhz) - 0.7) * m_SSAntennaHeight - (1.56 * logFrequencyMhz); // from the COST231 wiki entry // See also http://www.lx.it.pt/cost231/final_report.htm // Ch. 4, eq. 4.4.3, pg. 135 - double loss_in_db = - 46.3 + (33.9 * std::log10(frequency_MHz)) - (13.82 * std::log10(m_BSAntennaHeight)) - C_H + - ((44.9 - 6.55 * std::log10(m_BSAntennaHeight)) * std::log10(distance_km)) + m_shadowing; + double loss_in_db = 46.3 + (33.9 * logFrequencyMhz) - (13.82 * logBSAntennaHeight) - C_H + + ((44.9 - 6.55 * logBSAntennaHeight) * logDistanceKm) + m_shadowing; NS_LOG_DEBUG("dist =" << distance << ", Path Loss = " << loss_in_db); diff --git a/src/propagation/model/cost231-propagation-loss-model.h b/src/propagation/model/cost231-propagation-loss-model.h index 5f6c3c62d..01f871b53 100644 --- a/src/propagation/model/cost231-propagation-loss-model.h +++ b/src/propagation/model/cost231-propagation-loss-model.h @@ -21,8 +21,9 @@ #ifndef COST231_PROPAGATION_LOSS_MODEL_H #define COST231_PROPAGATION_LOSS_MODEL_H +#include "propagation-loss-model.h" + #include "ns3/nstime.h" -#include "ns3/propagation-loss-model.h" namespace ns3 { diff --git a/src/propagation/model/itu-r-1411-los-propagation-loss-model.h b/src/propagation/model/itu-r-1411-los-propagation-loss-model.h index c0d83184b..15c9d72c4 100644 --- a/src/propagation/model/itu-r-1411-los-propagation-loss-model.h +++ b/src/propagation/model/itu-r-1411-los-propagation-loss-model.h @@ -22,7 +22,7 @@ #ifndef ITU_R_1411_LOS_PROPAGATION_LOSS_MODEL_H #define ITU_R_1411_LOS_PROPAGATION_LOSS_MODEL_H -#include "ns3/propagation-loss-model.h" +#include "propagation-loss-model.h" namespace ns3 { diff --git a/src/propagation/model/itu-r-1411-nlos-over-rooftop-propagation-loss-model.h b/src/propagation/model/itu-r-1411-nlos-over-rooftop-propagation-loss-model.h index 5b5dbe735..40b94522c 100644 --- a/src/propagation/model/itu-r-1411-nlos-over-rooftop-propagation-loss-model.h +++ b/src/propagation/model/itu-r-1411-nlos-over-rooftop-propagation-loss-model.h @@ -22,8 +22,8 @@ #ifndef ITU_R_1411_NLOS_OVER_ROOFTOP_PROPAGATION_LOSS_MODEL_H #define ITU_R_1411_NLOS_OVER_ROOFTOP_PROPAGATION_LOSS_MODEL_H -#include -#include +#include "propagation-environment.h" +#include "propagation-loss-model.h" namespace ns3 { diff --git a/src/propagation/model/jakes-propagation-loss-model.h b/src/propagation/model/jakes-propagation-loss-model.h index d67310a2c..e61867b04 100644 --- a/src/propagation/model/jakes-propagation-loss-model.h +++ b/src/propagation/model/jakes-propagation-loss-model.h @@ -19,9 +19,9 @@ #ifndef JAKES_STATIONARY_LOSS_MODEL_H #define JAKES_STATIONARY_LOSS_MODEL_H -#include "ns3/jakes-process.h" -#include "ns3/propagation-cache.h" -#include "ns3/propagation-loss-model.h" +#include "jakes-process.h" +#include "propagation-cache.h" +#include "propagation-loss-model.h" namespace ns3 { diff --git a/src/propagation/model/kun-2600-mhz-propagation-loss-model.h b/src/propagation/model/kun-2600-mhz-propagation-loss-model.h index 18fd6084f..f36a6e1da 100644 --- a/src/propagation/model/kun-2600-mhz-propagation-loss-model.h +++ b/src/propagation/model/kun-2600-mhz-propagation-loss-model.h @@ -22,7 +22,7 @@ #ifndef KUN_2600MHZ_PROPAGATION_LOSS_MODEL_H #define KUN_2600MHZ_PROPAGATION_LOSS_MODEL_H -#include +#include "propagation-loss-model.h" namespace ns3 { diff --git a/src/propagation/model/okumura-hata-propagation-loss-model.cc b/src/propagation/model/okumura-hata-propagation-loss-model.cc index 6020b8d0d..94be7b7d0 100644 --- a/src/propagation/model/okumura-hata-propagation-loss-model.cc +++ b/src/propagation/model/okumura-hata-propagation-loss-model.cc @@ -25,6 +25,7 @@ #include "ns3/log.h" #include "ns3/mobility-model.h" +#include #include namespace ns3 @@ -80,19 +81,28 @@ OkumuraHataPropagationLossModel::GetLoss(Ptr a, PtrGetDistanceFrom(b) / 1000.0; + double log_fMhz = std::log10(fmhz); + // In the Okumura Hata literature, the distance is expressed in units of kilometers + // but other lengths are expressed in meters + double distKm = a->GetDistanceFrom(b) / 1000.0; + + Vector aPosition = a->GetPosition(); + Vector bPosition = b->GetPosition(); + + double hb = std::max(aPosition.z, bPosition.z); + double hm = std::min(aPosition.z, bPosition.z); + + NS_ASSERT_MSG(hb > 0 && hm > 0, "nodes' height must be greater then 0"); + + double log_hb = std::log10(hb); + double log_aHeight = 13.82 * log_hb; + double log_bHeight = 0.0; + if (m_frequency <= 1.500e9) { // standard Okumura Hata // see eq. (4.4.1) in the COST 231 final report - double log_f = std::log10(fmhz); - double hb = - (a->GetPosition().z > b->GetPosition().z ? a->GetPosition().z : b->GetPosition().z); - double hm = - (a->GetPosition().z < b->GetPosition().z ? a->GetPosition().z : b->GetPosition().z); - NS_ASSERT_MSG(hb > 0 && hm > 0, "nodes' height must be greater then 0"); - double log_aHeight = 13.82 * std::log10(hb); - double log_bHeight = 0.0; + if (m_citySize == LargeCity) { if (fmhz < 200) @@ -106,21 +116,21 @@ OkumuraHataPropagationLossModel::GetLoss(Ptr a, PtrGetDistanceFrom(b))) - << " logb " << log_bHeight); - loss = 69.55 + (26.16 * log_f) - log_aHeight + - (((44.9 - (6.55 * std::log10(hb)))) * std::log10(dist)) - log_bHeight; + NS_LOG_INFO(this << " logf " << 26.16 * log_fMhz << " loga " << log_aHeight << " X " + << ((44.9 - (6.55 * log_hb)) * std::log10(distKm)) << " logb " + << log_bHeight); + loss = 69.55 + (26.16 * log_fMhz) - log_aHeight + + ((44.9 - (6.55 * log_hb)) * std::log10(distKm)) - log_bHeight; if (m_environment == SubUrbanEnvironment) { loss += -2 * (std::pow(std::log10(fmhz / 28), 2)) - 5.4; } else if (m_environment == OpenAreasEnvironment) { - loss += -4.70 * std::pow(std::log10(fmhz), 2) + 18.33 * std::log10(fmhz) - 40.94; + loss += -4.70 * std::pow(log_fMhz, 2) + 18.33 * log_fMhz - 40.94; } } else @@ -128,28 +138,20 @@ OkumuraHataPropagationLossModel::GetLoss(Ptr a, PtrGetPosition().z > b->GetPosition().z ? a->GetPosition().z : b->GetPosition().z); - double hm = - (a->GetPosition().z < b->GetPosition().z ? a->GetPosition().z : b->GetPosition().z); - NS_ASSERT_MSG(hb > 0 && hm > 0, "nodes' height must be greater then 0"); - double log_aHeight = 13.82 * std::log10(hb); - double log_bHeight = 0.0; double C = 0.0; if (m_citySize == LargeCity) { - log_bHeight = 3.2 * std::pow((std::log10(11.75 * hm)), 2); + log_bHeight = 3.2 * std::pow(std::log10(11.75 * hm), 2); C = 3; } else { - log_bHeight = (1.1 * log_f - 0.7) * hm - (1.56 * log_f - 0.8); + log_bHeight = (1.1 * log_fMhz - 0.7) * hm - (1.56 * log_fMhz - 0.8); } - loss = 46.3 + (33.9 * log_f) - log_aHeight + - (((44.9 - (6.55 * std::log10(hb)))) * std::log10(dist)) - log_bHeight + C; + loss = 46.3 + (33.9 * log_fMhz) - log_aHeight + + ((44.9 - (6.55 * log_hb)) * std::log10(distKm)) - log_bHeight + C; } return loss; } diff --git a/src/propagation/model/okumura-hata-propagation-loss-model.h b/src/propagation/model/okumura-hata-propagation-loss-model.h index 54c8c8cb6..c20553525 100644 --- a/src/propagation/model/okumura-hata-propagation-loss-model.h +++ b/src/propagation/model/okumura-hata-propagation-loss-model.h @@ -22,8 +22,8 @@ #ifndef OKUMURA_HATA_PROPAGATION_LOSS_MODEL_H #define OKUMURA_HATA_PROPAGATION_LOSS_MODEL_H -#include -#include +#include "propagation-environment.h" +#include "propagation-loss-model.h" namespace ns3 { diff --git a/src/propagation/model/probabilistic-v2v-channel-condition-model.h b/src/propagation/model/probabilistic-v2v-channel-condition-model.h index d70a7b890..d75151392 100644 --- a/src/propagation/model/probabilistic-v2v-channel-condition-model.h +++ b/src/propagation/model/probabilistic-v2v-channel-condition-model.h @@ -19,7 +19,7 @@ #ifndef PROBABILISTIC_V2V_CHANNEL_CONDITION_MODEL_H #define PROBABILISTIC_V2V_CHANNEL_CONDITION_MODEL_H -#include "ns3/channel-condition-model.h" +#include "channel-condition-model.h" namespace ns3 { diff --git a/src/propagation/model/propagation-cache.h b/src/propagation/model/propagation-cache.h index 526bd3ee7..a05c5623c 100644 --- a/src/propagation/model/propagation-cache.h +++ b/src/propagation/model/propagation-cache.h @@ -48,7 +48,7 @@ class PropagationCache Ptr GetPathData(Ptr a, Ptr b, uint32_t modelUid) { PropagationPathIdentifier key = PropagationPathIdentifier(a, b, modelUid); - typename PathCache::iterator it = m_pathCache.find(key); + auto it = m_pathCache.find(key); if (it == m_pathCache.end()) { return nullptr; diff --git a/src/propagation/model/propagation-loss-model.cc b/src/propagation/model/propagation-loss-model.cc index 116149a55..309e60fbb 100644 --- a/src/propagation/model/propagation-loss-model.cc +++ b/src/propagation/model/propagation-loss-model.cc @@ -747,7 +747,7 @@ NakagamiPropagationLossModel::DoCalcRxPower(double txPowerDbm, // switch between Erlang- and Gamma distributions: this is only for // speed. (Gamma is equal to Erlang for any positive integer m.) - unsigned int int_m = static_cast(std::floor(m)); + auto int_m = static_cast(std::floor(m)); if (int_m == m) { @@ -869,7 +869,7 @@ MatrixPropagationLossModel::SetLoss(Ptr ma, NS_ASSERT(ma && mb); MobilityPair p = std::make_pair(ma, mb); - std::map::iterator i = m_loss.find(p); + auto i = m_loss.find(p); if (i == m_loss.end()) { @@ -891,7 +891,7 @@ MatrixPropagationLossModel::DoCalcRxPower(double txPowerDbm, Ptr a, Ptr b) const { - std::map::const_iterator i = m_loss.find(std::make_pair(a, b)); + auto i = m_loss.find(std::make_pair(a, b)); if (i != m_loss.end()) { diff --git a/src/propagation/model/three-gpp-propagation-loss-model.cc b/src/propagation/model/three-gpp-propagation-loss-model.cc index 7f2855a7e..6e25f2b2e 100644 --- a/src/propagation/model/three-gpp-propagation-loss-model.cc +++ b/src/propagation/model/three-gpp-propagation-loss-model.cc @@ -18,8 +18,9 @@ #include "three-gpp-propagation-loss-model.h" +#include "channel-condition-model.h" + #include "ns3/boolean.h" -#include "ns3/channel-condition-model.h" #include "ns3/double.h" #include "ns3/log.h" #include "ns3/mobility-model.h" diff --git a/src/propagation/model/three-gpp-propagation-loss-model.h b/src/propagation/model/three-gpp-propagation-loss-model.h index c664fafcc..646b77dd2 100644 --- a/src/propagation/model/three-gpp-propagation-loss-model.h +++ b/src/propagation/model/three-gpp-propagation-loss-model.h @@ -19,8 +19,8 @@ #ifndef THREE_GPP_PROPAGATION_LOSS_MODEL_H #define THREE_GPP_PROPAGATION_LOSS_MODEL_H -#include "ns3/channel-condition-model.h" -#include "ns3/propagation-loss-model.h" +#include "channel-condition-model.h" +#include "propagation-loss-model.h" namespace ns3 { diff --git a/src/sixlowpan/CMakeLists.txt b/src/sixlowpan/CMakeLists.txt index 00c4b5fdb..825bf3218 100644 --- a/src/sixlowpan/CMakeLists.txt +++ b/src/sixlowpan/CMakeLists.txt @@ -17,8 +17,6 @@ build_lib( model/sixlowpan-net-device.h LIBRARIES_TO_LINK ${libinternet} - ${libinternet} - ${libcore} TEST_SOURCES ${example_as_test_suite} test/mock-net-device.cc diff --git a/src/sixlowpan/helper/sixlowpan-helper.cc b/src/sixlowpan/helper/sixlowpan-helper.cc index 74ab70a60..703808b4f 100644 --- a/src/sixlowpan/helper/sixlowpan-helper.cc +++ b/src/sixlowpan/helper/sixlowpan-helper.cc @@ -140,7 +140,7 @@ SixLowPanHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr dev = DynamicCast(netDevice); diff --git a/src/sixlowpan/model/sixlowpan-net-device.cc b/src/sixlowpan/model/sixlowpan-net-device.cc index 080cb7a9c..c509b61c0 100644 --- a/src/sixlowpan/model/sixlowpan-net-device.cc +++ b/src/sixlowpan/model/sixlowpan-net-device.cc @@ -192,7 +192,7 @@ SixLowPanNetDevice::DoDispose() m_timeoutEvent.Cancel(); } - for (MapFragmentsI_t iter = m_fragments.begin(); iter != m_fragments.end(); iter++) + for (auto iter = m_fragments.begin(); iter != m_fragments.end(); iter++) { iter->second = nullptr; } @@ -666,9 +666,8 @@ SixLowPanNetDevice::DoSend(Ptr packet, // fragment std::list> fragmentList; DoFragmentation(packet, origPacketSize, origHdrSize, extraHdrSize, fragmentList); - std::list>::iterator it; bool success = true; - for (it = fragmentList.begin(); it != fragmentList.end(); it++) + for (auto it = fragmentList.begin(); it != fragmentList.end(); it++) { NS_LOG_DEBUG("SixLowPanNetDevice::Send (Fragment) " << **it); m_txTrace(*it, this, GetIfIndex()); @@ -2343,7 +2342,7 @@ SixLowPanNetDevice::DoFragmentation(Ptr packet, uint32_t packetSize = packet->GetSize(); uint32_t compressedHeaderSize = packetSize - (origPacketSize - origHdrSize); - uint16_t tag = uint16_t(m_rng->GetValue(0, 65535)); + auto tag = static_cast(m_rng->GetValue(0, 65535)); NS_LOG_LOGIC("random tag " << tag << " - test " << packetSize); // first fragment @@ -2474,18 +2473,17 @@ SixLowPanNetDevice::ProcessFragment(Ptr& packet, Ptr fragments; - MapFragments_t::iterator it = m_fragments.find(key); + auto it = m_fragments.find(key); if (it == m_fragments.end()) { // erase the oldest packet. if (m_fragmentReassemblyListSize && (m_fragments.size() >= m_fragmentReassemblyListSize)) { - FragmentsTimeoutsListI_t iter = m_timeoutEventList.begin(); + auto iter = m_timeoutEventList.begin(); FragmentKey_t oldestKey = std::get<1>(*iter); std::list> storedFragments = m_fragments[oldestKey]->GetFragments(); - for (std::list>::iterator fragIter = storedFragments.begin(); - fragIter != storedFragments.end(); + for (auto fragIter = storedFragments.begin(); fragIter != storedFragments.end(); fragIter++) { m_dropTrace(DROP_FRAGMENT_BUFFER_FULL, *fragIter, this, GetIfIndex()); @@ -2500,7 +2498,7 @@ SixLowPanNetDevice::ProcessFragment(Ptr& packet, m_fragments.insert(std::make_pair(key, fragments)); uint32_t ifIndex = GetIfIndex(); - FragmentsTimeoutsListI_t iter = SetTimeout(key, ifIndex); + auto iter = SetTimeout(key, ifIndex); fragments->SetTimeoutIter(iter); } else @@ -2592,9 +2590,7 @@ SixLowPanNetDevice::Fragments::IsEntire() const if (ret) { - for (std::list, uint16_t>>::const_iterator it = m_fragments.begin(); - it != m_fragments.end(); - it++) + for (auto it = m_fragments.begin(); it != m_fragments.end(); it++) { // overlapping fragments should not exist NS_LOG_LOGIC("Checking overlaps " << lastEndOffset << " - " << it->second); @@ -2618,7 +2614,7 @@ SixLowPanNetDevice::Fragments::GetPacket() const { NS_LOG_FUNCTION(this); - std::list, uint16_t>>::const_iterator it = m_fragments.begin(); + auto it = m_fragments.begin(); Ptr p = Create(); uint16_t lastEndOffset = 0; @@ -2655,8 +2651,7 @@ std::list> SixLowPanNetDevice::Fragments::GetFragments() const { std::list> fragments; - std::list, uint16_t>>::const_iterator iter; - for (iter = m_fragments.begin(); iter != m_fragments.end(); iter++) + for (auto iter = m_fragments.begin(); iter != m_fragments.end(); iter++) { fragments.push_back(iter->first); } @@ -2680,11 +2675,9 @@ SixLowPanNetDevice::HandleFragmentsTimeout(FragmentKey_t key, uint32_t iif) { NS_LOG_FUNCTION(this); - MapFragments_t::iterator it = m_fragments.find(key); + auto it = m_fragments.find(key); std::list> storedFragments = it->second->GetFragments(); - for (std::list>::iterator fragIter = storedFragments.begin(); - fragIter != storedFragments.end(); - fragIter++) + for (auto fragIter = storedFragments.begin(); fragIter != storedFragments.end(); fragIter++) { m_dropTrace(DROP_FRAGMENT_TIMEOUT, *fragIter, this, iif); } @@ -2719,7 +2712,7 @@ SixLowPanNetDevice::SetTimeout(FragmentKey_t key, uint32_t iif) } m_timeoutEventList.emplace_back(Simulator::Now() + m_fragmentExpirationTimeout, key, iif); - SixLowPanNetDevice::FragmentsTimeoutsListI_t iter = --m_timeoutEventList.end(); + auto iter = --m_timeoutEventList.end(); return (iter); } diff --git a/src/sixlowpan/test/example-ping-lr-wpan.reflog b/src/sixlowpan/test/sixlowpan-example-ping-lr-wpan.reflog similarity index 100% rename from src/sixlowpan/test/example-ping-lr-wpan.reflog rename to src/sixlowpan/test/sixlowpan-example-ping-lr-wpan.reflog diff --git a/src/sixlowpan/test/sixlowpan-examples-test-suite.cc b/src/sixlowpan/test/sixlowpan-examples-test-suite.cc index 74022e3bd..620071473 100644 --- a/src/sixlowpan/test/sixlowpan-examples-test-suite.cc +++ b/src/sixlowpan/test/sixlowpan-examples-test-suite.cc @@ -1,7 +1,7 @@ #include "ns3/example-as-test.h" static ns3::ExampleAsTestSuite g_sixlowpanExample( - "example-ping-lr-wpan", + "sixlowpan-example-ping-lr-wpan", "example-ping-lr-wpan", NS_TEST_SOURCEDIR, "--disable-pcap --disable-asciitrace --enable-sixlowpan-loginfo"); diff --git a/src/spectrum/doc/spectrum.rst b/src/spectrum/doc/spectrum.rst index be7118cc0..d971b589f 100644 --- a/src/spectrum/doc/spectrum.rst +++ b/src/spectrum/doc/spectrum.rst @@ -594,6 +594,8 @@ the given geographic origin point, and is tested in the ``rand-cart-around-geo`` test suite by verifying that the generated points do not exceed the given maximum distance radius from the origin point. +.. _3gpp-fast-fading-model: + 3GPP TR 38.901 fast fading model ================================ The framework described by TR 38.901 [TR38901]_ is a 3D statistical Spatial @@ -1042,6 +1044,3 @@ References Mattias Frenne, Farshid Ghasemzadeh, Måns Hagström et al. Advanced Antenna Systems for 5G Network Deployments: Bridging the Gap Between Theory and Practice. Academic Press, 2020. - -.. [TR38901] 3GPP. 2018. TR 38.901. Study on channel for frequencies from 0.5 to - 100 GHz. V.15.0.0. (2018-06). diff --git a/src/spectrum/examples/adhoc-aloha-ideal-phy-matrix-propagation-loss-model.cc b/src/spectrum/examples/adhoc-aloha-ideal-phy-matrix-propagation-loss-model.cc index 22ac384a2..b49b2bf2b 100644 --- a/src/spectrum/examples/adhoc-aloha-ideal-phy-matrix-propagation-loss-model.cc +++ b/src/spectrum/examples/adhoc-aloha-ideal-phy-matrix-propagation-loss-model.cc @@ -110,14 +110,9 @@ GlobalPathlossDatabase::UpdatePathloss(std::string context, void GlobalPathlossDatabase::Print() { - for (std::map>::const_iterator txit = - m_pathlossMap.begin(); - txit != m_pathlossMap.end(); - ++txit) + for (auto txit = m_pathlossMap.begin(); txit != m_pathlossMap.end(); ++txit) { - for (std::map::const_iterator rxit = txit->second.begin(); - rxit != txit->second.end(); - ++rxit) + for (auto rxit = txit->second.begin(); rxit != txit->second.end(); ++rxit) { std::cout << txit->first << " --> " << rxit->first << " : " << rxit->second << " dB" << std::endl; diff --git a/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc b/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc index 02e3ab28d..0180995fc 100644 --- a/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc +++ b/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc @@ -91,7 +91,7 @@ NetDeviceContainer AdhocAlohaNoackIdealPhyHelper::Install(NodeContainer c) const { NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; diff --git a/src/spectrum/helper/spectrum-analyzer-helper.cc b/src/spectrum/helper/spectrum-analyzer-helper.cc index bba571203..a4d74f981 100644 --- a/src/spectrum/helper/spectrum-analyzer-helper.cc +++ b/src/spectrum/helper/spectrum-analyzer-helper.cc @@ -51,8 +51,8 @@ WriteAveragePowerSpectralDensityReport(Ptr streamWrapper, std::ostream* ostream = streamWrapper->GetStream(); if (ostream->good()) { - Bands::const_iterator fi = avgPowerSpectralDensity->ConstBandsBegin(); - Values::const_iterator vi = avgPowerSpectralDensity->ConstValuesBegin(); + auto fi = avgPowerSpectralDensity->ConstBandsBegin(); + auto vi = avgPowerSpectralDensity->ConstValuesBegin(); while (fi != avgPowerSpectralDensity->ConstBandsEnd()) { NS_ASSERT(vi != avgPowerSpectralDensity->ConstValuesEnd()); @@ -126,7 +126,7 @@ SpectrumAnalyzerHelper::Install(NodeContainer c) const { NS_LOG_FUNCTION(this); NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; diff --git a/src/spectrum/helper/tv-spectrum-transmitter-helper.cc b/src/spectrum/helper/tv-spectrum-transmitter-helper.cc index 36161452f..311206a39 100644 --- a/src/spectrum/helper/tv-spectrum-transmitter-helper.cc +++ b/src/spectrum/helper/tv-spectrum-transmitter-helper.cc @@ -133,7 +133,7 @@ TvSpectrumTransmitterHelper::Install(NodeContainer nodeCont) NS_LOG_FUNCTION(this); NetDeviceContainer devCont; // iterate over node container to make one transmitter for each given node - for (NodeContainer::Iterator i = nodeCont.Begin(); i != nodeCont.End(); ++i) + for (auto i = nodeCont.Begin(); i != nodeCont.End(); ++i) { Ptr node = *i; Ptr phy = m_factory.Create()->GetObject(); @@ -193,7 +193,7 @@ TvSpectrumTransmitterHelper::Install(NodeContainer nodeCont, Region region, uint japanEndFrequencies[channelNumber] - japanStartFrequencies[channelNumber]; } // iterate over node container to make one transmitter for each given node - for (NodeContainer::Iterator i = nodeCont.Begin(); i != nodeCont.End(); ++i) + for (auto i = nodeCont.Begin(); i != nodeCont.End(); ++i) { Ptr node = *i; Ptr phy = m_factory.Create()->GetObject(); @@ -226,7 +226,7 @@ TvSpectrumTransmitterHelper::InstallAdjacent(NodeContainer nodeCont) DoubleValue startFrequency; DoubleValue channelBandwidth; // iterate over node container to make one transmitter for each given node - for (NodeContainer::Iterator i = nodeCont.Begin(); i != nodeCont.End(); ++i) + for (auto i = nodeCont.Begin(); i != nodeCont.End(); ++i) { Ptr node = *i; Ptr phy = m_factory.Create()->GetObject(); @@ -265,7 +265,7 @@ TvSpectrumTransmitterHelper::InstallAdjacent(NodeContainer nodeCont, uint16_t currChannelNumber; int index = 0; // iterate over node container to make one transmitter for each given node - for (NodeContainer::Iterator i = nodeCont.Begin(); i != nodeCont.End(); ++i) + for (auto i = nodeCont.Begin(); i != nodeCont.End(); ++i) { currChannelNumber = channelNumber + index; if (region == REGION_NORTH_AMERICA) @@ -461,7 +461,7 @@ TvSpectrumTransmitterHelper::InstallRandomRegionalTransmitters( tvNode.Create(1); mobility.Install(tvNode); // set channel number for this transmitter - uint16_t channelNumber = (uint16_t)transmitterIndicesToCreate.front(); + auto channelNumber = (uint16_t)transmitterIndicesToCreate.front(); Install(tvNode, region, channelNumber); // install tv transmitter transmitterLocations.pop_front(); // remove created transmitter location transmitterIndicesToCreate.pop_front(); // remove created transmitter index diff --git a/src/spectrum/helper/waveform-generator-helper.cc b/src/spectrum/helper/waveform-generator-helper.cc index ccd6e4506..5b91d40cf 100644 --- a/src/spectrum/helper/waveform-generator-helper.cc +++ b/src/spectrum/helper/waveform-generator-helper.cc @@ -82,7 +82,7 @@ NetDeviceContainer WaveformGeneratorHelper::Install(NodeContainer c) const { NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; diff --git a/src/spectrum/model/constant-spectrum-propagation-loss.cc b/src/spectrum/model/constant-spectrum-propagation-loss.cc index 12152f946..8e1b60306 100644 --- a/src/spectrum/model/constant-spectrum-propagation-loss.cc +++ b/src/spectrum/model/constant-spectrum-propagation-loss.cc @@ -17,7 +17,7 @@ * Author: Manuel Requena */ -#include "ns3/constant-spectrum-propagation-loss.h" +#include "constant-spectrum-propagation-loss.h" #include "spectrum-signal-parameters.h" @@ -84,8 +84,8 @@ ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity( NS_LOG_FUNCTION(this); Ptr rxPsd = Copy(params->psd); - Values::iterator vit = rxPsd->ValuesBegin(); - Bands::const_iterator fit = rxPsd->ConstBandsBegin(); + auto vit = rxPsd->ValuesBegin(); + auto fit = rxPsd->ConstBandsBegin(); while (vit != rxPsd->ValuesEnd()) { diff --git a/src/spectrum/model/constant-spectrum-propagation-loss.h b/src/spectrum/model/constant-spectrum-propagation-loss.h index 1669eeed0..dbb315c10 100644 --- a/src/spectrum/model/constant-spectrum-propagation-loss.h +++ b/src/spectrum/model/constant-spectrum-propagation-loss.h @@ -20,7 +20,7 @@ #ifndef CONSTANT_SPECTRUM_PROPAGATION_LOSS_H #define CONSTANT_SPECTRUM_PROPAGATION_LOSS_H -#include "ns3/spectrum-propagation-loss-model.h" +#include "spectrum-propagation-loss-model.h" namespace ns3 { diff --git a/src/spectrum/model/friis-spectrum-propagation-loss.cc b/src/spectrum/model/friis-spectrum-propagation-loss.cc index c6d2594eb..dddb2090c 100644 --- a/src/spectrum/model/friis-spectrum-propagation-loss.cc +++ b/src/spectrum/model/friis-spectrum-propagation-loss.cc @@ -17,9 +17,10 @@ * Author: Nicola Baldo */ +#include "friis-spectrum-propagation-loss.h" + #include "spectrum-signal-parameters.h" -#include #include #include // for M_PI @@ -54,8 +55,8 @@ FriisSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity( Ptr b) const { Ptr rxPsd = Copy(params->psd); - Values::iterator vit = rxPsd->ValuesBegin(); - Bands::const_iterator fit = rxPsd->ConstBandsBegin(); + auto vit = rxPsd->ValuesBegin(); + auto fit = rxPsd->ConstBandsBegin(); NS_ASSERT(a); NS_ASSERT(b); diff --git a/src/spectrum/model/friis-spectrum-propagation-loss.h b/src/spectrum/model/friis-spectrum-propagation-loss.h index 1749d08f8..0810ba236 100644 --- a/src/spectrum/model/friis-spectrum-propagation-loss.h +++ b/src/spectrum/model/friis-spectrum-propagation-loss.h @@ -20,7 +20,7 @@ #ifndef FRIIS_SPECTRUM_PROPAGATION_LOSS_H #define FRIIS_SPECTRUM_PROPAGATION_LOSS_H -#include +#include "spectrum-propagation-loss-model.h" namespace ns3 { diff --git a/src/spectrum/model/half-duplex-ideal-phy-signal-parameters.h b/src/spectrum/model/half-duplex-ideal-phy-signal-parameters.h index 614ef4949..d34484679 100644 --- a/src/spectrum/model/half-duplex-ideal-phy-signal-parameters.h +++ b/src/spectrum/model/half-duplex-ideal-phy-signal-parameters.h @@ -20,7 +20,7 @@ #ifndef HALF_DUPLEX_IDEAL_PHY_SPECTRUM_PARAMETERS_H #define HALF_DUPLEX_IDEAL_PHY_SPECTRUM_PARAMETERS_H -#include +#include "spectrum-signal-parameters.h" namespace ns3 { diff --git a/src/spectrum/model/half-duplex-ideal-phy.h b/src/spectrum/model/half-duplex-ideal-phy.h index f77e6be5c..7a3b09f4a 100644 --- a/src/spectrum/model/half-duplex-ideal-phy.h +++ b/src/spectrum/model/half-duplex-ideal-phy.h @@ -20,6 +20,12 @@ #ifndef HALF_DUPLEX_IDEAL_PHY_H #define HALF_DUPLEX_IDEAL_PHY_H +#include "spectrum-channel.h" +#include "spectrum-interference.h" +#include "spectrum-phy.h" +#include "spectrum-signal-parameters.h" +#include "spectrum-value.h" + #include #include #include @@ -27,11 +33,6 @@ #include #include #include -#include -#include -#include -#include -#include namespace ns3 { diff --git a/src/spectrum/model/ism-spectrum-value-helper.h b/src/spectrum/model/ism-spectrum-value-helper.h index 9937ea650..bcbe2ca00 100644 --- a/src/spectrum/model/ism-spectrum-value-helper.h +++ b/src/spectrum/model/ism-spectrum-value-helper.h @@ -22,7 +22,7 @@ #ifndef ISM_SPECTRUM_VALUE_HELPER_H #define ISM_SPECTRUM_VALUE_HELPER_H -#include +#include "spectrum-value.h" namespace ns3 { diff --git a/src/spectrum/model/microwave-oven-spectrum-value-helper.h b/src/spectrum/model/microwave-oven-spectrum-value-helper.h index 6bd0200cf..030086ab7 100644 --- a/src/spectrum/model/microwave-oven-spectrum-value-helper.h +++ b/src/spectrum/model/microwave-oven-spectrum-value-helper.h @@ -20,7 +20,7 @@ #ifndef MICROWAVE_OVEN_SPECTRUM_VALUE_HELPER_H #define MICROWAVE_OVEN_SPECTRUM_VALUE_HELPER_H -#include +#include "spectrum-value.h" namespace ns3 { diff --git a/src/spectrum/model/multi-model-spectrum-channel.cc b/src/spectrum/model/multi-model-spectrum-channel.cc index b782a8b5f..19031abf8 100644 --- a/src/spectrum/model/multi-model-spectrum-channel.cc +++ b/src/spectrum/model/multi-model-spectrum-channel.cc @@ -19,6 +19,11 @@ #include "multi-model-spectrum-channel.h" +#include "spectrum-converter.h" +#include "spectrum-phy.h" +#include "spectrum-propagation-loss-model.h" +#include "spectrum-transmit-filter.h" + #include #include #include @@ -32,10 +37,6 @@ #include #include #include -#include -#include -#include -#include #include #include @@ -57,10 +58,9 @@ NS_OBJECT_ENSURE_REGISTERED(MultiModelSpectrumChannel); std::ostream& operator<<(std::ostream& lhs, TxSpectrumModelInfoMap_t& rhs) { - for (TxSpectrumModelInfoMap_t::iterator it = rhs.begin(); it != rhs.end(); ++it) + for (auto it = rhs.begin(); it != rhs.end(); ++it) { - SpectrumConverterMap_t::iterator jt; - for (jt = it->second.m_spectrumConverterMap.begin(); + for (auto jt = it->second.m_spectrumConverterMap.begin(); jt != it->second.m_spectrumConverterMap.end(); ++jt) { @@ -116,7 +116,7 @@ MultiModelSpectrumChannel::RemoveRx(Ptr phy) // we need to scan for all rxSpectrumModel values since we don't // know which spectrum model the phy had when it was previously added // (it's probably different than the current one) - for (RxSpectrumModelInfoMap_t::iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); + for (auto rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); rxInfoIterator != m_rxSpectrumModelInfoMap.end(); ++rxInfoIterator) { @@ -159,7 +159,7 @@ MultiModelSpectrumChannel::AddRx(Ptr phy) if (inserted) { // create the necessary converters for all the TX spectrum models that we know of - for (TxSpectrumModelInfoMap_t::iterator txInfoIterator = m_txSpectrumModelInfoMap.begin(); + for (auto txInfoIterator = m_txSpectrumModelInfoMap.begin(); txInfoIterator != m_txSpectrumModelInfoMap.end(); ++txInfoIterator) { @@ -172,8 +172,7 @@ MultiModelSpectrumChannel::AddRx(Ptr phy) NS_LOG_LOGIC("Creating converter between SpectrumModelUid " << txSpectrumModel->GetUid() << " and " << rxSpectrumModelUid); SpectrumConverter converter(txSpectrumModel, rxSpectrumModel); - std::pair ret2; - ret2 = txInfoIterator->second.m_spectrumConverterMap.insert( + auto ret2 = txInfoIterator->second.m_spectrumConverterMap.insert( std::make_pair(rxSpectrumModelUid, converter)); NS_ASSERT(ret2.second); } @@ -187,22 +186,19 @@ MultiModelSpectrumChannel::FindAndEventuallyAddTxSpectrumModel( { NS_LOG_FUNCTION(this << txSpectrumModel); SpectrumModelUid_t txSpectrumModelUid = txSpectrumModel->GetUid(); - TxSpectrumModelInfoMap_t::iterator txInfoIterator = - m_txSpectrumModelInfoMap.find(txSpectrumModelUid); + auto txInfoIterator = m_txSpectrumModelInfoMap.find(txSpectrumModelUid); if (txInfoIterator == m_txSpectrumModelInfoMap.end()) { // first time we see this TX SpectrumModel // we add it to the list - std::pair ret; - ret = m_txSpectrumModelInfoMap.insert( + auto ret = m_txSpectrumModelInfoMap.insert( std::make_pair(txSpectrumModelUid, TxSpectrumModelInfo(txSpectrumModel))); NS_ASSERT(ret.second); txInfoIterator = ret.first; // and we create the converters for all the RX SpectrumModels that we know of - for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = - m_rxSpectrumModelInfoMap.begin(); + for (auto rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); rxInfoIterator != m_rxSpectrumModelInfoMap.end(); ++rxInfoIterator) { @@ -216,8 +212,7 @@ MultiModelSpectrumChannel::FindAndEventuallyAddTxSpectrumModel( << txSpectrumModelUid << " and " << rxSpectrumModelUid); SpectrumConverter converter(txSpectrumModel, rxSpectrumModel); - std::pair ret2; - ret2 = txInfoIterator->second.m_spectrumConverterMap.insert( + auto ret2 = txInfoIterator->second.m_spectrumConverterMap.insert( std::make_pair(rxSpectrumModelUid, converter)); NS_ASSERT(ret2.second); } @@ -247,7 +242,7 @@ MultiModelSpectrumChannel::StartTx(Ptr txParams) NS_LOG_LOGIC("txSpectrumModelUid " << txSpectrumModelUid); // - TxSpectrumModelInfoMap_t::const_iterator txInfoIteratorerator = + auto txInfoIteratorerator = FindAndEventuallyAddTxSpectrumModel(txParams->psd->GetSpectrumModel()); NS_ASSERT(txInfoIteratorerator != m_txSpectrumModelInfoMap.end()); @@ -257,7 +252,7 @@ MultiModelSpectrumChannel::StartTx(Ptr txParams) NS_LOG_LOGIC("converter map first element: " << txInfoIteratorerator->second.m_spectrumConverterMap.begin()->first); - for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); + for (auto rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); rxInfoIterator != m_rxSpectrumModelInfoMap.end(); ++rxInfoIterator) { @@ -274,7 +269,7 @@ MultiModelSpectrumChannel::StartTx(Ptr txParams) { NS_LOG_LOGIC("converting txPowerSpectrum SpectrumModelUids " << txSpectrumModelUid << " --> " << rxSpectrumModelUid); - SpectrumConverterMap_t::const_iterator rxConverterIterator = + auto rxConverterIterator = txInfoIteratorerator->second.m_spectrumConverterMap.find(rxSpectrumModelUid); if (rxConverterIterator == txInfoIteratorerator->second.m_spectrumConverterMap.end()) { @@ -451,7 +446,7 @@ MultiModelSpectrumChannel::GetDevice(std::size_t i) const // On the other hand, having slow SpectrumModel conversion would be // less acceptable. std::size_t j = 0; - for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); + for (auto rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); rxInfoIterator != m_rxSpectrumModelInfoMap.end(); ++rxInfoIterator) { diff --git a/src/spectrum/model/multi-model-spectrum-channel.h b/src/spectrum/model/multi-model-spectrum-channel.h index 6ace8abf5..b485eb96e 100644 --- a/src/spectrum/model/multi-model-spectrum-channel.h +++ b/src/spectrum/model/multi-model-spectrum-channel.h @@ -20,11 +20,12 @@ #ifndef MULTI_MODEL_SPECTRUM_CHANNEL_H #define MULTI_MODEL_SPECTRUM_CHANNEL_H +#include "spectrum-channel.h" +#include "spectrum-converter.h" +#include "spectrum-propagation-loss-model.h" +#include "spectrum-value.h" + #include -#include -#include -#include -#include #include #include @@ -127,7 +128,7 @@ class MultiModelSpectrumChannel : public SpectrumChannel * This method checks if m_rxSpectrumModelInfoMap contains an entry * for the given TX SpectrumModel. If such entry exists, it returns * an iterator pointing to it. If not, it creates a new entry in - * m_txSpectrumMpodelInfoMap, and returns an iterator to it. + * m_txSpectrumModelInfoMap, and returns an iterator to it. * * \param txSpectrumModel The TX SpectrumModel being considered * diff --git a/src/spectrum/model/phased-array-spectrum-propagation-loss-model.cc b/src/spectrum/model/phased-array-spectrum-propagation-loss-model.cc index 328b0ab1e..cfb287487 100644 --- a/src/spectrum/model/phased-array-spectrum-propagation-loss-model.cc +++ b/src/spectrum/model/phased-array-spectrum-propagation-loss-model.cc @@ -18,7 +18,8 @@ #include "phased-array-spectrum-propagation-loss-model.h" -#include "ns3/spectrum-signal-parameters.h" +#include "spectrum-signal-parameters.h" + #include #include diff --git a/src/spectrum/model/phased-array-spectrum-propagation-loss-model.h b/src/spectrum/model/phased-array-spectrum-propagation-loss-model.h index 453bef2aa..a2a2c8af3 100644 --- a/src/spectrum/model/phased-array-spectrum-propagation-loss-model.h +++ b/src/spectrum/model/phased-array-spectrum-propagation-loss-model.h @@ -19,10 +19,11 @@ #ifndef PHASED_ARRAY_SPECTRUM_PROPAGATION_LOSS_MODEL_H #define PHASED_ARRAY_SPECTRUM_PROPAGATION_LOSS_MODEL_H +#include "spectrum-value.h" + #include #include #include -#include namespace ns3 { diff --git a/src/spectrum/model/single-model-spectrum-channel.cc b/src/spectrum/model/single-model-spectrum-channel.cc index 392855439..e4c93dafc 100644 --- a/src/spectrum/model/single-model-spectrum-channel.cc +++ b/src/spectrum/model/single-model-spectrum-channel.cc @@ -19,6 +19,10 @@ #include "single-model-spectrum-channel.h" +#include "spectrum-phy.h" +#include "spectrum-propagation-loss-model.h" +#include "spectrum-transmit-filter.h" + #include #include #include @@ -32,9 +36,6 @@ #include #include #include -#include -#include -#include #include @@ -118,9 +119,7 @@ SingleModelSpectrumChannel::StartTx(Ptr txParams) Ptr senderMobility = txParams->txPhy->GetMobility(); - for (PhyList::const_iterator rxPhyIterator = m_phyList.begin(); - rxPhyIterator != m_phyList.end(); - ++rxPhyIterator) + for (auto rxPhyIterator = m_phyList.begin(); rxPhyIterator != m_phyList.end(); ++rxPhyIterator) { Ptr rxNetDevice = (*rxPhyIterator)->GetDevice(); Ptr txNetDevice = txParams->txPhy->GetDevice(); diff --git a/src/spectrum/model/single-model-spectrum-channel.h b/src/spectrum/model/single-model-spectrum-channel.h index a3542a4c0..a772e9d62 100644 --- a/src/spectrum/model/single-model-spectrum-channel.h +++ b/src/spectrum/model/single-model-spectrum-channel.h @@ -20,8 +20,9 @@ #ifndef SINGLE_MODEL_SPECTRUM_CHANNEL_H #define SINGLE_MODEL_SPECTRUM_CHANNEL_H -#include -#include +#include "spectrum-channel.h" +#include "spectrum-model.h" + #include namespace ns3 diff --git a/src/spectrum/model/spectrum-analyzer.h b/src/spectrum/model/spectrum-analyzer.h index 3284c485d..3d889cb13 100644 --- a/src/spectrum/model/spectrum-analyzer.h +++ b/src/spectrum/model/spectrum-analyzer.h @@ -20,13 +20,14 @@ #ifndef SPECTRUM_ANALYZER_H #define SPECTRUM_ANALYZER_H +#include "spectrum-channel.h" +#include "spectrum-phy.h" +#include "spectrum-value.h" + #include #include #include #include -#include -#include -#include #include #include diff --git a/src/spectrum/model/spectrum-channel.h b/src/spectrum/model/spectrum-channel.h index f4708fbd3..311ef1cb5 100644 --- a/src/spectrum/model/spectrum-channel.h +++ b/src/spectrum/model/spectrum-channel.h @@ -20,17 +20,18 @@ #ifndef SPECTRUM_CHANNEL_H #define SPECTRUM_CHANNEL_H +#include "phased-array-spectrum-propagation-loss-model.h" +#include "spectrum-phy.h" +#include "spectrum-propagation-loss-model.h" +#include "spectrum-signal-parameters.h" +#include "spectrum-transmit-filter.h" + #include #include #include #include -#include #include #include -#include -#include -#include -#include #include namespace ns3 diff --git a/src/spectrum/model/spectrum-converter.cc b/src/spectrum/model/spectrum-converter.cc index 357e1a39e..cd737e855 100644 --- a/src/spectrum/model/spectrum-converter.cc +++ b/src/spectrum/model/spectrum-converter.cc @@ -17,9 +17,10 @@ * Author: Nicola Baldo */ +#include "spectrum-converter.h" + #include #include -#include #include @@ -40,13 +41,10 @@ SpectrumConverter::SpectrumConverter(Ptr fromSpectrumModel, m_toSpectrumModel = toSpectrumModel; size_t rowPtr = 0; - for (Bands::const_iterator toit = toSpectrumModel->Begin(); toit != toSpectrumModel->End(); - ++toit) + for (auto toit = toSpectrumModel->Begin(); toit != toSpectrumModel->End(); ++toit) { size_t colInd = 0; - for (Bands::const_iterator fromit = fromSpectrumModel->Begin(); - fromit != fromSpectrumModel->End(); - ++fromit) + for (auto fromit = fromSpectrumModel->Begin(); fromit != fromSpectrumModel->End(); ++fromit) { double c = GetCoefficient(*fromit, *toit); NS_LOG_LOGIC("(" << fromit->fl << "," << fromit->fh << ")" @@ -82,12 +80,10 @@ SpectrumConverter::Convert(Ptr fvvf) const Ptr tvvf = Create(m_toSpectrumModel); - Values::iterator tvit = tvvf->ValuesBegin(); + auto tvit = tvvf->ValuesBegin(); size_t i = 0; // Index of conversion coefficient - for (std::vector::const_iterator convIt = m_conversionRowPtr.begin(); - convIt != m_conversionRowPtr.end(); - ++convIt) + for (auto convIt = m_conversionRowPtr.begin(); convIt != m_conversionRowPtr.end(); ++convIt) { double sum = 0; while (i < *convIt) diff --git a/src/spectrum/model/spectrum-converter.h b/src/spectrum/model/spectrum-converter.h index d271fe718..5c2aea006 100644 --- a/src/spectrum/model/spectrum-converter.h +++ b/src/spectrum/model/spectrum-converter.h @@ -20,7 +20,7 @@ #ifndef SPECTRUM_CONVERTER_H #define SPECTRUM_CONVERTER_H -#include +#include "spectrum-value.h" namespace ns3 { diff --git a/src/spectrum/model/spectrum-error-model.cc b/src/spectrum/model/spectrum-error-model.cc index 3cd7db2be..8bad21200 100644 --- a/src/spectrum/model/spectrum-error-model.cc +++ b/src/spectrum/model/spectrum-error-model.cc @@ -79,8 +79,8 @@ ShannonSpectrumErrorModel::EvaluateChunk(const SpectrumValue& sinr, Time duratio SpectrumValue CapacityPerHertz = Log2(1 + sinr); double capacity = 0; - Bands::const_iterator bi = CapacityPerHertz.ConstBandsBegin(); - Values::const_iterator vi = CapacityPerHertz.ConstValuesBegin(); + auto bi = CapacityPerHertz.ConstBandsBegin(); + auto vi = CapacityPerHertz.ConstValuesBegin(); while (bi != CapacityPerHertz.ConstBandsEnd()) { diff --git a/src/spectrum/model/spectrum-error-model.h b/src/spectrum/model/spectrum-error-model.h index 958315f41..9c41f92cb 100644 --- a/src/spectrum/model/spectrum-error-model.h +++ b/src/spectrum/model/spectrum-error-model.h @@ -20,11 +20,12 @@ #ifndef SPECTRUM_ERROR_MODEL_H #define SPECTRUM_ERROR_MODEL_H +#include "spectrum-value.h" + #include #include #include #include -#include namespace ns3 { diff --git a/src/spectrum/model/spectrum-interference.h b/src/spectrum/model/spectrum-interference.h index f2b5043e3..b0add667d 100644 --- a/src/spectrum/model/spectrum-interference.h +++ b/src/spectrum/model/spectrum-interference.h @@ -20,10 +20,11 @@ #ifndef SPECTRUM_INTERFERENCE_H #define SPECTRUM_INTERFERENCE_H +#include "spectrum-value.h" + #include #include #include -#include namespace ns3 { diff --git a/src/spectrum/model/spectrum-model-300kHz-300GHz-log.cc b/src/spectrum/model/spectrum-model-300kHz-300GHz-log.cc index 0be3e661b..d2e3cd5e5 100644 --- a/src/spectrum/model/spectrum-model-300kHz-300GHz-log.cc +++ b/src/spectrum/model/spectrum-model-300kHz-300GHz-log.cc @@ -17,7 +17,7 @@ * Author: Nicola Baldo */ -#include +#include "spectrum-model-300kHz-300GHz-log.h" namespace ns3 { diff --git a/src/spectrum/model/spectrum-model-300kHz-300GHz-log.h b/src/spectrum/model/spectrum-model-300kHz-300GHz-log.h index 5810253ef..0a8cba46a 100644 --- a/src/spectrum/model/spectrum-model-300kHz-300GHz-log.h +++ b/src/spectrum/model/spectrum-model-300kHz-300GHz-log.h @@ -20,7 +20,7 @@ #ifndef FREQS_300KHZ_300GHZ_LOG_H #define FREQS_300KHZ_300GHZ_LOG_H -#include +#include "spectrum-value.h" namespace ns3 { diff --git a/src/spectrum/model/spectrum-model-ism2400MHz-res1MHz.cc b/src/spectrum/model/spectrum-model-ism2400MHz-res1MHz.cc index fb374e66f..b72188903 100644 --- a/src/spectrum/model/spectrum-model-ism2400MHz-res1MHz.cc +++ b/src/spectrum/model/spectrum-model-ism2400MHz-res1MHz.cc @@ -17,7 +17,7 @@ * Author: Nicola Baldo */ -#include +#include "spectrum-model-ism2400MHz-res1MHz.h" namespace ns3 { diff --git a/src/spectrum/model/spectrum-model-ism2400MHz-res1MHz.h b/src/spectrum/model/spectrum-model-ism2400MHz-res1MHz.h index 6cd9371a2..cfbc60c4d 100644 --- a/src/spectrum/model/spectrum-model-ism2400MHz-res1MHz.h +++ b/src/spectrum/model/spectrum-model-ism2400MHz-res1MHz.h @@ -20,7 +20,7 @@ #ifndef FREQS_ISM2400MHZ_RES1MHZ_H #define FREQS_ISM2400MHZ_RES1MHZ_H -#include +#include "spectrum-value.h" namespace ns3 { diff --git a/src/spectrum/model/spectrum-model.cc b/src/spectrum/model/spectrum-model.cc index 3fecc1c0d..caf688852 100644 --- a/src/spectrum/model/spectrum-model.cc +++ b/src/spectrum/model/spectrum-model.cc @@ -18,9 +18,10 @@ * Author: Nicola Baldo */ +#include "spectrum-model.h" + #include #include -#include #include #include @@ -43,8 +44,7 @@ SpectrumModel::SpectrumModel(const std::vector& centerFreqs) NS_ASSERT(centerFreqs.size() > 1); m_uid = ++m_uidCount; - for (std::vector::const_iterator it = centerFreqs.begin(); it != centerFreqs.end(); - ++it) + for (auto it = centerFreqs.begin(); it != centerFreqs.end(); ++it) { BandInfo e; e.fc = *it; @@ -110,9 +110,9 @@ SpectrumModel::GetUid() const bool SpectrumModel::IsOrthogonal(const SpectrumModel& other) const { - for (Bands::const_iterator myIt = Begin(); myIt != End(); ++myIt) + for (auto myIt = Begin(); myIt != End(); ++myIt) { - for (Bands::const_iterator otherIt = other.Begin(); otherIt != other.End(); ++otherIt) + for (auto otherIt = other.Begin(); otherIt != other.End(); ++otherIt) { if (std::max(myIt->fl, otherIt->fl) < std::min(myIt->fh, otherIt->fh)) { diff --git a/src/spectrum/model/spectrum-phy.cc b/src/spectrum/model/spectrum-phy.cc index da50632b2..36f4e1f7a 100644 --- a/src/spectrum/model/spectrum-phy.cc +++ b/src/spectrum/model/spectrum-phy.cc @@ -19,11 +19,12 @@ #include "spectrum-phy.h" +#include "spectrum-channel.h" +#include "spectrum-value.h" + #include #include #include -#include -#include namespace ns3 { diff --git a/src/spectrum/model/spectrum-propagation-loss-model.h b/src/spectrum/model/spectrum-propagation-loss-model.h index fd8c7c81b..47f7594b3 100644 --- a/src/spectrum/model/spectrum-propagation-loss-model.h +++ b/src/spectrum/model/spectrum-propagation-loss-model.h @@ -20,9 +20,10 @@ #ifndef SPECTRUM_PROPAGATION_LOSS_MODEL_H #define SPECTRUM_PROPAGATION_LOSS_MODEL_H +#include "spectrum-value.h" + #include #include -#include namespace ns3 { diff --git a/src/spectrum/model/spectrum-signal-parameters.cc b/src/spectrum/model/spectrum-signal-parameters.cc index db053e141..460b3e07a 100644 --- a/src/spectrum/model/spectrum-signal-parameters.cc +++ b/src/spectrum/model/spectrum-signal-parameters.cc @@ -17,11 +17,13 @@ * Author: Nicola Baldo */ +#include "spectrum-signal-parameters.h" + +#include "spectrum-phy.h" +#include "spectrum-value.h" + #include #include -#include -#include -#include namespace ns3 { diff --git a/src/spectrum/model/spectrum-value.cc b/src/spectrum/model/spectrum-value.cc index d53d333b3..47134bfe9 100644 --- a/src/spectrum/model/spectrum-value.cc +++ b/src/spectrum/model/spectrum-value.cc @@ -18,9 +18,10 @@ * Author: Nicola Baldo */ +#include "spectrum-value.h" + #include #include -#include namespace ns3 { @@ -100,8 +101,8 @@ SpectrumValue::ConstBandsEnd() const void SpectrumValue::Add(const SpectrumValue& x) { - Values::iterator it1 = m_values.begin(); - Values::const_iterator it2 = x.m_values.begin(); + auto it1 = m_values.begin(); + auto it2 = x.m_values.begin(); NS_ASSERT(m_spectrumModel == x.m_spectrumModel); NS_ASSERT(m_values.size() == x.m_values.size()); @@ -117,7 +118,7 @@ SpectrumValue::Add(const SpectrumValue& x) void SpectrumValue::Add(double s) { - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -129,8 +130,8 @@ SpectrumValue::Add(double s) void SpectrumValue::Subtract(const SpectrumValue& x) { - Values::iterator it1 = m_values.begin(); - Values::const_iterator it2 = x.m_values.begin(); + auto it1 = m_values.begin(); + auto it2 = x.m_values.begin(); NS_ASSERT(m_spectrumModel == x.m_spectrumModel); NS_ASSERT(m_values.size() == x.m_values.size()); @@ -152,8 +153,8 @@ SpectrumValue::Subtract(double s) void SpectrumValue::Multiply(const SpectrumValue& x) { - Values::iterator it1 = m_values.begin(); - Values::const_iterator it2 = x.m_values.begin(); + auto it1 = m_values.begin(); + auto it2 = x.m_values.begin(); NS_ASSERT(m_spectrumModel == x.m_spectrumModel); NS_ASSERT(m_values.size() == x.m_values.size()); @@ -169,7 +170,7 @@ SpectrumValue::Multiply(const SpectrumValue& x) void SpectrumValue::Multiply(double s) { - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -181,8 +182,8 @@ SpectrumValue::Multiply(double s) void SpectrumValue::Divide(const SpectrumValue& x) { - Values::iterator it1 = m_values.begin(); - Values::const_iterator it2 = x.m_values.begin(); + auto it1 = m_values.begin(); + auto it2 = x.m_values.begin(); NS_ASSERT(m_spectrumModel == x.m_spectrumModel); NS_ASSERT(m_values.size() == x.m_values.size()); @@ -199,7 +200,7 @@ void SpectrumValue::Divide(double s) { NS_LOG_FUNCTION(this << s); - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -211,7 +212,7 @@ SpectrumValue::Divide(double s) void SpectrumValue::ChangeSign() { - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -256,7 +257,7 @@ void SpectrumValue::Pow(double exp) { NS_LOG_FUNCTION(this << exp); - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -269,7 +270,7 @@ void SpectrumValue::Exp(double base) { NS_LOG_FUNCTION(this << base); - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -282,7 +283,7 @@ void SpectrumValue::Log10() { NS_LOG_FUNCTION(this); - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -295,7 +296,7 @@ void SpectrumValue::Log2() { NS_LOG_FUNCTION(this); - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -308,7 +309,7 @@ void SpectrumValue::Log() { NS_LOG_FUNCTION(this); - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -321,7 +322,7 @@ double Norm(const SpectrumValue& x) { double s = 0; - Values::const_iterator it1 = x.ConstValuesBegin(); + auto it1 = x.ConstValuesBegin(); while (it1 != x.ConstValuesEnd()) { s += (*it1) * (*it1); @@ -334,7 +335,7 @@ double Sum(const SpectrumValue& x) { double s = 0; - Values::const_iterator it1 = x.ConstValuesBegin(); + auto it1 = x.ConstValuesBegin(); while (it1 != x.ConstValuesEnd()) { s += (*it1); @@ -347,7 +348,7 @@ double Prod(const SpectrumValue& x) { double s = 0; - Values::const_iterator it1 = x.ConstValuesBegin(); + auto it1 = x.ConstValuesBegin(); while (it1 != x.ConstValuesEnd()) { s *= (*it1); @@ -360,8 +361,8 @@ double Integral(const SpectrumValue& arg) { double i = 0; - Values::const_iterator vit = arg.ConstValuesBegin(); - Bands::const_iterator bit = arg.ConstBandsBegin(); + auto vit = arg.ConstValuesBegin(); + auto bit = arg.ConstBandsBegin(); while (vit != arg.ConstValuesEnd()) { NS_ASSERT(bit != arg.ConstBandsEnd()); @@ -392,7 +393,7 @@ SpectrumValue::Copy() const std::ostream& operator<<(std::ostream& os, const SpectrumValue& pvf) { - Values::const_iterator it1 = pvf.ConstValuesBegin(); + auto it1 = pvf.ConstValuesBegin(); while (it1 != pvf.ConstValuesEnd()) { os << *it1 << " "; @@ -612,7 +613,7 @@ SpectrumValue::operator/=(double rhs) SpectrumValue& SpectrumValue::operator=(double rhs) { - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { diff --git a/src/spectrum/model/spectrum-value.h b/src/spectrum/model/spectrum-value.h index c814d383a..9dc741ab2 100644 --- a/src/spectrum/model/spectrum-value.h +++ b/src/spectrum/model/spectrum-value.h @@ -20,9 +20,10 @@ #ifndef SPECTRUM_VALUE_H #define SPECTRUM_VALUE_H +#include "spectrum-model.h" + #include #include -#include #include #include diff --git a/src/spectrum/model/three-gpp-channel-model.cc b/src/spectrum/model/three-gpp-channel-model.cc index 9c84934a5..0daebe682 100644 --- a/src/spectrum/model/three-gpp-channel-model.cc +++ b/src/spectrum/model/three-gpp-channel-model.cc @@ -2197,12 +2197,11 @@ ThreeGppChannelModel::CalcAttenuationOfBlockage( { NS_LOG_FUNCTION(this); - DoubleVector powerAttenuation; - uint8_t clusterNum = clusterAOA.size(); - for (uint8_t cInd = 0; cInd < clusterNum; cInd++) - { - powerAttenuation.push_back(0); // Initial power attenuation for all clusters to be 0 dB; - } + auto clusterNum = clusterAOA.size(); + + // Initial power attenuation for all clusters to be 0 dB + DoubleVector powerAttenuation(clusterNum, 0); + // step a: the number of non-self blocking blockers is stored in m_numNonSelfBlocking. // step b:Generate the size and location of each blocker @@ -2315,7 +2314,7 @@ ThreeGppChannelModel::CalcAttenuationOfBlockage( } // step c: Determine the attenuation of each blocker due to blockers - for (uint8_t cInd = 0; cInd < clusterNum; cInd++) + for (std::size_t cInd = 0; cInd < clusterNum; cInd++) { NS_ASSERT_MSG(clusterAOA[cInd] >= 0 && clusterAOA[cInd] <= 360, "the AOA should be the range of [0,360]"); diff --git a/src/spectrum/model/three-gpp-channel-model.h b/src/spectrum/model/three-gpp-channel-model.h index 49ddc3bad..fec908e59 100644 --- a/src/spectrum/model/three-gpp-channel-model.h +++ b/src/spectrum/model/three-gpp-channel-model.h @@ -21,10 +21,11 @@ #ifndef THREE_GPP_CHANNEL_H #define THREE_GPP_CHANNEL_H +#include "matrix-based-channel-model.h" + #include "ns3/angles.h" #include #include -#include #include #include diff --git a/src/spectrum/model/three-gpp-spectrum-propagation-loss-model.h b/src/spectrum/model/three-gpp-spectrum-propagation-loss-model.h index 6dd259a76..2fb056680 100644 --- a/src/spectrum/model/three-gpp-spectrum-propagation-loss-model.h +++ b/src/spectrum/model/three-gpp-spectrum-propagation-loss-model.h @@ -21,8 +21,9 @@ #ifndef THREE_GPP_SPECTRUM_PROPAGATION_LOSS_H #define THREE_GPP_SPECTRUM_PROPAGATION_LOSS_H -#include "ns3/matrix-based-channel-model.h" -#include "ns3/phased-array-spectrum-propagation-loss-model.h" +#include "matrix-based-channel-model.h" +#include "phased-array-spectrum-propagation-loss-model.h" + #include "ns3/random-variable-stream.h" #include diff --git a/src/spectrum/model/trace-fading-loss-model.cc b/src/spectrum/model/trace-fading-loss-model.cc index d15d751e9..e0e284501 100644 --- a/src/spectrum/model/trace-fading-loss-model.cc +++ b/src/spectrum/model/trace-fading-loss-model.cc @@ -18,16 +18,17 @@ * Marco Miozzo */ +#include "trace-fading-loss-model.h" + #include "spectrum-signal-parameters.h" +#include "spectrum-value.h" #include "ns3/uinteger.h" #include #include #include #include -#include #include -#include #include @@ -152,9 +153,8 @@ TraceFadingLossModel::DoCalcRxPowerSpectralDensity(Ptrpsd << a << b); - std::map::iterator itOff; ChannelRealizationId_t mobilityPair = std::make_pair(a, b); - itOff = m_windowOffsetsMap.find(mobilityPair); + auto itOff = m_windowOffsetsMap.find(mobilityPair); if (itOff != m_windowOffsetsMap.end()) { if (Simulator::Now().GetSeconds() >= @@ -162,11 +162,10 @@ TraceFadingLossModel::DoCalcRxPowerSpectralDensity(Ptr::iterator itOff2; - for (itOff2 = m_windowOffsetsMap.begin(); itOff2 != m_windowOffsetsMap.end(); itOff2++) + for (auto itOff2 = m_windowOffsetsMap.begin(); itOff2 != m_windowOffsetsMap.end(); + itOff2++) { - std::map>::iterator itVar; - itVar = m_startVariableMap.find((*itOff2).first); + auto itVar = m_startVariableMap.find((*itOff2).first); (*itOff2).second = (*itVar).second->GetValue(); } m_lastWindowUpdate = Simulator::Now(); @@ -198,7 +197,7 @@ TraceFadingLossModel::DoCalcRxPowerSpectralDensity(Ptr rxPsd = Copy(params->psd); - Values::iterator vit = rxPsd->ValuesBegin(); + auto vit = rxPsd->ValuesBegin(); // Vector aSpeedVector = a->GetVelocity (); // Vector bSpeedVector = b->GetVelocity (); @@ -246,8 +245,7 @@ TraceFadingLossModel::AssignStreams(int64_t stream) m_streamsAssigned = true; m_currentStream = stream; m_lastStream = stream + m_streamSetSize - 1; - std::map>::iterator itVar; - itVar = m_startVariableMap.begin(); + auto itVar = m_startVariableMap.begin(); // the following loop is for eventually pre-existing ChannelRealization instances // note that more instances are expected to be created at run time while (itVar != m_startVariableMap.end()) diff --git a/src/spectrum/model/trace-fading-loss-model.h b/src/spectrum/model/trace-fading-loss-model.h index a53b40394..f8d647e2e 100644 --- a/src/spectrum/model/trace-fading-loss-model.h +++ b/src/spectrum/model/trace-fading-loss-model.h @@ -21,10 +21,11 @@ #ifndef TRACE_FADING_LOSS_MODEL_H #define TRACE_FADING_LOSS_MODEL_H +#include "spectrum-propagation-loss-model.h" + #include "ns3/random-variable-stream.h" #include #include -#include #include diff --git a/src/spectrum/model/tv-spectrum-transmitter.cc b/src/spectrum/model/tv-spectrum-transmitter.cc index 9802ac8f9..53ab65cde 100644 --- a/src/spectrum/model/tv-spectrum-transmitter.cc +++ b/src/spectrum/model/tv-spectrum-transmitter.cc @@ -246,7 +246,7 @@ TvSpectrumTransmitter::CreateTvPsd() NS_ASSERT(m_channelBandwidth != 0); Ptr model; TvSpectrumModelId key(m_startFrequency, m_channelBandwidth); - std::map>::iterator iter = g_tvSpectrumModelMap.find(key); + auto iter = g_tvSpectrumModelMap.find(key); if (iter != g_tvSpectrumModelMap.end()) { model = iter->second; // set SpectrumModel to previously created one diff --git a/src/spectrum/model/tv-spectrum-transmitter.h b/src/spectrum/model/tv-spectrum-transmitter.h index af00c6220..353795724 100644 --- a/src/spectrum/model/tv-spectrum-transmitter.h +++ b/src/spectrum/model/tv-spectrum-transmitter.h @@ -20,13 +20,14 @@ #ifndef TV_SPECTRUM_TRANSMITTER_H #define TV_SPECTRUM_TRANSMITTER_H +#include "spectrum-channel.h" +#include "spectrum-phy.h" +#include "spectrum-signal-parameters.h" +#include "spectrum-value.h" + #include #include #include -#include -#include -#include -#include namespace ns3 { diff --git a/src/spectrum/model/two-ray-spectrum-propagation-loss-model.h b/src/spectrum/model/two-ray-spectrum-propagation-loss-model.h index 38dd8baa6..b5ffeac81 100644 --- a/src/spectrum/model/two-ray-spectrum-propagation-loss-model.h +++ b/src/spectrum/model/two-ray-spectrum-propagation-loss-model.h @@ -19,9 +19,10 @@ #ifndef TWO_RAY_SPECTRUM_PROPAGATION_LOSS_H #define TWO_RAY_SPECTRUM_PROPAGATION_LOSS_H +#include "phased-array-spectrum-propagation-loss-model.h" +#include "spectrum-signal-parameters.h" + #include "ns3/channel-condition-model.h" -#include "ns3/phased-array-spectrum-propagation-loss-model.h" -#include "ns3/spectrum-signal-parameters.h" #include diff --git a/src/spectrum/model/waveform-generator.h b/src/spectrum/model/waveform-generator.h index 4eef4a7a0..4dbda66e5 100644 --- a/src/spectrum/model/waveform-generator.h +++ b/src/spectrum/model/waveform-generator.h @@ -20,14 +20,15 @@ #ifndef WAVEFORM_GENERATOR_H #define WAVEFORM_GENERATOR_H +#include "spectrum-channel.h" +#include "spectrum-phy.h" +#include "spectrum-value.h" + #include #include #include #include #include -#include -#include -#include #include namespace ns3 diff --git a/src/spectrum/model/wifi-spectrum-value-helper.cc b/src/spectrum/model/wifi-spectrum-value-helper.cc index 7ba35919e..5fb9244ac 100644 --- a/src/spectrum/model/wifi-spectrum-value-helper.cc +++ b/src/spectrum/model/wifi-spectrum-value-helper.cc @@ -77,8 +77,7 @@ WifiSpectrumValueHelper::GetSpectrumModel(uint32_t centerFrequency, NS_LOG_FUNCTION(centerFrequency << channelWidth << carrierSpacing << guardBandwidth); Ptr ret; WifiSpectrumModelId key{centerFrequency, channelWidth, carrierSpacing, guardBandwidth}; - std::map>::iterator it = - g_wifiSpectrumModelMap.find(key); + auto it = g_wifiSpectrumModelMap.find(key); if (it != g_wifiSpectrumModelMap.end()) { ret = it->second; @@ -89,7 +88,7 @@ WifiSpectrumValueHelper::GetSpectrumModel(uint32_t centerFrequency, double centerFrequencyHz = centerFrequency * 1e6; double bandwidth = (channelWidth + (2.0 * guardBandwidth)) * 1e6; // For OFDM, the center subcarrier is null (at center frequency) - uint32_t numBands = static_cast((bandwidth / carrierSpacing) + 0.5); + auto numBands = static_cast((bandwidth / carrierSpacing) + 0.5); NS_ASSERT(numBands > 0); if (numBands % 2 == 0) { @@ -134,11 +133,10 @@ WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity(uint32_t centerFrequen uint32_t carrierSpacing = 312500; Ptr c = Create( GetSpectrumModel(centerFrequency, channelWidth, carrierSpacing, guardBandwidth)); - Values::iterator vit = c->ValuesBegin(); - Bands::const_iterator bit = c->ConstBandsBegin(); - uint32_t nGuardBands = - static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); - uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); + auto vit = c->ValuesBegin(); + auto bit = c->ConstBandsBegin(); + auto nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); + auto nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); NS_ASSERT(c->GetSpectrumModel()->GetNumBands() == (nAllocatedBands + nGuardBands + 1)); // Evenly spread power across 22 MHz double txPowerPerBand = txPowerW / nAllocatedBands; @@ -188,9 +186,8 @@ WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity(uint32_t centerFrequen Ptr c = Create( GetSpectrumModel(centerFrequency, channelWidth, carrierSpacing, guardBandwidth)); - uint32_t nGuardBands = - static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); - uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); + auto nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); + auto nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); NS_ASSERT_MSG(c->GetSpectrumModel()->GetNumBands() == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel()->GetNumBands()); // 52 subcarriers (48 data + 4 pilot) @@ -240,9 +237,8 @@ WifiSpectrumValueHelper::CreateDuplicated20MhzTxPowerSpectralDensity( uint32_t carrierSpacing = 312500; Ptr c = Create( GetSpectrumModel(centerFrequency, channelWidth, carrierSpacing, guardBandwidth)); - uint32_t nGuardBands = - static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); - uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); + auto nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); + auto nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); NS_ASSERT_MSG(c->GetSpectrumModel()->GetNumBands() == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel()->GetNumBands()); std::size_t num20MhzBands = channelWidth / 20; @@ -281,7 +277,7 @@ WifiSpectrumValueHelper::CreateDuplicated20MhzTxPowerSpectralDensity( } // Prepare spectrum mask specific variables - uint32_t innerSlopeWidth = static_cast( + auto innerSlopeWidth = static_cast( (2e6 / carrierSpacing) + 0.5); // size in number of subcarriers of the 0dBr<->20dBr slope (2MHz for HT/VHT) WifiSpectrumBandIndices maskBand(0, nAllocatedBands + nGuardBands); @@ -315,9 +311,8 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity(uint32_t centerFrequ uint32_t carrierSpacing = 312500; Ptr c = Create( GetSpectrumModel(centerFrequency, channelWidth, carrierSpacing, guardBandwidth)); - uint32_t nGuardBands = - static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); - uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); + auto nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); + auto nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); NS_ASSERT_MSG(c->GetSpectrumModel()->GetNumBands() == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel()->GetNumBands()); std::size_t num20MhzBands = channelWidth / 20; @@ -347,7 +342,7 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity(uint32_t centerFrequ } // Prepare spectrum mask specific variables - uint32_t innerSlopeWidth = static_cast( + auto innerSlopeWidth = static_cast( (2e6 / carrierSpacing) + 0.5); // size in number of subcarriers of the inner band (2MHz for HT/VHT) WifiSpectrumBandIndices maskBand(0, nAllocatedBands + nGuardBands); @@ -383,9 +378,8 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity( uint32_t carrierSpacing = 78125; Ptr c = Create( GetSpectrumModel(centerFrequency, channelWidth, carrierSpacing, guardBandwidth)); - uint32_t nGuardBands = - static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); - uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); + auto nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); + auto nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); NS_ASSERT_MSG(c->GetSpectrumModel()->GetNumBands() == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel()->GetNumBands()); double txPowerPerBandW = 0.0; @@ -398,7 +392,7 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity( uint32_t start4; uint32_t stop4; // Prepare spectrum mask specific variables - uint32_t innerSlopeWidth = static_cast( + auto innerSlopeWidth = static_cast( (1e6 / carrierSpacing) + 0.5); // size in number of subcarriers of the inner band std::vector subBands; // list of data/pilot-containing subBands (sent at 0dBr) @@ -468,7 +462,7 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity( } // Create punctured bands - uint32_t puncturedSlopeWidth = + auto puncturedSlopeWidth = static_cast((500e3 / carrierSpacing) + 0.5); // size in number of subcarriers of the punctured slope band std::vector puncturedBands; @@ -516,8 +510,8 @@ WifiSpectrumValueHelper::CreateHeMuOfdmTxPowerSpectralDensity(uint32_t centerFre GetSpectrumModel(centerFrequency, channelWidth, carrierSpacing, guardBandwidth)); // Build spectrum mask - Values::iterator vit = c->ValuesBegin(); - Bands::const_iterator bit = c->ConstBandsBegin(); + auto vit = c->ValuesBegin(); + auto bit = c->ConstBandsBegin(); double txPowerPerBandW = (txPowerW / (ru.second - ru.first + 1)); // FIXME: null subcarriers uint32_t numBands = c->GetSpectrumModel()->GetNumBands(); for (size_t i = 0; i < numBands; i++, vit++, bit++) @@ -655,8 +649,8 @@ WifiSpectrumValueHelper::CreateSpectrumMaskForOfdm( double puncturedSlope = (-1 * minInnerBandDbr) / puncturedSlopeWidth; // Build spectrum mask - Values::iterator vit = c->ValuesBegin(); - Bands::const_iterator bit = c->ConstBandsBegin(); + auto vit = c->ValuesBegin(); + auto bit = c->ConstBandsBegin(); double txPowerW = 0.0; double previousTxPowerW = 0.0; for (size_t i = 0; i < numBands; i++, vit++, bit++) @@ -780,7 +774,7 @@ WifiSpectrumValueHelper::NormalizeSpectrumMask(Ptr c, double txPo double normalizationRatio = currentTxPowerW / txPowerW; NS_LOG_LOGIC("Current power: " << currentTxPowerW << "W vs expected power: " << txPowerW << "W" << " -> ratio (C/E) = " << normalizationRatio); - Values::iterator vit = c->ValuesBegin(); + auto vit = c->ValuesBegin(); for (size_t i = 0; i < c->GetSpectrumModel()->GetNumBands(); i++, vit++) { *vit = (*vit) / normalizationRatio; diff --git a/src/spectrum/model/wifi-spectrum-value-helper.h b/src/spectrum/model/wifi-spectrum-value-helper.h index 341ebe890..c991af1e3 100644 --- a/src/spectrum/model/wifi-spectrum-value-helper.h +++ b/src/spectrum/model/wifi-spectrum-value-helper.h @@ -22,7 +22,7 @@ #ifndef WIFI_SPECTRUM_VALUE_HELPER_H #define WIFI_SPECTRUM_VALUE_HELPER_H -#include +#include "spectrum-value.h" namespace ns3 { diff --git a/src/spectrum/test/spectrum-interference-test.cc b/src/spectrum/test/spectrum-interference-test.cc index 6143a1d29..a151d18cb 100644 --- a/src/spectrum/test/spectrum-interference-test.cc +++ b/src/spectrum/test/spectrum-interference-test.cc @@ -44,7 +44,7 @@ class SpectrumInterferenceTestCase : public TestCase * Constructor * \param s Spectrum value * \param txBytes number of bytes to transmit - * \param rxCorrect extected Rx bytes + * \param rxCorrect expected Rx bytes * \param name test name */ SpectrumInterferenceTestCase(Ptr s, @@ -62,7 +62,7 @@ class SpectrumInterferenceTestCase : public TestCase private: Ptr m_s; //!< Spectrum value uint32_t m_txBytes; //!< number of bytes to transmit - uint32_t m_rxCorrectKnownOutcome; //!< expected Rx bytes + bool m_rxCorrectKnownOutcome; //!< expected Rx bytes Ptr m_mySpectrumModel; //!< Spectrum model pointer }; diff --git a/src/spectrum/test/spectrum-test.h b/src/spectrum/test/spectrum-test.h index 2552c2d33..0ea9120ef 100644 --- a/src/spectrum/test/spectrum-test.h +++ b/src/spectrum/test/spectrum-test.h @@ -48,8 +48,8 @@ #define NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL(actual, expected, tol, msg) \ do \ { \ - Bands::const_iterator i = (actual).Begin(); \ - Bands::const_iterator j = (expected).Begin(); \ + auto i = (actual).Begin(); \ + auto j = (expected).Begin(); \ uint32_t k = 0; \ while (i != (actual).End() && j != (expected).End()) \ { \ @@ -113,8 +113,8 @@ #define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg) \ do \ { \ - Values::const_iterator i = (actual).ConstValuesBegin(); \ - Values::const_iterator j = (expected).ConstValuesBegin(); \ + auto i = (actual).ConstValuesBegin(); \ + auto j = (expected).ConstValuesBegin(); \ uint32_t k = 0; \ while (i != (actual).ConstValuesEnd() && j != (expected).ConstValuesEnd()) \ { \ diff --git a/src/spectrum/test/tv-spectrum-transmitter-test.cc b/src/spectrum/test/tv-spectrum-transmitter-test.cc index 3f5b5079f..ec6b553ff 100644 --- a/src/spectrum/test/tv-spectrum-transmitter-test.cc +++ b/src/spectrum/test/tv-spectrum-transmitter-test.cc @@ -124,7 +124,7 @@ TvSpectrumTransmitterTestCase::DoRun() /* Test max PSD value */ Ptr psd = phy->GetTxPsd(); - Values::const_iterator psdIter = psd->ConstValuesBegin(); + auto psdIter = psd->ConstValuesBegin(); double maxValue = 0; while (psdIter != psd->ConstValuesEnd()) { @@ -154,8 +154,8 @@ TvSpectrumTransmitterTestCase::DoRun() } /* Test frequency range */ - Bands::const_iterator bandStart = psd->ConstBandsBegin(); - Bands::const_iterator bandEnd = psd->ConstBandsEnd(); + auto bandStart = psd->ConstBandsBegin(); + auto bandEnd = psd->ConstBandsEnd(); epsilon = TOLERANCE * std::max(1.0, std::max((*bandStart).fc, m_startFrequency)); NS_TEST_ASSERT_MSG_EQ_TOL((*bandStart).fc, m_startFrequency, diff --git a/src/spectrum/test/two-ray-splm-test-suite.cc b/src/spectrum/test/two-ray-splm-test-suite.cc index 66e903333..4ed3d37bc 100644 --- a/src/spectrum/test/two-ray-splm-test-suite.cc +++ b/src/spectrum/test/two-ray-splm-test-suite.cc @@ -153,8 +153,10 @@ FtrFadingModelAverageTest::DoRun() // Generate a set of values for the FTR model parameters for (uint8_t j = 0; j < NUM_VALUES; j++) { - sigma[j] = std::pow(2, j); - k[j] = std::pow(2, j); + double power = std::pow(2, j); + + sigma[j] = power; + k[j] = power; delta[j] = double(j) / NUM_VALUES; // Delta must be in [0, 1] } diff --git a/src/spectrum/utils/two-ray-to-three-gpp-ch-calibration.py b/src/spectrum/utils/two-ray-to-three-gpp-ch-calibration.py index a48f02c81..8e8556446 100644 --- a/src/spectrum/utils/two-ray-to-three-gpp-ch-calibration.py +++ b/src/spectrum/utils/two-ray-to-three-gpp-ch-calibration.py @@ -220,7 +220,7 @@ def compute_ftr_th_mean(params: FtrParams): def compute_anderson_darling_measure(ref_ecdf: list, target_ecdf: list) -> float: '''! Computes the Anderson-Darling measure for the specified reference and targets distributions. In particular, the Anderson-Darling measure is defined as: - A^2 = -N -S, where S = \sum_{i=1}^N \frac{2i - 1}{N} \left[ ln F(Y_i) + ln F(Y_{N + 1 - i}) \right]. + \f$A^2 = -N -S\f$, where \f$S = \sum_{i=1}^N \frac{2i - 1}{N} \left[ ln F(Y_i) + ln F(Y_{N + 1 - i}) \right]\f$. See https://www.itl.nist.gov/div898/handbook/eda/section3/eda35e.htm for further details. @@ -248,7 +248,7 @@ def compute_anderson_darling_measure(ref_ecdf: list, target_ecdf: list) -> float def compute_ecdf_value(ecdf: list, data_points: float) -> np.ndarray: '''! Given an ECDF and data points belonging to its domain, returns their associated EDCF value. @param ecdf: The ECDF, represented as a sorted list of samples. - @param data_point: A list of data points belonging to the same domain as the samples. + @param data_points: A list of data points belonging to the same domain as the samples. @returns The ECDF value of the domain points of the specified ECDF ''' @@ -438,9 +438,8 @@ def print_cplusplus_map_from_fit_results(fit: pd.DataFrame, out_fname: str): out_str = out_str[0:-2] out_str += '}\n' - f = open(out_fname, "w") - f.write(out_str) - f.close() + with open(out_fname, "w", encoding="utf-8") as f: + f.write(out_str) if __name__ == '__main__': @@ -499,12 +498,10 @@ if __name__ == '__main__': res = joblib.Parallel(n_jobs=10)( joblib.delayed(fit_ftr_to_reference)(df, params_comb, num_search_grid_params, num_refinements) for params_comb in product(scenarios, is_los, frequencies)) - f = open(fit_out_fname, "w") - f.write("scen\tcond\tfc\tsigma\tk\tdelta\tm\n") - for line in res: - f.write(line) - - f.close() + with open(fit_out_fname, "w", encoding="utf-8") as f: + f.write("scen\tcond\tfc\tsigma\tk\tdelta\tm\n") + for line in res: + f.write(line) if output_ns3_table: diff --git a/src/stats/helper/file-helper.cc b/src/stats/helper/file-helper.cc index 45ebbe2ff..c3e0405fb 100644 --- a/src/stats/helper/file-helper.cc +++ b/src/stats/helper/file-helper.cc @@ -288,8 +288,7 @@ FileHelper::GetProbe(std::string probeName) const NS_LOG_FUNCTION(this << probeName); // Look for the probe. - std::map, std::string>>::const_iterator mapIterator = - m_probeMap.find(probeName); + auto mapIterator = m_probeMap.find(probeName); // Return the probe if it has been added. if (mapIterator != m_probeMap.end()) diff --git a/src/stats/helper/gnuplot-helper.cc b/src/stats/helper/gnuplot-helper.cc index 9de14be21..476467a4c 100644 --- a/src/stats/helper/gnuplot-helper.cc +++ b/src/stats/helper/gnuplot-helper.cc @@ -257,8 +257,7 @@ Ptr GnuplotHelper::GetProbe(std::string probeName) const { // Look for the probe. - std::map, std::string>>::const_iterator mapIterator = - m_probeMap.find(probeName); + auto mapIterator = m_probeMap.find(probeName); // Return the probe if it has been added. if (mapIterator != m_probeMap.end()) diff --git a/src/stats/model/average.h b/src/stats/model/average.h index f145adf91..e62d80cf7 100644 --- a/src/stats/model/average.h +++ b/src/stats/model/average.h @@ -20,7 +20,8 @@ #ifndef AVERAGE_H #define AVERAGE_H -#include "ns3/basic-data-calculators.h" + +#include "basic-data-calculators.h" #include #include diff --git a/src/stats/model/boolean-probe.cc b/src/stats/model/boolean-probe.cc index 4cd51f898..023ccdab7 100644 --- a/src/stats/model/boolean-probe.cc +++ b/src/stats/model/boolean-probe.cc @@ -20,7 +20,7 @@ * Modified by: Mitch Watrous (watrous@u.washington.edu) */ -#include "ns3/boolean-probe.h" +#include "boolean-probe.h" #include "ns3/config.h" #include "ns3/log.h" diff --git a/src/stats/model/boolean-probe.h b/src/stats/model/boolean-probe.h index e7e379779..792e8b51b 100644 --- a/src/stats/model/boolean-probe.h +++ b/src/stats/model/boolean-probe.h @@ -23,10 +23,11 @@ #ifndef BOOL_PROBE_H #define BOOL_PROBE_H +#include "probe.h" + #include "ns3/boolean.h" #include "ns3/callback.h" #include "ns3/object.h" -#include "ns3/probe.h" #include "ns3/simulator.h" #include "ns3/traced-value.h" diff --git a/src/stats/model/data-output-interface.h b/src/stats/model/data-output-interface.h index d363b7d80..1903275f7 100644 --- a/src/stats/model/data-output-interface.h +++ b/src/stats/model/data-output-interface.h @@ -20,7 +20,8 @@ #ifndef DATA_OUTPUT_INTERFACE_H #define DATA_OUTPUT_INTERFACE_H -#include "ns3/data-calculator.h" +#include "data-calculator.h" + #include "ns3/nstime.h" #include "ns3/object.h" diff --git a/src/stats/model/double-probe.cc b/src/stats/model/double-probe.cc index a364bddc4..2f3adaf80 100644 --- a/src/stats/model/double-probe.cc +++ b/src/stats/model/double-probe.cc @@ -20,7 +20,7 @@ * Modified by: Mitch Watrous (watrous@u.washington.edu) */ -#include "ns3/double-probe.h" +#include "double-probe.h" #include "ns3/config.h" #include "ns3/log.h" diff --git a/src/stats/model/double-probe.h b/src/stats/model/double-probe.h index bb52650ac..4f70de39e 100644 --- a/src/stats/model/double-probe.h +++ b/src/stats/model/double-probe.h @@ -23,10 +23,11 @@ #ifndef DOUBLE_PROBE_H #define DOUBLE_PROBE_H +#include "probe.h" + #include "ns3/boolean.h" #include "ns3/callback.h" #include "ns3/object.h" -#include "ns3/probe.h" #include "ns3/simulator.h" #include "ns3/traced-value.h" diff --git a/src/stats/model/file-aggregator.h b/src/stats/model/file-aggregator.h index 470353fe1..7fccc009a 100644 --- a/src/stats/model/file-aggregator.h +++ b/src/stats/model/file-aggregator.h @@ -23,7 +23,7 @@ #ifndef FILE_AGGREGATOR_H #define FILE_AGGREGATOR_H -#include "ns3/data-collection-object.h" +#include "data-collection-object.h" #include #include diff --git a/src/stats/model/gnuplot-aggregator.h b/src/stats/model/gnuplot-aggregator.h index 6e9addca9..b98cd70ce 100644 --- a/src/stats/model/gnuplot-aggregator.h +++ b/src/stats/model/gnuplot-aggregator.h @@ -23,8 +23,8 @@ #ifndef GNUPLOT_AGGREGATOR_H #define GNUPLOT_AGGREGATOR_H -#include "ns3/data-collection-object.h" -#include "ns3/gnuplot.h" +#include "data-collection-object.h" +#include "gnuplot.h" #include #include diff --git a/src/stats/model/gnuplot.cc b/src/stats/model/gnuplot.cc index 3b7891418..2ba37f9a2 100644 --- a/src/stats/model/gnuplot.cc +++ b/src/stats/model/gnuplot.cc @@ -293,7 +293,7 @@ Gnuplot2dDataset::Data2d::PrintExpression(std::ostream& os, void Gnuplot2dDataset::Data2d::PrintDataFile(std::ostream& os, bool generateOneOutputFile) const { - for (PointSet::const_iterator i = m_pointset.begin(); i != m_pointset.end(); ++i) + for (auto i = m_pointset.begin(); i != m_pointset.end(); ++i) { if (i->empty) { @@ -578,7 +578,7 @@ Gnuplot3dDataset::Data3d::PrintExpression(std::ostream& os, void Gnuplot3dDataset::Data3d::PrintDataFile(std::ostream& os, bool generateOneOutputFile) const { - for (PointSet::const_iterator i = m_pointset.begin(); i != m_pointset.end(); ++i) + for (auto i = m_pointset.begin(); i != m_pointset.end(); ++i) { if (i->empty) { @@ -852,7 +852,7 @@ Gnuplot::GenerateOutput(std::ostream& osControl, std::ostream& osData, std::stri std::string command = m_datasets.begin()->m_data->GetCommand(); - for (Datasets::const_iterator i = m_datasets.begin() + 1; i != m_datasets.end(); ++i) + for (auto i = m_datasets.begin() + 1; i != m_datasets.end(); ++i) { NS_ASSERT_MSG(command == i->m_data->GetCommand(), "Cannot mix 'plot' and 'splot' GnuplotDatasets."); @@ -863,7 +863,7 @@ Gnuplot::GenerateOutput(std::ostream& osControl, std::ostream& osData, std::stri // Print all dataset expressions bool isDataEmpty; - for (Datasets::const_iterator i = m_datasets.begin(); i != m_datasets.end();) + for (auto i = m_datasets.begin(); i != m_datasets.end();) { // Only print the dataset if it's not empty. isDataEmpty = i->m_data->IsEmpty(); @@ -889,7 +889,7 @@ Gnuplot::GenerateOutput(std::ostream& osControl, std::ostream& osData, std::stri // followed by the inline datafile. - for (Datasets::const_iterator i = m_datasets.begin(); i != m_datasets.end(); i++) + for (auto i = m_datasets.begin(); i != m_datasets.end(); i++) { i->m_data->PrintDataFile(osData, m_generateOneOutputFile); } @@ -950,7 +950,7 @@ GnuplotCollection::GenerateOutput(std::ostream& os) os << "set output \"" << m_outputFilename << "\"" << std::endl; } - for (Plots::iterator i = m_plots.begin(); i != m_plots.end(); ++i) + for (auto i = m_plots.begin(); i != m_plots.end(); ++i) { i->GenerateOutput(os); } @@ -974,7 +974,7 @@ GnuplotCollection::GenerateOutput(std::ostream& osControl, osControl << "set output \"" << m_outputFilename << "\"" << std::endl; } - for (Plots::iterator i = m_plots.begin(); i != m_plots.end(); ++i) + for (auto i = m_plots.begin(); i != m_plots.end(); ++i) { i->GenerateOutput(osControl, osData, dataFileName); } diff --git a/src/stats/model/histogram.cc b/src/stats/model/histogram.cc index b91e11982..1b0b3f9f6 100644 --- a/src/stats/model/histogram.cc +++ b/src/stats/model/histogram.cc @@ -80,7 +80,7 @@ Histogram::GetBinCount(uint32_t index) const void Histogram::AddValue(double value) { - uint32_t index = (uint32_t)std::floor(value / m_binWidth); + auto index = (uint32_t)std::floor(value / m_binWidth); // check if we need to resize the vector NS_LOG_DEBUG("AddValue: index=" << index << ", m_histogram.size()=" << m_histogram.size()); diff --git a/src/stats/model/omnet-data-output.cc b/src/stats/model/omnet-data-output.cc index b889f00d2..77e99be0e 100644 --- a/src/stats/model/omnet-data-output.cc +++ b/src/stats/model/omnet-data-output.cc @@ -75,7 +75,7 @@ isNumeric(const std::string& s) bool exponentSeen = false; char last = '\0'; - for (std::string::const_iterator it = s.begin(); it != s.end(); it++) + for (auto it = s.begin(); it != s.end(); it++) { if ((*it == '.') && (decimalPtSeen)) { @@ -120,7 +120,7 @@ OmnetDataOutput::Output(DataCollector& dc) scalarFile << "attr measurement \"" << dc.GetInputLabel() << "\"" << std::endl; scalarFile << "attr description \"" << dc.GetDescription() << "\"" << std::endl; - for (MetadataList::iterator i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) + for (auto i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) { std::pair blob = (*i); scalarFile << "attr \"" << blob.first << "\" \"" << blob.second << "\"" << std::endl; @@ -131,7 +131,7 @@ OmnetDataOutput::Output(DataCollector& dc) { scalarFile << "scalar . measurement \"" << dc.GetInputLabel() << "\"" << std::endl; } - for (MetadataList::iterator i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) + for (auto i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) { std::pair blob = (*i); if (isNumeric(blob.second)) @@ -142,8 +142,7 @@ OmnetDataOutput::Output(DataCollector& dc) } OmnetOutputCallback callback(&scalarFile); - for (DataCalculatorList::iterator i = dc.DataCalculatorBegin(); i != dc.DataCalculatorEnd(); - i++) + for (auto i = dc.DataCalculatorBegin(); i != dc.DataCalculatorEnd(); i++) { (*i)->Output(callback); } diff --git a/src/stats/model/probe.cc b/src/stats/model/probe.cc index 36ea10a0f..17b1d87cc 100644 --- a/src/stats/model/probe.cc +++ b/src/stats/model/probe.cc @@ -18,7 +18,7 @@ * Tiago G. Rodrigues (tgr002@bucknell.edu) */ -#include "ns3/probe.h" +#include "probe.h" #include "ns3/log.h" #include "ns3/object.h" diff --git a/src/stats/model/probe.h b/src/stats/model/probe.h index 38a64cefc..35575144a 100644 --- a/src/stats/model/probe.h +++ b/src/stats/model/probe.h @@ -21,7 +21,8 @@ #ifndef PROBE_H #define PROBE_H -#include "ns3/data-collection-object.h" +#include "data-collection-object.h" + #include "ns3/nstime.h" namespace ns3 diff --git a/src/stats/model/sqlite-data-output.cc b/src/stats/model/sqlite-data-output.cc index 2d36baee8..66a69753b 100644 --- a/src/stats/model/sqlite-data-output.cc +++ b/src/stats/model/sqlite-data-output.cc @@ -116,7 +116,7 @@ SqliteDataOutput::Output(DataCollector& dc) "values (?, ?, ?)"); NS_ASSERT(res); - for (MetadataList::iterator i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) + for (auto i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) { std::pair blob = (*i); m_sqliteOut->SpinReset(stmt); @@ -130,8 +130,7 @@ SqliteDataOutput::Output(DataCollector& dc) m_sqliteOut->SpinExec("BEGIN"); SqliteOutputCallback callback(m_sqliteOut, run); - for (DataCalculatorList::iterator i = dc.DataCalculatorBegin(); i != dc.DataCalculatorEnd(); - i++) + for (auto i = dc.DataCalculatorBegin(); i != dc.DataCalculatorEnd(); i++) { (*i)->Output(callback); } diff --git a/src/stats/model/time-probe.cc b/src/stats/model/time-probe.cc index 3a8a184b9..db7b482bf 100644 --- a/src/stats/model/time-probe.cc +++ b/src/stats/model/time-probe.cc @@ -21,7 +21,7 @@ * */ -#include "ns3/time-probe.h" +#include "time-probe.h" #include "ns3/config.h" #include "ns3/log.h" diff --git a/src/stats/model/time-probe.h b/src/stats/model/time-probe.h index 7a429f8df..3e477eba4 100644 --- a/src/stats/model/time-probe.h +++ b/src/stats/model/time-probe.h @@ -23,11 +23,12 @@ #ifndef TIME_PROBE_H #define TIME_PROBE_H +#include "probe.h" + #include "ns3/boolean.h" #include "ns3/callback.h" #include "ns3/nstime.h" #include "ns3/object.h" -#include "ns3/probe.h" #include "ns3/simulator.h" #include "ns3/traced-value.h" diff --git a/src/stats/model/time-series-adaptor.cc b/src/stats/model/time-series-adaptor.cc index 01e24dd17..bd92ac694 100644 --- a/src/stats/model/time-series-adaptor.cc +++ b/src/stats/model/time-series-adaptor.cc @@ -17,7 +17,7 @@ * Author: Mitch Watrous (watrous@u.washington.edu) */ -#include "ns3/time-series-adaptor.h" +#include "time-series-adaptor.h" #include "ns3/log.h" #include "ns3/object.h" diff --git a/src/stats/model/time-series-adaptor.h b/src/stats/model/time-series-adaptor.h index 106cceb2f..070859c33 100644 --- a/src/stats/model/time-series-adaptor.h +++ b/src/stats/model/time-series-adaptor.h @@ -20,7 +20,8 @@ #ifndef TIME_SERIES_ADAPTOR_H #define TIME_SERIES_ADAPTOR_H -#include "ns3/data-collection-object.h" +#include "data-collection-object.h" + #include "ns3/object.h" #include "ns3/traced-value.h" #include "ns3/type-id.h" diff --git a/src/stats/model/uinteger-16-probe.cc b/src/stats/model/uinteger-16-probe.cc index e5c563f68..48d5553ef 100644 --- a/src/stats/model/uinteger-16-probe.cc +++ b/src/stats/model/uinteger-16-probe.cc @@ -20,7 +20,7 @@ * Modified by: Mitch Watrous (watrous@u.washington.edu) */ -#include "ns3/uinteger-16-probe.h" +#include "uinteger-16-probe.h" #include "ns3/config.h" #include "ns3/log.h" diff --git a/src/stats/model/uinteger-16-probe.h b/src/stats/model/uinteger-16-probe.h index f912060e1..62f783fef 100644 --- a/src/stats/model/uinteger-16-probe.h +++ b/src/stats/model/uinteger-16-probe.h @@ -23,8 +23,9 @@ #ifndef UINTEGER_16_PROBE_H #define UINTEGER_16_PROBE_H +#include "probe.h" + #include "ns3/callback.h" -#include "ns3/probe.h" #include "ns3/traced-value.h" namespace ns3 diff --git a/src/stats/model/uinteger-32-probe.cc b/src/stats/model/uinteger-32-probe.cc index cdb9fbde1..e157a2deb 100644 --- a/src/stats/model/uinteger-32-probe.cc +++ b/src/stats/model/uinteger-32-probe.cc @@ -20,7 +20,7 @@ * Modified by: Mitch Watrous (watrous@u.washington.edu) */ -#include "ns3/uinteger-32-probe.h" +#include "uinteger-32-probe.h" #include "ns3/config.h" #include "ns3/log.h" diff --git a/src/stats/model/uinteger-32-probe.h b/src/stats/model/uinteger-32-probe.h index 366f47a7d..f4384e95c 100644 --- a/src/stats/model/uinteger-32-probe.h +++ b/src/stats/model/uinteger-32-probe.h @@ -23,8 +23,9 @@ #ifndef UINTEGER_32_PROBE_H #define UINTEGER_32_PROBE_H +#include "probe.h" + #include "ns3/callback.h" -#include "ns3/probe.h" #include "ns3/traced-value.h" namespace ns3 diff --git a/src/stats/model/uinteger-8-probe.cc b/src/stats/model/uinteger-8-probe.cc index f58f88533..548708830 100644 --- a/src/stats/model/uinteger-8-probe.cc +++ b/src/stats/model/uinteger-8-probe.cc @@ -20,7 +20,7 @@ * Modified by: Mitch Watrous (watrous@u.washington.edu) */ -#include "ns3/uinteger-8-probe.h" +#include "uinteger-8-probe.h" #include "ns3/config.h" #include "ns3/log.h" diff --git a/src/stats/model/uinteger-8-probe.h b/src/stats/model/uinteger-8-probe.h index c085fa531..9c67485ae 100644 --- a/src/stats/model/uinteger-8-probe.h +++ b/src/stats/model/uinteger-8-probe.h @@ -23,8 +23,9 @@ #ifndef UINTEGER_8_PROBE_H #define UINTEGER_8_PROBE_H +#include "probe.h" + #include "ns3/callback.h" -#include "ns3/probe.h" #include "ns3/traced-value.h" namespace ns3 diff --git a/src/tap-bridge/model/tap-bridge.cc b/src/tap-bridge/model/tap-bridge.cc index 13b6b7e03..3c711af7f 100644 --- a/src/tap-bridge/model/tap-bridge.cc +++ b/src/tap-bridge/model/tap-bridge.cc @@ -57,7 +57,7 @@ TapBridgeFdReader::DoRead() NS_LOG_FUNCTION(this); uint32_t bufferSize = 65536; - uint8_t* buf = (uint8_t*)std::malloc(bufferSize); + auto buf = (uint8_t*)std::malloc(bufferSize); NS_ABORT_MSG_IF(buf == nullptr, "malloc() failed"); NS_LOG_LOGIC("Calling read on tap device fd " << m_fd); diff --git a/src/test/csma-system-test-suite.cc b/src/test/csma-system-test-suite.cc index a710da265..bc8c3977d 100644 --- a/src/test/csma-system-test-suite.cc +++ b/src/test/csma-system-test-suite.cc @@ -870,7 +870,7 @@ CsmaPingTestCase::DoRun() // Make packets be sent about every DefaultPacketSize / DataRate = // 4096 bits / (5000 bits/second) = 0.82 second. Config::SetDefault("ns3::Ipv4RawSocketImpl::Protocol", StringValue("2")); - InetSocketAddress dst = InetSocketAddress(addresses.GetAddress(3)); + InetSocketAddress dst(addresses.GetAddress(3)); OnOffHelper onoff = OnOffHelper("ns3::Ipv4RawSocketFactory", dst); onoff.SetConstantRate(DataRate(5000)); @@ -1004,7 +1004,7 @@ CsmaRawIpSocketTestCase::DoRun() // Make packets be sent about every DefaultPacketSize / DataRate = // 4096 bits / (5000 bits/second) = 0.82 second. Config::SetDefault("ns3::Ipv4RawSocketImpl::Protocol", StringValue("2")); - InetSocketAddress dst = InetSocketAddress(addresses.GetAddress(3)); + InetSocketAddress dst(addresses.GetAddress(3)); OnOffHelper onoff = OnOffHelper("ns3::Ipv4RawSocketFactory", dst); onoff.SetConstantRate(DataRate(5000)); diff --git a/src/test/ns3tc/pfifo-fast-queue-disc-test-suite.cc b/src/test/ns3tc/pfifo-fast-queue-disc-test-suite.cc index 39438598d..25d3dda0e 100644 --- a/src/test/ns3tc/pfifo-fast-queue-disc-test-suite.cc +++ b/src/test/ns3tc/pfifo-fast-queue-disc-test-suite.cc @@ -369,7 +369,7 @@ PfifoFastQueueDiscNoPriority::DoRun() 2, "unexpected queue depth"); p = Create(100); - uint8_t* buf = new uint8_t[100]; + auto buf = new uint8_t[100]; uint8_t counter = 0; for (uint32_t i = 0; i < 100; i++) { diff --git a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc b/src/test/ns3tcp/ns3tcp-loss-test-suite.cc index 13c5a783e..9f9d96119 100644 --- a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc +++ b/src/test/ns3tcp/ns3tcp-loss-test-suite.cc @@ -246,7 +246,7 @@ Ns3TcpLossTestCase::Ipv4L3Tx(std::string, Ptr packet, Ptr, u NS_LOG_INFO("read " << readLen << " bytes"); - uint8_t* actual = new uint8_t[readLen]; + auto actual = new uint8_t[readLen]; received->CopyData(actual, readLen); int result = memcmp(actual, expectedBuffer, readLen); diff --git a/src/test/ns3tcp/ns3tcp-state-test-suite.cc b/src/test/ns3tcp/ns3tcp-state-test-suite.cc index a6fa1203e..3da311d1c 100644 --- a/src/test/ns3tcp/ns3tcp-state-test-suite.cc +++ b/src/test/ns3tcp/ns3tcp-state-test-suite.cc @@ -252,7 +252,7 @@ Ns3TcpStateTestCase::Ipv4L3Tx(std::string, Ptr packet, Ptr, NS_LOG_INFO("read " << readLen << " bytes"); - uint8_t* actual = new uint8_t[readLen]; + auto actual = new uint8_t[readLen]; received->CopyData(actual, readLen); int result = memcmp(actual, expectedBuffer, readLen); diff --git a/src/topology-read/examples/topology-example-sim.cc b/src/topology-read/examples/topology-example-sim.cc index 07321bcfb..710dc9704 100644 --- a/src/topology-read/examples/topology-example-sim.cc +++ b/src/topology-read/examples/topology-example-sim.cc @@ -122,7 +122,7 @@ main(int argc, char* argv[]) int totlinks = inFile->LinksSize(); NS_LOG_INFO("creating node containers"); - NodeContainer* nc = new NodeContainer[totlinks]; + auto nc = new NodeContainer[totlinks]; TopologyReader::ConstLinksIterator iter; int i = 0; for (iter = inFile->LinksBegin(); iter != inFile->LinksEnd(); iter++, i++) @@ -131,7 +131,7 @@ main(int argc, char* argv[]) } NS_LOG_INFO("creating net device containers"); - NetDeviceContainer* ndc = new NetDeviceContainer[totlinks]; + auto ndc = new NetDeviceContainer[totlinks]; PointToPointHelper p2p; for (int i = 0; i < totlinks; i++) { @@ -143,7 +143,7 @@ main(int argc, char* argv[]) // it crates little subnets, one for each couple of nodes. NS_LOG_INFO("creating IPv4 interfaces"); - Ipv4InterfaceContainer* ipic = new Ipv4InterfaceContainer[totlinks]; + auto ipic = new Ipv4InterfaceContainer[totlinks]; for (int i = 0; i < totlinks; i++) { ipic[i] = address.Assign(ndc[i]); @@ -166,7 +166,7 @@ main(int argc, char* argv[]) // -- Send around packets to check the ttl // -------------------------------------------- Config::SetDefault("ns3::Ipv4RawSocketImpl::Protocol", StringValue("2")); - InetSocketAddress dst = InetSocketAddress(ipv4AddrServer); + InetSocketAddress dst(ipv4AddrServer); OnOffHelper onoff = OnOffHelper("ns3::Ipv4RawSocketFactory", dst); onoff.SetConstantRate(DataRate(15000)); diff --git a/src/topology-read/helper/topology-reader-helper.cc b/src/topology-read/helper/topology-reader-helper.cc index 2417747a6..74e8deafc 100644 --- a/src/topology-read/helper/topology-reader-helper.cc +++ b/src/topology-read/helper/topology-reader-helper.cc @@ -18,7 +18,7 @@ * Author: Valerio Sartini (valesar@gmail.com) */ -#include "ns3/topology-reader-helper.h" +#include "topology-reader-helper.h" #include "ns3/inet-topology-reader.h" #include "ns3/log.h" diff --git a/src/topology-read/model/rocketfuel-topology-reader.cc b/src/topology-read/model/rocketfuel-topology-reader.cc index fd28fefa6..90052c124 100644 --- a/src/topology-read/model/rocketfuel-topology-reader.cc +++ b/src/topology-read/model/rocketfuel-topology-reader.cc @@ -322,19 +322,15 @@ RocketfuelTopologyReader::GenerateFromWeightsFile(const std::vector RocketfuelTopologyReader::RF_FileType RocketfuelTopologyReader::GetFileType(const std::string& line) { - int ret; - // Check whether Maps file or not std::smatch matches; - ret = std::regex_match(line, matches, rocketfuel_maps_regex); - if (ret) + if (std::regex_match(line, matches, rocketfuel_maps_regex)) { return RF_MAPS; } // Check whether Weights file or not - ret = std::regex_match(line, matches, rocketfuel_weights_regex); - if (ret) + if (std::regex_match(line, matches, rocketfuel_weights_regex)) { return RF_WEIGHTS; } @@ -362,7 +358,6 @@ RocketfuelTopologyReader::Read() while (!topgen.eof()) { - int ret; std::vector argv; lineNumber++; @@ -385,7 +380,7 @@ RocketfuelTopologyReader::Read() if (ftype == RF_MAPS) { - ret = std::regex_match(line, matches, rocketfuel_maps_regex); + bool ret = std::regex_match(line, matches, rocketfuel_maps_regex); if (!ret || matches.empty()) { NS_LOG_WARN("match failed (maps file): %s" << line); @@ -394,7 +389,7 @@ RocketfuelTopologyReader::Read() } else if (ftype == RF_WEIGHTS) { - ret = std::regex_match(line, matches, rocketfuel_weights_regex); + bool ret = std::regex_match(line, matches, rocketfuel_weights_regex); if (!ret || matches.empty()) { NS_LOG_WARN("match failed (weights file): %s" << line); diff --git a/src/traffic-control/CMakeLists.txt b/src/traffic-control/CMakeLists.txt index 6844029ab..7c7917b66 100644 --- a/src/traffic-control/CMakeLists.txt +++ b/src/traffic-control/CMakeLists.txt @@ -36,8 +36,9 @@ build_lib( model/red-queue-disc.h model/tbf-queue-disc.h model/traffic-control-layer.h - LIBRARIES_TO_LINK ${libnetwork} - ${libcore} + LIBRARIES_TO_LINK + ${libnetwork} + ${libcore} TEST_SOURCES test/adaptive-red-queue-disc-test-suite.cc test/cobalt-queue-disc-test-suite.cc diff --git a/src/traffic-control/helper/queue-disc-container.cc b/src/traffic-control/helper/queue-disc-container.cc index 5c342e0d9..20571e7c9 100644 --- a/src/traffic-control/helper/queue-disc-container.cc +++ b/src/traffic-control/helper/queue-disc-container.cc @@ -58,7 +58,7 @@ QueueDiscContainer::Get(std::size_t i) const void QueueDiscContainer::Add(QueueDiscContainer other) { - for (ConstIterator i = other.Begin(); i != other.End(); i++) + for (auto i = other.Begin(); i != other.End(); i++) { m_queueDiscs.push_back(*i); } diff --git a/src/traffic-control/helper/traffic-control-helper.cc b/src/traffic-control/helper/traffic-control-helper.cc index d009cdaf5..b5be24053 100644 --- a/src/traffic-control/helper/traffic-control-helper.cc +++ b/src/traffic-control/helper/traffic-control-helper.cc @@ -71,17 +71,13 @@ QueueDiscFactory::CreateQueueDisc(const std::vector>& queueDiscs) Ptr qd = m_queueDiscFactory.Create(); // create and add the internal queues - for (std::vector::iterator i = m_internalQueuesFactory.begin(); - i != m_internalQueuesFactory.end(); - i++) + for (auto i = m_internalQueuesFactory.begin(); i != m_internalQueuesFactory.end(); i++) { qd->AddInternalQueue(i->Create()); } // create and add the packet filters - for (std::vector::iterator i = m_packetFiltersFactory.begin(); - i != m_packetFiltersFactory.end(); - i++) + for (auto i = m_packetFiltersFactory.begin(); i != m_packetFiltersFactory.end(); i++) { qd->AddPacketFilter(i->Create()); } @@ -182,7 +178,7 @@ TrafficControlHelper::DoAddChildQueueDisc(uint16_t handle, uint16_t classId, Obj NS_ABORT_MSG_IF(handle >= m_queueDiscFactory.size(), "A queue disc with handle " << handle << " does not exist"); - uint16_t childHandle = static_cast(m_queueDiscFactory.size()); + auto childHandle = static_cast(m_queueDiscFactory.size()); m_queueDiscFactory.emplace_back(factory); m_queueDiscFactory[handle].SetChildQueueDisc(classId, childHandle); @@ -195,7 +191,7 @@ TrafficControlHelper::DoAddChildQueueDiscs(uint16_t handle, ObjectFactory factory) { HandleList list; - for (ClassIdList::const_iterator c = classes.begin(); c != classes.end(); c++) + for (auto c = classes.begin(); c != classes.end(); c++) { uint16_t childHandle = DoAddChildQueueDisc(handle, *c, factory); list.push_back(childHandle); @@ -254,7 +250,7 @@ TrafficControlHelper::Install(NetDeviceContainer c) { QueueDiscContainer container; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { container.Add(Install(*i)); } @@ -283,7 +279,7 @@ TrafficControlHelper::Uninstall(Ptr d) void TrafficControlHelper::Uninstall(NetDeviceContainer c) { - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Uninstall(*i); } diff --git a/src/traffic-control/helper/traffic-control-helper.h b/src/traffic-control/helper/traffic-control-helper.h index a5d1b5594..2b90802bc 100644 --- a/src/traffic-control/helper/traffic-control-helper.h +++ b/src/traffic-control/helper/traffic-control-helper.h @@ -19,9 +19,10 @@ #ifndef TRAFFIC_CONTROL_HELPER_H #define TRAFFIC_CONTROL_HELPER_H +#include "queue-disc-container.h" + #include "ns3/net-device-container.h" #include "ns3/object-factory.h" -#include "ns3/queue-disc-container.h" #include "ns3/queue.h" #include diff --git a/src/traffic-control/model/cobalt-queue-disc.cc b/src/traffic-control/model/cobalt-queue-disc.cc index 34f5feb52..c98ddfff0 100644 --- a/src/traffic-control/model/cobalt-queue-disc.cc +++ b/src/traffic-control/model/cobalt-queue-disc.cc @@ -359,7 +359,7 @@ CobaltQueueDisc::DoDequeue() { NS_LOG_FUNCTION(this); - while (1) + while (true) { Ptr item = GetInternalQueue(0)->Dequeue(); if (!item) @@ -542,7 +542,7 @@ CobaltQueueDisc::CobaltShouldDrop(Ptr item, int64_t now) if (m_pDrop) { double u = m_uv->GetValue(); - drop = drop | (u < m_pDrop); + drop = drop || (u < m_pDrop); } /* Overload the drop_next field as an activity timeout */ diff --git a/src/traffic-control/model/cobalt-queue-disc.h b/src/traffic-control/model/cobalt-queue-disc.h index e3eb3c138..5a4b639db 100644 --- a/src/traffic-control/model/cobalt-queue-disc.h +++ b/src/traffic-control/model/cobalt-queue-disc.h @@ -28,10 +28,11 @@ #ifndef COBALT_H #define COBALT_H +#include "queue-disc.h" + #include "ns3/boolean.h" #include "ns3/data-rate.h" #include "ns3/nstime.h" -#include "ns3/queue-disc.h" #include "ns3/random-variable-stream.h" #include "ns3/simulator.h" #include "ns3/string.h" diff --git a/src/traffic-control/model/codel-queue-disc.h b/src/traffic-control/model/codel-queue-disc.h index 378327cdf..c6535cb3b 100644 --- a/src/traffic-control/model/codel-queue-disc.h +++ b/src/traffic-control/model/codel-queue-disc.h @@ -27,8 +27,9 @@ #ifndef CODEL_H #define CODEL_H +#include "queue-disc.h" + #include "ns3/nstime.h" -#include "ns3/queue-disc.h" #include "ns3/simulator.h" #include "ns3/string.h" #include "ns3/trace-source-accessor.h" diff --git a/src/traffic-control/model/fifo-queue-disc.h b/src/traffic-control/model/fifo-queue-disc.h index 43e5ee5e7..9934963cd 100644 --- a/src/traffic-control/model/fifo-queue-disc.h +++ b/src/traffic-control/model/fifo-queue-disc.h @@ -20,7 +20,7 @@ #ifndef FIFO_QUEUE_DISC_H #define FIFO_QUEUE_DISC_H -#include "ns3/queue-disc.h" +#include "queue-disc.h" namespace ns3 { diff --git a/src/traffic-control/model/fq-cobalt-queue-disc.h b/src/traffic-control/model/fq-cobalt-queue-disc.h index 41dde9a60..248c7f3cd 100644 --- a/src/traffic-control/model/fq-cobalt-queue-disc.h +++ b/src/traffic-control/model/fq-cobalt-queue-disc.h @@ -27,8 +27,9 @@ #ifndef FQ_COBALT_QUEUE_DISC #define FQ_COBALT_QUEUE_DISC +#include "queue-disc.h" + #include "ns3/object-factory.h" -#include "ns3/queue-disc.h" #include #include diff --git a/src/traffic-control/model/fq-codel-queue-disc.h b/src/traffic-control/model/fq-codel-queue-disc.h index 2e18336ee..922edb404 100644 --- a/src/traffic-control/model/fq-codel-queue-disc.h +++ b/src/traffic-control/model/fq-codel-queue-disc.h @@ -21,8 +21,9 @@ #ifndef FQ_CODEL_QUEUE_DISC #define FQ_CODEL_QUEUE_DISC +#include "queue-disc.h" + #include "ns3/object-factory.h" -#include "ns3/queue-disc.h" #include #include diff --git a/src/traffic-control/model/fq-pie-queue-disc.h b/src/traffic-control/model/fq-pie-queue-disc.h index bfb2ba334..4e0df3768 100644 --- a/src/traffic-control/model/fq-pie-queue-disc.h +++ b/src/traffic-control/model/fq-pie-queue-disc.h @@ -26,8 +26,9 @@ #ifndef FQ_PIE_QUEUE_DISC #define FQ_PIE_QUEUE_DISC +#include "queue-disc.h" + #include "ns3/object-factory.h" -#include "ns3/queue-disc.h" #include #include diff --git a/src/traffic-control/model/mq-queue-disc.h b/src/traffic-control/model/mq-queue-disc.h index d7af1190b..77a67b22d 100644 --- a/src/traffic-control/model/mq-queue-disc.h +++ b/src/traffic-control/model/mq-queue-disc.h @@ -21,7 +21,7 @@ #ifndef MQ_QUEUE_DISC_H #define MQ_QUEUE_DISC_H -#include "ns3/queue-disc.h" +#include "queue-disc.h" namespace ns3 { diff --git a/src/traffic-control/model/pfifo-fast-queue-disc.h b/src/traffic-control/model/pfifo-fast-queue-disc.h index f64fa5c9b..0e8b2b43a 100644 --- a/src/traffic-control/model/pfifo-fast-queue-disc.h +++ b/src/traffic-control/model/pfifo-fast-queue-disc.h @@ -22,7 +22,7 @@ #ifndef PFIFO_FAST_H #define PFIFO_FAST_H -#include "ns3/queue-disc.h" +#include "queue-disc.h" namespace ns3 { diff --git a/src/traffic-control/model/pie-queue-disc.cc b/src/traffic-control/model/pie-queue-disc.cc index 01d1b7f04..d701f727a 100644 --- a/src/traffic-control/model/pie-queue-disc.cc +++ b/src/traffic-control/model/pie-queue-disc.cc @@ -437,7 +437,7 @@ PieQueueDisc::CalculateP() m_burstAllowance -= m_tUpdate; } - uint32_t burstResetLimit = static_cast(BURST_RESET_TIMEOUT / m_tUpdate.GetSeconds()); + auto burstResetLimit = static_cast(BURST_RESET_TIMEOUT / m_tUpdate.GetSeconds()); if ((qDelay.GetSeconds() < 0.5 * m_qDelayRef.GetSeconds()) && (m_qDelayOld.GetSeconds() < (0.5 * m_qDelayRef.GetSeconds())) && (m_dropProb == 0) && !missingInitFlag) diff --git a/src/traffic-control/model/pie-queue-disc.h b/src/traffic-control/model/pie-queue-disc.h index 378af479b..e7aac0c9d 100644 --- a/src/traffic-control/model/pie-queue-disc.h +++ b/src/traffic-control/model/pie-queue-disc.h @@ -27,11 +27,12 @@ #ifndef PIE_QUEUE_DISC_H #define PIE_QUEUE_DISC_H +#include "queue-disc.h" + #include "ns3/boolean.h" #include "ns3/data-rate.h" #include "ns3/event-id.h" #include "ns3/nstime.h" -#include "ns3/queue-disc.h" #include "ns3/random-variable-stream.h" #include "ns3/timer.h" diff --git a/src/traffic-control/model/prio-queue-disc.h b/src/traffic-control/model/prio-queue-disc.h index 58abb1da1..89fe99cbd 100644 --- a/src/traffic-control/model/prio-queue-disc.h +++ b/src/traffic-control/model/prio-queue-disc.h @@ -20,7 +20,7 @@ #ifndef PRIO_QUEUE_DISC_H #define PRIO_QUEUE_DISC_H -#include "ns3/queue-disc.h" +#include "queue-disc.h" #include diff --git a/src/traffic-control/model/queue-disc.cc b/src/traffic-control/model/queue-disc.cc index 0db2a831f..cad4f3b3a 100644 --- a/src/traffic-control/model/queue-disc.cc +++ b/src/traffic-control/model/queue-disc.cc @@ -178,9 +178,6 @@ QueueDisc::Stats::GetNMarkedBytes(std::string reason) const void QueueDisc::Stats::Print(std::ostream& os) const { - std::map::const_iterator itp; - std::map::const_iterator itb; - os << std::endl << "Packets/Bytes received: " << nTotalReceivedPackets << " / " << nTotalReceivedBytes << std::endl @@ -195,8 +192,8 @@ QueueDisc::Stats::Print(std::ostream& os) const << "Packets/Bytes dropped before enqueue: " << nTotalDroppedPacketsBeforeEnqueue << " / " << nTotalDroppedBytesBeforeEnqueue; - itp = nDroppedPacketsBeforeEnqueue.begin(); - itb = nDroppedBytesBeforeEnqueue.begin(); + auto itp = nDroppedPacketsBeforeEnqueue.begin(); + auto itb = nDroppedBytesBeforeEnqueue.begin(); while (itp != nDroppedPacketsBeforeEnqueue.end() && itb != nDroppedBytesBeforeEnqueue.end()) { @@ -403,8 +400,7 @@ QueueDisc::DoInitialize() InitializeParams(); // Check the configuration and initialize the parameters of the child queue discs - for (std::vector>::iterator cl = m_classes.begin(); cl != m_classes.end(); - cl++) + for (auto cl = m_classes.begin(); cl != m_classes.end(); cl++) { (*cl)->GetQueueDisc()->Initialize(); } @@ -673,9 +669,7 @@ QueueDisc::Classify(Ptr item) NS_LOG_FUNCTION(this << item); int32_t ret = PacketFilter::PF_NO_MATCH; - for (std::vector>::iterator f = m_filters.begin(); - f != m_filters.end() && ret == PacketFilter::PF_NO_MATCH; - f++) + for (auto f = m_filters.begin(); f != m_filters.end() && ret == PacketFilter::PF_NO_MATCH; f++) { ret = (*f)->Classify(item); } @@ -733,8 +727,7 @@ QueueDisc::DropBeforeEnqueue(Ptr item, const char* reason) m_stats.nTotalDroppedBytesBeforeEnqueue += item->GetSize(); // update the number of packets dropped for the given reason - std::map::iterator itp = - m_stats.nDroppedPacketsBeforeEnqueue.find(reason); + auto itp = m_stats.nDroppedPacketsBeforeEnqueue.find(reason); if (itp != m_stats.nDroppedPacketsBeforeEnqueue.end()) { itp->second++; @@ -744,7 +737,7 @@ QueueDisc::DropBeforeEnqueue(Ptr item, const char* reason) m_stats.nDroppedPacketsBeforeEnqueue[reason] = 1; } // update the amount of bytes dropped for the given reason - std::map::iterator itb = m_stats.nDroppedBytesBeforeEnqueue.find(reason); + auto itb = m_stats.nDroppedBytesBeforeEnqueue.find(reason); if (itb != m_stats.nDroppedBytesBeforeEnqueue.end()) { itb->second += item->GetSize(); @@ -773,8 +766,7 @@ QueueDisc::DropAfterDequeue(Ptr item, const char* reason) m_stats.nTotalDroppedBytesAfterDequeue += item->GetSize(); // update the number of packets dropped for the given reason - std::map::iterator itp = - m_stats.nDroppedPacketsAfterDequeue.find(reason); + auto itp = m_stats.nDroppedPacketsAfterDequeue.find(reason); if (itp != m_stats.nDroppedPacketsAfterDequeue.end()) { itp->second++; @@ -784,7 +776,7 @@ QueueDisc::DropAfterDequeue(Ptr item, const char* reason) m_stats.nDroppedPacketsAfterDequeue[reason] = 1; } // update the amount of bytes dropped for the given reason - std::map::iterator itb = m_stats.nDroppedBytesAfterDequeue.find(reason); + auto itb = m_stats.nDroppedBytesAfterDequeue.find(reason); if (itb != m_stats.nDroppedBytesAfterDequeue.end()) { itb->second += item->GetSize(); @@ -829,7 +821,7 @@ QueueDisc::Mark(Ptr item, const char* reason) m_stats.nTotalMarkedBytes += item->GetSize(); // update the number of packets marked for the given reason - std::map::iterator itp = m_stats.nMarkedPackets.find(reason); + auto itp = m_stats.nMarkedPackets.find(reason); if (itp != m_stats.nMarkedPackets.end()) { itp->second++; @@ -839,7 +831,7 @@ QueueDisc::Mark(Ptr item, const char* reason) m_stats.nMarkedPackets[reason] = 1; } // update the amount of bytes marked for the given reason - std::map::iterator itb = m_stats.nMarkedBytes.find(reason); + auto itb = m_stats.nMarkedBytes.find(reason); if (itb != m_stats.nMarkedBytes.end()) { itb->second += item->GetSize(); diff --git a/src/traffic-control/model/red-queue-disc.cc b/src/traffic-control/model/red-queue-disc.cc index 423b53ca7..b6372745c 100644 --- a/src/traffic-control/model/red-queue-disc.cc +++ b/src/traffic-control/model/red-queue-disc.cc @@ -763,7 +763,7 @@ double RedQueueDisc::ModifyP(double p, uint32_t size) { NS_LOG_FUNCTION(this << p << size); - double count1 = (double)m_count; + auto count1 = (double)m_count; if (GetMaxSize().GetUnit() == QueueSizeUnit::BYTES) { diff --git a/src/traffic-control/model/red-queue-disc.h b/src/traffic-control/model/red-queue-disc.h index 9374b124f..1918f895b 100644 --- a/src/traffic-control/model/red-queue-disc.h +++ b/src/traffic-control/model/red-queue-disc.h @@ -60,10 +60,11 @@ #ifndef RED_QUEUE_DISC_H #define RED_QUEUE_DISC_H +#include "queue-disc.h" + #include "ns3/boolean.h" #include "ns3/data-rate.h" #include "ns3/nstime.h" -#include "ns3/queue-disc.h" #include "ns3/random-variable-stream.h" namespace ns3 diff --git a/src/traffic-control/model/tbf-queue-disc.h b/src/traffic-control/model/tbf-queue-disc.h index 950fd2967..454eb2ed0 100644 --- a/src/traffic-control/model/tbf-queue-disc.h +++ b/src/traffic-control/model/tbf-queue-disc.h @@ -28,11 +28,12 @@ #ifndef TBF_QUEUE_DISC_H #define TBF_QUEUE_DISC_H +#include "queue-disc.h" + #include "ns3/boolean.h" #include "ns3/data-rate.h" #include "ns3/event-id.h" #include "ns3/nstime.h" -#include "ns3/queue-disc.h" #include "ns3/random-variable-stream.h" #include "ns3/trace-source-accessor.h" #include "ns3/traced-value.h" diff --git a/src/traffic-control/model/traffic-control-layer.cc b/src/traffic-control/model/traffic-control-layer.cc index 0b5007b3a..63b79860b 100644 --- a/src/traffic-control/model/traffic-control-layer.cc +++ b/src/traffic-control/model/traffic-control-layer.cc @@ -18,11 +18,12 @@ #include "traffic-control-layer.h" +#include "queue-disc.h" + #include "ns3/log.h" #include "ns3/net-device-queue-interface.h" #include "ns3/object-map.h" #include "ns3/packet.h" -#include "ns3/queue-disc.h" #include "ns3/socket.h" #include @@ -142,7 +143,7 @@ TrafficControlLayer::ScanDevices() Ptr ndqi = dev->GetObject(); NS_LOG_DEBUG("Pointer to NetDeviceQueueInterface: " << ndqi); - std::map, NetDeviceInfo>::iterator ndi = m_netDevices.find(dev); + auto ndi = m_netDevices.find(dev); if (ndi != m_netDevices.end()) { @@ -221,7 +222,7 @@ TrafficControlLayer::SetRootQueueDiscOnDevice(Ptr device, Ptr, NetDeviceInfo>::iterator ndi = m_netDevices.find(device); + auto ndi = m_netDevices.find(device); if (ndi == m_netDevices.end()) { @@ -243,7 +244,7 @@ TrafficControlLayer::GetRootQueueDiscOnDevice(Ptr device) const { NS_LOG_FUNCTION(this << device); - std::map, NetDeviceInfo>::const_iterator ndi = m_netDevices.find(device); + auto ndi = m_netDevices.find(device); if (ndi == m_netDevices.end()) { @@ -264,7 +265,7 @@ TrafficControlLayer::DeleteRootQueueDiscOnDevice(Ptr device) { NS_LOG_FUNCTION(this << device); - std::map, NetDeviceInfo>::iterator ndi = m_netDevices.find(device); + auto ndi = m_netDevices.find(device); NS_ASSERT_MSG(ndi != m_netDevices.end() && ndi->second.m_rootQueueDisc, "No root queue disc installed on device " << device); @@ -336,7 +337,7 @@ TrafficControlLayer::Receive(Ptr device, bool found = false; - for (ProtocolHandlerList::iterator i = m_handlers.begin(); i != m_handlers.end(); i++) + for (auto i = m_handlers.begin(); i != m_handlers.end(); i++) { if (!i->device || (i->device == device)) { @@ -364,7 +365,7 @@ TrafficControlLayer::Send(Ptr device, Ptr item) NS_LOG_DEBUG("Send packet to device " << device << " protocol number " << item->GetProtocol()); Ptr devQueueIface; - std::map, NetDeviceInfo>::iterator ndi = m_netDevices.find(device); + auto ndi = m_netDevices.find(device); if (ndi != m_netDevices.end()) { diff --git a/src/uan/examples/uan-6lowpan-example.cc b/src/uan/examples/uan-6lowpan-example.cc index 8b49a3f9d..4644cc0fb 100644 --- a/src/uan/examples/uan-6lowpan-example.cc +++ b/src/uan/examples/uan-6lowpan-example.cc @@ -131,7 +131,7 @@ UanExperiment::SetupCommunications() UanHelper uanHelper; NetDeviceContainer netDeviceContainer = uanHelper.Install(m_nodes, channel); EnergySourceContainer energySourceContainer; - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { energySourceContainer.Add((*node)->GetObject()->Get(0)); @@ -185,7 +185,7 @@ UanExperiment::PrintReceivedPacket(Ptr socket) void UanExperiment::SetupApplications() { - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { m_sockets[*node] = @@ -206,7 +206,7 @@ UanExperiment::SendPackets() { Ptr uniformRandomVariable = CreateObject(); - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); Ipv6Address dst = (*node)->GetObject()->GetInterface(1)->GetAddress(1).GetAddress(); node++; @@ -247,9 +247,7 @@ UanExperiment::Prepare() void UanExperiment::Teardown() { - std::map, Ptr>::iterator socket; - - for (socket = m_sockets.begin(); socket != m_sockets.end(); socket++) + for (auto socket = m_sockets.begin(); socket != m_sockets.end(); socket++) { socket->second->Close(); } diff --git a/src/uan/examples/uan-cw-example.cc b/src/uan/examples/uan-cw-example.cc index 658d96a36..4a617b2a4 100644 --- a/src/uan/examples/uan-cw-example.cc +++ b/src/uan/examples/uan-cw-example.cc @@ -106,7 +106,7 @@ void Experiment::UpdatePositions(NodeContainer& nodes) const { NS_LOG_DEBUG(Now().As(Time::S) << " Updating positions"); - NodeContainer::Iterator it = nodes.Begin(); + auto it = nodes.Begin(); Ptr uv = CreateObject(); for (; it != nodes.End(); it++) { diff --git a/src/uan/examples/uan-ipv4-example.cc b/src/uan/examples/uan-ipv4-example.cc index d4db2016a..b1343bc14 100644 --- a/src/uan/examples/uan-ipv4-example.cc +++ b/src/uan/examples/uan-ipv4-example.cc @@ -129,7 +129,7 @@ UanExperiment::SetupCommunications() UanHelper uanHelper; NetDeviceContainer netDeviceContainer = uanHelper.Install(m_nodes, channel); EnergySourceContainer energySourceContainer; - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { energySourceContainer.Add((*node)->GetObject()->Get(0)); @@ -176,7 +176,7 @@ UanExperiment::PrintReceivedPacket(Ptr socket) void UanExperiment::SetupApplications() { - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { m_sockets[*node] = @@ -197,7 +197,7 @@ UanExperiment::SendPackets() { Ptr uniformRandomVariable = CreateObject(); - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); Ipv4Address dst = (*node)->GetObject()->GetInterface(1)->GetAddress(0).GetLocal(); node++; @@ -238,9 +238,7 @@ UanExperiment::Prepare() void UanExperiment::Teardown() { - std::map, Ptr>::iterator socket; - - for (socket = m_sockets.begin(); socket != m_sockets.end(); socket++) + for (auto socket = m_sockets.begin(); socket != m_sockets.end(); socket++) { socket->second->Close(); } diff --git a/src/uan/examples/uan-ipv6-example.cc b/src/uan/examples/uan-ipv6-example.cc index 79e92a6e2..ed44d93ff 100644 --- a/src/uan/examples/uan-ipv6-example.cc +++ b/src/uan/examples/uan-ipv6-example.cc @@ -129,7 +129,7 @@ UanExperiment::SetupCommunications() UanHelper uanHelper; NetDeviceContainer netDeviceContainer = uanHelper.Install(m_nodes, channel); EnergySourceContainer energySourceContainer; - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { energySourceContainer.Add((*node)->GetObject()->Get(0)); @@ -180,7 +180,7 @@ UanExperiment::PrintReceivedPacket(Ptr socket) void UanExperiment::SetupApplications() { - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { m_sockets[*node] = @@ -201,7 +201,7 @@ UanExperiment::SendPackets() { Ptr uniformRandomVariable = CreateObject(); - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); Ipv6Address dst = (*node)->GetObject()->GetInterface(1)->GetAddress(1).GetAddress(); node++; @@ -242,9 +242,7 @@ UanExperiment::Prepare() void UanExperiment::Teardown() { - std::map, Ptr>::iterator socket; - - for (socket = m_sockets.begin(); socket != m_sockets.end(); socket++) + for (auto socket = m_sockets.begin(); socket != m_sockets.end(); socket++) { socket->second->Close(); } diff --git a/src/uan/examples/uan-raw-example.cc b/src/uan/examples/uan-raw-example.cc index a1e2c5dbb..ee58b382c 100644 --- a/src/uan/examples/uan-raw-example.cc +++ b/src/uan/examples/uan-raw-example.cc @@ -131,7 +131,7 @@ UanExperiment::SetupCommunications() UanHelper uanHelper; NetDeviceContainer netDeviceContainer = uanHelper.Install(m_nodes, channel); EnergySourceContainer energySourceContainer; - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { energySourceContainer.Add((*node)->GetObject()->Get(0)); @@ -165,7 +165,7 @@ UanExperiment::PrintReceivedPacket(Ptr socket) void UanExperiment::SetupApplications() { - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); PacketSocketHelper packetSocketHelper; while (node != m_nodes.End()) { @@ -187,7 +187,7 @@ UanExperiment::SendPackets() { Ptr uniformRandomVariable = CreateObject(); - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); Mac8Address dst = Mac8Address::ConvertFrom((*node)->GetDevice(0)->GetAddress()); node++; while (node != m_nodes.End()) @@ -230,9 +230,7 @@ UanExperiment::Prepare() void UanExperiment::Teardown() { - std::map, Ptr>::iterator socket; - - for (socket = m_sockets.begin(); socket != m_sockets.end(); socket++) + for (auto socket = m_sockets.begin(); socket != m_sockets.end(); socket++) { socket->second->Close(); } diff --git a/src/uan/helper/uan-helper.cc b/src/uan/helper/uan-helper.cc index 1c6992a87..1975540b6 100644 --- a/src/uan/helper/uan-helper.cc +++ b/src/uan/helper/uan-helper.cc @@ -113,7 +113,7 @@ UanHelper::EnableAscii(std::ostream& os, uint32_t nodeid, uint32_t deviceid) void UanHelper::EnableAscii(std::ostream& os, NetDeviceContainer d) { - for (NetDeviceContainer::Iterator i = d.Begin(); i != d.End(); ++i) + for (auto i = d.Begin(); i != d.End(); ++i) { Ptr dev = *i; EnableAscii(os, dev->GetNode()->GetId(), dev->GetIfIndex()); @@ -124,7 +124,7 @@ void UanHelper::EnableAscii(std::ostream& os, NodeContainer n) { NetDeviceContainer devs; - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; for (uint32_t j = 0; j < node->GetNDevices(); ++j) @@ -156,7 +156,7 @@ NetDeviceContainer UanHelper::Install(NodeContainer c, Ptr channel) const { NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { Ptr node = *i; @@ -193,7 +193,7 @@ UanHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr uan = DynamicCast(netDevice); diff --git a/src/uan/model/acoustic-modem-energy-model.cc b/src/uan/model/acoustic-modem-energy-model.cc index 79abcccf2..4d129b090 100644 --- a/src/uan/model/acoustic-modem-energy-model.cc +++ b/src/uan/model/acoustic-modem-energy-model.cc @@ -19,13 +19,14 @@ #include "acoustic-modem-energy-model.h" +#include "uan-net-device.h" +#include "uan-phy.h" + #include "ns3/double.h" #include "ns3/energy-source.h" #include "ns3/log.h" #include "ns3/simulator.h" #include "ns3/trace-source-accessor.h" -#include "ns3/uan-net-device.h" -#include "ns3/uan-phy.h" namespace ns3 { diff --git a/src/uan/model/uan-channel.cc b/src/uan/model/uan-channel.cc index 402e0da1c..8278ec9ee 100644 --- a/src/uan/model/uan-channel.cc +++ b/src/uan/model/uan-channel.cc @@ -84,7 +84,7 @@ UanChannel::Clear() return; } m_cleared = true; - UanDeviceList::iterator it = m_devList.begin(); + auto it = m_devList.begin(); for (; it != m_devList.end(); it++) { if (it->first) @@ -150,7 +150,7 @@ UanChannel::TxPacket(Ptr src, Ptr packet, double txPowerD Ptr senderMobility = nullptr; NS_LOG_DEBUG("Channel scheduling"); - for (UanDeviceList::const_iterator i = m_devList.begin(); i != m_devList.end(); i++) + for (auto i = m_devList.begin(); i != m_devList.end(); i++) { if (src == i->second) { @@ -160,7 +160,7 @@ UanChannel::TxPacket(Ptr src, Ptr packet, double txPowerD } NS_ASSERT(senderMobility); uint32_t j = 0; - UanDeviceList::const_iterator i = m_devList.begin(); + auto i = m_devList.begin(); for (; i != m_devList.end(); i++) { if (src != i->second) diff --git a/src/uan/model/uan-channel.h b/src/uan/model/uan-channel.h index 8921eed93..0a0e8768e 100644 --- a/src/uan/model/uan-channel.h +++ b/src/uan/model/uan-channel.h @@ -20,11 +20,12 @@ #ifndef UAN_CHANNEL_H #define UAN_CHANNEL_H +#include "uan-noise-model.h" +#include "uan-prop-model.h" + #include "ns3/channel.h" #include "ns3/net-device.h" #include "ns3/packet.h" -#include "ns3/uan-noise-model.h" -#include "ns3/uan-prop-model.h" #include #include diff --git a/src/uan/model/uan-header-rc.cc b/src/uan/model/uan-header-rc.cc index ef992d4b0..f355fba80 100644 --- a/src/uan/model/uan-header-rc.cc +++ b/src/uan/model/uan-header-rc.cc @@ -607,7 +607,7 @@ UanHeaderRcAck::Serialize(Buffer::Iterator start) const { start.WriteU8(m_frameNo); start.WriteU8(GetNoNacks()); - std::set::iterator it = m_nackedFrames.begin(); + auto it = m_nackedFrames.begin(); for (; it != m_nackedFrames.end(); it++) { start.WriteU8(*it); @@ -635,7 +635,7 @@ UanHeaderRcAck::Print(std::ostream& os) const << " Nacked: "; if (GetNoNacks() > 0) { - std::set::iterator it = m_nackedFrames.begin(); + auto it = m_nackedFrames.begin(); os << (uint32_t)*it; it++; for (; it != m_nackedFrames.end(); it++) diff --git a/src/uan/model/uan-mac-cw.cc b/src/uan/model/uan-mac-cw.cc index 9a50e7d9e..fe906a903 100644 --- a/src/uan/model/uan-mac-cw.cc +++ b/src/uan/model/uan-mac-cw.cc @@ -19,12 +19,13 @@ #include "uan-mac-cw.h" +#include "uan-header-common.h" + #include "ns3/attribute.h" #include "ns3/double.h" #include "ns3/log.h" #include "ns3/nstime.h" #include "ns3/trace-source-accessor.h" -#include "ns3/uan-header-common.h" #include "ns3/uinteger.h" namespace ns3 @@ -150,7 +151,7 @@ UanMacCw::Enqueue(Ptr packet, uint16_t protocolNumber, const Address& de m_pktTx = packet; m_pktTxProt = GetTxModeIndex(); m_state = CCABUSY; - uint32_t cw = (uint32_t)m_rv->GetValue(0, m_cw); + auto cw = (uint32_t)m_rv->GetValue(0, m_cw); m_savedDelayS = cw * m_slotTime; m_sendTime = Simulator::Now() + m_savedDelayS; NS_LOG_DEBUG("Time " << Now().As(Time::S) << ": Addr " << GetAddress() diff --git a/src/uan/model/uan-mac-cw.h b/src/uan/model/uan-mac-cw.h index 71124a0f2..d89d28f85 100644 --- a/src/uan/model/uan-mac-cw.h +++ b/src/uan/model/uan-mac-cw.h @@ -20,13 +20,14 @@ #ifndef UAN_MAC_CW_H #define UAN_MAC_CW_H +#include "uan-mac.h" +#include "uan-phy.h" +#include "uan-tx-mode.h" + #include "ns3/mac8-address.h" #include "ns3/nstime.h" #include "ns3/random-variable-stream.h" #include "ns3/simulator.h" -#include "ns3/uan-mac.h" -#include "ns3/uan-phy.h" -#include "ns3/uan-tx-mode.h" namespace ns3 { diff --git a/src/uan/model/uan-mac-rc-gw.cc b/src/uan/model/uan-mac-rc-gw.cc index e69cfd7a4..1df6b5814 100644 --- a/src/uan/model/uan-mac-rc-gw.cc +++ b/src/uan/model/uan-mac-rc-gw.cc @@ -84,7 +84,7 @@ UanMacRcGw::Clear() m_phy = nullptr; } m_propDelay.clear(); - std::map::iterator it = m_ackData.begin(); + auto it = m_ackData.begin(); for (; it != m_ackData.end(); it++) { it->second.rxFrames.clear(); @@ -262,7 +262,7 @@ UanMacRcGw::ReceivePacket(Ptr pkt, double /* sinr */, UanTxMode mode) NS_LOG_DEBUG(Now().As(Time::S) << " GW storing reservation from " << ch.GetSrc() << " with length " << req.length); m_requests.insert(std::make_pair(ch.GetSrc(), req)); - std::map::iterator it = m_propDelay.find(ch.GetSrc()); + auto it = m_propDelay.find(ch.GetSrc()); if (it == m_propDelay.end()) { m_sortedRes.insert(std::make_pair(m_maxDelta, ch.GetSrc())); @@ -292,7 +292,7 @@ UanMacRcGw::ReceivePacket(Ptr pkt, double /* sinr */, UanTxMode mode) void UanMacRcGw::StartCycle() { - uint32_t numRts = static_cast(m_sortedRes.size()); + auto numRts = static_cast(m_sortedRes.size()); if (numRts) { @@ -309,7 +309,7 @@ UanMacRcGw::StartCycle() Time pDelay = Seconds(0); if (numRts > 0) { - std::map::iterator rit = m_requests.begin(); + auto rit = m_requests.begin(); for (; rit != m_requests.end(); rit++) { totalBytes += (*rit).second.length; @@ -408,7 +408,7 @@ UanMacRcGw::StartCycle() m_state = CTSING; Simulator::Schedule(nextEarliest, &UanMacRcGw::CycleStarted, this); - std::set>::iterator it = m_sortedRes.begin(); + auto it = m_sortedRes.begin(); Time minPdelay = (*it).first; Ptr cts = Create(); @@ -487,7 +487,7 @@ UanMacRcGw::EndCycle() Time ackTime = Seconds(m_ackSize * 8.0 / m_phy->GetMode(m_currentRateNum).GetDataRateBps()); - std::map::iterator it = m_ackData.begin(); + auto it = m_ackData.begin(); for (; it != m_ackData.end(); it++) { Mac8Address dest = (*it).first; @@ -507,7 +507,7 @@ UanMacRcGw::EndCycle() ch.SetType(UanMacRc::TYPE_ACK); UanHeaderRcAck ah; ah.SetFrameNo(data.frameNo); - std::list::iterator nit = toNack.begin(); + auto nit = toNack.begin(); for (; nit != toNack.end(); nit++) { ah.AddNackedFrame(static_cast(*nit)); @@ -598,7 +598,7 @@ UanMacRcGw::GetExpPdk() { uint32_t n = m_numNodes; std::vector pds; - std::map::iterator pdit = m_propDelay.begin(); + auto pdit = m_propDelay.begin(); for (; pdit != m_propDelay.end(); pdit++) { @@ -664,7 +664,7 @@ UanMacRcGw::CompExpMinIndex(uint32_t n, uint32_t k) double sum = 0; for (uint32_t i = 1; i <= n - k + 1; i++) { - double nChK = static_cast(NchooseK(n, k)); + auto nChK = static_cast(NchooseK(n, k)); double p = (nChK > 0) ? (static_cast(NchooseK(n - i, k - 1)) / nChK) : DBL_MAX; sum += p * i; } @@ -674,7 +674,7 @@ UanMacRcGw::CompExpMinIndex(uint32_t n, uint32_t k) double UanMacRcGw::ComputePiK(uint32_t a, uint32_t n, uint32_t k) { - double nck = (double)NchooseK(n, k); + auto nck = (double)NchooseK(n, k); return nck * std::pow((std::exp((double)a / (double)n) - 1.0), (double)k) * std::exp(-((double)a)); } @@ -724,7 +724,7 @@ UanMacRcGw::FindOptA() { double tput = 0; uint32_t a = 1; - while (1) + while (true) { double newtput = ComputeExpS(a, m_frameSize); if (newtput < tput) diff --git a/src/uan/model/uan-mac-rc.cc b/src/uan/model/uan-mac-rc.cc index af1e0a8e8..f6a5abbfc 100644 --- a/src/uan/model/uan-mac-rc.cc +++ b/src/uan/model/uan-mac-rc.cc @@ -73,8 +73,7 @@ Reservation::Reservation(std::list, Mac8Address>>& list, Reservation::~Reservation() { - std::list, Mac8Address>>::iterator it; - for (it = m_pktList.begin(); it != m_pktList.end(); it++) + for (auto it = m_pktList.begin(); it != m_pktList.end(); it++) { it->first = Ptr((Packet*)nullptr); } @@ -185,8 +184,7 @@ UanMacRc::Clear() m_phy->Clear(); m_phy = nullptr; } - std::list, Mac8Address>>::iterator it; - for (it = m_pktQueue.begin(); it != m_pktQueue.end(); it++) + for (auto it = m_pktQueue.begin(); it != m_pktQueue.end(); it++) { it->first = nullptr; } @@ -424,7 +422,7 @@ UanMacRc::ScheduleData(const UanHeaderRcCts& ctsh, { NS_ASSERT(m_state == RTSSENT || m_state == GWPSENT); - std::list::iterator it = m_resList.begin(); + auto it = m_resList.begin(); for (; it != m_resList.end(); it++) { if (it->GetFrameNo() == ctsh.GetFrameNo()) @@ -455,8 +453,7 @@ UanMacRc::ScheduleData(const UanHeaderRcCts& ctsh, Time frameDelay = Seconds(0); const std::list, Mac8Address>> l = it->GetPktList(); - std::list, Mac8Address>>::const_iterator pit; - pit = l.begin(); + auto pit = l.begin(); for (uint8_t i = 0; i < it->GetNoFrames(); i++, pit++) { @@ -544,7 +541,7 @@ UanMacRc::ProcessAck(Ptr ack) UanHeaderRcAck ah; ack->RemoveHeader(ah); - std::list::iterator it = m_resList.begin(); + auto it = m_resList.begin(); for (; it != m_resList.end(); it++) { if (it->GetFrameNo() == ah.GetFrameNo()) @@ -565,11 +562,10 @@ UanMacRc::ProcessAck(Ptr ack) if (ah.GetNoNacks() > 0) { const std::list, Mac8Address>> l = it->GetPktList(); - std::list, Mac8Address>>::const_iterator pit; - pit = l.begin(); + auto pit = l.begin(); const std::set& nacks = ah.GetNackedFrames(); - std::set::iterator nit = nacks.begin(); + auto nit = nacks.begin(); uint8_t pnum = 0; for (; nit != nacks.end(); nit++) { @@ -617,7 +613,7 @@ UanMacRc::Associate() m_resList.push_back(res); Ptr phyDual = m_phy->GetObject(); bool phy1ok = IsPhy1Ok(); - if (phy1ok && !phyDual->IsPhy2Tx() & !m_rtsBlocked) + if (phy1ok && !phyDual->IsPhy2Tx() && !m_rtsBlocked) { Ptr pkt = Create(0); pkt->AddHeader(CreateRtsHeader(res)); diff --git a/src/uan/model/uan-noise-model-default.cc b/src/uan/model/uan-noise-model-default.cc index 629fb8895..664517aca 100644 --- a/src/uan/model/uan-noise-model-default.cc +++ b/src/uan/model/uan-noise-model-default.cc @@ -57,7 +57,7 @@ UanNoiseModelDefault::GetTypeId() } // Common acoustic noise formulas. These can be found -// in "Priniciples of Underwater Sound" by Robert J. Urick +// in "Principles of Underwater Sound" by Robert J. Urick double UanNoiseModelDefault::GetNoiseDbHz(double fKhz) const { @@ -71,18 +71,18 @@ UanNoiseModelDefault::GetNoiseDbHz(double fKhz) const double thermalDb; double noiseDb; - turbDb = 17.0 - 30.0 * std::log10(fKhz); + double log_fKhz = std::log10(fKhz); + + turbDb = 17.0 - 30.0 * log_fKhz; turb = std::pow(10.0, turbDb * 0.1); - shipDb = - 40.0 + 20.0 * (m_shipping - 0.5) + 26.0 * std::log10(fKhz) - 60.0 * std::log10(fKhz + 0.03); + shipDb = 40.0 + 20.0 * (m_shipping - 0.5) + 26.0 * log_fKhz - 60.0 * std::log10(fKhz + 0.03); ship = std::pow(10.0, (shipDb * 0.1)); - windDb = 50.0 + 7.5 * std::pow(m_wind, 0.5) + 20.0 * std::log10(fKhz) - - 40.0 * std::log10(fKhz + 0.4); + windDb = 50.0 + 7.5 * std::pow(m_wind, 0.5) + 20.0 * log_fKhz - 40.0 * std::log10(fKhz + 0.4); wind = std::pow(10.0, windDb * 0.1); - thermalDb = -15 + 20 * std::log10(fKhz); + thermalDb = -15 + 20 * log_fKhz; thermal = std::pow(10, thermalDb * 0.1); noiseDb = 10 * std::log10(turb + ship + wind + thermal); diff --git a/src/uan/model/uan-noise-model-default.h b/src/uan/model/uan-noise-model-default.h index 8646645da..960e4504e 100644 --- a/src/uan/model/uan-noise-model-default.h +++ b/src/uan/model/uan-noise-model-default.h @@ -20,9 +20,10 @@ #ifndef UAN_NOISE_MODEL_DEFAULT_H #define UAN_NOISE_MODEL_DEFAULT_H +#include "uan-noise-model.h" + #include "ns3/attribute.h" #include "ns3/object.h" -#include "ns3/uan-noise-model.h" namespace ns3 { diff --git a/src/uan/model/uan-phy-dual.cc b/src/uan/model/uan-phy-dual.cc index 52a4aa190..4985b5e09 100644 --- a/src/uan/model/uan-phy-dual.cc +++ b/src/uan/model/uan-phy-dual.cc @@ -79,7 +79,7 @@ UanPhyCalcSinrDual::CalcSinrDb(Ptr pkt, } double intKp = -DbToKp(rxPowerDb); // This packet is in the arrivalList - UanTransducer::ArrivalList::const_iterator it = arrivalList.begin(); + auto it = arrivalList.begin(); for (; it != arrivalList.end(); it++) { // Only count interference if there is overlap in incoming frequency diff --git a/src/uan/model/uan-phy-dual.h b/src/uan/model/uan-phy-dual.h index 5d17a676d..847989610 100644 --- a/src/uan/model/uan-phy-dual.h +++ b/src/uan/model/uan-phy-dual.h @@ -21,7 +21,7 @@ #ifndef UAN_PHY_DUAL_H #define UAN_PHY_DUAL_H -#include "ns3/uan-phy.h" +#include "uan-phy.h" namespace ns3 { diff --git a/src/uan/model/uan-phy-gen.cc b/src/uan/model/uan-phy-gen.cc index ee238448a..257a4f5a2 100644 --- a/src/uan/model/uan-phy-gen.cc +++ b/src/uan/model/uan-phy-gen.cc @@ -20,11 +20,12 @@ #include "uan-phy-gen.h" +#include "acoustic-modem-energy-model.h" #include "uan-channel.h" #include "uan-net-device.h" #include "uan-transducer.h" +#include "uan-tx-mode.h" -#include "ns3/acoustic-modem-energy-model.h" #include "ns3/double.h" #include "ns3/energy-source-container.h" #include "ns3/log.h" @@ -34,7 +35,6 @@ #include "ns3/string.h" #include "ns3/trace-source-accessor.h" #include "ns3/traced-callback.h" -#include "ns3/uan-tx-mode.h" #include "ns3/uinteger.h" namespace ns3 @@ -83,7 +83,7 @@ UanPhyCalcSinrDefault::CalcSinrDb(Ptr pkt, } double intKp = -DbToKp(rxPowerDb); // This packet is in the arrivalList - UanTransducer::ArrivalList::const_iterator it = arrivalList.begin(); + auto it = arrivalList.begin(); for (; it != arrivalList.end(); it++) { intKp += DbToKp(it->GetRxPowerDb()); @@ -143,7 +143,7 @@ UanPhyCalcSinrFhFsk::CalcSinrDb(Ptr pkt, // Get maximum arrival offset double maxAmp = -1; Time maxTapDelay(0); - UanPdp::Iterator pit = pdp.GetBegin(); + auto pit = pdp.GetBegin(); for (; pit != pdp.GetEnd(); pit++) { if (std::abs(pit->GetAmp()) > maxAmp) @@ -161,7 +161,7 @@ UanPhyCalcSinrFhFsk::CalcSinrDb(Ptr pkt, // eq. 14 double isiUpa = DbToKp(rxPowerDb) * pdp.SumTapsFromMaxNc(ts + clearingTime, ts); // added DpToKp() - UanTransducer::ArrivalList::const_iterator it = arrivalList.begin(); + auto it = arrivalList.begin(); double intKp = -DbToKp(effRxPowerDb); for (; it != arrivalList.end(); it++) { @@ -312,7 +312,7 @@ UanPhyPerCommonModes::CalcPer(Ptr pkt, double sinrDb, UanTxMode mode) // generic EbNo EbNo *= mode.GetDataRateBps() / mode.GetBandwidthHz(); - double M = (double)mode.GetConstellationSize(); + auto M = (double)mode.GetConstellationSize(); // standard squared quantized QAM, even number of bits per symbol supported int log2sqrtM = (int)::std::log2(sqrt(M)); @@ -1086,7 +1086,7 @@ UanPhyGen::GetInterferenceDb(Ptr pkt) { const UanTransducer::ArrivalList& arrivalList = m_transducer->GetArrivalList(); - UanTransducer::ArrivalList::const_iterator it = arrivalList.begin(); + auto it = arrivalList.begin(); double interfPower = 0; @@ -1116,7 +1116,7 @@ UanPhyGen::KpToDb(double kp) void UanPhyGen::NotifyListenersRxStart() { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyRxStart(); @@ -1126,7 +1126,7 @@ UanPhyGen::NotifyListenersRxStart() void UanPhyGen::NotifyListenersRxGood() { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyRxEndOk(); @@ -1136,7 +1136,7 @@ UanPhyGen::NotifyListenersRxGood() void UanPhyGen::NotifyListenersRxBad() { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyRxEndError(); @@ -1146,7 +1146,7 @@ UanPhyGen::NotifyListenersRxBad() void UanPhyGen::NotifyListenersCcaStart() { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyCcaStart(); @@ -1156,7 +1156,7 @@ UanPhyGen::NotifyListenersCcaStart() void UanPhyGen::NotifyListenersCcaEnd() { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyCcaEnd(); @@ -1166,7 +1166,7 @@ UanPhyGen::NotifyListenersCcaEnd() void UanPhyGen::NotifyListenersTxStart(Time duration) { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyTxStart(duration); @@ -1176,7 +1176,7 @@ UanPhyGen::NotifyListenersTxStart(Time duration) void UanPhyGen::NotifyListenersTxEnd() { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyTxEnd(); diff --git a/src/uan/model/uan-phy.h b/src/uan/model/uan-phy.h index 9bfeba43a..70c49f18d 100644 --- a/src/uan/model/uan-phy.h +++ b/src/uan/model/uan-phy.h @@ -21,12 +21,13 @@ #ifndef UAN_PHY_H #define UAN_PHY_H +#include "uan-mac.h" +#include "uan-prop-model.h" +#include "uan-transducer.h" +#include "uan-tx-mode.h" + #include "ns3/device-energy-model.h" #include "ns3/object.h" -#include "ns3/uan-mac.h" -#include "ns3/uan-prop-model.h" -#include "ns3/uan-transducer.h" -#include "ns3/uan-tx-mode.h" namespace ns3 { diff --git a/src/uan/model/uan-prop-model.cc b/src/uan/model/uan-prop-model.cc index d077128f5..bfdd582d9 100644 --- a/src/uan/model/uan-prop-model.cc +++ b/src/uan/model/uan-prop-model.cc @@ -33,7 +33,7 @@ operator<<(std::ostream& os, const UanPdp& pdp) os << pdp.GetNTaps() << '|'; os << pdp.GetResolution().GetSeconds() << '|'; - UanPdp::Iterator it = pdp.m_taps.begin(); + auto it = pdp.m_taps.begin(); for (; it != pdp.m_taps.end(); it++) { os << (*it).GetAmp() << '|'; diff --git a/src/uan/model/uan-transducer-hd.cc b/src/uan/model/uan-transducer-hd.cc index f82701580..d7897e0c5 100644 --- a/src/uan/model/uan-transducer-hd.cc +++ b/src/uan/model/uan-transducer-hd.cc @@ -21,12 +21,12 @@ #include "uan-channel.h" #include "uan-phy.h" +#include "uan-prop-model.h" #include "ns3/double.h" #include "ns3/log.h" #include "ns3/pointer.h" #include "ns3/simulator.h" -#include "ns3/uan-prop-model.h" namespace ns3 { @@ -62,7 +62,7 @@ UanTransducerHd::Clear() m_channel = nullptr; } - UanPhyList::iterator it = m_phyList.begin(); + auto it = m_phyList.begin(); for (; it != m_phyList.end(); it++) { if (*it) @@ -71,7 +71,7 @@ UanTransducerHd::Clear() *it = nullptr; } } - ArrivalList::iterator ait = m_arrivalList.begin(); + auto ait = m_arrivalList.begin(); for (; ait != m_arrivalList.end(); ait++) { ait->GetPacket() = nullptr; @@ -164,7 +164,7 @@ UanTransducerHd::Receive(Ptr packet, double rxPowerDb, UanTxMode txMode, if (m_state == RX) { NS_LOG_DEBUG("Transducer state = RX"); - UanPhyList::const_iterator it = m_phyList.begin(); + auto it = m_phyList.begin(); for (; it != m_phyList.end(); it++) { NS_LOG_DEBUG("Calling StartRx"); @@ -191,7 +191,7 @@ UanTransducerHd::Transmit(Ptr src, Ptr packet, double txPowerDb, NS_LOG_DEBUG("Transducer transmitting: TX delay = " << delay << " seconds for packet size " << packet->GetSize() << " bytes and rate = " << txMode.GetDataRateBps() << " bps"); - UanPhyList::const_iterator it = m_phyList.begin(); + auto it = m_phyList.begin(); for (; it != m_phyList.end(); it++) { if (src != (*it)) @@ -245,7 +245,7 @@ void UanTransducerHd::RemoveArrival(UanPacketArrival arrival) { // Remove entry from arrival list - ArrivalList::iterator it = m_arrivalList.begin(); + auto it = m_arrivalList.begin(); for (; it != m_arrivalList.end(); it++) { if (it->GetPacket() == arrival.GetPacket()) @@ -254,7 +254,7 @@ UanTransducerHd::RemoveArrival(UanPacketArrival arrival) break; } } - UanPhyList::const_iterator ait = m_phyList.begin(); + auto ait = m_phyList.begin(); for (; ait != m_phyList.end(); ait++) { (*ait)->NotifyIntChange(); diff --git a/src/uan/model/uan-transducer.h b/src/uan/model/uan-transducer.h index 9f50204b0..24297b9fd 100644 --- a/src/uan/model/uan-transducer.h +++ b/src/uan/model/uan-transducer.h @@ -20,11 +20,11 @@ #ifndef UAN_TRANSDUCER_H #define UAN_TRANSDUCER_H +#include "uan-prop-model.h" #include "uan-tx-mode.h" #include "ns3/object.h" #include "ns3/packet.h" -#include "ns3/uan-prop-model.h" #include diff --git a/src/uan/model/uan-tx-mode.cc b/src/uan/model/uan-tx-mode.cc index 06b438d00..0268527d9 100644 --- a/src/uan/model/uan-tx-mode.cc +++ b/src/uan/model/uan-tx-mode.cc @@ -116,7 +116,7 @@ UanTxModeFactory::~UanTxModeFactory() bool UanTxModeFactory::NameUsed(std::string name) { - std::map::iterator it = m_modes.begin(); + auto it = m_modes.begin(); for (; it != m_modes.end(); it++) { @@ -176,7 +176,7 @@ UanTxModeFactory::GetModeItem(uint32_t uid) UanTxModeFactory::UanTxModeItem& UanTxModeFactory::GetModeItem(std::string name) { - std::map::iterator it = m_modes.begin(); + auto it = m_modes.begin(); for (; it != m_modes.end(); it++) { if ((*it).second.m_name == name) @@ -237,7 +237,7 @@ UanModesList::DeleteMode(uint32_t modeNum) { NS_ASSERT(modeNum < m_modes.size()); - std::vector::iterator it = m_modes.begin(); + auto it = m_modes.begin(); for (uint32_t i = 0; i < modeNum; i++) { it++; diff --git a/src/visualizer/model/pyviz.cc b/src/visualizer/model/pyviz.cc index 632d005ab..5605fbeaf 100644 --- a/src/visualizer/model/pyviz.cc +++ b/src/visualizer/model/pyviz.cc @@ -51,7 +51,7 @@ PathSplit(std::string str) } str = str.substr(cutAt + 1); } - if (str.length() > 0) + if (!str.empty()) { results.push_back(str); } @@ -298,8 +298,7 @@ PyViz::SimulatorRunUntil(Time time) Time expirationTime = Simulator::Now() - Seconds(10); // Clear very old transmission records - for (std::map::iterator iter = m_txRecords.begin(); - iter != m_txRecords.end();) + for (auto iter = m_txRecords.begin(); iter != m_txRecords.end();) { if (iter->second.time < expirationTime) { @@ -312,8 +311,7 @@ PyViz::SimulatorRunUntil(Time time) } // Clear very old packets of interest - for (std::map::iterator iter = m_packetsOfInterest.begin(); - iter != m_packetsOfInterest.end();) + for (auto iter = m_packetsOfInterest.begin(); iter != m_packetsOfInterest.end();) { if (iter->second < expirationTime) { @@ -385,8 +383,7 @@ PyViz::TransmissionSampleKey::operator==(const PyViz::TransmissionSampleKey& oth PyViz::NetDeviceStatistics& PyViz::FindNetDeviceStatistics(int node, int interface) { - std::map>::iterator nodeStatsIter = - m_nodesStatistics.find(node); + auto nodeStatsIter = m_nodesStatistics.find(node); std::vector* stats; if (nodeStatsIter == m_nodesStatistics.end()) { @@ -404,8 +401,7 @@ PyViz::FindNetDeviceStatistics(int node, int interface) bool PyViz::GetPacketCaptureOptions(uint32_t nodeId, const PacketCaptureOptions** outOptions) const { - std::map::const_iterator iter = - m_packetCaptureOptions.find(nodeId); + auto iter = m_packetCaptureOptions.find(nodeId); if (iter == m_packetCaptureOptions.end()) { return false; @@ -444,7 +440,7 @@ PyViz::FilterPacket(Ptr packet, const PacketCaptureOptions& option while (metadataIterator.HasNext()) { PacketMetadata::Item item = metadataIterator.Next(); - std::set::iterator missingIter = missingHeaders.find(item.tid); + auto missingIter = missingHeaders.find(item.tid); if (missingIter != missingHeaders.end()) { missingHeaders.erase(missingIter); @@ -495,7 +491,7 @@ PyViz::TraceDevQueueDrop(std::string context, Ptr packet) } } - std::map, uint32_t>::iterator iter = m_packetDrops.find(node); + auto iter = m_packetDrops.find(node); if (iter == m_packetDrops.end()) { m_packetDrops[node] = packet->GetSize(); @@ -698,8 +694,7 @@ PyViz::TraceNetDevRxCommon(const std::string& context, Ptr channel = device->GetChannel(); - std::map::iterator recordIter = - m_txRecords.find(TxRecordKey(channel, uid)); + auto recordIter = m_txRecords.find(TxRecordKey(channel, uid)); if (recordIter == m_txRecords.end()) { @@ -722,10 +717,7 @@ PyViz::TraceNetDevRxCommon(const std::string& context, NS_LOG_DEBUG("m_transmissionSamples begin:"); if (g_log.IsEnabled(ns3::LOG_DEBUG)) { - for (std::map::const_iterator iter = - m_transmissionSamples.begin(); - iter != m_transmissionSamples.end(); - iter++) + for (auto iter = m_transmissionSamples.begin(); iter != m_transmissionSamples.end(); iter++) { NS_LOG_DEBUG(iter->first.transmitter << "/" << iter->first.transmitter->GetId() << ", " << iter->first.receiver @@ -736,8 +728,7 @@ PyViz::TraceNetDevRxCommon(const std::string& context, NS_LOG_DEBUG("m_transmissionSamples end."); #endif - std::map::iterator iter = - m_transmissionSamples.find(key); + auto iter = m_transmissionSamples.find(key); if (iter == m_transmissionSamples.end()) { @@ -867,10 +858,7 @@ PyViz::GetTransmissionSamples() const { NS_LOG_DEBUG("GetTransmissionSamples BEGIN"); TransmissionSampleList list; - for (std::map::const_iterator iter = - m_transmissionSamples.begin(); - iter != m_transmissionSamples.end(); - iter++) + for (auto iter = m_transmissionSamples.begin(); iter != m_transmissionSamples.end(); iter++) { TransmissionSample sample; sample.transmitter = iter->first.transmitter; @@ -890,9 +878,7 @@ PyViz::GetPacketDropSamples() const { NS_LOG_DEBUG("GetPacketDropSamples BEGIN"); PacketDropSampleList list; - for (std::map, uint32_t>::const_iterator iter = m_packetDrops.begin(); - iter != m_packetDrops.end(); - iter++) + for (auto iter = m_packetDrops.begin(); iter != m_packetDrops.end(); iter++) { PacketDropSample sample; sample.transmitter = iter->first; @@ -915,10 +901,7 @@ std::vector PyViz::GetNodesStatistics() const { std::vector retval; - for (std::map>::const_iterator iter = - m_nodesStatistics.begin(); - iter != m_nodesStatistics.end(); - iter++) + for (auto iter = m_nodesStatistics.begin(); iter != m_nodesStatistics.end(); iter++) { NodeStatistics stats = {iter->first, iter->second}; retval.push_back(stats); @@ -931,7 +914,7 @@ PyViz::GetLastPackets(uint32_t nodeId) const { NS_LOG_DEBUG("GetLastPackets: " << nodeId); - std::map::const_iterator iter = m_lastPackets.find(nodeId); + auto iter = m_lastPackets.find(nodeId); if (iter != m_lastPackets.end()) { return iter->second; diff --git a/src/visualizer/visualizer/core.py b/src/visualizer/visualizer/core.py index 34185b787..bedc9d24f 100644 --- a/src/visualizer/visualizer/core.py +++ b/src/visualizer/visualizer/core.py @@ -69,7 +69,7 @@ else: _import_error = None try: - import ipython_viewxxxxxxxxxx + from . import ipython_view except ImportError: ipython_view = None diff --git a/src/visualizer/visualizer/ipython_view.py b/src/visualizer/visualizer/ipython_view.py index 49a993350..4a586331d 100644 --- a/src/visualizer/visualizer/ipython_view.py +++ b/src/visualizer/visualizer/ipython_view.py @@ -13,15 +13,21 @@ is available at U{http://www.opensource.org/licenses/bsd-license.php} # this file is a modified version of source code from the Accerciser project # https://wiki.gnome.org/Apps/Accerciser -import gtk, gobject +import gi +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GLib +from gi.repository import Pango + +from pkg_resources import parse_version + import re import sys import os -from gi.repository import Pango -from StringIO import StringIO -import IPython -from pkg_resources import parse_version +from io import StringIO +from functools import reduce ## Try to import IPython try: @@ -41,6 +47,12 @@ class IterableIPShell: # history level ## @var complete_sep # separators + ## @var no_input_splitter + # no input splitter + ## @var lines + # lines + ## @var indent_spaces + # indent spaces ## @var prompt # prompt ## @var header @@ -52,8 +64,8 @@ class IterableIPShell: ## @var raw_input # raw input ## Constructor - def __init__(self,argv=None,user_ns=None,user_global_ns=None, - cin=None, cout=None,cerr=None, input_func=None): + def __init__(self, argv=[], user_ns=None, user_global_ns=None, + cin=None, cout=None, cerr=None, input_func=None): """! Initializer @param self: this object @@ -67,45 +79,47 @@ class IterableIPShell: """ io = IPython.utils.io if input_func: - if parse_version(IPython.release.version) >= parse_version("1.2.1"): - IPython.terminal.interactiveshell.raw_input_original = input_func - else: - IPython.frontend.terminal.interactiveshell.raw_input_original = input_func - if cin: - io.stdin = io.IOStream(cin) - if cout: - io.stdout = io.IOStream(cout) - if cerr: - io.stderr = io.IOStream(cerr) + IPython.terminal.interactiveshell.raw_input_original = input_func + if IPython.version_info < (8,): + if cin: + io.stdin = io.IOStream(cin) + if cout: + io.stdout = io.IOStream(cout) + if cerr: + io.stderr = io.IOStream(cerr) + else: + if cin: + sys.stdin = cin + if cout: + sys.stdout = cout + if cerr: + sys.stderr = cerr # This is to get rid of the blockage that occurs during # IPython.Shell.InteractiveShell.user_setup() - io.raw_input = lambda x: None os.environ['TERM'] = 'dumb' excepthook = sys.excepthook - from IPython.config.loader import Config + from traitlets.config.loader import Config cfg = Config() cfg.InteractiveShell.colors = "Linux" + cfg.Completer.use_jedi = False - # InteractiveShell's __init__ overwrites io.stdout,io.stderr with - # sys.stdout, sys.stderr, this makes sure they are right - # - old_stdout, old_stderr = sys.stdout, sys.stderr - sys.stdout, sys.stderr = io.stdout.stream, io.stderr.stream + if IPython.version_info < (8,): + # InteractiveShell's __init__ overwrites io.stdout,io.stderr with + # sys.stdout, sys.stderr, this makes sure they are right + old_stdout, old_stderr = sys.stdout, sys.stderr + sys.stdout, sys.stderr = io.stdout.stream, io.stderr.stream # InteractiveShell inherits from SingletonConfigurable, so use instance() # - if parse_version(IPython.release.version) >= parse_version("1.2.1"): - self.IP = IPython.terminal.embed.InteractiveShellEmbed.instance(\ - config=cfg, user_ns=user_ns) - else: - self.IP = IPython.frontend.terminal.embed.InteractiveShellEmbed.instance(\ + self.IP = IPython.terminal.embed.InteractiveShellEmbed.instance(\ config=cfg, user_ns=user_ns) - sys.stdout, sys.stderr = old_stdout, old_stderr + if IPython.version_info < (8,): + sys.stdout, sys.stderr = old_stdout, old_stderr self.IP.system = lambda cmd: self.shell(self.IP.var_expand(cmd), header='IPython system call: ') @@ -120,11 +134,17 @@ class IterableIPShell: self.complete_sep = re.compile('[\s\{\}\[\]\(\)]') self.updateNamespace({'exit':lambda:None}) self.updateNamespace({'quit':lambda:None}) - self.IP.readline_startup_hook(self.IP.pre_readline) # Workaround for updating namespace with sys.modules # self.__update_namespace() + # Avoid using input splitter when not really needed. + # Perhaps it could work even before 5.8.0 + # But it definitely does not work any more with >= 7.0.0 + self.no_input_splitter = parse_version(IPython.release.version) >= parse_version('5.8.0') + self.lines = [] + self.indent_spaces = '' + def __update_namespace(self): """! Update self.IP namespace for autocompletion with sys.modules @@ -140,11 +160,17 @@ class IterableIPShell: @return none """ self.history_level = 0 - orig_stdout = sys.stdout - sys.stdout = IPython.utils.io.stdout - orig_stdin = sys.stdin - sys.stdin = IPython.utils.io.stdin; + if IPython.version_info < (8,): + # this is needed because some functions in IPython use 'print' to print + # output (like 'who') + + orig_stdout = sys.stdout + sys.stdout = IPython.utils.io.stdout + + orig_stdin = sys.stdin + sys.stdin = IPython.utils.io.stdin + self.prompt = self.generatePrompt(self.iter_more) self.IP.hooks.pre_prompt_hook() @@ -160,21 +186,26 @@ class IterableIPShell: line = self.IP.raw_input(self.prompt) except KeyboardInterrupt: self.IP.write('\nKeyboardInterrupt\n') - self.IP.input_splitter.reset() + if self.no_input_splitter: + self.lines = [] + else: + self.IP.input_splitter.reset() except: self.IP.showtraceback() else: - self.IP.input_splitter.push(line) - self.iter_more = self.IP.input_splitter.push_accepts_more() - self.prompt = self.generatePrompt(self.iter_more) - if (self.IP.SyntaxTB.last_syntax_error and - self.IP.autoedit_syntax): - self.IP.edit_syntax_error() + if self.no_input_splitter: + self.lines.append(line) + (status, self.indent_spaces) = self.IP.check_complete('\n'.join(self.lines)) + self.iter_more = status == 'incomplete' + else: + self.IP.input_splitter.push(line) + self.iter_more = self.IP.input_splitter.push_accepts_more() if not self.iter_more: - if parse_version(IPython.release.version) >= parse_version("2.0.0-dev"): - source_raw = self.IP.input_splitter.raw_reset() + if self.no_input_splitter: + source_raw = '\n'.join(self.lines) + self.lines = [] else: - source_raw = self.IP.input_splitter.source_raw_reset()[1] + source_raw = self.IP.input_splitter.raw_reset() self.IP.run_cell(source_raw, store_history=True) self.IP.rl_do_indent = False else: @@ -182,9 +213,11 @@ class IterableIPShell: # self.IP.rl_do_indent = True pass + self.prompt = self.generatePrompt(self.iter_more) - sys.stdout = orig_stdout - sys.stdin = orig_stdin + if IPython.version_info < (8,): + sys.stdout = orig_stdout + sys.stdin = orig_stdin def generatePrompt(self, is_continuation): """! @@ -195,17 +228,10 @@ class IterableIPShell: """ - # Backwards compatibility with ipyton-0.11 - # - ver = IPython.__version__ - if '0.11' in ver: - prompt = self.IP.hooks.generate_prompt(is_continuation) + if is_continuation: + prompt = '... ' else: - if is_continuation: - prompt = self.IP.prompt_manager.render('in2') - else: - prompt = self.IP.prompt_manager.render('in') - + prompt = '>>> ' return prompt @@ -281,7 +307,7 @@ class IterableIPShell: return str1[:i] return str1 if possibilities[1]: - common_prefix = reduce(_commonPrefix, possibilities[1]) or line[-1] + common_prefix = reduce(_commonPrefix, possibilities[1]) or split_line[-1] completed = line[:-len(split_line[-1])]+common_prefix else: completed = line @@ -324,7 +350,8 @@ class ConsoleView(Gtk.TextView): """ Specialized text view for console-like workflow. - @cvar ANSI_COLORS: Mapping of terminal colors to X11 names. + @cvar ANSI_COLORS: Mapping of terminal control sequence values to + tuples containing foreground and background color names. @type ANSI_COLORS: dictionary @ivar text_buffer: Widget's text buffer. @@ -336,20 +363,35 @@ class ConsoleView(Gtk.TextView): @ivar line_start: Start of command line mark. @type line_start: Gtk.TextMark """ - ANSI_COLORS = {'0;30': 'Black', '0;31': 'Red', - '0;32': 'Green', '0;33': 'Brown', - '0;34': 'Blue', '0;35': 'Purple', - '0;36': 'Cyan', '0;37': 'LightGray', - '1;30': 'DarkGray', '1;31': 'DarkRed', - '1;32': 'SeaGreen', '1;33': 'Yellow', - '1;34': 'LightBlue', '1;35': 'MediumPurple', - '1;36': 'LightCyan', '1;37': 'White'} + ANSI_COLORS = {'0;30': ('Black', None), + '0;31': ('Red', None), + '0;32': ('Green', None), + '0;33': ('Brown', None), + '0;34': ('Blue', None), + '0;35': ('Purple', None), + '0;36': ('Cyan', None), + '0;37': ('LightGray', None), + '1;30': ('DarkGray', None), + '1;31': ('DarkRed', None), + '1;32': ('SeaGreen', None), + '1;33': ('Yellow', None), + '1;34': ('LightBlue', None), + '1;35': ('MediumPurple', None), + '1;36': ('LightCyan', None), + '1;37': ('White', None), + '38;5;124;43': ('DarkRed', 'Yellow'), + '38;5;241': ('Gray', None), + '38;5;241;43': ('Gray', 'Yellow'), + '39': ('Black', None), + '39;49': ('Red', 'White'), + '43': (None, 'Yellow'), + '49': (None, 'White')} def __init__(self): """ Initialize console view. """ - GObject.GObject.__init__(self) + Gtk.TextView.__init__(self) self.modify_font(Pango.FontDescription('Mono')) self.set_cursor_visible(True) self.text_buffer = self.get_buffer() @@ -358,7 +400,8 @@ class ConsoleView(Gtk.TextView): False) for code in self.ANSI_COLORS: self.text_buffer.create_tag(code, - foreground=self.ANSI_COLORS[code], + foreground=self.ANSI_COLORS[code][0], + background=self.ANSI_COLORS[code][1], weight=700) self.text_buffer.create_tag('0') self.text_buffer.create_tag('notouch', editable=False) @@ -376,7 +419,7 @@ class ConsoleView(Gtk.TextView): @param editable: If true, added text is editable. @return none """ - GObject.idle_add(self._write, text, editable) + GLib.idle_add(self._write, text, editable) def _write(self, text, editable=False): """! @@ -414,7 +457,7 @@ class ConsoleView(Gtk.TextView): @param prompt: Prompt to print. @return none """ - GObject.idle_add(self._showPrompt, prompt) + GLib.idle_add(self._showPrompt, prompt) def _showPrompt(self, prompt): """! @@ -434,7 +477,7 @@ class ConsoleView(Gtk.TextView): @param text: Text to use as replacement. @return none """ - GObject.idle_add(self._changeLine, text) + GLib.idle_add(self._changeLine, text) def _changeLine(self, text): """! @@ -466,7 +509,7 @@ class ConsoleView(Gtk.TextView): @param text: Text to show. @return none """ - GObject.idle_add(self._showReturned, text) + GLib.idle_add(self._showReturned, text) def _showReturned(self, text): """! @@ -485,11 +528,14 @@ class ConsoleView(Gtk.TextView): if text: self._write('\n') self._showPrompt(self.prompt) - self.text_buffer.move_mark(self.line_start,self.text_buffer.get_end_iter()) + self.text_buffer.move_mark(self.line_start, self.text_buffer.get_end_iter()) self.text_buffer.place_cursor(self.text_buffer.get_end_iter()) if self.IP.rl_do_indent: - indentation = self.IP.input_splitter.indent_spaces * ' ' + if self.no_input_splitter: + indentation = self.indent_spaces + else: + indentation = self.IP.input_splitter.indent_spaces * ' ' self.text_buffer.insert_at_cursor(indentation) def onKeyPress(self, widget, event): @@ -508,9 +554,9 @@ class ConsoleView(Gtk.TextView): selection_iter = self.text_buffer.get_iter_at_mark(selection_mark) start_iter = self.text_buffer.get_iter_at_mark(self.line_start) if event.keyval == Gdk.KEY_Home: - if event.get_state() & Gdk.ModifierType.CONTROL_MASK or event.get_state() & Gdk.ModifierType.MOD1_MASK: + if event.state & Gdk.ModifierType.CONTROL_MASK or event.state & Gdk.ModifierType.MOD1_MASK: pass - elif event.get_state() & Gdk.ModifierType.SHIFT_MASK: + elif event.state & Gdk.ModifierType.SHIFT_MASK: self.text_buffer.move_mark(insert_mark, start_iter) return True else: @@ -520,6 +566,24 @@ class ConsoleView(Gtk.TextView): insert_iter.backward_cursor_position() if not insert_iter.editable(True): return True + elif event.state & Gdk.ModifierType.CONTROL_MASK and event.keyval in [ord('L'), ord('l')]: + # clear previous output on Ctrl+L, but remember current input line + cursor position + cursor_offset = self.text_buffer.get_property('cursor-position') + cursor_pos_in_line = cursor_offset - start_iter.get_offset() + len(self.prompt) + current_input = self.text_buffer.get_text(start_iter, self.text_buffer.get_end_iter(), False) + self.text_buffer.set_text(self.prompt + current_input) + self.text_buffer.move_mark(self.line_start, self.text_buffer.get_iter_at_offset(len(self.prompt))) + self.text_buffer.place_cursor(self.text_buffer.get_iter_at_offset(cursor_pos_in_line)) + return True + elif event.state & Gdk.ModifierType.CONTROL_MASK and event.keyval in [Gdk.KEY_k, Gdk.KEY_K]: + # clear text after input cursor on Ctrl+K + if insert_iter.editable(True): + self.text_buffer.delete(insert_iter, self.text_buffer.get_end_iter()) + return True + elif event.state & Gdk.ModifierType.CONTROL_MASK and event.keyval == Gdk.KEY_C: + # copy selection on Ctrl+C (upper-case 'C' only) + self.text_buffer.copy_clipboard(Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)) + return True elif not event.string: pass elif start_iter.compare(insert_iter) <= 0 and \ @@ -569,7 +633,7 @@ class IPythonView(ConsoleView, IterableIPShell): """ ConsoleView.__init__(self) self.cout = StringIO() - IterableIPShell.__init__(self, cout=self.cout,cerr=self.cout, + IterableIPShell.__init__(self, cout=self.cout, cerr=self.cout, input_func=self.raw_input) self.interrupt = False self.execute() diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt index 93493c15d..02ac7826d 100644 --- a/src/wifi/CMakeLists.txt +++ b/src/wifi/CMakeLists.txt @@ -354,4 +354,5 @@ build_lib( test/wifi-txop-test.cc test/wifi-phy-cca-test.cc test/wifi-non-ht-dup-test.cc + test/wifi-phy-mu-mimo-test.cc ) diff --git a/src/wifi/doc/source/wifi-design.rst b/src/wifi/doc/source/wifi-design.rst index 998f09dd6..598ee8fe4 100644 --- a/src/wifi/doc/source/wifi-design.rst +++ b/src/wifi/doc/source/wifi-design.rst @@ -167,8 +167,6 @@ packets. Interference from other wireless technologies is only modeled when the SpectrumWifiPhy is used. The following details pertain to the physical layer and channel models: -* 802.11ax/be MU-RTS/CTS is not yet supported -* 802.11ac/ax/be MU-MIMO is not supported, and no more than 4 antennas can be configured * 802.11n/ac/ax/be beamforming is not supported * 802.11n RIFS is not supported * 802.11 PCF/HCF/HCCA are not implemented @@ -178,11 +176,11 @@ The following details pertain to the physical layer and channel models: * Cases where RTS/CTS and ACK are transmitted using HT/VHT/HE/EHT formats are not supported * Energy consumption model does not consider MIMO * 802.11ax preamble puncturing is supported by the PHY but is currently not exploited by the MAC -* Only minimal 802.11be PHY is supported (no MAC layer yet) +* Only minimal MU-MIMO is supported (ideal PHY assumed, no MAC layer yet) At the MAC layer, most of the main functions found in deployed Wi-Fi -equipment for 802.11a/b/e/g/n/ac/ax are implemented, but there are scattered instances -where some limitations in the models exist. Support for 802.11n, ac and ax is evolving. +equipment for 802.11a/b/e/g/n/ac/ax/be are implemented, but there are scattered instances +where some limitations in the models exist. Support for 802.11n, ac, ax and be is evolving. Some implementation choices that are not imposed by the standard are listed below: @@ -751,9 +749,14 @@ the other ones are referred to as inactive RF interfaces and might be disconnect Multiple RF interfaces concept -If the ``SpectrumWifiPhy::TrackSignalsFromInactiveInterfaces`` attribute is set to true, +If the ``SpectrumWifiPhy::TrackSignalsFromInactiveInterfaces`` attribute is set to true (default), inactive RF interfaces are connected to their respective spectrum channels and the ``SpectrumWifiPhy`` -forwards received signals from these inactive RF interfaces to the ``InterferenceHelper`` without processing them. +also receive signals from these inactive RF interfaces when they belong to a configured portion +of the frequency range covered by the interface. +The portion of the spectrum being monitored by an inactive interface is specified by a center frequency +and a channel width, and is seamlessly set to equivalent of the operating channel of the spectrum PHY +that is actively using that frequency range. The ``SpectrumWifiPhy``forwards these received signals +from inactive interfaces to the ``InterferenceHelper`` without further processing them. The benefit of the latter is that more accurate PHY-CCA.indication can be generated upon channel switching if one or more signals started to be transmitted on the new channel before the switch occurs, which would be ignored otherwise. This is illustrated in Figure :ref:`fig-cca-channel-switching-multiple-interfaces`, where the parts in red are only generated when ``SpectrumWifiPhy::TrackSignalsFromInactiveInterfaces`` is set to true. @@ -965,6 +968,16 @@ assigned a User Priority based on the socket priority (see, e.g., the wifi-multi the wifi-mac-ofdma examples), which determines the Access Category that handles the packet. By default, wifi MAC queues support flow control, hence upper layers do not forward a packet down if there is no room for it in the corresponding MAC queue. +Wifi MAC queues do not support dynamic queue limits (byte queue limits); therefore, +there is no backpressure into the traffic control layer until the WifiMacQueue for +an access category is completely full (i.e., when the queue depth reaches the value +of the MaxSize attribute, which defaults to 500 packets). +TCP small queues (TSQ) [corbet2012]_ is a Linux feature that provides feedback from the +Wi-Fi device to the socket layer, to control how much data is queued at the Wi-Fi +level. |ns3| TCP does not implement TSQ, nor does the WifiNetDevice provide that +specific feedback (although some use of the existing trace sources may be enough to +support it). Regardless, experimental tests have demonstrated that TSQ interferes with +Wi-Fi aggregation on uplink transfers [grazia2022]_. Packets stay in the wifi MAC queue until they are acknowledged or discarded. A packet may be discarded because, e.g., its lifetime expired (i.e., it stayed in the queue for too long) or the maximum number of retries was reached. The maximum lifetime for a packet can diff --git a/src/wifi/doc/source/wifi-references.rst b/src/wifi/doc/source/wifi-references.rst index 9b1328ca2..18fcea458 100644 --- a/src/wifi/doc/source/wifi-references.rst +++ b/src/wifi/doc/source/wifi-references.rst @@ -64,3 +64,7 @@ References .. [magrin2021mu] \ D. Magrin, S. Avallone, S. Roy, and M. Zorzi, 'Validation of the ns-3 802.11ax OFDMA implementation', in Proceedings of WNS3 2021. .. [avallone2021wcm] \ S. Avallone, P. Imputato, G. Redieteab, C. Ghosh and S. Roy, "Will OFDMA Improve the Performance of 802.11 WiFi Networks?", in IEEE Wireless Communications Magazine, DOI: 10.1109/MWC.001.2000332, to appear. + +.. [corbet2012] \ J. Corbet, "TCP Small Queues", `LWN.net, July 17, 2012 `__ + +.. [grazia2022] \ C. Grazia, N. Patriciello, T. Hoiland-Jorgensen, M. Klapez and M. Casoni, "Aggregating Without Bloating: Hard Times for TCP on Wi-Fi", IEEE/ACM Transactions on Networking, Vol. 30, No.5, October 2022. diff --git a/src/wifi/doc/source/wifi-user.rst b/src/wifi/doc/source/wifi-user.rst index 0f4a47455..d900f07a3 100644 --- a/src/wifi/doc/source/wifi-user.rst +++ b/src/wifi/doc/source/wifi-user.rst @@ -55,7 +55,9 @@ To create a WifiNetDevice, users need to follow these steps: are needed for propagation loss calculations. The following sample code illustrates a typical configuration using mostly -default values in the simulator, and infrastructure mode:: +default values in the simulator, and infrastructure mode: + +.. sourcecode:: cpp NodeContainer wifiStaNode; wifiStaNode.Create(10); // Create 10 station node objects @@ -98,7 +100,9 @@ named this way. The reference is to the `yans simulator helper can be used to create a YansWifiChannel with a default PropagationLoss and PropagationDelay model. -Users will typically type code such as:: +Users will typically type code such as: + +.. sourcecode:: cpp YansWifiChannelHelper wifiChannelHelper = YansWifiChannelHelper::Default(); Ptr wifiChannel = wifiChannelHelper.Create(); @@ -133,7 +137,9 @@ the ``YansWifiPhyHelper`` will do the work. The YansWifiPhyHelper class configures an object factory to create instances of a ``YansWifiPhy`` and adds some other objects to it, including possibly a supplemental ErrorRateModel and a pointer to a MobilityModel. The user code is -typically:: +typically: + +.. sourcecode:: cpp YansWifiPhyHelper wifiPhyHelper; wifiPhyHelper.SetChannel(wifiChannel); @@ -143,7 +149,9 @@ The default YansWifiPhyHelper is configured with TableBasedErrorRateModel calling the ``YansWifiPhyHelper::SetErrorRateModel`` method. Optionally, if pcap tracing is needed, a user may use the following -command to enable pcap tracing:: +command to enable pcap tracing: + +.. sourcecode:: cpp YansWifiPhyHelper::SetPcapDataLinkType(enum SupportedPcapDataLinkTypes dlt) @@ -154,14 +162,18 @@ prepared the YansWifiPhyHelper by telling it which channel it is connected to. The Phy objects are created in the next step. In order to enable 802.11n/ac/ax MIMO, the number of antennas as well as the number of supported spatial streams need to be configured. -For example, this code enables MIMO with 2 antennas and 2 spatial streams:: +For example, this code enables MIMO with 2 antennas and 2 spatial streams: + +.. sourcecode:: cpp wifiPhyHelper.Set("Antennas", UintegerValue(2)); wifiPhyHelper.Set("MaxSupportedTxSpatialStreams", UintegerValue(2)); wifiPhyHelper.Set("MaxSupportedRxSpatialStreams", UintegerValue(2)); It is also possible to configure less streams than the number of antennas in order to benefit from diversity gain, and to define different MIMO capabilities for downlink and uplink. -For example, this code configures a node with 3 antennas that supports 2 spatial streams in downstream and 1 spatial stream in upstream:: +For example, this code configures a node with 3 antennas that supports 2 spatial streams in downstream and 1 spatial stream in upstream: + +.. sourcecode:: cpp wifiPhyHelper.Set("Antennas", UintegerValue(3)); wifiPhyHelper.Set("MaxSupportedTxSpatialStreams", UintegerValue(2)); @@ -169,7 +181,7 @@ For example, this code configures a node with 3 antennas that supports 2 spatial 802.11n PHY layer can support both 20 (default) or 40 MHz channel width, and 802.11ac/ax PHY layer can use either 20, 40, 80 (default) or 160 MHz channel width. See below for further documentation on setting the frequency, channel width, and channel number. -:: +.. sourcecode:: cpp WifiHelper wifi; wifi.SetStandard(WIFI_STANDARD_80211ac); @@ -207,13 +219,13 @@ providing either a StringValue object or a TupleValue object: * Defining a StringValue object to set the ``ChannelSettings`` attribute -:: +.. sourcecode:: cpp StringValue value("{38, 40, BAND_5GHZ, 0}")); * Defining a TupleValue object to set the ``ChannelSettings`` attribute -:: +.. sourcecode:: cpp TupleValue value; value.Set(WifiPhy::ChannelTuple {38, 40, WIFI_PHY_BAND_5GHZ, 0}); @@ -226,13 +238,13 @@ The operating channel settings can then be configured in a number of ways: * by setting global configuration default; e.g. -:: +.. sourcecode:: cpp Config::SetDefault("ns3::WifiPhy::ChannelSettings", StringValue("{38, 40, BAND_5GHZ, 0}")); * by setting an attribute value in the helper; e.g. -:: +.. sourcecode:: cpp TupleValue value; value.Set(WifiPhy::ChannelTuple {38, 40, WIFI_PHY_BAND_5GHZ, 0}); @@ -244,7 +256,7 @@ The operating channel settings can then be configured in a number of ways: * by performing post-installation configuration of the option, either via a Ptr to the WifiPhy object, or through the Config namespace; e.g.: -:: +.. sourcecode:: cpp Config::Set("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelSettings", StringValue("{38, 40, BAND_5GHZ, 0}")); @@ -263,7 +275,7 @@ band can only be configured if the standard is 802.11ax (or beyond). The following values for WifiStandard are defined in ``src/wifi/model/wifi-standards.h``: -:: +.. sourcecode:: cpp WIFI_STANDARD_80211a, WIFI_STANDARD_80211b, @@ -308,7 +320,7 @@ as soon as the WifiStandard is set. Here are the rules (applied in the given ord Following are a few examples to clarify these rules: -:: +.. sourcecode:: cpp WifiHelper wifi; wifi.SetStandard(WIFI_STANDARD_80211ac); @@ -317,7 +329,7 @@ Following are a few examples to clarify these rules: // channel width unspecified // -> it is set to 80 MHz (width of channel 58) -:: +.. sourcecode:: cpp WifiHelper wifi; wifi.SetStandard(WIFI_STANDARD_80211n); @@ -326,7 +338,7 @@ Following are a few examples to clarify these rules: // channel number unspecified // -> it is set to channel 38 (first 40 MHz channel in the 5GHz band) -:: +.. sourcecode:: cpp WifiHelper wifi; wifi.SetStandard(WIFI_STANDARD_80211ax); @@ -336,7 +348,7 @@ Following are a few examples to clarify these rules: // -> width set to 20 MHz (default width for 802.11ax in the 2.4 GHZ band) // -> channel number set to 1 (first 20 MHz channel in the 2.4 GHz band) -:: +.. sourcecode:: cpp WifiHelper wifi; wifi.SetStandard(WIFI_STANDARD_80211a); @@ -455,7 +467,7 @@ WifiPhy object. If an unknown channel number (other than zero) is configured, the simulator will exit with an error; for instance, such as: -:: +.. sourcecode:: cpp Ptr wifiPhy = ...; wifiPhy->SetAttribute("ChannelSettings", StringValue("{1321, 20, BAND_5GHZ, 0}")); @@ -468,7 +480,7 @@ If a known channel number is configured against an incorrect value of the WifiPhyStandard, the simulator will exit with an error; for instance, such as: -:: +.. sourcecode:: cpp WifiHelper wifi; wifi.SetStandard(WIFI_STANDARD_80211n); @@ -508,7 +520,9 @@ of type ``ns3::YansWifiChannel`` must be used with it. Its API has been extended for 802.11be multi-link and EMLSR in order to attach multiple spectrum channels to a same PHY. For that purpose, a user may use the following command to attach a spectrum channel to the PHY objects -that will be created upon a call to ``ns3::WifiHelper::Install``:: +that will be created upon a call to ``ns3::WifiHelper::Install``: + +.. sourcecode:: cpp SpectrumWifiPhyHelper::SetPcapDataLinkType(const Ptr channel, const FrequencyRange& freqRange) @@ -528,7 +542,9 @@ By default, it creates an ad-hoc MAC instance that does not have 802.11e/WMM-sty nor 802.11ac-style Very High Throughput (VHT) nor 802.11ax-style High Efficiency (HE) support enabled. For example the following user code configures a non-QoS and non-HT/non-VHT/non-HE MAC that -will be a non-AP STA in an infrastructure network where the AP has SSID ``ns-3-ssid``:: +will be a non-AP STA in an infrastructure network where the AP has SSID ``ns-3-ssid``: + +.. sourcecode:: cpp WifiMacHelper wifiMacHelper; Ssid ssid = Ssid("ns-3-ssid"); @@ -536,7 +552,9 @@ will be a non-AP STA in an infrastructure network where the AP has SSID ``ns-3-s "Ssid", SsidValue(ssid), "ActiveProbing", BooleanValue(false)); -The following code shows how to create an AP with QoS enabled:: +The following code shows how to create an AP with QoS enabled: + +.. sourcecode:: cpp WifiMacHelper wifiMacHelper; wifiMacHelper.SetType("ns3::ApWifiMac", @@ -563,7 +581,9 @@ For MAC instances that have QoS support enabled, the ``ns3::WifiMacHelper`` can * block ack inactivity timeout. For example the following user code configures a MAC that will be a non-AP STA with QoS enabled and a block ack threshold for AC_BE set to 2 packets, -in an infrastructure network where the AP has SSID ``ns-3-ssid``:: +in an infrastructure network where the AP has SSID ``ns-3-ssid``: + +.. sourcecode:: cpp WifiMacHelper wifiMacHelper; Ssid ssid = Ssid("ns-3-ssid"); @@ -582,7 +602,9 @@ the ``ns3::WifiMacHelper`` can be also used to set: By default, MSDU aggregation feature is disabled for all ACs and MPDU aggregation is enabled for AC_VI and AC_BE, with a maximum aggregation size of 65535 bytes. For example the following user code configures a MAC that will be a non-AP STA with HT and QoS enabled, MPDU aggregation enabled for AC_VO with a maximum aggregation size of 65535 bytes, and MSDU aggregation enabled for AC_BE with a maximum aggregation size of 7935 bytes, -in an infrastructure network where the AP has SSID ``ns-3-ssid``:: +in an infrastructure network where the AP has SSID ``ns-3-ssid``: + +.. sourcecode:: cpp WifiHelper wifi; wifi.SetStandard(WIFI_STANDARD_80211n); @@ -597,7 +619,9 @@ in an infrastructure network where the AP has SSID ``ns-3-ssid``:: 802.11ax APs support sending multi-user frames via DL OFDMA and UL OFDMA if a Multi-User Scheduler is aggregated to the wifi MAC(by default no scheduler is aggregated). WifiMacHelper enables to aggregate -a Multi-User Scheduler to an AP and set its parameters:: +a Multi-User Scheduler to an AP and set its parameters: + +.. sourcecode:: cpp WifiMacHelper wifiMacHelper; wifiMacHelper.SetMultiUserScheduler("ns3::RrMultiUserScheduler", @@ -606,7 +630,9 @@ a Multi-User Scheduler to an AP and set its parameters:: The Ack Manager is in charge of selecting the acknowledgment method among the three available methods(see section :ref:`wifi-mu-ack-sequences` ). The default ack manager -enables to select the acknowledgment method, e.g.:: +enables to select the acknowledgment method, e.g.: + +.. sourcecode:: cpp Config::SetDefault("ns3::WifiDefaultAckManager::DlMuAckSequenceType", EnumValue(WifiAcknowledgment::DL_MU_AGGREGATE_TF)); @@ -620,7 +646,9 @@ value of the DS field in the IP header of the packet (ToS field in case of IPv4, Traffic Class field in case of IPv6). Details on how to set the ToS field of IPv4 packets are given in the :ref:`Type-of-service` section of the documentation. In summary, users can create an address of type :cpp:class:`ns3::InetSocketAddress` -with the desired type of service value and pass it to the application helpers:: +with the desired type of service value and pass it to the application helpers: + +.. sourcecode:: cpp InetSocketAddress destAddress(ipv4Address, udpPort); destAddress.SetTos(tos); @@ -674,7 +702,9 @@ CS6 110000xx 6 AC_VO CS7 111000xx 7 AC_VO ============ ============ == =============== -So, for example,:: +So, for example, + +.. sourcecode:: cpp destAddress.SetTos(0xc0); @@ -696,7 +726,9 @@ WifiHelper ========== We're now ready to create WifiNetDevices. First, let's create -a WifiHelper with default settings:: +a WifiHelper with default settings: + +.. sourcecode:: cpp WifiHelper wifiHelper; @@ -706,7 +738,9 @@ What does this do? It sets the default wifi standard to **802.11a** and sets th ``WifiHelper::SetStandard`` method with the desired standard. Now, let's use the wifiPhyHelper and wifiMacHelper created above to install WifiNetDevices -on a set of nodes in a NodeContainer "c":: +on a set of nodes in a NodeContainer "c": + +.. sourcecode:: cpp NetDeviceContainer wifiContainer = WifiHelper::Install(wifiPhyHelper, wifiMacHelper, c); @@ -714,7 +748,9 @@ This creates the WifiNetDevice which includes also a WifiRemoteStationManager, a WifiMac, and a WifiPhy (connected to the matching Channel). The ``WifiHelper::SetStandard`` method sets various default timing parameters as defined in the selected standard version, overwriting values that may exist or have been previously configured. -In order to change parameters that are overwritten by ``WifiHelper::SetStandard``, this should be done post-install using ``Config::Set``:: +In order to change parameters that are overwritten by ``WifiHelper::SetStandard``, this should be done post-install using ``Config::Set``: + +.. sourcecode:: cpp WifiHelper wifi; wifi.SetStandard(WIFI_STANDARD_80211n); @@ -746,7 +782,9 @@ The WifiHelper can be used to set the attributes of the default ack policy selec (``ConstantWifiAckPolicySelector``) or to select a different (user provided) ack policy selector, for each of the available Access Categories. As an example, the following code can be used to set the BaThreshold attribute of the default ack -policy selector associated with BE AC to 0.5:: +policy selector associated with BE AC to 0.5: + +.. sourcecode:: cpp WifiHelper wifi; wifi.SetAckPolicySelectorForAc(AC_BE, "ns3::ConstantWifiAckPolicySelector", @@ -754,7 +792,9 @@ policy selector associated with BE AC to 0.5:: The WifiHelper is also used to configure OBSS PD spatial reuse for 802.11ax. The following lines configure a WifiHelper to support OBSS PD spatial reuse -using the ``ConstantObssPdAlgorithm`` with a threshold set to -72 dBm:: +using the ``ConstantObssPdAlgorithm`` with a threshold set to -72 dBm: + +.. sourcecode:: cpp WifiHelper wifi; wifi.SetObssPdAlgorithm("ns3::ConstantObssPdAlgorithm", @@ -774,7 +814,9 @@ user sets the standard to a variant that supports HT capabilities (802.11n, created for the device. The configuration object is used to store and manage HT-specific attributes. -802.11n/ac PHY layer can use either long (800 ns) or short (400 ns) OFDM guard intervals. To configure this parameter for a given device, the following lines of code could be used (in this example, it enables the support of a short guard interval for the first station):: +802.11n/ac PHY layer can use either long (800 ns) or short (400 ns) OFDM guard intervals. To configure this parameter for a given device, the following lines of code could be used (in this example, it enables the support of a short guard interval for the first station): + +.. sourcecode:: cpp Ptr nd = wifiStaDevices.Get(0); Ptr wnd = nd->GetObject(); @@ -782,7 +824,9 @@ manage HT-specific attributes. htConfiguration->SetShortGuardIntervalSupported(true); It is also possible to configure HT-specific attributes using ``Config::Set``. -The following line of code enables the support of a short guard interval for all stations:: +The following line of code enables the support of a short guard interval for all stations: + +.. sourcecode:: cpp Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/ShortGuardIntervalSupported", BooleanValue(true)); @@ -803,7 +847,9 @@ IEEE 802.11ax is also known as High Efficiency (HE). Once the ``ns3::WifiHelper HE configuration object will automatically be created to manage HE-specific attributes for 802.11ax devices. -802.11ax PHY layer can use either 3200 ns, 1600 ns or 800 ns OFDM guard intervals. To configure this parameter, the following lines of code could be used (in this example, it enables the support of 1600 ns guard interval), such as in this example code snippet:: +802.11ax PHY layer can use either 3200 ns, 1600 ns or 800 ns OFDM guard intervals. To configure this parameter, the following lines of code could be used (in this example, it enables the support of 1600 ns guard interval), such as in this example code snippet: + +.. sourcecode:: cpp Ptr nd = wifiStaDevices.Get(0); Ptr wnd = nd->GetObject(); @@ -813,7 +859,9 @@ attributes for 802.11ax devices. 802.11ax allows extended compressed Block ACKs containing a 256-bits bitmap, making possible transmissions of A-MPDUs containing up to 256 MPDUs, depending on the negotiated buffer size. In order to configure the buffer size of an 802.11ax device, -the following line of code could be used:: +the following line of code could be used: + +.. sourcecode:: cpp heConfiguration->SetMpduBufferSize(256); @@ -853,7 +901,9 @@ In this example, we create two ad-hoc nodes equipped with 802.11a Wi-Fi devices. We use the ``ns3::ConstantSpeedPropagationDelayModel`` as the propagation delay model and ``ns3::LogDistancePropagationLossModel`` with the exponent of 3.0 as the propagation loss model. Both devices are configured with ``ConstantRateWifiManager`` at the fixed rate of 12Mbps. -Finally, we manually place them by using the ``ns3::ListPositionAllocator``:: +Finally, we manually place them by using the ``ns3::ListPositionAllocator``: + +.. sourcecode:: cpp std::string phyMode("OfdmRate12Mbps"); @@ -898,7 +948,9 @@ Infrastructure (access point and clients) WifiNetDevice configuration This is a typical example of how a user might configure an access point and a set of clients. In this example, we create one access point and two clients. -Each node is equipped with 802.11b Wi-Fi device:: +Each node is equipped with 802.11b Wi-Fi device: + +.. sourcecode:: cpp std::string phyMode("DsssRate1Mbps"); @@ -960,6 +1012,8 @@ Each node is equipped with 802.11b Wi-Fi device:: Multiple RF interfaces configuration ++++++++++++++++++++++++++++++++++++ +.. sourcecode:: cpp + NodeContainer ap; ap.Create(1); NodeContainer sta; diff --git a/src/wifi/examples/reference/bianchi11ax.py b/src/wifi/examples/reference/bianchi11ax.py index 43dbff0de..b06f807b9 100644 --- a/src/wifi/examples/reference/bianchi11ax.py +++ b/src/wifi/examples/reference/bianchi11ax.py @@ -129,41 +129,39 @@ ack_rates_160MHz = [6e6, 12e6, 12e6, 24e6, 24e6, 24e6, 24e6, 24e6, 24e6, 24e6, 2 k = 1 difs = 1 -fo = open("bianchi_11ax_difs.txt", "w") -for i in range(len(data_rates_20MHz)): - bianchi_result = bianchi_ax(data_rates_20MHz[i], ack_rates_20MHz[i], k, difs) - str_s = str_result(bianchi_result, i, 20) - fo.write(str_s) -for i in range(len(data_rates_40MHz)): - bianchi_result = bianchi_ax(data_rates_40MHz[i], ack_rates_40MHz[i], k, difs) - str_s = str_result(bianchi_result, i, 40) - fo.write(str_s) -for i in range(len(data_rates_80MHz)): - bianchi_result = bianchi_ax(data_rates_80MHz[i], ack_rates_80MHz[i], k, difs) - str_s = str_result(bianchi_result, i, 80) - fo.write(str_s) -for i in range(len(data_rates_160MHz)): - bianchi_result = bianchi_ax(data_rates_160MHz[i], ack_rates_160MHz[i], k, difs) - str_s = str_result(bianchi_result, i, 160) - fo.write(str_s) -fo.close() +with open("bianchi_11ax_difs.txt", "w", encoding="utf-8") as fo: + for i in range(len(data_rates_20MHz)): + bianchi_result = bianchi_ax(data_rates_20MHz[i], ack_rates_20MHz[i], k, difs) + str_s = str_result(bianchi_result, i, 20) + fo.write(str_s) + for i in range(len(data_rates_40MHz)): + bianchi_result = bianchi_ax(data_rates_40MHz[i], ack_rates_40MHz[i], k, difs) + str_s = str_result(bianchi_result, i, 40) + fo.write(str_s) + for i in range(len(data_rates_80MHz)): + bianchi_result = bianchi_ax(data_rates_80MHz[i], ack_rates_80MHz[i], k, difs) + str_s = str_result(bianchi_result, i, 80) + fo.write(str_s) + for i in range(len(data_rates_160MHz)): + bianchi_result = bianchi_ax(data_rates_160MHz[i], ack_rates_160MHz[i], k, difs) + str_s = str_result(bianchi_result, i, 160) + fo.write(str_s) difs = 0 -fo = open("bianchi_11ax_eifs.txt", "w") -for i in range(len(data_rates_20MHz)): - bianchi_result = bianchi_ax(data_rates_20MHz[i], ack_rates_20MHz[i], k, difs) - str_s = str_result(bianchi_result, i, 20) - fo.write(str_s) -for i in range(len(data_rates_40MHz)): - bianchi_result = bianchi_ax(data_rates_40MHz[i], ack_rates_40MHz[i], k, difs) - str_s = str_result(bianchi_result, i, 40) - fo.write(str_s) -for i in range(len(data_rates_80MHz)): - bianchi_result = bianchi_ax(data_rates_80MHz[i], ack_rates_80MHz[i], k, difs) - str_s = str_result(bianchi_result, i, 80) - fo.write(str_s) -for i in range(len(data_rates_160MHz)): - bianchi_result = bianchi_ax(data_rates_160MHz[i], ack_rates_160MHz[i], k, difs) - str_s = str_result(bianchi_result, i, 160) - fo.write(str_s) -fo.close() +with open("bianchi_11ax_eifs.txt", "w", encoding="utf-8") as fo: + for i in range(len(data_rates_20MHz)): + bianchi_result = bianchi_ax(data_rates_20MHz[i], ack_rates_20MHz[i], k, difs) + str_s = str_result(bianchi_result, i, 20) + fo.write(str_s) + for i in range(len(data_rates_40MHz)): + bianchi_result = bianchi_ax(data_rates_40MHz[i], ack_rates_40MHz[i], k, difs) + str_s = str_result(bianchi_result, i, 40) + fo.write(str_s) + for i in range(len(data_rates_80MHz)): + bianchi_result = bianchi_ax(data_rates_80MHz[i], ack_rates_80MHz[i], k, difs) + str_s = str_result(bianchi_result, i, 80) + fo.write(str_s) + for i in range(len(data_rates_160MHz)): + bianchi_result = bianchi_ax(data_rates_160MHz[i], ack_rates_160MHz[i], k, difs) + str_s = str_result(bianchi_result, i, 160) + fo.write(str_s) diff --git a/src/wifi/examples/wifi-manager-example.cc b/src/wifi/examples/wifi-manager-example.cc index 94ab19da0..6fdc96fb3 100644 --- a/src/wifi/examples/wifi-manager-example.cc +++ b/src/wifi/examples/wifi-manager-example.cc @@ -211,7 +211,7 @@ main(int argc, char* argv[]) double stepSize = 1; // dBm double stepTime = 1; // seconds uint32_t packetSize = 1024; // bytes - bool broadcast = 0; + bool broadcast = false; int ap1_x = 0; int ap1_y = 0; int sta1_x = 5; @@ -714,8 +714,8 @@ main(int argc, char* argv[]) Ptr wndServer = ndServer->GetObject(); Ptr wifiPhyPtrClient = wndClient->GetPhy(); Ptr wifiPhyPtrServer = wndServer->GetPhy(); - uint8_t t_clientNss = static_cast(clientNss); - uint8_t t_serverNss = static_cast(serverNss); + auto t_clientNss = static_cast(clientNss); + auto t_serverNss = static_cast(serverNss); wifiPhyPtrClient->SetNumberOfAntennas(t_clientNss); wifiPhyPtrClient->SetMaxSupportedTxSpatialStreams(t_clientNss); wifiPhyPtrClient->SetMaxSupportedRxSpatialStreams(t_clientNss); diff --git a/src/wifi/helper/athstats-helper.cc b/src/wifi/helper/athstats-helper.cc index 1411b5daf..3b977a015 100644 --- a/src/wifi/helper/athstats-helper.cc +++ b/src/wifi/helper/athstats-helper.cc @@ -30,6 +30,7 @@ #include #include +#include namespace ns3 { @@ -87,7 +88,7 @@ AthstatsHelper::EnableAthstats(std::string filename, Ptr nd) void AthstatsHelper::EnableAthstats(std::string filename, NetDeviceContainer d) { - for (NetDeviceContainer::Iterator i = d.Begin(); i != d.End(); ++i) + for (auto i = d.Begin(); i != d.End(); ++i) { Ptr dev = *i; EnableAthstats(filename, dev->GetNode()->GetId(), dev->GetIfIndex()); @@ -98,7 +99,7 @@ void AthstatsHelper::EnableAthstats(std::string filename, NodeContainer n) { NetDeviceContainer devs; - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; for (std::size_t j = 0; j < node->GetNDevices(); ++j) @@ -286,36 +287,36 @@ void AthstatsWifiTraceSink::WriteStats() { NS_LOG_FUNCTION(this); - // The comments below refer to how each value maps to madwifi's athstats - // I know C strings are ugly but that's the quickest way to use exactly the same format as in - // madwifi - char str[200]; - snprintf( - str, - 200, - "%8u %8u %7u %7u %7u %6u %6u %6u %7u %4u %3uM\n", - (unsigned int)m_txCount, // /proc/net/dev transmitted packets to which we should subtract - // management frames - (unsigned int) - m_rxCount, // /proc/net/dev received packets but subtracts management frames from it - (unsigned int)0, // ast_tx_altrate - (unsigned int)m_shortRetryCount, // ast_tx_shortretry - (unsigned int)m_longRetryCount, // ast_tx_longretry - (unsigned int)m_exceededRetryCount, // ast_tx_xretries - (unsigned int)m_phyRxErrorCount, // ast_rx_crcerr - (unsigned int)0, // ast_rx_badcrypt - (unsigned int)0, // ast_rx_phyerr - (unsigned int)0, // ast_rx_rssi - (unsigned int)0 // rate - ); - if (m_writer) + if (!m_writer) { - *m_writer << str; - - ResetCounters(); - Simulator::Schedule(m_interval, &AthstatsWifiTraceSink::WriteStats, this); + return; } + + // The comments below refer to how each value maps to madwifi's athstats. + // Format: "%8lu %8lu %7u %7u %7u %6u %6u %6u %7u %4u %3uM" + std::stringstream ss; + + // /proc/net/dev transmitted packets to which we should subtract management frames + ss << std::setw(8) << m_txCount << " "; + + // /proc/net/dev received packets but subtracts management frames from it + ss << std::setw(8) << m_rxCount << " "; + + ss << std::setw(7) << 0 << " "; // ast_tx_altrate + ss << std::setw(7) << m_shortRetryCount << " "; // ast_tx_shortretry + ss << std::setw(7) << m_longRetryCount << " "; // ast_tx_longretry + ss << std::setw(6) << m_exceededRetryCount << " "; // ast_tx_xretries + ss << std::setw(6) << m_phyRxErrorCount << " "; // ast_rx_crcerr + ss << std::setw(6) << 0 << " "; // ast_rx_badcrypt + ss << std::setw(7) << 0 << " "; // ast_rx_phyerr + ss << std::setw(4) << 0 << " "; // ast_rx_rssi + ss << std::setw(3) << 0 << "M"; // rate + + *m_writer << ss.str() << std::endl; + + ResetCounters(); + Simulator::Schedule(m_interval, &AthstatsWifiTraceSink::WriteStats, this); } } // namespace ns3 diff --git a/src/wifi/helper/spectrum-wifi-helper.cc b/src/wifi/helper/spectrum-wifi-helper.cc index 149397101..abd21004d 100644 --- a/src/wifi/helper/spectrum-wifi-helper.cc +++ b/src/wifi/helper/spectrum-wifi-helper.cc @@ -42,8 +42,8 @@ NS_LOG_COMPONENT_DEFINE("SpectrumWifiHelper"); SpectrumWifiPhyHelper::SpectrumWifiPhyHelper(uint8_t nLinks) : WifiPhyHelper(nLinks) { - NS_ABORT_IF(m_phy.size() != nLinks); - for (auto& phy : m_phy) + NS_ABORT_IF(m_phys.size() != nLinks); + for (auto& phy : m_phys) { phy.SetTypeId("ns3::SpectrumWifiPhy"); } @@ -54,16 +54,13 @@ SpectrumWifiPhyHelper::SpectrumWifiPhyHelper(uint8_t nLinks) void SpectrumWifiPhyHelper::SetChannel(const Ptr channel) { - m_channels[WHOLE_WIFI_SPECTRUM] = channel; - AddWifiBandwidthFilter(channel); + AddChannel(channel); } void SpectrumWifiPhyHelper::SetChannel(const std::string& channelName) { - Ptr channel = Names::Find(channelName); - m_channels[WHOLE_WIFI_SPECTRUM] = channel; - AddWifiBandwidthFilter(channel); + AddChannel(channelName); } void @@ -79,7 +76,6 @@ SpectrumWifiPhyHelper::AddChannel(const std::string& channelName, const Frequenc { Ptr channel = Names::Find(channelName); AddChannel(channel, freqRange); - AddWifiBandwidthFilter(channel); } void @@ -108,17 +104,36 @@ SpectrumWifiPhyHelper::AddWifiBandwidthFilter(Ptr channel) } } +void +SpectrumWifiPhyHelper::AddPhyToFreqRangeMapping(uint8_t linkId, const FrequencyRange& freqRange) +{ + if (auto it = m_interfacesMap.find(linkId); it == m_interfacesMap.end()) + { + m_interfacesMap.insert({linkId, {freqRange}}); + } + else + { + it->second.emplace(freqRange); + } +} + +void +SpectrumWifiPhyHelper::ResetPhyToFreqRangeMapping() +{ + m_interfacesMap.clear(); +} + std::vector> SpectrumWifiPhyHelper::Create(Ptr node, Ptr device) const { std::vector> ret; - for (std::size_t i = 0; i < m_phy.size(); i++) + for (std::size_t i = 0; i < m_phys.size(); i++) { - Ptr phy = m_phy.at(i).Create(); + auto phy = m_phys.at(i).Create(); auto interference = m_interferenceHelper.Create(); phy->SetInterferenceHelper(interference); - Ptr error = m_errorRateModel.at(i).Create(); + auto error = m_errorRateModel.at(i).Create(); phy->SetErrorRateModel(error); if (m_frameCaptureModel.at(i).IsTypeIdSet()) { @@ -131,10 +146,9 @@ SpectrumWifiPhyHelper::Create(Ptr node, Ptr device) const m_preambleDetectionModel.at(i).Create(); phy->SetPreambleDetectionModel(preambleDetection); } - for (const auto& [freqRange, channel] : m_channels) - { - phy->AddChannel(channel, freqRange); - } + InstallPhyInterfaces(i, phy); + phy->SetChannelSwitchedCallback( + MakeCallback(&SpectrumWifiPhyHelper::SpectrumChannelSwitched, this).Bind(phy)); phy->SetDevice(device); phy->SetMobility(node->GetObject()); ret.emplace_back(phy); @@ -143,4 +157,52 @@ SpectrumWifiPhyHelper::Create(Ptr node, Ptr device) const return ret; } +void +SpectrumWifiPhyHelper::InstallPhyInterfaces(uint8_t linkId, Ptr phy) const +{ + if (m_interfacesMap.count(linkId) == 0) + { + // default setup: set all interfaces to this link + for (const auto& [freqRange, channel] : m_channels) + { + phy->AddChannel(channel, freqRange); + } + } + else + { + for (const auto& freqRange : m_interfacesMap.at(linkId)) + { + phy->AddChannel(m_channels.at(freqRange), freqRange); + } + } +} + +void +SpectrumWifiPhyHelper::SpectrumChannelSwitched(Ptr phy) const +{ + NS_LOG_FUNCTION(this << phy); + for (const auto& otherPhy : phy->GetDevice()->GetPhys()) + { + auto spectrumPhy = DynamicCast(otherPhy); + NS_ASSERT(spectrumPhy); + if (spectrumPhy == phy) + { + // this is the PHY that has switched + continue; + } + if (spectrumPhy->GetCurrentFrequencyRange() == phy->GetCurrentFrequencyRange()) + { + // this is the active interface + continue; + } + if (const auto& interfaces = spectrumPhy->GetSpectrumPhyInterfaces(); + interfaces.count(phy->GetCurrentFrequencyRange()) == 0) + { + // no interface attached to that channel + continue; + } + spectrumPhy->ConfigureInterface(phy->GetFrequency(), phy->GetChannelWidth()); + } +} + } // namespace ns3 diff --git a/src/wifi/helper/spectrum-wifi-helper.h b/src/wifi/helper/spectrum-wifi-helper.h index a58cfeed7..481f2ece2 100644 --- a/src/wifi/helper/spectrum-wifi-helper.h +++ b/src/wifi/helper/spectrum-wifi-helper.h @@ -22,10 +22,14 @@ #include "wifi-helper.h" +#include +#include + namespace ns3 { class SpectrumChannel; +class SpectrumWifiPhy; /** * \brief Make it easy to create and manage PHY objects for the spectrum model. @@ -81,6 +85,21 @@ class SpectrumWifiPhyHelper : public WifiPhyHelper void AddChannel(const std::string& channelName, const FrequencyRange& freqRange = WHOLE_WIFI_SPECTRUM); + /** + * Add a given spectrum PHY interface to the PHY instance corresponding of a given link. + * If no mapping has been specified for a given link, all spectrum PHY interfaces will + * be added to the PHY instance of that link. + * + * \param linkId ID of the link to setup + * \param freqRange frequency range handled by of the spectrum PHY interface + */ + void AddPhyToFreqRangeMapping(uint8_t linkId, const FrequencyRange& freqRange); + + /** + * Reset mapping of the spectrum PHY interfaces added to the PHY instances. + */ + void ResetPhyToFreqRangeMapping(); + private: /** * \param node the node on which we wish to create a wifi PHY @@ -90,6 +109,22 @@ class SpectrumWifiPhyHelper : public WifiPhyHelper * This method implements the pure virtual method defined in \ref ns3::WifiPhyHelper. */ std::vector> Create(Ptr node, Ptr device) const override; + + /** + * \brief Install PHY interfaces to the PHY instance of a given link + * based on the currently configured mapping (\see AddPhyInterface). + * + * \param linkId ID of the link to setup + * \param phy spectrum PHY instance of the link + */ + void InstallPhyInterfaces(uint8_t linkId, Ptr phy) const; + + /** + * Function that is notified when a spectrum channel switched + * \param phy spectrum PHY instance that has switched its channel + */ + void SpectrumChannelSwitched(Ptr phy) const; + /** * \param channel The channel to inspect to possibly add a WifiBandwidthFilter * @@ -99,6 +134,9 @@ class SpectrumWifiPhyHelper : public WifiPhyHelper void AddWifiBandwidthFilter(Ptr channel); std::map> m_channels; ///< the spectrum channels + std::map> + m_interfacesMap; ///< map of the spectrum PHY interfaces to be added to the PHY instance + ///< corresponding to a given link ID }; } // namespace ns3 diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index 71d8e5324..f7f409d56 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -147,7 +147,7 @@ WifiPhyHelper::WifiPhyHelper(uint8_t nLinks) : m_pcapDlt(PcapHelper::DLT_IEEE802_11) { NS_ABORT_IF(nLinks == 0); - m_phy.resize(nLinks); + m_phys.resize(nLinks); m_errorRateModel.resize(nLinks); m_frameCaptureModel.resize(nLinks); m_preambleDetectionModel.resize(nLinks); @@ -162,7 +162,7 @@ WifiPhyHelper::~WifiPhyHelper() void WifiPhyHelper::Set(std::string name, const AttributeValue& v) { - for (auto& phy : m_phy) + for (auto& phy : m_phys) { phy.Set(name, v); } @@ -171,7 +171,7 @@ WifiPhyHelper::Set(std::string name, const AttributeValue& v) void WifiPhyHelper::Set(uint8_t linkId, std::string name, const AttributeValue& v) { - m_phy.at(linkId).Set(name, v); + m_phys.at(linkId).Set(name, v); } void @@ -759,7 +759,7 @@ WifiHelper::Install(const WifiPhyHelper& phyHelper, NodeContainer::Iterator last) const { NetDeviceContainer devices; - for (NodeContainer::Iterator i = first; i != last; ++i) + for (auto i = first; i != last; ++i) { Ptr node = *i; Ptr device = CreateObject(); @@ -975,6 +975,11 @@ WifiHelper::EnableLogComponents() LogComponentEnable("YansWifiChannel", LOG_LEVEL_ALL); LogComponentEnable("YansWifiPhy", LOG_LEVEL_ALL); + LogComponentEnable("Athstats", LOG_LEVEL_ALL); + LogComponentEnable("WifiHelper", LOG_LEVEL_ALL); + LogComponentEnable("SpectrumWifiHelper", LOG_LEVEL_ALL); + LogComponentEnable("YansWifiHelper", LOG_LEVEL_ALL); + // From Spectrum LogComponentEnable("WifiSpectrumValueHelper", LOG_LEVEL_ALL); } @@ -984,7 +989,7 @@ WifiHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr wifi = DynamicCast(netDevice); diff --git a/src/wifi/helper/wifi-helper.h b/src/wifi/helper/wifi-helper.h index b934ee0dd..7a9ccec6c 100644 --- a/src/wifi/helper/wifi-helper.h +++ b/src/wifi/helper/wifi-helper.h @@ -235,7 +235,7 @@ class WifiPhyHelper : public PcapHelperForDevice, public AsciiTraceHelperForDevi SignalNoiseDbm signalNoise, uint16_t staId = SU_STA_ID); - std::vector m_phy; ///< PHY object + std::vector m_phys; ///< PHY objects ObjectFactory m_interferenceHelper; ///< interference helper std::vector m_errorRateModel; ///< error rate model std::vector m_frameCaptureModel; ///< frame capture model @@ -549,7 +549,7 @@ template void WifiPhyHelper::SetErrorRateModel(std::string type, Args&&... args) { - for (std::size_t linkId = 0; linkId < m_phy.size(); linkId++) + for (std::size_t linkId = 0; linkId < m_phys.size(); linkId++) { SetErrorRateModel(linkId, type, std::forward(args)...); } @@ -567,7 +567,7 @@ template void WifiPhyHelper::SetFrameCaptureModel(std::string type, Args&&... args) { - for (std::size_t linkId = 0; linkId < m_phy.size(); linkId++) + for (std::size_t linkId = 0; linkId < m_phys.size(); linkId++) { SetFrameCaptureModel(linkId, type, std::forward(args)...); } @@ -585,7 +585,7 @@ template void WifiPhyHelper::SetPreambleDetectionModel(std::string type, Args&&... args) { - for (std::size_t linkId = 0; linkId < m_phy.size(); linkId++) + for (std::size_t linkId = 0; linkId < m_phys.size(); linkId++) { SetPreambleDetectionModel(linkId, type, std::forward(args)...); } diff --git a/src/wifi/helper/yans-wifi-helper.cc b/src/wifi/helper/yans-wifi-helper.cc index 1ee1b43f1..4f677f0c8 100644 --- a/src/wifi/helper/yans-wifi-helper.cc +++ b/src/wifi/helper/yans-wifi-helper.cc @@ -54,9 +54,7 @@ YansWifiChannelHelper::Create() const { Ptr channel = CreateObject(); Ptr prev = nullptr; - for (std::vector::const_iterator i = m_propagationLoss.begin(); - i != m_propagationLoss.end(); - ++i) + for (auto i = m_propagationLoss.begin(); i != m_propagationLoss.end(); ++i) { Ptr cur = (*i).Create(); if (prev) @@ -84,7 +82,7 @@ YansWifiPhyHelper::YansWifiPhyHelper() : WifiPhyHelper(1), // YANS phy is not used for 11be devices m_channel(nullptr) { - m_phy.at(0).SetTypeId("ns3::YansWifiPhy"); + m_phys.front().SetTypeId("ns3::YansWifiPhy"); SetInterferenceHelper("ns3::InterferenceHelper"); SetErrorRateModel("ns3::TableBasedErrorRateModel"); } @@ -105,19 +103,19 @@ YansWifiPhyHelper::SetChannel(std::string channelName) std::vector> YansWifiPhyHelper::Create(Ptr node, Ptr device) const { - Ptr phy = m_phy.at(0).Create(); + Ptr phy = m_phys.front().Create(); Ptr interference = m_interferenceHelper.Create(); phy->SetInterferenceHelper(interference); - Ptr error = m_errorRateModel.at(0).Create(); + Ptr error = m_errorRateModel.front().Create(); phy->SetErrorRateModel(error); - if (m_frameCaptureModel.at(0).IsTypeIdSet()) + if (m_frameCaptureModel.front().IsTypeIdSet()) { - auto frameCapture = m_frameCaptureModel.at(0).Create(); + auto frameCapture = m_frameCaptureModel.front().Create(); phy->SetFrameCaptureModel(frameCapture); } - if (m_preambleDetectionModel.at(0).IsTypeIdSet()) + if (m_preambleDetectionModel.front().IsTypeIdSet()) { - auto preambleDetection = m_preambleDetectionModel.at(0).Create(); + auto preambleDetection = m_preambleDetectionModel.front().Create(); phy->SetPreambleDetectionModel(preambleDetection); } phy->SetChannel(m_channel); diff --git a/src/wifi/model/ampdu-subframe-header.cc b/src/wifi/model/ampdu-subframe-header.cc index 2a843599e..e9e91efe3 100644 --- a/src/wifi/model/ampdu-subframe-header.cc +++ b/src/wifi/model/ampdu-subframe-header.cc @@ -44,7 +44,7 @@ AmpduSubframeHeader::GetInstanceTypeId() const AmpduSubframeHeader::AmpduSubframeHeader() : m_length(0), - m_eof(0), + m_eof(false), m_signature(0x4E) // Per 802.11 standard, the unique pattern is set to the value 0x4E. { } diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 1e30707b1..c710aaf0f 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -686,6 +686,25 @@ ApWifiMac::GetMultiLinkElement(uint8_t linkId, WifiMacType frameType, const Mac4 mle.SetTransitionTimeout(time.Get()); } + // The MLD Capabilities And Operations subfield is present in the Common Info field of the + // Basic Multi-Link element carried in Beacon, Probe Response, (Re)Association Request, and + // (Re)Association Response frames. (Sec. 9.4.2.312.2.3 of 802.11be D3.1) + if (frameType == WIFI_MAC_MGT_BEACON || frameType == WIFI_MAC_MGT_PROBE_RESPONSE || + frameType == WIFI_MAC_MGT_ASSOCIATION_REQUEST || + frameType == WIFI_MAC_MGT_REASSOCIATION_REQUEST || + frameType == WIFI_MAC_MGT_ASSOCIATION_RESPONSE) + { + auto& mldCapabilities = mle.GetCommonInfoBasic().m_mldCapabilities; + mldCapabilities.emplace(); + mldCapabilities->maxNSimultaneousLinks = GetNLinks() - 1; // assuming STR for now + mldCapabilities->srsSupport = 0; + EnumValue negSupport; + ehtConfiguration->GetAttributeFailSafe("TidToLinkMappingNegSupport", negSupport); + mldCapabilities->tidToLinkMappingSupport = negSupport.Get(); + mldCapabilities->freqSepForStrApMld = 0; // not supported yet + mldCapabilities->aarSupport = 0; // not supported yet + } + // if the Multi-Link Element is being inserted in a (Re)Association Response frame // and the remote station is affiliated with an MLD, try multi-link setup if (auto staMldAddress = GetWifiRemoteStationManager(linkId)->GetMldAddress(to); @@ -1083,6 +1102,10 @@ ApWifiMac::GetAssocResp(Mac48Address to, uint8_t linkId) { assoc.Get() = GetEhtCapabilities(linkId); assoc.Get() = GetEhtOperation(linkId); + // The AP MLD that accepts the requested TID-to-link mapping shall not include in the + // (Re)Association Response frame the TID-to-link Mapping element. + // (Sec. 35.3.7.1.8 of 802.11be D3.1). + // For now, we assume that AP MLDs always accept requested TID-to-link mappings. } return assoc; } @@ -1466,6 +1489,9 @@ ApWifiMac::TxOk(Ptr mpdu) StaSwitchingToPsMode(*staAddress, i); } } + + // Apply the negotiated TID-to-Link Mapping (if any) for DL direction + ApplyTidLinkMapping(*staMldAddress, WifiDirection::DOWNLINK); } } else if (hdr.IsAction()) @@ -1747,8 +1773,7 @@ ApWifiMac::Receive(Ptr mpdu, uint8_t linkId) packet->PeekHeader(reassocReq); frame = reassocReq; } - ReceiveAssocRequest(frame, from, linkId); - if (GetNLinks() > 1) + if (ReceiveAssocRequest(frame, from, linkId) && GetNLinks() > 1) { ParseReportedStaInfo(frame, from, linkId); } @@ -1791,9 +1816,9 @@ ApWifiMac::Receive(Ptr mpdu, uint8_t linkId) IsAssociated(hdr->GetAddr2())) { // received an EML Operating Mode Notification frame from an associated station - MgtEmlOperatingModeNotification frame; + MgtEmlOmn frame; pkt->RemoveHeader(frame); - ReceiveEmlNotification(frame, hdr->GetAddr2(), linkId); + ReceiveEmlOmn(frame, hdr->GetAddr2(), linkId); return; } break; @@ -1892,9 +1917,105 @@ ApWifiMac::ReceiveAssocRequest(const AssocReqRefVariant& assoc, } if (GetEhtSupported()) { - // check whether the EHT STA supports all MCSs in Basic MCS Set - // const auto& ehtCapabilities = frame.GetEhtCapabilities (); - // TODO: to be completed + // TODO check whether the EHT STA supports all MCSs in Basic MCS Set + auto ehtConfig = GetEhtConfiguration(); + NS_ASSERT(ehtConfig); + + if (const auto& tidLinkMapping = frame.template Get(); + !tidLinkMapping.empty()) + { + // non-AP MLD included TID-to-Link Mapping IE(s) in the Association Request. + // We refuse association if we do not support TID-to-Link mapping negotiation + // or the non-AP MLD included more than two TID-to-Link Mapping IEs + // or we support negotiation type 1 but TIDs are mapped onto distinct link sets + // or there is some TID that is not mapped to any link + // or the direction(s) is/are not set properly + if (tidLinkMapping.size() > 2) + { + return failure("More than two TID-to-Link Mapping IEs"); + } + + // if only one Tid-to-Link Mapping element is present, it must be valid for + // both directions + bool bothDirIfOneTlm = + tidLinkMapping.size() != 1 || + tidLinkMapping[0].m_control.direction == WifiDirection::BOTH_DIRECTIONS; + // An MLD that includes two TID-To-Link Mapping elements in a (Re)Association + // Request frame or a (Re)Association Response frame shall set the Direction + // subfield in one of the TID-To-Link Mapping elements to 0 and the Direction + // subfield in the other TID-To- Link Mapping element to 1. + // (Sec. 35.3.7.1.8 of 802.11be D3.1) + bool distinctDirsIfTwoTlms = + tidLinkMapping.size() != 2 || + (tidLinkMapping[0].m_control.direction != WifiDirection::BOTH_DIRECTIONS && + tidLinkMapping[1].m_control.direction != WifiDirection::BOTH_DIRECTIONS && + tidLinkMapping[0].m_control.direction != + tidLinkMapping[1].m_control.direction); + + if (!bothDirIfOneTlm || !distinctDirsIfTwoTlms) + { + return failure("Incorrect directions in TID-to-Link Mapping IEs"); + } + + EnumValue negSupport; + ehtConfig->GetAttributeFailSafe("TidToLinkMappingNegSupport", negSupport); + + if (negSupport.Get() == 0) + { + return failure("TID-to-Link Mapping negotiation not supported"); + } + + auto getMapping = [](const TidToLinkMapping& tlmIe, WifiTidLinkMapping& mapping) { + if (tlmIe.m_control.defaultMapping) + { + return; + } + for (uint8_t tid = 0; tid < 8; tid++) + { + if (auto linkSet = tlmIe.GetLinkMappingOfTid(tid); !linkSet.empty()) + { + mapping.emplace(tid, std::move(linkSet)); + } + } + }; + + WifiTidLinkMapping dlMapping; + WifiTidLinkMapping ulMapping; + + switch (tidLinkMapping[0].m_control.direction) + { + case WifiDirection::BOTH_DIRECTIONS: + getMapping(tidLinkMapping.at(0), dlMapping); + ulMapping = dlMapping; + break; + case WifiDirection::DOWNLINK: + getMapping(tidLinkMapping.at(0), dlMapping); + getMapping(tidLinkMapping.at(1), ulMapping); + break; + case WifiDirection::UPLINK: + getMapping(tidLinkMapping.at(0), ulMapping); + getMapping(tidLinkMapping.at(1), dlMapping); + break; + } + + if (negSupport.Get() == 1 && + !TidToLinkMappingValidForNegType1(dlMapping, ulMapping)) + { + return failure("Mapping TIDs to distinct link sets is incompatible with " + "negotiation support of 1"); + } + + // otherwise, we accept the TID-to-link Mapping and store it + const auto& mle = frame.template Get(); + NS_ASSERT_MSG(mle, + "Multi-Link Element not present in an Association Request including " + "TID-to-Link Mapping element(s)"); + auto mldAddr = mle->GetMldMacAddress(); + + // The requested link mappings are valid and can be accepted; store them. + UpdateTidToLinkMapping(mldAddr, WifiDirection::DOWNLINK, dlMapping); + UpdateTidToLinkMapping(mldAddr, WifiDirection::UPLINK, ulMapping); + } } // The association request from the station can be accepted. @@ -1975,7 +2096,6 @@ ApWifiMac::ReceiveAssocRequest(const AssocReqRefVariant& assoc, NS_LOG_DEBUG("Association Request from " << from << " accepted"); remoteStationManager->RecordWaitAssocTxOk(from); return true; - ; }; return std::visit(recvAssocRequest, assoc); @@ -1995,18 +2115,8 @@ ApWifiMac::ParseReportedStaInfo(const AssocReqRefVariant& assoc, Mac48Address fr return; } - auto emlCapabilities = std::make_shared(); - if (mle->HasEmlCapabilities()) - { - emlCapabilities->emlsrSupport = mle->IsEmlsrSupported() ? 1 : 0; - emlCapabilities->emlsrPaddingDelay = - CommonInfoBasicMle::EncodeEmlsrPaddingDelay(mle->GetEmlsrPaddingDelay()); - emlCapabilities->emlsrTransitionDelay = - CommonInfoBasicMle::EncodeEmlsrTransitionDelay(mle->GetEmlsrTransitionDelay()); - } - - GetWifiRemoteStationManager(linkId)->SetMldAddress(from, mle->GetMldMacAddress()); - GetWifiRemoteStationManager(linkId)->AddStationEmlCapabilities(from, emlCapabilities); + auto mleCommonInfo = std::make_shared(mle->GetCommonInfoBasic()); + GetWifiRemoteStationManager(linkId)->AddStationMleCommonInfo(from, mleCommonInfo); for (std::size_t i = 0; i < mle->GetNPerStaProfileSubelements(); i++) { @@ -2032,11 +2142,9 @@ ApWifiMac::ParseReportedStaInfo(const AssocReqRefVariant& assoc, Mac48Address fr ReceiveAssocRequest(perStaProfile.GetAssocRequest(), perStaProfile.GetStaMacAddress(), newLinkId); - GetWifiRemoteStationManager(newLinkId)->SetMldAddress(perStaProfile.GetStaMacAddress(), - mle->GetMldMacAddress()); - GetWifiRemoteStationManager(newLinkId)->AddStationEmlCapabilities( + GetWifiRemoteStationManager(newLinkId)->AddStationMleCommonInfo( perStaProfile.GetStaMacAddress(), - emlCapabilities); + mleCommonInfo); } }; @@ -2044,9 +2152,7 @@ ApWifiMac::ParseReportedStaInfo(const AssocReqRefVariant& assoc, Mac48Address fr } void -ApWifiMac::ReceiveEmlNotification(MgtEmlOperatingModeNotification& frame, - const Mac48Address& sender, - uint8_t linkId) +ApWifiMac::ReceiveEmlOmn(MgtEmlOmn& frame, const Mac48Address& sender, uint8_t linkId) { NS_LOG_FUNCTION(this << frame << sender << linkId); @@ -2070,8 +2176,8 @@ ApWifiMac::ReceiveEmlNotification(MgtEmlOperatingModeNotification& frame, NS_ASSERT_MSG(emlCapabilities, "EML Capabilities not stored for STA " << sender); // update values stored in remote station manager - emlCapabilities->emlsrPaddingDelay = frame.m_emlsrParamUpdate->paddingDelay; - emlCapabilities->emlsrTransitionDelay = frame.m_emlsrParamUpdate->transitionDelay; + emlCapabilities->get().emlsrPaddingDelay = frame.m_emlsrParamUpdate->paddingDelay; + emlCapabilities->get().emlsrTransitionDelay = frame.m_emlsrParamUpdate->transitionDelay; } auto mldAddress = GetWifiRemoteStationManager(linkId)->GetMldAddress(sender); @@ -2180,7 +2286,7 @@ ApWifiMac::ReceiveEmlNotification(MgtEmlOperatingModeNotification& frame, frame.m_emlsrParamUpdate.reset(); auto ehtFem = StaticCast(GetFrameExchangeManager(linkId)); - ehtFem->SendEmlOperatingModeNotification(sender, frame); + ehtFem->SendEmlOmn(sender, frame); } void diff --git a/src/wifi/model/ap-wifi-mac.h b/src/wifi/model/ap-wifi-mac.h index 580748a2b..098cfa33b 100644 --- a/src/wifi/model/ap-wifi-mac.h +++ b/src/wifi/model/ap-wifi-mac.h @@ -48,7 +48,7 @@ class UniformRandomVariable; class MgtAssocRequestHeader; class MgtReassocRequestHeader; class MgtAssocResponseHeader; -class MgtEmlOperatingModeNotification; +class MgtEmlOmn; /// variant holding a reference to a (Re)Association Request using AssocReqRefVariant = std::variant, @@ -246,9 +246,7 @@ class ApWifiMac : public WifiMac * \param sender the MAC address of the sender of the frame * \param linkId the ID of the link over which the frame was received */ - void ReceiveEmlNotification(MgtEmlOperatingModeNotification& frame, - const Mac48Address& sender, - uint8_t linkId); + void ReceiveEmlOmn(MgtEmlOmn& frame, const Mac48Address& sender, uint8_t linkId); /** * The packet we sent was successfully received by the receiver diff --git a/src/wifi/model/block-ack-manager.cc b/src/wifi/model/block-ack-manager.cc index 62c213648..a6d3a5a05 100644 --- a/src/wifi/model/block-ack-manager.cc +++ b/src/wifi/model/block-ack-manager.cc @@ -30,6 +30,7 @@ #include "ns3/log.h" #include "ns3/simulator.h" +#include #include namespace ns3 @@ -689,21 +690,6 @@ BlockAckManager::ScheduleBar(const CtrlBAckRequestHeader& reqHdr, const WifiMacH m_queue->Enqueue(Create(pkt, hdr)); } -void -BlockAckManager::ScheduleMuBar(Ptr muBar) -{ - NS_LOG_FUNCTION(this << *muBar); - NS_ASSERT(muBar->GetHeader().IsTrigger()); - -#ifdef NS3_BUILD_PROFILE_DEBUG - CtrlTriggerHeader triggerHdr; - muBar->GetPacket()->PeekHeader(triggerHdr); - NS_ASSERT(triggerHdr.IsMuBar()); -#endif - - m_queue->Enqueue(muBar); -} - const std::list& BlockAckManager::GetSendBarIfDataQueuedList() const { diff --git a/src/wifi/model/block-ack-manager.h b/src/wifi/model/block-ack-manager.h index 5e1e68f0a..668fa9c90 100644 --- a/src/wifi/model/block-ack-manager.h +++ b/src/wifi/model/block-ack-manager.h @@ -418,14 +418,6 @@ class BlockAckManager : public Object * it is placed at the head of the queue, otherwise at the tail. */ void ScheduleBar(const CtrlBAckRequestHeader& reqHdr, const WifiMacHeader& hdr); - /** - * \param muBar the MU-BAR Trigger Frame to enqueue - * - * Enqueue the given MU-BAR Trigger Frame into the queue storing the next MU-BAR - * frames to transmit. If the given MU-BAR Trigger Frame is retransmitted, - * it is placed at the head of the queue, otherwise at the tail. - */ - void ScheduleMuBar(Ptr muBar); /// agreement key typedef (MAC address and TID) using AgreementKey = std::pair; diff --git a/src/wifi/model/channel-access-manager.cc b/src/wifi/model/channel-access-manager.cc index f380a1dd5..da41e3938 100644 --- a/src/wifi/model/channel-access-manager.cc +++ b/src/wifi/model/channel-access-manager.cc @@ -19,14 +19,16 @@ #include "channel-access-manager.h" -#include "frame-exchange-manager.h" #include "txop.h" #include "wifi-phy-listener.h" #include "wifi-phy.h" +#include "ns3/eht-frame-exchange-manager.h" #include "ns3/log.h" #include "ns3/simulator.h" +#include + #undef NS_LOG_APPEND_CONTEXT #define NS_LOG_APPEND_CONTEXT std::clog << "[link=" << +m_linkId << "] " @@ -36,7 +38,11 @@ namespace ns3 NS_LOG_COMPONENT_DEFINE("ChannelAccessManager"); /** - * Listener for PHY events. Forwards to ChannelAccessManager + * Listener for PHY events. Forwards to ChannelAccessManager. + * The ChannelAccessManager may handle multiple PHY listeners connected to distinct PHYs, + * but only one listener at a time can be active. Notifications from inactive listeners are + * ignored by the ChannelAccessManager, except for the channel switch notification. + * Inactive PHY listeners are typically configured by 11be EMLSR clients. */ class PhyListener : public ns3::WifiPhyListener { @@ -47,7 +53,8 @@ class PhyListener : public ns3::WifiPhyListener * \param cam the ChannelAccessManager */ PhyListener(ns3::ChannelAccessManager* cam) - : m_cam(cam) + : m_cam(cam), + m_active(true) { } @@ -55,60 +62,106 @@ class PhyListener : public ns3::WifiPhyListener { } + /** + * Set this listener to be active or not. + * + * \param active whether this listener is active or not + */ + void SetActive(bool active) + { + m_active = active; + } + + /** + * \return whether this listener is active or not + */ + bool IsActive() const + { + return m_active; + } + void NotifyRxStart(Time duration) override { - m_cam->NotifyRxStartNow(duration); + if (m_active) + { + m_cam->NotifyRxStartNow(duration); + } } void NotifyRxEndOk() override { - m_cam->NotifyRxEndOkNow(); + if (m_active) + { + m_cam->NotifyRxEndOkNow(); + } } void NotifyRxEndError() override { - m_cam->NotifyRxEndErrorNow(); + if (m_active) + { + m_cam->NotifyRxEndErrorNow(); + } } void NotifyTxStart(Time duration, double txPowerDbm) override { - m_cam->NotifyTxStartNow(duration); + if (m_active) + { + m_cam->NotifyTxStartNow(duration); + } } void NotifyCcaBusyStart(Time duration, WifiChannelListType channelType, const std::vector