diff --git a/.clang-tidy b/.clang-tidy index cf9f0822a..1a72f0934 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -28,23 +28,29 @@ Checks: > performance-inefficient-algorithm, performance-inefficient-vector-operation, performance-trivially-destructible, + performance-unnecessary-copy-initialization, readability-braces-around-statements, readability-container-size-empty, - readability-duplicate-include, readability-isolate-declaration, readability-make-member-function-const, - readability-misleading-indentation, readability-misplaced-array-index, readability-redundant-control-flow, readability-redundant-function-ptr-dereference, readability-redundant-smartptr-get, readability-redundant-string-cstr, + readability-simplify-boolean-expr, readability-simplify-subscript-expr, readability-static-accessed-through-instance, readability-static-definition-in-anonymous-namespace, readability-string-compare, readability-uppercase-literal-suffix, +CheckOptions: + - key: performance-unnecessary-copy-initialization.AllowedTypes + value: Ptr + - key: readability-simplify-boolean-expr.SimplifyDeMorgan + value: false + FormatStyle: "file" HeaderFilterRegex: ".*(ns|NS).*/(contrib|examples|src|scratch|utils)/*/.*h" UseColor: true diff --git a/.codespellrc b/.codespellrc index c428309c9..d63e5cad7 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,4 +1,5 @@ [codespell] -skip = .git,.gitlab-ci-local,*.eps,*.pdf,*.css_t,AUTHORS +skip = .git,.gitlab-ci-local,*.eps,*.pdf,*.css_t,AUTHORS,*build*,*.mob ignore-words = ./utils/codespell-ignored-words exclude-file = ./utils/codespell-ignored-lines +regex = (? + +### 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++-6 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). Specifically, avoid Cppyy version 3; stay with version 2.4.2 for this release. + +### New user-visible features + +- (applications) !1412 - Add Tx and TxWithAddresses trace sources in UdpClient +- (bindings) - Package ns-3 as a pip wheel +- (doc) #876 - Improve dark-mode heading, navigation, and search bars +- (flowmonitor) #901 - Allow to reset the stats +- (lr-wpan) !1399 - Add orphan scan support. +- (lr-wpan) !1402 - Add attributes to MLME-SET and MLME-GET +- (lr-wpan) !1410 - Add Mac16 and Mac64 functions +- (network) !1405 - Add ConvertToInt to Mac64Address + +Note: This release has removed the "wave" module from the codebase due to lack of maintenance +and due to lack of relevance to modern vehicular networks which appear to be moving to cellular +V2X solutions. Future users who may wish to use this code should obtain it from an earlier ns-3 +release but should also be aware of a number of issues that arose and can be found in the +[ns-3 Issue tracker](https://gitlab.com/nsnam/ns-3-dev/-/issues/?state=all&label_name%5B%5D=module%3A%3Awave); in particular, #249, #879, #872, and #637. + +### Bugs fixed + +- (build) #881 - Fix scratch targets for file names containing dots +- (core) #902 - Fix vector inversion in the function `AttributeContainerTestSuite::ReverseList()` +- (energy) !1422 - Fix null harvester issue in EnergySource +- (internet) #910 - Release memory when sockets are closed +- (lr-wpan) !1406 - Fixes issues during MAC scan +- (lr-wpan) !1481 - Small fixes in MAC orphan scan +- (lte) #906 - Don't use invalid cell ID +- (propagation) - fix height assignment in 3gpp propagation loss model +- (wifi) #880 - Post-install change in WifiPhy::ChannelSettings does not completely reconfigure Wi-Fi +- (wifi) #862 - sta-wifi-mac.cc cond="!link.bssid.has_value()", High occurrence at higher numbers of STAs per AP in indoor deployment. +- (wifi) - Fix the equality operator of WifiInformationElement +- (wifi) - Make the implementation of the Multi-Link Element compliant with the 11be specs by adding support of inheritance +- (wifi) - Reset intra-BSS NAV when CF-End is an intra-BSS PPDU +- (wifi) - UL MU CS shall be evaluated a SIFS after end of MU-RTS +- (wifi) - Fix crash when changing operating channel after configuration but before initialization +- (wifi) - Fix assert when non-HE STAs receive CTS frames sent using non-HT duplicate following a MU-RTS frame +- (wifi) - Fix OBSS-PD support for 802.11be +- (wifi) #917 - Add missing STA-ID in GetMode() call from YansErrorRateModel +- (wifi) - Fix wifi-rate-adaptation-distance.cc example issues with CCA threshold + Release 3.38 ------------ @@ -50,12 +110,17 @@ This release has discontinued support for g++-8 compilers. - (network) !938 - Added class `TimestampTag` for associating a timestamp with a packet. - (network) !1163 - Initializing an Ipv[4,6]Address from an invalid string do not raise an exception anymore. Instead the address is marked as not initialized. - (spectrum) !1046 - Added the TwoRaySpectrumPropagationLossModel fast-fading class, as the outcome of the related GSoC 2022 project titled "A simplified channel and beamforming model for ns-3" +- (spectrum) !1119 - Added a capability to filter signals (with a new SpectrumTransmitFilter) sent on the SpectrumChannel before they are forwarded to receivers on the channel. This is motivated by scalability (reducing inconsequential simulation events). +the TwoRaySpectrumPropagationLossModel fast-fading class, as the outcome of the related GSoC 2022 project titled "A simplified channel and beamforming model for ns-3" - (wifi) Added support for 802.11be Multi-Link Operations (MLO), STR mode only - (wifi) Added more fields to the EHT Capabilities information element - (wifi) Added an initial 802.11be-based example program - (wifi) Added 802.11ax dual NAV (basic NAV and intra-BSS NAV) - (wifi) Added 802.11ax Uplink Multi-User Carrier Sense (UL MU CS) mechanism and have it used by non-AP STAs when determining if they can reply to a received Trigger Frame - (wifi) Added support for 802.11ax MU-RTS/CTS protection +- (wifi) !1119 - Added, by default, a WifiBandwidthFilter to spectrum channels created by the SpectrumWifiHelper, so as to filter out-of-band signals from the receiver. +- (internet) InternetStackHelper can be now used on nodes with an InternetStack already installed (it will not install IPv[4,6] twice). +- (wifi) Added support to attach multiple spectrum channels to a same PHY and the possibility to track signals from multiple RF interfaces ### Bugs fixed diff --git a/VERSION b/VERSION index 5ca3687ec..d9fcf0a6a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.38 +3.39 diff --git a/bindings/python/ns__init__.py b/bindings/python/ns__init__.py index f43f639ce..f0f3c5d20 100644 --- a/bindings/python/ns__init__.py +++ b/bindings/python/ns__init__.py @@ -1,5 +1,4 @@ import builtins -from copy import copy from functools import lru_cache import glob import os.path @@ -11,7 +10,7 @@ DEFAULT_INCLUDE_DIR = sysconfig.get_config_var("INCLUDEDIR") DEFAULT_LIB_DIR = sysconfig.get_config_var("LIBDIR") -def find_ns3_lock(): +def find_ns3_lock() -> str: # Get the absolute path to this file path_to_this_init_file = os.path.dirname(os.path.abspath(__file__)) path_to_lock = path_to_this_init_file @@ -29,12 +28,14 @@ def find_ns3_lock(): if lock_file in os.listdir(path_to_lock): path_to_lock += os.sep + lock_file else: - path_to_lock = None + path_to_lock = "" return path_to_lock SYSTEM_LIBRARY_DIRECTORIES = (DEFAULT_LIB_DIR, - os.path.dirname(DEFAULT_LIB_DIR) + os.path.dirname(DEFAULT_LIB_DIR), + "/usr/lib64", + "/usr/lib" ) DYNAMIC_LIBRARY_EXTENSIONS = {"linux": "so", "win32": "dll", @@ -81,12 +82,14 @@ def _search_libraries() -> dict: # Search for the core library in the search paths libraries = [] for search_path in library_search_paths: - libraries += glob.glob("%s/**/*.%s*" % (search_path, LIBRARY_EXTENSION), recursive=True) + if os.path.exists(search_path): + libraries += glob.glob("%s/**/*.%s*" % (search_path, LIBRARY_EXTENSION), recursive=True) # Search system library directories (too slow for recursive search) for search_path in SYSTEM_LIBRARY_DIRECTORIES: - libraries += glob.glob("%s/**/*.%s*" % (search_path, LIBRARY_EXTENSION), recursive=False) - libraries += glob.glob("%s/*.%s*" % (search_path, LIBRARY_EXTENSION), recursive=False) + if os.path.exists(search_path): + libraries += glob.glob("%s/**/*.%s*" % (search_path, LIBRARY_EXTENSION), recursive=False) + libraries += glob.glob("%s/*.%s*" % (search_path, LIBRARY_EXTENSION), recursive=False) del search_path, library_search_paths @@ -120,8 +123,35 @@ def search_libraries(library_name: str) -> list: return matched_libraries -def extract_library_include_dirs(library_name: str, prefix: str) -> list: - library_path = "%s/lib/%s" % (prefix, library_name) +LIBRARY_AND_DEFINES = { + "libgsl": ["HAVE_GSL"], + "libxml2": ["HAVE_LIBXML2"], + "libsqlite3": ["HAVE_SQLITE3"], + "openflow": ["NS3_OPENFLOW", "ENABLE_OPENFLOW"], + "click": ["NS3_CLICK"] +} + + +def add_library_defines(library_name: str): + has_defines = list(filter(lambda x: x in library_name, LIBRARY_AND_DEFINES.keys())) + defines = "" + if len(has_defines): + for define in LIBRARY_AND_DEFINES[has_defines[0]]: + defines += (f""" + #ifndef {define} + #define {define} 1 + #endif + """) + return defines + + +def extract_linked_libraries(library_name: str, prefix: str) -> tuple: + lib = "" + for variant in ["lib", "lib64"]: + library_path = f"{prefix}/{variant}/{library_name}" + if os.path.exists(library_path): + lib = variant + break linked_libs = [] # First discover which 3rd-party libraries are used by the current module try: @@ -131,10 +161,17 @@ def extract_library_include_dirs(library_name: str, prefix: str) -> list: print("Failed to extract libraries used by {library} with exception:{exception}" .format(library=library_path, exception=e)) exit(-1) + return library_path, lib, list(map(lambda x: x.decode("utf-8"), linked_libs)) + + +def extract_library_include_dirs(library_name: str, prefix: str) -> tuple: + library_path, lib, linked_libs = extract_linked_libraries(library_name, prefix) linked_libs_include_dirs = set() + defines = add_library_defines(library_name) + # Now find these libraries and add a few include paths for them - for linked_library in map(lambda x: x.decode("utf-8"), linked_libs): + for linked_library in linked_libs: # Skip ns-3 modules if "libns3" in linked_library: continue @@ -148,15 +185,18 @@ def extract_library_include_dirs(library_name: str, prefix: str) -> list: "Failed to find {library}. Make sure its library directory is in LD_LIBRARY_PATH.".format( library=linked_library)) - # Get path with shortest length + # Get path with the shortest length linked_library_path = sorted(linked_library_path, key=lambda x: len(x))[0] # If library is part of the ns-3 build, continue without any new includes if prefix in linked_library_path: continue + # Add defines based in linked libraries found + defines += add_library_defines(linked_library) + # If it is part of the system directories, try to find it - system_include_dir = os.path.dirname(linked_library_path).replace("lib", "include") + system_include_dir = os.path.dirname(linked_library_path).replace(lib, "include") if os.path.exists(system_include_dir): linked_libs_include_dirs.add(system_include_dir) @@ -179,134 +219,214 @@ def extract_library_include_dirs(library_name: str, prefix: str) -> list: inc_path = os.path.join(lib_path, "include") if os.path.exists(inc_path): linked_libs_include_dirs.add(inc_path) - return list(linked_libs_include_dirs) + return list(linked_libs_include_dirs), defines + + +def find_ns3_from_lock_file(lock_file: str) -> (str, list, str): + # Load NS3_ENABLED_MODULES from the lock file inside the build directory + values = {} + + # If we find a lock file, load the ns-3 modules from it + # Should be the case when running from the source directory + exec(open(lock_file).read(), {}, values) + suffix = "-" + values["BUILD_PROFILE"] if values["BUILD_PROFILE"] != "release" else "" + modules = [module.replace("ns3-", "") for module in values["NS3_ENABLED_MODULES"]] + prefix = values["out_dir"] + libraries = {os.path.splitext(os.path.basename(x))[0]: x for x in os.listdir(os.path.join(prefix, "lib"))} + version = values["VERSION"] + + # Filter out test libraries and incorrect versions + def filter_in_matching_ns3_libraries(libraries_to_filter: dict, + modules_to_filter: list, + version: str, + suffix: str) -> dict: + suffix = [suffix[1:]] if len(suffix) > 1 else [] + filtered_in_modules = [] + for module in modules_to_filter: + filtered_in_modules += list(filter(lambda x: "-".join([version, module, *suffix]) in x, + libraries_to_filter.keys())) + for library in list(libraries_to_filter.keys()): + if library not in filtered_in_modules: + libraries_to_filter.pop(library) + return libraries_to_filter + + libraries = filter_in_matching_ns3_libraries(libraries, modules, version, suffix) + + # When we have the lock file, we assemble the correct library names + libraries_to_load = [] + for module in modules: + library_name = "libns{version}-{module}{suffix}".format( + version=version, + module=module, + suffix=suffix + ) + if library_name not in libraries: + raise Exception("Missing library %s\n" % library_name, + "Build all modules with './ns3 build'" + ) + libraries_to_load.append(libraries[library_name]) + return prefix, libraries_to_load, version + + +# Extract version and build suffix (if it exists) +def filter_module_name(library: str) -> str: + library = os.path.splitext(os.path.basename(library))[0] + components = library.split("-") + + # Remove version-related prefixes + if "libns3" in components[0]: + components.pop(0) + if "dev" == components[0]: + components.pop(0) + if "rc" in components[0]: + components.pop(0) + + # Drop build profile suffix and test libraries + if components[-1] in ["debug", "default", "optimized", "release", "relwithdebinfo", "minsizerel"]: + components.pop(-1) + return "-".join(components) + + +def extract_version(library: str, module: str) -> str: + library = os.path.basename(library) + return re.findall(r"libns([\d.|rc|\-dev]+)-", library)[0] + + +def get_newest_version(versions: list) -> str: + versions = list(sorted(versions)) + if "dev" in versions[0]: + return versions[0] + + # Check if there is a release of a possible candidate + try: + pos = versions.index(os.path.splitext(versions[-1])[0]) + except ValueError: + pos = None + + # Remove release candidates + if pos is not None: + return versions[pos] + else: + return versions[-1] + + +def find_ns3_from_search() -> (str, list, str): + libraries = search_libraries("ns3") + + if not libraries: + raise Exception("ns-3 libraries were not found.") + + # If there is a version with a hash by the end, we have a pip-installed library + pip_libraries = list(filter(lambda x: "python" in x, libraries)) + if pip_libraries: + # We drop non-pip libraries + libraries = pip_libraries + + # The prefix is the directory with the lib directory + # libns3-dev-core.so/../../ + prefix = os.path.dirname(os.path.dirname(libraries[0])) + + # Remove test libraries + libraries = list(filter(lambda x: "test" not in x, libraries)) + + # Filter out module names + modules = set([filter_module_name(library) for library in libraries]) + + def filter_in_newest_ns3_libraries(libraries_to_filter: list, modules_to_filter: list) -> tuple: + newest_version_found = "" + # Filter out older ns-3 libraries + for module in list(modules_to_filter): + # Filter duplicates of modules, while excluding test libraries + conflicting_libraries = list(filter(lambda x: module == filter_module_name(x), libraries_to_filter)) + + # Extract versions from conflicting libraries + conflicting_libraries_versions = list(map(lambda x: extract_version(x, module), conflicting_libraries)) + + # Get the newest version found for that library + newest_version = get_newest_version(conflicting_libraries_versions) + + # Check if the version found is the global newest version + if not newest_version_found: + newest_version_found = newest_version + else: + newest_version_found = get_newest_version([newest_version, newest_version_found]) + if newest_version != newest_version_found: + raise Exception("Incompatible versions of the ns-3 module '%s' were found: %s != %s." + % (module, newest_version, newest_version_found)) + + for conflicting_library in list(conflicting_libraries): + if "-".join([newest_version, module]) not in conflicting_library: + libraries.remove(conflicting_library) + conflicting_libraries.remove(conflicting_library) + + if len(conflicting_libraries) > 1: + raise Exception("There are multiple build profiles for module '%s'.\nDelete one to continue: %s" + % (module, ", ".join(conflicting_libraries))) + + return libraries_to_filter, newest_version_found + + # Get library base names + libraries, version = filter_in_newest_ns3_libraries(libraries, list(modules)) + return prefix, libraries, version def load_modules(): lock_file = find_ns3_lock() libraries_to_load = [] - if lock_file: - # Load NS3_ENABLED_MODULES from the lock file inside the build directory - values = {} + # Search for prefix to ns-3 build, modules and respective libraries plus version + ret = find_ns3_from_search() if not lock_file else find_ns3_from_lock_file(lock_file) - # If we find a lock file, load the ns-3 modules from it - # Should be the case when running from the source directory - exec(open(lock_file).read(), {}, values) - suffix = "-" + values["BUILD_PROFILE"] if values["BUILD_PROFILE"] != "release" else "" - modules = [module.replace("ns3-", "") for module in values["NS3_ENABLED_MODULES"]] - prefix = values["out_dir"] - libraries = {os.path.splitext(os.path.basename(x))[0]: x for x in os.listdir(os.path.join(prefix, "lib"))} - version = values["VERSION"] + # Unpack returned values + prefix, libraries, version = ret + prefix = os.path.abspath(prefix) - # Filter out test libraries and incorrect versions - def filter_in_matching_ns3_libraries(libraries_to_filter: dict, - modules_to_filter: list, - version: str, - suffix: str) -> dict: - suffix = [suffix[1:]] if len(suffix) > 1 else [] - filtered_in_modules = [] - for module in modules_to_filter: - filtered_in_modules += list(filter(lambda x: "-".join([version, module, *suffix]) in x, - libraries_to_filter.keys())) - for library in list(libraries_to_filter.keys()): - if library not in filtered_in_modules: - libraries_to_filter.pop(library) - return libraries_to_filter + # Sort libraries according to their dependencies + def sort_to_dependencies(libraries: list, prefix: str) -> list: + module_dependencies = {} + libraries = list(map(lambda x: os.path.basename(x), libraries)) + for ns3_library in libraries: + _, _, linked_libraries = extract_linked_libraries(ns3_library, prefix) + linked_libraries = list(filter(lambda x: "libns3" in x and ns3_library not in x, linked_libraries)) + linked_libraries = list(map(lambda x: os.path.basename(x), linked_libraries)) + module_dependencies[os.path.basename(ns3_library)] = linked_libraries - libraries = filter_in_matching_ns3_libraries(libraries, modules, version, suffix) - else: - libraries = search_libraries("ns3") + def modules_that_can_be_loaded(module_dependencies, pending_modules, current_modules): + modules = [] + for pending_module in pending_modules: + can_be_loaded = True + for dependency in module_dependencies[pending_module]: + if dependency not in current_modules: + can_be_loaded = False + break + if not can_be_loaded: + continue + modules.append(pending_module) + return modules - if not libraries: - raise Exception("ns-3 libraries were not found.") + def dependency_order(module_dependencies, pending_modules, current_modules, step_number=0, steps={}): + if len(pending_modules) == 0: + return steps + if step_number not in steps: + steps[step_number] = [] + for module in modules_that_can_be_loaded(module_dependencies, pending_modules, current_modules): + steps[step_number].append(module) + pending_modules.remove(module) + current_modules.append(module) + return dependency_order(module_dependencies, pending_modules, current_modules, step_number + 1, steps) - # The prefix is the directory with the lib directory - # libns3-dev-core.so/../../ - prefix = os.path.dirname(os.path.dirname(libraries[0])) + sorted_libraries = [] + for step in dependency_order(module_dependencies, list(module_dependencies.keys()), [], 0).values(): + sorted_libraries.extend(step) + return sorted_libraries - # Remove test libraries - libraries = list(filter(lambda x: "test" not in x, libraries)) + libraries_to_load = sort_to_dependencies(libraries, prefix) - # Extract version and build suffix (if it exists) - def filter_module_name(library): - library = os.path.splitext(os.path.basename(library))[0] - components = library.split("-") + # Extract library base names + libraries_to_load = [os.path.basename(x) for x in libraries_to_load] - # Remove version-related prefixes - if "libns3" in components[0]: - components.pop(0) - if "dev" == components[0]: - components.pop(0) - if "rc" in components[0]: - components.pop(0) - - # Drop build profile suffix and test libraries - if components[-1] in ["debug", "default", "optimized", "release", "relwithdebinfo"]: - components.pop(-1) - return "-".join(components) - - # Filter out module names - modules = set([filter_module_name(library) for library in libraries]) - - def extract_version(library: str, module: str) -> str: - library = os.path.basename(library) - return re.findall(r"libns([\d.|rc|\-dev]+)-", library)[0] - - def get_newest_version(versions: list) -> str: - versions = list(sorted(versions)) - if "dev" in versions[0]: - return versions[0] - - # Check if there is a release of a possible candidate - try: - pos = versions.index(os.path.splitext(versions[-1])[0]) - except ValueError: - pos = None - - # Remove release candidates - if pos is not None: - return versions[pos] - else: - return versions[-1] - - def filter_in_newest_ns3_libraries(libraries_to_filter: list, modules_to_filter: list) -> list: - newest_version_found = None - # Filter out older ns-3 libraries - for module in list(modules_to_filter): - # Filter duplicates of modules, while excluding test libraries - conflicting_libraries = list(filter(lambda x: module == filter_module_name(x), libraries_to_filter)) - - # Extract versions from conflicting libraries - conflicting_libraries_versions = list(map(lambda x: extract_version(x, module), conflicting_libraries)) - - # Get the newest version found for that library - newest_version = get_newest_version(conflicting_libraries_versions) - - # Check if the version found is the global newest version - if not newest_version_found: - newest_version_found = newest_version - else: - newest_version_found = get_newest_version([newest_version, newest_version_found]) - if newest_version != newest_version_found: - raise Exception("Incompatible versions of the ns-3 module '%s' were found: %s != %s." - % (module, newest_version, newest_version_found)) - - for conflicting_library in list(conflicting_libraries): - if "-".join([newest_version, module]) not in conflicting_library: - libraries.remove(conflicting_library) - conflicting_libraries.remove(conflicting_library) - num_libraries -= 1 - - if len(conflicting_libraries) > 1: - raise Exception("There are multiple build profiles for module '%s'.\nDelete one to continue: %s" - % (module, ", ".join(conflicting_libraries))) - - return libraries_to_filter - - # Get library base names - libraries = filter_in_newest_ns3_libraries(libraries, modules) - libraries_to_load = list(map(lambda x: os.path.basename(x), libraries)) + # Sort modules based on libraries + modules = list(map(lambda x: filter_module_name(x), libraries_to_load)) # Try to import Cppyy and warn the user in case it is not found try: @@ -324,35 +444,27 @@ def load_modules(): libcppyy.AddSmartPtrType('Ptr') # Import ns-3 libraries - prefix = os.path.abspath(prefix) - cppyy.add_library_path("%s/lib" % prefix) - cppyy.add_include_path("%s/include" % prefix) - - if lock_file: - # When we have the lock file, we assemble the correct library names - for module in modules: - library_name = "libns{version}-{module}{suffix}".format( - version=version, - module=module, - suffix=suffix - ) - if library_name not in libraries: - raise Exception("Missing library %s\n" % library_name, - "Build all modules with './ns3 build'" - ) - libraries_to_load.append(libraries[library_name]) + for variant in ["lib", "lib64"]: + path_to_lib = f"{prefix}/{variant}" + if not os.path.exists(path_to_lib): + continue + cppyy.add_library_path(path_to_lib) + del variant, path_to_lib + cppyy.add_include_path(f"{prefix}/include") known_include_dirs = set() # We then need to include all include directories for dependencies for library in libraries_to_load: - for linked_lib_include_dir in extract_library_include_dirs(library, prefix): + linked_lib_include_dirs, defines = extract_library_include_dirs(library, prefix) + cppyy.cppexec(defines) + for linked_lib_include_dir in linked_lib_include_dirs: if linked_lib_include_dir not in known_include_dirs: known_include_dirs.add(linked_lib_include_dir) if os.path.isdir(linked_lib_include_dir): cppyy.add_include_path(linked_lib_include_dir) for module in modules: - cppyy.include("ns3/%s-module.h" % module) + cppyy.include(f"ns3/{module}-module.h") # After including all headers, we finally load the modules for library in libraries_to_load: diff --git a/build-support/cmake-format-modules.txt b/build-support/cmake-format-modules.yaml similarity index 100% rename from build-support/cmake-format-modules.txt rename to build-support/cmake-format-modules.yaml diff --git a/build-support/cmake-format.txt b/build-support/cmake-format.yaml similarity index 100% rename from build-support/cmake-format.txt rename to build-support/cmake-format.yaml diff --git a/build-support/custom-modules/ns3-module-macros.cmake b/build-support/custom-modules/ns3-module-macros.cmake index 91398da5f..4dd9f6d75 100644 --- a/build-support/custom-modules/ns3-module-macros.cmake +++ b/build-support/custom-modules/ns3-module-macros.cmake @@ -104,7 +104,9 @@ function(build_lib) ) endif() - if(NOT FILESYSTEM_LIBRARY_IS_LINKED) + if((NOT FILESYSTEM_LIBRARY_IS_LINKED) OR (${GCC} AND ${GCC8})) + # The GCC8 alternative is necessary since when installed alongside newer + # releases, the incorrect shared library can end up being linked. list(APPEND BLIB_LIBRARIES_TO_LINK -lstdc++fs) endif() @@ -144,6 +146,15 @@ function(build_lib) foreach(library ${BLIB_LIBRARIES_TO_LINK}) remove_lib_prefix("${library}" module_name) + # Ignore the case where the library dependency name match the ns-3 module + # since it is most likely is due to brite, click and openflow collisions. + # All the ns-3 module targets should be prefixed with 'lib' to be + # differentiable. + if("${library}" STREQUAL "${BLIB_LIBNAME}") + list(APPEND non_ns_libraries_to_link ${library}) + continue() + endif() + # Check if the module exists in the ns-3 modules list or if it is a # 3rd-party library if(${module_name} IN_LIST ns3-all-enabled-modules) @@ -193,6 +204,20 @@ function(build_lib) ${lib${BLIB_LIBNAME}} ${exported_libraries} ${private_libraries} ) + if(NOT ${XCODE}) + # Since linking libraries to object libraries in not allowed in older CMake + # releases, we need to import each of their include directories. Otherwise, + # include directories won't be properly propagated + set(temp) + foreach(target ${ns_libraries_to_link}) + list(APPEND temp + "$" + ) + endforeach() + target_include_directories(${lib${BLIB_LIBNAME}}-obj PRIVATE ${temp}) + unset(temp) + endif() + # set output name of library set_target_properties( ${lib${BLIB_LIBNAME}} diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 8622038c3..c6ae5895c 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -36,6 +36,9 @@ option(NS3_ENABLE_SUDO "Set executables ownership to root and enable the SUID flag" OFF ) +# a flag that controls some aspects related to pip packaging +option(NS3_PIP_PACKAGING "Control aspects related to pip wheel packaging" OFF) + # Replace default CMake messages (logging) with custom colored messages as early # as possible include(${PROJECT_SOURCE_DIR}/build-support/3rd-party/colored-messages.cmake) @@ -71,6 +74,11 @@ if(WIN32) set(NS3_PRECOMPILE_HEADERS OFF CACHE BOOL "Precompile module headers to speed up compilation" FORCE ) + + # For whatever reason getting M_PI and other math.h definitions from cmath + # requires this definition + # https://docs.microsoft.com/en-us/cpp/c-runtime-library/math-constants?view=vs-2019 + add_definitions(/D_USE_MATH_DEFINES) endif() set(cat_command cat) @@ -148,6 +156,25 @@ link_directories(${CMAKE_OUTPUT_DIRECTORY}/lib) include(GNUInstallDirs) include(build-support/custom-modules/ns3-cmake-package.cmake) +# Set RPATH not too need LD_LIBRARY_PATH after installing +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:$ORIGIN/:$ORIGIN/../lib") + +# Add the 64 suffix to the library path when manually requested with the +# -DNS3_USE_LIB64=ON flag. May be necessary depending on the target platform. +# This is used to properly build the manylinux pip wheel. +if(${NS3_USE_LIB64}) + link_directories(${CMAKE_OUTPUT_DIRECTORY}/lib64) + set(CMAKE_INSTALL_RPATH + "${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib64:$ORIGIN/:$ORIGIN/../lib64" + ) +endif() + +# cmake-format: off +# You are a wizard, Harry! +# source: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling +# cmake-format: on +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + if(${XCODE}) # Is that so hard not to break people's CI, AAPL? Why would you output the # targets to a Debug/Release subfolder? Why? @@ -202,6 +229,7 @@ if(CLANG) endif() set(GCC FALSE) +set(GCC8 FALSE) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${GNU_MinVersion}) message( @@ -209,6 +237,12 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") "GNU ${CMAKE_CXX_COMPILER_VERSION} ${below_minimum_msg} ${GNU_MinVersion}" ) endif() + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0") + # This block is used to identify if GCC8 is being used. In this case, we + # want to explicitly link stdc++fs, which is done in + # ns3-module-macros.cmake. + set(GCC8 TRUE) + endif() set(GCC TRUE) add_definitions(-fno-semantic-interposition) if(${NS3_COLORED_OUTPUT} OR "$ENV{CLICOLOR}") @@ -222,6 +256,7 @@ unset(below_minimum_msg) set(CXX_UNSUPPORTED_STANDARDS 98 11 14) set(CMAKE_CXX_STANDARD_MINIMUM 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) set(LIB_AS_NEEDED_PRE) set(LIB_AS_NEEDED_POST) set(STATIC_LINK_FLAGS -static -static-libstdc++ -static-libgcc) @@ -308,7 +343,6 @@ macro(clear_global_cached_variables) unset(ns3-headers-to-module-map CACHE) unset(ns3-libs CACHE) unset(ns3-libs-tests CACHE) - unset(ns3-python-bindings-modules CACHE) mark_as_advanced( build_profile build_profile_suffix @@ -322,7 +356,6 @@ macro(clear_global_cached_variables) ns3-headers-to-module-map ns3-libs ns3-libs-tests - ns3-python-bindings-modules ) endmacro() @@ -410,6 +443,8 @@ macro(process_options) if(${NS3_TESTS} OR ${ns3rc_tests_enabled}) set(ENABLE_TESTS ON) enable_testing() + else() + list(REMOVE_ITEM libs_to_build test) endif() set(profiles_without_suffixes release) @@ -553,11 +588,11 @@ macro(process_options) cmake-format COMMAND ${CMAKE_FORMAT_PROGRAM} -c - ${PROJECT_SOURCE_DIR}/build-support/cmake-format.txt -i + ${PROJECT_SOURCE_DIR}/build-support/cmake-format.yaml -i ${INTERNAL_CMAKE_FILES} COMMAND ${CMAKE_FORMAT_PROGRAM} -c - ${PROJECT_SOURCE_DIR}/build-support/cmake-format-modules.txt -i + ${PROJECT_SOURCE_DIR}/build-support/cmake-format-modules.yaml -i ${MODULES_CMAKE_FILES} ) unset(MODULES_CMAKE_FILES) @@ -802,7 +837,7 @@ macro(process_options) find_package(Python3 COMPONENTS Interpreter Development) else() # cmake-format: off - set(Python_ADDITIONAL_VERSIONS 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9) + set(Python_ADDITIONAL_VERSIONS 3.6 3.7 3.8 3.9 3.10 3.11) # cmake-format: on find_package(PythonInterp) find_package(PythonLibs) @@ -856,10 +891,12 @@ macro(process_options) ) endif() else() - message( - ${HIGHLIGHTED_STATUS} - "Python: an incompatible version of Python was found, python bindings will be disabled" - ) + if(${NS3_PYTHON_BINDINGS}) + message( + ${HIGHLIGHTED_STATUS} + "Python: an incompatible version of Python was found, python bindings will be disabled" + ) + endif() endif() set(ENABLE_PYTHON_BINDINGS OFF) @@ -901,12 +938,16 @@ macro(process_options) message( ${HIGHLIGHTED_STATUS} "NS3_BINDINGS_INSTALL_DIR was not set. The python bindings won't be installed with ./ns3 install." + "This setting is meant for packaging and redistribution." ) message( ${HIGHLIGHTED_STATUS} "Set NS3_BINDINGS_INSTALL_DIR=\"${SUGGESTED_BINDINGS_INSTALL_DIR}\" to install it to the default location." ) else() + if(${NS3_BINDINGS_INSTALL_DIR} STREQUAL "INSTALL_PREFIX") + set(NS3_BINDINGS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) + endif() install(FILES bindings/python/ns__init__.py DESTINATION ${NS3_BINDINGS_INSTALL_DIR}/ns RENAME __init__.py ) @@ -1370,8 +1411,6 @@ macro(process_options) set(ns3-contrib-libs) set(lib-ns3-static-objs) set(ns3-external-libs) - set(ns3-python-bindings ns${NS3_VER}-pybindings${build_profile_suffix}) - set(ns3-python-bindings-modules) foreach(libname ${scanned_modules}) # Create libname of output library of module @@ -1497,7 +1536,7 @@ macro(process_options) include(FetchContent) FetchContent_Declare( netanim GIT_REPOSITORY https://gitlab.com/nsnam/netanim.git - GIT_TAG netanim-3.108 + GIT_TAG netanim-3.109 ) FetchContent_Populate(netanim) file(COPY build-support/3rd-party/netanim-cmakelists.cmake @@ -1597,8 +1636,11 @@ function(build_exec) ) # Resolve nested scratch prefixes without user intervention - if("${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "scratch" - AND "${BEXEC_EXECNAME_PREFIX}" STREQUAL "" + string(REPLACE "${PROJECT_SOURCE_DIR}" "" relative_path + "${CMAKE_CURRENT_SOURCE_DIR}" + ) + if("${relative_path}" MATCHES "scratch" AND "${BEXEC_EXECNAME_PREFIX}" + STREQUAL "" ) get_scratch_prefix(BEXEC_EXECNAME_PREFIX) endif() @@ -1946,10 +1988,6 @@ macro( unset(dependencies) unset(contrib_dependencies) endforeach() - - if(core IN_LIST ${libs_to_build}) - list(APPEND ${libs_to_build} test) # include test module - endif() endif() if(${NS3_DISABLED_MODULES} OR ${ns3rc_disabled_modules}) diff --git a/build-support/pip-wheel/auditwheel-exclude-list.py b/build-support/pip-wheel/auditwheel-exclude-list.py new file mode 100644 index 000000000..02ea3d24c --- /dev/null +++ b/build-support/pip-wheel/auditwheel-exclude-list.py @@ -0,0 +1,11 @@ +import os + +ns3_path = os.path.dirname(os.path.abspath(os.sep.join([__file__, "../../"]))) + +for variant in ["lib", "lib64"]: + lib_dir = os.path.abspath(os.path.join(ns3_path, f"build/{variant}")) + if not os.path.exists(lib_dir): + continue + for lib in os.listdir(lib_dir): + if "libns3" in lib: + print(f"--exclude {lib}", end=' ') diff --git a/build-support/pip-wheel/ns/__init__.py b/build-support/pip-wheel/ns/__init__.py new file mode 100644 index 000000000..65ea85d7a --- /dev/null +++ b/build-support/pip-wheel/ns/__init__.py @@ -0,0 +1,10 @@ +# This is a stub module that loads the actual ns-3 +# bindings from ns3.ns +import sys + +try: + import ns3.ns + sys.modules['ns'] = ns3.ns +except ModuleNotFoundError as e: + print("Install the ns3 package with pip install ns3.", file=sys.stderr) + exit(-1) diff --git a/build-support/pip-wheel/visualizer/__init__.py b/build-support/pip-wheel/visualizer/__init__.py new file mode 100644 index 000000000..f1f712403 --- /dev/null +++ b/build-support/pip-wheel/visualizer/__init__.py @@ -0,0 +1,11 @@ +# This is a stub module that loads the actual visualizer +# from ns3.visualizer +import sys + +try: + import ns3.visualizer +except ModuleNotFoundError as e: + print("Install the ns3 package with pip install ns3.", file=sys.stderr) + exit(-1) + +from ns3.visualizer import start, register_plugin, set_bounds, add_initialization_hook diff --git a/build-support/pybindings-LP64-to-ILP32.py b/build-support/pybindings-LP64-to-ILP32.py deleted file mode 100644 index 5526ed2c9..000000000 --- a/build-support/pybindings-LP64-to-ILP32.py +++ /dev/null @@ -1,16 +0,0 @@ -#! /usr/bin/env python3 -# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- - -def lp64_to_ilp32(lp64path, ilp32path): - import re - lp64bindings = None - with open(lp64path, "r") as lp64file: - lp64bindings = lp64file.read() - with open(ilp32path, "w") as ilp32file: - ilp32bindings = re.sub("unsigned long(?!( long))", "unsigned long long", lp64bindings) - ilp32file.write(ilp32bindings) - -if __name__ == "__main__": - import sys - print(sys.argv) - exit(lp64_to_ilp32(sys.argv[1], sys.argv[2])) diff --git a/build-support/test-files/test-contrib-dependency/CMakeLists.txt b/build-support/test-files/test-contrib-dependency/CMakeLists.txt new file mode 100644 index 000000000..c3eef2dca --- /dev/null +++ b/build-support/test-files/test-contrib-dependency/CMakeLists.txt @@ -0,0 +1,6 @@ +build_lib( + LIBNAME test-contrib-dependency + SOURCE_FILES contrib-source.cc + HEADER_FILES contrib-header.h + LIBRARIES_TO_LINK ${libcore} +) diff --git a/build-support/test-files/test-contrib-dependency/contrib-header.h b/build-support/test-files/test-contrib-dependency/contrib-header.h new file mode 100644 index 000000000..39325f2f0 --- /dev/null +++ b/build-support/test-files/test-contrib-dependency/contrib-header.h @@ -0,0 +1,6 @@ +#ifndef NS3_CONTRIB_HEADER_H +#define NS3_CONTRIB_HEADER_H + +void testPrint(); + +#endif // NS3_CONTRIB_HEADER_H diff --git a/build-support/test-files/test-contrib-dependency/contrib-source.cc b/build-support/test-files/test-contrib-dependency/contrib-source.cc new file mode 100644 index 000000000..5c6e4831d --- /dev/null +++ b/build-support/test-files/test-contrib-dependency/contrib-source.cc @@ -0,0 +1,9 @@ +#include "contrib-header.h" + +#include + +void +testPrint() +{ + std::cout << ns3::Simulator::Now() << std::endl; +} diff --git a/build-support/test-files/test-src-dependant-on-contrib/CMakeLists.txt b/build-support/test-files/test-src-dependant-on-contrib/CMakeLists.txt new file mode 100644 index 000000000..6da487312 --- /dev/null +++ b/build-support/test-files/test-src-dependant-on-contrib/CMakeLists.txt @@ -0,0 +1,8 @@ +build_lib( + LIBNAME test-src-dependant-on-contrib + SOURCE_FILES src-source.cc + HEADER_FILES src-header.h + LIBRARIES_TO_LINK ${libcore} + ${libtest-contrib-dependency} +) + diff --git a/build-support/test-files/test-src-dependant-on-contrib/examples/CMakeLists.txt b/build-support/test-files/test-src-dependant-on-contrib/examples/CMakeLists.txt new file mode 100644 index 000000000..2146b7fac --- /dev/null +++ b/build-support/test-files/test-src-dependant-on-contrib/examples/CMakeLists.txt @@ -0,0 +1,6 @@ +build_lib_example( + NAME source-example + SOURCE_FILES source-example.cc + LIBRARIES_TO_LINK + ${libtest-src-dependant-on-contrib} +) diff --git a/build-support/test-files/test-src-dependant-on-contrib/examples/source-example.cc b/build-support/test-files/test-src-dependant-on-contrib/examples/source-example.cc new file mode 100644 index 000000000..de2a710d6 --- /dev/null +++ b/build-support/test-files/test-src-dependant-on-contrib/examples/source-example.cc @@ -0,0 +1,8 @@ +#include + +int +main() +{ + testPrint2(); + return 0; +} diff --git a/build-support/test-files/test-src-dependant-on-contrib/src-header.h b/build-support/test-files/test-src-dependant-on-contrib/src-header.h new file mode 100644 index 000000000..f92194ee9 --- /dev/null +++ b/build-support/test-files/test-src-dependant-on-contrib/src-header.h @@ -0,0 +1,6 @@ +#ifndef NS3_SRC_SOURCE2_H +#define NS3_SRC_SOURCE2_H + +void testPrint2(); + +#endif // NS3_SOURCE_H diff --git a/build-support/test-files/test-src-dependant-on-contrib/src-source.cc b/build-support/test-files/test-src-dependant-on-contrib/src-source.cc new file mode 100644 index 000000000..7b8074da2 --- /dev/null +++ b/build-support/test-files/test-src-dependant-on-contrib/src-source.cc @@ -0,0 +1,7 @@ +#include + +void +testPrint2() +{ + testPrint(); +} diff --git a/doc/contributing/source/coding-style.rst b/doc/contributing/source/coding-style.rst index 5875ab101..09e07bc34 100644 --- a/doc/contributing/source/coding-style.rst +++ b/doc/contributing/source/coding-style.rst @@ -129,6 +129,9 @@ their code and for the GitLab CI/CD pipeline to check if the codebase is well fo All checks are enabled by default. Users can disable specific checks using the corresponding flags: ``--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. + In addition to checking the files, the script can automatically fix detected issues in-place. This mode is enabled by adding the ``--fix`` flag. @@ -148,16 +151,16 @@ 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] [--no-formatting] [--no-whitespace] [--no-tabs] . + ./utils/check-style-clang-format.py [--fix] [--verbose] [--no-formatting] [--no-whitespace] [--no-tabs] . # Entire codebase (using absolute paths) - /path/to/utils/check-style-clang-format.py [--fix] [--no-formatting] [--no-whitespace] [--no-tabs] /path/to/ns3 + /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] [--no-formatting] [--no-whitespace] [--no-tabs] absolute_or_relative/path/to/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] [--no-formatting] [--no-whitespace] [--no-tabs] absolute_or_relative/path/to/file + /path/to/utils/check-style-clang-format.py [--fix] [--verbose] [--no-formatting] [--no-whitespace] [--no-tabs] absolute_or_relative/path/to/file Clang-tidy @@ -752,8 +755,8 @@ For standard headers, use the C++ style of inclusion: #include -Variables -========= +Variables and constants +======================= Each variable declaration is on a separate line. Variables should be declared at the point in the code where they are needed, @@ -768,6 +771,34 @@ and should be assigned an initial value at the time of declaration. int x = 0; int y = 0; +Named constants defined in classes should be declared as ``static constexpr`` instead of +macros, const, or enums. Use of ``static constexpr`` allows a single instance to be +evaluated at compile-time. Declaring the constant in the class enables it to share the scope +of the class. + +If the constant is only used in one file, consider declaring the constant in the implementation +file (``*.cc``). + +.. sourcecode:: cpp + + // Avoid declaring constants as enum + class LteRlcAmHeader : public Header + { + enum ControlPduType_t + { + STATUS_PDU = 000, + }; + }; + + // Prefer to declare them as static constexpr (in class) + class LteRlcAmHeader : public Header + { + static constexpr uint8_t STATUS_PDU{0}; + }; + + // Or as constexpr (in implementation files) + constexpr uint8_t STATUS_PDU{0}; + Comments ======== @@ -1096,6 +1127,53 @@ can be rewritten as: n += 3; return n; +Boolean Simplifications +======================= + +In order to increase readability and performance, avoid unnecessarily complex boolean +expressions in if statements and variable declarations. + +For instance, the following code: + + .. sourcecode:: cpp + + bool IsPositive(int n) + { + if (n > 0) + { + return true; + } + else + { + return false; + } + } + + void ProcessNumber(int n) + { + if (IsPositive(n) == true) + { + ... + } + } + +can be rewritten as: + + .. sourcecode:: cpp + + bool IsPositive(int n) + { + return n > 0; + } + + void ProcessNumber(int n) + { + if (IsPositive(n)) + { + ... + } + } + Smart pointer boolean comparisons ================================= diff --git a/doc/contributing/source/conf.py b/doc/contributing/source/conf.py index 36b709068..20ce22bac 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.38' +version = 'ns-3.39' # The full version, including alpha/beta/rc tags. -release = 'ns-3.38' +release = 'ns-3.39' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/contributing/source/general.rst b/doc/contributing/source/general.rst index 7edf1c391..3fb1bba09 100644 --- a/doc/contributing/source/general.rst +++ b/doc/contributing/source/general.rst @@ -95,7 +95,6 @@ the previous copyrights from the copyright file! See below for this case. An example placement of a copyright statement can be found in the file ``src/network/model/packet.h``:: - /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2005,2006 INRIA * @@ -112,7 +111,6 @@ contributor may add a copyright statement that clarifies the new portion of code that is covered by the new copyright. An example is the program ``src/lte/model/lte-ue-phy.h``:: - /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari * Copyright (c) 2018 Fraunhofer ESK : RLF extensions diff --git a/doc/doxygen.conf b/doc/doxygen.conf index 1ee923022..9306cf4aa 100644 --- a/doc/doxygen.conf +++ b/doc/doxygen.conf @@ -1881,7 +1881,7 @@ PAPER_TYPE = a4 # If left blank no extra packages will be included. # This tag requires that the tag GENERATE_LATEX is set to YES. -EXTRA_PACKAGES = amsmath +EXTRA_PACKAGES = amsmath,amssymb # The LATEX_HEADER tag can be used to specify a user-defined LaTeX header for # the generated LaTeX document. The header should contain everything until the @@ -2693,5 +2693,5 @@ GENERATE_LEGEND = YES DOT_CLEANUP = YES # Disable dark mode in the generated HTML in Doxygen 1.9.6 or greater. -HTML_COLORSTYLE = LIGHT +# HTML_COLORSTYLE = LIGHT diff --git a/doc/installation/source/conf.py b/doc/installation/source/conf.py index d4d4f43d7..9d56b8a40 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.38' +version = 'ns-3.39' # The full version, including alpha/beta/rc tags. -release = 'ns-3.38' +release = 'ns-3.39' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/installation/source/linux.rst b/doc/installation/source/linux.rst index 0f1cf65a8..663eb66b8 100644 --- a/doc/installation/source/linux.rst +++ b/doc/installation/source/linux.rst @@ -21,8 +21,8 @@ extensions you need; please review the previous chapter if you need more informa Requirements ************ -The minimum supported version of Ubuntu is Ubuntu 16.04 LTS (as long as a modern compiler -version such as g++ version 8 or later is added). +The minimum supported version of Ubuntu is Ubuntu 18.04 LTS (as long as a modern compiler +version such as g++ version 9 or later is added). +--------------------+---------------------------------------------------------------------+ | **ns-3 Version** | **apt Packages** | @@ -35,11 +35,8 @@ version such as g++ version 8 or later is added). +--------------------+---------------------------------------------------------------------+ .. note:: - As of January 2022 (ns-3.36 release and later), the minimum g++ version is g++-8. - Older Ubuntu releases (18.04, 16.04) come with an older default g++. On Ubuntu 18.04, this - `StackOverflow answer `_ can be followed to install and - prefer g++-8. On older Ubuntu such as 16.04, to use the most recent |ns3|, you must install - g++-8 or g++-9 from the `Ubuntu toolchain `_. + As of July 2023 (ns-3.39 release and later), the minimum g++ version is g++-9. + Older ns-3 releases may work with older versions of g++; check the RELEASE_NOTES. Recommended *********** @@ -106,9 +103,11 @@ Please see below subsections for Python-related package requirements. Python bindings =============== +Python requires `Cppyy, ` and specifically, version 2.4.2 is the latest version known to work with ns-3 at this time. + ns-3.37 and newer:: - python3 -m pip install --user cppyy + python3 -m pip install --user cppyy==2.4.2 ns-3.30-3.36 (also requires pybindgen, found in the ``allinone`` directory):: diff --git a/doc/installation/source/overview.rst b/doc/installation/source/overview.rst index 02c01f5ce..30a5e7adc 100644 --- a/doc/installation/source/overview.rst +++ b/doc/installation/source/overview.rst @@ -51,11 +51,9 @@ choose to use a subset of the available libraries; only the ``core`` library is |ns3| uses the CMake build system (until release 3.36, the Waf build system was used). It can be built from command-line or via a code editor program. -Most users write C++ ns-3 programs; Python support is less frequently used and is not officially -maintained as of this writing. As of *ns-3.37*, |ns3| uses `cppyy` to generate runtime Python -bindings. Officially, Python3 support is only lightly maintained, and the `cppyy` support was -contributed by Gabriel Ferreira as a proof-of-concept (hint: the project is seeking a full-time -maintainer to develop this further). +Most users write C++ ns-3 programs; Python support is less frequently used. +As of *ns-3.37*, |ns3| uses `cppyy` to generate runtime Python +bindings, and |ns3| is available in the Pip repositories as of ns-3.39 release. Many users may be familiar with how software is packaged and installed on Linux and other systems using package managers. For example, to install a given Linux development library such as diff --git a/doc/installation/source/quick-start.rst b/doc/installation/source/quick-start.rst index 202092989..bb7813883 100644 --- a/doc/installation/source/quick-start.rst +++ b/doc/installation/source/quick-start.rst @@ -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.38`` +1. Download a release tarball. This will unpack to a directory such as ``ns-allinone-3.39`` 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.38.tar.bz2 - $ tar xfj ns-allinone-3.38.tar.bz2 - $ cd ns-allinone-3.38/ns-3.38 + $ 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 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.38-release ns-3.38 + $ git checkout -b ns-3.39-release ns-3.39 In this quick-start, we are omitting download and build instructions for optional |ns3| modules, the ``NetAnim`` animator, Python bindings, and ``NetSimulyzer``. The @@ -152,8 +152,8 @@ You should see some output such as below, if successful:: propagation sixlowpan spectrum stats tap-bridge test (no Python) topology-read traffic-control uan - virtual-net-device visualizer wave - wifi wimax + virtual-net-device visualizer wifi + wimax Modules not built (see ns-3 tutorial for explanation): brite click openflow diff --git a/doc/installation/source/system.rst b/doc/installation/source/system.rst index a4c8731ba..a458d6510 100644 --- a/doc/installation/source/system.rst +++ b/doc/installation/source/system.rst @@ -140,7 +140,8 @@ if you are running LTE or NR simulations (which make use of SQLite databases): Python bindings (ns-3.37 and newer) =================================== -|ns3| Python support now uses `cppyy `_. +|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. Using Python bindings (release 3.30 to ns-3.36) =============================================== diff --git a/doc/manual/source/conf.py b/doc/manual/source/conf.py index 1011e13a7..b82319874 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.38' +version = u'ns-3.39' # The full version, including alpha/beta/rc tags. -release = u'ns-3.38' +release = u'ns-3.39' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/manual/source/events.rst b/doc/manual/source/events.rst index b77c03db6..a7c39dd7b 100644 --- a/doc/manual/source/events.rst +++ b/doc/manual/source/events.rst @@ -326,20 +326,20 @@ complexity on `Insert()` and `RemoveNext()`, are listed in the following table. See the individual Scheduler API pages for details on the complexity of the other API calls. -+-----------------------+-------------------------------------+-------------+--------------+----------+--------------+ -| Scheduler Type | Complexity | -+-----------------------+-------------------------------------+-------------+--------------+----------+--------------+ -| | | Time | Space | -| `SchedulerImpl` Type | Method +-------------+--------------+----------+--------------+ -| | | Insert() | RemoveNext() | Overhead | Per Event | -+=======================+=====================================+=============+==============+==========+==============+ -| CalendarScheduler | ` []` | Constant | Constant | 24 bytes | 16 bytes | -+-----------------------+-------------------------------------+-------------+--------------+----------+--------------+ -| HeapScheduler | Heap on `std::vector` | Logarithmic | Logarithmic | 24 bytes | 0 | -+-----------------------+-------------------------------------+-------------+--------------+----------+--------------+ -| ListScheduler | `std::list` | Linear | Constant | 24 bytes | 16 bytes | -+-----------------------+-------------------------------------+-------------+--------------+----------+--------------+ -| MapScheduler | `st::map` | Logarithmic | Constant | 40 bytes | 32 bytes | -+-----------------------+-------------------------------------+-------------+--------------+----------+--------------+ -| PriorityQueueSchduler | `std::priority_queue<,std::vector>` | Logarithimc | Logarithims | 24 bytes | 0 | -+-----------------------+-------------------------------------+-------------+--------------+----------+--------------+ ++------------------------+-------------------------------------+-------------+--------------+----------+--------------+ +| Scheduler Type | Complexity | ++------------------------+-------------------------------------+-------------+--------------+----------+--------------+ +| | | Time | Space | +| `SchedulerImpl` Type | Method +-------------+--------------+----------+--------------+ +| | | Insert() | RemoveNext() | Overhead | Per Event | ++========================+=====================================+=============+==============+==========+==============+ +| CalendarScheduler | ` []` | Constant | Constant | 24 bytes | 16 bytes | ++------------------------+-------------------------------------+-------------+--------------+----------+--------------+ +| HeapScheduler | Heap on `std::vector` | Logarithmic | Logarithmic | 24 bytes | 0 | ++------------------------+-------------------------------------+-------------+--------------+----------+--------------+ +| ListScheduler | `std::list` | Linear | Constant | 24 bytes | 16 bytes | ++------------------------+-------------------------------------+-------------+--------------+----------+--------------+ +| MapScheduler | `st::map` | Logarithmic | Constant | 40 bytes | 32 bytes | ++------------------------+-------------------------------------+-------------+--------------+----------+--------------+ +| PriorityQueueScheduler | `std::priority_queue<,std::vector>` | Logarithimc | Logarithims | 24 bytes | 0 | ++------------------------+-------------------------------------+-------------+--------------+----------+--------------+ diff --git a/doc/manual/source/logging-asserts.rst b/doc/manual/source/logging-asserts.rst index 3504b86c8..095ef4d0d 100644 --- a/doc/manual/source/logging-asserts.rst +++ b/doc/manual/source/logging-asserts.rst @@ -14,8 +14,8 @@ The |ns3| logging facility can be used to monitor or debug the progress of simulation programs. Logging output can be enabled by program statements in your ``main()`` program or by the use of the ``NS_LOG`` environment variable. -Logging statements are not compiled into optimized builds of |ns3|. To use -logging, one must build the (default) debug build of |ns3|. +Logging statements are not compiled into ``optimized`` builds of |ns3|. To use +logging, one must use the ``default`` or ``debug`` build profiles of |ns3|. The project makes no guarantee about whether logging output will remain the same over time. Users are cautioned against building simulation output @@ -29,21 +29,20 @@ Overview execution events, such as the occurrence of simulation events or the use of a particular function. -For example, this code snippet is from ``Ipv4L3Protocol::IsDestinationAddress()``:: +For example, this code snippet is from ``TcpSocketBase::EnterCwr()`` and informs the user that +the model is reducing the congestion window and changing state:: - if (address == iaddr.GetBroadcast()) - { - NS_LOG_LOGIC("For me (interface broadcast address)"); - return true; - } + NS_LOG_INFO("Enter CWR recovery mode; set cwnd to " << m_tcb->m_cWnd << ", ssthresh to " + << m_tcb->m_ssThresh << ", recover to " + << m_recover); If logging has been enabled for the ``Ipv4L3Protocol`` component at a severity -of ``LOGIC`` or above (see below about log severity), the statement +of ``INFO`` or above (see below about log severity), the statement will be printed out; otherwise, it will be suppressed. The logging implementation is enabled in ``debug`` and ``default`` builds, but disabled in all other build profiles, -so has no impact of execution speed. +so that it does not impact the execution speed of more optimized profiles. You can try the example program `log-example.cc` in `src/core/example` with various values for the `NS_LOG` environment variable to see the @@ -138,21 +137,21 @@ Severity and Level Options Individual messages belong to a single "severity class," set by the macro creating the message. In the example above, -``NS_LOG_LOGIC(..)`` creates the message in the ``LOG_LOGIC`` severity class. +``NS_LOG_INFO(..)`` creates the message in the ``LOG_INFO`` severity class. The following severity classes are defined as ``enum`` constants: -================ ===================================== +================ ========================================================= Severity Class Meaning -================ ===================================== +================ ========================================================= ``LOG_NONE`` The default, no logging ``LOG_ERROR`` Serious error messages only ``LOG_WARN`` Warning messages -``LOG_DEBUG`` For use in debugging -``LOG_INFO`` Informational +``LOG_INFO`` Info about the model changing state ``LOG_FUNCTION`` Function tracing -``LOG_LOGIC`` Control flow tracing within functions -================ ===================================== +``LOG_LOGIC`` For tracing key decision points or branches in a function +``LOG_DEBUG`` For use in debugging +================ ========================================================= Typically one wants to see messages at a given severity class *and higher*. This is done by defining inclusive logging "levels": @@ -162,10 +161,10 @@ Level Meaning ====================== =========================================== ``LOG_LEVEL_ERROR`` Only ``LOG_ERROR`` severity class messages. ``LOG_LEVEL_WARN`` ``LOG_WARN`` and above. -``LOG_LEVEL_DEBUG`` ``LOG_DEBUG`` and above. ``LOG_LEVEL_INFO`` ``LOG_INFO`` and above. ``LOG_LEVEL_FUNCTION`` ``LOG_FUNCTION`` and above. ``LOG_LEVEL_LOGIC`` ``LOG_LOGIC`` and above. +``LOG_LEVEL_DEBUG`` ``LOG_DEBUG`` and above. ``LOG_LEVEL_ALL`` All severity classes. ``LOG_ALL`` Synonym for ``LOG_LEVEL_ALL`` ====================== =========================================== @@ -178,10 +177,10 @@ Class Level ============ ================= ``error`` ``level_error`` ``warn`` ``level_warn`` -``debug`` ``level_debug`` ``info`` ``level_info`` ``function`` ``level_function`` ``logic`` ``level_logic`` +``debug`` ``level_debug`` .. | ``level_all`` | ``all`` | ``*`` @@ -193,8 +192,8 @@ For example, ``NS_LOG="*=warn"`` won't output messages with severity ``error``. ``debug`` and above. Severity classes and levels can be combined with the \`|' operator: -``NS_LOG="*=level_warn|logic"`` will output messages at severity levels -``error``, ``warn`` and ``logic``. +``NS_LOG="*=level_warn|debug"`` will output messages at severity levels +``error``, ``warn`` and ``debug``, but not ``info``, ``function``, or ``logic``. The ``NS_LOG`` severity level wildcard \`*' and ``all`` are synonyms for ``level_all``. @@ -265,10 +264,10 @@ class (``|prefix_level``). Scratch Simulator [ERROR] error message [WARN] warn message - [DEBUG] debug message [INFO] info message [FUNCT] function message [LOGIC] logic message + [DEBUG] debug message Time Prefix ########### @@ -415,10 +414,10 @@ Logging Macros ``LOG_NONE`` (none needed) ``LOG_ERROR`` ``NS_LOG_ERROR(...);`` ``LOG_WARN`` ``NS_LOG_WARN(...);`` - ``LOG_DEBUG`` ``NS_LOG_DEBUG(...);`` ``LOG_INFO`` ``NS_LOG_INFO(...);`` ``LOG_FUNCTION`` ``NS_LOG_FUNCTION(...);`` ``LOG_LOGIC`` ``NS_LOG_LOGIC(...);`` + ``LOG_DEBUG`` ``NS_LOG_DEBUG(...);`` ================ ========================== The macros function as output streamers, so anything you can send to @@ -449,15 +448,21 @@ severity. This macro does not use any of the prefix options. Recall that logging is only enabled in ``debug``, ``default`` and ``relwithdebinfo`` builds, so this macro will only produce output in the same builds. +The |ns3| model libraries do not typically use the ``NS_LOG_UNCOND(...)`` macro; +it is provided for users for assistance with debugging. + Guidelines ========== -* Start every class method with ``NS_LOG_FUNCTION(this << args...);`` +* Start every significant class method with ``NS_LOG_FUNCTION(this << args...);`` This enables easy function call tracing. - * Except: don't log operators or explicit copy constructors, + * Exception 1: don't log operators or explicit copy constructors, since these will cause infinite recursion and stack overflow. + * Exception 2: For simple methods such as getters, avoid function + logging because it tends to overload the logging output. + * For methods without arguments use the same form: ``NS_LOG_FUNCTION(this);`` @@ -467,26 +472,49 @@ Guidelines * Without arguments use ``NS_LOG_FUNCTION_NOARGS();`` * Use ``NS_LOG_ERROR`` for serious error conditions that probably - invalidate the simulation execution. + invalidate the simulation execution. Note that in |ns3|, we typically + abort the simulation under such conditions rather than log it as + an error (which might go undetected if the user is not using logging). + The ``NS_ABORT_MSG_IF/UNLESS(cond,msg)`` macros and variants, as well + as the lower-level ``NS_FATAL_ERROR(msg)`` macro, can be used to terminate + the simulation with an error message. -* Use ``NS_LOG_WARN`` for unusual conditions that may be correctable. +* Use ``NS_LOG_WARN`` for unusual conditions that are not considered + invalid. An example might be that some resource has been exhausted + (e.g., the DHCP server has run out of addresses to allocate). Please give some hints as to the nature of the problem and how it might be corrected. -* ``NS_LOG_DEBUG`` is usually used in an *ad hoc* way to understand - the execution of a model. +* Use ``NS_LOG_INFO`` for events that cause a state change in the model. + Avoid using it for logging periodic events that are not causing a + state change (e.g., a Wi-Fi beacon is sent, but all nodes are already + associated to the access point). Try to be efficient in using it; + for instance, sending a message is usually an important state change event, + but try to capture this event with one single log message at the ``INFO`` + level rather than multiple. If multiple log messages are desired to + fully capture the event and all of its consequences, use ``DEBUG`` level + for the additional messages. The intent of this log level is to allow a + user to examine the normal operation of a model without becoming overwhelmed + by the output. -* Use ``NS_LOG_INFO`` for additional information about the execution, - such as the size of a data structure when adding/removing from it. +* ``NS_LOG_LOGIC`` is used to trace important logic branches or decision points + within a function, without dumping all details of the variable states, + called function return values, individual iterations, etc. It may be useful + to think of it as a less granular level of function logging than ``DEBUG,`` + and may not be used by all models (some authors may choose to only use + ``DEBUG`` level for full logging). -* Use ``NS_LOG_LOGIC`` to trace important logic branches within a function. +* ``NS_LOG_DEBUG`` is usually used for full voluminous debugging, and contains + much more information than ``NS_LOG_INFO``, such as the detailed execution + logic of functions and the values that variables take within those functions. * Test that your logging changes do not break the code. Run some example programs with all log components turned on (e.g. ``NS_LOG="***"``). -* Use an explicit cast for any variable of type uint8_t or int8_t, - e.g., ``NS_LOG_LOGIC("Variable i is " << static_cast(i));``. +* Use a unary operator (preferred) or an explicit cast for any variable of type uint8_t or int8_t, + e.g., ``NS_LOG_DEBUG("Variable i is " << +i);``. + e.g., ``NS_LOG_DEBUG("Variable i is " << static_cast(i));`` or Without the cast, the integer is interpreted as a char, and the result will be most likely not in line with the expectations. This is a well documented C++ 'feature'. diff --git a/doc/manual/source/python.rst b/doc/manual/source/python.rst index ca7e14fee..6ad5ec803 100644 --- a/doc/manual/source/python.rst +++ b/doc/manual/source/python.rst @@ -101,10 +101,25 @@ Here is some example code that is written in Python and that runs |ns3|, which i Running Python Scripts ********************** -The main prerequisite is to install `cppyy`. Depending on how you may manage +For users that want to change upstream modules in C++ and got a copy of +ns-3 by Git cloning the ns-3-dev repository, or downloaded the +ns3-allinone package, or is using bake, continue to the next section. + +`Note: models implemented in Python are not available from C++. If you want +your model to be available for both C++ and Python users, you must implement +it in C++.` + +For users that want to exclusively run simulation scenarios and implement +simple modules in python, jump to the `Using the pip wheel`_ section. + +Using the bindings from the ns-3 source +======================================= + +The main prerequisite is to install `cppyy`, with version no later than 2.4.2. +Depending on how you may manage Python extensions, the installation instructions may vary, but you can first check if it installed by seeing if the `cppyy` module can be -successfully imported: +successfully imported and the version is no later than 2.4.2: .. sourcecode:: bash @@ -113,6 +128,8 @@ successfully imported: [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cppyy + >>> print("%s" % cppyy.__version) + 2.4.2 >>> If not, you may try to install via `pip` or whatever other manager you are @@ -120,7 +137,7 @@ using; e.g.: .. sourcecode:: bash - $ python3 -m pip install --user cppyy + $ python3 -m pip install --user cppyy==2.4.2 First, we need to enable the build of Python bindings: @@ -135,13 +152,13 @@ To run example programs, there are two ways to use ns3 to take care of this. On .. sourcecode:: bash $ ./ns3 shell - $ python3 examples/wireless/mixed-wireless.py + $ python3 examples/wireless/mixed-wired-wireless.py and the other is to use the 'run' option to ns3: .. sourcecode:: bash - $ ./ns3 run examples/wireless/mixed-wireless.py + $ ./ns3 run examples/wireless/mixed-wired-wireless.py Use the ``--no-build`` option to run the program without invoking a project rebuild. This option may be useful to improve execution time when running the same program @@ -149,14 +166,14 @@ repeatedly but with different arguments, such as from scripts. .. sourcecode:: bash - $ ./ns3 run --no-build examples/wireless/mixed-wireless.py + $ ./ns3 run --no-build examples/wireless/mixed-wired-wireless.py To run a python script under the C debugger: .. sourcecode:: bash $ ./ns3 shell - $ gdb --args python3 examples/wireless/mixed-wireless.py + $ gdb --args python3 examples/wireless/mixed-wired-wireless.py To run your own Python script that calls |ns3| and that has this path, ``/path/to/your/example/my-script.py``, do the following: @@ -165,6 +182,133 @@ To run your own Python script that calls |ns3| and that has this path, ``/path/t $ ./ns3 shell $ python3 /path/to/your/example/my-script.py + +Using the pip wheel +=================== + +Starting from ns-3.38, we provide a pip wheel for Python users using Linux. + +.. sourcecode:: bash + + $ pip install --user ns3 + +You can select a specific ns-3 version by specifying the wheel version. +Specifying a nonexistent version will result in an error message listing the available versions. + +.. sourcecode:: bash + + $ pip install --user ns3==3.37 + Defaulting to user installation because normal site-packages is not writeable + ERROR: Could not find a version that satisfies the requirement ns3==3.37 (from versions: 3.37.post415) + ERROR: No matching distribution found for ns3==3.37 + +You can also specify you want at least a specific version (e.g. which shipped a required feature). + +.. sourcecode:: bash + + $ pip install --user ns3>=3.37 + Defaulting to user installation because normal site-packages is not writeable + Requirement already satisfied: ns3==3.37.post415 in /home/username/.local/lib/python3.10/site-packages (3.37.post415) + Requirement already satisfied: cppyy in /home/username/.local/lib/python3.10/site-packages (from ns3==3.37.post415) (2.4.2) + Requirement already satisfied: cppyy-backend==1.14.10 in /home/username/.local/lib/python3.10/site-packages (from cppyy->ns3==3.37.post415) (1.14.10) + Requirement already satisfied: CPyCppyy==1.12.12 in /home/username/.local/lib/python3.10/site-packages (from cppyy->ns3==3.37.post415) (1.12.12) + Requirement already satisfied: cppyy-cling==6.27.1 in /home/username/.local/lib/python3.10/site-packages (from cppyy->ns3==3.37.post415) (6.27.1) + +To check if the pip wheel was installed, use the pip freeze command to list the installed packages, +then grep ns3 to filter the line of interest. + +.. sourcecode:: bash + + $ pip freeze | grep ns3 + ns3==3.37.post415 + +.. _ns3 wheel: https://pypi.org/project/ns3/#history + +The available versions are also listed on the Pypi page for the `ns3 wheel`_. + +After installing it, you can start using ns-3 right away. For example, using the following script. + +:: + + from ns import ns + + ns.cppyy.cppdef(""" + using namespace ns3; + + Callback,const Address&,const Address&> + make_sinktrace_callback(void(*func)(Ptr,Address,Address)) + { + return MakeCallback(func); + } + """) + + # Define the trace callback + def SinkTracer(packet: ns.Packet, src_address: ns.Address, dst_address: ns.Address) -> None: + print(f"At {ns.Simulator.Now().GetSeconds():.0f}s, '{dst_address}' received packet" + f" with {packet.__deref__().GetSerializedSize()} bytes from '{src_address}'") + + # Create two nodes + csmaNodes = ns.network.NodeContainer() + csmaNodes.Create(2) + + # Connect the two nodes + csma = ns.csma.CsmaHelper() + csma.SetChannelAttribute("DataRate", ns.core.StringValue("100Mbps")) + csma.SetChannelAttribute("Delay", ns.core.TimeValue(ns.core.NanoSeconds(6560))) + csmaDevices = csma.Install(csmaNodes) + + # Install the internet stack + stack = ns.internet.InternetStackHelper() + stack.Install(csmaNodes) + + # Assign Ipv4 addresses + address = ns.internet.Ipv4AddressHelper() + address.SetBase(ns.network.Ipv4Address("10.1.2.0"), ns.network.Ipv4Mask("255.255.255.0")) + csmaInterfaces = address.Assign(csmaDevices) + + # Setup applications + echoServer = ns.applications.UdpEchoServerHelper(9) + + serverApps = echoServer.Install(csmaNodes.Get(0)) + serverApps.Start(ns.core.Seconds(1.0)) + serverApps.Stop(ns.core.Seconds(10.0)) + + echoClient = ns.applications.UdpEchoClientHelper(csmaInterfaces.GetAddress(0).ConvertTo(), 9) + echoClient.SetAttribute("MaxPackets", ns.core.UintegerValue(10)) + echoClient.SetAttribute("Interval", ns.core.TimeValue(ns.core.Seconds(1.0))) + echoClient.SetAttribute("PacketSize", ns.core.UintegerValue(1024)) + + clientApps = echoClient.Install(csmaNodes.Get(1)) + clientApps.Start(ns.core.Seconds(2.0)) + clientApps.Stop(ns.core.Seconds(10.0)) + + # Populate routing tables + ns.internet.Ipv4GlobalRoutingHelper.PopulateRoutingTables() + + # Setup the trace callback + sinkTraceCallback = ns.cppyy.gbl.make_sinktrace_callback(SinkTracer) + serverApps.Get(0).__deref__().TraceConnectWithoutContext("RxWithAddresses", sinkTraceCallback); + + # Set the simulation duration to 11 seconds + ns.Simulator.Stop(ns.Seconds(11)) + + # Run the simulator + ns.Simulator.Run() + ns.Simulator.Destroy() + +Which should print: + +.. sourcecode:: bash + + At 2s, '04-07-00:00:00:00:09:00:00' received packet with 60 bytes from '04-07-0a:01:02:02:01:c0:00' + At 3s, '04-07-00:00:00:00:09:00:00' received packet with 60 bytes from '04-07-0a:01:02:02:01:c0:00' + At 4s, '04-07-00:00:00:00:09:00:00' received packet with 60 bytes from '04-07-0a:01:02:02:01:c0:00' + At 5s, '04-07-00:00:00:00:09:00:00' received packet with 60 bytes from '04-07-0a:01:02:02:01:c0:00' + At 6s, '04-07-00:00:00:00:09:00:00' received packet with 60 bytes from '04-07-0a:01:02:02:01:c0:00' + At 7s, '04-07-00:00:00:00:09:00:00' received packet with 60 bytes from '04-07-0a:01:02:02:01:c0:00' + At 8s, '04-07-00:00:00:00:09:00:00' received packet with 60 bytes from '04-07-0a:01:02:02:01:c0:00' + At 9s, '04-07-00:00:00:00:09:00:00' received packet with 60 bytes from '04-07-0a:01:02:02:01:c0:00' + Caveats ******* @@ -382,6 +526,240 @@ example. There is no structured documentation for the Python bindings like there is Doxygen for the C++ API, but the Doxygen can be consulted to understand how the C++ API works. +To inspect what function and classes are available, you can use +the ``dir`` function. Examples below: + +.. sourcecode:: bash + + >>> print(dir(ns.Simulator)) + ['Cancel', 'Destroy', 'GetContext', 'GetDelayLeft', 'GetEventCount', 'GetImplementation', 'GetMaximumSimulationTime', 'GetSystemId', 'IsExpired', 'IsFinished', 'NO_CONTEXT', 'Now', 'Remove', 'Run', 'Schedule', 'ScheduleDestroy', 'ScheduleNow', 'ScheduleWithContext', 'SetImplementation', 'SetScheduler', 'Stop', '__add__', '__assign__', '__bool__', '__class__', '__delattr__', '__destruct__', '__dict__', '__dir__', '__dispatch__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__invert__', '__le__', '__lt__', '__module__', '__mul__', '__ne__', '__neg__', '__new__', '__pos__', '__python_owns__', '__radd__', '__reduce__', '__reduce_ex__', '__repr__', '__reshape__', '__rmul__', '__rsub__', '__rtruediv__', '__setattr__', '__sizeof__', '__smartptr__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__weakref__'] + >>> print(dir(ns.DefaultSimulatorImpl)) + ['AggregateObject', 'Cancel', 'Destroy', 'Dispose', 'GetAggregateIterator', 'GetAttribute', 'GetAttributeFailSafe', 'GetContext', 'GetDelayLeft', 'GetEventCount', 'GetInstanceTypeId', 'GetMaximumSimulationTime', 'GetObject', 'GetReferenceCount', 'GetSystemId', 'GetTypeId', 'Initialize', 'IsExpired', 'IsFinished', 'IsInitialized', 'Now', 'PreEventHook', 'Ref', 'Remove', 'Run', 'Schedule', 'ScheduleDestroy', 'ScheduleNow', 'ScheduleWithContext', 'SetAttribute', 'SetAttributeFailSafe', 'SetScheduler', 'Stop', 'TraceConnect', 'TraceConnectWithoutContext', 'TraceDisconnect', 'TraceDisconnectWithoutContext', 'Unref', '__add__', '__assign__', '__bool__', '__class__', '__delattr__', '__destruct__', '__dict__', '__dir__', '__dispatch__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__invert__', '__le__', '__lt__', '__module__', '__mul__', '__ne__', '__neg__', '__new__', '__pos__', '__python_owns__', '__radd__', '__reduce__', '__reduce_ex__', '__repr__', '__reshape__', '__rmul__', '__rsub__', '__rtruediv__', '__setattr__', '__sizeof__', '__smartptr__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__weakref__'] + >>> print(dir(ns.Time)) + ['AUTO', 'As', 'Compare', 'D', 'FS', 'From', 'FromDouble', 'FromInteger', 'GetDays', 'GetDouble', 'GetFemtoSeconds', 'GetHours', 'GetInteger', 'GetMicroSeconds', 'GetMilliSeconds', 'GetMinutes', 'GetNanoSeconds', 'GetPicoSeconds', 'GetResolution', 'GetSeconds', 'GetTimeStep', 'GetYears', 'H', 'IsNegative', 'IsPositive', 'IsStrictlyNegative', 'IsStrictlyPositive', 'IsZero', 'LAST', 'MIN', 'MS', 'Max', 'Min', 'NS', 'PS', 'RoundTo', 'S', 'SetResolution', 'StaticInit', 'To', 'ToDouble', 'ToInteger', 'US', 'Y', '__add__', '__assign__', '__bool__', '__class__', '__delattr__', '__destruct__', '__dict__', '__dir__', '__dispatch__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__invert__', '__le__', '__lt__', '__module__', '__mul__', '__ne__', '__neg__', '__new__', '__pos__', '__python_owns__', '__radd__', '__reduce__', '__reduce_ex__', '__repr__', '__reshape__', '__rmul__', '__rsub__', '__rtruediv__', '__setattr__', '__sizeof__', '__smartptr__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__weakref__'] + + +To get more information about expected arguments, you can use the ``help`` +function. + +.. sourcecode:: bash + + >>> help(ns.DefaultSimulatorImpl) + class DefaultSimulatorImpl(SimulatorImpl) + | Method resolution order: + | DefaultSimulatorImpl + | SimulatorImpl + | Object + | SimpleRefCount + | ObjectBase + | cppyy.gbl.CPPInstance + | builtins.object + | + | Methods defined here: + | + | Cancel(...) + | void ns3::DefaultSimulatorImpl::Cancel(const ns3::EventId& id) + | + | Destroy(...) + | void ns3::DefaultSimulatorImpl::Destroy() + | + | GetContext(...) + | unsigned int ns3::DefaultSimulatorImpl::GetContext() + | + | GetDelayLeft(...) + | ns3::Time ns3::DefaultSimulatorImpl::GetDelayLeft(const ns3::EventId& id) + | + | GetEventCount(...) + | unsigned long ns3::DefaultSimulatorImpl::GetEventCount() + | + | GetMaximumSimulationTime(...) + | ns3::Time ns3::DefaultSimulatorImpl::GetMaximumSimulationTime() + | + | GetSystemId(...) + | unsigned int ns3::DefaultSimulatorImpl::GetSystemId() + | + | GetTypeId(...) + | static ns3::TypeId ns3::DefaultSimulatorImpl::GetTypeId() + | + | IsExpired(...) + | bool ns3::DefaultSimulatorImpl::IsExpired(const ns3::EventId& id) + | + | IsFinished(...) + | bool ns3::DefaultSimulatorImpl::IsFinished() + | + | Now(...) + | ns3::Time ns3::DefaultSimulatorImpl::Now() + | + | Remove(...) + | void ns3::DefaultSimulatorImpl::Remove(const ns3::EventId& id) + | + | Run(...) + | void ns3::DefaultSimulatorImpl::Run() + + +Pip wheel packaging +******************* + +This section is meant exclusively for ns-3 maintainers and ns-3 +users that want to redistribute their work as wheels for python. + +The packaging process is defined in the following GitLab job. +The job is split into blocks explained below. + +The manylinux image provides an old glibc compatible with most modern Linux +distributions, resulting on a pip wheel that is compatible across distributions. + +.. sourcecode:: yaml + + .manylinux-pip-wheel: + image: quay.io/pypa/manylinux_2_28_x86_64 + +Then we install the required toolchain and dependencies necessary for both +ns-3 (e.g. libxml2, gsl, sqlite, gtk, etc) and for the bindings and packaging +(e.g. setuptools, wheel, auditwheel, cmake-build-extension, cppyy). + +.. sourcecode:: yaml + + # Install minimal toolchain + - yum install -y libxml2-devel gsl-devel sqlite-devel gtk3-devel boost-devel + # Create Python venv + - $PYTHON -m venv ./venv + - . ./venv/bin/activate + # Upgrade the pip version to reuse the pre-build cppyy + - $PYTHON -m pip install pip --upgrade + - $PYTHON -m pip install setuptools setuptools_scm --upgrade + - $PYTHON -m pip install wheel auditwheel cmake-build-extension cppyy + +The project is then configured loading the configuration settings defined +in the ``ns-3-dev/setup.py`` file. + +.. sourcecode:: yaml + + # Configure and build wheel + - $PYTHON setup.py bdist_wheel build_ext "-DNS3_USE_LIB64=TRUE" + +At this point, we have a wheel that only works in the current system, +since external libraries are not shipped. + +Auditwheel needs to be called resolve and copy external libraries +that we need to ship along the ns-3 module libraries (e.g. libxml2, sqlite3, +gtk, gsl, etc). However, we need to prevent auditwheel from shipping copies of +the libraries built by the ns-3 project. A list of excluded libraries is generated +by the script ``ns-3-dev/build-support/pip-wheel/auditwheel-exclude-list.py``. + +.. sourcecode:: yaml + + - export EXCLUDE_INTERNAL_LIBRARIES=`$PYTHON ./build-support/pip-wheel/auditwheel-exclude-list.py` + # Bundle in shared libraries that were not explicitly packaged or depended upon + - $PYTHON -m auditwheel repair ./dist/*whl -L /lib64 $EXCLUDE_INTERNAL_LIBRARIES + + +At this point, we should have our final wheel ready, but we need to check if it works +before submitting it to Pypi servers. + +We first clean the environment and uninstall the packages previously installed. + +.. sourcecode:: yaml + + # Clean the build directory + - $PYTHON ./ns3 clean + # Clean up the environment + - deactivate + - rm -R ./venv + # Delete toolchain to check if required headers/libraries were really packaged + - yum remove -y libxml2-devel gsl-devel sqlite-devel gtk3-devel boost-devel + + +Then we can install our newly built wheel and test it. + +.. sourcecode:: yaml + + # Install wheel + - $PYTHON -m pip install ./wheelhouse/*whl + - $PYTHON -m pip install matplotlib numpy + # Test the bindings + - $PYTHON ./utils/python-unit-tests.py + - $PYTHON ./examples/realtime/realtime-udp-echo.py + - $PYTHON ./examples/routing/simple-routing-ping6.py + - $PYTHON ./examples/tutorial/first.py + - $PYTHON ./examples/tutorial/second.py + - $PYTHON ./examples/tutorial/third.py + - $PYTHON ./examples/wireless/wifi-ap.py + - $PYTHON ./examples/wireless/mixed-wired-wireless.py + - $PYTHON ./src/bridge/examples/csma-bridge.py + - $PYTHON ./src/brite/examples/brite-generic-example.py + - $PYTHON ./src/core/examples/sample-simulator.py + - $PYTHON ./src/core/examples/sample-rng-plot.py --not-blocking + - $PYTHON ./src/click/examples/nsclick-simple-lan.py + - $PYTHON ./src/flow-monitor/examples/wifi-olsr-flowmon.py + - $PYTHON ./src/flow-monitor/examples/flowmon-parse-results.py output.xml + - $PYTHON ./src/openflow/examples/openflow-switch.py + +If all programs finish normally, the bindings are working as expected, +and will be saved as an artifact. + +.. sourcecode:: yaml + + artifacts: + paths: + - wheelhouse/*.whl + +One can use ``gitlab-ci-local`` to build the pip wheels locally. After that, the wheels +will be stored in ``.gitlab-ci-local/artifacts/manylinux-pip-wheel-py3Lg10/wheelhouse`` +(for Python 3.10). + +The wheel names are based on the number of commits since the latest release. +For example, a wheel built 415 after the release 3.37 will be named +``ns3-3.37.post415-cp310-cp310-manylinux_2_28_x86_64.whl``. + +The wheel name (``ns3``) is defined in the ``/ns-3-dev/setup.cfg`` file, and that +name should match the build prefix specified in ``/ns-3-dev/setup.py`` file. + +The ``cp310-cp310`` indicates that this wheel is compatible from Python 3.10 and up to Python 3.10. + +The ``manylinux_2_28`` indicates that this is a manylinux wheel targeting glibc 2.28. + +The ``x86_64`` indicates that this is a 64-bit build targeting Intel/AMD processors. + +.. _Pypi: https://pypi.org/account/register/ +.. _Twine: https://twine.readthedocs.io/en/stable/ + +After packaging, we can either deploy that wheel locally or upload the wheel to Pypi for general availability. + +Local deployment +**************** + +To deploy a wheel locally, simply share the wheel file across the desired machines. +Then install the wheel and its dependencies running the following command: + +.. sourcecode:: bash + + $ pip install *.whl + +Publishing the pip wheel via Pypi +********************************* + +Publishing a pip wheel requires a `Pypi`_ account. + +After creating your account, install `Twine`_, an utility to upload the wheel to Pypi. + +Then run twine to upload the wheel to the Pypi servers. + +.. sourcecode:: bash + + $ twine upload .gitlab-ci-local/artifacts/manylinux-pip-wheel-py3Lg10/wheelhouse/*.whl + +Enter your Pypi username and password as requested. + +Your wheel should be up and running. Give it a try just to make sure. + +For the upstream pip wheel, try: + +.. sourcecode:: bash + + $ pip install ns3 + $ python3 -c "from ns import ns; print(ns.Simulator.Now())" + Historical Information ********************** diff --git a/doc/manual/source/working-with-cmake.rst b/doc/manual/source/working-with-cmake.rst index 99af4b5f9..e630ef9a4 100644 --- a/doc/manual/source/working-with-cmake.rst +++ b/doc/manual/source/working-with-cmake.rst @@ -423,8 +423,6 @@ We are going to use the aodv module as an example: .. sourcecode:: python3 - ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- - def build(bld): module = bld.create_ns3_module('aodv', ['internet', 'wifi']) module.includes = '.' @@ -521,8 +519,6 @@ steps. We should have something like the following: .. sourcecode:: python3 - ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- - def build(bld): obj = bld.create_ns3_program('aodv', ['wifi', 'internet', 'aodv', 'internet-apps']) diff --git a/doc/manual/source/working-with-git.rst b/doc/manual/source/working-with-git.rst index 0bd276ecc..161966094 100644 --- a/doc/manual/source/working-with-git.rst +++ b/doc/manual/source/working-with-git.rst @@ -256,7 +256,7 @@ It is strongly suggested to rebase your branch on top of upstream/master (or mas This helps reviewing the code changes proposed in the branch. merge it without conflicts, and it increase the speed of the GitLab CI. GitLab CI (Continuous Integration) -+++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++ GitLab provides a CI (Continuous Integration) feature. Shortly put, after every push the code is built and tests are run in one of the GitLab servers. diff --git a/doc/manual/source/working-with-gitlab-ci-local.rst b/doc/manual/source/working-with-gitlab-ci-local.rst index 0d76cde9f..6dec6a81b 100644 --- a/doc/manual/source/working-with-gitlab-ci-local.rst +++ b/doc/manual/source/working-with-gitlab-ci-local.rst @@ -5,7 +5,7 @@ Working with gitlab-ci-local ---------------------------- -.. _continuos integration (CI) : https://docs.gitlab.com/ee/ci/ +.. _continuous integration (CI) : https://docs.gitlab.com/ee/ci/ .. _pipelines : https://docs.gitlab.com/ee/ci/introduction/index.html#continuous-integration .. _daily and weekly pipelines : https://gitlab.com/nsnam/ns-3-dev/-/pipeline_schedules .. _crypto miners abuse : https://about.gitlab.com/blog/2021/05/17/prevent-crypto-mining-abuse/ @@ -15,7 +15,7 @@ Working with gitlab-ci-local .. _rootless mode : https://docs.docker.com/engine/security/rootless/ The ns-3 project repository is currently hosted in GitLab, which includes -`continuos integration (CI)`_ tools to automate build, tests, packaging and +`continuous integration (CI)`_ tools to automate build, tests, packaging and distribution of software. The CI works based on jobs, that are defined on YAML files. diff --git a/doc/models/Makefile b/doc/models/Makefile index f9a943ae6..d93c9b75f 100644 --- a/doc/models/Makefile +++ b/doc/models/Makefile @@ -98,7 +98,6 @@ SOURCES = \ $(SRC)/spectrum/doc/spectrum.rst \ $(SRC)/netanim/doc/animation.rst \ $(SRC)/flow-monitor/doc/flow-monitor.rst \ - $(SRC)/wave/doc/wave.rst \ $(SRC)/sixlowpan/doc/sixlowpan.rst \ $(SRC)/lr-wpan/doc/lr-wpan.rst \ @@ -161,6 +160,10 @@ SOURCEFIGS = \ $(SRC)/wifi/doc/source/figures/wifi-11g-p-1500-infrastructure-r-6-min-5-max-50-step-5-throughput.eps \ $(SRC)/wifi/doc/source/figures/default-table-based-error-model-validation.eps \ $(SRC)/wifi/doc/source/figures/error-models-comparison.eps \ + $(SRC)/wifi/doc/source/figures/spectrum-wifi-phy-multiple-interfaces.pdf \ + $(SRC)/wifi/doc/source/figures/spectrum-wifi-phy-multiple-interfaces.png \ + $(SRC)/wifi/doc/source/figures/cca-channel-switching-multiple-interfaces.pdf \ + $(SRC)/wifi/doc/source/figures/cca-channel-switching-multiple-interfaces.png \ $(SRC)/wimax/doc/WimaxArchitecture.dia \ $(SRC)/lte/doc/source/figures/epc-ctrl-arch.dia \ $(SRC)/lte/doc/source/figures/epc-data-flow-dl.dia \ diff --git a/doc/models/source/conf.py b/doc/models/source/conf.py index e22f16312..76c3b5145 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.38' +version = u'ns-3.39' # The full version, including alpha/beta/rc tags. -release = u'ns-3.38' +release = u'ns-3.39' # 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 29b6d3bba..382f7b9ca 100644 --- a/doc/models/source/index.rst +++ b/doc/models/source/index.rst @@ -59,6 +59,5 @@ from the ``doc/`` directory of each module. Source file column width is 100 col topology traffic-control uan - wave wifi wimax diff --git a/doc/ns3_html_theme/layout.html b/doc/ns3_html_theme/layout.html index f167dda17..0140ac840 100644 --- a/doc/ns3_html_theme/layout.html +++ b/doc/ns3_html_theme/layout.html @@ -74,6 +74,9 @@
+ Installation
Manual
diff --git a/doc/ns3_html_theme/ns3_doxy_header.html b/doc/ns3_html_theme/ns3_doxy_header.html index 75afc8243..8617f677d 100644 --- a/doc/ns3_html_theme/ns3_doxy_header.html +++ b/doc/ns3_html_theme/ns3_doxy_header.html @@ -70,7 +70,7 @@ $extrastylesheet
- Installation
`_. - -We recommend that you, well, just get used to the look and feel of |ns3| -code and adopt this standard whenever you are working with our code. All of -the development team and contributors have done so with various amounts of -grumbling. The emacs mode line above makes it easier to get the formatting -correct if you use the emacs editor. - +Copyright ++++++++++ The |ns3| simulator is licensed using the GNU General Public License version 2. You will see the appropriate GNU legalese at the head of every file in the |ns3| distribution. Often you will see a copyright notice for diff --git a/doc/tutorial/source/conf.py b/doc/tutorial/source/conf.py index 0d41a74cf..1ebe7befc 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.38' +version = u'ns-3.39' # The full version, including alpha/beta/rc tags. -release = u'ns-3.38' +release = u'ns-3.39' # 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 45da02c8d..d8ccba2f5 100644 --- a/doc/tutorial/source/getting-started.rst +++ b/doc/tutorial/source/getting-started.rst @@ -57,20 +57,11 @@ emacs, or Eclipse) and, if using the development repositories, an installation of Git source code control system. Most beginning users need not concern themselves if their configuration reports some missing optional features of |ns3|, but for those wishing a full installation, -the project provides a wiki that includes pages with many useful hints -and tips. One such page is the "Installation" page, with install instructions +the project provides an installation guide for various systems, available at -https://www.nsnam.org/wiki/Installation. +https://www.nsnam.org/docs/installation/html/index.html. -The "Prerequisites" section of this wiki page explains which packages are -required to support common |ns3| options, and also provides the -commands used to install them for common Linux or macOS variants. - -You may want to take this opportunity to explore the |ns3| wiki -a bit, or the main web site at https://www.nsnam.org, since there is a -wealth of information there. - -As of the most recent |ns3| release (ns-3.38), the following tools +As of the most recent |ns3| release (ns-3.39), the following tools are needed to get started with |ns3|: ============ =========================================================== @@ -87,7 +78,8 @@ bunzip2 any recent version (to uncompress an |ns3| release) To check the default version of Python, type ``python -V``. To check the default version of g++, type ``g++ -v``. If your installation is -missing or too old, please consult the |ns3| installation wiki for guidance. +missing or too old, please consult the |ns3| +`installation guide `_ for guidance. From this point forward, we are going to assume that the reader is working in Linux, macOS, or a Linux emulation environment, and has at least the above @@ -124,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.38.tar.bz2 - $ tar xjf ns-allinone-3.38.tar.bz2 + $ wget https://www.nsnam.org/release/ns-allinone-3.39.tar.bz2 + $ tar xjf ns-allinone-3.39.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.38``, you should see a number of files and directories +``ns-allinone-3.39``, you should see a number of files and directories .. sourcecode:: text - $ cd ns-allinone-3.38 + $ cd ns-allinone-3.39 $ ls - bake build.py constants.py netanim-3.109 ns-3.38 README.md util.py + bake build.py constants.py netanim-3.109 ns-3.39 README.md util.py You are now ready to build the base |ns3| distribution and may skip ahead to the section on building |ns3|. @@ -188,7 +180,7 @@ release number: .. sourcecode:: console - $ python3 download.py -n ns-3.38 + $ python3 download.py -n ns-3.39 After this step, the additional repositories of |ns3|, bake, pybindgen, and netanim will be downloaded to the ``ns-3-allinone`` directory. @@ -257,9 +249,9 @@ distribution of your choice. There are a few configuration targets available: -1. ``ns-3.38``: the code corresponding to the release +1. ``ns-3.39``: the code corresponding to the release 2. ``ns-3-dev``: a similar module but using the development code tree -3. ``ns-allinone-3.38``: the module that includes other optional features +3. ``ns-allinone-3.39``: 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. @@ -276,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.38``. +this tutorial example with ``ns-3.39``. 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. @@ -305,7 +297,7 @@ Step into the workspace directory and type the following into your shell: .. sourcecode:: console - $ ./bake.py configure -e ns-allinone-3.38 + $ ./bake.py configure -e ns-allinone-3.39 Next, we'll ask bake to check whether we have enough tools to download various components. Type: @@ -352,10 +344,10 @@ should yield something like: >> Searching for system dependency g++ - OK >> Searching for system dependency cmake - OK >> Downloading netanim-3.109 - OK - >> Downloading click-ns-3.38 - OK + >> Downloading click-ns-3.37 - OK >> Downloading BRITE - OK >> Downloading openflow-dev - OK - >> Downloading ns-3.38 (target directory:ns-3.38) - OK + >> Downloading ns-3.39 (target directory:ns-3.39) - OK The above suggests that three sources have been downloaded. Check the ``source`` directory now and type ``ls``; one should see: @@ -364,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.38 openflow-dev + BRITE click-ns-3.37 netanim-3.109 ns-3.39 openflow-dev You are now ready to build the |ns3| distribution. @@ -394,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.38`` under your ``~/workspace`` directory. +``ns-allinone-3.39`` under your ``~/workspace`` directory. Type the following: .. sourcecode:: console @@ -427,7 +419,7 @@ and you should see something like: .. sourcecode:: text >> Building netanim-3.109 - OK - >> Building ns-3.38 - OK + >> Building ns-3.39 - OK There may be failures to build all components, but the build will proceed anyway if the component is optional. @@ -604,7 +596,6 @@ output that looks similar to the following: -- Processing src/traffic-control -- Processing src/uan -- Processing src/virtual-net-device - -- Processing src/wave -- Processing src/wifi -- Processing src/wimax -- ---- Summary of optional NS-3 features: @@ -644,7 +635,7 @@ output that looks similar to the following: sixlowpan spectrum stats tap-bridge test topology-read traffic-control uan virtual-net-device - wave wifi wimax + wifi wimax Modules that cannot be built: diff --git a/doc/tutorial/source/quick-start.rst b/doc/tutorial/source/quick-start.rst index 5ff222a45..d32f54d6d 100644 --- a/doc/tutorial/source/quick-start.rst +++ b/doc/tutorial/source/quick-start.rst @@ -64,13 +64,13 @@ Downloading the Latest Release :: - $ tar xjf ns-allinone-3.38.tar.bz2 + $ tar xjf ns-allinone-3.39.tar.bz2 3) Change into the |ns3| directory directly; e.g. :: - $ cd ns-allinone-3.38/ns-3.38 + $ cd ns-allinone-3.39/ns-3.39 The ns-allinone directory has some additional components but we are skipping over them here; one can work directly from the |ns3| source code directory. @@ -92,12 +92,12 @@ only to `cd` into ns-3-dev; the `master` branch is checked out by default. $ cd ns-3-dev -If instead you want to try the most recent release (version 3.38 as of this +If instead you want to try the most recent release (version 3.39 as of this writing), you can checkout a branch corresponding to that git tag: :: - $ git checkout -b ns-3.38-branch ns-3.38 + $ git checkout -b ns-3.39-branch ns-3.39 Building and testing ns-3 ************************* diff --git a/doc/tutorial/source/resources.rst b/doc/tutorial/source/resources.rst index ebee294c3..fc4301444 100644 --- a/doc/tutorial/source/resources.rst +++ b/doc/tutorial/source/resources.rst @@ -84,18 +84,14 @@ neither make directly. We use CMake for these functions. On macOS, the toolchain used is Xcode. |ns3| users on a Mac are strongly encouraged to install Xcode and the command-line tools packages from the -Apple App Store, and to look at the |ns3| installation wiki for more -information (https://www.nsnam.org/wiki/Installation). +Apple App Store, and to look at the |ns3| installation guide for more +information (https://www.nsnam.org/docs/installation/html/). Typically an |ns3| author will work in Linux or a Unix-like environment. For those running under Windows, there do exist environments which simulate the Linux environment to various degrees. The |ns3| -project has in the past (but not presently) supported development in the Cygwin environment for -these users. See http://www.cygwin.com/ -for details on downloading, and visit the |ns3| wiki for more information -about Cygwin and |ns3|. MinGW is presently not officially supported. -Another alternative to Cygwin is to install a virtual machine environment -such as VMware server and install a Linux virtual machine. +installation guide has information about Windows support +(https://www.nsnam.org/docs/installation/html/windows.html). Socket Programming ****************** diff --git a/doc/tutorial/source/tracing.rst b/doc/tutorial/source/tracing.rst index 12a20dcf1..6f979cf8c 100644 --- a/doc/tutorial/source/tracing.rst +++ b/doc/tutorial/source/tracing.rst @@ -313,7 +313,6 @@ We have provided some code to implement what is really the simplest example of tracing that can be assembled. You can find this code in the tutorial directory as ``fourth.cc``. Let's walk through it:: - /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * 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 @@ -1390,7 +1389,6 @@ dissecting the congestion window test. Open ``examples/tutorial/fifth.cc`` in your favorite editor. You should see some familiar looking code:: - /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * 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 diff --git a/examples/channel-models/examples-to-run.py b/examples/channel-models/examples-to-run.py index 430364089..bec574b60 100644 --- a/examples/channel-models/examples-to-run.py +++ b/examples/channel-models/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/examples/energy/examples-to-run.py b/examples/energy/examples-to-run.py index 20dc70007..7c418ba7a 100644 --- a/examples/energy/examples-to-run.py +++ b/examples/energy/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/examples/error-model/examples-to-run.py b/examples/error-model/examples-to-run.py index 19b3ec789..52f2365b6 100644 --- a/examples/error-model/examples-to-run.py +++ b/examples/error-model/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/examples/ipv6/examples-to-run.py b/examples/ipv6/examples-to-run.py index a06c79ba9..2814327da 100644 --- a/examples/ipv6/examples-to-run.py +++ b/examples/ipv6/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/examples/ipv6/fragmentation-ipv6-PMTU.cc b/examples/ipv6/fragmentation-ipv6-PMTU.cc index be64d391c..b25c2b0ab 100644 --- a/examples/ipv6/fragmentation-ipv6-PMTU.cc +++ b/examples/ipv6/fragmentation-ipv6-PMTU.cc @@ -33,7 +33,6 @@ #include "ns3/applications-module.h" #include "ns3/core-module.h" #include "ns3/csma-module.h" -#include "ns3/internet-apps-module.h" #include "ns3/internet-module.h" #include "ns3/ipv6-routing-table-entry.h" #include "ns3/ipv6-static-routing-helper.h" diff --git a/examples/ipv6/fragmentation-ipv6-two-MTU.cc b/examples/ipv6/fragmentation-ipv6-two-MTU.cc index a3205c008..8a58cb80c 100644 --- a/examples/ipv6/fragmentation-ipv6-two-MTU.cc +++ b/examples/ipv6/fragmentation-ipv6-two-MTU.cc @@ -32,7 +32,6 @@ #include "ns3/applications-module.h" #include "ns3/core-module.h" #include "ns3/csma-module.h" -#include "ns3/internet-apps-module.h" #include "ns3/internet-module.h" #include "ns3/ipv6-routing-table-entry.h" #include "ns3/ipv6-static-routing-helper.h" diff --git a/examples/ipv6/fragmentation-ipv6.cc b/examples/ipv6/fragmentation-ipv6.cc index 3cbd9f708..5708739a1 100644 --- a/examples/ipv6/fragmentation-ipv6.cc +++ b/examples/ipv6/fragmentation-ipv6.cc @@ -30,7 +30,6 @@ #include "ns3/applications-module.h" #include "ns3/core-module.h" #include "ns3/csma-module.h" -#include "ns3/internet-apps-module.h" #include "ns3/internet-module.h" #include "ns3/ipv6-routing-table-entry.h" #include "ns3/ipv6-static-routing-helper.h" diff --git a/examples/matrix-topology/matrix-topology.cc b/examples/matrix-topology/matrix-topology.cc index 0cfaa302b..9c1cf4f22 100644 --- a/examples/matrix-topology/matrix-topology.cc +++ b/examples/matrix-topology/matrix-topology.cc @@ -60,7 +60,7 @@ using namespace ns3; // ---------- Prototypes ------------------------------------------------------ std::vector> readNxNMatrix(std::string adj_mat_file_name); -std::vector> readCordinatesFile(std::string node_coordinates_file_name); +std::vector> readCoordinatesFile(std::string node_coordinates_file_name); void printCoordinateArray(const char* description, std::vector> coord_array); void printMatrix(const char* description, std::vector> array); @@ -115,7 +115,7 @@ main(int argc, char* argv[]) // ---------- Read Node Coordinates File ----------------------------------- std::vector> coord_array; - coord_array = readCordinatesFile(node_coordinates_file_name); + coord_array = readCoordinatesFile(node_coordinates_file_name); // Optionally display node coordinates file // printCoordinateArray (node_coordinates_file_name.c_str (),coord_array); @@ -361,7 +361,7 @@ readNxNMatrix(std::string adj_mat_file_name) } std::vector> -readCordinatesFile(std::string node_coordinates_file_name) +readCoordinatesFile(std::string node_coordinates_file_name) { std::ifstream node_coordinates_file; node_coordinates_file.open(node_coordinates_file_name, std::ios::in); diff --git a/examples/naming/examples-to-run.py b/examples/naming/examples-to-run.py index 7c468cae9..1ac54a34f 100644 --- a/examples/naming/examples-to-run.py +++ b/examples/naming/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/examples/naming/object-names.cc b/examples/naming/object-names.cc index f26d8a82a..1238ade94 100644 --- a/examples/naming/object-names.cc +++ b/examples/naming/object-names.cc @@ -214,7 +214,7 @@ main(int argc, char* argv[]) outputValidated = false; } - if (outputValidated == false) + if (!outputValidated) { std::cerr << "Program internal checking failed; returning with error" << std::endl; return (1); diff --git a/examples/realtime/examples-to-run.py b/examples/realtime/examples-to-run.py index 2e58a0789..323d78f01 100644 --- a/examples/realtime/examples-to-run.py +++ b/examples/realtime/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/examples/routing/CMakeLists.txt b/examples/routing/CMakeLists.txt index e212cecd9..57b57ccb4 100644 --- a/examples/routing/CMakeLists.txt +++ b/examples/routing/CMakeLists.txt @@ -87,6 +87,7 @@ build_example( ${libolsr} ${libinternet} ${libapplications} + ${libflow-monitor} ) build_example( diff --git a/examples/routing/examples-to-run.py b/examples/routing/examples-to-run.py index cdaf08ba4..fe80dd6a7 100644 --- a/examples/routing/examples-to-run.py +++ b/examples/routing/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/examples/routing/manet-routing-compare.cc b/examples/routing/manet-routing-compare.cc index a213ba278..a105ab0d2 100644 --- a/examples/routing/manet-routing-compare.cc +++ b/examples/routing/manet-routing-compare.cc @@ -69,6 +69,7 @@ #include "ns3/core-module.h" #include "ns3/dsdv-module.h" #include "ns3/dsr-module.h" +#include "ns3/flow-monitor-module.h" #include "ns3/internet-module.h" #include "ns3/mobility-module.h" #include "ns3/network-module.h" @@ -94,20 +95,15 @@ class RoutingExperiment RoutingExperiment(); /** * Run the experiment. - * \param nSinks The number of Sink Nodes. - * \param txp The Tx power. - * \param CSVfileName The output CSV filename. */ - void Run(int nSinks, double txp, std::string CSVfileName); - // static void SetMACParam (ns3::NetDeviceContainer & devices, - // int slotDistance); + void Run(); + /** * Handles the command-line parameters. * \param argc The argument count. * \param argv The argument vector. - * \return the CSV filename. */ - std::string CommandSetup(int argc, char** argv); + void CommandSetup(int argc, char** argv); private: /** @@ -127,25 +123,19 @@ class RoutingExperiment */ void CheckThroughput(); - uint32_t port; //!< Receiving port number. - uint32_t bytesTotal; //!< Total received bytes. - uint32_t packetsReceived; //!< Total received packets. + uint32_t port{9}; //!< Receiving port number. + uint32_t bytesTotal{0}; //!< Total received bytes. + uint32_t packetsReceived{0}; //!< Total received packets. - std::string m_CSVfileName; //!< CSV filename. - int m_nSinks; //!< Number of sink nodes. - std::string m_protocolName; //!< Protocol name. - double m_txp; //!< Tx power. - bool m_traceMobility; //!< Enavle mobility tracing. - uint32_t m_protocol; //!< Protocol type. + std::string m_CSVfileName{"manet-routing.output.csv"}; //!< CSV filename. + int m_nSinks{10}; //!< Number of sink nodes. + std::string m_protocolName{"AODV"}; //!< Protocol name. + double m_txp{7.5}; //!< Tx power. + bool m_traceMobility{false}; //!< Enable mobility tracing. + bool m_flowMonitor{false}; //!< Enable FlowMonitor. }; RoutingExperiment::RoutingExperiment() - : port(9), - bytesTotal(0), - packetsReceived(0), - m_CSVfileName("manet-routing.output.csv"), - m_traceMobility(false), - m_protocol(2) // AODV { } @@ -209,25 +199,42 @@ RoutingExperiment::SetupPacketReceive(Ipv4Address addr, Ptr node) return sink; } -std::string +void RoutingExperiment::CommandSetup(int argc, char** argv) { CommandLine cmd(__FILE__); cmd.AddValue("CSVfileName", "The name of the CSV output file name", m_CSVfileName); cmd.AddValue("traceMobility", "Enable mobility tracing", m_traceMobility); - cmd.AddValue("protocol", "1=OLSR;2=AODV;3=DSDV;4=DSR", m_protocol); + cmd.AddValue("protocol", "Routing protocol (OLSR, AODV, DSDV, DSR)", m_protocolName); + cmd.AddValue("flowMonitor", "enable FlowMonitor", m_flowMonitor); cmd.Parse(argc, argv); - return m_CSVfileName; + + std::vector allowedProtocols{"OLSR", "AODV", "DSDV", "DSR"}; + + if (std::find(std::begin(allowedProtocols), std::end(allowedProtocols), m_protocolName) == + std::end(allowedProtocols)) + { + NS_FATAL_ERROR("No such protocol:" << m_protocolName); + } } int main(int argc, char* argv[]) { RoutingExperiment experiment; - std::string CSVfileName = experiment.CommandSetup(argc, argv); + experiment.CommandSetup(argc, argv); + experiment.Run(); + + return 0; +} + +void +RoutingExperiment::Run() +{ + Packet::EnablePrinting(); // blank out the last output file and write the column headers - std::ofstream out(CSVfileName); + std::ofstream out(m_CSVfileName); out << "SimulationSecond," << "ReceiveRate," << "PacketsReceived," @@ -236,22 +243,6 @@ main(int argc, char* argv[]) << "TransmissionPower" << std::endl; out.close(); - int nSinks = 10; - double txp = 7.5; - - experiment.Run(nSinks, txp, CSVfileName); - - return 0; -} - -void -RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) -{ - Packet::EnablePrinting(); - m_nSinks = nSinks; - m_txp = txp; - m_CSVfileName = CSVfileName; - int nWifis = 50; double TotalTime = 200.0; @@ -260,7 +251,6 @@ RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) std::string tr_name("manet-routing-compare"); int nodeSpeed = 20; // in m/s int nodePause = 0; // in s - m_protocolName = "protocol"; Config::SetDefault("ns3::OnOffApplication::PacketSize", StringValue("64")); Config::SetDefault("ns3::OnOffApplication::DataRate", StringValue(rate)); @@ -289,8 +279,8 @@ RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) "ControlMode", StringValue(phyMode)); - wifiPhy.Set("TxPowerStart", DoubleValue(txp)); - wifiPhy.Set("TxPowerEnd", DoubleValue(txp)); + wifiPhy.Set("TxPowerStart", DoubleValue(m_txp)); + wifiPhy.Set("TxPowerEnd", DoubleValue(m_txp)); wifiMac.SetType("ns3::AdhocWifiMac"); NetDeviceContainer adhocDevices = wifi.Install(wifiPhy, wifiMac, adhocNodes); @@ -329,36 +319,36 @@ RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) Ipv4ListRoutingHelper list; InternetStackHelper internet; - switch (m_protocol) + if (m_protocolName == "OLSR") { - case 1: list.Add(olsr, 100); - m_protocolName = "OLSR"; - break; - case 2: - list.Add(aodv, 100); - m_protocolName = "AODV"; - break; - case 3: - list.Add(dsdv, 100); - m_protocolName = "DSDV"; - break; - case 4: - m_protocolName = "DSR"; - break; - default: - NS_FATAL_ERROR("No such protocol:" << m_protocol); - } - - if (m_protocol < 4) - { internet.SetRoutingHelper(list); internet.Install(adhocNodes); } - else if (m_protocol == 4) + else if (m_protocolName == "AODV") + { + list.Add(aodv, 100); + internet.SetRoutingHelper(list); + internet.Install(adhocNodes); + } + else if (m_protocolName == "DSDV") + { + list.Add(dsdv, 100); + internet.SetRoutingHelper(list); + internet.Install(adhocNodes); + } + else if (m_protocolName == "DSR") { internet.Install(adhocNodes); dsrMain.Install(dsr, adhocNodes); + if (m_flowMonitor) + { + NS_FATAL_ERROR("Error: FlowMonitor does not work with DSR. Terminating."); + } + } + else + { + NS_FATAL_ERROR("No such protocol:" << m_protocolName); } NS_LOG_INFO("assigning ip address"); @@ -372,7 +362,7 @@ RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) onoff1.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1.0]")); onoff1.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0.0]")); - for (int i = 0; i < nSinks; i++) + for (int i = 0; i < m_nSinks; i++) { Ptr sink = SetupPacketReceive(adhocInterfaces.GetAddress(i), adhocNodes.Get(i)); @@ -380,7 +370,7 @@ RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) onoff1.SetAttribute("Remote", remoteAddress); Ptr var = CreateObject(); - ApplicationContainer temp = onoff1.Install(adhocNodes.Get(i + nSinks)); + ApplicationContainer temp = onoff1.Install(adhocNodes.Get(i + m_nSinks)); temp.Start(Seconds(var->GetValue(100.0, 101.0))); temp.Stop(Seconds(TotalTime)); } @@ -411,9 +401,12 @@ RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) AsciiTraceHelper ascii; MobilityHelper::EnableAsciiAll(ascii.CreateFileStream(tr_name + ".mob")); - // Ptr flowmon; - // FlowMonitorHelper flowmonHelper; - // flowmon = flowmonHelper.InstallAll(); + FlowMonitorHelper flowmonHelper; + Ptr flowmon; + if (m_flowMonitor) + { + flowmon = flowmonHelper.InstallAll(); + } NS_LOG_INFO("Run Simulation."); @@ -422,7 +415,10 @@ RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) Simulator::Stop(Seconds(TotalTime)); Simulator::Run(); - // flowmon->SerializeToXmlFile(tr_name + ".flowmon", false, false); + if (m_flowMonitor) + { + flowmon->SerializeToXmlFile(tr_name + ".flowmon", false, false); + } Simulator::Destroy(); } diff --git a/examples/socket/socket-options-ipv4.cc b/examples/socket/socket-options-ipv4.cc index 417eaee9e..774a5876d 100644 --- a/examples/socket/socket-options-ipv4.cc +++ b/examples/socket/socket-options-ipv4.cc @@ -22,7 +22,6 @@ // // - UDP flows from n0 to n1 -#include "ns3/applications-module.h" #include "ns3/core-module.h" #include "ns3/csma-module.h" #include "ns3/internet-module.h" diff --git a/examples/socket/socket-options-ipv6.cc b/examples/socket/socket-options-ipv6.cc index dd2609a39..067e5d1fc 100644 --- a/examples/socket/socket-options-ipv6.cc +++ b/examples/socket/socket-options-ipv6.cc @@ -22,7 +22,6 @@ // // - UDP flows from n0 to n1 -#include "ns3/applications-module.h" #include "ns3/core-module.h" #include "ns3/csma-module.h" #include "ns3/internet-module.h" diff --git a/examples/stats/examples-to-run.py b/examples/stats/examples-to-run.py index 929f1c418..678bf8783 100644 --- a/examples/stats/examples-to-run.py +++ b/examples/stats/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/examples/tcp/dctcp-example.cc b/examples/tcp/dctcp-example.cc index 0d5e147e2..9d8e080ee 100644 --- a/examples/tcp/dctcp-example.cc +++ b/examples/tcp/dctcp-example.cc @@ -301,8 +301,6 @@ main(int argc, char* argv[]) Time startTime = Seconds(0); Time stopTime = flowStartupWindow + convergenceTime + measurementWindow; - Time clientStartTime = startTime; - rxS1R1Bytes.reserve(10); rxS2R2Bytes.reserve(20); rxS3R1Bytes.reserve(10); @@ -493,7 +491,7 @@ main(int argc, char* argv[]) AddressValue remoteAddress(InetSocketAddress(ipR2T2[i].GetAddress(0), port)); clientHelper1.SetAttribute("Remote", remoteAddress); clientApps1.Add(clientHelper1.Install(S2.Get(i))); - clientApps1.Start(i * flowStartupWindow / 20 + clientStartTime + MilliSeconds(i * 5)); + clientApps1.Start(i * flowStartupWindow / 20 + startTime + MilliSeconds(i * 5)); clientApps1.Stop(stopTime); } @@ -534,13 +532,12 @@ main(int argc, char* argv[]) if (i < 10) { clientApps1.Add(clientHelper1.Install(S1.Get(i))); - clientApps1.Start(i * flowStartupWindow / 10 + clientStartTime + MilliSeconds(i * 5)); + clientApps1.Start(i * flowStartupWindow / 10 + startTime + MilliSeconds(i * 5)); } else { clientApps1.Add(clientHelper1.Install(S3.Get(i - 10))); - clientApps1.Start((i - 10) * flowStartupWindow / 10 + clientStartTime + - MilliSeconds(i * 5)); + clientApps1.Start((i - 10) * flowStartupWindow / 10 + startTime + MilliSeconds(i * 5)); } clientApps1.Stop(stopTime); diff --git a/examples/tcp/examples-to-run.py b/examples/tcp/examples-to-run.py index 2306d071d..fd2b27824 100644 --- a/examples/tcp/examples-to-run.py +++ b/examples/tcp/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/examples/tcp/tcp-validation.cc b/examples/tcp/tcp-validation.cc index 7aed2a009..b9a8c023d 100644 --- a/examples/tcp/tcp-validation.cc +++ b/examples/tcp/tcp-validation.cc @@ -746,7 +746,7 @@ main(int argc, char* argv[]) firstTcpTypeId = TcpDctcp::GetTypeId(); Config::SetDefault("ns3::CoDelQueueDisc::CeThreshold", TimeValue(ceThreshold)); Config::SetDefault("ns3::FqCoDelQueueDisc::CeThreshold", TimeValue(ceThreshold)); - if (queueUseEcn == false) + if (!queueUseEcn) { std::cout << "Warning: using DCTCP with queue ECN disabled" << std::endl; } @@ -933,7 +933,7 @@ main(int argc, char* argv[]) proto->SetAttribute("SocketType", TypeIdValue(secondTcpTypeId)); } - // InternetStackHelper will install a base TrafficControLayer on the node, + // InternetStackHelper will install a base TrafficControlLayer on the node, // but the Ipv4AddressHelper below will install the default FqCoDelQueueDisc // on all single device nodes. The below code overrides the configuration // that is normally done by the Ipv4AddressHelper::Install() method by diff --git a/examples/tcp/tcp-variants-comparison.cc b/examples/tcp/tcp-variants-comparison.cc index 31f0a9ef8..4859e865f 100644 --- a/examples/tcp/tcp-variants-comparison.cc +++ b/examples/tcp/tcp-variants-comparison.cc @@ -79,8 +79,8 @@ static std::map ssThreshValue; //!< SlowSta static uint32_t GetNodeIdFromContext(std::string context) { - std::size_t const n1 = context.find_first_of('/', 1); - std::size_t const n2 = context.find_first_of('/', n1 + 1); + const std::size_t n1 = context.find_first_of('/', 1); + const std::size_t n2 = context.find_first_of('/', n1 + 1); return std::stoul(context.substr(n1 + 1, n2 - n1 - 1)); } diff --git a/examples/traffic-control/examples-to-run.py b/examples/traffic-control/examples-to-run.py index 9a62b3935..ebaf94b63 100755 --- a/examples/traffic-control/examples-to-run.py +++ b/examples/traffic-control/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/examples/tutorial/examples-to-run.py b/examples/tutorial/examples-to-run.py index 7461e8cc0..f1542727f 100644 --- a/examples/tutorial/examples-to-run.py +++ b/examples/tutorial/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/examples/tutorial/seventh.cc b/examples/tutorial/seventh.cc index f4b61be1e..b17824474 100644 --- a/examples/tutorial/seventh.cc +++ b/examples/tutorial/seventh.cc @@ -125,7 +125,7 @@ main(int argc, char* argv[]) Address anyAddress; std::string probeType; std::string tracePath; - if (useV6 == false) + if (!useV6) { Ipv4AddressHelper address; address.SetBase("10.1.1.0", "255.255.255.0"); diff --git a/examples/udp-client-server/udp-client-server.cc b/examples/udp-client-server/udp-client-server.cc index 44c14a9c9..515561656 100644 --- a/examples/udp-client-server/udp-client-server.cc +++ b/examples/udp-client-server/udp-client-server.cc @@ -74,7 +74,7 @@ main(int argc, char* argv[]) NetDeviceContainer d = csma.Install(n); NS_LOG_INFO("Assign IP Addresses."); - if (useV6 == false) + if (!useV6) { Ipv4AddressHelper ipv4; ipv4.SetBase("10.1.1.0", "255.255.255.0"); diff --git a/examples/udp-client-server/udp-trace-client-server.cc b/examples/udp-client-server/udp-trace-client-server.cc index 03e922e33..dccc61702 100644 --- a/examples/udp-client-server/udp-trace-client-server.cc +++ b/examples/udp-client-server/udp-trace-client-server.cc @@ -73,7 +73,7 @@ main(int argc, char* argv[]) NetDeviceContainer d = csma.Install(n); NS_LOG_INFO("Assign IP Addresses."); - if (useV6 == false) + if (!useV6) { Ipv4AddressHelper ipv4; ipv4.SetBase("10.1.1.0", "255.255.255.0"); diff --git a/examples/udp/examples-to-run.py b/examples/udp/examples-to-run.py index bd29fcd67..daa0ce164 100644 --- a/examples/udp/examples-to-run.py +++ b/examples/udp/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/examples/udp/udp-echo.cc b/examples/udp/udp-echo.cc index e5e2ec6d8..177ff1f51 100644 --- a/examples/udp/udp-echo.cc +++ b/examples/udp/udp-echo.cc @@ -81,7 +81,7 @@ main(int argc, char* argv[]) // We've got the "hardware" in place. Now we need to add IP addresses. // NS_LOG_INFO("Assign IP Addresses."); - if (useV6 == false) + if (!useV6) { Ipv4AddressHelper ipv4; ipv4.SetBase("10.1.1.0", "255.255.255.0"); diff --git a/examples/wireless/examples-to-run.py b/examples/wireless/examples-to-run.py index f7fdba6e8..7eef186fe 100755 --- a/examples/wireless/examples-to-run.py +++ b/examples/wireless/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains @@ -30,6 +29,9 @@ cpp_examples = [ ("wifi-power-adaptation-distance --manager=ns3::ParfWifiManager --outputFileName=parf --steps=5 --stepsSize=10", "True", "True"), ("wifi-power-adaptation-distance --manager=ns3::AparfWifiManager --outputFileName=aparf --steps=5 --stepsSize=10", "True", "False"), ("wifi-power-adaptation-distance --manager=ns3::RrpaaWifiManager --outputFileName=rrpaa --steps=5 --stepsSize=10", "True", "False"), + ("wifi-rate-adaptation-distance --standard=802.11a --staManager=ns3::MinstrelWifiManager --apManager=ns3::MinstrelWifiManager --outputFileName=minstrel --stepsSize=50 --stepsTime=0.1", "True", "False"), + ("wifi-rate-adaptation-distance --standard=802.11a --staManager=ns3::MinstrelWifiManager --apManager=ns3::MinstrelWifiManager --outputFileName=minstrel --stepsSize=50 --stepsTime=0.1 --STA1_x=-200", "True", "False"), + ("wifi-rate-adaptation-distance --staManager=ns3::MinstrelHtWifiManager --apManager=ns3::MinstrelHtWifiManager --outputFileName=minstrelHt --shortGuardInterval=true --channelWidth=40 --stepsSize=50 --stepsTime=0.1", "True", "False"), ("wifi-power-adaptation-interference --simuTime=5", "True", "False"), ("wifi-dsss-validation", "True", "True"), ("wifi-ofdm-validation", "True", "True"), @@ -58,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.2 --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.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.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/mixed-wired-wireless.cc b/examples/wireless/mixed-wired-wireless.cc index 1760457f6..e800b1d01 100644 --- a/examples/wireless/mixed-wired-wireless.cc +++ b/examples/wireless/mixed-wired-wireless.cc @@ -414,7 +414,7 @@ main(int argc, char* argv[]) // pcap trace on the application data sink wifiPhy.EnablePcap("mixed-wireless", appSink->GetId(), 0); - if (useCourseChangeCallback == true) + if (useCourseChangeCallback) { Config::Connect("/NodeList/*/$ns3::MobilityModel/CourseChange", MakeCallback(&CourseChangeCallback)); diff --git a/examples/wireless/mixed-wired-wireless.py b/examples/wireless/mixed-wired-wireless.py index daa72198b..db595f52c 100644 --- a/examples/wireless/mixed-wired-wireless.py +++ b/examples/wireless/mixed-wired-wireless.py @@ -91,7 +91,7 @@ def main(argv): cmd.AddValue("backboneNodes", "number of backbone nodes", backboneNodes) cmd.AddValue("infraNodes", "number of leaf nodes", infraNodes) cmd.AddValue("lanNodes", "number of LAN nodes", lanNodes) - cmd.AddValue("stopTime", "simulation stop time(seconds)", stopTime) + cmd.AddValue["double"]("stopTime", "simulation stop time(seconds)", stopTime) # # The system global variables and the local values added to the argument diff --git a/examples/wireless/wifi-adhoc.cc b/examples/wireless/wifi-adhoc.cc index e65724382..37fc872c5 100644 --- a/examples/wireless/wifi-adhoc.cc +++ b/examples/wireless/wifi-adhoc.cc @@ -175,8 +175,7 @@ Experiment::Run(const WifiHelper& wifi, YansWifiPhyHelper phy = wifiPhy; phy.SetChannel(wifiChannel.Create()); - WifiMacHelper mac = wifiMac; - NetDeviceContainer devices = wifi.Install(phy, mac, c); + NetDeviceContainer devices = wifi.Install(phy, wifiMac, c); MobilityHelper mobility; Ptr positionAlloc = CreateObject(); diff --git a/examples/wireless/wifi-clear-channel-cmu.cc b/examples/wireless/wifi-clear-channel-cmu.cc index 4b245270f..4b4f308a2 100644 --- a/examples/wireless/wifi-clear-channel-cmu.cc +++ b/examples/wireless/wifi-clear-channel-cmu.cc @@ -183,8 +183,7 @@ Experiment::Run(const WifiHelper& wifi, YansWifiPhyHelper phy = wifiPhy; phy.SetChannel(wifiChannel.Create()); - WifiMacHelper mac = wifiMac; - NetDeviceContainer devices = wifi.Install(phy, mac, c); + NetDeviceContainer devices = wifi.Install(phy, wifiMac, c); MobilityHelper mobility; Ptr positionAlloc = CreateObject(); diff --git a/examples/wireless/wifi-eht-network.cc b/examples/wireless/wifi-eht-network.cc index 0841d2e20..7036f3c43 100644 --- a/examples/wireless/wifi-eht-network.cc +++ b/examples/wireless/wifi-eht-network.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2022 * @@ -244,11 +243,8 @@ main(int argc, char* argv[]) "AGGR-MU-BAR)"); } - double prevThroughput[12]; - for (uint32_t l = 0; l < 12; l++) - { - prevThroughput[l] = 0; - } + double prevThroughput[12] = {0}; + std::cout << "MCS value" << "\t\t" << "Channel width" diff --git a/examples/wireless/wifi-he-network.cc b/examples/wireless/wifi-he-network.cc index 06d89538b..fe380dba4 100644 --- a/examples/wireless/wifi-he-network.cc +++ b/examples/wireless/wifi-he-network.cc @@ -167,11 +167,8 @@ main(int argc, char* argv[]) phyModel = "Spectrum"; } - double prevThroughput[12]; - for (uint32_t l = 0; l < 12; l++) - { - prevThroughput[l] = 0; - } + double prevThroughput[12] = {0}; + std::cout << "MCS value" << "\t\t" << "Channel width" diff --git a/examples/wireless/wifi-ht-network.cc b/examples/wireless/wifi-ht-network.cc index 20eec4c70..e9008932f 100644 --- a/examples/wireless/wifi-ht-network.cc +++ b/examples/wireless/wifi-ht-network.cc @@ -96,11 +96,8 @@ main(int argc, char* argv[]) Config::SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue("0")); } - double prevThroughput[8]; - for (uint32_t l = 0; l < 8; l++) - { - prevThroughput[l] = 0; - } + double prevThroughput[8] = {0}; + std::cout << "MCS value" << "\t\t" << "Channel width" diff --git a/examples/wireless/wifi-multirate.cc b/examples/wireless/wifi-multirate.cc index 0d8f0a65d..fd0a224a6 100644 --- a/examples/wireless/wifi-multirate.cc +++ b/examples/wireless/wifi-multirate.cc @@ -505,8 +505,7 @@ Experiment::Run(const WifiHelper& wifi, YansWifiPhyHelper phy = wifiPhy; phy.SetChannel(wifiChannel.Create()); - WifiMacHelper mac = wifiMac; - NetDeviceContainer devices = wifi.Install(phy, mac, c); + NetDeviceContainer devices = wifi.Install(phy, wifiMac, c); OlsrHelper olsr; Ipv4StaticRoutingHelper staticRouting; diff --git a/examples/wireless/wifi-rate-adaptation-distance.cc b/examples/wireless/wifi-rate-adaptation-distance.cc index 14d2eef4e..7b1abe643 100644 --- a/examples/wireless/wifi-rate-adaptation-distance.cc +++ b/examples/wireless/wifi-rate-adaptation-distance.cc @@ -56,6 +56,7 @@ #include "ns3/boolean.h" #include "ns3/command-line.h" #include "ns3/config.h" +#include "ns3/double.h" #include "ns3/gnuplot.h" #include "ns3/internet-stack-helper.h" #include "ns3/ipv4-address-helper.h" @@ -65,6 +66,7 @@ #include "ns3/on-off-helper.h" #include "ns3/packet-sink-helper.h" #include "ns3/ssid.h" +#include "ns3/string.h" #include "ns3/uinteger.h" #include "ns3/yans-wifi-channel.h" #include "ns3/yans-wifi-helper.h" @@ -168,10 +170,16 @@ NodeStatistics::GetDatafile() return m_output; } +/** + * Callback for 'Rate' trace source + * + * \param oldRate old MCS rate (bits/sec) + * \param newRate new MCS rate (bits/sec) + */ void -RateCallback(std::string path, uint64_t rate, Mac48Address dest) +RateCallback(uint64_t oldRate, uint64_t newRate) { - NS_LOG_INFO((Simulator::Now()).GetSeconds() << " " << dest << " Rate " << rate / 1000000.0); + NS_LOG_INFO("Rate " << newRate / 1000000.0 << " Mbps"); } int @@ -194,9 +202,9 @@ main(int argc, char* argv[]) int stepsTime = 1; CommandLine cmd(__FILE__); - cmd.AddValue("staManager", "PRC Manager of the STA", staManager); - cmd.AddValue("apManager", "PRC Manager of the AP", apManager); - cmd.AddValue("standard", "Wifi Phy Standard", standard); + cmd.AddValue("staManager", "Rate adaptation manager of the STA", staManager); + cmd.AddValue("apManager", "Rate adaptation manager of the AP", apManager); + cmd.AddValue("standard", "Wifi standard (a/b/g/n/ac only)", standard); cmd.AddValue("shortGuardInterval", "Enable Short Guard Interval in all stations", shortGuardInterval); @@ -215,6 +223,12 @@ main(int argc, char* argv[]) int simuTime = steps * stepsTime; + if (standard != "802.11a" && standard != "802.11b" && standard != "802.11g" && + standard == "802.11n-2.4GHz" && standard != "802.11n-5GHz" && standard != "802.11ac") + { + NS_FATAL_ERROR("Standard " << standard << " is not supported by this program"); + } + // Define the APs NodeContainer wifiApNodes; wifiApNodes.Create(1); @@ -226,6 +240,30 @@ main(int argc, char* argv[]) YansWifiPhyHelper wifiPhy; YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default(); wifiPhy.SetChannel(wifiChannel.Create()); + // Channel configuration via ChannelSettings attribute can be performed here + std::string frequencyBand; + if (standard == "802.11b" || standard == "802.11g" || standard == "802.11n-2.4GHz") + { + frequencyBand = "BAND_2_4GHZ"; + } + else + { + frequencyBand = "BAND_5GHZ"; + } + wifiPhy.Set("ChannelSettings", + StringValue("{0, " + std::to_string(chWidth) + ", " + frequencyBand + ", 0}")); + + // By default, the CCA sensitivity is -82 dBm, meaning if the RSS is + // below this value, the receiver will reject the Wi-Fi frame. + // However, we want to allow the rate adaptation to work down to low + // SNR values. To allow this, we need to do three things: 1) disable + // the noise figure (set it to 0 dB) so that the noise level in 20 MHz + // is around -101 dBm, 2) lower the CCA sensitivity to a value that + // disables it (e.g. -110 dBm), and 3) disable the Wi-Fi preamble + // detection model. + wifiPhy.Set("CcaSensitivity", DoubleValue(-110)); + wifiPhy.Set("RxNoiseFigure", DoubleValue(0)); + wifiPhy.DisablePreambleDetectionModel(); NetDeviceContainer wifiApDevices; NetDeviceContainer wifiStaDevices; @@ -296,10 +334,6 @@ main(int argc, char* argv[]) wifiDevices.Add(wifiStaDevices); wifiDevices.Add(wifiApDevices); - // Set channel width - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", - UintegerValue(chWidth)); - // Set guard interval Config::Set( "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/ShortGuardIntervalSupported", @@ -359,9 +393,9 @@ main(int argc, char* argv[]) MakeCallback(&NodeStatistics::RxCallback, &atpCounter)); // Callbacks to print every change of rate - Config::ConnectFailSafe("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$" + - apManager + "/RateChange", - MakeCallback(RateCallback)); + Config::ConnectWithoutContextFailSafe( + "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$" + apManager + "/Rate", + MakeCallback(RateCallback)); Simulator::Stop(Seconds(simuTime)); Simulator::Run(); diff --git a/examples/wireless/wifi-simple-adhoc-grid.cc b/examples/wireless/wifi-simple-adhoc-grid.cc index d722ed193..8de6b70f9 100644 --- a/examples/wireless/wifi-simple-adhoc-grid.cc +++ b/examples/wireless/wifi-simple-adhoc-grid.cc @@ -255,7 +255,7 @@ main(int argc, char* argv[]) InetSocketAddress remote = InetSocketAddress(i.GetAddress(sinkNode, 0), 80); source->Connect(remote); - if (tracing == true) + if (tracing) { AsciiTraceHelper ascii; wifiPhy.EnableAsciiAll(ascii.CreateFileStream("wifi-simple-adhoc-grid.tr")); diff --git a/examples/wireless/wifi-spatial-reuse.cc b/examples/wireless/wifi-spatial-reuse.cc index 26aa40654..efcdcfa17 100644 --- a/examples/wireless/wifi-spatial-reuse.cc +++ b/examples/wireless/wifi-spatial-reuse.cc @@ -54,7 +54,7 @@ // time. // // Note that, by default, this script configures a network using a -// channel bandwidth of 20 MHz. Changing this value alone (through +// channel width of 20 MHz. Changing this value alone (through // the --channelWidth argument) without properly adjusting other // parameters will void the effect of spatial reuse: since energy is // measured over the 20 MHz primary channel regardless of the channel @@ -69,11 +69,11 @@ // all these values by 3 dB compared to their defaults. // // In addition, consider that adapting the adjustments shown above -// for an 80 MHz bandwidth (using a 6 dB threshold adjustment instead +// for an 80 MHz channel width (using a 6 dB threshold adjustment instead // of 3 dB) will not produce any changes when enableObssPd is enabled // or disabled. The cause for this is the insufficient amount of // traffic that is generated by default in the example: increasing -// the bandwidth shortens the frame durations, and lowers the +// the channel width shortens the frame durations, and lowers the // collision probability. Collisions between BSSs are a necessary // condition to see the improvements brought by spatial reuse, and // thus increasing the amount of generated traffic by setting the @@ -134,7 +134,7 @@ main(int argc, char* argv[]) double ccaEdTrAp1 = -62; // dBm double ccaEdTrAp2 = -62; // dBm double minimumRssi = -82; // dBm - int channelBandwidth = 20; // MHz + int channelWidth = 20; // MHz uint32_t payloadSize = 1500; // bytes uint32_t mcs = 0; // MCS value double interval = 0.001; // seconds @@ -159,9 +159,7 @@ main(int argc, char* argv[]) cmd.AddValue("minimumRssi", "Minimum RSSI for the ThresholdPreambleDetectionModel", minimumRssi); - cmd.AddValue("channelBandwidth", - "Bandwidth of the channel in MHz [20, 40, or 80]", - channelBandwidth); + cmd.AddValue("channelWidth", "Bandwidth of the channel in MHz [20, 40, or 80]", channelWidth); cmd.AddValue("obssPdThreshold", "Threshold for the OBSS PD Algorithm", obssPdThreshold); cmd.AddValue("mcs", "The constant MCS value to transmit HE PPDUs", mcs); cmd.Parse(argc, argv); @@ -182,7 +180,7 @@ main(int argc, char* argv[]) spectrumPhy.SetChannel(spectrumChannel); spectrumPhy.SetErrorRateModel("ns3::YansErrorRateModel"); - switch (channelBandwidth) + switch (channelWidth) { case 20: spectrumPhy.Set("ChannelSettings", StringValue("{36, 20, BAND_5GHZ, 0}")); @@ -194,7 +192,7 @@ main(int argc, char* argv[]) spectrumPhy.Set("ChannelSettings", StringValue("{171, 80, BAND_5GHZ, 0}")); break; default: - NS_ABORT_MSG("Unrecognized channel bandwidth: " << channelBandwidth); + NS_ABORT_MSG("Unrecognized channel width: " << channelWidth); break; } spectrumPhy.SetPreambleDetectionModel("ns3::ThresholdPreambleDetectionModel", diff --git a/examples/wireless/wifi-vht-network.cc b/examples/wireless/wifi-vht-network.cc index 0e48233f7..b9acfc8a6 100644 --- a/examples/wireless/wifi-vht-network.cc +++ b/examples/wireless/wifi-vht-network.cc @@ -90,11 +90,8 @@ main(int argc, char* argv[]) Config::SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue("0")); } - double prevThroughput[8]; - for (uint32_t l = 0; l < 8; l++) - { - prevThroughput[l] = 0; - } + double prevThroughput[8] = {0}; + std::cout << "MCS value" << "\t\t" << "Channel width" diff --git a/ns3 b/ns3 index f5a8e2817..9da22bdec 100755 --- a/ns3 +++ b/ns3 @@ -187,8 +187,7 @@ def parse_args(argv): action="store_true", default=None) parser_configure.add_argument('--out', '--output-directory', - help=('Use BRITE integration support, given by the indicated path,' - ' to allow the use of the BRITE topology generator'), + help=('Directory to store build artifacts'), type=str, default=None, dest="output_directory") parser_configure.add_argument('--with-brite', help=('Use BRITE integration support, given by the indicated path,' @@ -283,7 +282,7 @@ def parse_args(argv): help='Try "./ns3 docs --help" for more documentation options') parser_docs.add_argument('docs', help='Build project documentation', - choices=["manual", "models", "tutorial", "contributing", + choices=["contributing", "installation", "manual", "models", "tutorial", "sphinx", "doxygen-no-build", "doxygen", "all"], action="store", type=str, default=None) @@ -611,6 +610,14 @@ def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_gener if args.G is None: args.G = current_cmake_generator + # Get the current Python information to supply + # CMake with the respective installation + if args.enable_python_bindings is True: + import sysconfig + cmake_args.append(f"-DPython3_LIBRARY_DIRS={sysconfig.get_config_var('LIBDIR')}") + cmake_args.append(f"-DPython3_INCLUDE_DIRS={sysconfig.get_config_var('INCLUDEPY')}") + cmake_args.append(f"-DPython3_EXECUTABLE={sys.executable}") + # C++ standard if args.cxx_standard is not None: cmake_args.append("-DCMAKE_CXX_STANDARD=%s" % args.cxx_standard) @@ -796,7 +803,7 @@ def get_program_shortcuts(build_profile, ns3_version): ns3_program_map[shortcut_path] = [program] - # Add an additional shortcut with .exe suffix when running on Windows + # Add a shortcut with .exe suffix when running on Windows if sys.platform == "win32": ns3_program_map[shortcut_path.replace("\\", "/")] = [program] ns3_program_map[shortcut_path + ".exe"] = [program] @@ -848,6 +855,7 @@ def cmake_check_version(): if not cmake: print("Error: CMake not found; please install version 3.10 or greater, or modify", path_variable) exit(1) + cmake = cmake.replace(".EXE", "").replace(".exe", "") # Trim cmake executable extension cmake_output = subprocess.check_output([cmake, "--version"]).decode("utf-8") version = re.findall("version (.*)", cmake_output)[0] if parse_version(version) < parse_version("3.10.0"): @@ -1047,6 +1055,7 @@ def build_step(args, "docs", "doxygen", "doxygen-no-build", + "installation", "sphinx", "manual", "models", @@ -1065,7 +1074,7 @@ def build_step(args, target = get_target_to_build(target, ns3_version, build_profile) else: # Sphinx target should have the sphinx prefix - if target in ["contributing", "manual", "models", "tutorial"]: + if target in ["contributing", "installation", "manual", "models", "tutorial"]: target = "sphinx_%s" % target # Docs should build both doxygen and sphinx based docs @@ -1586,30 +1595,7 @@ def main(): output ) - def remove_overlapping_path(base_path, target_path): - """ - Remove overlapping paths from output directory and target_to_run - :param base_path: output path of the ns-3 build - :param target_path: path to the executable to run - :return: target_path without the overlapping parts - """ - target_path = target_path.replace('/', os.sep).split(os.sep) - base_path = base_path.replace('/', os.sep).split(os.sep) - while target_path[0] in base_path: - target_path = target_path[1:] - target_path = os.sep.join(target_path) - return target_path - if not args.shell and target_to_run and ".py" not in target_to_run: - target_to_run = remove_overlapping_path(out_dir, target_to_run) - - # Waf doesn't add version prefix and build type suffix to the scratches, so we remove them - if current_cmake_cache_folder is None: - if "scratch" in target_to_run and run_only: - waf_target_to_run = target_to_run.replace(os.path.basename(target_to_run), args.run) - if os.path.exists(os.sep.join([out_dir, waf_target_to_run])): - target_to_run = waf_target_to_run - target_to_run = os.sep.join([out_dir, target_to_run]) if sys.platform == "win32": target_to_run += ".exe" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..a18eb14ff --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = [ + "wheel", + "setuptools>=45", + "setuptools_scm[toml]>=6.0", + "cmake-build-extension>=0.4", + "cppyy==2.4.2", +] + +[tool.setuptools_scm] +version_scheme = "post-release" +local_scheme = "no-local-version" + +[tool.cibuildwheel] +build-frontend = "build" diff --git a/scratch/CMakeLists.txt b/scratch/CMakeLists.txt index 7d05f6022..093e79d7b 100644 --- a/scratch/CMakeLists.txt +++ b/scratch/CMakeLists.txt @@ -30,7 +30,17 @@ function(create_scratch source_files) string(REPLACE "/" "_" scratch_dirname "${scratch_dirname}") # Get source name - get_filename_component(scratch_name ${scratch_src} NAME_WE) + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0") + get_filename_component(scratch_name ${scratch_src} NAME_WLE) + else() + get_filename_component(scratch_name ${scratch_src} NAME) + string(FIND "${scratch_name}" "." ext_position REVERSE) + if(${ext_position} EQUAL -1) + message(FATAL_ERROR "Source file has no extension: ${scratch_src}") + else() + string(SUBSTRING "${scratch_name}" 0 ${ext_position} scratch_name) + endif() + endif() set(target_prefix scratch_) if(scratch_dirname) diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..679a7d3d9 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,44 @@ +[metadata] +name = ns3 +description = ns-3 network simulator and visualizer +long_description = file: README.md +long_description_content_type = text/markdown +author = nsnam +author_email = webmaster@nsnam.org +license = GPL-2.0-only +platforms = any +url = https://www.nsnam.org/ + +project_urls = + Tracker = https://gitlab.com/nsnam/ns-3-dev/-/issues + Documentation = https://www.nsnam.org/docs/tutorial/html/index.html + Source = https://gitlab.com/nsnam/ns-3-dev + +keywords = + network-simulator + +classifiers = + Development Status :: 5 - Production/Stable + Operating System :: POSIX :: Linux + #Operating System :: MacOS + #Operating System :: Microsoft :: Windows + Intended Audience :: Education + Intended Audience :: Developers + Intended Audience :: Science/Research + Programming Language :: C++ + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: Implementation :: CPython + License :: OSI Approved :: GNU General Public License v2 (GPLv2) + +[options] +zip_safe = False +python_requires = >=3.6 +install_requires = + cppyy==2.4.2 + diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..8aa256955 --- /dev/null +++ b/setup.py @@ -0,0 +1,35 @@ +import cmake_build_extension +import setuptools +import sys +import sysconfig + +setuptools.setup( + cmdclass=dict(build_ext=cmake_build_extension.BuildExtension), + packages=['ns', 'visualizer'], + package_dir={ + 'ns': './build-support/pip-wheel/ns', + 'visualizer': './build-support/pip-wheel/visualizer' + }, + ext_modules=[ + cmake_build_extension.CMakeExtension( + name="BuildAndInstall", + install_prefix="ns3", + cmake_configure_options=[ + "-DCMAKE_BUILD_TYPE:STRING=release", + "-DNS3_ASSERT:BOOL=ON", + "-DNS3_LOG:BOOL=ON", + "-DNS3_WARNINGS_AS_ERRORS:BOOL=OFF", + "-DNS3_PYTHON_BINDINGS:BOOL=ON", + "-DNS3_BINDINGS_INSTALL_DIR:STRING=INSTALL_PREFIX", + "-DNS3_FETCH_OPTIONAL_COMPONENTS:BOOL=ON", + "-DNS3_PIP_PACKAGING:BOOL=ON", + "-DNS3_USE_LIB64:BOOL=ON", + # Make CMake find python components from the currently running python + # https://catherineh.github.io/programming/2021/11/16/python-binary-distributions-whls-with-c17-cmake-auditwheel-and-manylinux + f"-DPython3_LIBRARY_DIRS={sysconfig.get_config_var('LIBDIR')}", + f"-DPython3_INCLUDE_DIRS={sysconfig.get_config_var('INCLUDEPY')}", + f"-DPython3_EXECUTABLE={sys.executable}" + ] + ), + ], +) diff --git a/src/antenna/model/phased-array-model.h b/src/antenna/model/phased-array-model.h index 563bb8b3c..9f6472536 100644 --- a/src/antenna/model/phased-array-model.h +++ b/src/antenna/model/phased-array-model.h @@ -140,13 +140,6 @@ class PhasedArrayModel : public Object uint32_t GetId() const; protected: - /** - * Utility method to compute the euclidean norm of a ComplexVector - * \param vector the ComplexVector - * \return the euclidean norm - */ - static double ComputeNorm(const ComplexVector& vector); - ComplexVector m_beamformingVector; //!< the beamforming vector in use Ptr m_antennaElement; //!< the model of the antenna element in use bool m_isBfVectorValid; //!< ensures the validity of the beamforming vector diff --git a/src/aodv/model/aodv-id-cache.h b/src/aodv/model/aodv-id-cache.h index f2699fab6..1d059d4a0 100644 --- a/src/aodv/model/aodv-id-cache.h +++ b/src/aodv/model/aodv-id-cache.h @@ -109,7 +109,7 @@ class IdCache * \param u UniqueId entry * \return true if expired, false otherwise */ - bool operator()(const struct UniqueId& u) const + bool operator()(const UniqueId& u) const { return (u.m_expire < Simulator::Now()); } diff --git a/src/aodv/model/aodv-routing-protocol.cc b/src/aodv/model/aodv-routing-protocol.cc index ba7e8355a..94cb44489 100644 --- a/src/aodv/model/aodv-routing-protocol.cc +++ b/src/aodv/model/aodv-routing-protocol.cc @@ -497,10 +497,10 @@ bool RoutingProtocol::RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) { NS_LOG_FUNCTION(this << p->GetUid() << header.GetDestination() << idev->GetAddress()); if (m_socketAddresses.empty()) @@ -558,7 +558,7 @@ RoutingProtocol::RouteInput(Ptr p, } UpdateRouteLifeTime(origin, m_activeRouteTimeout); Ptr packet = p->Copy(); - if (lcb.IsNull() == false) + if (!lcb.IsNull()) { NS_LOG_LOGIC("Broadcast local delivery to " << iface.GetLocal()); lcb(p, header, iif); @@ -617,7 +617,7 @@ RoutingProtocol::RouteInput(Ptr p, UpdateRouteLifeTime(toOrigin.GetNextHop(), m_activeRouteTimeout); m_nb.Update(toOrigin.GetNextHop(), m_activeRouteTimeout); } - if (lcb.IsNull() == false) + if (!lcb.IsNull()) { NS_LOG_LOGIC("Unicast local delivery to " << dst); lcb(p, header, iif); @@ -632,7 +632,7 @@ RoutingProtocol::RouteInput(Ptr p, } // Check if input device supports IP forwarding - if (m_ipv4->IsForwarding(iif) == false) + if (!m_ipv4->IsForwarding(iif)) { NS_LOG_LOGIC("Forwarding disabled for this interface"); ecb(p, header, Socket::ERROR_NOROUTETOHOST); diff --git a/src/aodv/model/aodv-routing-protocol.h b/src/aodv/model/aodv-routing-protocol.h index 637b1b890..363268804 100644 --- a/src/aodv/model/aodv-routing-protocol.h +++ b/src/aodv/model/aodv-routing-protocol.h @@ -78,10 +78,10 @@ class RoutingProtocol : public Ipv4RoutingProtocol bool RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override; + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override; void NotifyInterfaceUp(uint32_t interface) override; void NotifyInterfaceDown(uint32_t interface) override; void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) override; diff --git a/src/aodv/model/aodv-rtable.h b/src/aodv/model/aodv-rtable.h index ac65e21c8..dfe52fe58 100644 --- a/src/aodv/model/aodv-rtable.h +++ b/src/aodv/model/aodv-rtable.h @@ -407,7 +407,7 @@ class RoutingTableEntry /// List of precursors std::vector m_precursorList; /// When I can send another request - Time m_routeRequestTimout; + Time m_routeRequestTimeout; /// Number of route requests uint8_t m_reqCount; /// Indicate if this entry is in "blacklist" diff --git a/src/aodv/test/examples-to-run.py b/src/aodv/test/examples-to-run.py index 05d689e44..1edd6a9ff 100644 --- a/src/aodv/test/examples-to-run.py +++ b/src/aodv/test/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/src/applications/examples/three-gpp-http-example.cc b/src/applications/examples/three-gpp-http-example.cc index 2fe725cb4..991d0f37d 100644 --- a/src/applications/examples/three-gpp-http-example.cc +++ b/src/applications/examples/three-gpp-http-example.cc @@ -93,6 +93,17 @@ ClientEmbeddedObjectReceived(Ptr, Ptr pa } } +void +ClientPageReceived(Ptr client, + const Time& time, + uint32_t numObjects, + uint32_t numBytes) +{ + NS_LOG_INFO("Client " << client << " has received a page that took " << time.As(Time::MS) + << " ms to load with " << numObjects << " objects and " << numBytes + << " bytes."); +} + int main(int argc, char* argv[]) { @@ -163,6 +174,7 @@ main(int argc, char* argv[]) httpClient->TraceConnectWithoutContext("RxEmbeddedObject", MakeCallback(&ClientEmbeddedObjectReceived)); httpClient->TraceConnectWithoutContext("Rx", MakeCallback(&ClientRx)); + httpClient->TraceConnectWithoutContext("RxPage", MakeCallback(&ClientPageReceived)); // Stop browsing after 30 minutes clientApps.Stop(Seconds(simTimeSec)); diff --git a/src/applications/model/three-gpp-http-client.cc b/src/applications/model/three-gpp-http-client.cc index 8cfec42f2..ecf837d49 100644 --- a/src/applications/model/three-gpp-http-client.cc +++ b/src/applications/model/three-gpp-http-client.cc @@ -47,6 +47,9 @@ ThreeGppHttpClient::ThreeGppHttpClient() m_objectClientTs(MilliSeconds(0)), m_objectServerTs(MilliSeconds(0)), m_embeddedObjectsToBeRequested(0), + m_pageLoadStartTs(MilliSeconds(0)), + m_numberEmbeddedObjectsRequested(0), + m_numberBytesPage(0), m_httpVariables(CreateObject()) { NS_LOG_FUNCTION(this); @@ -76,6 +79,10 @@ ThreeGppHttpClient::GetTypeId() UintegerValue(80), // the default HTTP port MakeUintegerAccessor(&ThreeGppHttpClient::m_remoteServerPort), MakeUintegerChecker()) + .AddTraceSource("RxPage", + "A page has been received.", + MakeTraceSourceAccessor(&ThreeGppHttpClient::m_rxPageTrace), + "ns3::ThreeGppHttpClient::RxPageTracedCallback") .AddTraceSource( "ConnectionEstablished", "Connection to the destination web server has been established.", @@ -162,29 +169,21 @@ ThreeGppHttpClient::GetStateString(ThreeGppHttpClient::State_t state) { case NOT_STARTED: return "NOT_STARTED"; - break; case CONNECTING: return "CONNECTING"; - break; case EXPECTING_MAIN_OBJECT: return "EXPECTING_MAIN_OBJECT"; - break; case PARSING_MAIN_OBJECT: return "PARSING_MAIN_OBJECT"; - break; case EXPECTING_EMBEDDED_OBJECT: return "EXPECTING_EMBEDDED_OBJECT"; - break; case READING: return "READING"; - break; case STOPPED: return "STOPPED"; - break; default: NS_FATAL_ERROR("Unknown state"); return "FATAL_ERROR"; - break; } } @@ -447,6 +446,7 @@ ThreeGppHttpClient::RequestMainObject() else { SwitchToState(EXPECTING_MAIN_OBJECT); + m_pageLoadStartTs = Simulator::Now(); // start counting page loading time } } else @@ -628,6 +628,7 @@ ThreeGppHttpClient::ReceiveEmbeddedObject(Ptr packet, const Address& fro * downloaded completely. Now is the time to read it. */ NS_LOG_INFO(this << " Finished receiving a web page."); + FinishReceivingPage(); // trigger callback for page loading time EnterReadingTime(); } @@ -669,6 +670,7 @@ ThreeGppHttpClient::Receive(Ptr packet) m_constructedPacket->AddHeader(httpHeader); } uint32_t contentSize = packet->GetSize(); + m_numberBytesPage += contentSize; // increment counter of page size /* Note that the packet does not contain header at this point. * The content is purely raw data, which was the only intended data to be received. @@ -724,6 +726,8 @@ ThreeGppHttpClient::ParseMainObject() if (m_state == PARSING_MAIN_OBJECT) { m_embeddedObjectsToBeRequested = m_httpVariables->GetNumOfEmbeddedObjects(); + // saving total number of embedded objects + m_numberEmbeddedObjectsRequested = m_embeddedObjectsToBeRequested; NS_LOG_INFO(this << " Parsing has determined " << m_embeddedObjectsToBeRequested << " embedded object(s) in the main object."); @@ -743,6 +747,7 @@ ThreeGppHttpClient::ParseMainObject() * enjoy the plain web page. */ NS_LOG_INFO(this << " Finished receiving a web page."); + FinishReceivingPage(); // trigger callback for page loading time EnterReadingTime(); } } @@ -826,4 +831,16 @@ ThreeGppHttpClient::SwitchToState(ThreeGppHttpClient::State_t state) m_stateTransitionTrace(oldState, newState); } +void +ThreeGppHttpClient::FinishReceivingPage() +{ + m_rxPageTrace(this, + Simulator::Now() - m_pageLoadStartTs, + m_numberEmbeddedObjectsRequested, + m_numberBytesPage); + // Reset counter variables. + m_numberEmbeddedObjectsRequested = 0; + m_numberBytesPage = 0; +} + } // namespace ns3 diff --git a/src/applications/model/three-gpp-http-client.h b/src/applications/model/three-gpp-http-client.h index a149ce878..d0ad86ce7 100644 --- a/src/applications/model/three-gpp-http-client.h +++ b/src/applications/model/three-gpp-http-client.h @@ -172,6 +172,20 @@ class ThreeGppHttpClient : public Application */ typedef void (*TracedCallback)(Ptr httpClient); + /** + * Callback signature for `RxPage` trace sources. + * \param httpClient Pointer to this instance of ThreeGppHttpClient, + * which is where the trace originated. + * \param time Elapsed time from the start to the end of the request. + * \param numObjects Number of objects downloaded, including main and + * embedded objects. + * \param numBytes Total number of bytes included in the page. + */ + typedef void (*RxPageTracedCallback)(Ptr httpClient, + const Time& time, + uint32_t numObjects, + uint32_t numBytes); + protected: // Inherited from Object base class. void DoDispose() override; @@ -343,6 +357,12 @@ class ThreeGppHttpClient : public Application */ void SwitchToState(State_t state); + /** + * Finish receiving a page. This function should be called when a full-page + * finishes loading, including the main object and all embedded objects. + */ + void FinishReceivingPage(); + /// The current state of the client application. Begins with NOT_STARTED. State_t m_state; /// The socket for sending and receiving packets to/from the web server. @@ -357,6 +377,12 @@ class ThreeGppHttpClient : public Application Time m_objectServerTs; /// Determined after parsing the main object. uint32_t m_embeddedObjectsToBeRequested; + /// The time stamp when the page started loading. + Time m_pageLoadStartTs; + /// Number of embedded objects to requested in the current page. + uint32_t m_numberEmbeddedObjectsRequested; + /// Number of bytes received for the current page. + uint32_t m_numberBytesPage; // ATTRIBUTES @@ -369,6 +395,9 @@ class ThreeGppHttpClient : public Application // TRACE SOURCES + /// The `RxPage` trace source. + ns3::TracedCallback, const Time&, uint32_t, uint32_t> + m_rxPageTrace; /// The `ConnectionEstablished` trace source. ns3::TracedCallback> m_connectionEstablishedTrace; /// The `ConnectionClosed` trace source. diff --git a/src/applications/model/three-gpp-http-server.cc b/src/applications/model/three-gpp-http-server.cc index e90931e9f..f458a49bb 100644 --- a/src/applications/model/three-gpp-http-server.cc +++ b/src/applications/model/three-gpp-http-server.cc @@ -155,17 +155,13 @@ ThreeGppHttpServer::GetStateString(ThreeGppHttpServer::State_t state) { case NOT_STARTED: return "NOT_STARTED"; - break; case STARTED: return "STARTED"; - break; case STOPPED: return "STOPPED"; - break; default: NS_FATAL_ERROR("Unknown state"); return "FATAL_ERROR"; - break; } } @@ -197,7 +193,7 @@ ThreeGppHttpServer::StartApplication() const TypeId tcpSocketTid = TcpSocket::GetTypeId(); for (uint32_t i = 0; i < tcpSocketTid.GetAttributeN(); i++) { - struct TypeId::AttributeInformation attrInfo = tcpSocketTid.GetAttribute(i); + TypeId::AttributeInformation attrInfo = tcpSocketTid.GetAttribute(i); if (attrInfo.name == "SegmentSize") { previousSocketMtu = attrInfo.initialValue; diff --git a/src/applications/model/udp-client.cc b/src/applications/model/udp-client.cc index f5b4c9379..1d374d9f4 100644 --- a/src/applications/model/udp-client.cc +++ b/src/applications/model/udp-client.cc @@ -76,7 +76,15 @@ UdpClient::GetTypeId() "the size of the header carrying the sequence number and the time stamp.", UintegerValue(1024), MakeUintegerAccessor(&UdpClient::m_size), - MakeUintegerChecker(12, 65507)); + MakeUintegerChecker(12, 65507)) + .AddTraceSource("Tx", + "A new packet is created and sent", + MakeTraceSourceAccessor(&UdpClient::m_txTrace), + "ns3::Packet::TracedCallback") + .AddTraceSource("TxWithAddresses", + "A new packet is created and sent", + MakeTraceSourceAccessor(&UdpClient::m_txTraceWithAddresses), + "ns3::Packet::TwoAddressTracedCallback"); return tid; } @@ -125,7 +133,7 @@ UdpClient::StartApplication() { TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory"); m_socket = Socket::CreateSocket(GetNode(), tid); - if (Ipv4Address::IsMatchingType(m_peerAddress) == true) + if (Ipv4Address::IsMatchingType(m_peerAddress)) { if (m_socket->Bind() == -1) { @@ -134,7 +142,7 @@ UdpClient::StartApplication() m_socket->Connect( InetSocketAddress(Ipv4Address::ConvertFrom(m_peerAddress), m_peerPort)); } - else if (Ipv6Address::IsMatchingType(m_peerAddress) == true) + else if (Ipv6Address::IsMatchingType(m_peerAddress)) { if (m_socket->Bind6() == -1) { @@ -143,7 +151,7 @@ UdpClient::StartApplication() m_socket->Connect( Inet6SocketAddress(Ipv6Address::ConvertFrom(m_peerAddress), m_peerPort)); } - else if (InetSocketAddress::IsMatchingType(m_peerAddress) == true) + else if (InetSocketAddress::IsMatchingType(m_peerAddress)) { if (m_socket->Bind() == -1) { @@ -151,7 +159,7 @@ UdpClient::StartApplication() } m_socket->Connect(m_peerAddress); } - else if (Inet6SocketAddress::IsMatchingType(m_peerAddress) == true) + else if (Inet6SocketAddress::IsMatchingType(m_peerAddress)) { if (m_socket->Bind6() == -1) { @@ -203,9 +211,20 @@ UdpClient::Send() { NS_LOG_FUNCTION(this); NS_ASSERT(m_sendEvent.IsExpired()); + + Address from; + Address to; + m_socket->GetSockName(from); + m_socket->GetPeerName(to); SeqTsHeader seqTs; seqTs.SetSeq(m_sent); - Ptr p = Create(m_size - (8 + 4)); // 8+4 : the size of the seqTs header + NS_ABORT_IF(m_size < seqTs.GetSerializedSize()); + Ptr p = Create(m_size - seqTs.GetSerializedSize()); + + // Trace before adding header, for consistency with PacketSink + m_txTrace(p); + m_txTraceWithAddresses(p, from, to); + p->AddHeader(seqTs); if ((m_socket->Send(p)) >= 0) diff --git a/src/applications/model/udp-client.h b/src/applications/model/udp-client.h index 0f241ab5a..d5a14d93a 100644 --- a/src/applications/model/udp-client.h +++ b/src/applications/model/udp-client.h @@ -26,6 +26,7 @@ #include "ns3/event-id.h" #include "ns3/ipv4-address.h" #include "ns3/ptr.h" +#include namespace ns3 { @@ -82,6 +83,12 @@ class UdpClient : public Application */ void Send(); + /// Traced Callback: transmitted packets. + TracedCallback> m_txTrace; + + /// Callbacks for tracing the packet Tx events, includes source and destination addresses + TracedCallback, const Address&, const Address&> m_txTraceWithAddresses; + uint32_t m_count; //!< Maximum number of packets the application will send Time m_interval; //!< Packet inter-send time uint32_t m_size; //!< Size of the sent packet (including the SeqTsHeader) @@ -92,6 +99,7 @@ class UdpClient : public Application Address m_peerAddress; //!< Remote peer address uint16_t m_peerPort; //!< Remote peer port EventId m_sendEvent; //!< Event to send the next packet + #ifdef NS3_LOG_ENABLE std::string m_peerAddressString; //!< Remote peer address string #endif // NS3_LOG_ENABLE diff --git a/src/applications/model/udp-echo-client.cc b/src/applications/model/udp-echo-client.cc index ef7531d57..abf302002 100644 --- a/src/applications/model/udp-echo-client.cc +++ b/src/applications/model/udp-echo-client.cc @@ -141,7 +141,7 @@ UdpEchoClient::StartApplication() { TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory"); m_socket = Socket::CreateSocket(GetNode(), tid); - if (Ipv4Address::IsMatchingType(m_peerAddress) == true) + if (Ipv4Address::IsMatchingType(m_peerAddress)) { if (m_socket->Bind() == -1) { @@ -150,7 +150,7 @@ UdpEchoClient::StartApplication() m_socket->Connect( InetSocketAddress(Ipv4Address::ConvertFrom(m_peerAddress), m_peerPort)); } - else if (Ipv6Address::IsMatchingType(m_peerAddress) == true) + else if (Ipv6Address::IsMatchingType(m_peerAddress)) { if (m_socket->Bind6() == -1) { @@ -159,7 +159,7 @@ UdpEchoClient::StartApplication() m_socket->Connect( Inet6SocketAddress(Ipv6Address::ConvertFrom(m_peerAddress), m_peerPort)); } - else if (InetSocketAddress::IsMatchingType(m_peerAddress) == true) + else if (InetSocketAddress::IsMatchingType(m_peerAddress)) { if (m_socket->Bind() == -1) { @@ -167,7 +167,7 @@ UdpEchoClient::StartApplication() } m_socket->Connect(m_peerAddress); } - else if (Inet6SocketAddress::IsMatchingType(m_peerAddress) == true) + else if (Inet6SocketAddress::IsMatchingType(m_peerAddress)) { if (m_socket->Bind6() == -1) { diff --git a/src/applications/model/udp-trace-client.cc b/src/applications/model/udp-trace-client.cc index d279e2d10..aa0e2deed 100644 --- a/src/applications/model/udp-trace-client.cc +++ b/src/applications/model/udp-trace-client.cc @@ -48,7 +48,7 @@ NS_OBJECT_ENSURE_REGISTERED(UdpTraceClient); /** * \brief Default trace to send */ -struct UdpTraceClient::TraceEntry UdpTraceClient::g_defaultEntries[] = { +UdpTraceClient::TraceEntry UdpTraceClient::g_defaultEntries[] = { {0, 534, 'I'}, {40, 1542, 'P'}, {120, 134, 'B'}, @@ -258,7 +258,7 @@ UdpTraceClient::StartApplication() { TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory"); m_socket = Socket::CreateSocket(GetNode(), tid); - if (Ipv4Address::IsMatchingType(m_peerAddress) == true) + if (Ipv4Address::IsMatchingType(m_peerAddress)) { if (m_socket->Bind() == -1) { @@ -267,7 +267,7 @@ UdpTraceClient::StartApplication() m_socket->Connect( InetSocketAddress(Ipv4Address::ConvertFrom(m_peerAddress), m_peerPort)); } - else if (Ipv6Address::IsMatchingType(m_peerAddress) == true) + else if (Ipv6Address::IsMatchingType(m_peerAddress)) { if (m_socket->Bind6() == -1) { @@ -276,7 +276,7 @@ UdpTraceClient::StartApplication() m_socket->Connect( Inet6SocketAddress(Ipv6Address::ConvertFrom(m_peerAddress), m_peerPort)); } - else if (InetSocketAddress::IsMatchingType(m_peerAddress) == true) + else if (InetSocketAddress::IsMatchingType(m_peerAddress)) { if (m_socket->Bind() == -1) { @@ -284,7 +284,7 @@ UdpTraceClient::StartApplication() } m_socket->Connect(m_peerAddress); } - else if (Inet6SocketAddress::IsMatchingType(m_peerAddress) == true) + else if (Inet6SocketAddress::IsMatchingType(m_peerAddress)) { if (m_socket->Bind6() == -1) { @@ -329,11 +329,11 @@ UdpTraceClient::SendPacket(uint32_t size) p->AddHeader(seqTs); std::stringstream addressString; - if (Ipv4Address::IsMatchingType(m_peerAddress) == true) + if (Ipv4Address::IsMatchingType(m_peerAddress)) { addressString << Ipv4Address::ConvertFrom(m_peerAddress); } - else if (Ipv6Address::IsMatchingType(m_peerAddress) == true) + else if (Ipv6Address::IsMatchingType(m_peerAddress)) { addressString << Ipv6Address::ConvertFrom(m_peerAddress); } @@ -362,7 +362,7 @@ UdpTraceClient::Send() bool cycled = false; Ptr p; - struct TraceEntry* entry = &m_entries[m_currentEntry]; + TraceEntry* entry = &m_entries[m_currentEntry]; do { for (uint32_t i = 0; i < entry->packetSize / m_maxPacketSize; i++) diff --git a/src/bridge/test/examples-to-run.py b/src/bridge/test/examples-to-run.py index e4ad040ee..5de34691b 100644 --- a/src/bridge/test/examples-to-run.py +++ b/src/bridge/test/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/src/brite/examples/brite-MPI-example.cc b/src/brite/examples/brite-MPI-example.cc index 428311600..21b6e8679 100644 --- a/src/brite/examples/brite-MPI-example.cc +++ b/src/brite/examples/brite-MPI-example.cc @@ -1,4 +1,6 @@ /* + * Copyright (c) 2012 The Georgia Institute of Technology + * * 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; @@ -12,6 +14,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * Author: Brian Swenson */ #include "Brite.h" diff --git a/src/brite/examples/brite-generic-example.cc b/src/brite/examples/brite-generic-example.cc index 462addf13..0ea758d1d 100644 --- a/src/brite/examples/brite-generic-example.cc +++ b/src/brite/examples/brite-generic-example.cc @@ -1,4 +1,6 @@ /* + * Copyright (c) 2012 The Georgia Institute of Technology + * * 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; @@ -12,6 +14,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * Author: Brian Swenson */ #include "Brite.h" diff --git a/src/brite/examples/brite-generic-example.py b/src/brite/examples/brite-generic-example.py new file mode 100644 index 000000000..24e45b963 --- /dev/null +++ b/src/brite/examples/brite-generic-example.py @@ -0,0 +1,104 @@ +# +# Copyright (c) 2012 The Georgia Institute of Technology +# +# 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: Brian Swenson +# Modified by: Gabriel Ferreira +# + +from ns import ns + +ns.LogComponentEnable("BriteTopologyHelper", ns.LOG_LEVEL_ALL) + +# BRITE needs a configuration file to build its graph. By default, this +# example will use the TD_ASBarabasi_RTWaxman.conf file. There are many others +# which can be found in the BRITE/conf_files directory +confFile = "src/brite/examples/conf_files/TD_ASBarabasi_RTWaxman.conf" + +# Invoke the BriteTopologyHelper and pass in a BRITE +# configuration file and a seed file. This will use +# BRITE to build a graph from which we can build the ns-3 topology +bth = ns.BriteTopologyHelper(confFile) +bth.AssignStreams(3) + +p2p = ns.PointToPointHelper() + +stack = ns.InternetStackHelper() + +nixRouting = ns.Ipv4NixVectorHelper() +stack.SetRoutingHelper(nixRouting) + +address = ns.Ipv4AddressHelper() +address.SetBase("10.0.0.0", "255.255.255.252") + +bth.BuildBriteTopology(stack) +bth.AssignIpv4Addresses(address) + +print(f"Number of AS created {bth.GetNAs()}") + +# The BRITE topology generator generates a topology of routers. Here we create +# two subnetworks which we attach to router leaf nodes generated by BRITE +# use just one node +client = ns.NodeContainer() +server = ns.NodeContainer() + +client.Create(1) +stack.Install(client) + +# install client node on last leaf node of AS 0 +numLeafNodesInAsZero = bth.GetNLeafNodesForAs(0) +client.Add(bth.GetLeafNodeForAs(0, numLeafNodesInAsZero - 1)) + +server.Create(1) +stack.Install(server) + +# install server node on last leaf node on AS 1 +numLeafNodesInAsOne = bth.GetNLeafNodesForAs(1) +server.Add(bth.GetLeafNodeForAs(1, numLeafNodesInAsOne - 1)) + +p2p.SetDeviceAttribute("DataRate", ns.StringValue("5Mbps")) +p2p.SetChannelAttribute("Delay", ns.StringValue("2ms")) + +p2pClientDevices = p2p.Install(client) +p2pServerDevices = p2p.Install(server) + +address.SetBase("10.1.0.0", "255.255.0.0") +clientInterfaces = address.Assign(p2pClientDevices) + +address.SetBase("10.2.0.0", "255.255.0.0") +serverInterfaces = ns.Ipv4InterfaceContainer() +serverInterfaces = address.Assign(p2pServerDevices) + +echoServer = ns.UdpEchoServerHelper(9) +serverApps = echoServer.Install(server.Get(0)) +serverApps.Start(ns.Seconds(1.0)) +serverApps.Stop(ns.Seconds(5.0)) + +echoClient = ns.UdpEchoClientHelper(serverInterfaces.GetAddress(0).ConvertTo(), 9) +echoClient.SetAttribute("MaxPackets", ns.UintegerValue(1)) +echoClient.SetAttribute("Interval", ns.TimeValue(ns.Seconds(1.))) +echoClient.SetAttribute("PacketSize", ns.UintegerValue(1024)) + +clientApps = echoClient.Install(client.Get(0)) +clientApps.Start(ns.Seconds(2.0)) +clientApps.Stop(ns.Seconds(5.0)) + +asciiTrace = ns.AsciiTraceHelper() +p2p.EnableAsciiAll(asciiTrace.CreateFileStream("briteLeaves.tr")) + +# Run the simulator +ns.Simulator.Stop(ns.Seconds(6.0)) +ns.Simulator.Run() +ns.Simulator.Destroy() diff --git a/src/brite/helper/brite-topology-helper.cc b/src/brite/helper/brite-topology-helper.cc index 9392cbe00..f98728165 100644 --- a/src/brite/helper/brite-topology-helper.cc +++ b/src/brite/helper/brite-topology-helper.cc @@ -412,8 +412,8 @@ BriteTopologyHelper::BuildBriteTopology(InternetStackHelper& stack, const uint32 NS_LOG_LOGIC("Assigning << " << m_numAs << " AS to " << systemCount << " MPI instances"); for (uint32_t i = 0; i < m_numAs; ++i) { - int val = i % systemCount; - m_systemForAs.push_back(val); + uint32_t val = i % systemCount; + m_systemForAs.push_back(static_cast(val)); NS_LOG_INFO("AS: " << i << " System: " << val); } diff --git a/src/brite/test/examples-to-run.py b/src/brite/test/examples-to-run.py index 5197de2ea..a69525170 100644 --- a/src/brite/test/examples-to-run.py +++ b/src/brite/test/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains @@ -17,4 +16,6 @@ cpp_examples = [ # (example_name, do_run). # # See test.py for more information. -python_examples = [] +python_examples = [ + ("brite-generic-example.py", "ENABLE_BRITE == True"), +] diff --git a/src/buildings/CMakeLists.txt b/src/buildings/CMakeLists.txt index 347b3f747..104ddb5fb 100644 --- a/src/buildings/CMakeLists.txt +++ b/src/buildings/CMakeLists.txt @@ -33,11 +33,12 @@ build_lib( LIBRARIES_TO_LINK ${libmobility} ${libpropagation} TEST_SOURCES - test/building-position-allocator-test.cc + test/buildings-channel-condition-model-test.cc test/buildings-helper-test.cc test/buildings-pathloss-test.cc + test/buildings-penetration-loss-pathloss-test.cc + test/building-position-allocator-test.cc test/buildings-shadowing-test.cc - test/buildings-channel-condition-model-test.cc test/outdoor-random-walk-test.cc test/three-gpp-v2v-channel-condition-model-test.cc ) diff --git a/src/buildings/doc/source/buildings-user.rst b/src/buildings/doc/source/buildings-user.rst index 5ae47dbda..92b0e8f9f 100644 --- a/src/buildings/doc/source/buildings-user.rst +++ b/src/buildings/doc/source/buildings-user.rst @@ -194,6 +194,14 @@ Building-aware channel condition models The class BuildingsChannelConditionModel implements a `channel condition model `_ which determines the LOS/NLOS channel state based on the buildings deployed in the scenario. +In addition, based on the wall material of the building, low/high building +penetration losses are considered, as defined in 3GPP TS 38.901 7.4.3.1. +In particular, for O2I condition, in case of Wood or ConcreteWithWindows material, +low losses are considered in the pathloss calculation. In case the material has +been set to ConcreteWithoutWindows or StoneBlocks, high losses are considered. +Notice that in certain corner cases, such as the I2O2I interference, the model +underestimates losses by applying either low or high losses based on the wall material +of the involved nodes. For a more accurate estimation the model can be further extended. The classes ``ThreeGppV2vUrbanChannelConditionModel`` and ``ThreeGppV2vHighwayChannelConditionModel`` implement hybrid channel condition diff --git a/src/buildings/examples/outdoor-group-mobility-example.cc b/src/buildings/examples/outdoor-group-mobility-example.cc index 6f59bca76..d9c657cbe 100644 --- a/src/buildings/examples/outdoor-group-mobility-example.cc +++ b/src/buildings/examples/outdoor-group-mobility-example.cc @@ -176,7 +176,7 @@ main(int argc, char* argv[]) // configuration. int64_t streamIndex = 1; - if (useHelper == false) + if (!useHelper) { // The reference (parent) mobility model starts at coordinate (10, 10, 0) // and performs a buildings-aware random walk. @@ -196,7 +196,7 @@ main(int argc, char* argv[]) outdoorMm->SetPosition(Vector(10, 10, 0)); streamIndex += outdoorMm->AssignStreams(streamIndex); - // Each HierachicalMobilityModel contains the above model as the Parent, + // Each HierarchicalMobilityModel contains the above model as the Parent, // and a user defined model as the Child. Two MobilityModel objects are // instantiated per node, and each node also shares the same parent model. diff --git a/src/buildings/helper/building-allocator.h b/src/buildings/helper/building-allocator.h index b8ad63318..e81df23a0 100644 --- a/src/buildings/helper/building-allocator.h +++ b/src/buildings/helper/building-allocator.h @@ -76,11 +76,11 @@ class GridBuildingAllocator : public Object */ void PushAttributes() const; - mutable uint32_t m_current; //!< current building number - enum GridPositionAllocator::LayoutType m_layoutType; //!< Layout type - double m_xMin; //!< The x coordinate where the grid starts - double m_yMin; //!< The y coordinate where the grid starts - uint32_t m_n; //!< The number of objects laid out on a line + mutable uint32_t m_current; //!< Current building number + GridPositionAllocator::LayoutType m_layoutType; //!< Layout type + double m_xMin; //!< The x coordinate where the grid starts + double m_yMin; //!< The y coordinate where the grid starts + uint32_t m_n; //!< The number of objects laid out on a line double m_lengthX; //!< The length of the wall of each building along the X axis. double m_lengthY; //!< The length of the wall of each building along the Y axis. double m_deltaX; //!< The x space between buildings diff --git a/src/buildings/model/buildings-channel-condition-model.cc b/src/buildings/model/buildings-channel-condition-model.cc index 5e89c598b..8b1dfbcb1 100644 --- a/src/buildings/model/buildings-channel-condition-model.cc +++ b/src/buildings/model/buildings-channel-condition-model.cc @@ -99,6 +99,35 @@ BuildingsChannelConditionModel::GetChannelCondition(Ptr a, { NS_LOG_DEBUG("a and b are indoor in different buildings"); cond->SetLosCondition(ChannelCondition::LosConditionValue::NLOS); + + ChannelCondition::O2iLowHighConditionValue lowHighLossConditionA1; + ChannelCondition::O2iLowHighConditionValue lowHighLossConditionB1; + + // Low losses considered for Wood or ConcreteWithWindows, while + // high losses for ConcreteWithoutWindows and StoneBlocks + lowHighLossConditionA1 = + a1->GetBuilding()->GetExtWallsType() == Building::ExtWallsType_t::Wood || + a1->GetBuilding()->GetExtWallsType() == + Building::ExtWallsType_t::ConcreteWithWindows + ? ChannelCondition::O2iLowHighConditionValue::LOW + : ChannelCondition::O2iLowHighConditionValue::HIGH; + + lowHighLossConditionB1 = + b1->GetBuilding()->GetExtWallsType() == Building::ExtWallsType_t::Wood || + b1->GetBuilding()->GetExtWallsType() == + Building::ExtWallsType_t::ConcreteWithWindows + ? ChannelCondition::O2iLowHighConditionValue::LOW + : ChannelCondition::O2iLowHighConditionValue::HIGH; + + if (lowHighLossConditionA1 == ChannelCondition::O2iLowHighConditionValue::HIGH || + lowHighLossConditionB1 == ChannelCondition::O2iLowHighConditionValue::HIGH) + { + cond->SetO2iLowHighCondition(ChannelCondition::O2iLowHighConditionValue::HIGH); + } + else + { + cond->SetO2iLowHighCondition(ChannelCondition::O2iLowHighConditionValue::LOW); + } } } else // outdoor to indoor case @@ -107,6 +136,31 @@ BuildingsChannelConditionModel::GetChannelCondition(Ptr a, NS_LOG_DEBUG("a is indoor and b outdoor or vice-versa"); cond->SetLosCondition(ChannelCondition::LosConditionValue::NLOS); + + ChannelCondition::O2iLowHighConditionValue lowHighLossCondition; + if (isAIndoor) + { + // Low losses considered for Wood or ConcreteWithWindows, while + // high losses for ConcreteWithoutWindows and StoneBlocks + lowHighLossCondition = + a1->GetBuilding()->GetExtWallsType() == Building::ExtWallsType_t::Wood || + a1->GetBuilding()->GetExtWallsType() == + Building::ExtWallsType_t::ConcreteWithWindows + ? ChannelCondition::O2iLowHighConditionValue::LOW + : ChannelCondition::O2iLowHighConditionValue::HIGH; + + cond->SetO2iLowHighCondition(lowHighLossCondition); + } + else + { + lowHighLossCondition = + b1->GetBuilding()->GetExtWallsType() == Building::ExtWallsType_t::Wood || + b1->GetBuilding()->GetExtWallsType() == + Building::ExtWallsType_t::ConcreteWithWindows + ? ChannelCondition::O2iLowHighConditionValue::LOW + : ChannelCondition::O2iLowHighConditionValue::HIGH; + cond->SetO2iLowHighCondition(lowHighLossCondition); + } } return cond; diff --git a/src/buildings/test/buildings-channel-condition-model-test.cc b/src/buildings/test/buildings-channel-condition-model-test.cc index d5a4aea2d..15024a886 100644 --- a/src/buildings/test/buildings-channel-condition-model-test.cc +++ b/src/buildings/test/buildings-channel-condition-model-test.cc @@ -121,6 +121,7 @@ BuildingsChannelConditionModelTestCase::DoRun() building->SetNRoomsY(1); building->SetNFloors(1); building->SetBoundaries(Box(0.0, 10.0, 0.0, 10.0, 0.0, 5.0)); + building->SetExtWallsType(Building::ExtWallsType_t::Wood); BuildingsHelper::Install(nodes); diff --git a/src/buildings/test/buildings-penetration-loss-pathloss-test.cc b/src/buildings/test/buildings-penetration-loss-pathloss-test.cc new file mode 100644 index 000000000..0bcf90d52 --- /dev/null +++ b/src/buildings/test/buildings-penetration-loss-pathloss-test.cc @@ -0,0 +1,280 @@ +/* + * Copyright (c) 2023 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * 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 + */ + +#include "ns3/abort.h" +#include "ns3/boolean.h" +#include "ns3/building.h" +#include "ns3/buildings-channel-condition-model.h" +#include "ns3/channel-condition-model.h" +#include "ns3/config.h" +#include "ns3/constant-position-mobility-model.h" +#include "ns3/constant-velocity-mobility-model.h" +#include "ns3/double.h" +#include "ns3/log.h" +#include "ns3/mobility-building-info.h" +#include "ns3/mobility-helper.h" +#include "ns3/simulator.h" +#include "ns3/test.h" +#include "ns3/three-gpp-propagation-loss-model.h" + +using namespace ns3; + +NS_LOG_COMPONENT_DEFINE("BuildingsPenetrationLossesTest"); + +/** + * \ingroup propagation-tests + * + * Test case for the 3GPP channel O2I building penetration losses. + * It considers pre-determined scenarios and based on the outdoor/indoor + * condition (O2O/O2I) checks whether the calculated received power + * is aligned with the calculation in 3GPP TR 38.901. + * + * For O2O condition the calculation is done according to Table 7.4.1-1 + * and we check if the calculated received power is equal to the expected + * value. + * For the O2I condition, the calculation is done considering the building + * penetration losses based on the material of the building walls. + * In this case, we check if the calculated received power is less than the + * received value (thus ensure that losses have been included). + */ + +class BuildingsPenetrationLossesTestCase : public TestCase +{ + public: + /** + * Constructor + */ + BuildingsPenetrationLossesTestCase(); + + /** + * Destructor + */ + ~BuildingsPenetrationLossesTestCase() override; + + private: + /** + * Builds the simulation scenario and perform the tests + */ + void DoRun() override; + + /** + * Struct containing the parameters for each test + */ + struct TestVector + { + Vector m_positionA; //!< the position of the first node + Vector m_positionB; //!< the position of the second node + double m_frequency; //!< carrier frequency in Hz + bool m_isLos; //!< LOS probability + TypeId m_condModel; //!< the type ID of the channel condition model to be used + TypeId m_propModel; //!< the type ID of the propagation loss model to be used + double m_pt; //!< transmitted power in dBm + double m_pr; //!< received power in dBm + }; + + TestVectors m_testVectors; //!< array containing all the test vectors + Ptr m_propModel; //!< the propagation loss model + double m_tolerance; //!< tolerance +}; + +BuildingsPenetrationLossesTestCase::BuildingsPenetrationLossesTestCase() + : TestCase("Test case for BuildingsPenetrationLosses"), + m_testVectors(), + m_tolerance(2e-3) +{ +} + +BuildingsPenetrationLossesTestCase::~BuildingsPenetrationLossesTestCase() +{ +} + +void +BuildingsPenetrationLossesTestCase::DoRun() +{ + // create the test vector + TestVector testVector; + + // tests for the RMa scenario + testVector.m_positionA = Vector(0, 0, 35.0); // O2I case + testVector.m_positionB = Vector(10, 0, 1.5); + testVector.m_frequency = 5.0e9; + testVector.m_propModel = ThreeGppRmaPropagationLossModel::GetTypeId(); + testVector.m_pt = 0.0; + testVector.m_pr = -77.3784; + m_testVectors.Add(testVector); + + testVector.m_positionA = Vector(0, 0, 35.0); // O2I case + testVector.m_positionB = Vector(100, 0, 1.5); + testVector.m_frequency = 5.0e9; + testVector.m_propModel = ThreeGppRmaPropagationLossModel::GetTypeId(); + testVector.m_pt = 0.0; + testVector.m_pr = -87.2965; + m_testVectors.Add(testVector); + + testVector.m_positionA = Vector(0, 0, 35.0); // O2O case + testVector.m_positionB = Vector(1000, 0, 1.5); + testVector.m_frequency = 5.0e9; + testVector.m_propModel = ThreeGppRmaPropagationLossModel::GetTypeId(); + testVector.m_pt = 0.0; + testVector.m_pr = -108.5577; + m_testVectors.Add(testVector); + + // tests for the UMa scenario + testVector.m_positionA = Vector(0, 0, 25.0); // O2I case + testVector.m_positionB = Vector(10, 0, 1.5); + testVector.m_frequency = 5.0e9; + testVector.m_propModel = ThreeGppUmaPropagationLossModel::GetTypeId(); + testVector.m_pt = 0.0; + testVector.m_pr = -72.9380; + m_testVectors.Add(testVector); + + testVector.m_positionA = Vector(0, 0, 25.0); // O2I case + testVector.m_positionB = Vector(100, 0, 1.5); + testVector.m_frequency = 5.0e9; + testVector.m_propModel = ThreeGppUmaPropagationLossModel::GetTypeId(); + testVector.m_pt = 0.0; + testVector.m_pr = -86.2362; + m_testVectors.Add(testVector); + + testVector.m_positionA = Vector(0, 0, 25.0); // O2O case + testVector.m_positionB = Vector(1000, 0, 1.5); + testVector.m_frequency = 5.0e9; + testVector.m_propModel = ThreeGppUmaPropagationLossModel::GetTypeId(); + testVector.m_pt = 0.0; + testVector.m_pr = -109.7252; + m_testVectors.Add(testVector); + + // tests for the UMi scenario + testVector.m_positionA = Vector(0, 0, 10.0); // O2I case + testVector.m_positionB = Vector(10, 0, 1.5); + testVector.m_frequency = 5.0e9; + testVector.m_propModel = ThreeGppUmiStreetCanyonPropagationLossModel::GetTypeId(); + testVector.m_pt = 0.0; + testVector.m_pr = -69.8591; + m_testVectors.Add(testVector); + + testVector.m_positionA = Vector(0, 0, 10.0); // O2I case + testVector.m_positionB = Vector(100, 0, 1.5); + testVector.m_frequency = 5.0e9; + testVector.m_propModel = ThreeGppUmiStreetCanyonPropagationLossModel::GetTypeId(); + testVector.m_pt = 0.0; + testVector.m_pr = -88.4122; + m_testVectors.Add(testVector); + + testVector.m_positionA = Vector(0, 0, 10.0); // O2O case + testVector.m_positionB = Vector(1000, 0, 1.5); + testVector.m_frequency = 5.0e9; + testVector.m_propModel = ThreeGppUmiStreetCanyonPropagationLossModel::GetTypeId(); + testVector.m_pt = 0.0; + testVector.m_pr = -119.3114; + m_testVectors.Add(testVector); + + // create the factory for the propagation loss model + ObjectFactory propModelFactory; + + Ptr building = Create(); + building->SetExtWallsType(Building::ExtWallsType_t::ConcreteWithWindows); + building->SetNRoomsX(1); + building->SetNRoomsY(1); + building->SetNFloors(2); + building->SetBoundaries(Box(0.0, 100.0, 0.0, 10.0, 0.0, 5.0)); + + // create the two nodes + NodeContainer nodes; + nodes.Create(2); + + // create the mobility models + Ptr a = CreateObject(); + Ptr b = CreateObject(); + + // aggregate the nodes and the mobility models + nodes.Get(0)->AggregateObject(a); + nodes.Get(1)->AggregateObject(b); + + Ptr buildingInfoA = CreateObject(); + Ptr buildingInfoB = CreateObject(); + a->AggregateObject(buildingInfoA); // operation usually done by BuildingsHelper::Install + buildingInfoA->MakeConsistent(a); + + b->AggregateObject(buildingInfoB); // operation usually done by BuildingsHelper::Install + buildingInfoB->MakeConsistent(b); + + Ptr condModel = CreateObject(); + + for (std::size_t i = 0; i < m_testVectors.GetN(); i++) + { + TestVector testVector = m_testVectors.Get(i); + a->SetPosition(testVector.m_positionA); + b->SetPosition(testVector.m_positionB); + + Ptr cond = condModel->GetChannelCondition(a, b); + + propModelFactory.SetTypeId(testVector.m_propModel); + m_propModel = propModelFactory.Create(); + m_propModel->SetAttribute("Frequency", DoubleValue(testVector.m_frequency)); + m_propModel->SetAttribute("ShadowingEnabled", BooleanValue(false)); + m_propModel->SetChannelConditionModel(condModel); + + bool isAIndoor = buildingInfoA->IsIndoor(); + bool isBIndoor = buildingInfoB->IsIndoor(); + + if (!isAIndoor && !isBIndoor) // a and b are outdoor + { + cond->SetLosCondition(ChannelCondition::LosConditionValue::LOS); + cond->SetO2iCondition(ChannelCondition::O2iConditionValue::O2O); + + // check rcv power to be equal to the calculated value without losses + NS_TEST_EXPECT_MSG_EQ_TOL(m_propModel->CalcRxPower(testVector.m_pt, a, b), + testVector.m_pr, + m_tolerance, + "rcv power is not equal expected value"); + } + else + { + cond->SetLosCondition(ChannelCondition::LosConditionValue::LOS); + cond->SetO2iCondition(ChannelCondition::O2iConditionValue::O2I); + cond->SetO2iLowHighCondition(ChannelCondition::O2iLowHighConditionValue::LOW); + + // check rcv power to be lower than the calculated without losses + NS_TEST_EXPECT_MSG_LT(m_propModel->CalcRxPower(testVector.m_pt, a, b), + testVector.m_pr, + "rcv power is not less than calculated value"); + } + m_propModel = nullptr; + } + Simulator::Destroy(); +} + +/** + * \ingroup propagation-tests + * + * Test suite for the buildings penetration losses + */ +class BuildingsPenetrationLossesTestSuite : public TestSuite +{ + public: + BuildingsPenetrationLossesTestSuite(); +}; + +BuildingsPenetrationLossesTestSuite::BuildingsPenetrationLossesTestSuite() + : TestSuite("buildings-penetration-losses", UNIT) +{ + AddTestCase(new BuildingsPenetrationLossesTestCase, TestCase::QUICK); +} + +/// Static variable for test initialization +static BuildingsPenetrationLossesTestSuite g_buildingsPenetrationLossesTestSuite; diff --git a/src/buildings/test/examples-to-run.py b/src/buildings/test/examples-to-run.py index ae65e352e..8a1f441cd 100644 --- a/src/buildings/test/examples-to-run.py +++ b/src/buildings/test/examples-to-run.py @@ -1,6 +1,4 @@ #! /usr/bin/env python3 -# -*- coding: utf-8 -*- -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/src/click/examples/nsclick-simple-lan.py b/src/click/examples/nsclick-simple-lan.py new file mode 100644 index 000000000..3a32e62f1 --- /dev/null +++ b/src/click/examples/nsclick-simple-lan.py @@ -0,0 +1,79 @@ +# +# 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: Lalith Suresh +# Modified by: Gabriel Ferreira +# + +import os.path + +from ns import ns + +ns.LogComponentEnable("Ipv4ClickRouting", ns.LOG_LEVEL_ALL) +ns.LogComponentEnable("Ipv4L3ClickProtocol", ns.LOG_LEVEL_ALL) + +clickConfigFolder = os.path.dirname(__file__) + +csmaNodes = ns.NodeContainer() +csmaNodes.Create(2) + +# Setup CSMA channel between the nodes +csma = ns.CsmaHelper() +csma.SetChannelAttribute("DataRate", ns.DataRateValue(ns.DataRate(5000000))) +csma.SetChannelAttribute("Delay", ns.TimeValue(ns.MilliSeconds(2))) +csmaDevices = csma.Install(csmaNodes) + +# Install normal internet stack on node B +internet = ns.InternetStackHelper() +internet.Install(csmaNodes.Get(1)) + +# Install Click on node A +clickinternet = ns.ClickInternetStackHelper() +clickinternet.SetClickFile(csmaNodes.Get(0), + clickConfigFolder + "/nsclick-lan-single-interface.click") +clickinternet.SetRoutingTableElement(csmaNodes.Get(0), "rt") +clickinternet.Install(csmaNodes.Get(0)) + +# Configure IP addresses for the nodes +ipv4 = ns.Ipv4AddressHelper() +ipv4.SetBase("172.16.1.0", "255.255.255.0") +ipv4.Assign(csmaDevices) + +# Configure traffic application and sockets +LocalAddress = ns.InetSocketAddress(ns.Ipv4Address.GetAny(), 50000).ConvertTo() +packetSinkHelper = ns.PacketSinkHelper("ns3::TcpSocketFactory", LocalAddress) +recvapp = packetSinkHelper.Install(csmaNodes.Get(1)) +recvapp.Start(ns.Seconds(5.0)) +recvapp.Stop(ns.Seconds(10.0)) + +onOffHelper = ns.OnOffHelper("ns3::TcpSocketFactory", ns.Address()) +onOffHelper.SetAttribute("OnTime", ns.StringValue("ns3::ConstantRandomVariable[Constant=1]")) +onOffHelper.SetAttribute("OffTime", ns.StringValue("ns3::ConstantRandomVariable[Constant=0]")) + +appcont = ns.ApplicationContainer() + +remoteAddress = ns.InetSocketAddress(ns.Ipv4Address("172.16.1.2"), 50000).ConvertTo() +onOffHelper.SetAttribute("Remote", ns.AddressValue(remoteAddress)) +appcont.Add(onOffHelper.Install(csmaNodes.Get(0))) + +appcont.Start(ns.Seconds(5.0)) +appcont.Stop(ns.Seconds(10.0)) + +# For tracing +csma.EnablePcap("nsclick-simple-lan", csmaDevices, False) + +ns.Simulator.Stop(ns.Seconds(20.0)) +ns.Simulator.Run() + +ns.Simulator.Destroy() diff --git a/src/click/helper/click-internet-stack-helper.cc b/src/click/helper/click-internet-stack-helper.cc index ee800ddc3..1f6f225b8 100644 --- a/src/click/helper/click-internet-stack-helper.cc +++ b/src/click/helper/click-internet-stack-helper.cc @@ -70,7 +70,6 @@ ClickInternetStackHelper::ClickInternetStackHelper() void ClickInternetStackHelper::Initialize() { - SetTcp("ns3::TcpL4Protocol"); } ClickInternetStackHelper::~ClickInternetStackHelper() @@ -80,7 +79,6 @@ ClickInternetStackHelper::~ClickInternetStackHelper() ClickInternetStackHelper::ClickInternetStackHelper(const ClickInternetStackHelper& o) { m_ipv4Enabled = o.m_ipv4Enabled; - m_tcpFactory = o.m_tcpFactory; } ClickInternetStackHelper& @@ -100,19 +98,6 @@ ClickInternetStackHelper::Reset() Initialize(); } -void -ClickInternetStackHelper::SetTcp(const std::string tid) -{ - m_tcpFactory.SetTypeId(tid); -} - -void -ClickInternetStackHelper::SetTcp(std::string tid, std::string n0, const AttributeValue& v0) -{ - m_tcpFactory.SetTypeId(tid); - m_tcpFactory.Set(n0, v0); -} - void ClickInternetStackHelper::SetClickFile(NodeContainer c, std::string clickfile) { @@ -199,7 +184,7 @@ ClickInternetStackHelper::Install(Ptr node) const CreateAndAggregateObjectFromTypeId(node, "ns3::Ipv4L3ClickProtocol"); CreateAndAggregateObjectFromTypeId(node, "ns3::Icmpv4L4Protocol"); CreateAndAggregateObjectFromTypeId(node, "ns3::UdpL4Protocol"); - node->AggregateObject(m_tcpFactory.Create()); + CreateAndAggregateObjectFromTypeId(node, "ns3::TcpL4Protocol"); Ptr factory = CreateObject(); node->AggregateObject(factory); // Set routing @@ -488,7 +473,7 @@ ClickInternetStackHelper::EnableAsciiIpv4Internal(Ptr strea "Drop", MakeBoundCallback(&Ipv4L3ProtocolDropSinkWithoutContext, theStream)); NS_ASSERT_MSG(result == true, - "ClickInternetStackHelper::EanableAsciiIpv4Internal(): " + "ClickInternetStackHelper::EnableAsciiIpv4Internal(): " "Unable to connect ipv4L3Protocol \"Drop\""); } diff --git a/src/click/helper/click-internet-stack-helper.h b/src/click/helper/click-internet-stack-helper.h index f0f039782..fea68e954 100644 --- a/src/click/helper/click-internet-stack-helper.h +++ b/src/click/helper/click-internet-stack-helper.h @@ -101,34 +101,6 @@ class ClickInternetStackHelper : public PcapHelperForIpv4, public AsciiTraceHelp */ void InstallAll() const; - /** - * \brief set the Tcp stack which will not need any other parameter. - * - * This function sets up the tcp stack to the given TypeId. It should not be - * used for NSC stack setup because the nsc stack needs the Library attribute - * to be setup, please use instead the version that requires an attribute - * and a value. If you choose to use this function anyways to set nsc stack - * the default value for the linux library will be used: "liblinux2.6.26.so". - * - * \param tid the type id, typically it is set to "ns3::TcpL4Protocol" - */ - void SetTcp(std::string tid); - - /** - * \brief This function is used to setup the Network Simulation Cradle stack with library value. - * - * Give the NSC stack a shared library file name to use when creating the - * stack implementation. The attr string is actually the attribute name to - * be setup and val is its value. The attribute is the stack implementation - * to be used and the value is the shared library name. - * - * \param tid The type id, for the case of nsc it would be "ns3::NscTcpL4Protocol" - * \param attr The attribute name that must be setup, for example "Library" - * \param val The attribute value, which will be in fact the shared library name - * (example:"liblinux2.6.26.so") - */ - void SetTcp(std::string tid, std::string attr, const AttributeValue& val); - /** * \brief Set a Click file to be used for a group of nodes. * \param c NodeContainer of nodes @@ -200,7 +172,6 @@ class ClickInternetStackHelper : public PcapHelperForIpv4, public AsciiTraceHelp bool explicitFilename) override; void Initialize(); - ObjectFactory m_tcpFactory; static void CreateAndAggregateObjectFromTypeId(Ptr node, const std::string typeId); diff --git a/src/click/model/ipv4-click-routing.cc b/src/click/model/ipv4-click-routing.cc index 8480c4b04..e23714e05 100644 --- a/src/click/model/ipv4-click-routing.cc +++ b/src/click/model/ipv4-click-routing.cc @@ -227,14 +227,7 @@ Ipv4ClickRouting::GetInterfaceId(const char* ifname) bool Ipv4ClickRouting::IsInterfaceReady(int ifid) { - if (ifid >= 0 && ifid < (int)m_ipv4->GetNInterfaces()) - { - return true; - } - else - { - return false; - } + return ifid >= 0 && ifid < static_cast(m_ipv4->GetNInterfaces()); } std::string @@ -285,19 +278,21 @@ Ipv4ClickRouting::GetTimevalFromNow() const struct timeval curtime; uint64_t remainder = 0; - curtime.tv_sec = Simulator::Now().GetSeconds(); - curtime.tv_usec = Simulator::Now().GetMicroSeconds() % 1000000; + Time now = Simulator::Now(); - switch (Simulator::Now().GetResolution()) + curtime.tv_sec = now.GetSeconds(); + curtime.tv_usec = now.GetMicroSeconds() % 1000000; + + switch (Time::GetResolution()) { case Time::NS: - remainder = Simulator::Now().GetNanoSeconds() % 1000; + remainder = now.GetNanoSeconds() % 1000; break; case Time::PS: - remainder = Simulator::Now().GetPicoSeconds() % 1000000; + remainder = now.GetPicoSeconds() % 1000000; break; case Time::FS: - remainder = Simulator::Now().GetFemtoSeconds() % 1000000000; + remainder = now.GetFemtoSeconds() % 1000000000; break; default: break; @@ -563,10 +558,10 @@ bool Ipv4ClickRouting::RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) { NS_FATAL_ERROR("Click router does not have a RouteInput() interface!"); return false; diff --git a/src/click/model/ipv4-click-routing.h b/src/click/model/ipv4-click-routing.h index c77528261..aa1943e45 100644 --- a/src/click/model/ipv4-click-routing.h +++ b/src/click/model/ipv4-click-routing.h @@ -262,10 +262,10 @@ class Ipv4ClickRouting : public Ipv4RoutingProtocol bool RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override; + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override; void PrintRoutingTable(Ptr stream, Time::Unit unit = Time::S) const override; void NotifyInterfaceUp(uint32_t interface) override; diff --git a/src/click/model/ipv4-l3-click-protocol.cc b/src/click/model/ipv4-l3-click-protocol.cc index 60d4ca089..337b5e47a 100644 --- a/src/click/model/ipv4-l3-click-protocol.cc +++ b/src/click/model/ipv4-l3-click-protocol.cc @@ -229,11 +229,10 @@ Ipv4L3ClickProtocol::IsDestinationAddress(Ipv4Address address, uint32_t iif) con #ifdef NOTYET if (MulticastCheckGroup(iif, address)) #endif - if (true) - { - NS_LOG_LOGIC("For me (Ipv4Addr multicast address"); - return true; - } + { + NS_LOG_LOGIC("For me (Ipv4Addr multicast address"); + return true; + } } if (address.IsBroadcast()) @@ -470,7 +469,7 @@ Ipv4L3ClickProtocol::SourceAddressSelection(uint32_t interfaceIdx, Ipv4Address d Ipv4InterfaceAddress test = GetAddress(interfaceIdx, i); if (test.GetLocal().CombineMask(test.GetMask()) == dest.CombineMask(test.GetMask())) { - if (test.IsSecondary() == false) + if (!test.IsSecondary()) { return test.GetLocal(); } @@ -677,7 +676,7 @@ Ipv4L3ClickProtocol::BuildHeader(Ipv4Address source, ipHeader.SetProtocol(protocol); ipHeader.SetPayloadSize(payloadSize); ipHeader.SetTtl(ttl); - if (mayFragment == true) + if (mayFragment) { ipHeader.SetMayFragment(); ipHeader.SetIdentification(m_identification); @@ -786,7 +785,7 @@ Ipv4L3ClickProtocol::Receive(Ptr device, NS_LOG_LOGIC("Packet from " << from << " received on node " << m_node->GetId()); // Forward packet to raw sockets, if any - if (protocol == Ipv4L3ClickProtocol::PROT_NUMBER && m_sockets.size() > 0) + if (protocol == Ipv4L3ClickProtocol::PROT_NUMBER && !m_sockets.empty()) { Ptr packetForRawSocket = p->Copy(); int32_t interface = GetInterfaceForDevice(device); @@ -844,7 +843,7 @@ Ipv4L3ClickProtocol::LocalDeliver(Ptr packet, const Ipv4Header& ip // we need to make a copy in the unlikely event we hit the // RX_ENDPOINT_UNREACH codepath Ptr copy = p->Copy(); - enum IpL4Protocol::RxStatus status = protocol->Receive(p, ip, GetInterface(iif)); + IpL4Protocol::RxStatus status = protocol->Receive(p, ip, GetInterface(iif)); switch (status) { case IpL4Protocol::RX_OK: @@ -854,8 +853,7 @@ Ipv4L3ClickProtocol::LocalDeliver(Ptr packet, const Ipv4Header& ip case IpL4Protocol::RX_CSUM_FAILED: break; case IpL4Protocol::RX_ENDPOINT_UNREACH: - if (ip.GetDestination().IsBroadcast() == true || - ip.GetDestination().IsMulticast() == true) + if (ip.GetDestination().IsBroadcast() || ip.GetDestination().IsMulticast()) { break; // Do not reply to broadcast or multicast } @@ -871,7 +869,7 @@ Ipv4L3ClickProtocol::LocalDeliver(Ptr packet, const Ipv4Header& ip subnetDirected = true; } } - if (subnetDirected == false) + if (!subnetDirected) { GetIcmp()->SendDestUnreachPort(ip, copy); } diff --git a/src/click/test/examples-to-run.py b/src/click/test/examples-to-run.py index e5f2e74a4..342e58a9f 100644 --- a/src/click/test/examples-to-run.py +++ b/src/click/test/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains @@ -22,4 +21,6 @@ cpp_examples = [ # (example_name, do_run). # # See test.py for more information. -python_examples = [] +python_examples = [ + ("nsclick-simple-lan.py", "NSCLICK == True"), +] diff --git a/src/config-store/CMakeLists.txt b/src/config-store/CMakeLists.txt index 4a2931264..b62fba3e3 100644 --- a/src/config-store/CMakeLists.txt +++ b/src/config-store/CMakeLists.txt @@ -12,6 +12,13 @@ if(${GTK3_FOUND}) set(gtk_libraries ${GTK3_LIBRARIES} ) + if(${NS3_PIP_PACKAGING}) + # In case we are packaging ns-3, leave gtk symbols undefined and pray for + # the linker to find the correct libraries locally + set(gtk_libraries + -Wl,--allow-shlib-undefined + ) + endif() if(${GCC}) add_definitions(-Wno-parentheses) endif() diff --git a/src/config-store/model/attribute-default-iterator.cc b/src/config-store/model/attribute-default-iterator.cc index 27dde2826..d2b37c60c 100644 --- a/src/config-store/model/attribute-default-iterator.cc +++ b/src/config-store/model/attribute-default-iterator.cc @@ -45,7 +45,7 @@ AttributeDefaultIterator::Iterate() bool calledStart = false; for (uint32_t j = 0; j < tid.GetAttributeN(); j++) { - struct TypeId::AttributeInformation info = tid.GetAttribute(j); + TypeId::AttributeInformation info = tid.GetAttribute(j); if (!(info.flags & TypeId::ATTR_CONSTRUCT)) { // we can't construct the attribute, so, there is no diff --git a/src/config-store/model/attribute-iterator.cc b/src/config-store/model/attribute-iterator.cc index ea6d947f5..3165da3f5 100644 --- a/src/config-store/model/attribute-iterator.cc +++ b/src/config-store/model/attribute-iterator.cc @@ -226,7 +226,7 @@ AttributeIterator::DoIterate(Ptr object) NS_LOG_DEBUG("store " << tid.GetName()); for (uint32_t i = 0; i < tid.GetAttributeN(); ++i) { - struct TypeId::AttributeInformation info = tid.GetAttribute(i); + TypeId::AttributeInformation info = tid.GetAttribute(i); const PointerChecker* ptrChecker = dynamic_cast(PeekPointer(info.checker)); if (ptrChecker != nullptr) diff --git a/src/config-store/model/display-functions.cc b/src/config-store/model/display-functions.cc index bb61fb5a8..ac3ed0055 100644 --- a/src/config-store/model/display-functions.cc +++ b/src/config-store/model/display-functions.cc @@ -240,7 +240,7 @@ cell_tooltip_callback(GtkWidget* widget, } else { - struct TypeId::AttributeInformation info = tid.GetAttribute(attrIndex); + TypeId::AttributeInformation info = tid.GetAttribute(attrIndex); Ptr checker = info.checker; std::string tip; tip = "This attribute is of type " + checker->GetValueTypeName(); diff --git a/src/config-store/model/raw-text-config.cc b/src/config-store/model/raw-text-config.cc index 4c8d90ca6..188dd5ef7 100644 --- a/src/config-store/model/raw-text-config.cc +++ b/src/config-store/model/raw-text-config.cc @@ -93,7 +93,7 @@ RawTextConfigSave::Default() ns3::TypeId::SupportLevel supportLevel = TypeId::SupportLevel::SUPPORTED; for (std::size_t i = 0; i < tid.GetAttributeN(); i++) { - struct TypeId::AttributeInformation tmp = tid.GetAttribute(i); + TypeId::AttributeInformation tmp = tid.GetAttribute(i); if (tmp.name == name) { supportLevel = tmp.supportLevel; @@ -105,8 +105,7 @@ RawTextConfigSave::Default() NS_LOG_WARN("Global attribute " << m_typeId << "::" << name << " was not saved because it is OBSOLETE"); } - else if ((supportLevel == TypeId::SupportLevel::DEPRECATED) && - (m_saveDeprecated == false)) + else if (supportLevel == TypeId::SupportLevel::DEPRECATED && !m_saveDeprecated) { NS_LOG_WARN("Global attribute " << m_typeId << "::" << name << " was not saved because it is DEPRECATED"); @@ -169,7 +168,7 @@ RawTextConfigSave::Attributes() for (std::size_t i = 0; i < tid.GetAttributeN(); i++) { - struct TypeId::AttributeInformation tmp = tid.GetAttribute(i); + TypeId::AttributeInformation tmp = tid.GetAttribute(i); if (tmp.name == name) { supportLevel = tmp.supportLevel; @@ -181,8 +180,7 @@ RawTextConfigSave::Attributes() NS_LOG_WARN("Attribute " << GetCurrentPath() << " was not saved because it is OBSOLETE"); } - else if ((supportLevel == TypeId::SupportLevel::DEPRECATED) && - (m_saveDeprecated == false)) + else if (supportLevel == TypeId::SupportLevel::DEPRECATED && !m_saveDeprecated) { NS_LOG_WARN("Attribute " << GetCurrentPath() << " was not saved because it is DEPRECATED"); diff --git a/src/config-store/model/xml-config.cc b/src/config-store/model/xml-config.cc index 72a0510e3..6ea192f00 100644 --- a/src/config-store/model/xml-config.cc +++ b/src/config-store/model/xml-config.cc @@ -132,7 +132,7 @@ XmlConfigSave::Default() ns3::TypeId::SupportLevel supportLevel = TypeId::SupportLevel::SUPPORTED; for (std::size_t i = 0; i < tid.GetAttributeN(); i++) { - struct TypeId::AttributeInformation tmp = tid.GetAttribute(i); + TypeId::AttributeInformation tmp = tid.GetAttribute(i); if (tmp.name == name) { supportLevel = tmp.supportLevel; @@ -145,8 +145,7 @@ XmlConfigSave::Default() << " was not saved because it is OBSOLETE"); return; } - else if ((supportLevel == TypeId::SupportLevel::DEPRECATED) && - (m_saveDeprecated == false)) + else if (supportLevel == TypeId::SupportLevel::DEPRECATED && !m_saveDeprecated) { NS_LOG_WARN("Global attribute " << m_typeid << "::" << name << " was not saved because it is DEPRECATED"); @@ -212,7 +211,7 @@ XmlConfigSave::Attributes() ns3::TypeId::SupportLevel supportLevel = TypeId::SupportLevel::SUPPORTED; for (std::size_t i = 0; i < tid.GetAttributeN(); i++) { - struct TypeId::AttributeInformation tmp = tid.GetAttribute(i); + TypeId::AttributeInformation tmp = tid.GetAttribute(i); if (tmp.name == name) { supportLevel = tmp.supportLevel; @@ -225,8 +224,7 @@ XmlConfigSave::Attributes() << " was not saved because it is OBSOLETE"); return; } - else if ((supportLevel == TypeId::SupportLevel::DEPRECATED) && - (m_saveDeprecated == false)) + else if (supportLevel == TypeId::SupportLevel::DEPRECATED && !m_saveDeprecated) { NS_LOG_WARN("Attribute " << GetCurrentPath() << " was not saved because it is DEPRECATED"); diff --git a/src/config-store/test/examples-to-run.py b/src/config-store/test/examples-to-run.py index 80064ee8c..17d5c4812 100644 --- a/src/config-store/test/examples-to-run.py +++ b/src/config-store/test/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/src/core/examples/command-line-example.cc b/src/core/examples/command-line-example.cc index 7bb4e3fdc..7fb5b22b2 100644 --- a/src/core/examples/command-line-example.cc +++ b/src/core/examples/command-line-example.cc @@ -101,7 +101,7 @@ main(int argc, char* argv[]) const TypeId tid = TypeId::LookupByName(attrClass); std::string attrDef; { - struct TypeId::AttributeInformation info; + TypeId::AttributeInformation info; tid.LookupAttributeByName(attrName, &info); attrDef = info.originalInitialValue->SerializeToString(info.checker); } @@ -144,7 +144,7 @@ main(int argc, char* argv[]) // Look up new default value for attribute std::string antiArg; { - struct TypeId::AttributeInformation info; + TypeId::AttributeInformation info; tid.LookupAttributeByName(attrName, &info); antiArg = info.initialValue->SerializeToString(info.checker); } diff --git a/src/core/examples/log-example.cc b/src/core/examples/log-example.cc index f16c10ab9..62d4fdd14 100644 --- a/src/core/examples/log-example.cc +++ b/src/core/examples/log-example.cc @@ -51,9 +51,9 @@ FreeEvent() NS_LOG_ERROR("FreeEvent: error msg"); NS_LOG_WARN("FreeEvent: warning msg"); - NS_LOG_DEBUG("FreeEvent: debug msg"); NS_LOG_INFO("FreeEvent: info msg"); NS_LOG_LOGIC("FreeEvent: logic msg"); + NS_LOG_DEBUG("FreeEvent: debug msg"); } /** Simple object to aggregate to a node. @@ -93,9 +93,9 @@ class MyEventObject : public Object NS_LOG_ERROR("MyEventObject:Event: error msg"); NS_LOG_WARN("MyEventObject:Event: warning msg"); - NS_LOG_DEBUG("MyEventObject:Event: debug msg"); NS_LOG_INFO("MyEventObject:Event: info msg"); NS_LOG_LOGIC("MyEventObject:Event: logic msg"); + NS_LOG_DEBUG("MyEventObject:Event: debug msg"); } }; // MyEventObject @@ -110,26 +110,26 @@ main(int argc, char** argv) CommandLine cmd; cmd.Parse(argc, argv); - NS_LOG_UNCOND("Creating a Node"); + NS_LOG_DEBUG("Creating a Node"); auto node = CreateObject(); - NS_LOG_UNCOND("Creating MyEventObject"); + NS_LOG_DEBUG("Creating MyEventObject"); auto myObj = CreateObject(); - NS_LOG_UNCOND("Aggregating MyEventObject to Node"); + NS_LOG_DEBUG("Aggregating MyEventObject to Node"); node->AggregateObject(myObj); - NS_LOG_UNCOND("Scheduling the MyEventObject::Event with node context"); + NS_LOG_INFO("Scheduling the MyEventObject::Event with node context"); Simulator::ScheduleWithContext(node->GetId(), Seconds(3), &MyEventObject::Event, &(*myObj)); - NS_LOG_UNCOND("Scheduling FreeEvent"); + NS_LOG_INFO("Scheduling FreeEvent"); Simulator::Schedule(Seconds(5), FreeEvent); - NS_LOG_UNCOND("Starting run..."); + NS_LOG_DEBUG("Starting run..."); Simulator::Run(); - NS_LOG_UNCOND("... run complete"); + NS_LOG_DEBUG("... run complete"); Simulator::Destroy(); - NS_LOG_UNCOND("Goodbye"); + NS_LOG_DEBUG("Goodbye"); return 0; } diff --git a/src/core/examples/sample-log-time-format.cc b/src/core/examples/sample-log-time-format.cc index cf9d5ede2..f25ee58d7 100644 --- a/src/core/examples/sample-log-time-format.cc +++ b/src/core/examples/sample-log-time-format.cc @@ -89,6 +89,8 @@ #include "ns3/random-variable-stream.h" #include "ns3/simulator.h" +#include + using namespace ns3; namespace diff --git a/src/core/helper/csv-reader.cc b/src/core/helper/csv-reader.cc index abd4c4d73..0bb534294 100644 --- a/src/core/helper/csv-reader.cc +++ b/src/core/helper/csv-reader.cc @@ -180,7 +180,7 @@ CsvReader::GetValueAs(std::string input, signed char& value) const std::istringstream tempStream(input); - std::int16_t tempOutput = 0; + int16_t tempOutput = 0; tempStream >> tempOutput; if (tempOutput >= std::numeric_limits::min() && @@ -247,7 +247,7 @@ CsvReader::GetValueAs(std::string input, unsigned char& value) const std::istringstream tempStream(input); - std::uint16_t tempOutput = 0; + uint16_t tempOutput = 0; tempStream >> tempOutput; if (tempOutput >= std::numeric_limits::min() && diff --git a/src/core/helper/random-variable-stream-helper.h b/src/core/helper/random-variable-stream-helper.h index 51bb1a010..6b63dcf89 100644 --- a/src/core/helper/random-variable-stream-helper.h +++ b/src/core/helper/random-variable-stream-helper.h @@ -18,6 +18,7 @@ #ifndef RANDOM_VARIABLE_STREAM_HELPER_H #define RANDOM_VARIABLE_STREAM_HELPER_H +#include #include /** diff --git a/src/core/model/attribute-accessor-helper.h b/src/core/model/attribute-accessor-helper.h index 1beccfbc5..e9f1e9f1c 100644 --- a/src/core/model/attribute-accessor-helper.h +++ b/src/core/model/attribute-accessor-helper.h @@ -247,7 +247,7 @@ template inline Ptr DoMakeAccessorHelperOne(U T::*memberVariable) { - /* AttributeAcessor implementation for a class member variable. */ + /* AttributeAccessor implementation for a class member variable. */ class MemberVariable : public AccessorHelper { public: diff --git a/src/core/model/attribute-construction-list.cc b/src/core/model/attribute-construction-list.cc index 92c759b6a..657db4507 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 (std::list::iterator k = m_list.begin(); k != m_list.end(); k++) { if (k->checker == checker) { diff --git a/src/core/model/attribute-construction-list.h b/src/core/model/attribute-construction-list.h index 43debec8c..d76efafed 100644 --- a/src/core/model/attribute-construction-list.h +++ b/src/core/model/attribute-construction-list.h @@ -50,8 +50,9 @@ class AttributeConstructionList /** The name of the Attribute. */ std::string name; }; + /** Iterator type. */ - typedef std::list::const_iterator CIterator; + typedef std::list::const_iterator CIterator; /** Constructor */ AttributeConstructionList(); @@ -81,7 +82,7 @@ class AttributeConstructionList private: /** The list of Items */ - std::list m_list; + std::list m_list; }; } // namespace ns3 diff --git a/src/core/model/attribute-container.h b/src/core/model/attribute-container.h index 88bc31ebc..974abfd6c 100644 --- a/src/core/model/attribute-container.h +++ b/src/core/model/attribute-container.h @@ -45,9 +45,10 @@ class AttributeChecker; * can return the items in a container specified by \p C. * * @tparam A AttributeValue type to be contained. + * @tparam Sep Character separator between elements for parsing. * @tparam C Possibly templated container class returned by Get. */ -template class C = std::list> +template class C = std::list> class AttributeContainerValue : public AttributeValue { public: @@ -74,9 +75,8 @@ class AttributeContainerValue : public AttributeValue /** * Default constructor. - * \param[in] sep Character separator between elements for parsing. */ - AttributeContainerValue(char sep = ','); + AttributeContainerValue(); /** * Construct from another container. @@ -186,9 +186,8 @@ class AttributeContainerValue : public AttributeValue * \return This object with items copied. */ template - Ptr> CopyFrom(const ITER begin, const ITER end); + Ptr> CopyFrom(const ITER begin, const ITER end); - char m_sep; //!< Item separator container_type m_container; //!< Internal container }; @@ -210,35 +209,40 @@ class AttributeContainerChecker : public AttributeChecker /** * Make AttributeContainerChecker from AttributeContainerValue. * @tparam A \deduced AttributeValue type in container. + * @tparam Sep \deduced Character separator between elements for parsing. * @tparam C \deduced Container type returned by Get. * \param[in] value AttributeContainerValue from which to deduce types. * \return AttributeContainerChecker for value. */ -template class C> -Ptr MakeAttributeContainerChecker(const AttributeContainerValue& value); +template class C> +Ptr MakeAttributeContainerChecker( + const AttributeContainerValue& value); /** * Make AttributeContainerChecker using explicit types, initialize item checker. * @tparam A AttributeValue type in container. + * @tparam Sep Character separator between elements for parsing. * @tparam C Container type returned by Get. * \param[in] itemchecker AttributeChecker used for each item in the container. * \return AttributeContainerChecker. */ -template class C = std::list> +template class C = std::list> Ptr MakeAttributeContainerChecker(Ptr itemchecker); /** * Make uninitialized AttributeContainerChecker using explicit types. * @tparam A AttributeValue type in container. + * @tparam Sep Character separator between elements for parsing. * @tparam C Container type returned by Get. * \return AttributeContainerChecker. */ -template class C = std::list> +template class C = std::list> Ptr MakeAttributeContainerChecker(); /** * Make AttributeContainerAccessor using explicit types. * @tparam A AttributeValue type in container. + * @tparam Sep Character separator between elements for parsing. * @tparam C Container type returned by Get. * \tparam T1 \deduced The type of the class data member, * or the type of the class get functor or set method. @@ -246,12 +250,13 @@ Ptr MakeAttributeContainerChecker(); * or the get or set method. * \return AttributeContainerAccessor. */ -template class C = std::list, typename T1> +template class C = std::list, typename T1> Ptr MakeAttributeContainerAccessor(T1 a1); /** * Make AttributeContainerAccessor using explicit types. * @tparam A AttributeValue type in container. + * @tparam Sep Character separator between elements for parsing. * @tparam C Container type returned by Get. * \tparam T1 \deduced The type of the class data member, * or the type of the class get functor or set method. @@ -262,7 +267,11 @@ Ptr MakeAttributeContainerAccessor(T1 a1); * or the get or set method. * \return AttributeContainerAccessor. */ -template class C = std::list, typename T1, typename T2> +template class C = std::list, + typename T1, + typename T2> Ptr MakeAttributeContainerAccessor(T1 a1, T2 a2); } // namespace ns3 @@ -283,7 +292,7 @@ namespace internal * in MakeAttributeContainerChecker. The non-templated base ns3::AttributeContainerChecker * is returned from that function. This is the same pattern as ObjectPtrContainer. */ -template class C> +template class C> class AttributeContainerChecker : public ns3::AttributeContainerChecker { public: @@ -300,58 +309,59 @@ class AttributeContainerChecker : public ns3::AttributeContainerChecker Ptr m_itemchecker; //!< The AttributeChecker }; -template class C> -AttributeContainerChecker::AttributeContainerChecker() +template class C> +AttributeContainerChecker::AttributeContainerChecker() : m_itemchecker(nullptr) { } -template class C> -AttributeContainerChecker::AttributeContainerChecker(Ptr itemchecker) +template class C> +AttributeContainerChecker::AttributeContainerChecker( + Ptr itemchecker) : m_itemchecker(itemchecker) { } -template class C> +template class C> void -AttributeContainerChecker::SetItemChecker(Ptr itemchecker) +AttributeContainerChecker::SetItemChecker(Ptr itemchecker) { m_itemchecker = itemchecker; } -template class C> +template class C> Ptr -AttributeContainerChecker::GetItemChecker() const +AttributeContainerChecker::GetItemChecker() const { return m_itemchecker; } } // namespace internal -template class C> +template class C> Ptr -MakeAttributeContainerChecker(const AttributeContainerValue& value) +MakeAttributeContainerChecker(const AttributeContainerValue& value) { - return MakeAttributeContainerChecker(); + return MakeAttributeContainerChecker(); } -template class C> +template class C> Ptr MakeAttributeContainerChecker(Ptr itemchecker) { - auto checker = MakeAttributeContainerChecker(); + auto checker = MakeAttributeContainerChecker(); auto acchecker = DynamicCast(checker); acchecker->SetItemChecker(itemchecker); return checker; } -template class C> +template class C> Ptr MakeAttributeContainerChecker() { std::string containerType; std::string underlyingType; - typedef AttributeContainerValue T; + typedef AttributeContainerValue T; { std::ostringstream oss; oss << "ns3::AttributeContainerValue<" << typeid(typename T::attribute_type).name() << ", " @@ -365,51 +375,50 @@ MakeAttributeContainerChecker() underlyingType = oss.str(); } - return MakeSimpleAttributeChecker>(containerType, - underlyingType); + return MakeSimpleAttributeChecker>( + containerType, + underlyingType); } -template class C> -AttributeContainerValue::AttributeContainerValue(char sep) - : m_sep(sep) +template class C> +AttributeContainerValue::AttributeContainerValue() { } -template class C> +template class C> template -AttributeContainerValue::AttributeContainerValue(const CONTAINER& c) - : AttributeContainerValue(c.begin(), c.end()) +AttributeContainerValue::AttributeContainerValue(const CONTAINER& c) + : AttributeContainerValue(c.begin(), c.end()) { } -template class C> +template class C> template -AttributeContainerValue::AttributeContainerValue(const ITER begin, const ITER end) +AttributeContainerValue::AttributeContainerValue(const ITER begin, const ITER end) : AttributeContainerValue() { CopyFrom(begin, end); } -template class C> -AttributeContainerValue::~AttributeContainerValue() +template class C> +AttributeContainerValue::~AttributeContainerValue() { m_container.clear(); } -template class C> +template class C> Ptr -AttributeContainerValue::Copy() const +AttributeContainerValue::Copy() const { - auto c = Create>(); - c->m_sep = m_sep; + auto c = Create>(); c->m_container = m_container; return c; } -template class C> +template class C> bool -AttributeContainerValue::DeserializeFromString(std::string value, - Ptr checker) +AttributeContainerValue::DeserializeFromString(std::string value, + Ptr checker) { auto acchecker = DynamicCast(checker); if (!acchecker) @@ -418,7 +427,7 @@ AttributeContainerValue::DeserializeFromString(std::string value, } std::istringstream iss(value); // copies value - while (std::getline(iss, value, m_sep)) + while (std::getline(iss, value, Sep)) { auto avalue = acchecker->GetItemChecker()->CreateValidValue(StringValue(value)); if (!avalue) @@ -438,9 +447,9 @@ AttributeContainerValue::DeserializeFromString(std::string value, return true; } -template class C> +template class C> std::string -AttributeContainerValue::SerializeToString(Ptr checker) const +AttributeContainerValue::SerializeToString(Ptr checker) const { std::ostringstream oss; bool first = true; @@ -448,7 +457,7 @@ AttributeContainerValue::SerializeToString(Ptr che { if (!first) { - oss << m_sep; + oss << Sep; } oss << attr->SerializeToString(checker); first = false; @@ -456,9 +465,9 @@ AttributeContainerValue::SerializeToString(Ptr che return oss.str(); } -template class C> -typename AttributeContainerValue::result_type -AttributeContainerValue::Get() const +template class C> +typename AttributeContainerValue::result_type +AttributeContainerValue::Get() const { result_type c; for (const value_type& a : *this) @@ -468,10 +477,10 @@ AttributeContainerValue::Get() const return c; } -template class C> +template class C> template bool -AttributeContainerValue::GetAccessor(T& value) const +AttributeContainerValue::GetAccessor(T& value) const { result_type src = Get(); value.clear(); @@ -479,75 +488,75 @@ AttributeContainerValue::GetAccessor(T& value) const return true; } -template class C> +template class C> template void -AttributeContainerValue::Set(const T& c) +AttributeContainerValue::Set(const T& c) { m_container.clear(); CopyFrom(c.begin(), c.end()); } -template class C> -typename AttributeContainerValue::size_type -AttributeContainerValue::GetN() const +template class C> +typename AttributeContainerValue::size_type +AttributeContainerValue::GetN() const { return size(); } -template class C> -typename AttributeContainerValue::Iterator -AttributeContainerValue::Begin() +template class C> +typename AttributeContainerValue::Iterator +AttributeContainerValue::Begin() { return begin(); } -template class C> -typename AttributeContainerValue::Iterator -AttributeContainerValue::End() +template class C> +typename AttributeContainerValue::Iterator +AttributeContainerValue::End() { return end(); } -template class C> -typename AttributeContainerValue::size_type -AttributeContainerValue::size() const +template class C> +typename AttributeContainerValue::size_type +AttributeContainerValue::size() const { return m_container.size(); } -template class C> -typename AttributeContainerValue::iterator -AttributeContainerValue::begin() +template class C> +typename AttributeContainerValue::iterator +AttributeContainerValue::begin() { return m_container.begin(); } -template class C> -typename AttributeContainerValue::iterator -AttributeContainerValue::end() +template class C> +typename AttributeContainerValue::iterator +AttributeContainerValue::end() { return m_container.end(); } -template class C> -typename AttributeContainerValue::const_iterator -AttributeContainerValue::begin() const +template class C> +typename AttributeContainerValue::const_iterator +AttributeContainerValue::begin() const { return m_container.cbegin(); } -template class C> -typename AttributeContainerValue::const_iterator -AttributeContainerValue::end() const +template class C> +typename AttributeContainerValue::const_iterator +AttributeContainerValue::end() const { return m_container.cend(); } -template class C> +template class C> template -Ptr> -AttributeContainerValue::CopyFrom(const ITER begin, const ITER end) +Ptr> +AttributeContainerValue::CopyFrom(const ITER begin, const ITER end) { for (ITER iter = begin; iter != end; ++iter) { @@ -556,18 +565,18 @@ AttributeContainerValue::CopyFrom(const ITER begin, const ITER end) return this; } -template class C, typename T1> +template class C, typename T1> Ptr MakeAttributeContainerAccessor(T1 a1) { - return MakeAccessorHelper>(a1); + return MakeAccessorHelper>(a1); } -template class C, typename T1, typename T2> +template class C, typename T1, typename T2> Ptr MakeAttributeContainerAccessor(T1 a1, T2 a2) { - return MakeAccessorHelper>(a1, a2); + return MakeAccessorHelper>(a1, a2); } } // namespace ns3 diff --git a/src/core/model/callback.h b/src/core/model/callback.h index 989ee19c3..67655506e 100644 --- a/src/core/model/callback.h +++ b/src/core/model/callback.h @@ -184,12 +184,7 @@ class CallbackComponent : public CallbackComponentBase auto p = std::dynamic_pointer_cast>(other); // other must have the same type and value as ours - if (p == nullptr || p->m_comp != m_comp) - { - return false; - } - - return true; + return !(p == nullptr || p->m_comp != m_comp); } private: diff --git a/src/core/model/command-line.cc b/src/core/model/command-line.cc index 3423bb08e..cd8d6807f 100644 --- a/src/core/model/command-line.cc +++ b/src/core/model/command-line.cc @@ -572,7 +572,7 @@ CommandLine::PrintAttributeList(std::ostream& os, const TypeId tid, std::strings { std::stringstream ss; ss << " --" << tid.GetAttributeFullName(i) << "=["; - struct TypeId::AttributeInformation info = tid.GetAttribute(i); + TypeId::AttributeInformation info = tid.GetAttribute(i); ss << info.initialValue->SerializeToString(info.checker) << "]\n" << " " << info.help << "\n"; attributes.push_back(ss.str()); @@ -790,7 +790,7 @@ CommandLine::AddValue(const std::string& name, const std::string& attributePath) } const std::string attrName = attributePath.substr(colon + 2); - struct TypeId::AttributeInformation info; + TypeId::AttributeInformation info; if (!tid.LookupAttributeByName(attrName, &info)) { NS_FATAL_ERROR("Attribute not found: " << attributePath); diff --git a/src/core/model/config.cc b/src/core/model/config.cc index 566984ad5..f6cf3c741 100644 --- a/src/core/model/config.cc +++ b/src/core/model/config.cc @@ -542,7 +542,7 @@ Resolver::DoResolve(std::string path, Ptr root) for (uint32_t i = 0; i < tid.GetAttributeN(); i++) { - struct TypeId::AttributeInformation info; + TypeId::AttributeInformation info; info = tid.GetAttribute(i); if (info.name != item && item != "*") { @@ -638,7 +638,7 @@ class ConfigImpl : public Singleton { public: // Keep Set and SetFailSafe since their errors are triggered - // by the underlying ObjecBase functions. + // by the underlying ObjectBase functions. /** \copydoc ns3::Config::Set() */ void Set(std::string path, const AttributeValue& value); /** \copydoc ns3::Config::SetFailSafe() */ @@ -862,7 +862,7 @@ Reset() TypeId tid = TypeId::GetRegistered(i); for (uint32_t j = 0; j < tid.GetAttributeN(); j++) { - struct TypeId::AttributeInformation info = tid.GetAttribute(j); + TypeId::AttributeInformation info = tid.GetAttribute(j); tid.SetAttributeInitialValue(j, info.originalInitialValue); } } @@ -914,11 +914,11 @@ SetDefaultFailSafe(std::string fullName, const AttributeValue& value) { return false; } - struct TypeId::AttributeInformation info; + TypeId::AttributeInformation info; tid.LookupAttributeByName(paramName, &info); for (uint32_t j = 0; j < tid.GetAttributeN(); j++) { - struct TypeId::AttributeInformation tmp = tid.GetAttribute(j); + TypeId::AttributeInformation tmp = tid.GetAttribute(j); if (tmp.name == paramName) { Ptr v = tmp.checker->CreateValidValue(value); diff --git a/src/core/model/default-simulator-impl.cc b/src/core/model/default-simulator-impl.cc index 7014c3373..b269a3ff1 100644 --- a/src/core/model/default-simulator-impl.cc +++ b/src/core/model/default-simulator-impl.cc @@ -375,16 +375,9 @@ DefaultSimulatorImpl::IsExpired(const EventId& id) const } return true; } - if (id.PeekEventImpl() == nullptr || id.GetTs() < m_currentTs || - (id.GetTs() == m_currentTs && id.GetUid() <= m_currentUid) || - id.PeekEventImpl()->IsCancelled()) - { - return true; - } - else - { - return false; - } + return id.PeekEventImpl() == nullptr || id.GetTs() < m_currentTs || + (id.GetTs() == m_currentTs && id.GetUid() <= m_currentUid) || + id.PeekEventImpl()->IsCancelled(); } Time diff --git a/src/core/model/default-simulator-impl.h b/src/core/model/default-simulator-impl.h index 93fa6bc7c..e7edcc542 100644 --- a/src/core/model/default-simulator-impl.h +++ b/src/core/model/default-simulator-impl.h @@ -96,8 +96,9 @@ class DefaultSimulatorImpl : public SimulatorImpl /** The event implementation. */ EventImpl* event; }; + /** Container type for the events from a different context. */ - typedef std::list EventsWithContext; + typedef std::list EventsWithContext; /** The container of events from a different context. */ EventsWithContext m_eventsWithContext; /** diff --git a/src/core/model/deprecated.h b/src/core/model/deprecated.h index 701c59265..7401151ef 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_39 + * Tag for things deprecated in version ns-3.39. + */ +#define NS_DEPRECATED_3_39(msg) NS_DEPRECATED(msg) + /** * \ingroup core * \def NS_DEPRECATED_3_38 diff --git a/src/core/model/hash-fnv.h b/src/core/model/hash-fnv.h index 21e9aa6bc..71f4966a9 100644 --- a/src/core/model/hash-fnv.h +++ b/src/core/model/hash-fnv.h @@ -98,10 +98,7 @@ class Fnv1a : public Implementation /** * Seed value */ - enum Seed - { - SEED = 0x8BADF00D /**< Ate bad food */ - }; + static constexpr auto SEED{0x8BADF00D}; // Ate bad food /** Cache last hash value, for incremental hashing. */ /**@{*/ diff --git a/src/core/model/hash-murmur3.h b/src/core/model/hash-murmur3.h index 5ba8fee3e..700bae866 100644 --- a/src/core/model/hash-murmur3.h +++ b/src/core/model/hash-murmur3.h @@ -101,10 +101,7 @@ class Murmur3 : public Implementation * This has to be a constant for all MPI ranks to generate * the same hash from the same string. */ - enum Seed - { - SEED = 0x8BADF00D // Ate bad food - }; + static constexpr auto SEED{0x8BADF00D}; // Ate bad food /** * Cache last hash value, and total bytes hashed (needed to finalize), diff --git a/src/core/model/log.cc b/src/core/model/log.cc index 8a0ba2925..e2f0507b3 100644 --- a/src/core/model/log.cc +++ b/src/core/model/log.cc @@ -168,15 +168,12 @@ LogComponent::LogComponent(const std::string& name, EnvVarCheck(); LogComponent::ComponentList* components = GetComponentList(); - for (LogComponent::ComponentList::const_iterator i = components->begin(); - i != components->end(); - i++) + + if (components->find(name) != components->end()) { - if (i->first == name) - { - NS_FATAL_ERROR("Log component \"" << name << "\" has already been registered once."); - } + NS_FATAL_ERROR("Log component \"" << name << "\" has already been registered once."); } + components->insert(std::make_pair(name, this)); } @@ -305,24 +302,18 @@ void LogComponentEnable(const std::string& name, LogLevel level) { LogComponent::ComponentList* components = LogComponent::GetComponentList(); - LogComponent::ComponentList::const_iterator i; - for (i = components->begin(); i != components->end(); i++) + auto logComponent = components->find(name); + + if (logComponent == components->end()) { - if (i->first == name) - { - i->second->Enable(level); - return; - } - } - if (i == components->end()) - { - // nothing matched NS_LOG_UNCOND("Logging component \"" << name << "\" not found."); LogComponentPrintList(); NS_FATAL_ERROR("Logging component \"" << name << "\" not found." << " See above for a list of available log components"); } + + logComponent->second->Enable(level); } void @@ -341,15 +332,11 @@ void LogComponentDisable(const std::string& name, LogLevel level) { LogComponent::ComponentList* components = LogComponent::GetComponentList(); - for (LogComponent::ComponentList::const_iterator i = components->begin(); - i != components->end(); - i++) + auto logComponent = components->find(name); + + if (logComponent != components->end()) { - if (i->first == name) - { - i->second->Disable(level); - break; - } + logComponent->second->Disable(level); } } @@ -368,67 +355,73 @@ LogComponentDisableAll(LogLevel level) void LogComponentPrintList() { - LogComponent::ComponentList* components = LogComponent::GetComponentList(); - for (LogComponent::ComponentList::const_iterator i = components->begin(); - i != components->end(); - i++) + // Create sorted map of components by inserting them into a map + std::map componentsSorted; + + for (const auto& component : *LogComponent::GetComponentList()) { - std::cout << i->first << "="; - if (i->second->IsNoneEnabled()) + componentsSorted.insert(component); + } + + // Iterate through sorted components + for (const auto& [name, component] : componentsSorted) + { + std::cout << name << "="; + if (component->IsNoneEnabled()) { std::cout << "0" << std::endl; continue; } - if (i->second->IsEnabled(LOG_LEVEL_ALL)) + if (component->IsEnabled(LOG_LEVEL_ALL)) { std::cout << "all"; } else { - if (i->second->IsEnabled(LOG_ERROR)) + if (component->IsEnabled(LOG_ERROR)) { std::cout << "error"; } - if (i->second->IsEnabled(LOG_WARN)) + if (component->IsEnabled(LOG_WARN)) { std::cout << "|warn"; } - if (i->second->IsEnabled(LOG_DEBUG)) + if (component->IsEnabled(LOG_DEBUG)) { std::cout << "|debug"; } - if (i->second->IsEnabled(LOG_INFO)) + if (component->IsEnabled(LOG_INFO)) { std::cout << "|info"; } - if (i->second->IsEnabled(LOG_FUNCTION)) + if (component->IsEnabled(LOG_FUNCTION)) { std::cout << "|function"; } - if (i->second->IsEnabled(LOG_LOGIC)) + if (component->IsEnabled(LOG_LOGIC)) { std::cout << "|logic"; } } - if (i->second->IsEnabled(LOG_PREFIX_ALL)) + if (component->IsEnabled(LOG_PREFIX_ALL)) { std::cout << "|prefix_all"; } else { - if (i->second->IsEnabled(LOG_PREFIX_FUNC)) + if (component->IsEnabled(LOG_PREFIX_FUNC)) { std::cout << "|func"; } - if (i->second->IsEnabled(LOG_PREFIX_TIME)) + if (component->IsEnabled(LOG_PREFIX_TIME)) { std::cout << "|time"; } - if (i->second->IsEnabled(LOG_PREFIX_NODE)) + if (component->IsEnabled(LOG_PREFIX_NODE)) { std::cout << "|node"; } - if (i->second->IsEnabled(LOG_PREFIX_LEVEL)) + if (component->IsEnabled(LOG_PREFIX_LEVEL)) { std::cout << "|level"; } @@ -449,17 +442,8 @@ static bool ComponentExists(std::string componentName) { LogComponent::ComponentList* components = LogComponent::GetComponentList(); - LogComponent::ComponentList::const_iterator i; - for (i = components->begin(); i != components->end(); i++) - { - if (i->first == componentName) - { - return true; - } - } - NS_ASSERT(i == components->end()); - // nothing matched - return false; + + return components->find(componentName) != components->end(); } /** diff --git a/src/core/model/log.h b/src/core/model/log.h index b4512f235..551c0043c 100644 --- a/src/core/model/log.h +++ b/src/core/model/log.h @@ -26,10 +26,10 @@ #include "time-printer.h" #include -#include #include #include #include +#include #include /** @@ -100,17 +100,17 @@ enum LogLevel LOG_WARN = 0x00000002, //!< Warning messages. LOG_LEVEL_WARN = 0x00000003, //!< LOG_WARN and above. - LOG_DEBUG = 0x00000004, //!< Rare ad-hoc debug messages. - LOG_LEVEL_DEBUG = 0x00000007, //!< LOG_DEBUG and above. + LOG_INFO = 0x00000004, //!< Something happened to change state. + LOG_LEVEL_INFO = 0x00000007, //!< LOG_INFO and above. - LOG_INFO = 0x00000008, //!< Informational messages (e.g., banners). - LOG_LEVEL_INFO = 0x0000000f, //!< LOG_INFO and above. + LOG_FUNCTION = 0x00000008, //!< Function tracing for non-trivial function calls. + LOG_LEVEL_FUNCTION = 0x0000000f, //!< LOG_FUNCTION and above. - LOG_FUNCTION = 0x00000010, //!< Function tracing. - LOG_LEVEL_FUNCTION = 0x0000001f, //!< LOG_FUNCTION and above. + LOG_LOGIC = 0x00000010, //!< Debugging logs for key branches and decisions in a function. + LOG_LEVEL_LOGIC = 0x0000001f, //!< LOG_LOGIC and above. - LOG_LOGIC = 0x00000020, //!< Control flow tracing within functions. - LOG_LEVEL_LOGIC = 0x0000003f, //!< LOG_LOGIC and above. + LOG_DEBUG = 0x00000020, //!< Full voluminous logging to support debugging. + LOG_LEVEL_DEBUG = 0x0000003f, //!< LOG_DEBUG and above. LOG_ALL = 0x0fffffff, //!< Print everything. LOG_LEVEL_ALL = LOG_ALL, //!< Print everything. @@ -395,7 +395,7 @@ class LogComponent * It is exposed here to allow print-introspected-doxygen.cc * to generate a list of all LogComponents. */ - typedef std::map ComponentList; + using ComponentList = std::unordered_map; /** * Get the list of LogComponents. diff --git a/src/core/model/matrix-array.cc b/src/core/model/matrix-array.cc index affa42e6a..72ec3f99a 100644 --- a/src/core/model/matrix-array.cc +++ b/src/core/model/matrix-array.cc @@ -34,7 +34,7 @@ using ConstEigenMatrix = Eigen::Map -MatrixArray::MatrixArray(uint16_t numRows, uint16_t numCols, uint16_t numPages) +MatrixArray::MatrixArray(size_t numRows, size_t numCols, size_t numPages) : ValArray(numRows, numCols, numPages) { } @@ -58,30 +58,30 @@ MatrixArray::MatrixArray(const std::vector& values) } template -MatrixArray::MatrixArray(uint16_t numRows, uint16_t numCols, const std::valarray& values) +MatrixArray::MatrixArray(size_t numRows, size_t numCols, const std::valarray& values) : ValArray(numRows, numCols, values) { } template -MatrixArray::MatrixArray(uint16_t numRows, uint16_t numCols, std::valarray&& values) +MatrixArray::MatrixArray(size_t numRows, size_t numCols, std::valarray&& values) : ValArray(numRows, numCols, std::move(values)) { } template -MatrixArray::MatrixArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, +MatrixArray::MatrixArray(size_t numRows, + size_t numCols, + size_t numPages, const std::valarray& values) : ValArray(numRows, numCols, numPages, values) { } template -MatrixArray::MatrixArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, +MatrixArray::MatrixArray(size_t numRows, + size_t numCols, + size_t numPages, std::valarray&& values) : ValArray(numRows, numCols, numPages, std::move(values)) { @@ -96,7 +96,7 @@ MatrixArray::operator*(const MatrixArray& rhs) const MatrixArray res{m_numRows, rhs.m_numCols, m_numPages}; - for (uint16_t page = 0; page < res.m_numPages; ++page) + for (size_t page = 0; page < res.m_numPages; ++page) { #ifdef HAVE_EIGEN3 // Eigen found and enabled Eigen optimizations @@ -108,14 +108,16 @@ MatrixArray::operator*(const MatrixArray& rhs) const #else // Eigen not found or Eigen optimizations not enabled size_t matrixOffset = page * m_numRows * m_numCols; - for (uint16_t i = 0; i < res.m_numRows; ++i) + size_t rhsMatrixOffset = page * rhs.m_numRows * rhs.m_numCols; + for (size_t i = 0; i < res.m_numRows; ++i) { - for (uint16_t j = 0; j < res.m_numCols; ++j) + for (size_t j = 0; j < res.m_numCols; ++j) { - res(i, j, page) = - (m_values[std::slice(matrixOffset + i, m_numCols, m_numRows)] * - rhs.m_values[std::slice(matrixOffset + j * rhs.m_numRows, rhs.m_numRows, 1)]) - .sum(); + res(i, j, page) = (m_values[std::slice(matrixOffset + i, m_numCols, m_numRows)] * + rhs.m_values[std::slice(rhsMatrixOffset + j * rhs.m_numRows, + rhs.m_numRows, + 1)]) + .sum(); } } @@ -132,7 +134,7 @@ MatrixArray::Transpose() const // m_numPages = this.m_numPages MatrixArray res{m_numCols, m_numRows, m_numPages}; - for (uint16_t page = 0; page < m_numPages; ++page) + for (size_t page = 0; page < m_numPages; ++page) { #ifdef HAVE_EIGEN3 // Eigen found and Eigen optimizations enabled @@ -143,7 +145,7 @@ MatrixArray::Transpose() const #else // Eigen not found or Eigen optimizations not enabled size_t matrixIndex = page * m_numRows * m_numCols; - for (uint16_t i = 0; i < m_numRows; ++i) + for (size_t i = 0; i < m_numRows; ++i) { res.m_values[std::slice(matrixIndex + i * res.m_numRows, res.m_numRows, 1)] = m_values[std::slice(matrixIndex + i, m_numCols, m_numRows)]; @@ -174,7 +176,7 @@ MatrixArray::MultiplyByLeftAndRightMatrix(const MatrixArray& lMatrix, ConstEigenMatrix rMatrixEigen(rMatrix.GetPagePtr(0), rMatrix.m_numRows, rMatrix.m_numCols); #endif - for (uint16_t page = 0; page < m_numPages; ++page) + for (size_t page = 0; page < m_numPages; ++page) { #ifdef HAVE_EIGEN3 // Eigen found and Eigen optimizations enabled @@ -186,14 +188,14 @@ MatrixArray::MultiplyByLeftAndRightMatrix(const MatrixArray& lMatrix, #else // Eigen not found or Eigen optimizations not enabled size_t matrixOffset = page * m_numRows * m_numCols; - for (uint16_t resRow = 0; resRow < res.m_numRows; ++resRow) + for (size_t resRow = 0; resRow < res.m_numRows; ++resRow) { - for (uint16_t resCol = 0; resCol < res.m_numCols; ++resCol) + for (size_t resCol = 0; resCol < res.m_numCols; ++resCol) { // create intermediate row result, a multiply of resRow row of lMatrix and each // column of this matrix std::valarray interRes(m_numCols); - for (uint16_t thisCol = 0; thisCol < m_numCols; ++thisCol) + for (size_t thisCol = 0; thisCol < m_numCols; ++thisCol) { interRes[thisCol] = (lMatrix @@ -222,7 +224,7 @@ MatrixArray::HermitianTranspose() const for (size_t index = 0; index < this->GetSize(); ++index) { - retMatrix[index] = std::conj(m_values[index]); + retMatrix.m_values[index] = std::conj(retMatrix.m_values[index]); } return retMatrix; } diff --git a/src/core/model/matrix-array.h b/src/core/model/matrix-array.h index 7bfab6b2c..c2dca2456 100644 --- a/src/core/model/matrix-array.h +++ b/src/core/model/matrix-array.h @@ -92,7 +92,7 @@ class MatrixArray : public ValArray * \param numCols the number of columns * \param numPages the number of pages */ - MatrixArray(uint16_t numRows, uint16_t numCols = 1, uint16_t numPages = 1); + MatrixArray(size_t numRows, size_t numCols = 1, size_t numPages = 1); /** * \brief Constructor creates a single array of values.size () elements and 1 column, * and uses std::valarray values to initialize the elements. @@ -118,7 +118,7 @@ class MatrixArray : public ValArray * \param numCols the number of columns * \param values std::valarray that will be used to initialize elements of 3D array */ - MatrixArray(uint16_t numRows, uint16_t numCols, const std::valarray& values); + MatrixArray(size_t numRows, size_t numCols, const std::valarray& values); /** * \brief Constructor creates a single matrix of numRows and numCols, and moves * std::valarray values to initialize the elements. @@ -126,7 +126,7 @@ class MatrixArray : public ValArray * \param numCols the number of columns * \param values std::valarray that will be moved to initialize elements of 3D array */ - MatrixArray(uint16_t numRows, uint16_t numCols, std::valarray&& values); + MatrixArray(size_t numRows, size_t numCols, std::valarray&& values); /** * \brief Constructor creates the array of numPages matrices of numRows x numCols dimensions, * and uses std::valarray values to initialize all the elements. @@ -135,10 +135,7 @@ class MatrixArray : public ValArray * \param numPages the number of pages * \param values std::valarray that will be used to initialize elements of 3D array */ - MatrixArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, - const std::valarray& values); + MatrixArray(size_t numRows, size_t numCols, size_t numPages, const std::valarray& values); /** * \brief Constructor creates the array of numPages matrices of numRows x numCols dimensions, * and moves std::valarray values to initialize all the elements. @@ -147,10 +144,7 @@ class MatrixArray : public ValArray * \param numPages the number of pages * \param values std::valarray that will be used to initialize elements of 3D array */ - MatrixArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, - std::valarray&& values); + MatrixArray(size_t numRows, size_t numCols, size_t numPages, std::valarray&& values); /** instruct the compiler to generate the implicitly declared destructor*/ ~MatrixArray() override = default; /** instruct the compiler to generate the implicitly declared copy constructor*/ @@ -179,13 +173,13 @@ class MatrixArray : public ValArray /** * \brief operator+ definition for MatrixArray. * \param rhs The rhs MatrixArray object - * \returns The result of operator+ of this MatrixArray and rhs MatrixAray + * \returns The result of operator+ of this MatrixArray and rhs MatrixArray */ MatrixArray operator+(const MatrixArray& rhs) const; /** * \brief binary operator- definition for MatrixArray. * \param rhs The rhs MatrixArray object - * \returns The result of operator- of this MatrixArray and rhs MatrixAray + * \returns The result of operator- of this MatrixArray and rhs MatrixArray */ MatrixArray operator-(const MatrixArray& rhs) const; /** @@ -253,7 +247,7 @@ class MatrixArray : public ValArray EnableBool)>::type> MatrixArray HermitianTranspose() const; - private: + protected: // To simplify functions in MatrixArray that are using members from the template base class using ValArray::m_numRows; using ValArray::m_numCols; diff --git a/src/core/model/names.cc b/src/core/model/names.cc index d39b3f24b..6a0976073 100644 --- a/src/core/model/names.cc +++ b/src/core/model/names.cc @@ -307,7 +307,7 @@ NamesPriv::Clear() ++i) { delete i->second; - i->second = 0; + i->second = nullptr; } m_objectMap.clear(); diff --git a/src/core/model/nstime.h b/src/core/model/nstime.h index f0282d4d9..294895f7f 100644 --- a/src/core/model/nstime.h +++ b/src/core/model/nstime.h @@ -497,7 +497,7 @@ class Time */ inline static Time FromInteger(uint64_t value, Unit unit) { - struct Information* info = PeekInformation(unit); + Information* info = PeekInformation(unit); NS_ASSERT_MSG(info->isValid, "Attempted a conversion from an unavailable unit."); @@ -519,7 +519,7 @@ class Time inline static Time From(const int64x64_t& value, Unit unit) { - struct Information* info = PeekInformation(unit); + Information* info = PeekInformation(unit); NS_ASSERT_MSG(info->isValid, "Attempted a conversion from an unavailable unit."); @@ -553,7 +553,7 @@ class Time */ inline int64_t ToInteger(Unit unit) const { - struct Information* info = PeekInformation(unit); + Information* info = PeekInformation(unit); NS_ASSERT_MSG(info->isValid, "Attempted a conversion to an unavailable unit."); @@ -576,7 +576,7 @@ class Time inline int64x64_t To(Unit unit) const { - struct Information* info = PeekInformation(unit); + Information* info = PeekInformation(unit); NS_ASSERT_MSG(info->isValid, "Attempted a conversion to an unavailable unit."); @@ -651,9 +651,9 @@ class Time * * \return A pointer to the current Resolution */ - static inline struct Resolution* PeekResolution() + static inline Resolution* PeekResolution() { - static struct Time::Resolution& resolution{SetDefaultNsResolution()}; + static Time::Resolution& resolution{SetDefaultNsResolution()}; return &resolution; } @@ -663,7 +663,7 @@ class Time * \param [in] timeUnit The Unit to get Information for * \return The Information for \pname{timeUnit} */ - static inline struct Information* PeekInformation(Unit timeUnit) + static inline Information* PeekInformation(Unit timeUnit) { return &(PeekResolution()->info[timeUnit]); } @@ -673,7 +673,7 @@ class Time * * \return The Resolution object for the default resolution. */ - static struct Resolution& SetDefaultNsResolution(); + static Resolution& SetDefaultNsResolution(); /** * Set the current Resolution. * diff --git a/src/core/model/object-base.cc b/src/core/model/object-base.cc index e1ca714a7..65cc54c1f 100644 --- a/src/core/model/object-base.cc +++ b/src/core/model/object-base.cc @@ -89,7 +89,7 @@ ObjectBase::ConstructSelf(const AttributeConstructionList& attributes) NS_LOG_DEBUG("construct tid=" << tid.GetName() << ", params=" << tid.GetAttributeN()); for (uint32_t i = 0; i < tid.GetAttributeN(); i++) { - struct TypeId::AttributeInformation info = tid.GetAttribute(i); + TypeId::AttributeInformation info = tid.GetAttribute(i); NS_LOG_DEBUG("try to construct \"" << tid.GetName() << "::" << info.name << "\""); // is this attribute stored in this AttributeConstructionList instance ? Ptr value = attributes.Find(info.checker); @@ -200,7 +200,7 @@ void ObjectBase::SetAttribute(std::string name, const AttributeValue& value) { NS_LOG_FUNCTION(this << name << &value); - struct TypeId::AttributeInformation info; + TypeId::AttributeInformation info; TypeId tid = GetInstanceTypeId(); if (!tid.LookupAttributeByName(name, &info)) { @@ -223,7 +223,7 @@ bool ObjectBase::SetAttributeFailSafe(std::string name, const AttributeValue& value) { NS_LOG_FUNCTION(this << name << &value); - struct TypeId::AttributeInformation info; + TypeId::AttributeInformation info; TypeId tid = GetInstanceTypeId(); if (!tid.LookupAttributeByName(name, &info)) { @@ -240,7 +240,7 @@ void ObjectBase::GetAttribute(std::string name, AttributeValue& value) const { NS_LOG_FUNCTION(this << name << &value); - struct TypeId::AttributeInformation info; + TypeId::AttributeInformation info; TypeId tid = GetInstanceTypeId(); if (!tid.LookupAttributeByName(name, &info)) { @@ -277,7 +277,7 @@ bool ObjectBase::GetAttributeFailSafe(std::string name, AttributeValue& value) const { NS_LOG_FUNCTION(this << name << &value); - struct TypeId::AttributeInformation info; + TypeId::AttributeInformation info; TypeId tid = GetInstanceTypeId(); if (!tid.LookupAttributeByName(name, &info)) { diff --git a/src/core/model/object-factory.cc b/src/core/model/object-factory.cc index 6e086a2bf..e6e29effa 100644 --- a/src/core/model/object-factory.cc +++ b/src/core/model/object-factory.cc @@ -55,11 +55,7 @@ ObjectFactory::SetTypeId(std::string tid) bool ObjectFactory::IsTypeIdSet() const { - if (m_tid.GetUid() != 0) - { - return true; - } - return false; + return m_tid.GetUid() != 0; } void @@ -71,7 +67,7 @@ ObjectFactory::DoSet(const std::string& name, const AttributeValue& value) return; } - struct TypeId::AttributeInformation info; + TypeId::AttributeInformation info; if (!m_tid.LookupAttributeByName(name, &info)) { NS_FATAL_ERROR("Invalid attribute set (" << name << ") on " << m_tid.GetName()); @@ -162,7 +158,7 @@ operator>>(std::istream& is, ObjectFactory& factory) else { std::string name = parameters.substr(cur, equal - cur); - struct TypeId::AttributeInformation info; + TypeId::AttributeInformation info; if (!factory.m_tid.LookupAttributeByName(name, &info)) { is.setstate(std::ios_base::failbit); diff --git a/src/core/model/object-map.h b/src/core/model/object-map.h index 091d844df..1adf11477 100644 --- a/src/core/model/object-map.h +++ b/src/core/model/object-map.h @@ -102,7 +102,6 @@ MakeObjectMapAccessor(U T::*memberVector) { *index = (*j).first; return (*j).second; - break; } } NS_ASSERT(false); diff --git a/src/core/model/object-vector.h b/src/core/model/object-vector.h index 9a63d0d41..30c03a414 100644 --- a/src/core/model/object-vector.h +++ b/src/core/model/object-vector.h @@ -102,7 +102,6 @@ MakeObjectVectorAccessor(U T::*memberVector) { *index = k; return *j; - break; } } NS_ASSERT(false); diff --git a/src/core/model/object.cc b/src/core/model/object.cc index a4a082bce..4baaa5494 100644 --- a/src/core/model/object.cc +++ b/src/core/model/object.cc @@ -96,7 +96,7 @@ Object::Object() : m_tid(Object::GetTypeId()), m_disposed(false), m_initialized(false), - m_aggregates((struct Aggregates*)std::malloc(sizeof(struct Aggregates))), + m_aggregates((Aggregates*)std::malloc(sizeof(Aggregates))), m_getObjectCount(0) { NS_LOG_FUNCTION(this); @@ -133,7 +133,7 @@ Object::Object(const Object& o) : m_tid(o.m_tid), m_disposed(false), m_initialized(false), - m_aggregates((struct Aggregates*)std::malloc(sizeof(struct Aggregates))), + m_aggregates((Aggregates*)std::malloc(sizeof(Aggregates))), m_getObjectCount(0) { m_aggregates->n = 1; @@ -244,7 +244,7 @@ restart: } void -Object::UpdateSortedArray(struct Aggregates* aggregates, uint32_t j) const +Object::UpdateSortedArray(Aggregates* aggregates, uint32_t j) const { NS_LOG_FUNCTION(this << aggregates << j); while (j > 0 && @@ -269,8 +269,8 @@ Object::AggregateObject(Ptr o) Object* other = PeekPointer(o); // first create the new aggregate buffer. uint32_t total = m_aggregates->n + other->m_aggregates->n; - struct Aggregates* aggregates = - (struct Aggregates*)std::malloc(sizeof(struct Aggregates) + (total - 1) * sizeof(Object*)); + Aggregates* aggregates = + (Aggregates*)std::malloc(sizeof(Aggregates) + (total - 1) * sizeof(Object*)); aggregates->n = total; // copy our buffer to the new buffer @@ -294,8 +294,8 @@ Object::AggregateObject(Ptr o) // keep track of the old aggregate buffers for the iteration // of NotifyNewAggregates - struct Aggregates* a = m_aggregates; - struct Aggregates* b = other->m_aggregates; + Aggregates* a = m_aggregates; + Aggregates* b = other->m_aggregates; // Then, assign the new aggregation buffer to every object uint32_t n = aggregates->n; @@ -426,7 +426,7 @@ Object::DoDelete() } // Now, actually delete all objects - struct Aggregates* aggregates = m_aggregates; + Aggregates* aggregates = m_aggregates; for (uint32_t i = 0; i < n; i++) { // There is a trick here: each time we call delete below, diff --git a/src/core/model/object.h b/src/core/model/object.h index 8339388f2..09bf09357 100644 --- a/src/core/model/object.h +++ b/src/core/model/object.h @@ -404,7 +404,7 @@ class Object : public SimpleRefCount * \param [in,out] aggregates The list of aggregated Objects. * \param [in] i The most recently used entry in the list. */ - void UpdateSortedArray(struct Aggregates* aggregates, uint32_t i) const; + void UpdateSortedArray(Aggregates* aggregates, uint32_t i) const; /** * Attempt to delete this Object. * @@ -435,7 +435,7 @@ class Object : public SimpleRefCount * array. The array is shared by all aggregated Objects * so the size of the array is indirectly a reference count. */ - struct Aggregates* m_aggregates; + Aggregates* m_aggregates; /** * The number of times the Object was accessed with a * call to GetObject(). diff --git a/src/core/model/pointer.h b/src/core/model/pointer.h index 3708d1375..e14cbe461 100644 --- a/src/core/model/pointer.h +++ b/src/core/model/pointer.h @@ -140,11 +140,7 @@ class PointerChecker : public ns3::PointerChecker return true; } T* ptr = dynamic_cast(PeekPointer(value->GetObject())); - if (ptr == nullptr) - { - return false; - } - return true; + return ptr; } std::string GetValueTypeName() const override diff --git a/src/core/model/random-variable-stream.cc b/src/core/model/random-variable-stream.cc index 5d1d30dce..cddb88b71 100644 --- a/src/core/model/random-variable-stream.cc +++ b/src/core/model/random-variable-stream.cc @@ -802,6 +802,7 @@ LogNormalRandomVariable::GetTypeId() } LogNormalRandomVariable::LogNormalRandomVariable() + : m_nextValid(false) { // m_mu and m_sigma are initialized after constructor by // attributes @@ -851,6 +852,14 @@ LogNormalRandomVariable::GetSigma() const double LogNormalRandomVariable::GetValue(double mu, double sigma) { + if (m_nextValid) + { // use previously generated + m_nextValid = false; + double normal = m_v2 * m_normal; + + return std::exp(sigma * normal + mu); + } + double v1; double v2; double r2; @@ -878,7 +887,10 @@ LogNormalRandomVariable::GetValue(double mu, double sigma) r2 = v1 * v1 + v2 * v2; } while (r2 > 1.0 || r2 == 0); - normal = v1 * std::sqrt(-2.0 * std::log(r2) / r2); + m_normal = std::sqrt(-2.0 * std::log(r2) / r2); + normal = v1 * m_normal; + m_nextValid = true; + m_v2 = v2; x = std::exp(sigma * normal + mu); diff --git a/src/core/model/random-variable-stream.h b/src/core/model/random-variable-stream.h index 6feb07648..96fcd8601 100644 --- a/src/core/model/random-variable-stream.h +++ b/src/core/model/random-variable-stream.h @@ -1175,6 +1175,15 @@ class LogNormalRandomVariable : public RandomVariableStream /** The sigma value for the log-normal distribution returned by this RNG stream. */ double m_sigma; + /** True if m_normal is valid. */ + bool m_nextValid; + + /** The algorithm produces two values at a time. Cache parameters for possible reuse.*/ + double m_v2; + + /** The algorithm produces two values at a time. Cache parameters for possible reuse.*/ + double m_normal; + }; // class LogNormalRandomVariable /** diff --git a/src/core/model/realtime-simulator-impl.cc b/src/core/model/realtime-simulator-impl.cc index 6ca7ed893..23974dcf8 100644 --- a/src/core/model/realtime-simulator-impl.cc +++ b/src/core/model/realtime-simulator-impl.cc @@ -125,12 +125,12 @@ RealtimeSimulatorImpl::Destroy() // means shutting down the workers and doing a Join() before calling the // Simulator::Destroy(). // - while (m_destroyEvents.empty() == false) + while (!m_destroyEvents.empty()) { Ptr ev = m_destroyEvents.front().PeekEventImpl(); m_destroyEvents.pop_front(); NS_LOG_LOGIC("handle destroy " << ev); - if (ev->IsCancelled() == false) + if (!ev->IsCancelled()) { ev->Invoke(); } @@ -149,7 +149,7 @@ RealtimeSimulatorImpl::SetScheduler(ObjectFactory schedulerFactory) if (m_events) { - while (m_events->IsEmpty() == false) + while (!m_events->IsEmpty()) { Scheduler::Event next = m_events->RemoveNext(); scheduler->Insert(next); @@ -738,7 +738,7 @@ RealtimeSimulatorImpl::Remove(const EventId& id) void RealtimeSimulatorImpl::Cancel(const EventId& id) { - if (IsExpired(id) == false) + if (!IsExpired(id)) { id.PeekEventImpl()->Cancel(); } @@ -773,16 +773,9 @@ RealtimeSimulatorImpl::IsExpired(const EventId& id) const // // The same is true for the next line involving the m_currentUid. // - if (id.PeekEventImpl() == nullptr || id.GetTs() < m_currentTs || - (id.GetTs() == m_currentTs && id.GetUid() <= m_currentUid) || - id.PeekEventImpl()->IsCancelled()) - { - return true; - } - else - { - return false; - } + return id.PeekEventImpl() == nullptr || id.GetTs() < m_currentTs || + (id.GetTs() == m_currentTs && id.GetUid() <= m_currentUid) || + id.PeekEventImpl()->IsCancelled(); } Time diff --git a/src/core/model/rng-seed-manager.h b/src/core/model/rng-seed-manager.h index 7681b3f42..a44f1b4c2 100644 --- a/src/core/model/rng-seed-manager.h +++ b/src/core/model/rng-seed-manager.h @@ -46,7 +46,7 @@ class RngSeedManager * subsequently instantiated RandomVariableStream objects. * * \code - * RngSeedManger::SetSeed(15); + * RngSeedManager::SetSeed(15); * UniformVariable x(2,3); // These will give the same output every time * ExponentialVariable y(120); // as long as the seed stays the same. * \endcode diff --git a/src/core/model/rng-stream.cc b/src/core/model/rng-stream.cc index 16906c8f2..75e3ac170 100644 --- a/src/core/model/rng-stream.cc +++ b/src/core/model/rng-stream.cc @@ -297,9 +297,9 @@ struct Precalculated * * \returns The precalculated powers of the transition matrices. */ -struct Precalculated PowerOfTwoConstants () +Precalculated PowerOfTwoConstants () { - struct Precalculated precalculated; + Precalculated precalculated; for (int i = 0; i < 190; i++) { int power = i + 1; @@ -317,7 +317,7 @@ struct Precalculated PowerOfTwoConstants () */ void PowerOfTwoMatrix (int n, Matrix a1p, Matrix a2p) { - static struct Precalculated constants = PowerOfTwoConstants (); + static Precalculated constants = PowerOfTwoConstants (); for (int i = 0; i < 3; i ++) { for (int j = 0; j < 3; j++) diff --git a/src/core/model/test.cc b/src/core/model/test.cc index 688e2c8b6..85d7c5530 100644 --- a/src/core/model/test.cc +++ b/src/core/model/test.cc @@ -63,11 +63,7 @@ TestDoubleIsEqual(const double x1, const double x2, const double epsilon) delta = std::ldexp(epsilon, exponent); difference = x1 - x2; - if (difference > delta || difference < -delta) - { - return false; - } - return true; + return difference <= delta && difference >= -delta; } /** @@ -241,8 +237,8 @@ class TestRunnerImpl : public Singleton * \returns The list of tests matching the filter constraints. */ std::list FilterTests(std::string testName, - enum TestSuite::Type testType, - enum TestCase::TestDuration maximumTestDuration); + TestSuite::Type testType, + TestCase::TestDuration maximumTestDuration); /** Container type for the test. */ typedef std::vector TestSuiteVector; @@ -302,7 +298,7 @@ TestCase::~TestCase() } void -TestCase::AddTestCase(TestCase* testCase, enum TestCase::TestDuration duration) +TestCase::AddTestCase(TestCase* testCase, TestCase::TestDuration duration) { NS_LOG_FUNCTION(&testCase << duration); @@ -836,8 +832,8 @@ TestRunnerImpl::PrintTestTypeList() const std::list TestRunnerImpl::FilterTests(std::string testName, - enum TestSuite::Type testType, - enum TestCase::TestDuration maximumTestDuration) + TestSuite::Type testType, + TestCase::TestDuration maximumTestDuration) { NS_LOG_FUNCTION(this << testName << testType); std::list tests; @@ -899,7 +895,7 @@ TestRunnerImpl::Run(int argc, char* argv[]) bool printTestTypeList = false; bool printTestNameList = false; bool printTestTypeAndName = false; - enum TestCase::TestDuration maximumTestDuration = TestCase::QUICK; + TestCase::TestDuration maximumTestDuration = TestCase::QUICK; char* progname = argv[0]; char** argi = argv; @@ -1006,7 +1002,7 @@ TestRunnerImpl::Run(int argc, char* argv[]) } argi++; } - enum TestSuite::Type testType; + TestSuite::Type testType; if (testTypeString.empty()) { testType = TestSuite::ALL; diff --git a/src/core/model/test.h b/src/core/model/test.h index ec492b5ac..4e07b8b23 100644 --- a/src/core/model/test.h +++ b/src/core/model/test.h @@ -1240,7 +1240,7 @@ class TestCase std::vector m_children; //!< Vector of my children std::string m_dataDir; //!< My data directory TestRunnerImpl* m_runner; //!< Pointer to the TestRunner - struct Result* m_result; //!< Results data + Result* m_result; //!< Results data std::string m_name; //!< TestCase name TestDuration m_duration; //!< TestCase duration }; diff --git a/src/core/model/time.cc b/src/core/model/time.cc index fa5e81d1a..f89a95621 100644 --- a/src/core/model/time.cc +++ b/src/core/model/time.cc @@ -137,43 +137,43 @@ Time::Time(const std::string& s) double r; iss >> r; std::string trailer = s.substr(n, std::string::npos); - if (trailer == std::string("s")) + if (trailer == "s") { *this = Time::FromDouble(r, Time::S); } - else if (trailer == std::string("ms")) + else if (trailer == "ms") { *this = Time::FromDouble(r, Time::MS); } - else if (trailer == std::string("us")) + else if (trailer == "us") { *this = Time::FromDouble(r, Time::US); } - else if (trailer == std::string("ns")) + else if (trailer == "ns") { *this = Time::FromDouble(r, Time::NS); } - else if (trailer == std::string("ps")) + else if (trailer == "ps") { *this = Time::FromDouble(r, Time::PS); } - else if (trailer == std::string("fs")) + else if (trailer == "fs") { *this = Time::FromDouble(r, Time::FS); } - else if (trailer == std::string("min")) + else if (trailer == "min") { *this = Time::FromDouble(r, Time::MIN); } - else if (trailer == std::string("h")) + else if (trailer == "h") { *this = Time::FromDouble(r, Time::H); } - else if (trailer == std::string("d")) + else if (trailer == "d") { *this = Time::FromDouble(r, Time::D); } - else if (trailer == std::string("y")) + else if (trailer == "y") { *this = Time::FromDouble(r, Time::Y); } @@ -199,7 +199,7 @@ Time::Time(const std::string& s) } // static -struct Time::Resolution& +Time::Resolution& Time::SetDefaultNsResolution() { NS_LOG_FUNCTION_NOARGS(); @@ -246,7 +246,7 @@ Time::SetResolution(Unit unit, Resolution* resolution, const bool convert /* = t << " has shift " << shift << " has quotient " << quotient); - struct Information* info = &resolution->info[i]; + Information* info = &resolution->info[i]; if ((std::pow(10, std::fabs(shift)) * quotient) > static_cast(std::numeric_limits::max())) { @@ -338,7 +338,7 @@ Time::Mark(Time* const time) ret = g_markingTimes->insert(time); NS_LOG_LOGIC("\t[" << g_markingTimes->size() << "] recording " << time); - if (ret.second == false) + if (!ret.second) { NS_LOG_WARN("already recorded " << time << "!"); } @@ -388,8 +388,8 @@ Time::ConvertTimes(const Unit unit) for (MarkedTimes::iterator it = g_markingTimes->begin(); it != g_markingTimes->end(); it++) { Time* const tp = *it; - if (!((tp->m_data == std::numeric_limits::min()) || - (tp->m_data == std::numeric_limits::max()))) + if (!(tp->m_data == std::numeric_limits::min() || + tp->m_data == std::numeric_limits::max())) { tp->m_data = tp->ToInteger(unit); } @@ -406,7 +406,7 @@ Time::ConvertTimes(const Unit unit) } // Time::ConvertTimes () // static -enum Time::Unit +Time::Unit Time::GetResolution() { // No function log b/c it interferes with operator<< diff --git a/src/core/model/timer-impl.h b/src/core/model/timer-impl.h index c76229074..0e0b3dabc 100644 --- a/src/core/model/timer-impl.h +++ b/src/core/model/timer-impl.h @@ -1084,7 +1084,7 @@ template void TimerImpl::SetArgs(T1 a1) { - typedef struct TimerImplOne::ParameterType> TimerImplBase; + typedef TimerImplOne::ParameterType> TimerImplBase; TimerImplBase* impl = dynamic_cast(this); if (impl == nullptr) { @@ -1098,8 +1098,8 @@ template void TimerImpl::SetArgs(T1 a1, T2 a2) { - typedef struct TimerImplTwo::ParameterType, - typename TimerTraits::ParameterType> + typedef TimerImplTwo::ParameterType, + typename TimerTraits::ParameterType> TimerImplBase; TimerImplBase* impl = dynamic_cast(this); if (impl == nullptr) @@ -1114,9 +1114,9 @@ template void TimerImpl::SetArgs(T1 a1, T2 a2, T3 a3) { - typedef struct TimerImplThree::ParameterType, - typename TimerTraits::ParameterType, - typename TimerTraits::ParameterType> + typedef TimerImplThree::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType> TimerImplBase; TimerImplBase* impl = dynamic_cast(this); if (impl == nullptr) @@ -1131,10 +1131,10 @@ template void TimerImpl::SetArgs(T1 a1, T2 a2, T3 a3, T4 a4) { - typedef struct TimerImplFour::ParameterType, - typename TimerTraits::ParameterType, - typename TimerTraits::ParameterType, - typename TimerTraits::ParameterType> + typedef TimerImplFour::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType> TimerImplBase; TimerImplBase* impl = dynamic_cast(this); if (impl == nullptr) @@ -1149,11 +1149,11 @@ template void TimerImpl::SetArgs(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { - typedef struct TimerImplFive::ParameterType, - typename TimerTraits::ParameterType, - typename TimerTraits::ParameterType, - typename TimerTraits::ParameterType, - typename TimerTraits::ParameterType> + typedef TimerImplFive::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType> TimerImplBase; TimerImplBase* impl = dynamic_cast(this); if (impl == nullptr) @@ -1168,12 +1168,12 @@ template ::ParameterType, - typename TimerTraits::ParameterType, - typename TimerTraits::ParameterType, - typename TimerTraits::ParameterType, - typename TimerTraits::ParameterType, - typename TimerTraits::ParameterType> + typedef TimerImplSix::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType> TimerImplBase; TimerImplBase* impl = dynamic_cast(this); if (impl == 0) diff --git a/src/core/model/timer.cc b/src/core/model/timer.cc index 170091bd8..1fcba54c3 100644 --- a/src/core/model/timer.cc +++ b/src/core/model/timer.cc @@ -94,17 +94,13 @@ Timer::GetDelayLeft() const { case Timer::RUNNING: return Simulator::GetDelayLeft(m_event); - break; case Timer::EXPIRED: return TimeStep(0); - break; case Timer::SUSPENDED: return m_delayLeft; - break; default: NS_ASSERT(false); return TimeStep(0); - break; } } @@ -143,7 +139,7 @@ Timer::IsSuspended() const return (m_flags & TIMER_SUSPENDED) == TIMER_SUSPENDED; } -enum Timer::State +Timer::State Timer::GetState() const { NS_LOG_FUNCTION(this); diff --git a/src/core/model/timer.h b/src/core/model/timer.h index a3f49061f..6cc78b513 100644 --- a/src/core/model/timer.h +++ b/src/core/model/timer.h @@ -198,7 +198,7 @@ class Timer /** * \returns The current state of the timer. */ - enum Timer::State GetState() const; + Timer::State GetState() const; /** * Schedule a new event using the currently-configured delay, function, * and arguments. @@ -233,11 +233,8 @@ class Timer void Resume(); private: - /** Internal bit marking the suspended state. */ - enum InternalSuspended - { - TIMER_SUSPENDED = (1 << 7) /** Timer suspended. */ - }; + /** Internal bit marking the suspended timer state */ + static constexpr auto TIMER_SUSPENDED{1 << 7}; /** * Bitfield for Timer State, DestroyPolicy and InternalSuspended. diff --git a/src/core/model/type-id.cc b/src/core/model/type-id.cc index 485f09c93..d847da779 100644 --- a/src/core/model/type-id.cc +++ b/src/core/model/type-id.cc @@ -228,7 +228,7 @@ class IidManager : public Singleton * \param [in] i Index into attribute array * \returns The information associated to attribute whose index is \pname{i}. */ - struct TypeId::AttributeInformation GetAttribute(uint16_t uid, std::size_t i) const; + TypeId::AttributeInformation GetAttribute(uint16_t uid, std::size_t i) const; /** * Record a new TraceSource. * \param [in] uid The id. @@ -262,7 +262,7 @@ class IidManager : public Singleton * \param [in] i Index into trace source array. * \returns Detailed information about the requested trace source. */ - struct TypeId::TraceSourceInformation GetTraceSource(uint16_t uid, std::size_t i) const; + TypeId::TraceSourceInformation GetTraceSource(uint16_t uid, std::size_t i) const; /** * Check if this TypeId should not be listed in documentation. * \param [in] uid The id. @@ -312,26 +312,27 @@ class IidManager : public Singleton /** \c true if this type should be omitted from documentation. */ bool mustHideFromDocumentation; /** The container of Attributes. */ - std::vector attributes; + std::vector attributes; /** The container of TraceSources. */ - std::vector traceSources; + std::vector traceSources; /** Support level/deprecation. */ TypeId::SupportLevel supportLevel; /** Support message. */ std::string supportMsg; }; + /** Iterator type. */ - typedef std::vector::const_iterator Iterator; + typedef std::vector::const_iterator Iterator; /** * Retrieve the information record for a type. * \param [in] uid The id. * \returns The information record. */ - struct IidManager::IidInformation* LookupInformation(uint16_t uid) const; + IidManager::IidInformation* LookupInformation(uint16_t uid) const; /** The container of all type id records. */ - std::vector m_information; + std::vector m_information; /** Type of the by-name index. */ typedef std::map namemap_t; @@ -413,7 +414,7 @@ IidManager::AllocateUid(std::string name) // into ns3. -- Peter Barnes, LLNL // Alphabetize the two types, so it's deterministic - struct IidInformation* hinfo = LookupInformation(GetUid(hash)); + IidInformation* hinfo = LookupInformation(GetUid(hash)); if (name > hinfo->name) { // new type gets chained NS_LOG_LOGIC(IIDL << "New TypeId '" << name << "' getting chained."); @@ -451,13 +452,13 @@ IidManager::AllocateUid(std::string name) return uid; } -struct IidManager::IidInformation* +IidManager::IidInformation* IidManager::LookupInformation(uint16_t uid) const { NS_LOG_FUNCTION(IID << uid); NS_ASSERT(uid <= m_information.size() && uid != 0); NS_LOG_LOGIC(IIDL << m_information[uid - 1].name); - return const_cast(&m_information[uid - 1]); + return const_cast(&m_information[uid - 1]); } void @@ -465,7 +466,7 @@ IidManager::SetParent(uint16_t uid, uint16_t parent) { NS_LOG_FUNCTION(IID << uid << parent); NS_ASSERT(parent <= m_information.size()); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); information->parent = parent; } @@ -473,7 +474,7 @@ void IidManager::SetGroupName(uint16_t uid, std::string groupName) { NS_LOG_FUNCTION(IID << uid << groupName); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); information->groupName = groupName; } @@ -481,7 +482,7 @@ void IidManager::SetSize(uint16_t uid, std::size_t size) { NS_LOG_FUNCTION(IID << uid << size); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); information->size = size; } @@ -489,7 +490,7 @@ void IidManager::HideFromDocumentation(uint16_t uid) { NS_LOG_FUNCTION(IID << uid); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); information->mustHideFromDocumentation = true; } @@ -497,7 +498,7 @@ void IidManager::AddConstructor(uint16_t uid, Callback callback) { NS_LOG_FUNCTION(IID << uid << &callback); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); if (information->hasConstructor) { NS_FATAL_ERROR(information->name << " already has a constructor."); @@ -538,7 +539,7 @@ std::string IidManager::GetName(uint16_t uid) const { NS_LOG_FUNCTION(IID << uid); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); NS_LOG_LOGIC(IIDL << information->name); return information->name; } @@ -547,7 +548,7 @@ TypeId::hash_t IidManager::GetHash(uint16_t uid) const { NS_LOG_FUNCTION(IID << uid); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); TypeId::hash_t hash = information->hash; NS_LOG_LOGIC(IIDL << hash); return hash; @@ -557,7 +558,7 @@ uint16_t IidManager::GetParent(uint16_t uid) const { NS_LOG_FUNCTION(IID << uid); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); uint16_t pid = information->parent; NS_LOG_LOGIC(IIDL << pid); return pid; @@ -567,7 +568,7 @@ std::string IidManager::GetGroupName(uint16_t uid) const { NS_LOG_FUNCTION(IID << uid); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); NS_LOG_LOGIC(IIDL << information->groupName); return information->groupName; } @@ -576,7 +577,7 @@ std::size_t IidManager::GetSize(uint16_t uid) const { NS_LOG_FUNCTION(IID << uid); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); std::size_t size = information->size; NS_LOG_LOGIC(IIDL << size); return size; @@ -586,7 +587,7 @@ Callback IidManager::GetConstructor(uint16_t uid) const { NS_LOG_FUNCTION(IID << uid); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); if (!information->hasConstructor) { NS_FATAL_ERROR("Requested constructor for " << information->name @@ -599,7 +600,7 @@ bool IidManager::HasConstructor(uint16_t uid) const { NS_LOG_FUNCTION(IID << uid); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); bool hasC = information->hasConstructor; NS_LOG_LOGIC(IIDL << hasC); return hasC; @@ -623,10 +624,10 @@ bool IidManager::HasAttribute(uint16_t uid, std::string name) { NS_LOG_FUNCTION(IID << uid << name); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); while (true) { - for (std::vector::const_iterator i = + for (std::vector::const_iterator i = information->attributes.begin(); i != information->attributes.end(); ++i) @@ -637,7 +638,7 @@ IidManager::HasAttribute(uint16_t uid, std::string name) return true; } } - struct IidInformation* parent = LookupInformation(information->parent); + IidInformation* parent = LookupInformation(information->parent); if (parent == information) { // top of inheritance tree @@ -664,7 +665,7 @@ IidManager::AddAttribute(uint16_t uid, { NS_LOG_FUNCTION(IID << uid << name << help << flags << initialValue << accessor << checker << supportLevel << supportMsg); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); if (name.find(' ') != std::string::npos) { NS_FATAL_ERROR("Attribute name \"" << name << "\" may not contain spaces ' ', " @@ -676,7 +677,7 @@ IidManager::AddAttribute(uint16_t uid, NS_FATAL_ERROR("Attribute \"" << name << "\" already registered on tid=\"" << information->name << "\""); } - struct TypeId::AttributeInformation info; + TypeId::AttributeInformation info; info.name = name; info.help = help; info.flags = flags; @@ -696,7 +697,7 @@ IidManager::SetAttributeInitialValue(uint16_t uid, Ptr initialValue) { NS_LOG_FUNCTION(IID << uid << i << initialValue); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); NS_ASSERT(i < information->attributes.size()); information->attributes[i].initialValue = initialValue; } @@ -705,17 +706,17 @@ std::size_t IidManager::GetAttributeN(uint16_t uid) const { NS_LOG_FUNCTION(IID << uid); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); std::size_t size = information->attributes.size(); NS_LOG_LOGIC(IIDL << size); return size; } -struct TypeId::AttributeInformation +TypeId::AttributeInformation IidManager::GetAttribute(uint16_t uid, std::size_t i) const { NS_LOG_FUNCTION(IID << uid << i); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); NS_ASSERT(i < information->attributes.size()); NS_LOG_LOGIC(IIDL << information->name); return information->attributes[i]; @@ -725,10 +726,10 @@ bool IidManager::HasTraceSource(uint16_t uid, std::string name) { NS_LOG_FUNCTION(IID << uid << name); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); while (true) { - for (std::vector::const_iterator i = + for (std::vector::const_iterator i = information->traceSources.begin(); i != information->traceSources.end(); ++i) @@ -739,7 +740,7 @@ IidManager::HasTraceSource(uint16_t uid, std::string name) return true; } } - struct IidInformation* parent = LookupInformation(information->parent); + IidInformation* parent = LookupInformation(information->parent); if (parent == information) { // top of inheritance tree @@ -764,13 +765,13 @@ IidManager::AddTraceSource(uint16_t uid, { NS_LOG_FUNCTION(IID << uid << name << help << accessor << callback << supportLevel << supportMsg); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); if (HasTraceSource(uid, name)) { NS_FATAL_ERROR("Trace source \"" << name << "\" already registered on tid=\"" << information->name << "\""); } - struct TypeId::TraceSourceInformation source; + TypeId::TraceSourceInformation source; source.name = name; source.help = help; source.accessor = accessor; @@ -785,17 +786,17 @@ std::size_t IidManager::GetTraceSourceN(uint16_t uid) const { NS_LOG_FUNCTION(IID << uid); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); std::size_t size = information->traceSources.size(); NS_LOG_LOGIC(IIDL << size); return size; } -struct TypeId::TraceSourceInformation +TypeId::TraceSourceInformation IidManager::GetTraceSource(uint16_t uid, std::size_t i) const { NS_LOG_FUNCTION(IID << uid << i); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); NS_ASSERT(i < information->traceSources.size()); NS_LOG_LOGIC(IIDL << information->name); return information->traceSources[i]; @@ -805,7 +806,7 @@ bool IidManager::MustHideFromDocumentation(uint16_t uid) const { NS_LOG_FUNCTION(IID << uid); - struct IidInformation* information = LookupInformation(uid); + IidInformation* information = LookupInformation(uid); bool hide = information->mustHideFromDocumentation; NS_LOG_LOGIC(IIDL << hide); return hide; @@ -894,7 +895,7 @@ TypeId::GetRegistered(uint16_t i) } bool -TypeId::LookupAttributeByName(std::string name, struct TypeId::AttributeInformation* info) const +TypeId::LookupAttributeByName(std::string name, TypeId::AttributeInformation* info) const { NS_LOG_FUNCTION(this << name << info); TypeId tid; @@ -904,7 +905,7 @@ TypeId::LookupAttributeByName(std::string name, struct TypeId::AttributeInformat tid = nextTid; for (std::size_t i = 0; i < tid.GetAttributeN(); i++) { - struct TypeId::AttributeInformation tmp = tid.GetAttribute(i); + TypeId::AttributeInformation tmp = tid.GetAttribute(i); if (tmp.name == name) { if (tmp.supportLevel == TypeId::SUPPORTED) @@ -1108,7 +1109,7 @@ TypeId::GetAttributeN() const return n; } -struct TypeId::AttributeInformation +TypeId::AttributeInformation TypeId::GetAttribute(std::size_t i) const { NS_LOG_FUNCTION(this << i); @@ -1119,7 +1120,7 @@ std::string TypeId::GetAttributeFullName(std::size_t i) const { NS_LOG_FUNCTION(this << i); - struct TypeId::AttributeInformation info = GetAttribute(i); + TypeId::AttributeInformation info = GetAttribute(i); return GetName() + "::" + info.name; } @@ -1130,7 +1131,7 @@ TypeId::GetTraceSourceN() const return IidManager::Get()->GetTraceSourceN(m_tid); } -struct TypeId::TraceSourceInformation +TypeId::TraceSourceInformation TypeId::GetTraceSource(std::size_t i) const { NS_LOG_FUNCTION(this << i); @@ -1160,12 +1161,12 @@ TypeId::HideFromDocumentation() } Ptr -TypeId::LookupTraceSourceByName(std::string name, struct TraceSourceInformation* info) const +TypeId::LookupTraceSourceByName(std::string name, TraceSourceInformation* info) const { NS_LOG_FUNCTION(this << name); TypeId tid; TypeId nextTid = *this; - struct TypeId::TraceSourceInformation tmp; + TypeId::TraceSourceInformation tmp; do { tid = nextTid; diff --git a/src/core/model/type-id.h b/src/core/model/type-id.h index 250f6471f..2c2a58f3f 100644 --- a/src/core/model/type-id.h +++ b/src/core/model/type-id.h @@ -23,7 +23,6 @@ #include "attribute-helper.h" #include "attribute.h" #include "callback.h" -#include "deprecated.h" #include "hash.h" #include "trace-source-accessor.h" @@ -262,7 +261,7 @@ class TypeId * \param [in] i Index into attribute array * \returns The information associated to attribute whose index is \pname{i}. */ - struct TypeId::AttributeInformation GetAttribute(std::size_t i) const; + TypeId::AttributeInformation GetAttribute(std::size_t i) const; /** * Get the Attribute name by index. * @@ -298,7 +297,7 @@ class TypeId * \param [in] i Index into trace source array. * \returns Detailed information about the requested trace source. */ - struct TypeId::TraceSourceInformation GetTraceSource(std::size_t i) const; + TypeId::TraceSourceInformation GetTraceSource(std::size_t i) const; /** * Set the parent TypeId. @@ -474,7 +473,7 @@ class TypeId * will be stored. * \returns \c true if the requested attribute could be found. */ - bool LookupAttributeByName(std::string name, struct AttributeInformation* info) const; + bool LookupAttributeByName(std::string name, AttributeInformation* info) const; /** * Find a TraceSource by name. * @@ -497,9 +496,8 @@ class TypeId * and disconnect trace sinks with the requested trace source on * an object instance. */ - Ptr LookupTraceSourceByName( - std::string name, - struct TraceSourceInformation* info) const; + Ptr LookupTraceSourceByName(std::string name, + TraceSourceInformation* info) const; /** * Get the internal id of this TypeId. diff --git a/src/core/model/unix-fd-reader.cc b/src/core/model/unix-fd-reader.cc index 20955b921..89dd3801c 100644 --- a/src/core/model/unix-fd-reader.cc +++ b/src/core/model/unix-fd-reader.cc @@ -218,7 +218,7 @@ FdReader::Run() if (FD_ISSET(m_fd, &readfds)) { - struct FdReader::Data data = DoRead(); + FdReader::Data data = DoRead(); // reading stops when m_len is zero if (data.m_len == 0) { diff --git a/src/core/model/val-array.h b/src/core/model/val-array.h index d09edac82..609400c7a 100644 --- a/src/core/model/val-array.h +++ b/src/core/model/val-array.h @@ -89,7 +89,7 @@ class ValArray : public SimpleRefCount> * \param numCols the number of columns * \param numPages the number of pages */ - ValArray(uint16_t numRows, uint16_t numCols = 1, uint16_t numPages = 1); + ValArray(size_t numRows, size_t numCols = 1, size_t numPages = 1); /** * \brief Constructor creates a single 1D array of values.size () elements and 1 column, * and uses std::valarray values to initialize the elements. @@ -115,7 +115,7 @@ class ValArray : public SimpleRefCount> * \param numCols the number of columns * \param values valarray that will be used to initialize elements of 3D array */ - ValArray(uint16_t numRows, uint16_t numCols, const std::valarray& values); + ValArray(size_t numRows, size_t numCols, const std::valarray& values); /** * \brief Constructor creates a single 2D array of numRows and numCols, and moves * std::valarray values to initialize the elements. @@ -123,7 +123,7 @@ class ValArray : public SimpleRefCount> * \param numCols the number of columns * \param values valarray that will be used to initialize elements of 3D array */ - ValArray(uint16_t numRows, uint16_t numCols, std::valarray&& values); + ValArray(size_t numRows, size_t numCols, std::valarray&& values); /** * \brief Constructor creates the 3D array of numRows x numCols x numPages dimensions, * and uses std::valarray values to initialize all the 2D arrays, where first @@ -133,10 +133,7 @@ class ValArray : public SimpleRefCount> * \param numPages the number of pages * \param values valarray that will be used to initialize elements of 3D array */ - ValArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, - const std::valarray& values); + ValArray(size_t numRows, size_t numCols, size_t numPages, const std::valarray& values); /** * \brief Constructor creates the 3D array of numRows x numCols x numPages dimensions, * and moves std::valarray values to initialize all the 2D arrays, where first @@ -146,7 +143,7 @@ class ValArray : public SimpleRefCount> * \param numPages the number of pages * \param values valarray that will be used to initialize elements of 3D array */ - ValArray(uint16_t numRows, uint16_t numCols, uint16_t numPages, std::valarray&& values); + ValArray(size_t numRows, size_t numCols, size_t numPages, std::valarray&& values); /** instruct the compiler to generate the implicitly declared destructor*/ virtual ~ValArray() = default; /** instruct the compiler to generate the implicitly declared copy constructor*/ @@ -168,15 +165,15 @@ class ValArray : public SimpleRefCount> /** * \returns Number of rows */ - uint16_t GetNumRows() const; + size_t GetNumRows() const; /** * \returns Number of columns */ - uint16_t GetNumCols() const; + size_t GetNumCols() const; /** * \returns Number of pages, i.e., the number of 2D arrays */ - uint16_t GetNumPages() const; + size_t GetNumPages() const; /** * \returns Total number of elements */ @@ -188,7 +185,7 @@ class ValArray : public SimpleRefCount> * \param pageIndex The index of the page * \returns A const reference to the element with with rowIndex, colIndex and pageIndex indices. */ - T& operator()(uint16_t rowIndex, uint16_t colIndex, uint16_t pageIndex); + T& operator()(size_t rowIndex, size_t colIndex, size_t pageIndex); /** * \brief Const access operator, with bound-checking in debug profile * \param rowIndex The index of the row @@ -196,7 +193,7 @@ class ValArray : public SimpleRefCount> * \param pageIndex The index of the page * \returns A const reference to the element with with rowIndex, colIndex and pageIndex indices. */ - const T& operator()(uint16_t rowIndex, uint16_t colIndex, uint16_t pageIndex) const; + const T& operator()(size_t rowIndex, size_t colIndex, size_t pageIndex) const; /** * \brief Access operator for 2D ValArrays. * Assuming that the third dimension is equal to 1, e.g. ValArray contains @@ -209,7 +206,7 @@ class ValArray : public SimpleRefCount> * \param colIndex The index of the column * \returns A reference to the element with the specified indices */ - T& operator()(uint16_t rowIndex, uint16_t colIndex); + T& operator()(size_t rowIndex, size_t colIndex); /** * \brief Const access operator for 2D ValArrays. * Assuming that the third dimension is equal to 1, e.g. ValArray contains @@ -218,7 +215,7 @@ class ValArray : public SimpleRefCount> * \param colIndex column index * \returns a Const reference to the value with the specified row and column index. */ - const T& operator()(uint16_t rowIndex, uint16_t colIndex) const; + const T& operator()(size_t rowIndex, size_t colIndex) const; /** * \brief Single-element access operator() for 1D ValArrays. * Assuming that the number of columns and pages is equal to 1, e.g. ValArray @@ -230,13 +227,13 @@ class ValArray : public SimpleRefCount> * \param index The index of the 1D ValArray. * \returns A reference to the value with the specified index. */ - T& operator()(uint16_t index); + T& operator()(size_t index); /** * \brief Single-element access operator() for 1D ValArrays. * \param index The index of the 1D ValArray. * \returns The const reference to the values with the specified index. */ - const T& operator()(uint16_t index) const; + const T& operator()(size_t index) const; /** * \brief Element-wise multiplication with a scalar value. * \param rhs A scalar value of type T @@ -302,14 +299,14 @@ class ValArray : public SimpleRefCount> * \param pageIndex The index of the desired 2D array * \returns a pointer to the data elements of the 2D array */ - T* GetPagePtr(uint16_t pageIndex); + T* GetPagePtr(size_t pageIndex); /** * \brief Get a data pointer to a specific 2D array for use in linear * algebra libraries * \param pageIndex An index of the desired 2D array * \returns a pointer to the data elements of the 2D array */ - const T* GetPagePtr(uint16_t pageIndex) const; + const T* GetPagePtr(size_t pageIndex) const; /** * \brief Checks whether rhs and lhs ValArray objects have the same dimensions. * \param rhs The rhs ValArray @@ -365,11 +362,11 @@ class ValArray : public SimpleRefCount> const T& Elem(size_t row, size_t col, size_t page) const; protected: - uint16_t m_numRows = + size_t m_numRows = 0; //!< The size of the first dimension, i.e., the number of rows of each 2D array - uint16_t m_numCols = + size_t m_numCols = 0; //!< The size of the second dimension, i.e., the number of columns of each 2D array - uint16_t m_numPages = 0; //!< The size of the third dimension, i.e., the number of 2D arrays + size_t m_numPages = 0; //!< The size of the third dimension, i.e., the number of 2D arrays std::valarray m_values; //!< The data values }; @@ -378,21 +375,21 @@ class ValArray : public SimpleRefCount> ************************************************/ template -inline uint16_t +inline size_t ValArray::GetNumRows() const { return m_numRows; }; template -inline uint16_t +inline size_t ValArray::GetNumCols() const { return m_numCols; }; template -inline uint16_t +inline size_t ValArray::GetNumPages() const { return m_numPages; @@ -407,7 +404,7 @@ ValArray::GetSize() const template inline T& -ValArray::operator()(uint16_t rowIndex, uint16_t colIndex, uint16_t pageIndex) +ValArray::operator()(size_t rowIndex, size_t colIndex, size_t pageIndex) { NS_ASSERT_MSG(rowIndex < m_numRows, "Row index out of bounds"); NS_ASSERT_MSG(colIndex < m_numCols, "Column index out of bounds"); @@ -418,7 +415,7 @@ ValArray::operator()(uint16_t rowIndex, uint16_t colIndex, uint16_t pageIndex template inline const T& -ValArray::operator()(uint16_t rowIndex, uint16_t colIndex, uint16_t pageIndex) const +ValArray::operator()(size_t rowIndex, size_t colIndex, size_t pageIndex) const { NS_ASSERT_MSG(rowIndex < m_numRows, "Row index out of bounds"); NS_ASSERT_MSG(colIndex < m_numCols, "Column index out of bounds"); @@ -429,7 +426,7 @@ ValArray::operator()(uint16_t rowIndex, uint16_t colIndex, uint16_t pageIndex template inline T& -ValArray::operator()(uint16_t rowIndex, uint16_t colIndex) +ValArray::operator()(size_t rowIndex, size_t colIndex) { NS_ASSERT_MSG(m_numPages == 1, "Cannot use 2D access operator for 3D ValArray."); return (*this)(rowIndex, colIndex, 0); @@ -437,7 +434,7 @@ ValArray::operator()(uint16_t rowIndex, uint16_t colIndex) template inline const T& -ValArray::operator()(uint16_t rowIndex, uint16_t colIndex) const +ValArray::operator()(size_t rowIndex, size_t colIndex) const { NS_ASSERT_MSG(m_numPages == 1, "Cannot use 2D access operator for 3D ValArray."); return (*this)(rowIndex, colIndex, 0); @@ -445,7 +442,7 @@ ValArray::operator()(uint16_t rowIndex, uint16_t colIndex) const template inline T& -ValArray::operator()(uint16_t index) +ValArray::operator()(size_t index) { NS_ASSERT_MSG(index < m_values.size(), "Invalid index to 1D ValArray. The size of the array should be set through " @@ -458,7 +455,7 @@ ValArray::operator()(uint16_t index) template inline const T& -ValArray::operator()(uint16_t index) const +ValArray::operator()(size_t index) const { NS_ASSERT_MSG(index < m_values.size(), "Invalid index to 1D ValArray.The size of the array should be set through " @@ -522,7 +519,7 @@ ValArray::operator-=(const ValArray& rhs) template inline T* -ValArray::GetPagePtr(uint16_t pageIndex) +ValArray::GetPagePtr(size_t pageIndex) { NS_ASSERT_MSG(pageIndex < m_numPages, "Invalid page index."); return &(m_values[m_numRows * m_numCols * pageIndex]); @@ -530,7 +527,7 @@ ValArray::GetPagePtr(uint16_t pageIndex) template inline const T* -ValArray::GetPagePtr(uint16_t pageIndex) const +ValArray::GetPagePtr(size_t pageIndex) const { NS_ASSERT_MSG(pageIndex < m_numPages, "Invalid page index."); return &(m_values[m_numRows * m_numCols * pageIndex]); @@ -584,7 +581,7 @@ ValArray::Elem(size_t row, size_t col, size_t page) const ************************************************/ template -ValArray::ValArray(uint16_t numRows, uint16_t numCols, uint16_t numPages) +ValArray::ValArray(size_t numRows, size_t numCols, size_t numPages) : m_numRows{numRows}, m_numCols{numCols}, m_numPages{numPages} @@ -594,7 +591,7 @@ ValArray::ValArray(uint16_t numRows, uint16_t numCols, uint16_t numPages) template ValArray::ValArray(const std::valarray& values) - : m_numRows{(uint16_t)values.size()}, + : m_numRows{values.size()}, m_numCols{1}, m_numPages{1}, m_values{values} @@ -603,7 +600,7 @@ ValArray::ValArray(const std::valarray& values) template ValArray::ValArray(std::valarray&& values) - : m_numRows{(uint16_t)values.size()}, + : m_numRows{values.size()}, m_numCols{1}, m_numPages{1}, m_values{std::move(values)} @@ -612,7 +609,7 @@ ValArray::ValArray(std::valarray&& values) template ValArray::ValArray(const std::vector& values) - : m_numRows{(uint16_t)values.size()}, + : m_numRows{values.size()}, m_numCols{1}, m_numPages{1} { @@ -621,7 +618,7 @@ ValArray::ValArray(const std::vector& values) } template -ValArray::ValArray(uint16_t numRows, uint16_t numCols, const std::valarray& values) +ValArray::ValArray(size_t numRows, size_t numCols, const std::valarray& values) : m_numRows{numRows}, m_numCols{numCols}, m_numPages{1}, @@ -632,7 +629,7 @@ ValArray::ValArray(uint16_t numRows, uint16_t numCols, const std::valarray }; template -ValArray::ValArray(uint16_t numRows, uint16_t numCols, std::valarray&& values) +ValArray::ValArray(size_t numRows, size_t numCols, std::valarray&& values) : m_numRows{numRows}, m_numCols{numCols}, m_numPages{1} @@ -643,9 +640,9 @@ ValArray::ValArray(uint16_t numRows, uint16_t numCols, std::valarray&& val }; template -ValArray::ValArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, +ValArray::ValArray(size_t numRows, + size_t numCols, + size_t numPages, const std::valarray& values) : m_numRows{numRows}, m_numCols{numCols}, @@ -657,10 +654,7 @@ ValArray::ValArray(uint16_t numRows, }; template -ValArray::ValArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, - std::valarray&& values) +ValArray::ValArray(size_t numRows, size_t numCols, size_t numPages, std::valarray&& values) : m_numRows{numRows}, m_numCols{numCols}, m_numPages{numPages} @@ -723,12 +717,12 @@ std::ostream& operator<<(std::ostream& os, const ValArray& a) { os << "\n"; - for (auto p = 0; p != a.GetNumPages(); ++p) + for (size_t p = 0; p != a.GetNumPages(); ++p) { os << "Page " << p << ":\n"; - for (auto i = 0; i != a.GetNumRows(); ++i) + for (size_t i = 0; i != a.GetNumRows(); ++i) { - for (auto j = 0; j != a.GetNumCols(); ++j) + for (size_t j = 0; j != a.GetNumCols(); ++j) { os << "\t" << a(i, j, p); } diff --git a/src/core/model/wall-clock-synchronizer.cc b/src/core/model/wall-clock-synchronizer.cc index eb3f15bdd..ea8b87546 100644 --- a/src/core/model/wall-clock-synchronizer.cc +++ b/src/core/model/wall-clock-synchronizer.cc @@ -227,7 +227,7 @@ WallClockSynchronizer::DoSynchronize(uint64_t nsCurrent, uint64_t nsDelay) // interrupted by a Signal. In this case, we need to return and let the // simulator re-evaluate what to do. // - if (SleepWait((numberJiffies - 3) * m_jiffy) == false) + if (!SleepWait((numberJiffies - 3) * m_jiffy)) { NS_LOG_INFO("SleepWait interrupted"); return false; diff --git a/src/core/model/win32-fd-reader.cc b/src/core/model/win32-fd-reader.cc index 6a10a5fcd..457dd669f 100644 --- a/src/core/model/win32-fd-reader.cc +++ b/src/core/model/win32-fd-reader.cc @@ -225,7 +225,7 @@ FdReader::Run() if (FD_ISSET(m_fd, &readfds)) { - struct FdReader::Data data = DoRead(); + FdReader::Data data = DoRead(); // reading stops when m_len is zero if (data.m_len == 0) { diff --git a/src/core/test/attribute-container-test-suite.cc b/src/core/test/attribute-container-test-suite.cc index fb12e2d08..d8a191ac7 100644 --- a/src/core/test/attribute-container-test-suite.cc +++ b/src/core/test/attribute-container-test-suite.cc @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -59,7 +58,7 @@ class AttributeContainerObject : public Object /** * Reverses the list of doubles. */ - void ReverseList(); + void ReverseDoubleList(); /** * \brief Get the type ID. @@ -67,6 +66,19 @@ class AttributeContainerObject : public Object */ static TypeId GetTypeId(); + /** + * Set the list of doubles to the given list + * + * \param doubleList the given list + */ + void SetDoubleList(const std::list& doubleList); + /** + * Get the list of doubles + * + * \return the list of doubles + */ + std::list GetDoubleList() const; + /** * Set the vector of ints to the given vector * @@ -80,20 +92,12 @@ class AttributeContainerObject : public Object */ std::vector GetIntVec() const; - /** - * \brief Stream insertion operator. - * - * \param [in] os The reference to the output stream. - * \param [in] obj The AttributeContainer object. - * \returns The reference to the output stream. - */ - friend std::ostream& operator<<(std::ostream& os, const AttributeContainerObject& obj); - private: std::list m_doublelist; //!< List of doubles. std::vector m_intvec; //!< Vector of ints. // TODO(jared): need PairValue attributevalue to handle std::pair elements - std::map m_map; //!< Map of . + std::map m_map; //!< Map of . + std::map> m_intVecIntMapping; //!< Mapping integers to vectors }; AttributeContainerObject::AttributeContainerObject() @@ -107,6 +111,8 @@ AttributeContainerObject::~AttributeContainerObject() TypeId AttributeContainerObject::GetTypeId() { + using IntVecMapValue = PairValue>; + static TypeId tid = TypeId("ns3::AttributeContainerObject") .SetParent() @@ -118,15 +124,16 @@ AttributeContainerObject::GetTypeId() MakeAttributeContainerAccessor( &AttributeContainerObject::m_doublelist), MakeAttributeContainerChecker(MakeDoubleChecker())) - .AddAttribute("IntegerVector", - "Vector of integers", - // the container value container differs from the underlying object - AttributeContainerValue(), - // the type of the underlying container cannot be deduced - MakeAttributeContainerAccessor( - &AttributeContainerObject::SetIntVec, - &AttributeContainerObject::GetIntVec), - MakeAttributeContainerChecker(MakeIntegerChecker())) + .AddAttribute( + "IntegerVector", + "Vector of integers", + // the container value container differs from the underlying object + AttributeContainerValue(), + // the type of the underlying container cannot be deduced + MakeAttributeContainerAccessor( + &AttributeContainerObject::SetIntVec, + &AttributeContainerObject::GetIntVec), + MakeAttributeContainerChecker(MakeIntegerChecker())) .AddAttribute( "MapStringInt", "Map of strings to ints", @@ -136,17 +143,42 @@ AttributeContainerObject::GetTypeId() &AttributeContainerObject::m_map), MakeAttributeContainerChecker>( MakePairChecker(MakeStringChecker(), - MakeIntegerChecker()))); + MakeIntegerChecker()))) + .AddAttribute( + "IntVecPairVec", + "An example of complex attribute that is defined by a vector of pairs consisting " + "of an integer value and a vector of integers. In case a string is used to set " + "this attribute, the string shall contain the pairs separated by a semicolon (;); " + "in every pair, the integer value and the vector of integers are separated by a " + "blank space, and the elements of the vectors are separated by a comma (,) " + "without spaces. E.g. \"0 1,2,3; 1 0; 2 0,1\" consists of three pairs containing " + "vectors of 3, 1 and 2 elements, respectively.", + StringValue(""), + MakeAttributeContainerAccessor( + &AttributeContainerObject::m_intVecIntMapping), + MakeAttributeContainerChecker( + MakePairChecker>( + MakeIntegerChecker(), + MakeAttributeContainerChecker(MakeIntegerChecker())))); return tid; } void -AttributeContainerObject::ReverseList() +AttributeContainerObject::ReverseDoubleList() { m_doublelist.reverse(); - std::vector tmp; - std::copy_backward(m_intvec.begin(), m_intvec.end(), tmp.begin()); - m_intvec = tmp; +} + +void +AttributeContainerObject::SetDoubleList(const std::list& doubleList) +{ + m_doublelist = doubleList; +} + +std::list +AttributeContainerObject::GetDoubleList() const +{ + return m_doublelist; } void @@ -161,23 +193,6 @@ AttributeContainerObject::GetIntVec() const return m_intvec; } -std::ostream& -operator<<(std::ostream& os, const AttributeContainerObject& obj) -{ - os << "AttributeContainerObject: "; - bool first = true; - for (auto d : obj.m_doublelist) - { - if (!first) - { - os << ", "; - } - os << d; - first = false; - } - return os; -} - /** * \ingroup attribute-tests * @@ -256,7 +271,7 @@ AttributeContainerTestCase::DoRun() auto ref = {"one", "two", "three"}; AttributeContainerValue ac(ref.begin(), ref.end()); - NS_TEST_ASSERT_MSG_EQ(3, ac.GetN(), "Container size mismatch"); + NS_TEST_ASSERT_MSG_EQ(ref.size(), ac.GetN(), "Container size mismatch"); auto aciter = ac.Begin(); for (auto v : ref) { @@ -269,9 +284,9 @@ AttributeContainerTestCase::DoRun() { auto ref = {"one", "two", "three"}; - AttributeContainerValue ac(ref); + AttributeContainerValue ac(ref); - NS_TEST_ASSERT_MSG_EQ(3, ac.GetN(), "Container size mismatch"); + NS_TEST_ASSERT_MSG_EQ(ref.size(), ac.GetN(), "Container size mismatch"); auto aciter = ac.Begin(); for (auto v : ref) { @@ -287,7 +302,7 @@ AttributeContainerTestCase::DoRun() std::map ref = {{"one", 1}, {"two", 2}, {"three", 3}}; AttributeContainerValue> ac(ref); - NS_TEST_ASSERT_MSG_EQ(3, ac.GetN(), "Container size mismatch"); + NS_TEST_ASSERT_MSG_EQ(ref.size(), ac.GetN(), "Container size mismatch"); auto aciter = ac.Begin(); for (const auto& v : ref) { @@ -366,7 +381,7 @@ AttributeContainerSerializationTestCase::DoRun() { std::string strings = "this is a sentence with words"; - AttributeContainerValue attr(' '); + AttributeContainerValue attr; auto checker = MakeAttributeContainerChecker(attr); auto acchecker = DynamicCast(checker); acchecker->SetItemChecker(MakeStringChecker()); @@ -376,8 +391,7 @@ AttributeContainerSerializationTestCase::DoRun() NS_TEST_ASSERT_MSG_EQ(attr.GetN(), 6, "Incorrect container size"); std::string reserialized = attr.SerializeToString(checker); - std::string canonical = strings; - NS_TEST_ASSERT_MSG_EQ(reserialized, canonical, "Reserialization failed"); + NS_TEST_ASSERT_MSG_EQ(reserialized, strings, "Reserialization failed"); } { @@ -394,8 +408,7 @@ AttributeContainerSerializationTestCase::DoRun() NS_TEST_ASSERT_MSG_EQ(attr.GetN(), 3, "Incorrect container size"); std::string reserialized = attr.SerializeToString(checker); - std::string canonical = pairs; - NS_TEST_ASSERT_MSG_EQ(reserialized, canonical, "Reserealization failed"); + NS_TEST_ASSERT_MSG_EQ(reserialized, pairs, "Reserealization failed"); } } @@ -427,29 +440,24 @@ AttributeContainerSetGetTestCase::DoRun() { Ptr obj = CreateObject(); { - std::ostringstream oss; - oss << *obj; - NS_TEST_ASSERT_MSG_EQ(oss.str(), - "AttributeContainerObject: ", - "DoubleList initialized incorrectly"); + auto doubleList = obj->GetDoubleList(); + NS_TEST_ASSERT_MSG_EQ(doubleList.empty(), true, "DoubleList initialized incorrectly"); } - std::list doubles = {1.1, 2.22, 3.333}; + const std::list doubles = {1.1, 2.22, 3.333}; obj->SetAttribute("DoubleList", AttributeContainerValue(doubles)); { - std::ostringstream oss; - oss << *obj; - NS_TEST_ASSERT_MSG_EQ(oss.str(), - "AttributeContainerObject: 1.1, 2.22, 3.333", + auto doubleList = obj->GetDoubleList(); + NS_TEST_ASSERT_MSG_EQ(std::equal(doubles.begin(), doubles.end(), doubleList.begin()), + true, "DoubleList incorrectly set"); } - obj->ReverseList(); + obj->ReverseDoubleList(); { - std::ostringstream oss; - oss << *obj; - NS_TEST_ASSERT_MSG_EQ(oss.str(), - "AttributeContainerObject: 3.333, 2.22, 1.1", + auto doubleList = obj->GetDoubleList(); + NS_TEST_ASSERT_MSG_EQ(std::equal(doubles.rbegin(), doubles.rend(), doubleList.begin()), + true, "DoubleList incorrectly reversed"); // NOTE: changing the return container here too! @@ -459,32 +467,58 @@ AttributeContainerSetGetTestCase::DoRun() AttributeContainerValue::result_type doublevec = value.Get(); NS_TEST_ASSERT_MSG_EQ(doubles.size(), doublevec.size(), "DoublesVec wrong size"); - auto iter = doubles.rbegin(); - for (auto d : doublevec) - { - NS_TEST_ASSERT_MSG_EQ(d, *iter, "Incorrect value in doublesvec"); - ++iter; - } + NS_TEST_ASSERT_MSG_EQ(std::equal(doubles.rbegin(), doubles.rend(), doublevec.begin()), + true, + "Incorrect value in doublesvec"); } - std::vector ints = {-1, 0, 1, 2, 3}; + const std::vector ints = {-1, 0, 1, 2, 3}; // NOTE: here the underlying attribute container type differs from the actual container - obj->SetAttribute("IntegerVector", AttributeContainerValue(ints)); + obj->SetAttribute("IntegerVector", AttributeContainerValue(ints)); { // NOTE: changing the container here too! - AttributeContainerValue value; + AttributeContainerValue value; obj->GetAttribute("IntegerVector", value); NS_TEST_ASSERT_MSG_EQ(ints.size(), value.GetN(), "AttributeContainerValue wrong size"); AttributeContainerValue::result_type intlist = value.Get(); NS_TEST_ASSERT_MSG_EQ(ints.size(), intlist.size(), "Intvec wrong size"); - auto iter = ints.begin(); - for (auto d : intlist) - { - NS_TEST_ASSERT_MSG_EQ(d, *iter, "Incorrect value in intvec"); - ++iter; - } + + NS_TEST_ASSERT_MSG_EQ(std::equal(ints.begin(), ints.end(), intlist.begin()), + true, + "Incorrect value in intvec"); + } + + std::string intVecPairString("0 1,2,3; 1 0; 2 0,1"); + // NOTE: here the underlying attribute container type differs from the actual container + obj->SetAttribute("IntVecPairVec", StringValue(intVecPairString)); + + { + using IntVecMapValue = PairValue>; + + // NOTE: changing the container here too! + AttributeContainerValue value; + obj->GetAttribute("IntVecPairVec", value); + NS_TEST_ASSERT_MSG_EQ(3, value.GetN(), "AttributeContainerValue wrong size"); // 3 pairs + + AttributeContainerValue::result_type reslist = value.Get(); + NS_TEST_ASSERT_MSG_EQ(3, reslist.size(), "IntVecMapValue wrong size"); + auto reslistIt = reslist.begin(); + NS_TEST_ASSERT_MSG_EQ(reslistIt->first, 0, "Incorrect integer value in first pair"); + NS_TEST_ASSERT_MSG_EQ(reslistIt->second.size(), + 3, + "Incorrect number of integer values in first pair"); + ++reslistIt; + NS_TEST_ASSERT_MSG_EQ(reslistIt->first, 1, "Incorrect integer value in second pair"); + NS_TEST_ASSERT_MSG_EQ(reslistIt->second.size(), + 1, + "Incorrect number of integer values in second pair"); + ++reslistIt; + NS_TEST_ASSERT_MSG_EQ(reslistIt->first, 2, "Incorrect integer value in third pair"); + NS_TEST_ASSERT_MSG_EQ(reslistIt->second.size(), + 2, + "Incorrect number of integer values in third pair"); } std::map map = {{"one", 1}, {"two", 2}, {"three", 3}}; diff --git a/src/core/test/attribute-test-suite.cc b/src/core/test/attribute-test-suite.cc index de6e26b0e..a2f156541 100644 --- a/src/core/test/attribute-test-suite.cc +++ b/src/core/test/attribute-test-suite.cc @@ -237,6 +237,11 @@ class AttributeObjectTest : public Object ObjectMapValue(), MakeObjectMapAccessor(&AttributeObjectTest::m_map1), MakeObjectMapChecker()) + .AddAttribute("TestUnorderedMap", + "help text", + ObjectMapValue(), + MakeObjectMapAccessor(&AttributeObjectTest::m_unorderedMap), + MakeObjectMapChecker()) .AddAttribute("IntegerTraceSource1", "help text", IntegerValue(-2), @@ -350,6 +355,24 @@ class AttributeObjectTest : public Object m_map1.insert(std::pair>(i, CreateObject())); } + /** + * Adds an object to the unordered map. + * \param i The index to assign to the object. + */ + void AddToUnorderedMap(uint64_t i) + { + m_unorderedMap.insert({i, CreateObject()}); + } + + /** + * Remove an object from the first map. + * \param i The index to assign to the object. + */ + void RemoveFromUnorderedMap(uint64_t i) + { + m_unorderedMap.erase(i); + } + /** * Invoke the m_cb callback. * \param a The first argument of the callback. @@ -477,15 +500,17 @@ class AttributeObjectTest : public Object int16_t m_int16SetGet; //!< 16-bit integer set-get. uint8_t m_uint8; //!< 8-bit integer. float m_float; //!< float. - enum Test_e m_enum; //!< Enum. - enum Test_e m_enumSetGet; //!< Enum set-get. + Test_e m_enum; //!< Enum. + Test_e m_enumSetGet; //!< Enum set-get. Ptr m_random; //!< Random number generator. std::vector> m_vector1; //!< First vector of derived objects. std::vector> m_vector2; //!< Second vector of derived objects. std::map> m_map1; //!< Map of uint32_t, derived objects. - Callback m_cbValue; //!< Callback accepting an integer. - TracedValue m_intSrc1; //!< First int8_t Traced value. - TracedValue m_intSrc2; //!< Second int8_t Traced value. + std::unordered_map> + m_unorderedMap; //!< Unordered map of uint64_t, derived objects. + Callback m_cbValue; //!< Callback accepting an integer. + TracedValue m_intSrc1; //!< First int8_t Traced value. + TracedValue m_intSrc2; //!< Second int8_t Traced value. /// Traced callbacks for (double, int, float) values. typedef void (*NumericTracedCallback)(double, int, float); @@ -1329,6 +1354,42 @@ ObjectMapAttributeTestCase::DoRun() // p->GetAttribute("TestMap1", map); NS_TEST_ASSERT_MSG_EQ(map.GetN(), 2, "ObjectVectorValue \"TestMap1\" should be incremented"); + + // + // Test that ObjectMapValue is iterable with an underlying unordered_map + // + ObjectMapValue unorderedMap; + // Add objects at 1, 2, 3, 4 + p->AddToUnorderedMap(4); + p->AddToUnorderedMap(2); + p->AddToUnorderedMap(1); + p->AddToUnorderedMap(3); + // Remove object 2 + p->RemoveFromUnorderedMap(2); + p->GetAttribute("TestUnorderedMap", unorderedMap); + NS_TEST_ASSERT_MSG_EQ(unorderedMap.GetN(), + 3, + "ObjectMapValue \"TestUnorderedMap\" should have three values"); + Ptr o1 = unorderedMap.Get(1); + NS_TEST_ASSERT_MSG_NE(o1, + nullptr, + "ObjectMapValue \"TestUnorderedMap\" should have value with key 1"); + Ptr o2 = unorderedMap.Get(2); + NS_TEST_ASSERT_MSG_EQ(o2, + nullptr, + "ObjectMapValue \"TestUnorderedMap\" should not have value with key 2"); + auto it = unorderedMap.Begin(); + NS_TEST_ASSERT_MSG_EQ(it->first, + 1, + "ObjectMapValue \"TestUnorderedMap\" should have a value with key 1"); + it++; + NS_TEST_ASSERT_MSG_EQ(it->first, + 3, + "ObjectMapValue \"TestUnorderedMap\" should have a value with key 3"); + it++; + NS_TEST_ASSERT_MSG_EQ(it->first, + 4, + "ObjectMapValue \"TestUnorderedMap\" should have a value with key 4"); } /** diff --git a/src/core/test/examples-to-run.py b/src/core/test/examples-to-run.py index f3befa574..7fa3c5e29 100644 --- a/src/core/test/examples-to-run.py +++ b/src/core/test/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/src/core/test/matrix-array-test-suite.cc b/src/core/test/matrix-array-test-suite.cc index 77a016e89..595932b6d 100644 --- a/src/core/test/matrix-array-test-suite.cc +++ b/src/core/test/matrix-array-test-suite.cc @@ -38,7 +38,7 @@ NS_LOG_COMPONENT_DEFINE("MatrixArrayTest"); /** * \ingroup matrixArray-tests - * MatrixArray test for testing constructors + * MatrixArray test case for testing constructors, operators and other functions */ template class MatrixArrayTestCase : public TestCase @@ -50,7 +50,7 @@ class MatrixArrayTestCase : public TestCase * * \param [in] name reference name */ - MatrixArrayTestCase(const std::string name); + MatrixArrayTestCase(const std::string& name); /** Destructor. */ ~MatrixArrayTestCase() override; @@ -83,7 +83,7 @@ class MatrixArrayTestCase : public TestCase }; template -MatrixArrayTestCase::MatrixArrayTestCase(const std::string name) +MatrixArrayTestCase::MatrixArrayTestCase(const std::string& name) : TestCase(name) { } @@ -100,9 +100,9 @@ MatrixArrayTestCase::DoRun() // test multiplication of matrices (MatrixArray containing only 1 matrix) MatrixArray m1 = MatrixArray(2, 3); MatrixArray m2 = MatrixArray(m1.GetNumCols(), m1.GetNumRows()); - for (auto i = 0; i < m1.GetNumRows(); ++i) + for (size_t i = 0; i < m1.GetNumRows(); ++i) { - for (auto j = 0; j < m1.GetNumCols(); ++j) + for (size_t j = 0; j < m1.GetNumCols(); ++j) { m1(i, j) = 1; m2(j, i) = 1; @@ -121,9 +121,9 @@ MatrixArrayTestCase::DoRun() NS_TEST_ASSERT_MSG_EQ(m3.GetNumRows(), m3.GetNumCols(), "The number of rows and cols should be equal"); - for (auto i = 0; i < m3.GetNumCols(); ++i) + for (size_t i = 0; i < m3.GetNumCols(); ++i) { - for (auto j = 0; j < m3.GetNumRows(); ++j) + for (size_t j = 0; j < m3.GetNumRows(); ++j) { NS_TEST_ASSERT_MSG_EQ(std::real(m3(i, j)), m1.GetNumCols(), @@ -133,9 +133,9 @@ MatrixArrayTestCase::DoRun() // multiplication with a scalar value MatrixArray m4 = m3 * (static_cast(5.0)); - for (auto i = 0; i < m4.GetNumCols(); ++i) + for (size_t i = 0; i < m4.GetNumCols(); ++i) { - for (auto j = 0; j < m4.GetNumRows(); ++j) + for (size_t j = 0; j < m4.GetNumRows(); ++j) { NS_TEST_ASSERT_MSG_EQ(m3(i, j) * (static_cast(5.0)), m4(i, j), @@ -147,11 +147,11 @@ MatrixArrayTestCase::DoRun() // test multiplication of arrays of matrices MatrixArray m5 = MatrixArray(2, 3, 2); MatrixArray m6 = MatrixArray(m5.GetNumCols(), m5.GetNumRows(), m5.GetNumPages()); - for (auto p = 0; p < m5.GetNumPages(); ++p) + for (size_t p = 0; p < m5.GetNumPages(); ++p) { - for (auto i = 0; i < m5.GetNumRows(); ++i) + for (size_t i = 0; i < m5.GetNumRows(); ++i) { - for (auto j = 0; j < m5.GetNumCols(); ++j) + for (size_t j = 0; j < m5.GetNumCols(); ++j) { m5(i, j, p) = 1; m6(j, i, p) = 1; @@ -169,11 +169,11 @@ MatrixArrayTestCase::DoRun() m7.GetNumCols(), "The number of rows and cols should be equal"); - for (auto p = 0; p < m7.GetNumPages(); ++p) + for (size_t p = 0; p < m7.GetNumPages(); ++p) { - for (auto i = 0; i < m7.GetNumCols(); ++i) + for (size_t i = 0; i < m7.GetNumCols(); ++i) { - for (auto j = 0; j < m7.GetNumRows(); ++j) + for (size_t j = 0; j < m7.GetNumRows(); ++j) { NS_TEST_ASSERT_MSG_EQ(std::real(m7(i, j, p)), m5.GetNumCols(), @@ -191,6 +191,27 @@ MatrixArrayTestCase::DoRun() NS_TEST_ASSERT_MSG_EQ(m6, m8, "These two matrices should be equal"); NS_LOG_INFO("m8 = m5.Transpose ()" << m8); + // test transpose using initialization arrays + std::valarray a{0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}; + std::valarray b{0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4}; + std::valarray aCasted(a.size()); + std::valarray bCasted(b.size()); + for (size_t i = 0; i < a.size(); ++i) + { + aCasted[i] = static_cast(a[i]); + } + for (size_t i = 0; i < b.size(); ++i) + { + bCasted[i] = static_cast(b[i]); + } + m5 = MatrixArray(3, 5, 1, aCasted); + m6 = MatrixArray(5, 3, 1, bCasted); + m8 = m5.Transpose(); + NS_TEST_ASSERT_MSG_EQ(m6, m8, "These two matrices should be equal"); + NS_LOG_INFO("m5 (3, 5, 1):" << m5); + NS_LOG_INFO("m6 (5, 3, 1):" << m6); + NS_LOG_INFO("m8 (5, 3, 1) = m5.Transpose ()" << m8); + // test 1D array creation, i.e. vector and transposing it MatrixArray m9 = MatrixArray(std::vector({0, 1, 2, 3, 4, 5, 6, 7})); NS_TEST_ASSERT_MSG_EQ((m9.GetNumRows() == 8) && (m9.GetNumCols() == 1) && @@ -217,12 +238,14 @@ MatrixArrayTestCase::DoRun() NS_TEST_ASSERT_MSG_EQ(m10, m9, "m10 and m9 should be equal"); // test multiplication by using an initialization matrixArray - std::valarray a{0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5}; - std::valarray b{0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; + // matrix dimensions in each page are 2x3, 3x2, and the resulting matrix per page is a square + // matrix 2x2 + a = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5}; + b = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; std::valarray c{2, 3, 4, 6, 2, 3, 4, 6}; - std::valarray aCasted(a.size()); - std::valarray bCasted(b.size()); - std::valarray cCasted(c.size()); + aCasted = std::valarray(a.size()); + bCasted = std::valarray(b.size()); + std::valarray cCasted = std::valarray(c.size()); for (size_t i = 0; i < a.size(); ++i) { @@ -247,9 +270,88 @@ MatrixArrayTestCase::DoRun() m14.GetNumRows(), "The number of rows is not as expected."); NS_TEST_ASSERT_MSG_EQ(m13, m14, "The values are not equal."); - NS_LOG_INFO("m11:" << m11); - NS_LOG_INFO("m12:" << m12); - NS_LOG_INFO("m13 = matrixArrayA * matrixArrayB:" << m13); + NS_LOG_INFO("m11 (2,3,2):" << m11); + NS_LOG_INFO("m12 (3,2,2):" << m12); + NS_LOG_INFO("m13 = m11 * m12:" << m13); + + // test multiplication by using an initialization matrixArray + // matrices have different number of elements per page + // matrix dimensions in each page are 4x3, 3x2, and the resulting matrix + // dimensions are 4x2 + a = std::valarray( + {0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5}); + b = std::valarray({0, 1, 0, 1, 0, 1, 0, 10, 0, 10, 0, 10}); + c = std::valarray({2, 3, 2, 3, 4, 6, 4, 6, 20, 30, 20, 30, 40, 60, 40, 60}); + aCasted = std::valarray(a.size()); + bCasted = std::valarray(b.size()); + cCasted = std::valarray(c.size()); + + for (size_t i = 0; i < a.size(); ++i) + { + aCasted[i] = static_cast(a[i]); + } + for (size_t i = 0; i < b.size(); ++i) + { + bCasted[i] = static_cast(b[i]); + } + for (size_t i = 0; i < c.size(); ++i) + { + cCasted[i] = static_cast(c[i]); + } + + m11 = MatrixArray(4, 3, 2, aCasted); + m12 = MatrixArray(3, 2, 2, bCasted); + m13 = m11 * m12; + m14 = MatrixArray(4, 2, 2, cCasted); + NS_TEST_ASSERT_MSG_EQ(m13.GetNumCols(), + m14.GetNumCols(), + "The number of columns is not as expected."); + NS_TEST_ASSERT_MSG_EQ(m13.GetNumRows(), + m14.GetNumRows(), + "The number of rows is not as expected."); + NS_TEST_ASSERT_MSG_EQ(m13, m14, "The values are not equal."); + NS_LOG_INFO("m11 (4,3,2):" << m11); + NS_LOG_INFO("m12 (3,2,2):" << m12); + NS_LOG_INFO("m13 = m11 * m12:" << m13); + + // test multiplication by using an initialization matrixArray + // matrices have different number of elements per page + // matrix dimensions in each page are 1x3, 3x2, and the resulting matrix has + // dimensions 1x2 + a = std::valarray({5, 4, 5, 5, 4, 5}); + b = std::valarray({0, 1, 0, 1, 0, 1, 1, 2, 3, 10, 100, 1000}); + c = std::valarray({4, 10, 28, 5450}); + aCasted = std::valarray(a.size()); + bCasted = std::valarray(b.size()); + cCasted = std::valarray(c.size()); + + for (size_t i = 0; i < a.size(); ++i) + { + aCasted[i] = static_cast(a[i]); + } + for (size_t i = 0; i < b.size(); ++i) + { + bCasted[i] = static_cast(b[i]); + } + for (size_t i = 0; i < c.size(); ++i) + { + cCasted[i] = static_cast(c[i]); + } + + m11 = MatrixArray(1, 3, 2, aCasted); + m12 = MatrixArray(3, 2, 2, bCasted); + m13 = m11 * m12; + m14 = MatrixArray(1, 2, 2, cCasted); + NS_TEST_ASSERT_MSG_EQ(m13.GetNumCols(), + m14.GetNumCols(), + "The number of columns is not as expected."); + NS_TEST_ASSERT_MSG_EQ(m13.GetNumRows(), + m14.GetNumRows(), + "The number of rows is not as expected."); + NS_TEST_ASSERT_MSG_EQ(m13, m14, "The values are not equal."); + NS_LOG_INFO("m11 (1,3,2):" << m11); + NS_LOG_INFO("m12 (3,2,2):" << m12); + NS_LOG_INFO("m13 = m11 * m12:" << m13); // test MultiplyByLeftAndRightMatrix std::valarray d{1, 1, 1}; @@ -320,23 +422,100 @@ MatrixArrayTestCase::DoRun() NS_LOG_INFO("m24 = m20 * m22 * m21" << m24); // test initialization with moving + size_t lCastedSize = lCasted.size(); NS_LOG_INFO("size() of lCasted before move: " << lCasted.size()); MatrixArray m25 = MatrixArray(2, 2, 2, std::move(lCasted)); - NS_LOG_INFO("size() of lCasted after move: " << lCasted.size()); NS_LOG_INFO("m25.GetSize ()" << m25.GetSize()); - NS_TEST_ASSERT_MSG_EQ(lCasted.size(), 0, "The size of lCasted should be 0."); + NS_TEST_ASSERT_MSG_EQ(lCastedSize, m25.GetSize(), "The number of elements are not equal."); + size_t hCastedSize = hCasted.size(); NS_LOG_INFO("size() of hCasted before move: " << hCasted.size()); MatrixArray m26 = MatrixArray(2, 3, std::move(hCasted)); - NS_LOG_INFO("size() of hCasted after move: " << hCasted.size()); NS_LOG_INFO("m26.GetSize ()" << m26.GetSize()); - NS_TEST_ASSERT_MSG_EQ(hCasted.size(), 0, "The size of hCasted should be 0."); + NS_TEST_ASSERT_MSG_EQ(hCastedSize, m26.GetSize(), "The number of elements are not equal."); + size_t jCastedSize = jCasted.size(); NS_LOG_INFO("size() of jCasted before move: " << jCasted.size()); MatrixArray m27 = MatrixArray(std::move(jCasted)); - NS_LOG_INFO("size() of jCasted after move: " << jCasted.size()); NS_LOG_INFO("m27.GetSize ()" << m27.GetSize()); - NS_TEST_ASSERT_MSG_EQ(hCasted.size(), 0, "The size of jCasted should be 0."); + NS_TEST_ASSERT_MSG_EQ(jCastedSize, m27.GetSize(), "The number of elements are not equal."); +} + +/** + * \ingroup matrixArray-tests + * Test for testing functions that apply to MatrixArrays that use complex numbers, + * such as HermitianTranspose that is only defined for complex type + */ +class ComplexMatrixArrayTestCase : public TestCase +{ + public: + /** Constructor*/ + ComplexMatrixArrayTestCase(); + /** + * Constructor + * + * \param [in] name reference name + */ + ComplexMatrixArrayTestCase(const std::string& name); + /** Destructor*/ + ~ComplexMatrixArrayTestCase() override; + + private: + void DoRun() override; +}; + +ComplexMatrixArrayTestCase::ComplexMatrixArrayTestCase() + : TestCase("ComplexMatrixArrayTestCase") +{ +} + +ComplexMatrixArrayTestCase::ComplexMatrixArrayTestCase(const std::string& name) + : TestCase(name) +{ +} + +ComplexMatrixArrayTestCase::~ComplexMatrixArrayTestCase() +{ +} + +void +ComplexMatrixArrayTestCase::DoRun() +{ + std::valarray> complexValarray1 = { + {1, 1}, + {2, 2}, + {3, 3}, + {4, 4}, + {5, 5}, + {6, 6}, + {-1, 1}, + {-2, 2}, + {-3, 3}, + {-4, 4}, + {-5, 5}, + {-6, 6}, + }; + std::valarray> complexValarray2 = { + {1, -1}, + {4, -4}, + {2, -2}, + {5, -5}, + {3, -3}, + {6, -6}, + {-1, -1}, + {-4, -4}, + {-2, -2}, + {-5, -5}, + {-3, -3}, + {-6, -6}, + }; + ComplexMatrixArray m1 = ComplexMatrixArray(3, 2, 2, complexValarray1); + ComplexMatrixArray m2 = ComplexMatrixArray(2, 3, 2, complexValarray2); + ComplexMatrixArray m3 = m1.HermitianTranspose(); + NS_LOG_INFO("m1 (3, 2, 2):" << m1); + NS_LOG_INFO("m2 (2, 3, 2):" << m2); + NS_LOG_INFO("m3 (2, 3, 2):" << m3); + NS_TEST_ASSERT_MSG_EQ(m2, m3, "m2 and m3 matrices should be equal"); } /** @@ -357,6 +536,7 @@ MatrixArrayTestSuite::MatrixArrayTestSuite() AddTestCase( new MatrixArrayTestCase>("Test MatrixArray>")); AddTestCase(new MatrixArrayTestCase("Test MatrixArray")); + AddTestCase(new ComplexMatrixArrayTestCase("Test ComplexMatrixArray")); } /** diff --git a/src/core/test/object-test-suite.cc b/src/core/test/object-test-suite.cc index abf3fbce1..76032ab68 100644 --- a/src/core/test/object-test-suite.cc +++ b/src/core/test/object-test-suite.cc @@ -541,7 +541,7 @@ ObjectFactoryTestCase::DoRun() // // Since a declared a BaseA, even if it is really a DerivedA, we should not - // be able to GetOBject for a DerivedA since this would break the type + // be able to GetObject for a DerivedA since this would break the type // declaration. // NS_TEST_ASSERT_MSG_EQ(!a->GetObject(), diff --git a/src/core/test/random-variable-stream-test-suite.cc b/src/core/test/random-variable-stream-test-suite.cc index 610ea0d26..d9e7c3d0a 100644 --- a/src/core/test/random-variable-stream-test-suite.cc +++ b/src/core/test/random-variable-stream-test-suite.cc @@ -316,7 +316,7 @@ class TestCaseBase : public TestCase */ void SetTestSuiteSeed() { - if (m_seedSet == false) + if (!m_seedSet) { uint32_t seed; if (RngSeedManager::GetRun() == 0) diff --git a/src/core/test/simulator-test-suite.cc b/src/core/test/simulator-test-suite.cc index e0824ea6b..e2ff55969 100644 --- a/src/core/test/simulator-test-suite.cc +++ b/src/core/test/simulator-test-suite.cc @@ -115,14 +115,7 @@ SimulatorEventsTestCase::EventA(int /* a */) void SimulatorEventsTestCase::EventB(int b) { - if (b != 2 || NowUs() != 11) - { - m_b = false; - } - else - { - m_b = true; - } + m_b = !(b != 2 || NowUs() != 11); Simulator::Remove(m_idC); Simulator::Schedule(MicroSeconds(10), &SimulatorEventsTestCase::EventD, this, 4); } @@ -136,14 +129,7 @@ SimulatorEventsTestCase::EventC(int /* c */) void SimulatorEventsTestCase::EventD(int d) { - if (d != 4 || NowUs() != (11 + 10)) - { - m_d = false; - } - else - { - m_d = true; - } + m_d = !(d != 4 || NowUs() != (11 + 10)); } void @@ -185,7 +171,11 @@ SimulatorEventsTestCase::DoRun() NS_TEST_EXPECT_MSG_EQ(m_d, true, "Event D did not run ?"); EventId anId = Simulator::ScheduleNow(&SimulatorEventsTestCase::Eventfoo0, this); + + // Test copy assignment operator + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) EventId anotherId = anId; + NS_TEST_EXPECT_MSG_EQ(!(anId.IsExpired() || anotherId.IsExpired()), true, "Event should not have expired yet."); diff --git a/src/core/test/trickle-timer-test-suite.cc b/src/core/test/trickle-timer-test-suite.cc index b3ccd3204..b27b8a190 100644 --- a/src/core/test/trickle-timer-test-suite.cc +++ b/src/core/test/trickle-timer-test-suite.cc @@ -96,7 +96,7 @@ TrickleTimerTestCase::TrickleTimerTestCase() void TrickleTimerTestCase::ExpireTimer() { - if (m_enableDataCollection == false) + if (!m_enableDataCollection) { return; } diff --git a/src/core/test/type-id-test-suite.cc b/src/core/test/type-id-test-suite.cc index ccfaf03f6..3f50ffcc3 100644 --- a/src/core/test/type-id-test-suite.cc +++ b/src/core/test/type-id-test-suite.cc @@ -59,10 +59,8 @@ class UniqueTypeIdTestCase : public TestCase private: void DoRun() override; - enum - { - HashChainFlag = 0x80000000 - }; + /// Hash chaining flag, copied from type-id.cc:IidManager + static constexpr auto HASH_CHAIN_FLAG{0x80000000}; }; UniqueTypeIdTestCase::UniqueTypeIdTestCase() @@ -93,7 +91,7 @@ UniqueTypeIdTestCase::DoRun() { const TypeId tid = TypeId::GetRegistered(i); std::cout << suite << "" << std::setw(6) << tid.GetUid(); - if (tid.GetHash() & HashChainFlag) + if (tid.GetHash() & HASH_CHAIN_FLAG) { std::cout << " chain"; } @@ -108,9 +106,9 @@ UniqueTypeIdTestCase::DoRun() TypeId::LookupByName(tid.GetName()).GetUid(), "LookupByName returned different TypeId for " << tid.GetName()); - // Mask off HashChainFlag in this test, since tid might have been chained - NS_TEST_ASSERT_MSG_EQ((tid.GetHash() & (~HashChainFlag)), - (hasher.clear().GetHash32(tid.GetName()) & (~HashChainFlag)), + // Mask off HASH_CHAIN_FLAG in this test, since tid might have been chained + NS_TEST_ASSERT_MSG_EQ((tid.GetHash() & (~HASH_CHAIN_FLAG)), + (hasher.clear().GetHash32(tid.GetName()) & (~HASH_CHAIN_FLAG)), "TypeId .hash and Hash32 (.name) unequal for " << tid.GetName()); NS_TEST_ASSERT_MSG_EQ(tid.GetUid(), @@ -135,10 +133,8 @@ class CollisionTestCase : public TestCase private: void DoRun() override; - enum - { - HashChainFlag = 0x80000000 - }; + /// Hash chaining flag, copied from type-id.cc:IidManager + static constexpr auto HASH_CHAIN_FLAG{0x80000000}; }; CollisionTestCase::CollisionTestCase() @@ -167,14 +163,14 @@ CollisionTestCase::DoRun() TypeId t2(t2Name); // Check that they are alphabetical: t1 name < t2 name - NS_TEST_ASSERT_MSG_EQ((t1.GetHash() & HashChainFlag), + NS_TEST_ASSERT_MSG_EQ((t1.GetHash() & HASH_CHAIN_FLAG), 0, - "First and lesser TypeId has HashChainFlag set"); + "First and lesser TypeId has HASH_CHAIN_FLAG set"); std::cout << suite << "collision: first,lesser not chained: OK" << std::endl; - NS_TEST_ASSERT_MSG_NE((t2.GetHash() & HashChainFlag), + NS_TEST_ASSERT_MSG_NE((t2.GetHash() & HASH_CHAIN_FLAG), 0, - "Second and greater TypeId does not have HashChainFlag set"); + "Second and greater TypeId does not have HASH_CHAIN_FLAG set"); std::cout << suite << "collision: second,greater chained: OK" << std::endl; // Register colliding types in reverse alphabetical order @@ -188,14 +184,14 @@ CollisionTestCase::DoRun() TypeId t4(t4Name); // Check that they are alphabetical: t3 name > t4 name - NS_TEST_ASSERT_MSG_NE((t3.GetHash() & HashChainFlag), + NS_TEST_ASSERT_MSG_NE((t3.GetHash() & HASH_CHAIN_FLAG), 0, - "First and greater TypeId does not have HashChainFlag set"); + "First and greater TypeId does not have HASH_CHAIN_FLAG set"); std::cout << suite << "collision: first,greater chained: OK" << std::endl; - NS_TEST_ASSERT_MSG_EQ((t4.GetHash() & HashChainFlag), + NS_TEST_ASSERT_MSG_EQ((t4.GetHash() & HASH_CHAIN_FLAG), 0, - "Second and lesser TypeId has HashChainFlag set"); + "Second and lesser TypeId has HASH_CHAIN_FLAG set"); std::cout << suite << "collision: second,lesser not chained: OK" << std::endl; /** TODO Extra credit: register three types whose hashes collide @@ -321,7 +317,7 @@ DeprecatedAttributeTestCase::DoRun() std::cerr << suite << "DeprecatedAttribute TypeId: " << tid.GetUid() << std::endl; // Try the lookups - struct TypeId::AttributeInformation ainfo; + TypeId::AttributeInformation ainfo; NS_TEST_ASSERT_MSG_EQ(tid.LookupAttributeByName("attribute", &ainfo), true, "lookup new attribute"); @@ -334,7 +330,7 @@ DeprecatedAttributeTestCase::DoRun() std::cerr << suite << "lookup old attribute:" << (ainfo.supportLevel == TypeId::DEPRECATED ? "deprecated" : "error") << std::endl; - struct TypeId::TraceSourceInformation tinfo; + TypeId::TraceSourceInformation tinfo; Ptr acc; acc = tid.LookupTraceSourceByName("trace", &tinfo); NS_TEST_ASSERT_MSG_NE(acc, nullptr, "lookup new trace source"); @@ -368,10 +364,8 @@ class LookupTimeTestCase : public TestCase */ void Report(const std::string how, const uint32_t delta) const; - enum - { - REPETITIONS = 100000 - }; + /// Number of repetitions + static constexpr uint32_t REPETITIONS{100000}; }; LookupTimeTestCase::LookupTimeTestCase() diff --git a/src/core/test/val-array-test-suite.cc b/src/core/test/val-array-test-suite.cc index 7da8eed07..8ac7dd534 100644 --- a/src/core/test/val-array-test-suite.cc +++ b/src/core/test/val-array-test-suite.cc @@ -48,7 +48,7 @@ class ValArrayTestCase : public TestCase * * \param [in] name reference name */ - ValArrayTestCase(const std::string name); + ValArrayTestCase(const std::string& name); /** Destructor. */ ~ValArrayTestCase() override; @@ -80,7 +80,7 @@ class ValArrayTestCase : public TestCase }; template -ValArrayTestCase::ValArrayTestCase(const std::string name) +ValArrayTestCase::ValArrayTestCase(const std::string& name) : TestCase(name) { } @@ -95,9 +95,9 @@ void ValArrayTestCase::DoRun() { ValArray v1 = ValArray(2, 3); - for (uint16_t i = 0; i < v1.GetNumRows(); ++i) + for (size_t i = 0; i < v1.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v1.GetNumCols(); ++j) + for (size_t j = 0; j < v1.GetNumCols(); ++j) { v1(i, j) = 1; } @@ -108,9 +108,9 @@ ValArrayTestCase::DoRun() NS_TEST_ASSERT_MSG_EQ(v1.GetNumCols(), v2.GetNumCols(), "The number of cols are not equal."); // test copy constructor - for (uint16_t i = 0; i < v1.GetNumRows(); ++i) + for (size_t i = 0; i < v1.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v1.GetNumCols(); ++j) + for (size_t j = 0; j < v1.GetNumCols(); ++j) { NS_TEST_ASSERT_MSG_EQ(v1(i, j), v2(i, j), "The elements are not equal."); } @@ -120,9 +120,9 @@ ValArrayTestCase::DoRun() ValArray v3 = v1; NS_TEST_ASSERT_MSG_EQ(v1.GetNumRows(), v3.GetNumRows(), "The number of rows are not equal."); NS_TEST_ASSERT_MSG_EQ(v1.GetNumCols(), v3.GetNumCols(), "The number of cols are not equal."); - for (uint16_t i = 0; i < v1.GetNumRows(); ++i) + for (size_t i = 0; i < v1.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v1.GetNumCols(); ++j) + for (size_t j = 0; j < v1.GetNumCols(); ++j) { NS_TEST_ASSERT_MSG_EQ(v1(i, j), v2(i, j), "The elements are not equal."); } @@ -136,9 +136,9 @@ ValArrayTestCase::DoRun() v4 = std::move(v1); NS_LOG_INFO("v4 size after move: " << v4.GetSize()); NS_TEST_ASSERT_MSG_EQ(v1size, v4.GetSize(), "The number of elements are not equal."); - for (uint16_t i = 0; i < v4.GetNumRows(); ++i) + for (size_t i = 0; i < v4.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v4.GetNumCols(); ++j) + for (size_t j = 0; j < v4.GetNumCols(); ++j) { // Use v3 for comparison since it hasn't moved NS_TEST_ASSERT_MSG_EQ(v3(i, j), v4(i, j), "The elements are not equal."); @@ -150,9 +150,9 @@ ValArrayTestCase::DoRun() size_t v3size = v3.GetSize(); ValArray v5(std::move(v3)); NS_TEST_ASSERT_MSG_EQ(v3size, v5.GetSize(), "The number of elements are not equal."); - for (uint16_t i = 0; i < v5.GetNumRows(); ++i) + for (size_t i = 0; i < v5.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v5.GetNumCols(); ++j) + for (size_t j = 0; j < v5.GetNumCols(); ++j) { // Use v4 for comparison since it hasn't moved NS_TEST_ASSERT_MSG_EQ(v4(i, j), v5(i, j), "The elements are not equal."); @@ -177,10 +177,10 @@ ValArrayTestCase::DoRun() // test whether column-major order was respected during the initialization and // also in the access operator if we iterate over rows first we should find 0, 2, 4, 6, ... std::valarray initArray2{0, 2, 4, 6, 1, 3, 5, 7}; - auto testIndex = 0; - for (uint16_t i = 0; i < v6.GetNumRows(); ++i) + size_t testIndex = 0; + for (size_t i = 0; i < v6.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v6.GetNumCols(); ++j) + for (size_t j = 0; j < v6.GetNumCols(); ++j) { NS_TEST_ASSERT_MSG_EQ(v6(i, j), static_cast(initArray2[testIndex]), @@ -203,11 +203,11 @@ ValArrayTestCase::DoRun() // if we iterate over rows first we should find 0, 2, 4, 6, ... std::valarray initArray4{0, 2, 4, 6, 1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7}; testIndex = 0; - for (uint16_t p = 0; p < v7.GetNumPages(); ++p) + for (size_t p = 0; p < v7.GetNumPages(); ++p) { - for (uint16_t i = 0; i < v7.GetNumRows(); ++i) + for (size_t i = 0; i < v7.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v7.GetNumCols(); ++j) + for (size_t j = 0; j < v7.GetNumCols(); ++j) { NS_TEST_ASSERT_MSG_EQ(v7(i, j, p), static_cast(initArray4[testIndex]), @@ -219,11 +219,11 @@ ValArrayTestCase::DoRun() // multiplication with a scalar value with 3D array ValArray v8 = v7 * (static_cast(5.0)); - for (uint16_t p = 0; p < v8.GetNumPages(); ++p) + for (size_t p = 0; p < v8.GetNumPages(); ++p) { - for (uint16_t i = 0; i < v8.GetNumRows(); ++i) + for (size_t i = 0; i < v8.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v8.GetNumCols(); ++j) + for (size_t j = 0; j < v8.GetNumCols(); ++j) { NS_TEST_ASSERT_MSG_EQ(v7(i, j, p) * (static_cast(5.0)), v8(i, j, p), diff --git a/src/csma/model/csma-channel.cc b/src/csma/model/csma-channel.cc index 9f1fad3ce..9c9f253a6 100644 --- a/src/csma/model/csma-channel.cc +++ b/src/csma/model/csma-channel.cc @@ -310,14 +310,7 @@ CsmaChannel::GetDeviceNum(Ptr device) bool CsmaChannel::IsBusy() { - if (m_state == IDLE) - { - return false; - } - else - { - return true; - } + return m_state != IDLE; } DataRate diff --git a/src/csma/model/csma-net-device.cc b/src/csma/model/csma-net-device.cc index 33d555e15..bb0b93894 100644 --- a/src/csma/model/csma-net-device.cc +++ b/src/csma/model/csma-net-device.cc @@ -459,7 +459,7 @@ CsmaNetDevice::TransmitStart() // // Only transmit if the send side of net device is enabled // - if (IsSendEnabled() == false) + if (!IsSendEnabled()) { m_phyTxDropTrace(m_currentPkt); m_currentPkt = nullptr; @@ -512,7 +512,7 @@ CsmaNetDevice::TransmitStart() // The channel is free, transmit the packet // m_phyTxBeginTrace(m_currentPkt); - if (m_channel->TransmitStart(m_currentPkt, m_deviceId) == false) + if (!m_channel->TransmitStart(m_currentPkt, m_deviceId)) { NS_LOG_WARN("Channel TransmitStart returns an error"); m_phyTxDropTrace(m_currentPkt); @@ -718,7 +718,7 @@ CsmaNetDevice::Receive(Ptr packet, Ptr senderDevice) // // Only receive if the send side of net device is enabled // - if (IsReceiveEnabled() == false) + if (!IsReceiveEnabled()) { m_phyRxDropTrace(packet); return; @@ -974,7 +974,7 @@ CsmaNetDevice::SendFrom(Ptr packet, // // Only transmit if send side of net device is enabled // - if (IsSendEnabled() == false) + if (!IsSendEnabled()) { m_macTxDropTrace(packet); return false; @@ -990,7 +990,7 @@ CsmaNetDevice::SendFrom(Ptr packet, // Place the packet to be sent on the send queue. Note that the // queue may fire a drop trace, but we will too. // - if (m_queue->Enqueue(packet) == false) + if (!m_queue->Enqueue(packet)) { m_macTxDropTrace(packet); return false; @@ -1003,7 +1003,7 @@ CsmaNetDevice::SendFrom(Ptr packet, // if (m_txMachineState == READY) { - if (m_queue->IsEmpty() == false) + if (!m_queue->IsEmpty()) { Ptr packet = m_queue->Dequeue(); NS_ASSERT_MSG(packet, diff --git a/src/csma/test/examples-to-run.py b/src/csma/test/examples-to-run.py index eba7b5b77..3e49f1972 100644 --- a/src/csma/test/examples-to-run.py +++ b/src/csma/test/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/src/dsdv/examples/dsdv-manet.cc b/src/dsdv/examples/dsdv-manet.cc index 63ca9ef19..63b6bcca5 100644 --- a/src/dsdv/examples/dsdv-manet.cc +++ b/src/dsdv/examples/dsdv-manet.cc @@ -29,7 +29,6 @@ */ #include "ns3/applications-module.h" -#include "ns3/config-store-module.h" #include "ns3/core-module.h" #include "ns3/dsdv-helper.h" #include "ns3/internet-module.h" diff --git a/src/dsdv/model/dsdv-routing-protocol.cc b/src/dsdv/model/dsdv-routing-protocol.cc index 0548066e6..85080b221 100644 --- a/src/dsdv/model/dsdv-routing-protocol.cc +++ b/src/dsdv/model/dsdv-routing-protocol.cc @@ -391,10 +391,10 @@ bool RoutingProtocol::RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) { NS_LOG_FUNCTION(m_mainAddress << " received packet " << p->GetUid() << " from " << header.GetSource() << " on interface " << idev->GetAddress() @@ -419,7 +419,7 @@ RoutingProtocol::RouteInput(Ptr p, } // Deferred route request - if (EnableBuffering == true && idev == m_lo) + if (EnableBuffering && idev == m_lo) { DeferredRouteOutputTag tag; if (p->PeekPacketTag(tag)) @@ -449,7 +449,7 @@ RoutingProtocol::RouteInput(Ptr p, if (dst == iface.GetBroadcast() || dst.IsBroadcast()) { Ptr packet = p->Copy(); - if (lcb.IsNull() == false) + if (!lcb.IsNull()) { NS_LOG_LOGIC("Broadcast local delivery to " << iface.GetLocal()); lcb(p, header, iif); @@ -482,7 +482,7 @@ RoutingProtocol::RouteInput(Ptr p, if (m_ipv4->IsDestinationAddress(dst, iif)) { - if (lcb.IsNull() == false) + if (!lcb.IsNull()) { NS_LOG_LOGIC("Unicast local delivery to " << dst); lcb(p, header, iif); @@ -497,7 +497,7 @@ RoutingProtocol::RouteInput(Ptr p, } // Check if input device supports IP forwarding - if (m_ipv4->IsForwarding(iif) == false) + if (!m_ipv4->IsForwarding(iif)) { NS_LOG_LOGIC("Forwarding disabled for this interface"); ecb(p, header, Socket::ERROR_NOROUTETOHOST); @@ -627,7 +627,7 @@ RoutingProtocol::RecvDsdv(Ptr socket) EventId event; bool permanentTableVerifier = m_routingTable.LookupRoute(dsdvHeader.GetDst(), fwdTableEntry); - if (permanentTableVerifier == false) + if (!permanentTableVerifier) { if (dsdvHeader.GetDstSeqno() % 2 != 1) { @@ -860,8 +860,8 @@ RoutingProtocol::SendTriggeredUpdate() << " SeqNo:" << i->second.GetSeqNo() << " HopCount:" << i->second.GetHop() + 1); RoutingTableEntry temp = i->second; - if ((i->second.GetEntriesChanged() == true) && - (!m_advRoutingTable.AnyRunningEvent(temp.GetDestination()))) + if (i->second.GetEntriesChanged() && + !m_advRoutingTable.AnyRunningEvent(temp.GetDestination())) { dsdvHeader.SetDst(i->second.GetDestination()); dsdvHeader.SetDstSeqno(i->second.GetSeqNo()); @@ -1287,8 +1287,8 @@ RoutingProtocol::MergeTriggerPeriodicUpdates() ++i) { RoutingTableEntry advEntry = i->second; - if ((advEntry.GetEntriesChanged() == true) && - (!m_advRoutingTable.AnyRunningEvent(advEntry.GetDestination()))) + if (advEntry.GetEntriesChanged() && + !m_advRoutingTable.AnyRunningEvent(advEntry.GetDestination())) { if (!(advEntry.GetSeqNo() % 2)) { diff --git a/src/dsdv/model/dsdv-routing-protocol.h b/src/dsdv/model/dsdv-routing-protocol.h index e8b285210..3af825297 100644 --- a/src/dsdv/model/dsdv-routing-protocol.h +++ b/src/dsdv/model/dsdv-routing-protocol.h @@ -87,10 +87,10 @@ class RoutingProtocol : public Ipv4RoutingProtocol bool RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override; + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override; void PrintRoutingTable(Ptr stream, Time::Unit unit = Time::S) const override; void NotifyInterfaceUp(uint32_t interface) override; diff --git a/src/dsdv/model/dsdv-rtable.cc b/src/dsdv/model/dsdv-rtable.cc index 47a2e9c75..18dc1af0b 100644 --- a/src/dsdv/model/dsdv-rtable.cc +++ b/src/dsdv/model/dsdv-rtable.cc @@ -101,7 +101,7 @@ RoutingTable::LookupRoute(Ipv4Address id, RoutingTableEntry& rt, bool forRouteIn { return false; } - if (forRouteInput == true && id == i->second.GetInterface().GetBroadcast()) + if (forRouteInput && id == i->second.GetInterface().GetBroadcast()) { return false; } @@ -112,12 +112,7 @@ RoutingTable::LookupRoute(Ipv4Address id, RoutingTableEntry& rt, bool forRouteIn bool RoutingTable::DeleteRoute(Ipv4Address dst) { - if (m_ipv4AddressEntry.erase(dst) != 0) - { - // NS_LOG_DEBUG("Route erased"); - return true; - } - return false; + return m_ipv4AddressEntry.erase(dst) != 0; } uint32_t @@ -329,14 +324,7 @@ RoutingTable::AnyRunningEvent(Ipv4Address address) return false; } event = i->second; - if (event.IsRunning()) - { - return true; - } - else - { - return false; - } + return event.IsRunning(); } bool diff --git a/src/dsdv/model/dsdv-rtable.h b/src/dsdv/model/dsdv-rtable.h index 7c2b29253..4046e2502 100644 --- a/src/dsdv/model/dsdv-rtable.h +++ b/src/dsdv/model/dsdv-rtable.h @@ -353,7 +353,7 @@ class RoutingTable * \param id destination address * \param rt entry with destination address dst, if exists * \param forRouteInput for routing input - * \return true on success + * \return true onns3 success */ bool LookupRoute(Ipv4Address id, RoutingTableEntry& rt, bool forRouteInput); /** diff --git a/src/dsr/model/dsr-gratuitous-reply-table.h b/src/dsr/model/dsr-gratuitous-reply-table.h index 729d0d427..6bf9b0329 100644 --- a/src/dsr/model/dsr-gratuitous-reply-table.h +++ b/src/dsr/model/dsr-gratuitous-reply-table.h @@ -132,7 +132,7 @@ class DsrGraReply : public Object * \param b GraReplyEntry entry * \return true if expired, false otherwise */ - bool operator()(const struct GraReplyEntry& b) const + bool operator()(const GraReplyEntry& b) const { return (b.m_gratReplyHoldoff < Simulator::Now()); } diff --git a/src/dsr/model/dsr-option-header.cc b/src/dsr/model/dsr-option-header.cc index f12d092ac..3d2619f0d 100644 --- a/src/dsr/model/dsr-option-header.cc +++ b/src/dsr/model/dsr-option-header.cc @@ -417,14 +417,11 @@ DsrOptionRreqHeader::Deserialize(Buffer::Iterator start) m_identification = i.ReadNtohU16(); ReadFrom(i, m_target); - uint8_t index = 0; - for (std::vector::iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end(); - it++) + for (std::size_t index = 0; index < m_ipv4Address.size(); index++) { i.Read(buff, 4); - m_address = it->Deserialize(buff); - SetNodeAddress(index, m_address); - ++index; + m_address = Ipv4Address::Deserialize(buff); + SetNodeAddress(static_cast(index), m_address); } return GetSerializedSize(); @@ -555,14 +552,11 @@ DsrOptionRrepHeader::Deserialize(Buffer::Iterator start) i.ReadU8(); i.ReadU8(); - uint8_t index = 0; - for (std::vector::iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end(); - it++) + for (std::size_t index = 0; index < m_ipv4Address.size(); index++) { i.Read(buff, 4); - m_address = it->Deserialize(buff); - SetNodeAddress(index, m_address); - ++index; + m_address = Ipv4Address::Deserialize(buff); + SetNodeAddress(static_cast(index), m_address); } return GetSerializedSize(); @@ -718,14 +712,11 @@ DsrOptionSRHeader::Deserialize(Buffer::Iterator start) m_salvage = i.ReadU8(); m_segmentsLeft = i.ReadU8(); - uint8_t index = 0; - for (std::vector::iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end(); - it++) + for (std::size_t index = 0; index < m_ipv4Address.size(); index++) { i.Read(buff, 4); - m_address = it->Deserialize(buff); - SetNodeAddress(index, m_address); - ++index; + m_address = Ipv4Address::Deserialize(buff); + SetNodeAddress(static_cast(index), m_address); } return GetSerializedSize(); @@ -1018,25 +1009,25 @@ DsrOptionRerrUnreachHeader::GetAlignment() const return retVal; } -NS_OBJECT_ENSURE_REGISTERED(DsrOptionRerrUnsupportHeader); +NS_OBJECT_ENSURE_REGISTERED(DsrOptionRerrUnsupportedHeader); TypeId -DsrOptionRerrUnsupportHeader::GetTypeId() +DsrOptionRerrUnsupportedHeader::GetTypeId() { - static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrUnsupportHeader") - .AddConstructor() + static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrUnsupportedHeader") + .AddConstructor() .SetParent() .SetGroupName("Dsr"); return tid; } TypeId -DsrOptionRerrUnsupportHeader::GetInstanceTypeId() const +DsrOptionRerrUnsupportedHeader::GetInstanceTypeId() const { return GetTypeId(); } -DsrOptionRerrUnsupportHeader::DsrOptionRerrUnsupportHeader() +DsrOptionRerrUnsupportedHeader::DsrOptionRerrUnsupportedHeader() : m_salvage(0) { SetType(3); @@ -1044,60 +1035,60 @@ DsrOptionRerrUnsupportHeader::DsrOptionRerrUnsupportHeader() SetErrorType(3); } -DsrOptionRerrUnsupportHeader::~DsrOptionRerrUnsupportHeader() +DsrOptionRerrUnsupportedHeader::~DsrOptionRerrUnsupportedHeader() { } void -DsrOptionRerrUnsupportHeader::SetSalvage(uint8_t salvage) +DsrOptionRerrUnsupportedHeader::SetSalvage(uint8_t salvage) { m_salvage = salvage; } uint8_t -DsrOptionRerrUnsupportHeader::GetSalvage() const +DsrOptionRerrUnsupportedHeader::GetSalvage() const { return m_salvage; } void -DsrOptionRerrUnsupportHeader::SetErrorSrc(Ipv4Address errorSrcAddress) +DsrOptionRerrUnsupportedHeader::SetErrorSrc(Ipv4Address errorSrcAddress) { m_errorSrcAddress = errorSrcAddress; } Ipv4Address -DsrOptionRerrUnsupportHeader::GetErrorSrc() const +DsrOptionRerrUnsupportedHeader::GetErrorSrc() const { return m_errorSrcAddress; } void -DsrOptionRerrUnsupportHeader::SetErrorDst(Ipv4Address errorDstAddress) +DsrOptionRerrUnsupportedHeader::SetErrorDst(Ipv4Address errorDstAddress) { m_errorDstAddress = errorDstAddress; } Ipv4Address -DsrOptionRerrUnsupportHeader::GetErrorDst() const +DsrOptionRerrUnsupportedHeader::GetErrorDst() const { return m_errorDstAddress; } void -DsrOptionRerrUnsupportHeader::SetUnsupported(uint16_t unsupported) +DsrOptionRerrUnsupportedHeader::SetUnsupported(uint16_t unsupported) { m_unsupported = unsupported; } uint16_t -DsrOptionRerrUnsupportHeader::GetUnsupported() const +DsrOptionRerrUnsupportedHeader::GetUnsupported() const { return m_unsupported; } void -DsrOptionRerrUnsupportHeader::Print(std::ostream& os) const +DsrOptionRerrUnsupportedHeader::Print(std::ostream& os) const { os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage @@ -1106,13 +1097,13 @@ DsrOptionRerrUnsupportHeader::Print(std::ostream& os) const } uint32_t -DsrOptionRerrUnsupportHeader::GetSerializedSize() const +DsrOptionRerrUnsupportedHeader::GetSerializedSize() const { return 16; } void -DsrOptionRerrUnsupportHeader::Serialize(Buffer::Iterator start) const +DsrOptionRerrUnsupportedHeader::Serialize(Buffer::Iterator start) const { Buffer::Iterator i = start; @@ -1126,7 +1117,7 @@ DsrOptionRerrUnsupportHeader::Serialize(Buffer::Iterator start) const } uint32_t -DsrOptionRerrUnsupportHeader::Deserialize(Buffer::Iterator start) +DsrOptionRerrUnsupportedHeader::Deserialize(Buffer::Iterator start) { Buffer::Iterator i = start; @@ -1142,7 +1133,7 @@ DsrOptionRerrUnsupportHeader::Deserialize(Buffer::Iterator start) } DsrOptionHeader::Alignment -DsrOptionRerrUnsupportHeader::GetAlignment() const +DsrOptionRerrUnsupportedHeader::GetAlignment() const { Alignment retVal = {4, 0}; return retVal; diff --git a/src/dsr/model/dsr-option-header.h b/src/dsr/model/dsr-option-header.h index 86fe5ad0d..19d8fb474 100644 --- a/src/dsr/model/dsr-option-header.h +++ b/src/dsr/model/dsr-option-header.h @@ -1028,7 +1028,7 @@ class DsrOptionRerrUnreachHeader : public DsrOptionRerrHeader \endverbatim */ -class DsrOptionRerrUnsupportHeader : public DsrOptionRerrHeader +class DsrOptionRerrUnsupportedHeader : public DsrOptionRerrHeader { public: /** @@ -1044,11 +1044,11 @@ class DsrOptionRerrUnsupportHeader : public DsrOptionRerrHeader /** * \brief Constructor. */ - DsrOptionRerrUnsupportHeader(); + DsrOptionRerrUnsupportedHeader(); /** * \brief Destructor. */ - ~DsrOptionRerrUnsupportHeader() override; + ~DsrOptionRerrUnsupportedHeader() override; /** * \brief Set the route error source address * \param errorSrcAddress The error source address @@ -1335,7 +1335,7 @@ class DsrOptionAckHeader : public DsrOptionHeader Ipv4Address m_realDstAddress; }; -static inline std::ostream& +[[maybe_unused]] static inline std::ostream& operator<<(std::ostream& os, const DsrOptionSRHeader& sr) { sr.Print(os); diff --git a/src/dsr/model/dsr-options.cc b/src/dsr/model/dsr-options.cc index 08bfdb3e4..e5b248a15 100644 --- a/src/dsr/model/dsr-options.cc +++ b/src/dsr/model/dsr-options.cc @@ -58,6 +58,7 @@ #include "ns3/udp-header.h" #include "ns3/uinteger.h" +#include #include #include #include @@ -164,18 +165,10 @@ bool DsrOptions::ReverseRoutes(std::vector& vec) { NS_LOG_FUNCTION(this); - std::vector vec2(vec); - vec.clear(); // To ensure vec is empty before start - for (std::vector::reverse_iterator ri = vec2.rbegin(); ri != vec2.rend(); ++ri) - { - vec.push_back(*ri); - } - if ((vec.size() == vec2.size()) && (vec.front() == vec2.back())) - { - return true; - } - return false; + std::reverse(vec.begin(), vec.end()); + + return true; } Ipv4Address @@ -190,23 +183,22 @@ DsrOptions::SearchNextHop(Ipv4Address ipv4Address, std::vector& vec nextHop = vec[1]; return nextHop; } - else + + if (ipv4Address == vec.back()) { - if (ipv4Address == vec.back()) + NS_LOG_DEBUG("We have reached to the final destination " << ipv4Address << " " + << vec.back()); + return ipv4Address; + } + for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + { + if (ipv4Address == (*i)) { - NS_LOG_DEBUG("We have reached to the final destination " << ipv4Address << " " - << vec.back()); - return ipv4Address; - } - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) - { - if (ipv4Address == (*i)) - { - nextHop = *(++i); - return nextHop; - } + nextHop = *(++i); + return nextHop; } } + NS_LOG_DEBUG("next hop address not found, route corrupted"); Ipv4Address none = "0.0.0.0"; return none; @@ -223,17 +215,16 @@ DsrOptions::ReverseSearchNextHop(Ipv4Address ipv4Address, std::vector::reverse_iterator ri = vec.rbegin(); ri != vec.rend(); ++ri) { - for (std::vector::reverse_iterator ri = vec.rbegin(); ri != vec.rend(); ++ri) + if (ipv4Address == (*ri)) { - if (ipv4Address == (*ri)) - { - nextHop = *(++ri); - return nextHop; - } + nextHop = *(++ri); + return nextHop; } } + NS_LOG_DEBUG("next hop address not found, route corrupted"); Ipv4Address none = "0.0.0.0"; return none; @@ -292,10 +283,6 @@ DsrOptions::IfDuplicates(std::vector& vec, std::vector { return true; } - else - { - continue; - } } } return false; @@ -311,10 +298,6 @@ DsrOptions::CheckDuplicates(Ipv4Address ipv4Address, std::vector& v { return true; } - else - { - continue; - } } return false; } @@ -335,31 +318,22 @@ DsrOptions::RemoveDuplicates(std::vector& vec) vec.push_back(*i); continue; } - else + + for (std::vector::iterator j = vec.begin(); j != vec.end(); ++j) { - for (std::vector::iterator j = vec.begin(); j != vec.end(); ++j) + if ((*i) == (*j)) { - if ((*i) == (*j)) + if ((j + 1) != vec.end()) { - if ((j + 1) != vec.end()) - { - vec.erase(j + 1, vec.end()); // Automatic shorten the route - break; - } - else - { - break; - } - } - else if (j == (vec.end() - 1)) - { - vec.push_back(*i); - break; - } - else - { - continue; + vec.erase(j + 1, vec.end()); // Automatic shorten the route } + + break; + } + else if (j == (vec.end() - 1)) + { + vec.push_back(*i); + break; } } } @@ -1634,12 +1608,12 @@ DsrOptionRerr::Process(Ptr packet, /* * Remove the route error header from the packet, and get the error type */ - DsrOptionRerrUnsupportHeader rerrUnsupport; - p->RemoveHeader(rerrUnsupport); + DsrOptionRerrUnsupportedHeader rerrUnsupported; + p->RemoveHeader(rerrUnsupported); /// \todo This is for the other two error options, not supporting for now - // uint32_t rerrSize = rerrUnsupport.GetSerializedSize(); - // uint32_t serialized = DoSendError (p, rerrUnsupport, rerrSize, ipv4Address, protocol); + // uint32_t rerrSize = rerrUnsupported.GetSerializedSize(); + // uint32_t serialized = DoSendError (p, rerrUnsupported, rerrSize, ipv4Address, protocol); uint32_t serialized = 0; return serialized; } diff --git a/src/dsr/model/dsr-rcache.cc b/src/dsr/model/dsr-rcache.cc index d0cc2e1db..240385ae5 100644 --- a/src/dsr/model/dsr-rcache.cc +++ b/src/dsr/model/dsr-rcache.cc @@ -164,7 +164,6 @@ DsrRouteCache::DsrRouteCache() */ m_ntimer.SetDelay(m_delay); m_ntimer.SetFunction(&DsrRouteCache::PurgeMac, this); - m_txErrorCallback = MakeCallback(&DsrRouteCache::ProcessTxError, this); } DsrRouteCache::~DsrRouteCache() @@ -220,100 +219,95 @@ DsrRouteCache::LookupRoute(Ipv4Address id, DsrRouteCacheEntry& rt) { return LookupRoute_Link(id, rt); } - else - { - Purge(); // Purge first to remove expired entries - if (m_sortedRoutes.empty()) - { - NS_LOG_LOGIC("Route to " << id << " not found; m_sortedRoutes is empty"); - return false; - } - std::map>::const_iterator 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) - { - 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) - { - // 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) + Purge(); // Purge first to remove expired entries + if (m_sortedRoutes.empty()) + { + NS_LOG_LOGIC("Route to " << id << " not found; m_sortedRoutes is empty"); + return false; + } + std::map>::const_iterator 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) + { + 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) + { + // 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) + { + changeVector.push_back(*l); + + if (*l == id) { - if (*l != id) - { - changeVector.push_back(*l); - } - else - { - changeVector.push_back(*l); - break; - } - } - /* - * When the changed vector is smaller in size and larger than 1, which means we - * have found a route with the destination address we are looking for - */ - if ((changeVector.size() < routeVector.size()) && (changeVector.size() > 1)) - { - DsrRouteCacheEntry changeEntry; // Create the route entry - changeEntry.SetVector(changeVector); - changeEntry.SetDestination(id); - // Use the expire time from original route entry - changeEntry.SetExpireTime(k->GetExpireTime()); - // We need to add new route entry here - std::list newVector; - newVector.push_back(changeEntry); - newVector.sort(CompareRoutesExpire); // sort the route vector first - m_sortedRoutes[id] = - newVector; // Only get the first sub route and add it in route cache - NS_LOG_INFO("We have a sub-route to " << id << " add it in route cache"); + break; } } + /* + * When the changed vector is smaller in size and larger than 1, which means we + * have found a route with the destination address we are looking for + */ + if ((changeVector.size() < routeVector.size()) && (changeVector.size() > 1)) + { + DsrRouteCacheEntry changeEntry; // Create the route entry + changeEntry.SetVector(changeVector); + changeEntry.SetDestination(id); + // Use the expire time from original route entry + changeEntry.SetExpireTime(k->GetExpireTime()); + // We need to add new route entry here + std::list newVector; + newVector.push_back(changeEntry); + newVector.sort(CompareRoutesExpire); // sort the route vector first + m_sortedRoutes[id] = + newVector; // Only get the first sub route and add it in route cache + NS_LOG_INFO("We have a sub-route to " << id << " add it in route cache"); + } } } - NS_LOG_INFO("Here we check the route cache again after updated the sub routes"); - std::map>::const_iterator m = - m_sortedRoutes.find(id); - if (m == m_sortedRoutes.end()) - { - NS_LOG_LOGIC("No updated route till last time"); - return false; - } - /* - * We have a direct route to the destination address - */ - std::list rtVector = m->second; - rt = rtVector.front(); // use the first entry in the route vector - NS_LOG_LOGIC("Route to " << id << " with route size " << rtVector.size()); - return true; } + NS_LOG_INFO("Here we check the route cache again after updated the sub routes"); + std::map>::const_iterator m = + m_sortedRoutes.find(id); + if (m == m_sortedRoutes.end()) + { + NS_LOG_LOGIC("No updated route till last time"); + return false; + } + /* + * We have a direct route to the destination address + */ + std::list rtVector = m->second; + rt = rtVector.front(); // use the first entry in the route vector + NS_LOG_LOGIC("Route to " << id << " with route size " << rtVector.size()); + return true; } void DsrRouteCache::SetCacheType(std::string type) { NS_LOG_FUNCTION(this << type); - if (type == std::string("LinkCache")) + if (type == "LinkCache") { m_isLinkCache = true; } - else if (type == std::string("PathCache")) + else if (type == "PathCache") { m_isLinkCache = false; } @@ -442,13 +436,7 @@ DsrRouteCache::RebuildBestRouteTable(Ipv4Address source) } route.push_back(source); // Reverse the route - DsrRouteCacheEntry::IP_VECTOR reverseroute; - for (DsrRouteCacheEntry::IP_VECTOR::reverse_iterator j = route.rbegin(); - j != route.rend(); - ++j) - { - reverseroute.push_back(*j); - } + DsrRouteCacheEntry::IP_VECTOR reverseroute(route.rbegin(), route.rend()); NS_LOG_LOGIC("Add newly calculated best routes"); PrintVector(reverseroute); m_bestRoutesTable_link[i->first] = reverseroute; @@ -469,24 +457,22 @@ DsrRouteCache::LookupRoute_Link(Ipv4Address id, DsrRouteCacheEntry& rt) NS_LOG_INFO("No route find to " << id); return false; } - else - { - if (i->second.size() < 2) - { - NS_LOG_LOGIC("Route to " << id << " error"); - return false; - } - DsrRouteCacheEntry newEntry; // Create the route entry - newEntry.SetVector(i->second); - newEntry.SetDestination(id); - newEntry.SetExpireTime(RouteCacheTimeout); - NS_LOG_INFO("Route to " << id << " found with the length " << i->second.size()); - rt = newEntry; - std::vector path = rt.GetVector(); - PrintVector(path); - return true; + if (i->second.size() < 2) + { + NS_LOG_LOGIC("Route to " << id << " error"); + return false; } + + DsrRouteCacheEntry newEntry; // Create the route entry + newEntry.SetVector(i->second); + newEntry.SetDestination(id); + newEntry.SetExpireTime(RouteCacheTimeout); + NS_LOG_INFO("Route to " << id << " found with the length " << i->second.size()); + rt = newEntry; + std::vector path = rt.GetVector(); + PrintVector(path); + return true; } void @@ -710,55 +696,54 @@ DsrRouteCache::AddRoute(DsrRouteCacheEntry& rt) m_sortedRoutes.insert(std::make_pair(dst, rtVector)); return result.second; } + + rtVector = i->second; + NS_LOG_DEBUG("The existing route size " << rtVector.size() << " for destination address " + << dst); + /** + * \brief Drop the most aged packet when buffer reaches to max + */ + if (rtVector.size() >= m_maxEntriesEachDst) + { + RemoveLastEntry(rtVector); // Drop the last entry for the sorted route cache, the route + // has already been sorted + } + + if (FindSameRoute(rt, rtVector)) + { + NS_LOG_DEBUG( + "Find same vector, the FindSameRoute function will update the route expire time"); + return true; + } else { - rtVector = i->second; - NS_LOG_DEBUG("The existing route size " << rtVector.size() << " for destination address " - << dst); - /** - * \brief Drop the most aged packet when buffer reaches to max - */ - if (rtVector.size() >= m_maxEntriesEachDst) + // Check if the expire time for the new route has expired or not + if (rt.GetExpireTime() > Time(0)) { - RemoveLastEntry(rtVector); // Drop the last entry for the sorted route cache, the route - // has already been sorted - } - - if (FindSameRoute(rt, rtVector)) - { - NS_LOG_DEBUG( - "Find same vector, the FindSameRoute function will update the route expire time"); - return true; + rtVector.push_back(rt); + // This sort function will sort the route cache entries based on the size of route + // in each of the route entries + rtVector.sort(CompareRoutesExpire); + NS_LOG_DEBUG("The first time" << rtVector.front().GetExpireTime().As(Time::S) + << " The second time " + << rtVector.back().GetExpireTime().As(Time::S)); + NS_LOG_DEBUG("The first hop" << rtVector.front().GetVector().size() + << " The second hop " + << rtVector.back().GetVector().size()); + m_sortedRoutes.erase(dst); // erase the route entries for dst first + /** + * 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)); + return result.second; } else { - // Check if the expire time for the new route has expired or not - if (rt.GetExpireTime() > Time(0)) - { - rtVector.push_back(rt); - // This sort function will sort the route cache entries based on the size of route - // in each of the route entries - rtVector.sort(CompareRoutesExpire); - NS_LOG_DEBUG("The first time" << rtVector.front().GetExpireTime().As(Time::S) - << " The second time " - << rtVector.back().GetExpireTime().As(Time::S)); - NS_LOG_DEBUG("The first hop" << rtVector.front().GetVector().size() - << " The second hop " - << rtVector.back().GetVector().size()); - m_sortedRoutes.erase(dst); // erase the route entries for dst first - /** - * 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)); - return result.second; - } - else - { - NS_LOG_INFO("The newly found route is already expired"); - } + NS_LOG_INFO("The newly found route is already expired"); } } + return false; } @@ -897,15 +882,12 @@ DsrRouteCache::DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, } else { + changeVector.push_back(*i); + if (*(i + 1) == unreachNode) { - changeVector.push_back(*i); break; } - else - { - changeVector.push_back(*i); - } } } /* @@ -1109,14 +1091,12 @@ DsrRouteCache::CheckUniqueAckId(Ipv4Address nextHop) m_ackIdCache[nextHop] = 1; return 1; } - else - { - uint16_t ackId = m_ackIdCache[nextHop]; - NS_LOG_LOGIC("Ack id for " << nextHop << " found in the cache has value " << ackId); - ackId++; - m_ackIdCache[nextHop] = ackId; - return ackId; - } + + uint16_t ackId = m_ackIdCache[nextHop]; + NS_LOG_LOGIC("Ack id for " << nextHop << " found in the cache has value " << ackId); + ackId++; + m_ackIdCache[nextHop] = ackId; + return ackId; } uint16_t diff --git a/src/dsr/model/dsr-rcache.h b/src/dsr/model/dsr-rcache.h index 74a71321a..43572343f 100644 --- a/src/dsr/model/dsr-rcache.h +++ b/src/dsr/model/dsr-rcache.h @@ -766,16 +766,6 @@ class DsrRouteCache : public Object */ void DelArpCache(Ptr); - /** - * \brief Get callback to ProcessTxError, this callback is trying to use the wifi mac tx error - * header to notify a link layer drop event, however, it is not fully supported yet - * \return The callback to ProcessTxError - */ - Callback GetTxErrorCallback() const - { - return m_txErrorCallback; - } - /** * Handle link failure callback * \param cb the callback to be set @@ -912,8 +902,6 @@ class DsrRouteCache : public Object */ Callback m_handleLinkFailure; ///< link failure callback - Callback m_txErrorCallback; ///< TX error callback - Timer m_ntimer; ///< Timer for neighbor's list. Schedule Purge(). std::vector m_nb; ///< vector of entries diff --git a/src/dsr/model/dsr-routing.cc b/src/dsr/model/dsr-routing.cc index e4a1c4825..11d1b7847 100644 --- a/src/dsr/model/dsr-routing.cc +++ b/src/dsr/model/dsr-routing.cc @@ -579,8 +579,6 @@ DsrRouting::DoDispose() Ptr adhoc = mac->GetObject(); if (adhoc) { - adhoc->TraceDisconnectWithoutContext("TxErrHeader", - m_routeCache->GetTxErrorCallback()); m_routeCache->DelArpCache(m_ipv4->GetInterface(i)->GetArpCache()); } } @@ -769,23 +767,22 @@ DsrRouting::SearchNextHop(Ipv4Address ipv4Address, std::vector& vec nextHop = vec[1]; return nextHop; } - else + + if (ipv4Address == vec.back()) { - if (ipv4Address == vec.back()) + NS_LOG_DEBUG("We have reached to the final destination " << ipv4Address << " " + << vec.back()); + return ipv4Address; + } + for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + { + if (ipv4Address == (*i)) { - NS_LOG_DEBUG("We have reached to the final destination " << ipv4Address << " " - << vec.back()); - return ipv4Address; - } - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) - { - if (ipv4Address == (*i)) - { - nextHop = *(++i); - return nextHop; - } + nextHop = *(++i); + return nextHop; } } + NS_LOG_DEBUG("Next hop address not found"); Ipv4Address none = "0.0.0.0"; return none; @@ -833,12 +830,10 @@ DsrRouting::GetIPfromID(uint16_t id) NS_LOG_DEBUG("Exceed the node range"); return "0.0.0.0"; } - else - { - Ptr node = NodeList::GetNode(uint32_t(id)); - Ptr ipv4 = node->GetObject(); - return ipv4->GetAddress(1, 0).GetLocal(); - } + + Ptr node = NodeList::GetNode(uint32_t(id)); + Ptr ipv4 = node->GetObject(); + return ipv4->GetAddress(1, 0).GetLocal(); } uint32_t @@ -3035,7 +3030,6 @@ DsrRouting::SendErrorRequest(DsrOptionRerrUnreachHeader& rerr, uint8_t protocol) SendPacketFromBuffer(sourceRoute, nextHop, protocol); } NS_LOG_LOGIC("Route to " << dst << " found"); - return; } else { @@ -3535,7 +3529,7 @@ DsrRouting::SendAck(uint16_t ackId, } } -enum IpL4Protocol::RxStatus +IpL4Protocol::RxStatus DsrRouting::Receive(Ptr p, const Ipv4Header& ip, Ptr incomingInterface) { NS_LOG_FUNCTION(this << p << ip << incomingInterface); @@ -3660,7 +3654,7 @@ DsrRouting::Receive(Ptr p, const Ipv4Header& ip, Ptr inco optionLength = dsrOption ->Process(p, packet, m_mainAddress, source, ip, protocol, isPromisc, promiscSource); - segmentsLeft = *(data + 3); + segmentsLeft = data[3]; if (optionLength == 0) { NS_LOG_INFO("Discard this packet"); @@ -3674,36 +3668,32 @@ DsrRouting::Receive(Ptr p, const Ipv4Header& ip, Ptr inco uint8_t nextHeader = dsrRoutingHeader.GetNextHeader(); Ptr l3proto = m_node->GetObject(); Ptr nextProto = l3proto->GetProtocol(nextHeader); - if (nextProto) - { - // we need to make a copy in the unlikely event we hit the - // RX_ENDPOINT_UNREACH code path - // Here we can use the packet that has been get off whole DSR header - enum IpL4Protocol::RxStatus status = - nextProto->Receive(copy, ip, incomingInterface); - NS_LOG_DEBUG("The receive status " << status); - switch (status) - { - case IpL4Protocol::RX_OK: - // fall through - case IpL4Protocol::RX_ENDPOINT_CLOSED: - // fall through - case IpL4Protocol::RX_CSUM_FAILED: - break; - case IpL4Protocol::RX_ENDPOINT_UNREACH: - if (ip.GetDestination().IsBroadcast() == true || - ip.GetDestination().IsMulticast() == true) - { - break; // Do not reply to broadcast or multicast - } - // Another case to suppress ICMP is a subnet-directed broadcast - } - return status; - } - else + if (!nextProto) { NS_FATAL_ERROR("Should not have 0 next protocol value"); } + + // we need to make a copy in the unlikely event we hit the + // RX_ENDPOINT_UNREACH code path + // Here we can use the packet that has been get off whole DSR header + IpL4Protocol::RxStatus status = nextProto->Receive(copy, ip, incomingInterface); + NS_LOG_DEBUG("The receive status " << status); + switch (status) + { + case IpL4Protocol::RX_OK: + // fall through + case IpL4Protocol::RX_ENDPOINT_CLOSED: + // fall through + case IpL4Protocol::RX_CSUM_FAILED: + break; + case IpL4Protocol::RX_ENDPOINT_UNREACH: + if (ip.GetDestination().IsBroadcast() || ip.GetDestination().IsMulticast()) + { + break; // Do not reply to broadcast or multicast + } + // Another case to suppress ICMP is a subnet-directed broadcast + } + return status; } else { @@ -3720,26 +3710,26 @@ DsrRouting::Receive(Ptr p, const Ipv4Header& ip, Ptr inco */ uint8_t salvage = 0; - DsrOptionRerrUnsupportHeader rerrUnsupportHeader; - rerrUnsupportHeader.SetErrorType(3); // The error type 3 means Option not supported - rerrUnsupportHeader.SetErrorSrc( + DsrOptionRerrUnsupportedHeader rerrUnsupportedHeader; + rerrUnsupportedHeader.SetErrorType(3); // The error type 3 means Option not supported + rerrUnsupportedHeader.SetErrorSrc( m_mainAddress); // The error source address is our own address - rerrUnsupportHeader.SetUnsupported(optionType); // The unsupported option type number - rerrUnsupportHeader.SetErrorDst( + rerrUnsupportedHeader.SetUnsupported(optionType); // The unsupported option type number + rerrUnsupportedHeader.SetErrorDst( src); // Error destination address is the destination of the data packet - rerrUnsupportHeader.SetSalvage( + rerrUnsupportedHeader.SetSalvage( salvage); // Set the value about whether to salvage a packet or not /* * The unknown option error is not supported currently in this implementation, and it's also * not likely to happen in simulations */ - // SendError (rerrUnsupportHeader, 0, protocol); // Send the error packet + // SendError (rerrUnsupportedHeader, 0, protocol); // Send the error packet } return IpL4Protocol::RX_OK; } -enum IpL4Protocol::RxStatus +IpL4Protocol::RxStatus DsrRouting::Receive(Ptr p, const Ipv6Header& ip, Ptr incomingInterface) { NS_LOG_FUNCTION(this << p << ip.GetSource() << ip.GetDestination() << incomingInterface); diff --git a/src/dsr/model/dsr-routing.h b/src/dsr/model/dsr-routing.h index af337022c..0b11ac889 100644 --- a/src/dsr/model/dsr-routing.h +++ b/src/dsr/model/dsr-routing.h @@ -644,9 +644,9 @@ class DsrRouting : public IpL4Protocol * Called from lower-level layers to send the packet up * in the stack. */ - enum IpL4Protocol::RxStatus Receive(Ptr p, - const Ipv4Header& header, - Ptr incomingInterface) override; + IpL4Protocol::RxStatus Receive(Ptr p, + const Ipv4Header& header, + Ptr incomingInterface) override; /** * \param p packet to forward up @@ -657,9 +657,9 @@ class DsrRouting : public IpL4Protocol * Called from lower-level layers to send the packet up * in the stack. Not implemented (IPv6). */ - enum IpL4Protocol::RxStatus Receive(Ptr p, - const Ipv6Header& header, - Ptr incomingInterface) override; + IpL4Protocol::RxStatus Receive(Ptr p, + const Ipv6Header& header, + Ptr incomingInterface) override; void SetDownTarget(IpL4Protocol::DownTargetCallback callback) override; void SetDownTarget6(IpL4Protocol::DownTargetCallback6 callback) override; diff --git a/src/dsr/model/dsr-rreq-table.cc b/src/dsr/model/dsr-rreq-table.cc index c2ae7fe76..dfb4dc0c1 100644 --- a/src/dsr/model/dsr-rreq-table.cc +++ b/src/dsr/model/dsr-rreq-table.cc @@ -145,11 +145,9 @@ DsrRreqTable::GetRreqCnt(Ipv4Address dst) NS_LOG_LOGIC("Request table entry not found"); return 0; } - else - { - RreqTableEntry rreqTableEntry = i->second; - return rreqTableEntry.m_reqNo; - } + + RreqTableEntry rreqTableEntry = i->second; + return rreqTableEntry.m_reqNo; } // ---------------------------------------------------------------------------------------------------------- @@ -168,25 +166,23 @@ DsrRreqTable::CheckUniqueRreqId(Ipv4Address dst) m_rreqIdCache[dst] = 0; return 0; } + + NS_LOG_LOGIC("Request id for " << dst << " found in the cache"); + uint32_t rreqId = m_rreqIdCache[dst]; + if (rreqId >= m_maxRreqId) + { + NS_LOG_DEBUG("The request id increase past the max value, " << m_maxRreqId + << " so reset it to 0"); + rreqId = 0; + m_rreqIdCache[dst] = rreqId; + } else { - NS_LOG_LOGIC("Request id for " << dst << " found in the cache"); - uint32_t rreqId = m_rreqIdCache[dst]; - if (rreqId >= m_maxRreqId) - { - NS_LOG_DEBUG("The request id increase past the max value, " << m_maxRreqId - << " so reset it to 0"); - rreqId = 0; - m_rreqIdCache[dst] = rreqId; - } - else - { - rreqId++; - m_rreqIdCache[dst] = rreqId; - } - NS_LOG_INFO("The Request id for " << dst << " is " << rreqId); - return rreqId; + rreqId++; + m_rreqIdCache[dst] = rreqId; } + NS_LOG_INFO("The Request id for " << dst << " is " << rreqId); + return rreqId; } uint32_t @@ -276,35 +272,32 @@ DsrRreqTable::FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id) m_sourceRreqMap[src] = receivedRreqEntryList; return false; } - else + + NS_LOG_LOGIC("Find the request table entry for " << src << ", check if it is exact duplicate"); + /* + * Drop the most aged packet when buffer reaches to max + */ + receivedRreqEntryList = i->second; + if (receivedRreqEntryList.size() >= m_requestIdSize) { - NS_LOG_LOGIC("Find the request table entry for " << src - << ", check if it is exact duplicate"); - /* - * Drop the most aged packet when buffer reaches to max - */ - receivedRreqEntryList = i->second; - if (receivedRreqEntryList.size() >= m_requestIdSize) - { - receivedRreqEntryList.pop_front(); - } - Ipv4Address src = i->first; - // We loop the receive rreq entry to find duplicate - for (std::list::const_iterator j = receivedRreqEntryList.begin(); - j != receivedRreqEntryList.end(); - ++j) - { - if (*j == rreqEntry) /// Check if we have found one duplication entry or not - { - return true; - } - } - /// if this entry is not found, we need to save the entry in the cache, and then return - /// false for the check - receivedRreqEntryList.push_back(rreqEntry); - m_sourceRreqMap[src] = receivedRreqEntryList; - return false; + receivedRreqEntryList.pop_front(); } + + // We loop the receive rreq entry to find duplicate + for (std::list::const_iterator j = receivedRreqEntryList.begin(); + j != receivedRreqEntryList.end(); + ++j) + { + if (*j == rreqEntry) /// Check if we have found one duplication entry or not + { + return true; + } + } + /// if this entry is not found, we need to save the entry in the cache, and then return + /// false for the check + receivedRreqEntryList.push_back(rreqEntry); + m_sourceRreqMap[src] = receivedRreqEntryList; + return false; } } // namespace dsr diff --git a/src/dsr/model/dsr-rreq-table.h b/src/dsr/model/dsr-rreq-table.h index eade4d39f..15b702d85 100644 --- a/src/dsr/model/dsr-rreq-table.h +++ b/src/dsr/model/dsr-rreq-table.h @@ -408,7 +408,7 @@ class DsrRreqTable : public Object * \param b BlackList entry * \return true if expired, false otherwise */ - bool operator()(const struct BlackList& b) const + bool operator()(const BlackList& b) const { return (b.m_expireTime < Simulator::Now()); } diff --git a/src/energy/helper/energy-source-container.h b/src/energy/helper/energy-source-container.h index 1ae8ff011..d955f57c8 100644 --- a/src/energy/helper/energy-source-container.h +++ b/src/energy/helper/energy-source-container.h @@ -63,7 +63,7 @@ class EnergySourceContainer : public Object /** * \param source Pointer to an EnergySource. * - * Creates an EnergySourceContianer with exactly one EnergySource previously + * Creates an EnergySourceContainer with exactly one EnergySource previously * instantiated. */ EnergySourceContainer(Ptr source); diff --git a/src/energy/model/energy-source.cc b/src/energy/model/energy-source.cc index a76b7b083..84d426539 100644 --- a/src/energy/model/energy-source.cc +++ b/src/energy/model/energy-source.cc @@ -22,9 +22,8 @@ * Modifications made by: Cristiano Tapparello */ -#include "energy-source.h" - -#include "ns3/log.h" +#include +#include namespace ns3 { @@ -168,23 +167,28 @@ EnergySource::CalculateTotalCurrent() totalCurrentA += (*i)->GetCurrentA(); } - double totalHarvestedPower = 0.0; - - std::vector>::const_iterator harvester; - for (harvester = m_harvesters.begin(); harvester != m_harvesters.end(); harvester++) + if (!m_harvesters.empty()) { - totalHarvestedPower += (*harvester)->GetPower(); + double totalHarvestedPower = 0.0; + + std::vector>::const_iterator harvester; + for (harvester = m_harvesters.begin(); harvester != m_harvesters.end(); harvester++) + { + totalHarvestedPower += (*harvester)->GetPower(); + } + + double supplyVoltage = GetSupplyVoltage(); + + if (supplyVoltage != 0) + { + double currentHarvestersA = totalHarvestedPower / supplyVoltage; + NS_LOG_DEBUG(" Total harvested power: " << totalHarvestedPower + << "| Current from harvesters: " + << currentHarvestersA); + totalCurrentA -= currentHarvestersA; + } } - NS_LOG_DEBUG("EnergySource(" << GetNode()->GetId() - << "): Total harvested power = " << totalHarvestedPower); - - double currentHarvestersA = totalHarvestedPower / GetSupplyVoltage(); - NS_LOG_DEBUG("EnergySource(" << GetNode()->GetId() - << "): Current from harvesters = " << currentHarvestersA); - - totalCurrentA -= currentHarvestersA; - return totalCurrentA; } diff --git a/src/energy/model/li-ion-energy-source.h b/src/energy/model/li-ion-energy-source.h index 78e24cb9e..24d2e36be 100644 --- a/src/energy/model/li-ion-energy-source.h +++ b/src/energy/model/li-ion-energy-source.h @@ -46,7 +46,7 @@ namespace ns3 * * * The model requires several parameters to approximates the discharge curves: - * - IntialCellVoltage, maximum voltage of the fully charged cell + * - InitialCellVoltage, maximum voltage of the fully charged cell * - NominalCellVoltage, nominal cell's voltage, is used to determine the end of the * nominal zone. * - ExpCellVoltage, cell's voltage at the end of the exponential zone diff --git a/src/energy/model/simple-device-energy-model.h b/src/energy/model/simple-device-energy-model.h index 633238024..a3fdd287a 100644 --- a/src/energy/model/simple-device-energy-model.h +++ b/src/energy/model/simple-device-energy-model.h @@ -65,7 +65,7 @@ class SimpleDeviceEnergyModel : public DeviceEnergyModel virtual Ptr GetNode() const; /** - * \brief Sets pointer to EnergySouce installed on node. + * \brief Sets pointer to EnergySource installed on node. * * \param source Pointer to EnergySource installed on node. * diff --git a/src/energy/test/examples-to-run.py b/src/energy/test/examples-to-run.py index 0b49ab771..fc59c4220 100644 --- a/src/energy/test/examples-to-run.py +++ b/src/energy/test/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/src/fd-net-device/CMakeLists.txt b/src/fd-net-device/CMakeLists.txt index a2814b4e9..d7d2c3062 100644 --- a/src/fd-net-device/CMakeLists.txt +++ b/src/fd-net-device/CMakeLists.txt @@ -1,9 +1,3 @@ -option( - NS3_DPDK - "Enable fd-net-device DPDK features" - OFF -) - set(module_enabled_features) # modulegen_customizations consumes this list check_include_file( diff --git a/src/fd-net-device/examples/fd-emu-onoff.cc b/src/fd-net-device/examples/fd-emu-onoff.cc index 8a8cd9056..4145263f8 100644 --- a/src/fd-net-device/examples/fd-emu-onoff.cc +++ b/src/fd-net-device/examples/fd-emu-onoff.cc @@ -103,7 +103,6 @@ // #include "ns3/applications-module.h" -#include "ns3/config-store-module.h" #include "ns3/core-module.h" #include "ns3/fd-net-device-module.h" #include "ns3/internet-module.h" diff --git a/src/fd-net-device/examples/fd-emu-ping.cc b/src/fd-net-device/examples/fd-emu-ping.cc index 3b9449d1b..5693248c9 100644 --- a/src/fd-net-device/examples/fd-emu-ping.cc +++ b/src/fd-net-device/examples/fd-emu-ping.cc @@ -50,7 +50,7 @@ // 1') If you run emulation in dpdk mode, use device address (eg. 0000:00.1f.6) // as device name. This address can be obtained by running `lspci` // 2) The host device must be set to promiscuous mode -// (e.g. "sudo ifconfig eth0 promisc") +// (e.g. "sudo ip link set eth0 promisc on") // 2') If you run emulation in netmap or dpdk mode, you need before to load // the netmap.ko or dpdk modules. The user is in charge to configure and // build netmap/dpdk separately. diff --git a/src/fd-net-device/examples/fd-emu-send.cc b/src/fd-net-device/examples/fd-emu-send.cc index 948af676a..be6e0cc2a 100644 --- a/src/fd-net-device/examples/fd-emu-send.cc +++ b/src/fd-net-device/examples/fd-emu-send.cc @@ -99,7 +99,7 @@ Send(Ptr dev, int level, std::string emuMode) if (level == 1) { - if (device->SendFrom(packet, sender, receiver, 0) == false) + if (!device->SendFrom(packet, sender, receiver, 0)) { failed++; } 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 eb063f28e..848f2a226 100644 --- a/src/fd-net-device/helper/dpdk-net-device-helper.h +++ b/src/fd-net-device/helper/dpdk-net-device-helper.h @@ -40,7 +40,7 @@ class DpdkNetDeviceHelper : public EmuFdNetDeviceHelper */ DpdkNetDeviceHelper(); - virtual ~DpdkNetDeviceHelper() + ~DpdkNetDeviceHelper() override { } @@ -73,7 +73,7 @@ class DpdkNetDeviceHelper : public EmuFdNetDeviceHelper * \param node The node to install the device in * \returns A container holding the added net device. */ - Ptr InstallPriv(Ptr node) const; + Ptr InstallPriv(Ptr node) const override; /** * Logical cores to use diff --git a/src/fd-net-device/helper/encode-decode.h b/src/fd-net-device/helper/encode-decode.h index 5483807a4..196d5b76d 100644 --- a/src/fd-net-device/helper/encode-decode.h +++ b/src/fd-net-device/helper/encode-decode.h @@ -18,6 +18,7 @@ #ifndef ENCODE_DECODE_H #define ENCODE_DECODE_H +#include #include namespace ns3 diff --git a/src/fd-net-device/model/dpdk-net-device.h b/src/fd-net-device/model/dpdk-net-device.h index 0be486a0a..e908f66fd 100644 --- a/src/fd-net-device/model/dpdk-net-device.h +++ b/src/fd-net-device/model/dpdk-net-device.h @@ -61,7 +61,7 @@ class DpdkNetDevice : public FdNetDevice /** * Destructor for the DpdkNetDevice. */ - ~DpdkNetDevice(); + ~DpdkNetDevice() override; /** * Check the link status of all ports in up to 9s @@ -114,20 +114,20 @@ class DpdkNetDevice : public FdNetDevice * Check the status of the link. * \return Status of the link - up/down as true/false. */ - bool IsLinkUp() const; + bool IsLinkUp() const override; /** * Free the given packet buffer. * \param buf the pointer to the buffer to be freed */ - virtual void FreeBuffer(uint8_t* buf); + void FreeBuffer(uint8_t* buf) override; /** * Allocate packet buffer. * \param len the length of the buffer * \return A pointer to the newly created buffer. */ - virtual uint8_t* AllocateBuffer(size_t len); + uint8_t* AllocateBuffer(size_t len) override; protected: /** @@ -136,7 +136,7 @@ class DpdkNetDevice : public FdNetDevice * \param length The data length. * \return The size of data written. */ - ssize_t Write(uint8_t* buffer, size_t length); + ssize_t Write(uint8_t* buffer, size_t length) override; /** * The port number of the device to be used. @@ -149,7 +149,7 @@ class DpdkNetDevice : public FdNetDevice std::string m_deviceName; private: - void DoFinishStoppingDevice(); + void DoFinishStoppingDevice() override; /** * Condition variable for Dpdk to stop */ diff --git a/src/fd-net-device/model/fd-net-device.cc b/src/fd-net-device/model/fd-net-device.cc index 5c14f0299..127441f44 100644 --- a/src/fd-net-device/model/fd-net-device.cc +++ b/src/fd-net-device/model/fd-net-device.cc @@ -570,7 +570,7 @@ FdNetDevice::SendFrom(Ptr packet, NS_LOG_FUNCTION(this << packet << src << dest << protocolNumber); NS_LOG_LOGIC("packet: " << packet << " UID: " << packet->GetUid()); - if (IsLinkUp() == false) + if (!IsLinkUp()) { m_macTxDropTrace(packet); return false; diff --git a/src/fd-net-device/test/examples-to-run.py b/src/fd-net-device/test/examples-to-run.py index 92e76667b..e1cb15080 100644 --- a/src/fd-net-device/test/examples-to-run.py +++ b/src/fd-net-device/test/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/src/flow-monitor/doc/flow-monitor.rst b/src/flow-monitor/doc/flow-monitor.rst index 91a725bee..f76882edc 100644 --- a/src/flow-monitor/doc/flow-monitor.rst +++ b/src/flow-monitor/doc/flow-monitor.rst @@ -13,7 +13,7 @@ Flow Monitor Model Description ***************** -The source code for the new module lives in the directory ``src/flow-monitor``. +The source code for the module lives in the directory ``src/flow-monitor``. The Flow Monitor module goal is to provide a flexible system to measure the performance of network protocols. The module uses probes, installed in network @@ -86,6 +86,9 @@ The L2 headers are not included in the measure. These stats will be written in XML form upon request (see the Usage section). +Due to the above design, FlowMonitor can not generate statistics when used with DSR routing +protocol (because DSR forwards packets using broadcast addresses) + The "lost" packets problem ########################## diff --git a/src/flow-monitor/model/flow-monitor.cc b/src/flow-monitor/model/flow-monitor.cc index 7a03f8499..de8460876 100644 --- a/src/flow-monitor/model/flow-monitor.cc +++ b/src/flow-monitor/model/flow-monitor.cc @@ -582,4 +582,31 @@ FlowMonitor::SerializeToXmlFile(std::string fileName, bool enableHistograms, boo os.close(); } +void +FlowMonitor::ResetAllStats() +{ + NS_LOG_FUNCTION(this); + + for (auto& iter : m_flowStats) + { + auto& flowStat = iter.second; + flowStat.delaySum = Seconds(0); + flowStat.jitterSum = Seconds(0); + flowStat.lastDelay = Seconds(0); + flowStat.txBytes = 0; + flowStat.rxBytes = 0; + flowStat.txPackets = 0; + flowStat.rxPackets = 0; + flowStat.lostPackets = 0; + flowStat.timesForwarded = 0; + flowStat.bytesDropped.clear(); + flowStat.packetsDropped.clear(); + + flowStat.delayHistogram.Clear(); + flowStat.jitterHistogram.Clear(); + flowStat.packetSizeHistogram.Clear(); + flowStat.flowInterruptionsHistogram.Clear(); + } +} + } // namespace ns3 diff --git a/src/flow-monitor/model/flow-monitor.h b/src/flow-monitor/model/flow-monitor.h index f448ee68d..5b996d282 100644 --- a/src/flow-monitor/model/flow-monitor.h +++ b/src/flow-monitor/model/flow-monitor.h @@ -274,6 +274,9 @@ class FlowMonitor : public Object /// \param enableProbes if true, include also the per-probe/flow pair statistics in the output void SerializeToXmlFile(std::string fileName, bool enableHistograms, bool enableProbes); + /// Reset all the statistics + void ResetAllStats(); + protected: void NotifyConstructionCompleted() override; void DoDispose() override; diff --git a/src/flow-monitor/test/examples-to-run.py b/src/flow-monitor/test/examples-to-run.py index 7e5c82378..e82b26201 100644 --- a/src/flow-monitor/test/examples-to-run.py +++ b/src/flow-monitor/test/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/src/internet-apps/model/dhcp-client.cc b/src/internet-apps/model/dhcp-client.cc index cc1744ea6..31c9bbf22 100644 --- a/src/internet-apps/model/dhcp-client.cc +++ b/src/internet-apps/model/dhcp-client.cc @@ -369,7 +369,7 @@ DhcpClient::OfferHandler(DhcpHeader header) NS_LOG_FUNCTION(this << header); m_offerList.push_back(header); - if (m_offered == false) + if (!m_offered) { m_discoverEvent.Cancel(); m_offered = true; diff --git a/src/internet-apps/model/dhcp-header.cc b/src/internet-apps/model/dhcp-header.cc index bbda04932..6022c9c15 100644 --- a/src/internet-apps/model/dhcp-header.cc +++ b/src/internet-apps/model/dhcp-header.cc @@ -75,7 +75,7 @@ DhcpHeader::~DhcpHeader() void DhcpHeader::SetType(uint8_t type) { - if (m_opt[OP_MSGTYPE] == false) + if (!m_opt[OP_MSGTYPE]) { m_len += 3; m_opt[OP_MSGTYPE] = true; @@ -154,7 +154,7 @@ DhcpHeader::GetYiaddr() const void DhcpHeader::SetDhcps(Ipv4Address addr) { - if (m_opt[OP_SERVID] == false) + if (!m_opt[OP_SERVID]) { m_len += 6; m_opt[OP_SERVID] = true; @@ -171,7 +171,7 @@ DhcpHeader::GetDhcps() const void DhcpHeader::SetReq(Ipv4Address addr) { - if (m_opt[OP_ADDREQ] == false) + if (!m_opt[OP_ADDREQ]) { m_len += 6; m_opt[OP_ADDREQ] = true; @@ -188,7 +188,7 @@ DhcpHeader::GetReq() const void DhcpHeader::SetMask(uint32_t addr) { - if (m_opt[OP_MASK] == false) + if (!m_opt[OP_MASK]) { m_len += 6; m_opt[OP_MASK] = true; @@ -205,7 +205,7 @@ DhcpHeader::GetMask() const void DhcpHeader::SetRouter(Ipv4Address addr) { - if (m_opt[OP_ROUTE] == false) + if (!m_opt[OP_ROUTE]) { m_len += 6; m_opt[OP_ROUTE] = true; @@ -222,7 +222,7 @@ DhcpHeader::GetRouter() const void DhcpHeader::SetLease(uint32_t time) { - if (m_opt[OP_LEASE] == false) + if (!m_opt[OP_LEASE]) { m_len += 6; m_opt[OP_LEASE] = true; @@ -239,7 +239,7 @@ DhcpHeader::GetLease() const void DhcpHeader::SetRenew(uint32_t time) { - if (m_opt[OP_RENEW] == false) + if (!m_opt[OP_RENEW]) { m_len += 6; m_opt[OP_RENEW] = true; @@ -256,7 +256,7 @@ DhcpHeader::GetRenew() const void DhcpHeader::SetRebind(uint32_t time) { - if (m_opt[OP_REBIND] == false) + if (!m_opt[OP_REBIND]) { m_len += 6; m_opt[OP_REBIND] = true; diff --git a/src/internet-apps/model/ping.h b/src/internet-apps/model/ping.h index 8a18b747a..aaf80ea72 100644 --- a/src/internet-apps/model/ping.h +++ b/src/internet-apps/model/ping.h @@ -145,7 +145,7 @@ class Ping : public Application * * \param [in] report The report information */ - typedef void (*ReportTrace)(const struct PingReport& report); + typedef void (*ReportTrace)(const PingReport& report); private: /** @@ -222,7 +222,7 @@ class Ping : public Application /// TracedCallback for drop events TracedCallback m_dropTrace; /// TracedCallback for final ping report - TracedCallback m_reportTrace; + TracedCallback m_reportTrace; /// Variable to stor verbose mode VerboseMode m_verbose{VerboseMode::VERBOSE}; /// Received packets counter diff --git a/src/internet-apps/model/radvd.cc b/src/internet-apps/model/radvd.cc index dd1a2e781..bb9f92d09 100644 --- a/src/internet-apps/model/radvd.cc +++ b/src/internet-apps/model/radvd.cc @@ -192,7 +192,7 @@ Radvd::Send(Ptr config, Ipv6Address dst, bool reschedule) { NS_LOG_FUNCTION(this << dst << reschedule); - if (reschedule == true) + if (reschedule) { config->SetLastRaTxTime(Simulator::Now()); } diff --git a/src/internet/CMakeLists.txt b/src/internet/CMakeLists.txt index 35ac7691b..8d0508e5d 100644 --- a/src/internet/CMakeLists.txt +++ b/src/internet/CMakeLists.txt @@ -262,6 +262,7 @@ endif() set(test_sources test/global-route-manager-impl-test-suite.cc test/icmp-test.cc + test/internet-stack-helper-test-suite.cc test/ipv4-address-generator-test-suite.cc test/ipv4-address-helper-test-suite.cc test/ipv4-deduplication-test.cc diff --git a/src/internet/examples/neighbor-cache-example.cc b/src/internet/examples/neighbor-cache-example.cc index 8e92a6d34..6981b58fa 100644 --- a/src/internet/examples/neighbor-cache-example.cc +++ b/src/internet/examples/neighbor-cache-example.cc @@ -283,7 +283,6 @@ #include "ns3/csma-module.h" #include "ns3/internet-module.h" #include "ns3/network-module.h" -#include "ns3/point-to-point-module.h" using namespace ns3; diff --git a/src/internet/helper/internet-stack-helper.cc b/src/internet/helper/internet-stack-helper.cc index 6ef7647b0..67b7ecd19 100644 --- a/src/internet/helper/internet-stack-helper.cc +++ b/src/internet/helper/internet-stack-helper.cc @@ -20,22 +20,22 @@ #include "internet-stack-helper.h" +#include "ipv4-global-routing-helper.h" +#include "ipv4-list-routing-helper.h" +#include "ipv4-static-routing-helper.h" +#include "ipv6-static-routing-helper.h" + #include "ns3/arp-l3-protocol.h" #include "ns3/assert.h" #include "ns3/callback.h" #include "ns3/config.h" -#include "ns3/core-config.h" #include "ns3/global-router-interface.h" #include "ns3/icmpv6-l4-protocol.h" -#include "ns3/ipv4-global-routing-helper.h" #include "ns3/ipv4-global-routing.h" -#include "ns3/ipv4-list-routing-helper.h" -#include "ns3/ipv4-static-routing-helper.h" #include "ns3/ipv4.h" #include "ns3/ipv6-extension-demux.h" #include "ns3/ipv6-extension-header.h" #include "ns3/ipv6-extension.h" -#include "ns3/ipv6-static-routing-helper.h" #include "ns3/ipv6.h" #include "ns3/log.h" #include "ns3/names.h" @@ -129,7 +129,6 @@ InternetStackHelper::InternetStackHelper() void InternetStackHelper::Initialize() { - SetTcp("ns3::TcpL4Protocol"); Ipv4StaticRoutingHelper staticRouting; Ipv4GlobalRoutingHelper globalRouting; Ipv4ListRoutingHelper listRouting; @@ -152,7 +151,6 @@ InternetStackHelper::InternetStackHelper(const InternetStackHelper& o) m_routingv6 = o.m_routingv6->Copy(); m_ipv4Enabled = o.m_ipv4Enabled; m_ipv6Enabled = o.m_ipv6Enabled; - m_tcpFactory = o.m_tcpFactory; m_ipv4ArpJitterEnabled = o.m_ipv4ArpJitterEnabled; m_ipv6NsRsJitterEnabled = o.m_ipv6NsRsJitterEnabled; } @@ -266,12 +264,6 @@ InternetStackHelper::AssignStreams(NodeContainer c, int64_t stream) return (currentStream - stream); } -void -InternetStackHelper::SetTcp(const std::string tid) -{ - m_tcpFactory.SetTypeId(tid); -} - void InternetStackHelper::Install(NodeContainer c) const { @@ -290,6 +282,12 @@ InternetStackHelper::InstallAll() const void InternetStackHelper::CreateAndAggregateObjectFromTypeId(Ptr node, const std::string typeId) { + TypeId tid = TypeId::LookupByName(typeId); + if (node->GetObject(tid)) + { + return; + } + ObjectFactory factory; factory.SetTypeId(typeId); Ptr protocol = factory.Create(); @@ -301,42 +299,33 @@ InternetStackHelper::Install(Ptr node) const { if (m_ipv4Enabled) { - if (node->GetObject()) - { - NS_FATAL_ERROR("InternetStackHelper::Install (): Aggregating " - "an InternetStack to a node with an existing Ipv4 object"); - return; - } - + /* IPv4 stack */ CreateAndAggregateObjectFromTypeId(node, "ns3::ArpL3Protocol"); CreateAndAggregateObjectFromTypeId(node, "ns3::Ipv4L3Protocol"); CreateAndAggregateObjectFromTypeId(node, "ns3::Icmpv4L4Protocol"); - if (m_ipv4ArpJitterEnabled == false) + if (!m_ipv4ArpJitterEnabled) { Ptr arp = node->GetObject(); NS_ASSERT(arp); arp->SetAttribute("RequestJitter", StringValue("ns3::ConstantRandomVariable[Constant=0.0]")); } + // Set routing Ptr ipv4 = node->GetObject(); - Ptr ipv4Routing = m_routing->Create(node); - ipv4->SetRoutingProtocol(ipv4Routing); + if (!ipv4->GetRoutingProtocol()) + { + Ptr ipv4Routing = m_routing->Create(node); + ipv4->SetRoutingProtocol(ipv4Routing); + } } if (m_ipv6Enabled) { /* IPv6 stack */ - if (node->GetObject()) - { - NS_FATAL_ERROR("InternetStackHelper::Install (): Aggregating " - "an InternetStack to a node with an existing Ipv6 object"); - return; - } - CreateAndAggregateObjectFromTypeId(node, "ns3::Ipv6L3Protocol"); CreateAndAggregateObjectFromTypeId(node, "ns3::Icmpv6L4Protocol"); - if (m_ipv6NsRsJitterEnabled == false) + if (!m_ipv6NsRsJitterEnabled) { Ptr icmpv6l4 = node->GetObject(); NS_ASSERT(icmpv6l4); @@ -345,9 +334,11 @@ InternetStackHelper::Install(Ptr node) const } // Set routing Ptr ipv6 = node->GetObject(); - Ptr ipv6Routing = m_routingv6->Create(node); - ipv6->SetRoutingProtocol(ipv6Routing); - + if (!ipv6->GetRoutingProtocol()) + { + Ptr ipv6Routing = m_routingv6->Create(node); + ipv6->SetRoutingProtocol(ipv6Routing); + } /* register IPv6 extensions and options */ ipv6->RegisterExtensions(); ipv6->RegisterOptions(); @@ -357,9 +348,12 @@ InternetStackHelper::Install(Ptr node) const { CreateAndAggregateObjectFromTypeId(node, "ns3::TrafficControlLayer"); CreateAndAggregateObjectFromTypeId(node, "ns3::UdpL4Protocol"); - node->AggregateObject(m_tcpFactory.Create()); - Ptr factory = CreateObject(); - node->AggregateObject(factory); + CreateAndAggregateObjectFromTypeId(node, "ns3::TcpL4Protocol"); + if (!node->GetObject()) + { + Ptr factory = CreateObject(); + node->AggregateObject(factory); + } } if (m_ipv4Enabled) diff --git a/src/internet/helper/internet-stack-helper.h b/src/internet/helper/internet-stack-helper.h index a158837c9..e8cd81659 100644 --- a/src/internet/helper/internet-stack-helper.h +++ b/src/internet/helper/internet-stack-helper.h @@ -144,8 +144,8 @@ class InternetStackHelper : public PcapHelperForIpv4, /** * Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes - * onto the provided node. This method will assert if called on a node that - * already has an Ipv4 object aggregated to it. + * onto the provided node. This method will do nothing if the stacks are already installed, + * and will not overwrite existing stacks parameters. * * \param nodeName The name of the node on which to install the stack. */ @@ -153,8 +153,8 @@ class InternetStackHelper : public PcapHelperForIpv4, /** * Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes - * onto the provided node. This method will assert if called on a node that - * already has an Ipv4 object aggregated to it. + * onto the provided node. This method will do nothing if the stacks are already installed, + * and will not overwrite existing stacks parameters. * * \param node The node on which to install the stack. */ @@ -162,9 +162,8 @@ class InternetStackHelper : public PcapHelperForIpv4, /** * For each node in the input container, aggregate implementations of the - * ns3::Ipv4, ns3::Ipv6, ns3::Udp, and, ns3::Tcp classes. The program will assert - * if this method is called on a container with a node that already has - * an Ipv4 object aggregated to it. + * ns3::Ipv4, ns3::Ipv6, ns3::Udp, and, ns3::Tcp classes. This method will do nothing if the + * stacks are already installed, and will not overwrite existing stacks parameters. * * \param c NodeContainer that holds the set of nodes on which to install the * new stacks. @@ -176,19 +175,6 @@ class InternetStackHelper : public PcapHelperForIpv4, */ void InstallAll() const; - /** - * \brief set the Tcp stack which will not need any other parameter. - * - * This function sets up the tcp stack to the given TypeId. It should not be - * used for NSC stack setup because the nsc stack needs the Library attribute - * to be setup, please use instead the version that requires an attribute - * and a value. If you choose to use this function anyways to set nsc stack - * the default value for the linux library will be used: "liblinux2.6.26.so". - * - * \param tid the type id, typically it is set to "ns3::TcpL4Protocol" - */ - void SetTcp(std::string tid); - /** * \brief Enable/disable IPv4 stack install. * \param enable enable state @@ -290,11 +276,6 @@ class InternetStackHelper : public PcapHelperForIpv4, */ void Initialize(); - /** - * \brief TCP objects factory - */ - ObjectFactory m_tcpFactory; - /** * \brief IPv4 routing helper. */ @@ -306,7 +287,8 @@ class InternetStackHelper : public PcapHelperForIpv4, const Ipv6RoutingHelper* m_routingv6; /** - * \brief create an object from its TypeId and aggregates it to the node + * \brief create an object from its TypeId and aggregates it to the node. Does nothing if + * an object of the same type is already aggregated to the node. * \param node the node * \param typeId the object TypeId */ diff --git a/src/internet/helper/ipv6-interface-container.cc b/src/internet/helper/ipv6-interface-container.cc index 4d955ace6..9018c3baf 100644 --- a/src/internet/helper/ipv6-interface-container.cc +++ b/src/internet/helper/ipv6-interface-container.cc @@ -21,7 +21,8 @@ #include "ipv6-interface-container.h" -#include "ns3/ipv6-static-routing-helper.h" +#include "ipv6-static-routing-helper.h" + #include "ns3/names.h" #include "ns3/node-list.h" diff --git a/src/internet/helper/neighbor-cache-helper.cc b/src/internet/helper/neighbor-cache-helper.cc index 8bf615915..a56eb310a 100644 --- a/src/internet/helper/neighbor-cache-helper.cc +++ b/src/internet/helper/neighbor-cache-helper.cc @@ -17,7 +17,7 @@ * Author: Zhiheng Dong */ -#include "ns3/neighbor-cache-helper.h" +#include "neighbor-cache-helper.h" #include "ns3/assert.h" #include "ns3/channel-list.h" diff --git a/src/internet/helper/ripng-helper.cc b/src/internet/helper/ripng-helper.cc index 270e57dff..275fed0e4 100644 --- a/src/internet/helper/ripng-helper.cc +++ b/src/internet/helper/ripng-helper.cc @@ -24,6 +24,8 @@ #include "ns3/node.h" #include "ns3/ripng.h" +#include + namespace ns3 { diff --git a/src/internet/helper/ripng-helper.h b/src/internet/helper/ripng-helper.h index 81d66a42f..e1761ec2d 100644 --- a/src/internet/helper/ripng-helper.h +++ b/src/internet/helper/ripng-helper.h @@ -25,6 +25,8 @@ #include "ns3/node.h" #include "ns3/object-factory.h" +#include + namespace ns3 { diff --git a/src/internet/model/arp-cache.cc b/src/internet/model/arp-cache.cc index cbae1b33c..020a5db62 100644 --- a/src/internet/model/arp-cache.cc +++ b/src/internet/model/arp-cache.cc @@ -18,7 +18,6 @@ */ #include "arp-cache.h" -#include "arp-header.h" #include "ipv4-header.h" #include "ipv4-interface.h" @@ -551,11 +550,7 @@ ArpCache::Entry::IsExpired() const Time timeout = GetTimeout(); Time delta = Simulator::Now() - m_lastSeen; NS_LOG_DEBUG("delta=" << delta.GetSeconds() << "s"); - if (delta > timeout) - { - return true; - } - return false; + return delta > timeout; } ArpCache::Ipv4PayloadHeaderPair diff --git a/src/internet/model/arp-l3-protocol.cc b/src/internet/model/arp-l3-protocol.cc index 958684326..3031246fc 100644 --- a/src/internet/model/arp-l3-protocol.cc +++ b/src/internet/model/arp-l3-protocol.cc @@ -276,7 +276,7 @@ ArpL3Protocol::Receive(Ptr device, break; } } - if (found == false) + if (!found) { NS_LOG_LOGIC("node=" << m_node->GetId() << ", got request from " << arp.GetSourceIpv4Address() << " for unknown address " diff --git a/src/internet/model/global-route-manager-impl.cc b/src/internet/model/global-route-manager-impl.cc index ddb6ea025..cefa5673c 100644 --- a/src/internet/model/global-route-manager-impl.cc +++ b/src/internet/model/global-route-manager-impl.cc @@ -26,14 +26,13 @@ #include "candidate-queue.h" #include "global-router-interface.h" #include "ipv4-global-routing.h" +#include "ipv4.h" #include "ns3/assert.h" #include "ns3/fatal-error.h" -#include "ns3/ipv4-list-routing.h" -#include "ns3/ipv4-routing-protocol.h" -#include "ns3/ipv4.h" #include "ns3/log.h" #include "ns3/node-list.h" +#include "ns3/simulator.h" #include #include @@ -1218,7 +1217,7 @@ GlobalRouteManagerImpl::SPFGetNextLink(SPFVertex* v, // skipped a previous link and moved forward to the next (which is then the // one we want). // - if (skip == false) + if (!skip) { NS_LOG_LOGIC("Returning the found link"); return l; diff --git a/src/internet/model/global-router-interface.cc b/src/internet/model/global-router-interface.cc index 16d7a2cf0..1836cd777 100644 --- a/src/internet/model/global-router-interface.cc +++ b/src/internet/model/global-router-interface.cc @@ -20,13 +20,13 @@ #include "global-router-interface.h" #include "ipv4-global-routing.h" +#include "ipv4.h" #include "loopback-net-device.h" #include "ns3/abort.h" #include "ns3/assert.h" #include "ns3/bridge-net-device.h" #include "ns3/channel.h" -#include "ns3/ipv4.h" #include "ns3/log.h" #include "ns3/net-device.h" #include "ns3/node-list.h" @@ -791,7 +791,7 @@ GlobalRouter::ProcessSingleBroadcastLink(Ptr nd, // is a transit network. // ClearBridgesVisited(); - if (AnotherRouterOnLink(nd) == false) + if (!AnotherRouterOnLink(nd)) { // // This is a net device connected to a stub network @@ -831,29 +831,29 @@ GlobalRouter::ProcessSingleBroadcastLink(Ptr nd, // case. // ClearBridgesVisited(); - Ipv4Address desigRtr; - desigRtr = FindDesignatedRouterForLink(nd); + Ipv4Address designatedRtr; + designatedRtr = FindDesignatedRouterForLink(nd); // // Let's double-check that any designated router we find out on our // network is really on our network. // - if (desigRtr != "255.255.255.255") + if (designatedRtr != "255.255.255.255") { Ipv4Address networkHere = addrLocal.CombineMask(maskLocal); - Ipv4Address networkThere = desigRtr.CombineMask(maskLocal); + Ipv4Address networkThere = designatedRtr.CombineMask(maskLocal); NS_ABORT_MSG_UNLESS( networkHere == networkThere, "GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion (" - << addrLocal << "/" << maskLocal.GetPrefixLength() << ", " << desigRtr << "/" - << maskLocal.GetPrefixLength() << ")"); + << addrLocal << "/" << maskLocal.GetPrefixLength() << ", " << designatedRtr + << "/" << maskLocal.GetPrefixLength() << ")"); } - if (desigRtr == addrLocal) + if (designatedRtr == addrLocal) { c.Add(nd); NS_LOG_LOGIC("Node " << node->GetId() << " elected a designated router"); } - plr->SetLinkId(desigRtr); + plr->SetLinkId(designatedRtr); // // OSPF says that the Link Data is this router's own IP address. @@ -921,7 +921,7 @@ GlobalRouter::ProcessBridgedBroadcastLink(Ptr nd, // bool areTransitNetwork = false; - Ipv4Address desigRtr ("255.255.255.255"); + Ipv4Address designatedRtr ("255.255.255.255"); for (uint32_t i = 0; i < bnd->GetNBridgePorts (); ++i) { @@ -945,24 +945,24 @@ GlobalRouter::ProcessBridgedBroadcastLink(Ptr nd, // all. // ClearBridgesVisited (); - Ipv4Address desigRtrTemp = FindDesignatedRouterForLink (ndTemp); + Ipv4Address designatedRtrTemp = FindDesignatedRouterForLink (ndTemp); // // Let's double-check that any designated router we find out on our // network is really on our network. // - if (desigRtrTemp != "255.255.255.255") + if (designatedRtrTemp != "255.255.255.255") { Ipv4Address networkHere = addrLocal.CombineMask (maskLocal); - Ipv4Address networkThere = desigRtrTemp.CombineMask (maskLocal); + Ipv4Address networkThere = designatedRtrTemp.CombineMask (maskLocal); NS_ABORT_MSG_UNLESS (networkHere == networkThere, "GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion (" << addrLocal << "/" << maskLocal.GetPrefixLength () << ", " << - desigRtrTemp << "/" << maskLocal.GetPrefixLength () << ")"); + designatedRtrTemp << "/" << maskLocal.GetPrefixLength () << ")"); } - if (desigRtrTemp < desigRtr) + if (designatedRtrTemp < designatedRtr) { - desigRtr = desigRtrTemp; + designatedRtr = designatedRtrTemp; } } } @@ -1013,12 +1013,12 @@ GlobalRouter::ProcessBridgedBroadcastLink(Ptr nd, // gets the IP interface address of the designated router in this // case. // - if (desigRtr == addrLocal) + if (designatedRtr == addrLocal) { c.Add (nd); NS_LOG_LOGIC ("Node " << node->GetId () << " elected a designated router"); } - plr->SetLinkId (desigRtr); + plr->SetLinkId (designatedRtr); // // OSPF says that the Link Data is this router's own IP address. @@ -1290,7 +1290,7 @@ GlobalRouter::FindAllNonBridgedDevicesOnLink(Ptr ch) const Ptr nd = ch->GetDevice(i); NS_LOG_LOGIC("checking to see if the device " << nd << " is bridged"); Ptr bnd = NetDeviceIsBridged(nd); - if (bnd && BridgeHasAlreadyBeenVisited(bnd) == false) + if (bnd && !BridgeHasAlreadyBeenVisited(bnd)) { NS_LOG_LOGIC("Device is bridged by BridgeNetDevice " << bnd << " with " << bnd->GetNBridgePorts() << " ports"); @@ -1337,7 +1337,7 @@ GlobalRouter::FindDesignatedRouterForLink(Ptr ndLocal) const NS_LOG_LOGIC("Looking for designated router off of net device " << ndLocal << " on node " << ndLocal->GetNode()->GetId()); - Ipv4Address desigRtr("255.255.255.255"); + Ipv4Address designatedRtr("255.255.255.255"); // // Look through all of the devices on the channel to which the net device @@ -1402,8 +1402,8 @@ GlobalRouter::FindDesignatedRouterForLink(Ptr ndLocal) const "primary one"); } Ipv4Address addrOther = ipv4->GetAddress(interfaceOther, 0).GetLocal(); - desigRtr = addrOther < desigRtr ? addrOther : desigRtr; - NS_LOG_LOGIC("designated router now " << desigRtr); + designatedRtr = addrOther < designatedRtr ? addrOther : designatedRtr; + NS_LOG_LOGIC("designated router now " << designatedRtr); } } @@ -1433,8 +1433,8 @@ GlobalRouter::FindDesignatedRouterForLink(Ptr ndLocal) const NS_LOG_LOGIC("Recursively looking for routers down bridge port " << ndBridged); Ipv4Address addrOther = FindDesignatedRouterForLink(ndBridged); - desigRtr = addrOther < desigRtr ? addrOther : desigRtr; - NS_LOG_LOGIC("designated router now " << desigRtr); + designatedRtr = addrOther < designatedRtr ? addrOther : designatedRtr; + NS_LOG_LOGIC("designated router now " << designatedRtr); } } else @@ -1466,13 +1466,13 @@ GlobalRouter::FindDesignatedRouterForLink(Ptr ndLocal) const "primary one"); } Ipv4Address addrOther = ipv4->GetAddress(interfaceOther, 0).GetLocal(); - desigRtr = addrOther < desigRtr ? addrOther : desigRtr; - NS_LOG_LOGIC("designated router now " << desigRtr); + designatedRtr = addrOther < designatedRtr ? addrOther : designatedRtr; + NS_LOG_LOGIC("designated router now " << designatedRtr); } } } } - return desigRtr; + return designatedRtr; } // diff --git a/src/internet/model/icmpv4-l4-protocol.cc b/src/internet/model/icmpv4-l4-protocol.cc index a93fe75c9..db64443a1 100644 --- a/src/internet/model/icmpv4-l4-protocol.cc +++ b/src/internet/model/icmpv4-l4-protocol.cc @@ -20,13 +20,14 @@ #include "icmpv4-l4-protocol.h" #include "ipv4-interface.h" -#include "ipv4-l3-protocol.h" #include "ipv4-raw-socket-factory-impl.h" +#include "ipv4-route.h" +#include "ipv4-routing-protocol.h" +#include "ipv4.h" +#include "ipv6-interface.h" #include "ns3/assert.h" #include "ns3/boolean.h" -#include "ns3/ipv4-route.h" -#include "ns3/ipv6-interface.h" #include "ns3/log.h" #include "ns3/node.h" #include "ns3/packet.h" @@ -289,7 +290,7 @@ Icmpv4L4Protocol::HandleTimeExceeded(Ptr p, Forward(source, icmp, 0, ipHeader, payload); } -enum IpL4Protocol::RxStatus +IpL4Protocol::RxStatus Icmpv4L4Protocol::Receive(Ptr p, const Ipv4Header& header, Ptr incomingInterface) @@ -342,7 +343,7 @@ Icmpv4L4Protocol::Receive(Ptr p, return IpL4Protocol::RX_OK; } -enum IpL4Protocol::RxStatus +IpL4Protocol::RxStatus Icmpv4L4Protocol::Receive(Ptr p, const Ipv6Header& header, Ptr incomingInterface) diff --git a/src/internet/model/icmpv4-l4-protocol.h b/src/internet/model/icmpv4-l4-protocol.h index 5de78d342..18a3439f6 100644 --- a/src/internet/model/icmpv4-l4-protocol.h +++ b/src/internet/model/icmpv4-l4-protocol.h @@ -81,9 +81,9 @@ class Icmpv4L4Protocol : public IpL4Protocol * \param incomingInterface the interface from which the packet is coming * \returns the receive status */ - enum IpL4Protocol::RxStatus Receive(Ptr p, - const Ipv4Header& header, - Ptr incomingInterface) override; + IpL4Protocol::RxStatus Receive(Ptr p, + const Ipv4Header& header, + Ptr incomingInterface) override; /** * \brief Receive method. @@ -92,9 +92,9 @@ class Icmpv4L4Protocol : public IpL4Protocol * \param incomingInterface the interface from which the packet is coming * \returns the receive status */ - enum IpL4Protocol::RxStatus Receive(Ptr p, - const Ipv6Header& header, - Ptr incomingInterface) override; + IpL4Protocol::RxStatus Receive(Ptr p, + const Ipv6Header& header, + Ptr incomingInterface) override; /** * \brief Send a Destination Unreachable - Fragmentation needed ICMP error diff --git a/src/internet/model/icmpv6-l4-protocol.cc b/src/internet/model/icmpv6-l4-protocol.cc index 33385d758..69277526b 100644 --- a/src/internet/model/icmpv6-l4-protocol.cc +++ b/src/internet/model/icmpv6-l4-protocol.cc @@ -24,13 +24,13 @@ #include "ipv6-interface.h" #include "ipv6-l3-protocol.h" +#include "ipv6-route.h" +#include "ipv6-routing-protocol.h" #include "ns3/assert.h" #include "ns3/boolean.h" #include "ns3/double.h" #include "ns3/integer.h" -#include "ns3/ipv6-route.h" -#include "ns3/ipv6-routing-protocol.h" #include "ns3/log.h" #include "ns3/node.h" #include "ns3/packet.h" @@ -284,7 +284,7 @@ Icmpv6L4Protocol::DoDAD(Ipv6Address target, Ptr interface) Ipv6Address::MakeSolicitedAddress(target)); } -enum IpL4Protocol::RxStatus +IpL4Protocol::RxStatus Icmpv6L4Protocol::Receive(Ptr packet, const Ipv4Header& header, Ptr interface) @@ -293,7 +293,7 @@ Icmpv6L4Protocol::Receive(Ptr packet, return IpL4Protocol::RX_ENDPOINT_UNREACH; } -enum IpL4Protocol::RxStatus +IpL4Protocol::RxStatus Icmpv6L4Protocol::Receive(Ptr packet, const Ipv6Header& header, Ptr interface) @@ -446,7 +446,7 @@ Icmpv6L4Protocol::HandleRA(Ptr packet, defaultRouter = src; } - while (next == true) + while (next) { uint8_t type = 0; p->CopyData(&type, sizeof(type)); @@ -688,7 +688,7 @@ Icmpv6L4Protocol::HandleNS(Ptr packet, bool next = true; bool hasSllao = false; - while (next == true) + while (next) { uint8_t type; packet->CopyData(&type, sizeof(type)); diff --git a/src/internet/model/icmpv6-l4-protocol.h b/src/internet/model/icmpv6-l4-protocol.h index 26e261763..6522a4c1a 100644 --- a/src/internet/model/icmpv6-l4-protocol.h +++ b/src/internet/model/icmpv6-l4-protocol.h @@ -328,9 +328,9 @@ class Icmpv6L4Protocol : public IpL4Protocol * \param interface the interface from which the packet is coming * \returns the receive status */ - enum IpL4Protocol::RxStatus Receive(Ptr p, - const Ipv4Header& header, - Ptr interface) override; + IpL4Protocol::RxStatus Receive(Ptr p, + const Ipv4Header& header, + Ptr interface) override; /** * \brief Receive method. @@ -339,9 +339,9 @@ class Icmpv6L4Protocol : public IpL4Protocol * \param interface the interface from which the packet is coming * \returns the receive status */ - enum IpL4Protocol::RxStatus Receive(Ptr p, - const Ipv6Header& header, - Ptr interface) override; + IpL4Protocol::RxStatus Receive(Ptr p, + const Ipv6Header& header, + Ptr interface) override; /** * \brief Function called when DAD timeout. diff --git a/src/internet/model/ipv4-end-point.cc b/src/internet/model/ipv4-end-point.cc index ed51f6c10..0bfc3814f 100644 --- a/src/internet/model/ipv4-end-point.cc +++ b/src/internet/model/ipv4-end-point.cc @@ -51,7 +51,7 @@ Ipv4EndPoint::~Ipv4EndPoint() } Ipv4Address -Ipv4EndPoint::GetLocalAddress() +Ipv4EndPoint::GetLocalAddress() const { NS_LOG_FUNCTION(this); return m_localAddr; @@ -65,21 +65,21 @@ Ipv4EndPoint::SetLocalAddress(Ipv4Address address) } uint16_t -Ipv4EndPoint::GetLocalPort() +Ipv4EndPoint::GetLocalPort() const { NS_LOG_FUNCTION(this); return m_localPort; } Ipv4Address -Ipv4EndPoint::GetPeerAddress() +Ipv4EndPoint::GetPeerAddress() const { NS_LOG_FUNCTION(this); return m_peerAddr; } uint16_t -Ipv4EndPoint::GetPeerPort() +Ipv4EndPoint::GetPeerPort() const { NS_LOG_FUNCTION(this); return m_peerPort; @@ -101,7 +101,7 @@ Ipv4EndPoint::BindToNetDevice(Ptr netdevice) } Ptr -Ipv4EndPoint::GetBoundNetDevice() +Ipv4EndPoint::GetBoundNetDevice() const { NS_LOG_FUNCTION(this); return m_boundnetdevice; diff --git a/src/internet/model/ipv4-end-point.h b/src/internet/model/ipv4-end-point.h index 9b0288ae3..ef87228cf 100644 --- a/src/internet/model/ipv4-end-point.h +++ b/src/internet/model/ipv4-end-point.h @@ -62,7 +62,7 @@ class Ipv4EndPoint * \brief Get the local address. * \return the local address */ - Ipv4Address GetLocalAddress(); + Ipv4Address GetLocalAddress() const; /** * \brief Set the local address. @@ -74,19 +74,19 @@ class Ipv4EndPoint * \brief Get the local port. * \return the local port */ - uint16_t GetLocalPort(); + uint16_t GetLocalPort() const; /** * \brief Get the peer address. * \return the peer address */ - Ipv4Address GetPeerAddress(); + Ipv4Address GetPeerAddress() const; /** * \brief Get the peer port. * \return the peer port */ - uint16_t GetPeerPort(); + uint16_t GetPeerPort() const; /** * \brief Set the peer information (address and port). @@ -124,7 +124,7 @@ class Ipv4EndPoint * * \returns Pointer to interface. */ - Ptr GetBoundNetDevice(); + Ptr GetBoundNetDevice() const; // Called from socket implementations to get notified about important events. /** diff --git a/src/internet/model/ipv4-global-routing.cc b/src/internet/model/ipv4-global-routing.cc index d0c3249d7..ae018d6cb 100644 --- a/src/internet/model/ipv4-global-routing.cc +++ b/src/internet/model/ipv4-global-routing.cc @@ -19,10 +19,10 @@ #include "global-route-manager.h" #include "ipv4-queue-disc-item.h" +#include "ipv4-route.h" +#include "ipv4-routing-table-entry.h" #include "ns3/boolean.h" -#include "ns3/ipv4-route.h" -#include "ns3/ipv4-routing-table-entry.h" #include "ns3/log.h" #include "ns3/names.h" #include "ns3/net-device.h" @@ -490,10 +490,10 @@ bool Ipv4GlobalRouting::RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) { NS_LOG_FUNCTION(this << p << header << header.GetSource() << header.GetDestination() << idev << &lcb << &ecb); @@ -528,7 +528,7 @@ Ipv4GlobalRouting::RouteInput(Ptr p, } // Check if input device supports IP forwarding - if (m_ipv4->IsForwarding(iif) == false) + if (!m_ipv4->IsForwarding(iif)) { NS_LOG_LOGIC("Forwarding disabled for this interface"); ecb(p, header, Socket::ERROR_NOROUTETOHOST); diff --git a/src/internet/model/ipv4-global-routing.h b/src/internet/model/ipv4-global-routing.h index 15e68e436..4f0039497 100644 --- a/src/internet/model/ipv4-global-routing.h +++ b/src/internet/model/ipv4-global-routing.h @@ -96,10 +96,10 @@ class Ipv4GlobalRouting : public Ipv4RoutingProtocol bool RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override; + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override; void NotifyInterfaceUp(uint32_t interface) override; void NotifyInterfaceDown(uint32_t interface) override; void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) override; diff --git a/src/internet/model/ipv4-l3-protocol.cc b/src/internet/model/ipv4-l3-protocol.cc index 8154aa105..489eb94bd 100644 --- a/src/internet/model/ipv4-l3-protocol.cc +++ b/src/internet/model/ipv4-l3-protocol.cc @@ -22,16 +22,15 @@ #include "arp-cache.h" #include "arp-l3-protocol.h" #include "icmpv4-l4-protocol.h" +#include "ipv4-header.h" #include "ipv4-interface.h" #include "ipv4-raw-socket-impl.h" +#include "ipv4-route.h" #include "loopback-net-device.h" #include "ns3/boolean.h" #include "ns3/callback.h" #include "ns3/ipv4-address.h" -#include "ns3/ipv4-header.h" -#include "ns3/ipv4-route.h" -#include "ns3/ipv4-routing-table-entry.h" #include "ns3/log.h" #include "ns3/net-device.h" #include "ns3/node.h" @@ -134,6 +133,10 @@ Ipv4L3Protocol::GetTypeId() Ipv4L3Protocol::Ipv4L3Protocol() { NS_LOG_FUNCTION(this); + m_ucb = MakeCallback(&Ipv4L3Protocol::IpForward, this); + m_mcb = MakeCallback(&Ipv4L3Protocol::IpMulticastForward, this); + m_lcb = MakeCallback(&Ipv4L3Protocol::LocalDeliver, this); + m_ecb = MakeCallback(&Ipv4L3Protocol::RouteInputError, this); } Ipv4L3Protocol::~Ipv4L3Protocol() @@ -535,11 +538,10 @@ Ipv4L3Protocol::IsDestinationAddress(Ipv4Address address, uint32_t iif) const #ifdef NOTYET if (MulticastCheckGroup(iif, address)) #endif - if (true) - { - NS_LOG_LOGIC("For me (Ipv4Addr multicast address)"); - return true; - } + { + NS_LOG_LOGIC("For me (Ipv4Addr multicast address)"); + return true; + } } if (address.IsBroadcast()) @@ -674,13 +676,7 @@ Ipv4L3Protocol::Receive(Ptr device, } NS_ASSERT_MSG(m_routingProtocol, "Need a routing protocol object to process packets"); - if (!m_routingProtocol->RouteInput(packet, - ipHeader, - device, - MakeCallback(&Ipv4L3Protocol::IpForward, this), - MakeCallback(&Ipv4L3Protocol::IpMulticastForward, this), - MakeCallback(&Ipv4L3Protocol::LocalDeliver, this), - MakeCallback(&Ipv4L3Protocol::RouteInputError, this))) + if (!m_routingProtocol->RouteInput(packet, ipHeader, device, m_ucb, m_mcb, m_lcb, m_ecb)) { NS_LOG_WARN("No route found for forwarding packet. Drop."); m_dropTrace(ipHeader, packet, DROP_NO_ROUTE, this, interface); @@ -963,7 +959,7 @@ Ipv4L3Protocol::BuildHeader(Ipv4Address source, uint64_t srcDst = dst | (src << 32); std::pair key = std::make_pair(srcDst, protocol); - if (mayFragment == true) + if (mayFragment) { ipHeader.SetMayFragment(); ipHeader.SetIdentification(m_identification[key]); @@ -1092,8 +1088,7 @@ Ipv4L3Protocol::IpForward(Ptr rtentry, Ptr p, const Ipv if (ipHeader.GetTtl() == 0) { // Do not reply to multicast/broadcast IP address - if (ipHeader.GetDestination().IsBroadcast() == false && - ipHeader.GetDestination().IsMulticast() == false) + if (!ipHeader.GetDestination().IsBroadcast() && !ipHeader.GetDestination().IsMulticast()) { Ptr icmp = GetIcmp(); icmp->SendTimeExceededTtl(ipHeader, packet, false); @@ -1129,7 +1124,7 @@ Ipv4L3Protocol::LocalDeliver(Ptr packet, const Ipv4Header& ip, uin NS_LOG_LOGIC("Received a fragment, processing " << *p); bool isPacketComplete; isPacketComplete = ProcessFragment(p, ipHeader, iif); - if (isPacketComplete == false) + if (!isPacketComplete) { return; } @@ -1146,7 +1141,7 @@ Ipv4L3Protocol::LocalDeliver(Ptr packet, const Ipv4Header& ip, uin // we need to make a copy in the unlikely event we hit the // RX_ENDPOINT_UNREACH codepath Ptr copy = p->Copy(); - enum IpL4Protocol::RxStatus status = protocol->Receive(p, ipHeader, GetInterface(iif)); + IpL4Protocol::RxStatus status = protocol->Receive(p, ipHeader, GetInterface(iif)); switch (status) { case IpL4Protocol::RX_OK: @@ -1156,8 +1151,7 @@ Ipv4L3Protocol::LocalDeliver(Ptr packet, const Ipv4Header& ip, uin case IpL4Protocol::RX_CSUM_FAILED: break; case IpL4Protocol::RX_ENDPOINT_UNREACH: - if (ipHeader.GetDestination().IsBroadcast() == true || - ipHeader.GetDestination().IsMulticast() == true) + if (ipHeader.GetDestination().IsBroadcast() || ipHeader.GetDestination().IsMulticast()) { break; // Do not reply to broadcast or multicast } @@ -1173,7 +1167,7 @@ Ipv4L3Protocol::LocalDeliver(Ptr packet, const Ipv4Header& ip, uin subnetDirected = true; } } - if (subnetDirected == false) + if (!subnetDirected) { GetIcmp()->SendDestUnreachPort(ipHeader, copy); } @@ -1268,7 +1262,7 @@ Ipv4L3Protocol::SourceAddressSelection(uint32_t interfaceIdx, Ipv4Address dest) Ipv4InterfaceAddress test = GetAddress(interfaceIdx, i); if (test.GetLocal().CombineMask(test.GetMask()) == dest.CombineMask(test.GetMask())) { - if (test.IsSecondary() == false) + if (!test.IsSecondary()) { return test.GetLocal(); } diff --git a/src/internet/model/ipv4-l3-protocol.h b/src/internet/model/ipv4-l3-protocol.h index ea6d49b82..94327765d 100644 --- a/src/internet/model/ipv4-l3-protocol.h +++ b/src/internet/model/ipv4-l3-protocol.h @@ -630,6 +630,11 @@ class Ipv4L3Protocol : public Ipv4 Time m_expire; //!< duplicate entry expiration delay Time m_purge; //!< time between purging expired duplicate entries EventId m_cleanDpd; //!< event to cleanup expired duplicate entries + + Ipv4RoutingProtocol::UnicastForwardCallback m_ucb; ///< Unicast forward callback + Ipv4RoutingProtocol::MulticastForwardCallback m_mcb; ///< Multicast forward callback + Ipv4RoutingProtocol::LocalDeliverCallback m_lcb; ///< Local delivery callback + Ipv4RoutingProtocol::ErrorCallback m_ecb; ///< Error callback }; } // Namespace ns3 diff --git a/src/internet/model/ipv4-list-routing.cc b/src/internet/model/ipv4-list-routing.cc index f14917afa..dad69ebc9 100644 --- a/src/internet/model/ipv4-list-routing.cc +++ b/src/internet/model/ipv4-list-routing.cc @@ -18,9 +18,9 @@ #include "ipv4-list-routing.h" -#include "ns3/ipv4-route.h" -#include "ns3/ipv4-static-routing.h" -#include "ns3/ipv4.h" +#include "ipv4-route.h" +#include "ipv4.h" + #include "ns3/log.h" #include "ns3/node.h" @@ -105,7 +105,7 @@ Ptr Ipv4ListRouting::RouteOutput(Ptr p, const Ipv4Header& header, Ptr oif, - enum Socket::SocketErrno& sockerr) + Socket::SocketErrno& sockerr) { NS_LOG_FUNCTION(this << p << header.GetDestination() << header.GetSource() << oif << sockerr); Ptr route; @@ -136,10 +136,10 @@ bool Ipv4ListRouting::RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) { NS_LOG_FUNCTION(this << p << header << idev << &ucb << &mcb << &lcb << &ecb); bool retVal = false; @@ -151,7 +151,7 @@ Ipv4ListRouting::RouteInput(Ptr p, uint32_t iif = m_ipv4->GetInterfaceForDevice(idev); retVal = m_ipv4->IsDestinationAddress(header.GetDestination(), iif); - if (retVal == true) + if (retVal) { NS_LOG_LOGIC("Address " << header.GetDestination() << " is a match for local delivery"); if (header.GetDestination().IsMulticast()) @@ -168,7 +168,7 @@ Ipv4ListRouting::RouteInput(Ptr p, } } // Check if input device supports IP forwarding - if (m_ipv4->IsForwarding(iif) == false) + if (!m_ipv4->IsForwarding(iif)) { NS_LOG_LOGIC("Forwarding disabled for this interface"); ecb(p, header, Socket::ERROR_NOROUTETOHOST); @@ -178,7 +178,7 @@ Ipv4ListRouting::RouteInput(Ptr p, // If we have already delivered a packet locally (e.g. multicast) // we suppress further downstream local delivery by nulling the callback LocalDeliverCallback downstreamLcb = lcb; - if (retVal == true) + if (retVal) { downstreamLcb = MakeNullCallback, const Ipv4Header&, uint32_t>(); } diff --git a/src/internet/model/ipv4-list-routing.h b/src/internet/model/ipv4-list-routing.h index a7a196953..08d2e881e 100644 --- a/src/internet/model/ipv4-list-routing.h +++ b/src/internet/model/ipv4-list-routing.h @@ -88,10 +88,10 @@ class Ipv4ListRouting : public Ipv4RoutingProtocol bool RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override; + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override; void NotifyInterfaceUp(uint32_t interface) override; void NotifyInterfaceDown(uint32_t interface) override; void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) override; diff --git a/src/internet/model/ipv4-packet-filter.cc b/src/internet/model/ipv4-packet-filter.cc index 141dabdb1..d4d52ce9d 100644 --- a/src/internet/model/ipv4-packet-filter.cc +++ b/src/internet/model/ipv4-packet-filter.cc @@ -26,8 +26,6 @@ #include "ns3/enum.h" #include "ns3/log.h" -#include "ns3/tcp-header.h" -#include "ns3/udp-header.h" #include "ns3/uinteger.h" namespace ns3 diff --git a/src/internet/model/ipv4-packet-probe.cc b/src/internet/model/ipv4-packet-probe.cc index 8488eb45d..0c5ffa0fe 100644 --- a/src/internet/model/ipv4-packet-probe.cc +++ b/src/internet/model/ipv4-packet-probe.cc @@ -20,7 +20,7 @@ * Modified by: Mitch Watrous (watrous@u.washington.edu) */ -#include "ns3/ipv4-packet-probe.h" +#include "ipv4-packet-probe.h" #include "ns3/config.h" #include "ns3/log.h" diff --git a/src/internet/model/ipv4-queue-disc-item.cc b/src/internet/model/ipv4-queue-disc-item.cc index 4555f7266..24ce79d24 100644 --- a/src/internet/model/ipv4-queue-disc-item.cc +++ b/src/internet/model/ipv4-queue-disc-item.cc @@ -17,9 +17,10 @@ #include "ipv4-queue-disc-item.h" +#include "tcp-header.h" +#include "udp-header.h" + #include "ns3/log.h" -#include "ns3/tcp-header.h" -#include "ns3/udp-header.h" namespace ns3 { diff --git a/src/internet/model/ipv4-raw-socket-impl.cc b/src/internet/model/ipv4-raw-socket-impl.cc index 3d12b8c4f..c4f98fc0b 100644 --- a/src/internet/model/ipv4-raw-socket-impl.cc +++ b/src/internet/model/ipv4-raw-socket-impl.cc @@ -1,18 +1,18 @@ #include "ipv4-raw-socket-impl.h" #include "icmpv4.h" -#include "ipv4-l3-protocol.h" +#include "ipv4-packet-info-tag.h" +#include "ipv4-routing-protocol.h" #include "ns3/boolean.h" #include "ns3/inet-socket-address.h" -#include "ns3/ipv4-packet-info-tag.h" #include "ns3/log.h" #include "ns3/node.h" #include "ns3/packet.h" #include "ns3/uinteger.h" #ifdef __WIN32__ -#include "ns3/win32-internet.h" +#include "win32-internet.h" #else #include #include @@ -88,14 +88,14 @@ Ipv4RawSocketImpl::DoDispose() Socket::DoDispose(); } -enum Socket::SocketErrno +Socket::SocketErrno Ipv4RawSocketImpl::GetErrno() const { NS_LOG_FUNCTION(this); return m_err; } -enum Socket::SocketType +Socket::SocketType Ipv4RawSocketImpl::GetSocketType() const { NS_LOG_FUNCTION(this); @@ -526,11 +526,7 @@ bool Ipv4RawSocketImpl::SetAllowBroadcast(bool allowBroadcast) { NS_LOG_FUNCTION(this << allowBroadcast); - if (!allowBroadcast) - { - return false; - } - return true; + return allowBroadcast; } bool diff --git a/src/internet/model/ipv4-raw-socket-impl.h b/src/internet/model/ipv4-raw-socket-impl.h index 0820b3a98..2bd93e0a7 100644 --- a/src/internet/model/ipv4-raw-socket-impl.h +++ b/src/internet/model/ipv4-raw-socket-impl.h @@ -42,13 +42,13 @@ class Ipv4RawSocketImpl : public Socket */ void SetNode(Ptr node); - enum Socket::SocketErrno GetErrno() const override; + Socket::SocketErrno GetErrno() const override; /** * \brief Get socket type (NS3_SOCK_RAW) * \return socket type */ - enum Socket::SocketType GetSocketType() const override; + Socket::SocketType GetSocketType() const override; Ptr GetNode() const override; int Bind(const Address& address) override; @@ -99,15 +99,15 @@ class Ipv4RawSocketImpl : public Socket uint16_t fromProtocol; /**< Protocol used */ }; - mutable enum Socket::SocketErrno m_err; //!< Last error number. - Ptr m_node; //!< Node - Ipv4Address m_src; //!< Source address. - Ipv4Address m_dst; //!< Destination address. - uint16_t m_protocol; //!< Protocol. - std::list m_recv; //!< Packet waiting to be processed. - bool m_shutdownSend; //!< Flag to shutdown send capability. - bool m_shutdownRecv; //!< Flag to shutdown receive capability. - uint32_t m_icmpFilter; //!< ICMPv4 filter specification + mutable Socket::SocketErrno m_err; //!< Last error number. + Ptr m_node; //!< Node + Ipv4Address m_src; //!< Source address. + Ipv4Address m_dst; //!< Destination address. + uint16_t m_protocol; //!< Protocol. + std::list m_recv; //!< Packet waiting to be processed. + bool m_shutdownSend; //!< Flag to shutdown send capability. + bool m_shutdownRecv; //!< Flag to shutdown receive capability. + uint32_t m_icmpFilter; //!< ICMPv4 filter specification bool m_iphdrincl; //!< Include IP Header information (a.k.a setsockopt (IP_HDRINCL)) }; diff --git a/src/internet/model/ipv4-routing-protocol.cc b/src/internet/model/ipv4-routing-protocol.cc index 2e0224d0b..e8cb7d90e 100644 --- a/src/internet/model/ipv4-routing-protocol.cc +++ b/src/internet/model/ipv4-routing-protocol.cc @@ -17,8 +17,6 @@ #include "ipv4-routing-protocol.h" -#include "ipv4-route.h" - #include "ns3/assert.h" #include "ns3/log.h" diff --git a/src/internet/model/ipv4-routing-protocol.h b/src/internet/model/ipv4-routing-protocol.h index bdf072311..ffee409e7 100644 --- a/src/internet/model/ipv4-routing-protocol.h +++ b/src/internet/model/ipv4-routing-protocol.h @@ -126,10 +126,10 @@ class Ipv4RoutingProtocol : public Object virtual bool RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) = 0; + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) = 0; /** * \param interface the index of the interface we are being notified about diff --git a/src/internet/model/ipv4-routing-table-entry.cc b/src/internet/model/ipv4-routing-table-entry.cc index 787e4ff64..e4ec9115e 100644 --- a/src/internet/model/ipv4-routing-table-entry.cc +++ b/src/internet/model/ipv4-routing-table-entry.cc @@ -99,14 +99,7 @@ bool Ipv4RoutingTableEntry::IsHost() const { NS_LOG_FUNCTION(this); - if (m_destNetworkMask == Ipv4Mask::GetOnes()) - { - return true; - } - else - { - return false; - } + return m_destNetworkMask == Ipv4Mask::GetOnes(); } Ipv4Address @@ -127,14 +120,7 @@ bool Ipv4RoutingTableEntry::IsDefault() const { NS_LOG_FUNCTION(this); - if (m_dest == Ipv4Address::GetZero()) - { - return true; - } - else - { - return false; - } + return m_dest == Ipv4Address::GetZero(); } Ipv4Address @@ -155,14 +141,7 @@ bool Ipv4RoutingTableEntry::IsGateway() const { NS_LOG_FUNCTION(this); - if (m_gateway == Ipv4Address::GetZero()) - { - return false; - } - else - { - return true; - } + return m_gateway != Ipv4Address::GetZero(); } Ipv4Address diff --git a/src/internet/model/ipv4-static-routing.cc b/src/internet/model/ipv4-static-routing.cc index baf4d9665..781c88f4e 100644 --- a/src/internet/model/ipv4-static-routing.cc +++ b/src/internet/model/ipv4-static-routing.cc @@ -26,9 +26,9 @@ #include "ipv4-static-routing.h" +#include "ipv4-route.h" #include "ipv4-routing-table-entry.h" -#include "ns3/ipv4-route.h" #include "ns3/log.h" #include "ns3/names.h" #include "ns3/node.h" @@ -503,10 +503,10 @@ bool Ipv4StaticRouting::RouteInput(Ptr p, const Ipv4Header& ipHeader, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) { NS_LOG_FUNCTION(this << p << ipHeader << ipHeader.GetSource() << ipHeader.GetDestination() << idev << &ucb << &mcb << &lcb << &ecb); @@ -558,7 +558,7 @@ Ipv4StaticRouting::RouteInput(Ptr p, } // Check if input device supports IP forwarding - if (m_ipv4->IsForwarding(iif) == false) + if (!m_ipv4->IsForwarding(iif)) { NS_LOG_LOGIC("Forwarding disabled for this interface"); ecb(p, ipHeader, Socket::ERROR_NOROUTETOHOST); diff --git a/src/internet/model/ipv4-static-routing.h b/src/internet/model/ipv4-static-routing.h index 8a144bd2f..c96007f00 100644 --- a/src/internet/model/ipv4-static-routing.h +++ b/src/internet/model/ipv4-static-routing.h @@ -83,10 +83,10 @@ class Ipv4StaticRouting : public Ipv4RoutingProtocol bool RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override; + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override; void NotifyInterfaceUp(uint32_t interface) override; void NotifyInterfaceDown(uint32_t interface) override; diff --git a/src/internet/model/ipv6-address-generator.cc b/src/internet/model/ipv6-address-generator.cc index ead3de1fe..c01efafda 100644 --- a/src/internet/model/ipv6-address-generator.cc +++ b/src/internet/model/ipv6-address-generator.cc @@ -605,9 +605,8 @@ Ipv6AddressGeneratorImpl::IsNetworkAllocated(const Ipv6Address address, const Ip { NS_LOG_FUNCTION(this << address << prefix); - Ipv6Address addr = address; NS_ABORT_MSG_UNLESS( - address == addr.CombinePrefix(prefix), + address == address.CombinePrefix(prefix), "Ipv6AddressGeneratorImpl::IsNetworkAllocated(): network address and mask don't match " << address << " " << prefix); diff --git a/src/internet/model/ipv6-end-point.cc b/src/internet/model/ipv6-end-point.cc index cabf77bb3..7daaeebed 100644 --- a/src/internet/model/ipv6-end-point.cc +++ b/src/internet/model/ipv6-end-point.cc @@ -49,7 +49,7 @@ Ipv6EndPoint::~Ipv6EndPoint() } Ipv6Address -Ipv6EndPoint::GetLocalAddress() +Ipv6EndPoint::GetLocalAddress() const { return m_localAddr; } @@ -73,7 +73,7 @@ Ipv6EndPoint::SetLocalPort(uint16_t port) } Ipv6Address -Ipv6EndPoint::GetPeerAddress() +Ipv6EndPoint::GetPeerAddress() const { return m_peerAddr; } @@ -91,7 +91,7 @@ Ipv6EndPoint::BindToNetDevice(Ptr netdevice) } Ptr -Ipv6EndPoint::GetBoundNetDevice() +Ipv6EndPoint::GetBoundNetDevice() const { return m_boundnetdevice; } diff --git a/src/internet/model/ipv6-end-point.h b/src/internet/model/ipv6-end-point.h index f5d92e31a..3dc0fe200 100644 --- a/src/internet/model/ipv6-end-point.h +++ b/src/internet/model/ipv6-end-point.h @@ -62,7 +62,7 @@ class Ipv6EndPoint * \brief Get the local address. * \return the local address */ - Ipv6Address GetLocalAddress(); + Ipv6Address GetLocalAddress() const; /** * \brief Set the local address. @@ -86,7 +86,7 @@ class Ipv6EndPoint * \brief Get the peer address. * \return the peer address */ - Ipv6Address GetPeerAddress(); + Ipv6Address GetPeerAddress() const; /** * \brief Get the peer port. @@ -130,7 +130,7 @@ class Ipv6EndPoint * * \returns Pointer to interface. */ - Ptr GetBoundNetDevice(); + Ptr GetBoundNetDevice() const; /** * \brief Set the reception callback. diff --git a/src/internet/model/ipv6-extension.cc b/src/internet/model/ipv6-extension.cc index 81223c1bb..c8157a126 100644 --- a/src/internet/model/ipv6-extension.cc +++ b/src/internet/model/ipv6-extension.cc @@ -22,17 +22,14 @@ #include "icmpv6-l4-protocol.h" #include "ipv6-extension-demux.h" #include "ipv6-extension-header.h" +#include "ipv6-header.h" +#include "ipv6-l3-protocol.h" #include "ipv6-option-demux.h" #include "ipv6-option.h" -#include "udp-header.h" +#include "ipv6-route.h" #include "ns3/assert.h" #include "ns3/ipv6-address.h" -#include "ns3/ipv6-header.h" -#include "ns3/ipv6-l3-protocol.h" -#include "ns3/ipv6-list-routing.h" -#include "ns3/ipv6-route.h" -#include "ns3/ipv6-static-routing.h" #include "ns3/log.h" #include "ns3/object-vector.h" #include "ns3/trace-source-accessor.h" @@ -513,11 +510,16 @@ Ipv6ExtensionFragment::GetFragments(Ptr packet, } else if (nextHeader == Ipv6Header::IPV6_EXT_ROUTING) { - uint8_t buf[2]; + Ptr ipv6ExtensionRoutingDemux = + GetNode()->GetObject(); + + uint8_t buf[4]; p->CopyData(buf, sizeof(buf)); - uint8_t numberAddress = buf[1] / 2; - Ipv6ExtensionLooseRoutingHeader* routingHeader = new Ipv6ExtensionLooseRoutingHeader(); - routingHeader->SetNumberAddress(numberAddress); + uint8_t routingType = buf[2]; + + Ipv6ExtensionRoutingHeader* routingHeader = + ipv6ExtensionRoutingDemux->GetExtensionRoutingHeaderPtr(routingType); + p->RemoveHeader(*routingHeader); nextHeader = routingHeader->GetNextHeader(); @@ -885,6 +887,12 @@ Ipv6ExtensionRouting::GetTypeRouting() const return 0; } +Ipv6ExtensionRoutingHeader* +Ipv6ExtensionRouting::GetExtensionRoutingHeaderPtr() +{ + return nullptr; +} + uint8_t Ipv6ExtensionRouting::Process(Ptr& packet, uint8_t offset, @@ -1014,15 +1022,30 @@ Ipv6ExtensionRoutingDemux::Insert(Ptr extensionRouting) Ptr Ipv6ExtensionRoutingDemux::GetExtensionRouting(uint8_t typeRouting) { - for (Ipv6ExtensionRoutingList_t::iterator i = m_extensionsRouting.begin(); - i != m_extensionsRouting.end(); - i++) + for (const auto& extRouting : m_extensionsRouting) { - if ((*i)->GetTypeRouting() == typeRouting) + if (extRouting->GetTypeRouting() == typeRouting) { - return *i; + return extRouting; } } + + return nullptr; +} + +Ipv6ExtensionRoutingHeader* +Ipv6ExtensionRoutingDemux::GetExtensionRoutingHeaderPtr(uint8_t typeRouting) +{ + NS_LOG_FUNCTION(this << typeRouting); + + for (const auto& extRouting : m_extensionsRouting) + { + if (extRouting->GetTypeRouting() == typeRouting) + { + return extRouting->GetExtensionRoutingHeaderPtr(); + } + } + return nullptr; } @@ -1059,6 +1082,12 @@ Ipv6ExtensionLooseRouting::GetTypeRouting() const return TYPE_ROUTING; } +Ipv6ExtensionRoutingHeader* +Ipv6ExtensionLooseRouting::GetExtensionRoutingHeaderPtr() +{ + return new Ipv6ExtensionLooseRoutingHeader(); +} + uint8_t Ipv6ExtensionLooseRouting::Process(Ptr& packet, uint8_t offset, @@ -1089,9 +1118,7 @@ Ipv6ExtensionLooseRouting::Process(Ptr& packet, // Get the number of routers' address field uint8_t buf[2]; p->CopyData(buf, sizeof(buf)); - uint8_t numberAddress = buf[1] / 2; Ipv6ExtensionLooseRoutingHeader routingHeader; - routingHeader.SetNumberAddress(numberAddress); p->RemoveHeader(routingHeader); if (nextHeader) diff --git a/src/internet/model/ipv6-extension.h b/src/internet/model/ipv6-extension.h index e06e83b2a..5c6af5b64 100644 --- a/src/internet/model/ipv6-extension.h +++ b/src/internet/model/ipv6-extension.h @@ -20,6 +20,7 @@ #ifndef IPV6_EXTENSION_H #define IPV6_EXTENSION_H +#include "ipv6-extension-header.h" #include "ipv6-interface.h" #include "ns3/buffer.h" @@ -515,6 +516,13 @@ class Ipv6ExtensionRouting : public Ipv6Extension */ virtual uint8_t GetTypeRouting() const; + /** + * \brief Get a pointer to a new routing extension header. + * The ownership is transferred to the caller. + * \return a pointer to a new routing extension header. + */ + virtual Ipv6ExtensionRoutingHeader* GetExtensionRoutingHeaderPtr(); + uint8_t Process(Ptr& packet, uint8_t offset, const Ipv6Header& ipv6Header, @@ -568,6 +576,14 @@ class Ipv6ExtensionRoutingDemux : public Object */ Ptr GetExtensionRouting(uint8_t typeRouting); + /** + * \brief Get a pointer to a new routing extension header corresponding + * to typeRouting. The ownership is transferred to the caller. + * \param typeRouting the number of the routing extension to retrieve + * \return a pointer to a new routing extension header matching IPv6 routing extension + */ + Ipv6ExtensionRoutingHeader* GetExtensionRoutingHeaderPtr(uint8_t typeRouting); + /** * \brief Remove a routing extension from this demux. * \param extensionRouting pointer on the extension to remove @@ -632,6 +648,8 @@ class Ipv6ExtensionLooseRouting : public Ipv6ExtensionRouting */ uint8_t GetTypeRouting() const override; + Ipv6ExtensionRoutingHeader* GetExtensionRoutingHeaderPtr() override; + uint8_t Process(Ptr& packet, uint8_t offset, const Ipv6Header& ipv6Header, diff --git a/src/internet/model/ipv6-header.h b/src/internet/model/ipv6-header.h index 8f1dfc5df..073863a9b 100644 --- a/src/internet/model/ipv6-header.h +++ b/src/internet/model/ipv6-header.h @@ -20,7 +20,6 @@ #ifndef IPV6_HEADER_H #define IPV6_HEADER_H -#include "ns3/deprecated.h" #include "ns3/header.h" #include "ns3/ipv6-address.h" @@ -89,7 +88,7 @@ class Ipv6Header : public Header IPV6_EXT_ROUTING = 43, IPV6_EXT_FRAGMENTATION = 44, IPV6_EXT_CONFIDENTIALITY = 50, - IPV6_EXT_AUTHENTIFICATION = 51, + IPV6_EXT_AUTHENTICATION = 51, IPV6_ICMPV6 = 58, IPV6_EXT_END = 59, IPV6_EXT_DESTINATION = 60, diff --git a/src/internet/model/ipv6-l3-protocol.cc b/src/internet/model/ipv6-l3-protocol.cc index cab6efeff..4ee84f1f5 100644 --- a/src/internet/model/ipv6-l3-protocol.cc +++ b/src/internet/model/ipv6-l3-protocol.cc @@ -22,20 +22,19 @@ #include "icmpv6-l4-protocol.h" #include "ipv6-autoconfigured-prefix.h" #include "ipv6-extension-demux.h" -#include "ipv6-extension-header.h" #include "ipv6-extension.h" #include "ipv6-interface.h" #include "ipv6-option-demux.h" #include "ipv6-option.h" #include "ipv6-raw-socket-factory-impl.h" #include "ipv6-raw-socket-impl.h" +#include "ipv6-route.h" +#include "ipv6-routing-protocol.h" #include "loopback-net-device.h" #include "ndisc-cache.h" #include "ns3/boolean.h" #include "ns3/callback.h" -#include "ns3/ipv6-route.h" -#include "ns3/ipv6-routing-protocol.h" #include "ns3/log.h" #include "ns3/mac16-address.h" #include "ns3/mac64-address.h" @@ -91,7 +90,7 @@ Ipv6L3Protocol::GetTypeId() MakeBooleanChecker()) .AddAttribute("StrongEndSystemModel", "Reject packets for an address not configured on the interface they're " - "coming from (RFC1222).", + "coming from (RFC1122, section 3.3.4.2).", BooleanValue(true), MakeBooleanAccessor(&Ipv6L3Protocol::m_strongEndSystemModel), MakeBooleanChecker()) @@ -134,6 +133,10 @@ Ipv6L3Protocol::Ipv6L3Protocol() Ptr rawFactoryImpl = CreateObject(); AggregateObject(rawFactoryImpl); + m_ucb = MakeCallback(&Ipv6L3Protocol::IpForward, this); + m_mcb = MakeCallback(&Ipv6L3Protocol::IpMulticastForward, this); + m_lcb = MakeCallback(&Ipv6L3Protocol::LocalDeliver, this); + m_ecb = MakeCallback(&Ipv6L3Protocol::RouteInputError, this); } Ipv6L3Protocol::~Ipv6L3Protocol() @@ -1160,39 +1163,41 @@ Ipv6L3Protocol::Receive(Ptr device, for (uint32_t j = 0; j < GetNInterfaces(); j++) { - if (j == interface || !m_strongEndSystemModel) + for (uint32_t i = 0; i < GetNAddresses(j); i++) { - for (uint32_t i = 0; i < GetNAddresses(j); i++) + Ipv6InterfaceAddress iaddr = GetAddress(j, i); + Ipv6Address addr = iaddr.GetAddress(); + if (addr == hdr.GetDestination()) { - Ipv6InterfaceAddress iaddr = GetAddress(j, i); - Ipv6Address addr = iaddr.GetAddress(); - if (addr == hdr.GetDestination()) + if (j == interface) { - if (j == interface) - { - NS_LOG_LOGIC("For me (destination " << addr << " match)"); - } - else - { - NS_LOG_LOGIC("For me (destination " << addr - << " match) on another interface " - << hdr.GetDestination()); - } + NS_LOG_LOGIC("For me (destination " << addr << " match)"); LocalDeliver(packet, hdr, interface); return; } - NS_LOG_LOGIC("Address " << addr << " not a match"); + else if (!m_strongEndSystemModel) + { + NS_LOG_LOGIC("For me (destination " + << addr << " match) on another interface with Weak ES Model" + << hdr.GetDestination()); + LocalDeliver(packet, hdr, interface); + return; + } + else + { + NS_LOG_LOGIC("For me (destination " + << addr + << " match) on another interface with Strong ES Model - discarding" + << hdr.GetDestination()); + m_dropTrace(hdr, packet, DROP_NO_ROUTE, this, interface); + return; + } } + NS_LOG_LOGIC("Address " << addr << " not a match"); } } - if (!m_routingProtocol->RouteInput(packet, - hdr, - device, - MakeCallback(&Ipv6L3Protocol::IpForward, this), - MakeCallback(&Ipv6L3Protocol::IpMulticastForward, this), - MakeCallback(&Ipv6L3Protocol::LocalDeliver, this), - MakeCallback(&Ipv6L3Protocol::RouteInputError, this))) + if (!m_routingProtocol->RouteInput(packet, hdr, device, m_ucb, m_mcb, m_lcb, m_ecb)) { NS_LOG_WARN("No route found for forwarding packet. Drop."); // Drop trace and ICMPs are courtesy of RouteInputError @@ -1383,7 +1388,7 @@ Ipv6L3Protocol::IpForward(Ptr idev, NS_LOG_WARN("TTL exceeded. Drop."); m_dropTrace(ipHeader, packet, DROP_TTL_EXPIRED, this, 0); // Do not reply to multicast IPv6 address - if (ipHeader.GetDestination().IsMulticast() == false) + if (!ipHeader.GetDestination().IsMulticast()) { packet->AddHeader(ipHeader); GetIcmpv6()->SendErrorTimeExceeded(packet, @@ -1579,7 +1584,7 @@ Ipv6L3Protocol::LocalDeliver(Ptr packet, const Ipv6Header& ip, uin m_localDeliverTrace(ip, p, iif); - enum IpL4Protocol::RxStatus status = protocol->Receive(p, ip, GetInterface(iif)); + IpL4Protocol::RxStatus status = protocol->Receive(p, ip, GetInterface(iif)); switch (status) { @@ -1652,6 +1657,10 @@ Ipv6L3Protocol::BuildHeader(Ipv6Address src, void Ipv6L3Protocol::RegisterExtensions() { + if (m_node->GetObject()) + { + return; + } Ptr ipv6ExtensionDemux = CreateObject(); ipv6ExtensionDemux->SetNode(m_node); @@ -1688,6 +1697,10 @@ Ipv6L3Protocol::RegisterExtensions() void Ipv6L3Protocol::RegisterOptions() { + if (m_node->GetObject()) + { + return; + } Ptr ipv6OptionDemux = CreateObject(); ipv6OptionDemux->SetNode(m_node); @@ -1777,11 +1790,7 @@ Ipv6L3Protocol::IsRegisteredMulticastAddress(Ipv6Address address, uint32_t inter Ipv6RegisteredMulticastAddressKey_t key = std::make_pair(address, interface); Ipv6RegisteredMulticastAddressCIter_t iter = m_multicastAddresses.find(key); - if (iter == m_multicastAddresses.end()) - { - return false; - } - return true; + return iter != m_multicastAddresses.end(); } bool @@ -1792,11 +1801,7 @@ Ipv6L3Protocol::IsRegisteredMulticastAddress(Ipv6Address address) const Ipv6RegisteredMulticastAddressNoInterfaceCIter_t iter = m_multicastAddressesNoInterface.find(address); - if (iter == m_multicastAddressesNoInterface.end()) - { - return false; - } - return true; + return iter != m_multicastAddressesNoInterface.end(); } bool diff --git a/src/internet/model/ipv6-l3-protocol.h b/src/internet/model/ipv6-l3-protocol.h index bae7e47d1..12db07b77 100644 --- a/src/internet/model/ipv6-l3-protocol.h +++ b/src/internet/model/ipv6-l3-protocol.h @@ -23,6 +23,7 @@ #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" @@ -367,14 +368,7 @@ class Ipv6L3Protocol : public Ipv6 Ipv6Prefix mask, Ipv6Address defaultRouter); - /** - * \brief Register the IPv6 Extensions. - */ void RegisterExtensions() override; - - /** - * \brief Register the IPv6 Options. - */ void RegisterOptions() override; /** @@ -836,6 +830,11 @@ class Ipv6L3Protocol : public Ipv6 * \brief List of multicast IP addresses of interest for all the interfaces. */ Ipv6RegisteredMulticastAddressNoInterface_t m_multicastAddressesNoInterface; + + Ipv6RoutingProtocol::UnicastForwardCallback m_ucb; ///< Unicast forward callback + Ipv6RoutingProtocol::MulticastForwardCallback m_mcb; ///< Multicast forward callback + Ipv6RoutingProtocol::LocalDeliverCallback m_lcb; ///< Local delivery callback + Ipv6RoutingProtocol::ErrorCallback m_ecb; ///< Error callback }; } /* namespace ns3 */ diff --git a/src/internet/model/ipv6-list-routing.cc b/src/internet/model/ipv6-list-routing.cc index 6fad5456b..f6f0b4829 100644 --- a/src/internet/model/ipv6-list-routing.cc +++ b/src/internet/model/ipv6-list-routing.cc @@ -18,9 +18,9 @@ #include "ipv6-list-routing.h" -#include "ns3/ipv6-route.h" -#include "ns3/ipv6-static-routing.h" -#include "ns3/ipv6.h" +#include "ipv6-route.h" +#include "ipv6.h" + #include "ns3/log.h" #include "ns3/node.h" #include "ns3/simulator.h" @@ -74,7 +74,7 @@ Ptr Ipv6ListRouting::RouteOutput(Ptr p, const Ipv6Header& header, Ptr oif, - enum Socket::SocketErrno& sockerr) + Socket::SocketErrno& sockerr) { NS_LOG_FUNCTION(this << header.GetDestination() << header.GetSource() << oif); Ptr route; @@ -105,10 +105,10 @@ bool Ipv6ListRouting::RouteInput(Ptr p, const Ipv6Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) { NS_LOG_FUNCTION(p << header << idev); NS_LOG_LOGIC("RouteInput logic for node: " << m_ipv6->GetObject()->GetId()); @@ -120,7 +120,7 @@ Ipv6ListRouting::RouteInput(Ptr p, // Check if input device supports IP forwarding uint32_t iif = m_ipv6->GetInterfaceForDevice(idev); - if (m_ipv6->IsForwarding(iif) == false) + if (!m_ipv6->IsForwarding(iif)) { NS_LOG_LOGIC("Forwarding disabled for this interface"); ecb(p, header, Socket::ERROR_NOROUTETOHOST); diff --git a/src/internet/model/ipv6-list-routing.h b/src/internet/model/ipv6-list-routing.h index d10b79ddf..24abc7552 100644 --- a/src/internet/model/ipv6-list-routing.h +++ b/src/internet/model/ipv6-list-routing.h @@ -95,10 +95,10 @@ class Ipv6ListRouting : public Ipv6RoutingProtocol bool RouteInput(Ptr p, const Ipv6Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override; + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override; void NotifyInterfaceUp(uint32_t interface) override; void NotifyInterfaceDown(uint32_t interface) override; void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address) override; diff --git a/src/internet/model/ipv6-packet-filter.cc b/src/internet/model/ipv6-packet-filter.cc index 05692105b..27a9de98f 100644 --- a/src/internet/model/ipv6-packet-filter.cc +++ b/src/internet/model/ipv6-packet-filter.cc @@ -26,8 +26,6 @@ #include "ns3/enum.h" #include "ns3/log.h" -#include "ns3/tcp-header.h" -#include "ns3/udp-header.h" #include "ns3/uinteger.h" namespace ns3 diff --git a/src/internet/model/ipv6-packet-probe.cc b/src/internet/model/ipv6-packet-probe.cc index 1ab089a39..a382b6c43 100644 --- a/src/internet/model/ipv6-packet-probe.cc +++ b/src/internet/model/ipv6-packet-probe.cc @@ -21,7 +21,7 @@ * Adapted to Ipv6 by: Tommaso Pecorella (tommaso.pecorella@unifi.it) */ -#include "ns3/ipv6-packet-probe.h" +#include "ipv6-packet-probe.h" #include "ns3/config.h" #include "ns3/log.h" diff --git a/src/internet/model/ipv6-queue-disc-item.cc b/src/internet/model/ipv6-queue-disc-item.cc index 8036fef95..e010832e5 100644 --- a/src/internet/model/ipv6-queue-disc-item.cc +++ b/src/internet/model/ipv6-queue-disc-item.cc @@ -17,9 +17,10 @@ #include "ipv6-queue-disc-item.h" +#include "tcp-header.h" +#include "udp-header.h" + #include "ns3/log.h" -#include "ns3/tcp-header.h" -#include "ns3/udp-header.h" namespace ns3 { diff --git a/src/internet/model/ipv6-raw-socket-impl.cc b/src/internet/model/ipv6-raw-socket-impl.cc index a8690f065..4ff166993 100644 --- a/src/internet/model/ipv6-raw-socket-impl.cc +++ b/src/internet/model/ipv6-raw-socket-impl.cc @@ -22,18 +22,18 @@ #include "icmpv6-header.h" #include "icmpv6-l4-protocol.h" #include "ipv6-l3-protocol.h" +#include "ipv6-packet-info-tag.h" +#include "ipv6-route.h" +#include "ipv6-routing-protocol.h" #include "ns3/inet6-socket-address.h" -#include "ns3/ipv6-packet-info-tag.h" -#include "ns3/ipv6-route.h" -#include "ns3/ipv6-routing-protocol.h" #include "ns3/log.h" #include "ns3/node.h" #include "ns3/packet.h" #include "ns3/uinteger.h" #ifdef __WIN32__ -#include "ns3/win32-internet.h" +#include "win32-internet.h" #else #include #include @@ -100,14 +100,14 @@ Ipv6RawSocketImpl::GetNode() const return m_node; } -enum Socket::SocketErrno +Socket::SocketErrno Ipv6RawSocketImpl::GetErrno() const { NS_LOG_FUNCTION(this); return m_err; } -enum Socket::SocketType +Socket::SocketType Ipv6RawSocketImpl::GetSocketType() const { return NS3_SOCK_RAW; @@ -510,11 +510,7 @@ Ipv6RawSocketImpl::ForwardUp(Ptr p, Ipv6Header hdr, Ptr bool Ipv6RawSocketImpl::SetAllowBroadcast(bool allowBroadcast) { - if (!allowBroadcast) - { - return false; - } - return true; + return allowBroadcast; } bool diff --git a/src/internet/model/ipv6-raw-socket-impl.h b/src/internet/model/ipv6-raw-socket-impl.h index cde09d609..2b23819ab 100644 --- a/src/internet/model/ipv6-raw-socket-impl.h +++ b/src/internet/model/ipv6-raw-socket-impl.h @@ -80,13 +80,13 @@ class Ipv6RawSocketImpl : public Socket */ void SetNode(Ptr node); - enum Socket::SocketErrno GetErrno() const override; + Socket::SocketErrno GetErrno() const override; /** * \brief Get socket type (NS3_SOCK_RAW) * \return socket type */ - enum Socket::SocketType GetSocketType() const override; + Socket::SocketType GetSocketType() const override; Ptr GetNode() const override; @@ -185,7 +185,7 @@ class Ipv6RawSocketImpl : public Socket /** * \brief Last error number. */ - mutable enum Socket::SocketErrno m_err; + mutable Socket::SocketErrno m_err; /** * \brief Node. diff --git a/src/internet/model/ipv6-routing-protocol.cc b/src/internet/model/ipv6-routing-protocol.cc index 94d63edf6..c073d20a5 100644 --- a/src/internet/model/ipv6-routing-protocol.cc +++ b/src/internet/model/ipv6-routing-protocol.cc @@ -19,8 +19,6 @@ #include "ipv6-routing-protocol.h" -#include "ipv6-route.h" - #include "ns3/assert.h" namespace ns3 diff --git a/src/internet/model/ipv6-routing-protocol.h b/src/internet/model/ipv6-routing-protocol.h index dfd67f249..b9cbcb700 100644 --- a/src/internet/model/ipv6-routing-protocol.h +++ b/src/internet/model/ipv6-routing-protocol.h @@ -132,10 +132,10 @@ class Ipv6RoutingProtocol : public Object virtual bool RouteInput(Ptr p, const Ipv6Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) = 0; + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) = 0; /** * \brief Notify when specified interface goes UP. diff --git a/src/internet/model/ipv6-routing-table-entry.cc b/src/internet/model/ipv6-routing-table-entry.cc index 9d146a9a4..94464d117 100644 --- a/src/internet/model/ipv6-routing-table-entry.cc +++ b/src/internet/model/ipv6-routing-table-entry.cc @@ -121,11 +121,7 @@ Ipv6RoutingTableEntry::~Ipv6RoutingTableEntry() bool Ipv6RoutingTableEntry::IsHost() const { - if (m_destNetworkPrefix == Ipv6Prefix::GetOnes()) - { - return true; - } - return false; + return m_destNetworkPrefix == Ipv6Prefix::GetOnes(); } Ipv6Address @@ -155,11 +151,7 @@ Ipv6RoutingTableEntry::IsNetwork() const bool Ipv6RoutingTableEntry::IsDefault() const { - if (m_dest == Ipv6Address::GetZero()) - { - return true; - } - return false; + return m_dest == Ipv6Address::GetZero(); } Ipv6Address @@ -177,11 +169,7 @@ Ipv6RoutingTableEntry::GetDestNetworkPrefix() const bool Ipv6RoutingTableEntry::IsGateway() const { - if (m_gateway == Ipv6Address::GetZero()) - { - return false; - } - return true; + return m_gateway != Ipv6Address::GetZero(); } Ipv6Address diff --git a/src/internet/model/ipv6-static-routing.cc b/src/internet/model/ipv6-static-routing.cc index 514bdd341..f6a752296 100644 --- a/src/internet/model/ipv6-static-routing.cc +++ b/src/internet/model/ipv6-static-routing.cc @@ -19,9 +19,9 @@ #include "ipv6-static-routing.h" +#include "ipv6-route.h" #include "ipv6-routing-table-entry.h" -#include "ns3/ipv6-route.h" #include "ns3/log.h" #include "ns3/names.h" #include "ns3/net-device.h" @@ -715,10 +715,10 @@ bool Ipv6StaticRouting::RouteInput(Ptr p, const Ipv6Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) { NS_LOG_FUNCTION(this << p << header << header.GetSource() << header.GetDestination() << idev); NS_ASSERT(m_ipv6); @@ -750,7 +750,7 @@ Ipv6StaticRouting::RouteInput(Ptr p, } // Check if input device supports IP forwarding - if (m_ipv6->IsForwarding(iif) == false) + if (!m_ipv6->IsForwarding(iif)) { NS_LOG_LOGIC("Forwarding disabled for this interface"); if (!ecb.IsNull()) diff --git a/src/internet/model/ipv6-static-routing.h b/src/internet/model/ipv6-static-routing.h index 4f554a1e3..f1a3273a2 100644 --- a/src/internet/model/ipv6-static-routing.h +++ b/src/internet/model/ipv6-static-routing.h @@ -257,10 +257,10 @@ class Ipv6StaticRouting : public Ipv6RoutingProtocol bool RouteInput(Ptr p, const Ipv6Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override; + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override; void NotifyInterfaceUp(uint32_t interface) override; void NotifyInterfaceDown(uint32_t interface) override; diff --git a/src/internet/model/ipv6.h b/src/internet/model/ipv6.h index 221b4f114..45e8ee610 100644 --- a/src/internet/model/ipv6.h +++ b/src/internet/model/ipv6.h @@ -383,12 +383,14 @@ class Ipv6 : public Object Ptr route) = 0; /** - * \brief Register the IPv6 Extensions. + * \brief Register the IPv6 Extensions. Does nothing if the Extensions have been already + * registered. */ virtual void RegisterExtensions() = 0; /** - * \brief Register the IPv6 Options. + * \brief Register the IPv6 Options. Does nothing if the Options have been already + * registered. */ virtual void RegisterOptions() = 0; diff --git a/src/internet/model/rip.cc b/src/internet/model/rip.cc index a6b4bd607..f51a36f28 100644 --- a/src/internet/model/rip.cc +++ b/src/internet/model/rip.cc @@ -19,18 +19,19 @@ #include "rip.h" +#include "ipv4-packet-info-tag.h" +#include "ipv4-route.h" +#include "loopback-net-device.h" +#include "rip-header.h" +#include "udp-header.h" + #include "ns3/abort.h" #include "ns3/assert.h" #include "ns3/enum.h" -#include "ns3/ipv4-packet-info-tag.h" -#include "ns3/ipv4-route.h" #include "ns3/log.h" -#include "ns3/loopback-net-device.h" #include "ns3/names.h" #include "ns3/node.h" #include "ns3/random-variable-stream.h" -#include "ns3/rip-header.h" -#include "ns3/udp-header.h" #include "ns3/uinteger.h" #include @@ -153,7 +154,7 @@ Rip::DoInitialize() for (uint32_t j = 0; j < m_ipv4->GetNAddresses(i); j++) { Ipv4InterfaceAddress address = m_ipv4->GetAddress(i, j); - if (address.GetScope() != Ipv4InterfaceAddress::HOST && activeInterface == true) + if (address.GetScope() != Ipv4InterfaceAddress::HOST && activeInterface) { NS_LOG_LOGIC("RIP: adding socket to " << address.GetLocal()); TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory"); @@ -241,10 +242,10 @@ bool Rip::RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) { NS_LOG_FUNCTION(this << p << header << header.GetSource() << header.GetDestination() << idev); @@ -290,7 +291,7 @@ Rip::RouteInput(Ptr p, } // Check if input device supports IP forwarding - if (m_ipv4->IsForwarding(iif) == false) + if (!m_ipv4->IsForwarding(iif)) { NS_LOG_LOGIC("Forwarding disabled for this interface"); if (!ecb.IsNull()) @@ -365,8 +366,7 @@ Rip::NotifyInterfaceUp(uint32_t i) { Ipv4InterfaceAddress address = m_ipv4->GetAddress(i, j); - if (address.GetScope() != Ipv4InterfaceAddress::HOST && sendSocketFound == false && - activeInterface == true) + if (address.GetScope() != Ipv4InterfaceAddress::HOST && !sendSocketFound && activeInterface) { NS_LOG_LOGIC("RIP: adding sending socket to " << address.GetLocal()); TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory"); diff --git a/src/internet/model/rip.h b/src/internet/model/rip.h index a9be6af8f..850c3d8c9 100644 --- a/src/internet/model/rip.h +++ b/src/internet/model/rip.h @@ -192,10 +192,10 @@ class Rip : public Ipv4RoutingProtocol bool RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override; + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override; void NotifyInterfaceUp(uint32_t interface) override; void NotifyInterfaceDown(uint32_t interface) override; void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) override; diff --git a/src/internet/model/ripng.cc b/src/internet/model/ripng.cc index 232d8688d..6fae1a8fe 100644 --- a/src/internet/model/ripng.cc +++ b/src/internet/model/ripng.cc @@ -19,18 +19,19 @@ #include "ripng.h" +#include "ipv6-packet-info-tag.h" +#include "ipv6-route.h" +#include "ripng-header.h" +#include "udp-header.h" + #include "ns3/abort.h" #include "ns3/assert.h" #include "ns3/enum.h" -#include "ns3/ipv6-packet-info-tag.h" -#include "ns3/ipv6-route.h" #include "ns3/log.h" #include "ns3/names.h" #include "ns3/node.h" #include "ns3/random-variable-stream.h" -#include "ns3/ripng-header.h" #include "ns3/simulator.h" -#include "ns3/udp-header.h" #include "ns3/uinteger.h" #include @@ -147,7 +148,7 @@ RipNg::DoInitialize() for (uint32_t j = 0; j < m_ipv6->GetNAddresses(i); j++) { Ipv6InterfaceAddress address = m_ipv6->GetAddress(i, j); - if (address.GetScope() == Ipv6InterfaceAddress::LINKLOCAL && activeInterface == true) + if (address.GetScope() == Ipv6InterfaceAddress::LINKLOCAL && activeInterface) { NS_LOG_LOGIC("RIPng: adding socket to " << address.GetAddress()); TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory"); @@ -233,10 +234,10 @@ bool RipNg::RouteInput(Ptr p, const Ipv6Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) { NS_LOG_FUNCTION(this << p << header << header.GetSource() << header.GetDestination() << idev); @@ -263,7 +264,7 @@ RipNg::RouteInput(Ptr p, } // Check if input device supports IP forwarding - if (m_ipv6->IsForwarding(iif) == false) + if (!m_ipv6->IsForwarding(iif)) { NS_LOG_LOGIC("Forwarding disabled for this interface"); if (!ecb.IsNull()) @@ -332,8 +333,8 @@ RipNg::NotifyInterfaceUp(uint32_t i) { Ipv6InterfaceAddress address = m_ipv6->GetAddress(i, j); - if (address.GetScope() == Ipv6InterfaceAddress::LINKLOCAL && sendSocketFound == false && - activeInterface == true) + if (address.GetScope() == Ipv6InterfaceAddress::LINKLOCAL && !sendSocketFound && + activeInterface) { NS_LOG_LOGIC("RIPng: adding sending socket to " << address.GetAddress()); TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory"); diff --git a/src/internet/model/ripng.h b/src/internet/model/ripng.h index 41a50fde4..08802a23b 100644 --- a/src/internet/model/ripng.h +++ b/src/internet/model/ripng.h @@ -194,10 +194,10 @@ class RipNg : public Ipv6RoutingProtocol bool RouteInput(Ptr p, const Ipv6Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override; + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override; void NotifyInterfaceUp(uint32_t interface) override; void NotifyInterfaceDown(uint32_t interface) override; void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address) override; diff --git a/src/internet/model/tcp-dctcp.cc b/src/internet/model/tcp-dctcp.cc index 86138993c..98b52dd80 100644 --- a/src/internet/model/tcp-dctcp.cc +++ b/src/internet/model/tcp-dctcp.cc @@ -20,9 +20,10 @@ #include "tcp-dctcp.h" +#include "tcp-socket-state.h" + #include "ns3/abort.h" #include "ns3/log.h" -#include "ns3/tcp-socket-state.h" namespace ns3 { @@ -142,7 +143,7 @@ TcpDctcp::PktsAcked(Ptr tcb, uint32_t segmentsAcked, const Time& { m_ackedBytesEcn += segmentsAcked * tcb->m_segmentSize; } - if (m_nextSeqFlag == false) + if (!m_nextSeqFlag) { m_nextSeq = tcb->m_nextTxSequence; m_nextSeqFlag = true; @@ -196,7 +197,7 @@ TcpDctcp::CeState0to1(Ptr tcb) tcb->m_rxBuffer->SetNextRxSequence(tmpRcvNxt); } - if (m_priorRcvNxtFlag == false) + if (!m_priorRcvNxtFlag) { m_priorRcvNxtFlag = true; } @@ -223,7 +224,7 @@ TcpDctcp::CeState1to0(Ptr tcb) tcb->m_rxBuffer->SetNextRxSequence(tmpRcvNxt); } - if (m_priorRcvNxtFlag == false) + if (!m_priorRcvNxtFlag) { m_priorRcvNxtFlag = true; } diff --git a/src/internet/model/tcp-l4-protocol.cc b/src/internet/model/tcp-l4-protocol.cc index 2c8fc4271..c1bf07228 100644 --- a/src/internet/model/tcp-l4-protocol.cc +++ b/src/internet/model/tcp-l4-protocol.cc @@ -21,10 +21,12 @@ #include "ipv4-end-point-demux.h" #include "ipv4-end-point.h" -#include "ipv4-l3-protocol.h" +#include "ipv4-route.h" +#include "ipv4-routing-protocol.h" #include "ipv6-end-point-demux.h" #include "ipv6-end-point.h" #include "ipv6-l3-protocol.h" +#include "ipv6-route.h" #include "ipv6-routing-protocol.h" #include "rtt-estimator.h" #include "tcp-congestion-ops.h" @@ -37,17 +39,16 @@ #include "ns3/assert.h" #include "ns3/boolean.h" -#include "ns3/ipv4-route.h" -#include "ns3/ipv6-route.h" #include "ns3/log.h" #include "ns3/node.h" #include "ns3/nstime.h" -#include "ns3/object-vector.h" +#include "ns3/object-map.h" #include "ns3/packet.h" #include "ns3/simulator.h" #include #include +#include #include namespace ns3 @@ -72,30 +73,33 @@ const uint8_t TcpL4Protocol::PROT_NUMBER = 6; TypeId TcpL4Protocol::GetTypeId() { - static TypeId tid = TypeId("ns3::TcpL4Protocol") - .SetParent() - .SetGroupName("Internet") - .AddConstructor() - .AddAttribute("RttEstimatorType", - "Type of RttEstimator objects.", - TypeIdValue(RttMeanDeviation::GetTypeId()), - MakeTypeIdAccessor(&TcpL4Protocol::m_rttTypeId), - MakeTypeIdChecker()) - .AddAttribute("SocketType", - "Socket type of TCP objects.", - TypeIdValue(TcpCubic::GetTypeId()), - MakeTypeIdAccessor(&TcpL4Protocol::m_congestionTypeId), - MakeTypeIdChecker()) - .AddAttribute("RecoveryType", - "Recovery type of TCP objects.", - TypeIdValue(TcpPrrRecovery::GetTypeId()), - MakeTypeIdAccessor(&TcpL4Protocol::m_recoveryTypeId), - MakeTypeIdChecker()) - .AddAttribute("SocketList", - "The list of sockets associated to this protocol.", - ObjectVectorValue(), - MakeObjectVectorAccessor(&TcpL4Protocol::m_sockets), - MakeObjectVectorChecker()); + static TypeId tid = + TypeId("ns3::TcpL4Protocol") + .SetParent() + .SetGroupName("Internet") + .AddConstructor() + .AddAttribute("RttEstimatorType", + "Type of RttEstimator objects.", + TypeIdValue(RttMeanDeviation::GetTypeId()), + MakeTypeIdAccessor(&TcpL4Protocol::m_rttTypeId), + MakeTypeIdChecker()) + .AddAttribute("SocketType", + "Socket type of TCP objects.", + TypeIdValue(TcpCubic::GetTypeId()), + MakeTypeIdAccessor(&TcpL4Protocol::m_congestionTypeId), + MakeTypeIdChecker()) + .AddAttribute("RecoveryType", + "Recovery type of TCP objects.", + TypeIdValue(TcpPrrRecovery::GetTypeId()), + MakeTypeIdAccessor(&TcpL4Protocol::m_recoveryTypeId), + MakeTypeIdChecker()) + .AddAttribute("SocketList", + "A container of sockets associated to this protocol. " + "The underlying type is an unordered map, the attribute name " + "is kept for backward compatibility.", + ObjectMapValue(), + MakeObjectMapAccessor(&TcpL4Protocol::m_sockets), + MakeObjectMapChecker()); return tid; } @@ -213,7 +217,7 @@ TcpL4Protocol::CreateSocket(TypeId congestionTypeId, TypeId recoveryTypeId) socket->SetCongestionControlAlgorithm(algo); socket->SetRecoveryAlgorithm(recovery); - m_sockets.push_back(socket); + m_sockets[m_socketIndex++] = socket; return socket; } @@ -380,7 +384,7 @@ TcpL4Protocol::ReceiveIcmp(Ipv6Address icmpSource, } } -enum IpL4Protocol::RxStatus +IpL4Protocol::RxStatus TcpL4Protocol::PacketReceived(Ptr packet, TcpHeader& incomingTcpHeader, const Address& source, @@ -448,7 +452,7 @@ TcpL4Protocol::NoEndPointsFound(const TcpHeader& incomingHeader, } } -enum IpL4Protocol::RxStatus +IpL4Protocol::RxStatus TcpL4Protocol::Receive(Ptr packet, const Ipv4Header& incomingIpHeader, Ptr incomingInterface) @@ -519,7 +523,7 @@ TcpL4Protocol::Receive(Ptr packet, return IpL4Protocol::RX_OK; } -enum IpL4Protocol::RxStatus +IpL4Protocol::RxStatus TcpL4Protocol::Receive(Ptr packet, const Ipv6Header& incomingIpHeader, Ptr interface) @@ -747,36 +751,30 @@ void TcpL4Protocol::AddSocket(Ptr socket) { NS_LOG_FUNCTION(this << socket); - std::vector>::iterator it = m_sockets.begin(); - while (it != m_sockets.end()) + for (auto& socketItem : m_sockets) { - if (*it == socket) + if (socketItem.second == socket) { return; } - - ++it; } - - m_sockets.push_back(socket); + m_sockets[m_socketIndex++] = socket; } bool TcpL4Protocol::RemoveSocket(Ptr socket) { NS_LOG_FUNCTION(this << socket); - std::vector>::iterator it = m_sockets.begin(); - while (it != m_sockets.end()) + for (auto& socketItem : m_sockets) { - if (*it == socket) + if (socketItem.second == socket) { - m_sockets.erase(it); + socketItem.second = nullptr; + m_sockets.erase(socketItem.first); return true; } - - ++it; } return false; diff --git a/src/internet/model/tcp-l4-protocol.h b/src/internet/model/tcp-l4-protocol.h index 3317c78c6..e68cca596 100644 --- a/src/internet/model/tcp-l4-protocol.h +++ b/src/internet/model/tcp-l4-protocol.h @@ -27,6 +27,7 @@ #include "ns3/sequence-number.h" #include +#include namespace ns3 { @@ -257,12 +258,12 @@ class TcpL4Protocol : public IpL4Protocol void DeAllocate(Ipv6EndPoint* endPoint); // From IpL4Protocol - enum IpL4Protocol::RxStatus Receive(Ptr p, - const Ipv4Header& incomingIpHeader, - Ptr incomingInterface) override; - enum IpL4Protocol::RxStatus Receive(Ptr p, - const Ipv6Header& incomingIpHeader, - Ptr incomingInterface) override; + IpL4Protocol::RxStatus Receive(Ptr p, + const Ipv4Header& incomingIpHeader, + Ptr incomingInterface) override; + IpL4Protocol::RxStatus Receive(Ptr p, + const Ipv6Header& incomingIpHeader, + Ptr incomingInterface) override; void ReceiveIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, @@ -311,10 +312,10 @@ class TcpL4Protocol : public IpL4Protocol * * \return RX_CSUM_FAILED if the checksum check fails, RX_OK otherwise */ - enum IpL4Protocol::RxStatus PacketReceived(Ptr packet, - TcpHeader& incomingTcpHeader, - const Address& source, - const Address& destination); + IpL4Protocol::RxStatus PacketReceived(Ptr packet, + TcpHeader& incomingTcpHeader, + const Address& source, + const Address& destination); /** * \brief Check if RST packet should be sent, and in case, send it @@ -334,13 +335,15 @@ class TcpL4Protocol : public IpL4Protocol const Address& incomingDAddr); private: - Ptr m_node; //!< the node this stack is associated with - Ipv4EndPointDemux* m_endPoints; //!< A list of IPv4 end points. - Ipv6EndPointDemux* m_endPoints6; //!< A list of IPv6 end points. - TypeId m_rttTypeId; //!< The RTT Estimator TypeId - TypeId m_congestionTypeId; //!< The socket TypeId - TypeId m_recoveryTypeId; //!< The recovery TypeId - std::vector> m_sockets; //!< list of sockets + Ptr m_node; //!< the node this stack is associated with + Ipv4EndPointDemux* m_endPoints; //!< A list of IPv4 end points. + Ipv6EndPointDemux* m_endPoints6; //!< A list of IPv6 end points. + TypeId m_rttTypeId; //!< The RTT Estimator TypeId + TypeId m_congestionTypeId; //!< The socket TypeId + TypeId m_recoveryTypeId; //!< The recovery TypeId + std::unordered_map> + m_sockets; //!< Unordered map of socket IDs and corresponding sockets + uint64_t m_socketIndex{0}; //!< index of the next socket to be created IpL4Protocol::DownTargetCallback m_downTarget; //!< Callback to send packets over IPv4 IpL4Protocol::DownTargetCallback6 m_downTarget6; //!< Callback to send packets over IPv6 diff --git a/src/internet/model/tcp-ledbat.cc b/src/internet/model/tcp-ledbat.cc index 9fad0fa57..2bab9ba4f 100644 --- a/src/internet/model/tcp-ledbat.cc +++ b/src/internet/model/tcp-ledbat.cc @@ -105,7 +105,7 @@ TcpLedbat::TcpLedbat() }; void -TcpLedbat::InitCircBuf(struct OwdCircBuf& buffer) +TcpLedbat::InitCircBuf(OwdCircBuf& buffer) { NS_LOG_FUNCTION(this); buffer.buffer.clear(); @@ -147,7 +147,7 @@ TcpLedbat::GetName() const } uint32_t -TcpLedbat::MinCircBuf(struct OwdCircBuf& b) +TcpLedbat::MinCircBuf(OwdCircBuf& b) { NS_LOG_FUNCTION_NOARGS(); if (b.buffer.empty()) @@ -239,7 +239,7 @@ TcpLedbat::CongestionAvoidance(Ptr tcb, uint32_t segmentsAcked) } void -TcpLedbat::AddDelay(struct OwdCircBuf& cb, uint32_t owd, uint32_t maxlen) +TcpLedbat::AddDelay(OwdCircBuf& cb, uint32_t owd, uint32_t maxlen) { NS_LOG_FUNCTION(this << owd << maxlen << cb.buffer.size()); if (cb.buffer.empty()) diff --git a/src/internet/model/tcp-ledbat.h b/src/internet/model/tcp-ledbat.h index 7a8b248be..614150eae 100644 --- a/src/internet/model/tcp-ledbat.h +++ b/src/internet/model/tcp-ledbat.h @@ -139,10 +139,10 @@ class TcpLedbat : public TcpNewReno * * \param buffer The buffer to be initialised */ - void InitCircBuf(struct OwdCircBuf& buffer); + void InitCircBuf(OwdCircBuf& buffer); /// Filter function used by LEDBAT for current delay - typedef uint32_t (*FilterFunction)(struct OwdCircBuf&); + typedef uint32_t (*FilterFunction)(OwdCircBuf&); /** * \brief Return the minimum delay of the buffer @@ -150,7 +150,7 @@ class TcpLedbat : public TcpNewReno * \param b The buffer * \return The minimum delay */ - static uint32_t MinCircBuf(struct OwdCircBuf& b); + static uint32_t MinCircBuf(OwdCircBuf& b); /** * \brief Return the value of current delay @@ -174,7 +174,7 @@ class TcpLedbat : public TcpNewReno * \param owd The new delay * \param maxlen The maximum permitted length */ - void AddDelay(struct OwdCircBuf& cb, uint32_t owd, uint32_t maxlen); + void AddDelay(OwdCircBuf& cb, uint32_t owd, uint32_t maxlen); /** * \brief Update the base delay buffer diff --git a/src/internet/model/tcp-option-sack-permitted.cc b/src/internet/model/tcp-option-sack-permitted.cc index cc79d2983..3410e3773 100644 --- a/src/internet/model/tcp-option-sack-permitted.cc +++ b/src/internet/model/tcp-option-sack-permitted.cc @@ -24,7 +24,6 @@ #include "tcp-option-sack-permitted.h" #include "ns3/log.h" -#include "ns3/tcp-header.h" namespace ns3 { diff --git a/src/internet/model/tcp-socket-base.cc b/src/internet/model/tcp-socket-base.cc index ee443db5c..49cba7a6e 100644 --- a/src/internet/model/tcp-socket-base.cc +++ b/src/internet/model/tcp-socket-base.cc @@ -27,8 +27,13 @@ #include "tcp-socket-base.h" #include "ipv4-end-point.h" +#include "ipv4-route.h" +#include "ipv4-routing-protocol.h" +#include "ipv4.h" #include "ipv6-end-point.h" #include "ipv6-l3-protocol.h" +#include "ipv6-route.h" +#include "ipv6-routing-protocol.h" #include "rtt-estimator.h" #include "tcp-congestion-ops.h" #include "tcp-header.h" @@ -37,6 +42,7 @@ #include "tcp-option-sack.h" #include "tcp-option-ts.h" #include "tcp-option-winscale.h" +#include "tcp-rate-ops.h" #include "tcp-recovery-ops.h" #include "tcp-rx-buffer.h" #include "tcp-tx-buffer.h" @@ -46,13 +52,6 @@ #include "ns3/double.h" #include "ns3/inet-socket-address.h" #include "ns3/inet6-socket-address.h" -#include "ns3/ipv4-interface-address.h" -#include "ns3/ipv4-route.h" -#include "ns3/ipv4-routing-protocol.h" -#include "ns3/ipv4.h" -#include "ns3/ipv6-route.h" -#include "ns3/ipv6-routing-protocol.h" -#include "ns3/ipv6.h" #include "ns3/log.h" #include "ns3/node.h" #include "ns3/object.h" @@ -60,7 +59,6 @@ #include "ns3/pointer.h" #include "ns3/simulation-singleton.h" #include "ns3/simulator.h" -#include "ns3/tcp-rate-ops.h" #include "ns3/trace-source-accessor.h" #include "ns3/uinteger.h" @@ -513,14 +511,14 @@ TcpSocketBase::SetRtt(Ptr rtt) } /* Inherit from Socket class: Returns error code */ -enum Socket::SocketErrno +Socket::SocketErrno TcpSocketBase::GetErrno() const { return m_errno; } /* Inherit from Socket class: Returns socket type, NS3_SOCK_STREAM */ -enum Socket::SocketType +Socket::SocketType TcpSocketBase::GetSocketType() const { return NS3_SOCK_STREAM; @@ -709,7 +707,7 @@ TcpSocketBase::Connect(const Address& address) // a v4 address and re-call this function Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom(address); Ipv6Address v6Addr = transport.GetIpv6(); - if (v6Addr.IsIpv4MappedAddress() == true) + if (v6Addr.IsIpv4MappedAddress()) { Ipv4Address v4Addr = v6Addr.GetIpv4MappedAddress(); return Connect(InetSocketAddress(v4Addr, transport.GetPort())); @@ -786,7 +784,7 @@ TcpSocketBase::Close() if (m_txBuffer->SizeFromSequence(m_tcb->m_nextTxSequence) > 0) { // App close with pending data must wait until all data transmitted - if (m_closeOnEmpty == false) + if (!m_closeOnEmpty) { m_closeOnEmpty = true; NS_LOG_INFO("Socket " << this << " deferring close, state " << TcpStateName[m_state]); @@ -1596,13 +1594,9 @@ void TcpSocketBase::ReadOptions(const TcpHeader& tcpHeader, uint32_t* bytesSacked) { NS_LOG_FUNCTION(this << tcpHeader); - TcpHeader::TcpOptionList::const_iterator it; - const TcpHeader::TcpOptionList options = tcpHeader.GetOptionList(); - for (it = options.begin(); it != options.end(); ++it) + for (const auto& option : tcpHeader.GetOptionList()) { - const Ptr option = (*it); - // Check only for ACK options here switch (option->GetKind()) { @@ -2881,6 +2875,11 @@ TcpSocketBase::SendRST() void TcpSocketBase::DeallocateEndPoint() { + // note: it shouldn't be necessary to invalidate the callback and manually call + // TcpL4Protocol::RemoveSocket. Alas, if one relies on the endpoint destruction + // callback, there's a weird memory access to a free'd area. Harmless, but valgrind + // considers it an error. + if (m_endPoint != nullptr) { CancelAllTimers(); @@ -3267,7 +3266,7 @@ TcpSocketBase::UpdateRttHistory(const SequenceNumber32& seq, uint32_t sz, bool i NS_LOG_FUNCTION(this); // update the history of sequence numbers used to calculate the RTT - if (isRetransmission == false) + if (!isRetransmission) { // This is the next expected one, just log at end m_history.emplace_back(seq, sz, Simulator::Now()); } @@ -4410,7 +4409,7 @@ TcpSocketBase::UpdateWindowSize(const TcpHeader& header) m_highRxMark = header.GetSequenceNumber(); update = true; } - if (update == true) + if (update) { m_rWnd = receivedWindow; NS_LOG_LOGIC("updating rWnd to " << m_rWnd); diff --git a/src/internet/model/tcp-tx-buffer.cc b/src/internet/model/tcp-tx-buffer.cc index d50947f04..105833b76 100644 --- a/src/internet/model/tcp-tx-buffer.cc +++ b/src/internet/model/tcp-tx-buffer.cc @@ -23,7 +23,7 @@ #include "ns3/abort.h" #include "ns3/log.h" #include "ns3/packet.h" -#include "ns3/tcp-option-ts.h" +#include "ns3/simulator.h" #include #include @@ -943,13 +943,13 @@ TcpTxBuffer::IsLost(const SequenceNumber32& seq) const // Search for the right iterator before calling IsLost() if (beginOfCurrentPacket >= seq) { - if ((*it)->m_lost == true) + if ((*it)->m_lost) { NS_LOG_INFO("seq=" << seq << " is lost because of lost flag"); return true; } - if ((*it)->m_sacked == true) + if ((*it)->m_sacked) { NS_LOG_INFO("seq=" << seq << " is not lost because of sacked flag"); return false; @@ -991,7 +991,7 @@ TcpTxBuffer::NextSeg(SequenceNumber32* seq, SequenceNumber32* seqHigh, bool isRe item = *it; // Condition 1.a , 1.b , and 1.c - if (item->m_retrans == false && item->m_sacked == false) + if (!item->m_retrans && !item->m_sacked) { if (item->m_lost) { @@ -1166,7 +1166,7 @@ TcpTxBuffer::IsLostRFC(const SequenceNumber32& seq, const PacketList::const_iter Ptr current; SequenceNumber32 beginOfCurrentPacket = seq; - if ((*segment)->m_sacked == true) + if ((*segment)->m_sacked) { return false; } diff --git a/src/internet/model/tcp-westwood-plus.cc b/src/internet/model/tcp-westwood-plus.cc index 353bd3a76..11af7e744 100644 --- a/src/internet/model/tcp-westwood-plus.cc +++ b/src/internet/model/tcp-westwood-plus.cc @@ -32,9 +32,6 @@ #include "tcp-westwood-plus.h" -#include "rtt-estimator.h" -#include "tcp-socket-base.h" - #include "ns3/log.h" #include "ns3/simulator.h" diff --git a/src/internet/model/udp-l4-protocol.cc b/src/internet/model/udp-l4-protocol.cc index 96d00b2e2..9442b530c 100644 --- a/src/internet/model/udp-l4-protocol.cc +++ b/src/internet/model/udp-l4-protocol.cc @@ -21,25 +21,25 @@ #include "ipv4-end-point-demux.h" #include "ipv4-end-point.h" -#include "ipv4-l3-protocol.h" +#include "ipv4-route.h" +#include "ipv4.h" #include "ipv6-end-point-demux.h" #include "ipv6-end-point.h" -#include "ipv6-l3-protocol.h" +#include "ipv6-route.h" +#include "ipv6.h" #include "udp-header.h" #include "udp-socket-factory-impl.h" #include "udp-socket-impl.h" #include "ns3/assert.h" #include "ns3/boolean.h" -#include "ns3/ipv4-route.h" -#include "ns3/ipv6-header.h" -#include "ns3/ipv6-route.h" -#include "ns3/ipv6.h" #include "ns3/log.h" #include "ns3/node.h" -#include "ns3/object-vector.h" +#include "ns3/object-map.h" #include "ns3/packet.h" +#include + namespace ns3 { @@ -53,15 +53,18 @@ const uint8_t UdpL4Protocol::PROT_NUMBER = 17; TypeId UdpL4Protocol::GetTypeId() { - static TypeId tid = TypeId("ns3::UdpL4Protocol") - .SetParent() - .SetGroupName("Internet") - .AddConstructor() - .AddAttribute("SocketList", - "The list of sockets associated to this protocol.", - ObjectVectorValue(), - MakeObjectVectorAccessor(&UdpL4Protocol::m_sockets), - MakeObjectVectorChecker()); + static TypeId tid = + TypeId("ns3::UdpL4Protocol") + .SetParent() + .SetGroupName("Internet") + .AddConstructor() + .AddAttribute("SocketList", + "A container of sockets associated to this protocol. " + "The underlying type is an unordered map, the attribute name " + "is kept for backward compatibility.", + ObjectMapValue(), + MakeObjectMapAccessor(&UdpL4Protocol::m_sockets), + MakeObjectMapChecker()); return tid; } @@ -135,9 +138,9 @@ void UdpL4Protocol::DoDispose() { NS_LOG_FUNCTION(this); - for (std::vector>::iterator i = m_sockets.begin(); i != m_sockets.end(); i++) + for (auto i = m_sockets.begin(); i != m_sockets.end(); i++) { - *i = nullptr; + i->second = nullptr; } m_sockets.clear(); @@ -167,7 +170,7 @@ UdpL4Protocol::CreateSocket() Ptr socket = CreateObject(); socket->SetNode(m_node); socket->SetUdp(this); - m_sockets.push_back(socket); + m_sockets[m_socketIndex++] = socket; return socket; } @@ -328,7 +331,7 @@ UdpL4Protocol::ReceiveIcmp(Ipv6Address icmpSource, } } -enum IpL4Protocol::RxStatus +IpL4Protocol::RxStatus UdpL4Protocol::Receive(Ptr packet, const Ipv4Header& header, Ptr interface) { NS_LOG_FUNCTION(this << packet << header); @@ -362,7 +365,7 @@ UdpL4Protocol::Receive(Ptr packet, const Ipv4Header& header, PtrGetObject()) + if (this->GetObject()) { NS_LOG_LOGIC(" No Ipv4 endpoints matched on UdpL4Protocol, trying Ipv6 " << this); Ptr fakeInterface; @@ -387,7 +390,7 @@ UdpL4Protocol::Receive(Ptr packet, const Ipv4Header& header, Ptr packet, const Ipv6Header& header, Ptr interface) { NS_LOG_FUNCTION(this << packet << header.GetSource() << header.GetDestination()); @@ -547,4 +550,21 @@ UdpL4Protocol::GetDownTarget6() const return m_downTarget6; } +bool +UdpL4Protocol::RemoveSocket(Ptr socket) +{ + NS_LOG_FUNCTION(this << socket); + + for (auto& socketItem : m_sockets) + { + if (socketItem.second == socket) + { + socketItem.second = nullptr; + m_sockets.erase(socketItem.first); + return true; + } + } + return false; +} + } // namespace ns3 diff --git a/src/internet/model/udp-l4-protocol.h b/src/internet/model/udp-l4-protocol.h index 920a971ca..8c3b24da9 100644 --- a/src/internet/model/udp-l4-protocol.h +++ b/src/internet/model/udp-l4-protocol.h @@ -26,6 +26,7 @@ #include "ns3/ptr.h" #include +#include namespace ns3 { @@ -183,6 +184,14 @@ class UdpL4Protocol : public IpL4Protocol */ void DeAllocate(Ipv6EndPoint* endPoint); + /** + * \brief Remove a socket from the internal list + * + * \param socket socket to remove + * \return true if the socket has been removed + */ + bool RemoveSocket(Ptr socket); + // called by UdpSocket. /** * \brief Send a packet via UDP (IPv4) @@ -242,12 +251,12 @@ class UdpL4Protocol : public IpL4Protocol Ptr route); // inherited from Ipv4L4Protocol - enum IpL4Protocol::RxStatus Receive(Ptr p, - const Ipv4Header& header, - Ptr interface) override; - enum IpL4Protocol::RxStatus Receive(Ptr p, - const Ipv6Header& header, - Ptr interface) override; + IpL4Protocol::RxStatus Receive(Ptr p, + const Ipv4Header& header, + Ptr interface) override; + IpL4Protocol::RxStatus Receive(Ptr p, + const Ipv6Header& header, + Ptr interface) override; void ReceiveIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, @@ -283,11 +292,13 @@ class UdpL4Protocol : public IpL4Protocol void NotifyNewAggregate() override; private: - Ptr m_node; //!< the node this stack is associated with + Ptr m_node; //!< The node this stack is associated with Ipv4EndPointDemux* m_endPoints; //!< A list of IPv4 end points. Ipv6EndPointDemux* m_endPoints6; //!< A list of IPv6 end points. - std::vector> m_sockets; //!< list of sockets + std::unordered_map> + m_sockets; //!< Unordered map of socket IDs and corresponding sockets + uint64_t m_socketIndex{0}; //!< Index of the next socket to be created IpL4Protocol::DownTargetCallback m_downTarget; //!< Callback to send packets over IPv4 IpL4Protocol::DownTargetCallback6 m_downTarget6; //!< Callback to send packets over IPv6 }; diff --git a/src/internet/model/udp-socket-impl.cc b/src/internet/model/udp-socket-impl.cc index c8be8d80e..0fd3c24d3 100644 --- a/src/internet/model/udp-socket-impl.cc +++ b/src/internet/model/udp-socket-impl.cc @@ -20,25 +20,24 @@ #include "udp-socket-impl.h" #include "ipv4-end-point.h" +#include "ipv4-header.h" +#include "ipv4-packet-info-tag.h" +#include "ipv4-route.h" +#include "ipv4-routing-protocol.h" +#include "ipv4.h" #include "ipv6-end-point.h" +#include "ipv6-l3-protocol.h" +#include "ipv6-packet-info-tag.h" +#include "ipv6-route.h" +#include "ipv6-routing-protocol.h" +#include "ipv6.h" #include "udp-l4-protocol.h" #include "ns3/inet-socket-address.h" #include "ns3/inet6-socket-address.h" -#include "ns3/ipv4-header.h" -#include "ns3/ipv4-packet-info-tag.h" -#include "ns3/ipv4-route.h" -#include "ns3/ipv4-routing-protocol.h" -#include "ns3/ipv4.h" -#include "ns3/ipv6-l3-protocol.h" -#include "ns3/ipv6-packet-info-tag.h" -#include "ns3/ipv6-route.h" -#include "ns3/ipv6-routing-protocol.h" -#include "ns3/ipv6.h" #include "ns3/log.h" #include "ns3/node.h" #include "ns3/trace-source-accessor.h" -#include "ns3/udp-socket-factory.h" #include @@ -153,14 +152,14 @@ UdpSocketImpl::SetUdp(Ptr udp) m_udp = udp; } -enum Socket::SocketErrno +Socket::SocketErrno UdpSocketImpl::GetErrno() const { NS_LOG_FUNCTION(this); return m_errno; } -enum Socket::SocketType +Socket::SocketType UdpSocketImpl::GetSocketType() const { return NS3_SOCK_DGRAM; @@ -177,6 +176,10 @@ void UdpSocketImpl::Destroy() { NS_LOG_FUNCTION(this); + if (m_udp) + { + m_udp->RemoveSocket(this); + } m_endPoint = nullptr; } @@ -184,6 +187,10 @@ void UdpSocketImpl::Destroy6() { NS_LOG_FUNCTION(this); + if (m_udp) + { + m_udp->RemoveSocket(this); + } m_endPoint6 = nullptr; } @@ -193,13 +200,11 @@ UdpSocketImpl::DeallocateEndPoint() { if (m_endPoint != nullptr) { - m_endPoint->SetDestroyCallback(MakeNullCallback()); m_udp->DeAllocate(m_endPoint); m_endPoint = nullptr; } if (m_endPoint6 != nullptr) { - m_endPoint6->SetDestroyCallback(MakeNullCallback()); m_udp->DeAllocate(m_endPoint6); m_endPoint6 = nullptr; } @@ -390,7 +395,7 @@ int UdpSocketImpl::Close() { NS_LOG_FUNCTION(this); - if (m_shutdownRecv == true && m_shutdownSend == true) + if (m_shutdownRecv && m_shutdownSend) { m_errno = Socket::ERROR_BADF; return -1; @@ -406,7 +411,7 @@ int UdpSocketImpl::Connect(const Address& address) { NS_LOG_FUNCTION(this << address); - if (InetSocketAddress::IsMatchingType(address) == true) + if (InetSocketAddress::IsMatchingType(address)) { InetSocketAddress transport = InetSocketAddress::ConvertFrom(address); m_defaultAddress = Address(transport.GetIpv4()); @@ -415,7 +420,7 @@ UdpSocketImpl::Connect(const Address& address) m_connected = true; NotifyConnectionSucceeded(); } - else if (Inet6SocketAddress::IsMatchingType(address) == true) + else if (Inet6SocketAddress::IsMatchingType(address)) { Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom(address); m_defaultAddress = Address(transport.GetIpv6()); @@ -457,7 +462,7 @@ int UdpSocketImpl::DoSend(Ptr p) { NS_LOG_FUNCTION(this << p); - if ((m_endPoint == nullptr) && (Ipv4Address::IsMatchingType(m_defaultAddress) == true)) + if (m_endPoint == nullptr && Ipv4Address::IsMatchingType(m_defaultAddress)) { if (Bind() == -1) { @@ -466,7 +471,7 @@ UdpSocketImpl::DoSend(Ptr p) } NS_ASSERT(m_endPoint != nullptr); } - else if ((m_endPoint6 == nullptr) && (Ipv6Address::IsMatchingType(m_defaultAddress) == true)) + else if (m_endPoint6 == nullptr && Ipv6Address::IsMatchingType(m_defaultAddress)) { if (Bind6() == -1) { diff --git a/src/internet/test/examples-to-run.py b/src/internet/test/examples-to-run.py index 1266e93c1..879313d55 100644 --- a/src/internet/test/examples-to-run.py +++ b/src/internet/test/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/src/internet/test/internet-stack-helper-test-suite.cc b/src/internet/test/internet-stack-helper-test-suite.cc new file mode 100644 index 000000000..367ae3947 --- /dev/null +++ b/src/internet/test/internet-stack-helper-test-suite.cc @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2023 Universita' di Firenze + * + * 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: Tommaso Pecorella + */ + +#include "ns3/internet-stack-helper.h" +#include "ns3/log.h" +#include "ns3/node.h" +#include "ns3/test.h" + +#include + +using namespace ns3; + +NS_LOG_COMPONENT_DEFINE("InternetStackHelperTestSuite"); + +/** + * \ingroup internet-test + * + * \brief InternetStackHelper Test + */ +class InternetStackHelperTestCase : public TestCase +{ + public: + InternetStackHelperTestCase(); + + private: + void DoRun() override; + void DoTeardown() override; +}; + +InternetStackHelperTestCase::InternetStackHelperTestCase() + : TestCase("InternetStackHelperTestCase") +{ +} + +void +InternetStackHelperTestCase::DoRun() +{ + // Checks: + // 1. IPv4 only, add IPv4 + IPv6 (result, IPv4 + IPv6) + // 2. IPv6 only, add IPv4 + IPv6 (result, IPv4 + IPv6) + // 3. IPv4 + IPv6, add IPv4 + IPv6 (result, IPv4 + IPv6) + + Ptr nodeIpv4Only = CreateObject(); + Ptr nodeIpv6Only = CreateObject(); + Ptr nodeIpv46 = CreateObject(); + + InternetStackHelper internet; + + internet.SetIpv4StackInstall(true); + internet.SetIpv6StackInstall(false); + internet.Install(nodeIpv4Only); + + internet.SetIpv4StackInstall(false); + internet.SetIpv6StackInstall(true); + internet.Install(nodeIpv6Only); + + internet.SetIpv4StackInstall(true); + internet.SetIpv6StackInstall(true); + internet.Install(nodeIpv46); + + // Check that the three nodes have only the intended IP stack. + NS_TEST_EXPECT_MSG_NE(nodeIpv4Only->GetObject(), + nullptr, + "IPv4 not found on IPv4-only node (should have been there)"); + NS_TEST_EXPECT_MSG_EQ(nodeIpv4Only->GetObject(), + nullptr, + "IPv6 found on IPv4-only node (should not have been there)"); + + NS_TEST_EXPECT_MSG_EQ(nodeIpv6Only->GetObject(), + nullptr, + "IPv4 found on IPv6-only node (should not have been there)"); + NS_TEST_EXPECT_MSG_NE(nodeIpv6Only->GetObject(), + nullptr, + "IPv6 not found on IPv6-only node (should have been there)"); + + NS_TEST_EXPECT_MSG_NE(nodeIpv46->GetObject(), + nullptr, + "IPv4 not found on dual stack node (should have been there)"); + NS_TEST_EXPECT_MSG_NE(nodeIpv46->GetObject(), + nullptr, + "IPv6 not found on dual stack node (should have been there)"); + + // Now we install IPv4 and IPv6 on the IPv4-only node + // IPv4 is already there, no error should happen. + internet.Install(nodeIpv4Only); + // Now we install IPv4 and IPv6 on the IPv6-only node, + // IPv6 is already there, no error should happen. + internet.Install(nodeIpv6Only); + // Now we install IPv4 and IPv6 on the dual stack node + // IPv4 and IPv6 are already there, no error should happen. + internet.Install(nodeIpv46); + + // Check that the three nodes have both IPv4 and IPv6. + NS_TEST_EXPECT_MSG_NE( + nodeIpv4Only->GetObject(), + nullptr, + "IPv4 not found on IPv4-only, now dual stack node (should have been there)"); + NS_TEST_EXPECT_MSG_NE( + nodeIpv4Only->GetObject(), + nullptr, + "IPv6 not found on IPv4-only, now dual stack node (should have been there)"); + + NS_TEST_EXPECT_MSG_NE( + nodeIpv6Only->GetObject(), + nullptr, + "IPv4 not found on IPv6-only, now dual stack node (should have been there)"); + NS_TEST_EXPECT_MSG_NE( + nodeIpv6Only->GetObject(), + nullptr, + "IPv6 not found on IPv6-only, now dual stack node (should have been there)"); + + NS_TEST_EXPECT_MSG_NE(nodeIpv46->GetObject(), + nullptr, + "IPv4 not found on dual stack node (should have been there)"); + NS_TEST_EXPECT_MSG_NE(nodeIpv46->GetObject(), + nullptr, + "IPv6 not found on dual stack node (should have been there)"); +} + +void +InternetStackHelperTestCase::DoTeardown() +{ + Simulator::Destroy(); +} + +/** + * \ingroup internet-test + * + * \brief InternetStackHelper TestSuite + */ +class InternetStackHelperTestSuite : public TestSuite +{ + public: + InternetStackHelperTestSuite() + : TestSuite("internet-stack-helper", UNIT) + { + AddTestCase(new InternetStackHelperTestCase(), TestCase::QUICK); + } +}; + +static InternetStackHelperTestSuite + g_internetStackHelperTestSuite; //!< Static variable for test initialization diff --git a/src/internet/test/ipv4-global-routing-test-suite.cc b/src/internet/test/ipv4-global-routing-test-suite.cc index 56932ecda..5f257af86 100644 --- a/src/internet/test/ipv4-global-routing-test-suite.cc +++ b/src/internet/test/ipv4-global-routing-test-suite.cc @@ -940,7 +940,7 @@ Ipv4DynamicGlobalRoutingTestCase::HandleRead(Ptr socket) void Ipv4DynamicGlobalRoutingTestCase::SendData(uint8_t index) { - if (m_sendSocks[index].second == false) + if (!m_sendSocks[index].second) { return; } diff --git a/src/internet/test/ipv4-list-routing-test-suite.cc b/src/internet/test/ipv4-list-routing-test-suite.cc index a111b7720..290a8490e 100644 --- a/src/internet/test/ipv4-list-routing-test-suite.cc +++ b/src/internet/test/ipv4-list-routing-test-suite.cc @@ -20,7 +20,8 @@ #include "ns3/ipv4-routing-protocol.h" #include "ns3/test.h" -using namespace ns3; +namespace ns3 +{ /** * \ingroup internet-test @@ -41,10 +42,10 @@ class Ipv4ARouting : public Ipv4RoutingProtocol bool RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override { return false; } @@ -93,10 +94,10 @@ class Ipv4BRouting : public Ipv4RoutingProtocol bool RouteInput(Ptr p, const Ipv4Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override { return false; } @@ -217,3 +218,5 @@ class Ipv4ListRoutingTestSuite : public TestSuite static Ipv4ListRoutingTestSuite g_ipv4ListRoutingTestSuite; //!< Static variable for test initialization + +} // namespace ns3 diff --git a/src/internet/test/ipv6-list-routing-test-suite.cc b/src/internet/test/ipv6-list-routing-test-suite.cc index bdb081db0..181a578ee 100644 --- a/src/internet/test/ipv6-list-routing-test-suite.cc +++ b/src/internet/test/ipv6-list-routing-test-suite.cc @@ -21,7 +21,8 @@ #include "ns3/ipv6-routing-protocol.h" #include "ns3/test.h" -using namespace ns3; +namespace ns3 +{ /** * \ingroup internet-test @@ -42,10 +43,10 @@ class Ipv6ARouting : public Ipv6RoutingProtocol bool RouteInput(Ptr p, const Ipv6Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override { return false; } @@ -108,10 +109,10 @@ class Ipv6BRouting : public Ipv6RoutingProtocol bool RouteInput(Ptr p, const Ipv6Header& header, Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb) override + const UnicastForwardCallback& ucb, + const MulticastForwardCallback& mcb, + const LocalDeliverCallback& lcb, + const ErrorCallback& ecb) override { return false; } @@ -246,3 +247,5 @@ class Ipv6ListRoutingTestSuite : public TestSuite static Ipv6ListRoutingTestSuite g_ipv6ListRoutingTestSuite; //!< Static variable for test initialization + +} // namespace ns3 diff --git a/src/internet/test/tcp-endpoint-bug2211.cc b/src/internet/test/tcp-endpoint-bug2211.cc index d220664b0..026938629 100644 --- a/src/internet/test/tcp-endpoint-bug2211.cc +++ b/src/internet/test/tcp-endpoint-bug2211.cc @@ -119,7 +119,7 @@ TcpEndPointBug2211Test::DoRun() TypeId tid = TcpSocketFactory::GetTypeId(); Ptr sink = Socket::CreateSocket(node, tid); - if (m_v6 == false) + if (!m_v6) { sink->Bind(InetSocketAddress(Ipv4Address::GetAny(), 9)); } @@ -135,7 +135,7 @@ TcpEndPointBug2211Test::DoRun() source->Bind(); source->SetConnectCallback(MakeCallback(&TcpEndPointBug2211Test::HandleConnect, this), MakeNullCallback>()); - if (m_v6 == false) + if (!m_v6) { source->Connect(InetSocketAddress(Ipv4Address::GetLoopback(), 9)); } diff --git a/src/internet/test/tcp-pacing-test.cc b/src/internet/test/tcp-pacing-test.cc index 8f2b4a2d6..5c53212bb 100644 --- a/src/internet/test/tcp-pacing-test.cc +++ b/src/internet/test/tcp-pacing-test.cc @@ -336,14 +336,7 @@ TcpPacingTest::Tx(const Ptr p, const TcpHeader& h, SocketWho who) // so add an additional m_segmentSize to bytesInFlight uint32_t soonBytesInFlight = m_bytesInFlight + m_segmentSize; bool canPacketBeSent = ((m_curCwnd - soonBytesInFlight) >= m_segmentSize); - if (!canPacketBeSent || (m_curCwnd == 0)) - { - m_isFullCwndSent = true; - } - else - { - m_isFullCwndSent = false; - } + m_isFullCwndSent = (!canPacketBeSent || m_curCwnd == 0); m_nextPacketInterval = m_expectedInterval; NS_LOG_DEBUG("Next expected interval (s): " << m_nextPacketInterval.GetSeconds()); } diff --git a/src/internet/test/tcp-test.cc b/src/internet/test/tcp-test.cc index ee79b9a49..8a6af9e4f 100644 --- a/src/internet/test/tcp-test.cc +++ b/src/internet/test/tcp-test.cc @@ -226,7 +226,7 @@ TcpTestCase::DoRun() memset(m_sourceRxPayload, 0, m_totalBytes); memset(m_serverRxPayload, 0, m_totalBytes); - if (m_useIpv6 == true) + if (m_useIpv6) { SetupDefaultSim6(); } diff --git a/src/lr-wpan/doc/lr-wpan.rst b/src/lr-wpan/doc/lr-wpan.rst index a94300d2f..25d2bee6b 100644 --- a/src/lr-wpan/doc/lr-wpan.rst +++ b/src/lr-wpan/doc/lr-wpan.rst @@ -155,11 +155,11 @@ IEEE 802.15.4 supports 4 types of scanning: * *Energy Detection (ED) Scan:* In an energy scan, a device or a coordinator scan a set number of channels looking for traces of energy. The maximum energy registered during a given amount of time is stored. Energy scan is typically used to measure the quality of a channel at any given time. For this reason, coordinators often use this scan before initiating a PAN on a channel. -* *Active Scan:* A device sends beacon requests on a set number of channels looking for a PAN coordinator. The receiving coordinator must be configured on non-beacon mode. Coordinators on beacon-mode ignore these requests. The coordinators who accept the request, respond with a beacon. After an active scan take place, during the association process devices extract the information in the PAN descriptors from the collected beacons and based on this information (e.g. channel, LQI level), choose a coordinator to associate with. +* *Active Scan:* A device sends ``beacon request commands`` on a set number of channels looking for a PAN coordinator. The receiving coordinator must be configured on non-beacon mode. Coordinators on beacon-mode ignore these requests. The coordinators who accept the request, respond with a beacon. After an active scan take place, during the association process devices extract the information in the PAN descriptors from the collected beacons and based on this information (e.g. channel, LQI level), choose a coordinator to associate with. -* *Passive Scan:* In a passive scan, no beacon requests are sent. Devices scan a set number of channels looking for beacons currently being transmitted (coordinators in beacon-mode). Like in the active scan, the information from beacons is stored in PAN descriptors and used by the device to choose a coordinator to associate with. +* *Passive Scan:* In a passive scan, no ``beacon requests commands`` are sent. Devices scan a set number of channels looking for beacons currently being transmitted (coordinators in beacon-mode). Like in the active scan, the information from beacons is stored in PAN descriptors and used by the device to choose a coordinator to associate with. -* *Orphan Scan:* +* *Orphan Scan:* Orphan scan is used typically by device as a result of repeated communication failure attempts with a coordinator. In other words, an orphan scan represents the intent of a device to relocate its coordinator. In some situations, it can be used by devices higher layers to not only rejoin a network but also join a network for the first time. In an orphan scan, a device send a ``orphan notification command`` to a given list of channels. If a coordinator receives this notification, it responds to the device with a ``coordinator realignment command``. In active and passive scans, the link quality indicator (LQI) is the main parameter used to determine the optimal coordinator. LQI values range from 0 to 255. Where 255 is the highest quality link value and 0 the lowest. Typically, a link lower than 127 is considered a link with poor quality. @@ -315,7 +315,7 @@ running on both, slotted and unslotted mode (CSMA/CA) of 802.15.4 operation for - The standard describes the support of multiple PHY band-modulations but currently, only 250kbps O-QPSK (channel page 0) is supported. - Active and passive MAC scans are able to obtain a LQI value from a beacon frame, however, the scan primitives assumes LQI is correctly implemented and does not check the validity of its value. - Configuration of the ED thresholds are currently not supported. -- Orphan scans are not supported. +- Coordinator realignment command is only supported in orphan scans. - Disassociation primitives are not supported. - Security is not supported. - Beacon enabled mode GTS are not supported. @@ -324,8 +324,10 @@ References ========== * Wireless Medium Access Control (MAC) and Physical Layer (PHY) Specifications for Low-Rate Wireless Personal Area Networks (WPANs), IEEE Computer Society, IEEE Std 802.15.4-2006, 8 September 2006. +* IEEE Standard for Local and metropolitan area networks--Part 15.4: Low-Rate Wireless Personal Area Networks (LR-WPANs)," in IEEE Std 802.15.4-2011 (Revision of IEEE Std 802.15.4-2006) , vol., no., pp.1-314, 5 Sept. 2011, doi: 10.1109/IEEESTD.2011.6012487. * J. Zheng and Myung J. Lee, "A comprehensive performance study of IEEE 802.15.4," Sensor Network Operations, IEEE Press, Wiley Interscience, Chapter 4, pp. 218-237, 2006. * Alberto Gallegos Ramonet and Taku Noguchi. 2020. LR-WPAN: Beacon Enabled Direct Transmissions on Ns-3. In 2020 the 6th International Conference on Communication and Information Processing (ICCIP 2020). Association for Computing Machinery, New York, NY, USA, 115–122. https://doi.org/10.1145/3442555.3442574. +* Gallegos Ramonet, A.; Noguchi, T. Performance Analysis of IEEE 802.15.4 Bootstrap Process. Electronics 2022, 11, 4090. https://doi.org/10.3390/electronics11244090. Usage ***** @@ -362,6 +364,7 @@ The following examples have been written, which can be found in ``src/lr-wpan/ex * ``lr-wpan-active-scan.cc``: A simple example showing the use of an active scan in the MAC. * ``lr-wpan-mlme.cc``: Demonstrates the use of lr-wpan beacon mode. Nodes use a manual association (i.e. No bootstrap) in this example. * ``lr-wpan-bootstrap.cc``: Demonstrates the use of scanning and association working together to initiate a PAN. +* ``lr-wpan-orphan-scan.cc``: Demonstrates the use of an orphan scanning in a simple network joining procedure. In particular, the module enables a very simplified end-to-end data diff --git a/src/lr-wpan/examples/CMakeLists.txt b/src/lr-wpan/examples/CMakeLists.txt index c23e715e9..9122f66af 100644 --- a/src/lr-wpan/examples/CMakeLists.txt +++ b/src/lr-wpan/examples/CMakeLists.txt @@ -5,6 +5,7 @@ set(base_examples lr-wpan-phy-test lr-wpan-ed-scan lr-wpan-active-scan + lr-wpan-orphan-scan ) foreach( diff --git a/src/lr-wpan/examples/lr-wpan-orphan-scan.cc b/src/lr-wpan/examples/lr-wpan-orphan-scan.cc new file mode 100644 index 000000000..a094df01a --- /dev/null +++ b/src/lr-wpan/examples/lr-wpan-orphan-scan.cc @@ -0,0 +1,215 @@ +/* + * 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 + */ + +/* + * [00:00:00:00:00:00:00:01 | 00:01] [00:00:00:00:00:00:00:02 | ff:ff] + * PAN Coordinator 1 (PAN: 5) End Device + * |---------------------100m-----------------------| + * Channel 12 (Orphan Scan channels 11-14) + * + * + * This example demonstrate the usage of the MAC MLME-SCAN.request (ORPHAN scan) primitive as + * described by IEEE 802.15.4-2011 (See Figures 14 and 15). + * + * Orphan scan is used typically on devices as a result of repeated communication failures + * (For example, lossing too many ACK). An orphan scan represents the attempt of a device to + * relocate its coordinator. In some situations, it can be used by devices higher layers to not only + * rejoin a network but also join a network for the first time (Like in the joining through + * orphaning mechanism described in Zigbee networks). + * + * In this example, the end device is set to scan 4 channels (11~14) for a period of + * macResponseWaitTime until it finally gets in contact with the coordinator. + * On contact, the coordinator responds to the device (via coordinator realignment command) + * an assign it a short address. The detailed sequence of events is as following: + * + * 1) [Time 2s] The coordinator start a network in channel 12. + * 2) [Time 3s] The end device start orphan scan and transmits a orphan + * notification cmd on channel 11. + * 3) No response is received in channel 11, therefore, the device ends scanning on + * channel 11 after macResponseWaitTime and repeats step 2 in channel 12. + * 4) [Time 3.00269s] The orphan notification command is received by the coordinator in + * channel 12. The coordinator verify the requesting device and replies to the device + * with a coordinator realignment command containing the assigned short address [DE:AF]. + * 5) [Time 3.00646s] The device receives the coordinator realignment command, update its + * macPanId, macShortAddress, macCoordShortAddress and macCoordExtAddress. + * 6) Scanning of the remaining channels 13 and 14 is cancelled. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace ns3; + +static void +ScanConfirm(Ptr device, MlmeScanConfirmParams params) +{ + if (params.m_status == MLMESCAN_SUCCESS) + { + std::cout << Simulator::Now().As(Time::S) << " Node " << device->GetNode()->GetId() << " [" + << device->GetMac()->GetShortAddress() << " | " + << device->GetMac()->GetExtendedAddress() + << "] MLME-SCAN.confirm: Active scan status SUCCESSFUL " + << "(Coordinator found and address assigned) \n"; + } + else if (params.m_status == MLMESCAN_NO_BEACON) + { + std::cout << Simulator::Now().As(Time::S) << " Node " << device->GetNode()->GetId() << " [" + << device->GetMac()->GetShortAddress() << " | " + << device->GetMac()->GetExtendedAddress() + << "] MLME-SCAN.confirm: Could not locate coordinator " + << "(Coord realignment command not received) " + << "status: " << params.m_status << "\n"; + } + else + { + std::cout << Simulator::Now().As(Time::S) << " Node " << device->GetNode()->GetId() << " [" + << device->GetMac()->GetShortAddress() << " | " + << device->GetMac()->GetExtendedAddress() + << "] MLME-SCAN.confirm: An error occurred during scanning, " + << "status: " << params.m_status << "\n"; + } +} + +static void +OrphanIndication(Ptr device, MlmeOrphanIndicationParams params) +{ + // The steps taken by the coordinator on the event of an orphan indication + // are meant to be implemented by the next higher layer and are out of the scope of the + // standard. In this example, we simply accept the request , assign a fixed short address + // [DE:AF] and respond to the requesting device using a MLME-ORPHAN.response. + + std::cout << Simulator::Now().As(Time::S) << " Node " << device->GetNode()->GetId() << " [" + << device->GetMac()->GetShortAddress() << " | " + << device->GetMac()->GetExtendedAddress() + << "] MLME-ORPHAN.indication: Orphan Notification received, processing...\n"; + + MlmeOrphanResponseParams respParams; + respParams.m_assocMember = true; + respParams.m_orphanAddr = params.m_orphanAddr; + respParams.m_shortAddr = Mac16Address("DE:AF"); + + Simulator::ScheduleNow(&LrWpanMac::MlmeOrphanResponse, device->GetMac(), respParams); +} + +int +main(int argc, char* argv[]) +{ + LogComponentEnableAll(LogLevel(LOG_PREFIX_TIME | LOG_PREFIX_FUNC)); + + // Create 2 PAN coordinator nodes, and 1 end device + Ptr coord1 = CreateObject(); + Ptr endNode = CreateObject(); + + Ptr coord1NetDevice = CreateObject(); + Ptr endNodeNetDevice = CreateObject(); + + // PAN Coordinators configurations require to set both, the EUI-64 (extended address) + // and to assign their own short address. + coord1NetDevice->GetMac()->SetExtendedAddress(Mac64Address("00:00:00:00:00:00:00:01")); + coord1NetDevice->GetMac()->SetShortAddress(Mac16Address("00:01")); + + // Other devices must have only its EUI-64 and later on, their short address is + // potentially assigned by the coordinator. + endNodeNetDevice->GetMac()->SetExtendedAddress(Mac64Address("00:00:00:00:00:00:00:02")); + + // Configure Spectrum channel + Ptr channel = CreateObject(); + Ptr propModel = + CreateObject(); + Ptr delayModel = + CreateObject(); + channel->AddPropagationLossModel(propModel); + channel->SetPropagationDelayModel(delayModel); + + coord1NetDevice->SetChannel(channel); + endNodeNetDevice->SetChannel(channel); + + coord1->AddDevice(coord1NetDevice); + endNode->AddDevice(endNodeNetDevice); + + // Mobility + Ptr coord1Mobility = + CreateObject(); + coord1Mobility->SetPosition(Vector(0, 0, 0)); + coord1NetDevice->GetPhy()->SetMobility(coord1Mobility); + + Ptr endNodeMobility = + CreateObject(); + endNodeMobility->SetPosition(Vector(100, 0, 0)); + endNodeNetDevice->GetPhy()->SetMobility(endNodeMobility); + + // MAC layer Callbacks hooks + endNodeNetDevice->GetMac()->SetMlmeScanConfirmCallback( + MakeBoundCallback(&ScanConfirm, endNodeNetDevice)); + + coord1NetDevice->GetMac()->SetMlmeOrphanIndicationCallback( + MakeBoundCallback(&OrphanIndication, coord1NetDevice)); + + ///////////////// + // ORPHAN SCAN // + ///////////////// + + // PAN coordinator N0 (PAN 5) is set to channel 12 in non-beacon mode + // but answer to beacon request and orphan notification commands. + MlmeStartRequestParams params; + params.m_panCoor = true; + params.m_PanId = 5; + params.m_bcnOrd = 15; + params.m_sfrmOrd = 15; + params.m_logCh = 12; + Simulator::ScheduleWithContext(1, + Seconds(2.0), + &LrWpanMac::MlmeStartRequest, + coord1NetDevice->GetMac(), + params); + + // End device N1 is set to scan 4 channels looking for the presence of a coordinator. + // On each channel, a single orphan notification command is sent and a response is + // waited for a maximum time of macResponseWaitTime. If a reply is received from a + // coordinator within this time (coordinator realignment command), the programmed scans on + // other channels is suspended. + // Scan Channels are represented by bits 0-26 (27 LSB) + // ch 14 ch 11 + // | | + // 0x7800 = 0000000000000000111100000000000 + MlmeScanRequestParams scanParams; + scanParams.m_chPage = 0; + scanParams.m_scanChannels = 0x7800; + scanParams.m_scanType = MLMESCAN_ORPHAN; + Simulator::ScheduleWithContext(1, + Seconds(3.0), + &LrWpanMac::MlmeScanRequest, + endNodeNetDevice->GetMac(), + scanParams); + + Simulator::Stop(Seconds(2000)); + Simulator::Run(); + + Simulator::Destroy(); + return 0; +} diff --git a/src/lr-wpan/examples/lr-wpan-per-plot.cc b/src/lr-wpan/examples/lr-wpan-per-plot.cc index a770816f3..38d1f55f8 100644 --- a/src/lr-wpan/examples/lr-wpan-per-plot.cc +++ b/src/lr-wpan/examples/lr-wpan-per-plot.cc @@ -86,7 +86,7 @@ main(int argc, char* argv[]) Gnuplot perplot = Gnuplot("802.15.4-per-vs-rxSignal.eps"); Gnuplot2dDataset perdatasetExperimental("Experimental"); - Gnuplot2dDataset perdatasetTheorical("Theoretical"); + Gnuplot2dDataset perdatasetTheoretical("Theoretical"); Ptr n0 = CreateObject(); Ptr n1 = CreateObject(); @@ -214,7 +214,7 @@ main(int argc, char* argv[]) sensThreshold = false; } - perdatasetTheorical.Add(j, perTheoretical); + perdatasetTheoretical.Add(j, perTheoretical); } std::cout << "_____________________________________________________________________________\n"; @@ -229,7 +229,7 @@ main(int argc, char* argv[]) << "Rx Sensitivity (Theo) = " << sensitivityTheo << " dBm"; perplot.AddDataset(perdatasetExperimental); - perplot.AddDataset(perdatasetTheorical); + perplot.AddDataset(perdatasetTheoretical); perplot.SetTitle(os.str()); perplot.SetTerminal("postscript eps color enh \"Times-BoldItalic\""); diff --git a/src/lr-wpan/helper/lr-wpan-helper.cc b/src/lr-wpan/helper/lr-wpan-helper.cc index a4d72efe9..0f73ab867 100644 --- a/src/lr-wpan/helper/lr-wpan-helper.cc +++ b/src/lr-wpan/helper/lr-wpan-helper.cc @@ -361,7 +361,7 @@ LrWpanHelper::EnablePcapInternal(std::string prefix, Ptr file = pcapHelper.CreateFile(filename, std::ios::out, PcapHelper::DLT_IEEE802_15_4); - if (promiscuous == true) + if (promiscuous) { device->GetMac()->TraceConnectWithoutContext("PromiscSniffer", MakeBoundCallback(&PcapSniffLrWpan, file)); diff --git a/src/lr-wpan/model/lr-wpan-constants.h b/src/lr-wpan/model/lr-wpan-constants.h index 4241df33a..609b5dc35 100644 --- a/src/lr-wpan/model/lr-wpan-constants.h +++ b/src/lr-wpan/model/lr-wpan-constants.h @@ -119,7 +119,7 @@ constexpr uint32_t aMaxBeaconOverhead{75}; * The maximum size, in octets, of a beacon payload. * See IEEE 802.15.4-2011, section 6.4.1, Table 51. */ -constexpr uint32_t aMaxBeaconPayloadLenght{aMaxPhyPacketSize - aMaxBeaconOverhead}; +constexpr uint32_t aMaxBeaconPayloadLength{aMaxPhyPacketSize - aMaxBeaconOverhead}; /** @} */ diff --git a/src/lr-wpan/model/lr-wpan-csmaca.cc b/src/lr-wpan/model/lr-wpan-csmaca.cc index 7e3863b58..9975a9613 100644 --- a/src/lr-wpan/model/lr-wpan-csmaca.cc +++ b/src/lr-wpan/model/lr-wpan-csmaca.cc @@ -31,7 +31,9 @@ #include #undef NS_LOG_APPEND_CONTEXT -#define NS_LOG_APPEND_CONTEXT std::clog << "[address " << m_mac->GetShortAddress() << "] "; +#define NS_LOG_APPEND_CONTEXT \ + std::clog << "[address " << m_mac->GetShortAddress() << " | " << m_mac->GetExtendedAddress() \ + << "] "; namespace ns3 { diff --git a/src/lr-wpan/model/lr-wpan-fields.cc b/src/lr-wpan/model/lr-wpan-fields.cc index 955f8adef..59829e815 100644 --- a/src/lr-wpan/model/lr-wpan-fields.cc +++ b/src/lr-wpan/model/lr-wpan-fields.cc @@ -268,18 +268,18 @@ GtsFields::Serialize(Buffer::Iterator i) const if (m_gtsSpecDescCount > 0) { - uint8_t gtsDescStartAndLenght; + uint8_t gtsDescStartAndLength; i.WriteU8(GetGtsDirectionField()); for (int j = 0; j < m_gtsSpecDescCount; j++) { WriteTo(i, m_gtsList[j].m_gtsDescDevShortAddr); - gtsDescStartAndLenght = + gtsDescStartAndLength = (m_gtsList[j].m_gtsDescStartSlot & 0x0F) | // GTS descriptor bits 16-19 (m_gtsList[j].m_gtsDescLength & 0xF0); // GTS descriptor bits 20-23 - i.WriteU8(gtsDescStartAndLenght); + i.WriteU8(gtsDescStartAndLength); } } return i; @@ -296,14 +296,14 @@ GtsFields::Deserialize(Buffer::Iterator i) uint8_t gtsDirectionField = i.ReadU8(); SetGtsDirectionField(gtsDirectionField); - uint8_t gtsDescStartAndLenght; + uint8_t gtsDescStartAndLength; for (int j = 0; j < m_gtsSpecDescCount; j++) { ReadFrom(i, m_gtsList[j].m_gtsDescDevShortAddr); - gtsDescStartAndLenght = i.ReadU8(); - m_gtsList[j].m_gtsDescStartSlot = (gtsDescStartAndLenght) & (0x0F); - m_gtsList[j].m_gtsDescLength = (gtsDescStartAndLenght >> 4) & (0x0F); + gtsDescStartAndLength = i.ReadU8(); + m_gtsList[j].m_gtsDescStartSlot = (gtsDescStartAndLength) & (0x0F); + m_gtsList[j].m_gtsDescLength = (gtsDescStartAndLength >> 4) & (0x0F); } } return i; diff --git a/src/lr-wpan/model/lr-wpan-mac-header.cc b/src/lr-wpan/model/lr-wpan-mac-header.cc index 7d35530e0..396ae328b 100644 --- a/src/lr-wpan/model/lr-wpan-mac-header.cc +++ b/src/lr-wpan/model/lr-wpan-mac-header.cc @@ -58,23 +58,19 @@ LrWpanMacHeader::~LrWpanMacHeader() { } -enum LrWpanMacHeader::LrWpanMacType +LrWpanMacHeader::LrWpanMacType LrWpanMacHeader::GetType() const { switch (m_fctrlFrmType) { case 0: return LRWPAN_MAC_BEACON; - break; case 1: return LRWPAN_MAC_DATA; - break; case 2: return LRWPAN_MAC_ACKNOWLEDGMENT; - break; case 3: return LRWPAN_MAC_COMMAND; - break; default: return LRWPAN_MAC_RESERVED; } diff --git a/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc b/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc index b6e6bfdb5..bd19ae278 100644 --- a/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc +++ b/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc @@ -182,6 +182,7 @@ CommandPayloadHeader::GetSerializedSize() const case BEACON_REQ: break; case COOR_REALIGN: + size += 8; break; case GTS_REQ: break; @@ -217,6 +218,11 @@ CommandPayloadHeader::Serialize(Buffer::Iterator start) const case BEACON_REQ: break; case COOR_REALIGN: + i.WriteU16(m_panid); + WriteTo(i, m_coordShortAddr); + i.WriteU8(m_logCh); + WriteTo(i, m_shortAddr); + i.WriteU8(m_logChPage); break; case GTS_REQ: break; @@ -251,6 +257,11 @@ CommandPayloadHeader::Deserialize(Buffer::Iterator start) case BEACON_REQ: break; case COOR_REALIGN: + m_panid = i.ReadU16(); + ReadFrom(i, m_coordShortAddr); + m_logCh = i.ReadU8(); + ReadFrom(i, m_shortAddr); + m_logChPage = i.ReadU8(); break; case GTS_REQ: break; @@ -264,7 +275,7 @@ CommandPayloadHeader::Deserialize(Buffer::Iterator start) void CommandPayloadHeader::Print(std::ostream& os) const { - os << "| MAC Command Frame ID | = " << (uint32_t)m_cmdFrameId; + os << "| MAC Command Frame ID | = " << static_cast(m_cmdFrameId); switch (m_cmdFrameId) { case ASSOCIATION_REQ: @@ -289,6 +300,11 @@ CommandPayloadHeader::Print(std::ostream& os) const case BEACON_REQ: break; case COOR_REALIGN: + os << "| PAN identifier| = " << m_panid + << "| PAN Coord Short address| = " << m_coordShortAddr + << "| Channel Num.| = " << static_cast(m_logCh) + << "| Short address| = " << m_shortAddr + << "| Page Num.| = " << static_cast(m_logChPage); break; case GTS_REQ: break; @@ -310,6 +326,34 @@ CommandPayloadHeader::SetCapabilityField(CapabilityField cap) m_capabilityInfo = cap; } +void +CommandPayloadHeader::SetCoordShortAddr(Mac16Address addr) +{ + NS_ASSERT(m_cmdFrameId == COOR_REALIGN); + m_coordShortAddr = addr; +} + +void +CommandPayloadHeader::SetChannel(uint8_t channel) +{ + NS_ASSERT(m_cmdFrameId == COOR_REALIGN); + m_logCh = channel; +} + +void +CommandPayloadHeader::SetPage(uint8_t page) +{ + NS_ASSERT(m_cmdFrameId == COOR_REALIGN); + m_logChPage = page; +} + +void +CommandPayloadHeader::SetPanId(uint16_t id) +{ + NS_ASSERT(m_cmdFrameId == COOR_REALIGN); + m_panid = id; +} + CommandPayloadHeader::MacCommand CommandPayloadHeader::GetCommandFrameType() const { @@ -317,31 +361,22 @@ CommandPayloadHeader::GetCommandFrameType() const { case 0x01: return ASSOCIATION_REQ; - break; case 0x02: return ASSOCIATION_RESP; - break; case 0x03: return DISASSOCIATION_NOTIF; - break; case 0x04: return DATA_REQ; - break; case 0x05: return PANID_CONFLICT; - break; case 0x06: return ORPHAN_NOTIF; - break; case 0x07: return BEACON_REQ; - break; case 0x08: return COOR_REALIGN; - break; case 0x09: return GTS_REQ; - break; default: return CMD_RESERVED; } @@ -350,7 +385,7 @@ CommandPayloadHeader::GetCommandFrameType() const void CommandPayloadHeader::SetShortAddr(Mac16Address shortAddr) { - NS_ASSERT(m_cmdFrameId == ASSOCIATION_RESP); + NS_ASSERT(m_cmdFrameId == ASSOCIATION_RESP || m_cmdFrameId == COOR_REALIGN); m_shortAddr = shortAddr; } @@ -364,7 +399,6 @@ CommandPayloadHeader::SetAssociationStatus(AssocStatus status) Mac16Address CommandPayloadHeader::GetShortAddr() const { - NS_ASSERT(m_cmdFrameId == ASSOCIATION_RESP); return m_shortAddr; } @@ -382,4 +416,32 @@ CommandPayloadHeader::GetCapabilityField() const return m_capabilityInfo; } +Mac16Address +CommandPayloadHeader::GetCoordShortAddr() const +{ + NS_ASSERT(m_cmdFrameId == COOR_REALIGN); + return m_coordShortAddr; +} + +uint8_t +CommandPayloadHeader::GetChannel() const +{ + NS_ASSERT(m_cmdFrameId == COOR_REALIGN); + return m_logCh; +} + +uint8_t +CommandPayloadHeader::GetPage() const +{ + NS_ASSERT(m_cmdFrameId == COOR_REALIGN); + return m_logChPage; +} + +uint16_t +CommandPayloadHeader::GetPanId() const +{ + NS_ASSERT(m_cmdFrameId == COOR_REALIGN); + return m_panid; +} + } // namespace ns3 diff --git a/src/lr-wpan/model/lr-wpan-mac-pl-headers.h b/src/lr-wpan/model/lr-wpan-mac-pl-headers.h index d426ca95b..fbb1df272 100644 --- a/src/lr-wpan/model/lr-wpan-mac-pl-headers.h +++ b/src/lr-wpan/model/lr-wpan-mac-pl-headers.h @@ -98,6 +98,9 @@ class BeaconPayloadHeader : public Header * \ingroup lr-wpan * Implements the header for the MAC payload command frame according to * the IEEE 802.15.4-2011 Std. + * - Association Response Command (See 5.3.2.2.) + * - Coordinator Realigment Command (See 5.3.8.) + * - Association Request Command (See 5.3.1.) */ class CommandPayloadHeader : public Header { @@ -160,7 +163,28 @@ class CommandPayloadHeader : public Header */ void SetCapabilityField(CapabilityField cap); /** - * Set the Short Address Assigned by the coordinator (Association Response Command). + * Set the coordinator short address (16 bit address). + * \param addr The coordinator short address. + */ + void SetCoordShortAddr(Mac16Address addr); + /** + * Set the logical channel number. + * \param channel The channel number. + */ + void SetChannel(uint8_t channel); + /** + * Set the logical channel page number. + * \param page The page number. + */ + void SetPage(uint8_t page); + /** + * Get the PAN identifier. + * \param id The PAN identifier. + */ + void SetPanId(uint16_t id); + /** + * Set the Short Address Assigned by the coordinator + * (Association Response and Coordinator Realigment Commands). * \param shortAddr The short address assigned by the coordinator */ void SetShortAddr(Mac16Address shortAddr); @@ -170,7 +194,8 @@ class CommandPayloadHeader : public Header */ void SetAssociationStatus(AssocStatus status); /** - * Get the Short address assigned by the coordinator (Association Response Command). + * Get the Short address assigned by the coordinator + * (Association Response and Coordinator Realigment commands). * \return The Mac16Address assigned by the coordinator */ Mac16Address GetShortAddr() const; @@ -185,19 +210,44 @@ class CommandPayloadHeader : public Header */ MacCommand GetCommandFrameType() const; /** - * Get the Capability Information Field from the command payload header. (Association Request - * Command) + * Get the Capability Information Field from the command payload header. + * (Association Request Command) * \return The Capability Information Field */ CapabilityField GetCapabilityField() const; + /** + * Get the coordinator short address. + * \return The coordinator short address (16 bit address) + */ + Mac16Address GetCoordShortAddr() const; + /** + * Get the logical channel number. + * \return The channel number + */ + uint8_t GetChannel() const; + /** + * Get the logical channel page number. + * \return The page number. + */ + uint8_t GetPage() const; + /** + * Get the PAN identifier. + * \return The PAN Identifier + */ + uint16_t GetPanId() const; private: - MacCommand m_cmdFrameId; //!< The command Frame Identifier - CapabilityField - m_capabilityInfo; //!< Capability Information Field (Association Request Command) - Mac16Address m_shortAddr; //!< Contains the short address assigned by the coordinator - //!< (Association Response Command) See IEEE 802.15.4-2011 5.3.2.2. - AssocStatus m_assocStatus; //!< Association Status (Association Response Command) + MacCommand m_cmdFrameId; //!< The command Frame Identifier (Used by all commands) + CapabilityField m_capabilityInfo; //!< Capability Information Field + //!< (Association Request Command) + Mac16Address m_shortAddr; //!< Contains the short address assigned by the coordinator + //!< (Association Response and Coordinator Realiagment Command) + Mac16Address m_coordShortAddr; //!< The coordinator short address + //!< (Coordinator realigment command) + uint16_t m_panid; //!< The PAN identifier (Coordinator realigment command) + uint8_t m_logCh; //!< The channel number (Coordinator realigment command) + uint8_t m_logChPage; //!< The channel page number (Coordinator realigment command) + AssocStatus m_assocStatus; //!< Association Status (Association Response Command) }; } // namespace ns3 diff --git a/src/lr-wpan/model/lr-wpan-mac.cc b/src/lr-wpan/model/lr-wpan-mac.cc index 8a330757b..94cd8d45a 100644 --- a/src/lr-wpan/model/lr-wpan-mac.cc +++ b/src/lr-wpan/model/lr-wpan-mac.cc @@ -39,7 +39,8 @@ #include #undef NS_LOG_APPEND_CONTEXT -#define NS_LOG_APPEND_CONTEXT std::clog << "[address " << m_shortAddress << "] "; +#define NS_LOG_APPEND_CONTEXT \ + std::clog << "[address " << m_shortAddress << " | " << m_selfExt << "] "; namespace ns3 { @@ -188,6 +189,7 @@ LrWpanMac::LrWpanMac() m_macSIFSPeriod = 12; m_panCoor = false; + m_coor = false; m_macBeaconOrder = 15; m_macSuperframeOrder = 15; m_macTransactionPersistenceTime = 500; // 0x01F5 @@ -276,7 +278,15 @@ LrWpanMac::DoDispose() m_mlmeAssociateConfirmCallback = MakeNullCallback(); m_mlmeAssociateIndicationCallback = MakeNullCallback(); m_mlmeCommStatusIndicationCallback = MakeNullCallback(); + m_mlmeOrphanIndicationCallback = MakeNullCallback(); + m_panDescriptorList.clear(); + m_energyDetectList.clear(); + m_unscannedChannels.clear(); + + m_scanEvent.Cancel(); + m_scanEnergyEvent.Cancel(); + m_scanOrphanEvent.Cancel(); m_beaconEvent.Cancel(); Object::DoDispose(); @@ -489,13 +499,12 @@ LrWpanMac::McpsDataRequest(McpsDataRequestParams params, Ptr p) // A DEVICE must be tracking beacons (MLME-SYNC.request is running) before attempting // request data from the coordinator. - // TODO: Check if the current device is coordinator (not just pan coordinator) // Indirect Transmission can only be done by PAN coordinator or coordinators. - NS_ASSERT(m_panCoor); + NS_ASSERT(m_coor); p->AddHeader(macHdr); LrWpanMacTrailer macTrailer; - // Calculate FCS if the global attribute ChecksumEnable is set. + // Calculate FCS if the global attribute ChecksumEnabled is set. if (Node::ChecksumEnabled()) { macTrailer.EnableFcs(true); @@ -520,7 +529,7 @@ LrWpanMac::McpsDataRequest(McpsDataRequestParams params, Ptr p) p->AddHeader(macHdr); LrWpanMacTrailer macTrailer; - // Calculate FCS if the global attribute ChecksumEnable is set. + // Calculate FCS if the global attribute ChecksumEnabled is set. if (Node::ChecksumEnabled()) { macTrailer.EnableFcs(true); @@ -570,9 +579,9 @@ LrWpanMac::MlmeStartRequest(MlmeStartRequestParams params) m_pendPrimitive = MLME_START_REQ; m_startParams = params; - LrWpanPhyPibAttributes pibAttr; - pibAttr.phyCurrentPage = m_startParams.m_logChPage; - m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentPage, &pibAttr); + Ptr pibAttr = Create(); + pibAttr->phyCurrentPage = m_startParams.m_logChPage; + m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentPage, pibAttr); } void @@ -584,7 +593,7 @@ LrWpanMac::MlmeScanRequest(MlmeScanRequestParams params) confirmParams.m_scanType = params.m_scanType; confirmParams.m_chPage = params.m_chPage; - if (m_scanEvent.IsRunning() || m_scanEnergyEvent.IsRunning()) + if ((m_scanEvent.IsRunning() || m_scanEnergyEvent.IsRunning()) || m_scanOrphanEvent.IsRunning()) { if (!m_mlmeScanConfirmCallback.IsNull()) { @@ -595,7 +604,7 @@ LrWpanMac::MlmeScanRequest(MlmeScanRequestParams params) return; } - if (params.m_scanDuration > 14 || params.m_scanType > MLMESCAN_PASSIVE) + if (params.m_scanDuration > 14 || params.m_scanType > MLMESCAN_ORPHAN) { if (!m_mlmeScanConfirmCallback.IsNull()) { @@ -611,6 +620,7 @@ LrWpanMac::MlmeScanRequest(MlmeScanRequestParams params) m_panDescriptorList.clear(); m_energyDetectList.clear(); + m_unscannedChannels.clear(); // TODO: stop beacon transmission @@ -629,9 +639,9 @@ LrWpanMac::MlmeScanRequest(MlmeScanRequestParams params) m_scanParams = params; m_pendPrimitive = MLME_SCAN_REQ; - LrWpanPhyPibAttributes pibAttr; - pibAttr.phyCurrentPage = params.m_chPage; - m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentPage, &pibAttr); + Ptr pibAttr = Create(); + pibAttr->phyCurrentPage = params.m_chPage; + m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentPage, pibAttr); } void @@ -683,9 +693,9 @@ LrWpanMac::MlmeAssociateRequest(MlmeAssociateRequestParams params) } else { - LrWpanPhyPibAttributes pibAttr; - pibAttr.phyCurrentPage = params.m_chPage; - m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentPage, &pibAttr); + Ptr pibAttr = Create(); + pibAttr->phyCurrentPage = params.m_chPage; + m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentPage, pibAttr); } } @@ -758,7 +768,7 @@ LrWpanMac::MlmeAssociateResponse(MlmeAssociateResponseParams params) commandPacket->AddHeader(macPayload); commandPacket->AddHeader(macHdr); - // Calculate FCS if the global attribute ChecksumEnable is set. + // Calculate FCS if the global attribute ChecksumEnabled is set. if (Node::ChecksumEnabled()) { macTrailer.EnableFcs(true); @@ -771,6 +781,66 @@ LrWpanMac::MlmeAssociateResponse(MlmeAssociateResponseParams params) EnqueueInd(commandPacket); } +void +LrWpanMac::MlmeOrphanResponse(MlmeOrphanResponseParams params) +{ + NS_LOG_FUNCTION(this); + // Mac header Coordinator realigment Command + // See 802.15.4-2011 (Section 6.2.7.2) + LrWpanMacHeader macHdr(LrWpanMacHeader::LRWPAN_MAC_COMMAND, m_macDsn.GetValue()); + m_macDsn++; + LrWpanMacTrailer macTrailer; + Ptr commandPacket = Create(); + macHdr.SetPanIdComp(); + macHdr.SetDstAddrMode(LrWpanMacHeader::EXTADDR); + macHdr.SetDstAddrFields(0xffff, params.m_orphanAddr); + + macHdr.SetSrcAddrMode(LrWpanMacHeader::EXTADDR); + macHdr.SetSrcAddrFields(m_macPanId, GetExtendedAddress()); + macHdr.SetSrcAddrFields(m_macPanId, Mac16Address("FF:FF")); + + macHdr.SetFrameVer(0x01); + macHdr.SetSecDisable(); + macHdr.SetAckReq(); + + CommandPayloadHeader macPayload(CommandPayloadHeader::COOR_REALIGN); + macPayload.SetPanId(m_macPanId); + macPayload.SetCoordShortAddr(GetShortAddress()); + macPayload.SetChannel(m_phy->GetCurrentChannelNum()); + macPayload.SetPage(m_phy->GetCurrentPage()); + + if (params.m_assocMember) + { + // The orphan device was associated with the coordinator + + // Either FF:FE for extended address mode + // or the short address assigned by the coord. + macPayload.SetShortAddr(params.m_shortAddr); + } + else + { + // The orphan device was NOT associated with the coordinator + macPayload.SetShortAddr(Mac16Address("FF:FF")); + } + + commandPacket->AddHeader(macPayload); + commandPacket->AddHeader(macHdr); + + // Calculate FCS if the global attribute ChecksumEnabled is set. + if (Node::ChecksumEnabled()) + { + macTrailer.EnableFcs(true); + macTrailer.SetFcs(commandPacket); + } + + commandPacket->AddTrailer(macTrailer); + + Ptr txQElement = Create(); + txQElement->txQPkt = commandPacket; + EnqueueTxQElement(txQElement); + CheckQueue(); +} + void LrWpanMac::MlmeSyncRequest(MlmeSyncRequestParams params) { @@ -779,9 +849,9 @@ LrWpanMac::MlmeSyncRequest(MlmeSyncRequestParams params) uint64_t symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second // change phy current logical channel - LrWpanPhyPibAttributes pibAttr; - pibAttr.phyCurrentChannel = params.m_logCh; - m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentChannel, &pibAttr); + Ptr pibAttr = Create(); + pibAttr->phyCurrentChannel = params.m_logCh; + m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentChannel, pibAttr); // Enable Phy receiver m_phy->PlmeSetTRXStateRequest(IEEE_802_15_4_PHY_RX_ON); @@ -830,16 +900,17 @@ void LrWpanMac::MlmeSetRequest(LrWpanMacPibAttributeIdentifier id, Ptr attribute) { MlmeSetConfirmParams confirmParams; + confirmParams.m_status = MLMESET_SUCCESS; + switch (id) { case macBeaconPayload: - if (attribute->macBeaconPayload->GetSize() > lrwpan::aMaxBeaconPayloadLenght) + if (attribute->macBeaconPayload->GetSize() > lrwpan::aMaxBeaconPayloadLength) { confirmParams.m_status = MLMESET_INVALID_PARAMETER; } else { - confirmParams.m_status = MLMESET_SUCCESS; m_macBeaconPayload = attribute->macBeaconPayload; m_macBeaconPayloadLength = attribute->macBeaconPayload->GetSize(); } @@ -847,6 +918,15 @@ LrWpanMac::MlmeSetRequest(LrWpanMacPibAttributeIdentifier id, PtrmacShortAddress; + break; + case macExtendedAddress: + confirmParams.m_status = MLMESET_READ_ONLY; + break; + case macPanId: + m_macPanId = macPanId; + break; default: // TODO: Add support for setting other attributes confirmParams.m_status = MLMESET_UNSUPPORTED_ATTRIBUTE; @@ -860,6 +940,40 @@ LrWpanMac::MlmeSetRequest(LrWpanMacPibAttributeIdentifier id, Ptr attributes = Create(); + + switch (id) + { + case macBeaconPayload: + attributes->macBeaconPayload = m_macBeaconPayload; + break; + case macBeaconPayloadLength: + attributes->macBeaconPayloadLength = m_macBeaconPayloadLength; + break; + case macShortAddress: + attributes->macShortAddress = m_shortAddress; + break; + case macExtendedAddress: + attributes->macExtendedAddress = m_selfExt; + break; + case macPanId: + attributes->macPanId = m_macPanId; + break; + default: + status = MLMEGET_UNSUPPORTED_ATTRIBUTE; + break; + } + + if (!m_mlmeGetConfirmCallback.IsNull()) + { + m_mlmeGetConfirmCallback(status, id, attributes); + } +} + void LrWpanMac::SendOneBeacon() { @@ -906,7 +1020,7 @@ LrWpanMac::SendOneBeacon() beaconPacket->AddHeader(macPayload); beaconPacket->AddHeader(macHdr); - // Calculate FCS if the global attribute ChecksumEnable is set. + // Calculate FCS if the global attribute ChecksumEnabled is set. if (Node::ChecksumEnabled()) { macTrailer.EnableFcs(true); @@ -944,8 +1058,8 @@ LrWpanMac::SendBeaconRequestCommand() macHdr.SetDstAddrMode(LrWpanMacHeader::SHORTADDR); macHdr.SetSrcAddrMode(LrWpanMacHeader::NOADDR); - macHdr.SetDstAddrFields(0xFFFF, - Mac16Address("FF:FF")); // Not associated PAN, broadcast dst address + // Not associated PAN, broadcast dst address + macHdr.SetDstAddrFields(0xFFFF, Mac16Address("FF:FF")); macHdr.SetSecDisable(); macHdr.SetNoAckReq(); @@ -956,7 +1070,48 @@ LrWpanMac::SendBeaconRequestCommand() commandPacket->AddHeader(macPayload); commandPacket->AddHeader(macHdr); - // Calculate FCS if the global attribute ChecksumEnable is set. + // Calculate FCS if the global attribute ChecksumEnabled is set. + if (Node::ChecksumEnabled()) + { + macTrailer.EnableFcs(true); + macTrailer.SetFcs(commandPacket); + } + + commandPacket->AddTrailer(macTrailer); + + Ptr txQElement = Create(); + txQElement->txQPkt = commandPacket; + EnqueueTxQElement(txQElement); + CheckQueue(); +} + +void +LrWpanMac::SendOrphanNotificationCommand() +{ + LrWpanMacHeader macHdr(LrWpanMacHeader::LRWPAN_MAC_COMMAND, m_macDsn.GetValue()); + m_macDsn++; + LrWpanMacTrailer macTrailer; + Ptr commandPacket = Create(); + + // See IEEE 802.15.4-2011 (5.3.6) + macHdr.SetPanIdComp(); + + macHdr.SetSrcAddrMode(LrWpanMacHeader::EXTADDR); + macHdr.SetSrcAddrFields(0xFFFF, GetExtendedAddress()); + + macHdr.SetDstAddrMode(LrWpanMacHeader::SHORTADDR); + macHdr.SetDstAddrFields(0xFFFF, Mac16Address("FF:FF")); + + macHdr.SetSecDisable(); + macHdr.SetNoAckReq(); + + CommandPayloadHeader macPayload; + macPayload.SetCommandFrameType(CommandPayloadHeader::ORPHAN_NOTIF); + + commandPacket->AddHeader(macPayload); + commandPacket->AddHeader(macHdr); + + // Calculate FCS if the global attribute ChecksumEnabled is set. if (Node::ChecksumEnabled()) { macTrailer.EnableFcs(true); @@ -1005,7 +1160,7 @@ LrWpanMac::SendAssocRequestCommand() commandPacket->AddHeader(macPayload); commandPacket->AddHeader(macHdr); - // Calculate FCS if the global attribute ChecksumEnable is set. + // Calculate FCS if the global attribute ChecksumEnabled is set. if (Node::ChecksumEnabled()) { macTrailer.EnableFcs(true); @@ -1063,7 +1218,7 @@ LrWpanMac::SendDataRequestCommand() commandPacket->AddHeader(macPayload); commandPacket->AddHeader(macHdr); - // Calculate FCS if the global attribute ChecksumEnable is set. + // Calculate FCS if the global attribute ChecksumEnabled is set. if (Node::ChecksumEnabled()) { macTrailer.EnableFcs(true); @@ -1139,9 +1294,11 @@ LrWpanMac::EndStartRequest() if (m_startParams.m_panCoor) { m_panCoor = true; - m_macPanId = m_startParams.m_PanId; } + m_coor = true; + m_macPanId = m_startParams.m_PanId; + NS_ASSERT(m_startParams.m_PanId != 0xffff); m_macBeaconOrder = m_startParams.m_bcnOrd; @@ -1160,6 +1317,7 @@ LrWpanMac::EndStartRequest() m_incCfpEvent.Cancel(); m_trackingEvent.Cancel(); m_scanEvent.Cancel(); + m_scanOrphanEvent.Cancel(); m_scanEnergyEvent.Cancel(); m_csmaCa->SetUnSlottedCsmaCa(); @@ -1221,36 +1379,74 @@ LrWpanMac::EndChannelScan() if (channelFound) { // Switch to the next channel in the list and restart scan - LrWpanPhyPibAttributes pibAttr; - pibAttr.phyCurrentChannel = m_channelScanIndex; - m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentChannel, &pibAttr); + Ptr pibAttr = Create(); + pibAttr->phyCurrentChannel = m_channelScanIndex; + m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentChannel, pibAttr); } else { - // All scans on the channel list completed - // Return to the MAC values previous to start of the first scan. + // All channels in the list scan completed. + // Return variables to the values before the scan and return the status to the next layer. m_macPanId = m_macPanIdScan; m_macPanIdScan = 0; // TODO: restart beacon transmissions that were active before the beginning of the scan // (i.e when a coordinator perform a scan and it was already transmitting beacons) - - // All channels scanned, report success MlmeScanConfirmParams confirmParams; - confirmParams.m_status = MLMESCAN_SUCCESS; confirmParams.m_chPage = m_scanParams.m_chPage; confirmParams.m_scanType = m_scanParams.m_scanType; confirmParams.m_energyDetList = {}; - confirmParams.m_panDescList = m_panDescriptorList; + confirmParams.m_unscannedCh = m_unscannedChannels; + confirmParams.m_resultListSize = m_panDescriptorList.size(); - if (!m_mlmeScanConfirmCallback.IsNull()) + // See IEEE 802.15.4-2011, Table 31 (panDescriptorList value on macAutoRequest) + // and Section 6.2.10.2 + switch (confirmParams.m_scanType) { - m_mlmeScanConfirmCallback(confirmParams); + case MLMESCAN_PASSIVE: + if (m_macAutoRequest) + { + confirmParams.m_panDescList = m_panDescriptorList; + } + confirmParams.m_status = MLMESCAN_SUCCESS; + break; + case MLMESCAN_ACTIVE: + if (m_panDescriptorList.empty()) + { + confirmParams.m_status = MLMESCAN_NO_BEACON; + } + else + { + if (m_macAutoRequest) + { + confirmParams.m_panDescList = m_panDescriptorList; + } + confirmParams.m_status = MLMESCAN_SUCCESS; + } + break; + case MLMESCAN_ORPHAN: + confirmParams.m_panDescList = {}; + confirmParams.m_status = MLMESCAN_NO_BEACON; + confirmParams.m_resultListSize = 0; + // The device lost track of the coordinator and was unable + // to locate it, disassociate from the network. + m_macPanId = 0xffff; + m_shortAddress = Mac16Address("FF:FF"); + m_macCoordShortAddress = Mac16Address("ff:ff"); + m_macCoordExtendedAddress = Mac64Address("ff:ff:ff:ff:ff:ff:ff:ed"); + break; + default: + NS_LOG_ERROR(this << " Invalid scan type"); } m_pendPrimitive = MLME_NONE; m_channelScanIndex = 0; m_scanParams = {}; + + if (!m_mlmeScanConfirmCallback.IsNull()) + { + m_mlmeScanConfirmCallback(confirmParams); + } } } @@ -1259,7 +1455,7 @@ LrWpanMac::EndChannelEnergyScan() { NS_LOG_FUNCTION(this); // Add the results of channel energy scan to the detectList - m_energyDetectList.push_back(m_maxEnergyLevel); + m_energyDetectList.emplace_back(m_maxEnergyLevel); m_maxEnergyLevel = 0; m_channelScanIndex++; @@ -1278,9 +1474,9 @@ LrWpanMac::EndChannelEnergyScan() if (channelFound) { // switch to the next channel in the list and restart scan - LrWpanPhyPibAttributes pibAttr; - pibAttr.phyCurrentChannel = m_channelScanIndex; - m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentChannel, &pibAttr); + Ptr pibAttr = Create(); + pibAttr->phyCurrentChannel = m_channelScanIndex; + m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentChannel, pibAttr); } else { @@ -1293,18 +1489,21 @@ LrWpanMac::EndChannelEnergyScan() // (i.e when a coordinator perform a scan and it was already transmitting beacons) // All channels scanned, report success - if (!m_mlmeScanConfirmCallback.IsNull()) - { - MlmeScanConfirmParams confirmParams; - confirmParams.m_status = MLMESCAN_SUCCESS; - confirmParams.m_chPage = m_phy->GetCurrentPage(); - confirmParams.m_scanType = m_scanParams.m_scanType; - confirmParams.m_energyDetList = m_energyDetectList; - m_mlmeScanConfirmCallback(confirmParams); - } + MlmeScanConfirmParams confirmParams; + confirmParams.m_status = MLMESCAN_SUCCESS; + confirmParams.m_chPage = m_phy->GetCurrentPage(); + confirmParams.m_scanType = m_scanParams.m_scanType; + confirmParams.m_energyDetList = m_energyDetectList; + confirmParams.m_resultListSize = m_energyDetectList.size(); + m_pendPrimitive = MLME_NONE; m_channelScanIndex = 0; m_scanParams = {}; + + if (!m_mlmeScanConfirmCallback.IsNull()) + { + m_mlmeScanConfirmCallback(confirmParams); + } } } @@ -1495,9 +1694,7 @@ LrWpanMac::CheckQueue() // Pull a packet from the queue and start sending if we are not already sending. if (m_lrWpanMacState == MAC_IDLE && !m_txQueue.empty() && !m_setMacState.IsRunning()) { - // TODO: this should check if the node is a coordinator and using the outcoming superframe - // not just the PAN coordinator - if (m_csmaCa->IsUnSlottedCsmaCa() || (m_outSuperframeStatus == CAP && m_panCoor) || + if (m_csmaCa->IsUnSlottedCsmaCa() || (m_outSuperframeStatus == CAP && m_coor) || m_incSuperframeStatus == CAP) { // check MAC is not in a IFS @@ -1596,6 +1793,12 @@ LrWpanMac::SetMlmeCommStatusIndicationCallback(MlmeCommStatusIndicationCallback m_mlmeCommStatusIndicationCallback = c; } +void +LrWpanMac::SetMlmeOrphanIndicationCallback(MlmeOrphanIndicationCallback c) +{ + m_mlmeOrphanIndicationCallback = c; +} + void LrWpanMac::SetMcpsDataConfirmCallback(McpsDataConfirmCallback c) { @@ -1644,6 +1847,12 @@ LrWpanMac::SetMlmeSetConfirmCallback(MlmeSetConfirmCallback c) m_mlmeSetConfirmCallback = c; } +void +LrWpanMac::SetMlmeGetConfirmCallback(MlmeGetConfirmCallback c) +{ + m_mlmeGetConfirmCallback = c; +} + void LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) { @@ -1754,11 +1963,11 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) if (acceptFrame && (receivedMacHdr.GetDstAddrMode() > 1)) { - // Accept frame if: + // Accept frame if one of the following is true: // 1) Have the same macPanId - // 2) Or is Message to all PANs - // 3) Or Is a beacon and the macPanId is not present (bootstrap) + // 2) Is Message to all PANs + // 3) Is a beacon or command frame and the macPanId is not present (bootstrap) acceptFrame = ((receivedMacHdr.GetDstPanId() == m_macPanId || receivedMacHdr.GetDstPanId() == 0xffff) || (m_macPanId == 0xffff && receivedMacHdr.IsBeacon())) || @@ -1767,10 +1976,17 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) if (acceptFrame && (receivedMacHdr.GetShortDstAddr() == Mac16Address("FF:FF"))) { - // A broadcast message (e.g. beacons) should not be received by the device who - // issues it. - acceptFrame = (receivedMacHdr.GetShortSrcAddr() != GetShortAddress()); // 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)) @@ -1783,16 +1999,9 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) else if (receivedMacHdr.GetShortDstAddr().IsBroadcast() || receivedMacHdr.GetShortDstAddr().IsMulticast()) { - // broadcast or multicast - if (receivedMacHdr.IsAckReq()) - { - // discard broadcast/multicast with the ACK bit set - acceptFrame = false; - } - else - { - acceptFrame = true; - } + // Broadcast or multicast. + // Discard broadcast/multicast with the ACK bit set. + acceptFrame = !receivedMacHdr.IsAckReq(); } else { @@ -1805,15 +2014,23 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) acceptFrame = (receivedMacHdr.GetExtDstAddr() == m_selfExt); } - // When PASSIVE or ACTIVE scan is running, reject any frames other than BEACON frames - if (acceptFrame && (!receivedMacHdr.IsBeacon() && m_scanEvent.IsRunning())) + if (acceptFrame && m_scanEvent.IsRunning()) { - acceptFrame = false; + if (!receivedMacHdr.IsBeacon()) + { + acceptFrame = false; + } } - - // Energy Scan is running, reject any frames - if (m_scanEnergyEvent.IsRunning()) + else if (acceptFrame && m_scanOrphanEvent.IsRunning()) { + if (!receivedMacHdr.IsCommand()) + { + acceptFrame = false; + } + } + else if (m_scanEnergyEvent.IsRunning()) + { + // Reject any frames if energy scan is running acceptFrame = false; } @@ -1828,7 +2045,7 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) if (receivedMacPayload.GetCommandFrameType() == CommandPayloadHeader::ASSOCIATION_REQ && - !(m_macAssociationPermit == true && m_panCoor == true)) + !(m_macAssociationPermit && m_coor)) { acceptFrame = false; } @@ -2073,7 +2290,7 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) if (!descriptorExists) { - m_panDescriptorList.push_back(panDescriptor); + m_panDescriptorList.emplace_back(panDescriptor); } return; } @@ -2130,15 +2347,15 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) } else if (receivedMacHdr.IsCommand()) { - // Handle the reception of frame commands that do not require ACK (i.e. Beacon - // Request Command) + // Handle the reception of frame commands that do not require ACK + // (i.e. Beacon Request, Orphan notification, Coordinator Realigment) CommandPayloadHeader receivedMacPayload; p->PeekHeader(receivedMacPayload); - if (receivedMacPayload.GetCommandFrameType() == - CommandPayloadHeader::BEACON_REQ) + + switch (receivedMacPayload.GetCommandFrameType()) { - // TODO: check that node is any coordinator not just pan coordinator - if (m_csmaCa->IsUnSlottedCsmaCa() && m_panCoor) + case CommandPayloadHeader::BEACON_REQ: + if (m_csmaCa->IsUnSlottedCsmaCa() && m_coor) { SendOneBeacon(); } @@ -2146,6 +2363,51 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) { m_macRxDropTrace(originalPkt); } + break; + case CommandPayloadHeader::ORPHAN_NOTIF: + if (!m_mlmeOrphanIndicationCallback.IsNull()) + { + if (m_coor) + { + MlmeOrphanIndicationParams orphanParams; + orphanParams.m_orphanAddr = receivedMacHdr.GetExtSrcAddr(); + m_mlmeOrphanIndicationCallback(orphanParams); + } + } + break; + case CommandPayloadHeader::COOR_REALIGN: + if (m_scanOrphanEvent.IsRunning()) + { + // Coordinator located, no need to keep scanning other channels + m_scanOrphanEvent.Cancel(); + + m_macPanIdScan = 0; + m_pendPrimitive = MLME_NONE; + m_channelScanIndex = 0; + + // Update the device information with the received information + // from the Coordinator Realigment command. + m_macPanId = receivedMacPayload.GetPanId(); + m_shortAddress = receivedMacPayload.GetShortAddr(); + m_macCoordExtendedAddress = receivedMacHdr.GetExtSrcAddr(); + m_macCoordShortAddress = receivedMacPayload.GetCoordShortAddr(); + + if (!m_mlmeScanConfirmCallback.IsNull()) + { + MlmeScanConfirmParams confirmParams; + confirmParams.m_scanType = m_scanParams.m_scanType; + confirmParams.m_chPage = m_scanParams.m_chPage; + confirmParams.m_status = MLMESCAN_SUCCESS; + m_mlmeScanConfirmCallback(confirmParams); + } + m_scanParams = {}; + } + // TODO: handle Coordinator realignment when not + // used during an orphan scan. + break; + default: + m_macRxDropTrace(originalPkt); + break; } } else if (receivedMacHdr.IsData() && !m_mcpsDataIndicationCallback.IsNull()) @@ -2245,6 +2507,24 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) break; } + case CommandPayloadHeader::COOR_REALIGN: { + // ACK of coordinator realigment commands is not specified in the + // standard, in here, we assume they are required as in other + // commands. + if (!m_mlmeCommStatusIndicationCallback.IsNull()) + { + MlmeCommStatusIndicationParams commStatusParams; + commStatusParams.m_panId = m_macPanId; + commStatusParams.m_srcAddrMode = LrWpanMacHeader::EXTADDR; + commStatusParams.m_srcExtAddr = macHdr.GetExtSrcAddr(); + commStatusParams.m_dstAddrMode = LrWpanMacHeader::EXTADDR; + commStatusParams.m_dstExtAddr = macHdr.GetExtDstAddr(); + commStatusParams.m_status = + LrWpanMlmeCommStatus::MLMECOMMSTATUS_SUCCESS; + m_mlmeCommStatusIndicationCallback(commStatusParams); + } + } + default: { // TODO: add response to other request commands (e.g. Orphan) break; @@ -2316,7 +2596,7 @@ LrWpanMac::SendAck(uint8_t seqno) LrWpanMacTrailer macTrailer; Ptr ackPacket = Create(0); ackPacket->AddHeader(macHdr); - // Calculate FCS if the global attribute ChecksumEnable is set. + // Calculate FCS if the global attribute ChecksumEnabled is set. if (Node::ChecksumEnabled()) { macTrailer.EnableFcs(true); @@ -2834,8 +3114,38 @@ LrWpanMac::PdDataConfirm(LrWpanPhyEnumeration status) } else if (macHdr.IsCommand()) { - // We handle commands that do not require ACK (e.g. BeaconReq command) - // other command are handle by the previous if statement. + // We handle commands that do not require ACK + // (e.g. Coordinator realigment command in an orphan response) + // Other command with ACK required are handle by the previous if statement. + + // Check the transmitted packet command type and issue the appropriate indication. + Ptr txOriginalPkt = m_txPkt->Copy(); + LrWpanMacHeader txMacHdr; + txOriginalPkt->RemoveHeader(txMacHdr); + CommandPayloadHeader txMacPayload; + txOriginalPkt->RemoveHeader(txMacPayload); + + if (txMacPayload.GetCommandFrameType() == CommandPayloadHeader::COOR_REALIGN) + { + if (!m_mlmeCommStatusIndicationCallback.IsNull()) + { + MlmeCommStatusIndicationParams commStatusParams; + commStatusParams.m_panId = m_macPanId; + + commStatusParams.m_srcAddrMode = macHdr.GetSrcAddrMode(); + commStatusParams.m_srcExtAddr = macHdr.GetExtSrcAddr(); + commStatusParams.m_srcShortAddr = macHdr.GetShortSrcAddr(); + + commStatusParams.m_dstAddrMode = macHdr.GetDstAddrMode(); + commStatusParams.m_dstExtAddr = macHdr.GetExtDstAddr(); + commStatusParams.m_dstShortAddr = macHdr.GetShortDstAddr(); + + commStatusParams.m_status = LrWpanMlmeCommStatus::MLMECOMMSTATUS_SUCCESS; + m_mlmeCommStatusIndicationCallback(commStatusParams); + } + } + + ifsWaitTime = Seconds(static_cast(GetIfsSize()) / symbolRate); RemoveFirstTxQElement(); } else @@ -3012,7 +3322,7 @@ LrWpanMac::PlmeEdConfirm(LrWpanPhyEnumeration status, uint8_t energyLevel) void LrWpanMac::PlmeGetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttributeIdentifier id, - LrWpanPhyPibAttributes* attribute) + Ptr attribute) { NS_LOG_FUNCTION(this << status << id << attribute); } @@ -3090,10 +3400,10 @@ LrWpanMac::PlmeSetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttribu if (channelFound) { - LrWpanPhyPibAttributes pibAttr; - pibAttr.phyCurrentChannel = m_channelScanIndex; + Ptr pibAttr = Create(); + pibAttr->phyCurrentChannel = m_channelScanIndex; m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentChannel, - &pibAttr); + pibAttr); } } else @@ -3115,9 +3425,19 @@ LrWpanMac::PlmeSetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttribu if (status == LrWpanPhyEnumeration::IEEE_802_15_4_PHY_SUCCESS) { uint64_t symbolRate = static_cast(m_phy->GetDataOrSymbolRate(false)); - uint64_t scanDuration = lrwpan::aBaseSuperframeDuration * - ((static_cast(1 << m_scanParams.m_scanDuration)) + 1); - Time nextScanTime = Seconds(static_cast(scanDuration / symbolRate)); + Time nextScanTime; + + if (m_scanParams.m_scanType == MLMESCAN_ORPHAN) + { + nextScanTime = Seconds(static_cast(m_macResponseWaitTime) / symbolRate); + } + else + { + uint64_t scanDurationSym = + lrwpan::aBaseSuperframeDuration * (pow(2, m_scanParams.m_scanDuration) + 1); + + nextScanTime = Seconds(static_cast(scanDurationSym) / symbolRate); + } switch (m_scanParams.m_scanType) { @@ -3138,8 +3458,9 @@ LrWpanMac::PlmeSetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttribu m_phy->PlmeSetTRXStateRequest(IEEE_802_15_4_PHY_RX_ON); break; case MLMESCAN_ORPHAN: - // TODO: add orphan scan support - NS_LOG_ERROR("Scan Type currently not supported"); + m_scanOrphanEvent = + Simulator::Schedule(nextScanTime, &LrWpanMac::EndChannelScan, this); + SendOrphanNotificationCommand(); break; default: @@ -3174,10 +3495,10 @@ LrWpanMac::PlmeSetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttribu { if (status == LrWpanPhyEnumeration::IEEE_802_15_4_PHY_SUCCESS) { - LrWpanPhyPibAttributes pibAttr; - pibAttr.phyCurrentChannel = m_startParams.m_logCh; + Ptr pibAttr = Create(); + pibAttr->phyCurrentChannel = m_startParams.m_logCh; m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentChannel, - &pibAttr); + pibAttr); } else { @@ -3213,10 +3534,10 @@ LrWpanMac::PlmeSetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttribu { if (status == LrWpanPhyEnumeration::IEEE_802_15_4_PHY_SUCCESS) { - LrWpanPhyPibAttributes pibAttr; - pibAttr.phyCurrentChannel = m_associateParams.m_chNum; + Ptr pibAttr = Create(); + pibAttr->phyCurrentChannel = m_associateParams.m_chNum; m_phy->PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier::phyCurrentChannel, - &pibAttr); + pibAttr); } else { @@ -3378,8 +3699,41 @@ LrWpanMac::SetLrWpanMacState(LrWpanMacState macState) } break; } + case CommandPayloadHeader::COOR_REALIGN: { + if (!m_mlmeCommStatusIndicationCallback.IsNull()) + { + MlmeCommStatusIndicationParams commStatusParams; + commStatusParams.m_panId = m_macPanId; + commStatusParams.m_srcAddrMode = LrWpanMacHeader::EXTADDR; + commStatusParams.m_srcExtAddr = macHdr.GetExtSrcAddr(); + commStatusParams.m_dstAddrMode = LrWpanMacHeader::EXTADDR; + commStatusParams.m_dstExtAddr = macHdr.GetExtDstAddr(); + commStatusParams.m_status = + LrWpanMlmeCommStatus::MLMECOMMSTATUS_CHANNEL_ACCESS_FAILURE; + m_mlmeCommStatusIndicationCallback(commStatusParams); + } + break; + } + case CommandPayloadHeader::ORPHAN_NOTIF: { + if (m_scanOrphanEvent.IsRunning()) + { + m_unscannedChannels.emplace_back(m_phy->GetCurrentChannelNum()); + } + // TODO: Handle orphan notification command during a + // channel access failure when not is not scanning. + break; + } + case CommandPayloadHeader::BEACON_REQ: { + if (m_scanEvent.IsRunning()) + { + m_unscannedChannels.emplace_back(m_phy->GetCurrentChannelNum()); + } + // TODO: Handle beacon request command during a + // channel access failure when not scanning. + break; + } default: { - // TODO: Other commands(e.g. Orphan Request) + // TODO: Other commands(e.g. Disassociation notification, etc) break; } } @@ -3517,9 +3871,9 @@ LrWpanMac::isCoordDest() LrWpanMacHeader macHdr; m_txPkt->PeekHeader(macHdr); - if (m_panCoor) + if (m_coor) { - // The device is the PAN coordinator and the packet is not to itself + // The device is its coordinator and the packet is not to itself return false; } else if (m_macCoordShortAddress == macHdr.GetShortDstAddr() || diff --git a/src/lr-wpan/model/lr-wpan-mac.h b/src/lr-wpan/model/lr-wpan-mac.h index 29c432488..02022f19e 100644 --- a/src/lr-wpan/model/lr-wpan-mac.h +++ b/src/lr-wpan/model/lr-wpan-mac.h @@ -323,6 +323,17 @@ enum LrWpanMlmeSetConfirmStatus MLMESET_INVALID_PARAMETER = 4 }; +/** + * \ingroup lr-wpan + * + * Table 20 of IEEE 802.15.4-2011 + */ +enum LrWpanMlmeGetConfirmStatus +{ + MLMEGET_SUCCESS = 0, + MLMEGET_UNSUPPORTED_ATTRIBUTE = 1 +}; + /** * \ingroup lr-wpan * @@ -332,7 +343,11 @@ enum LrWpanMlmeSetConfirmStatus enum LrWpanMacPibAttributeIdentifier { macBeaconPayload = 0, - macBeaconPayloadLength = 1 + macBeaconPayloadLength = 1, + macShortAddress = 2, + macExtendedAddress = 3, + macPanId = 4, + unsupported = 255 // TODO: complete other MAC pib attributes }; @@ -345,6 +360,9 @@ struct LrWpanMacPibAttributes : public SimpleRefCount { Ptr macBeaconPayload; //!< The contents of the beacon payload. uint8_t macBeaconPayloadLength{0}; //!< The length in octets of the beacon payload. + Mac16Address macShortAddress; //!< The 16 bit mac short address + Mac64Address macExtendedAddress; //!< The EUI-64 bit address + uint16_t macPanId; //!< The identifier of the PAN // TODO: complete other MAC pib attributes }; @@ -455,11 +473,11 @@ struct MlmeAssociateResponseParams */ struct MlmeStartRequestParams { - uint16_t m_PanId{0}; //!< Pan Identifier used by the device. - uint8_t m_logCh{ - 11}; //!< Logical channel on which to start using the new superframe configuration. - uint32_t m_logChPage{ - 0}; //!< Logical channel page on which to start using the new superframe configuration. + uint16_t m_PanId{0}; //!< Pan Identifier used by the device. + uint8_t m_logCh{11}; //!< Logical channel on which to start using the + //!< new superframe configuration. + uint32_t m_logChPage{0}; //!< Logical channel page on which to start using the + //!< new superframe configuration. uint32_t m_startTime{0}; //!< Time at which to begin transmitting beacons (Used by Coordinator //!< not PAN Coordinators). The time is specified in symbols. uint8_t m_bcnOrd{15}; //!< Beacon Order, Used to calculate the beacon interval, a value of 15 @@ -507,9 +525,13 @@ struct MlmeScanRequestParams { LrWpanMlmeScanType m_scanType{MLMESCAN_PASSIVE}; //!< Indicates the type of scan performed as //!< described in IEEE 802.15.4-2011 (5.1.2.1). - uint32_t m_scanChannels{0x7FFFFFF}; //!< The channel numbers to be scanned. - uint8_t m_scanDuration{14}; //!< A value used to calculate the length of time to spend scanning - //!< [aBaseSuperframeDuration * (2^m_scanDuration +)]. + uint32_t m_scanChannels{0x7FFF800}; //!< The channel numbers to be scanned. + //!< Default: (0x7FFF800 = Ch11-Ch26) + //!< 27 LSB (b0,b1,...,b26) = channels + uint8_t m_scanDuration{14}; //!< The factor (0-14) used to calculate the length of time + //!< to spend scanning. + //!< scanDurationSymbols = + //!< [aBaseSuperframeDuration * (2^m_scanDuration + 1)]. uint32_t m_chPage{0}; //!< The channel page on which to perform scan. }; @@ -520,16 +542,17 @@ struct MlmeScanRequestParams */ struct MlmeScanConfirmParams { - LrWpanMlmeScanConfirmStatus m_status{ - MLMESCAN_INVALID_PARAMETER}; //!< The status of the scan request. - LrWpanMlmeScanType m_scanType{ - MLMESCAN_PASSIVE}; //!< Indicates the type of scan performed (ED,ACTIVE,PASSIVE,ORPHAN). - uint32_t m_chPage{0}; //!< The channel page on which the scan was performed. - std::vector m_unscannedCh; //!< A list of channels given in the request which were not - //!< scanned (Not valid for ED scans). - std::vector - m_energyDetList; //!< A list of energy measurements, one for each channel searched during ED - //!< scan (Not valid for Active, Passive or Orphan Scans) + LrWpanMlmeScanConfirmStatus m_status{MLMESCAN_INVALID_PARAMETER}; //!< The status the request. + LrWpanMlmeScanType m_scanType{MLMESCAN_PASSIVE}; //!< Indicates the type of scan + //!< performed (ED,ACTIVE,PASSIVE,ORPHAN). + uint32_t m_chPage{0}; //!< The channel page on which the scan was performed. + std::vector m_unscannedCh; //!< A list of channels given in the request which + //!< were not scanned (Not valid for ED scans). + uint8_t m_resultListSize{0}; //!< The number of elements returned in the appropriate + //!< result list. (Not valid for Orphan scan). + std::vector m_energyDetList; //!< A list of energy measurements, one for each + //!< channel searched during ED scan + //!< (Not valid for Active, Passive or Orphan Scans) std::vector m_panDescList; //!< A list of PAN descriptor, one for each beacon //!< found (Not valid for ED and Orphan scans). }; @@ -620,13 +643,35 @@ struct MlmeCommStatusIndicationParams Mac64Address m_srcExtAddr; //!< The extended address of the entity from which the frame causing //!< the error originated. uint8_t m_dstAddrMode{SHORT_ADDR}; //!< The destination addressing mode for this primitive. - Mac16Address - m_dstShortAddr; //!< The short address of the device for which the frame was intended. - Mac64Address - m_dstExtAddr; //!< The extended address of the device for which the frame was intended. + Mac16Address m_dstShortAddr; //!< The short address of the device for + //!< which the frame was intended. + Mac64Address m_dstExtAddr; //!< The extended address of the device for + //!< which the frame was intended. LrWpanMlmeCommStatus m_status{MLMECOMMSTATUS_INVALID_PARAMETER}; //!< The communication status }; +/** + * \ingroup lr-wpan + * + * MLME-ORPHAN.indication params. See 802.15.4-2011 Section 6.2.7.1 + */ +struct MlmeOrphanIndicationParams +{ + Mac64Address m_orphanAddr; //!< The address of the orphaned device. +}; + +/** + * \ingroup lr-wpan + * + * MLME-ORPHAN.response params. See 802.15.4-2011 Section 6.2.7.2 + */ +struct MlmeOrphanResponseParams +{ + Mac64Address m_orphanAddr; //!< The address of the orphaned device. + Mac16Address m_shortAddr; //!< The short address allocated. + bool m_assocMember{false}; //!< T = allocated with this coord | F = otherwise +}; + /** * \ingroup lr-wpan * @@ -646,9 +691,9 @@ struct MlmePollConfirmParams */ struct MlmeSetConfirmParams { - LrWpanMlmeSetConfirmStatus m_status{ - MLMESET_UNSUPPORTED_ATTRIBUTE}; //!< The result of the request to write - //!< the PIB attribute. + LrWpanMlmeSetConfirmStatus m_status{MLMESET_UNSUPPORTED_ATTRIBUTE}; //!< The result of + //!< the request to write + //!< the PIB attribute. LrWpanMacPibAttributeIdentifier id; //!< The id of the PIB attribute that was written. }; @@ -751,6 +796,17 @@ typedef Callback MlmeAssociateIndicationCal */ typedef Callback MlmeCommStatusIndicationCallback; +/** + * \ingroup lr-wpan + * + * This callback is called by the MLME and issued to its next higher layer following + * the reception of a orphan notification. + * + * Security related parameters and not handle. + * See 802.15.4-2011 6.2.7.1 + */ +typedef Callback MlmeOrphanIndicationCallback; + /** * \ingroup lr-wpan * @@ -760,6 +816,19 @@ typedef Callback MlmeCommStatusIndicationC */ typedef Callback MlmeSetConfirmCallback; +/** + * \ingroup lr-wpan + * + * This callback is called after a MlmeGetRequest has been called from + * the higher layer to get a PIB. It returns a status of the outcome of the + * write attempt. + */ +typedef Callback> + MlmeGetConfirmCallback; + /** * \ingroup lr-wpan * @@ -901,6 +970,16 @@ class LrWpanMac : public Object */ void MlmeAssociateResponse(MlmeAssociateResponseParams params); + /** + * IEEE 802.15.4-2011, section 6.2.7.2 + * MLME-ORPHAN.response + * Primitive used to initiatte a response to an MLME-ORPHAN.indication + * primitive. + * + * \param params the orphan response parameters + */ + void MlmeOrphanResponse(MlmeOrphanResponseParams params); + /** * IEEE 802.15.4-2011, section 6.2.13.1 * MLME-SYNC.request @@ -930,6 +1009,15 @@ class LrWpanMac : public Object */ void MlmeSetRequest(LrWpanMacPibAttributeIdentifier id, Ptr attribute); + /** + * IEEE 802.15.4-2011, section 6.2.5.1 + * MLME-GET.request + * Request information about a given PIB attribute. + * + * \param id the attribute identifier + */ + void MlmeGetRequest(LrWpanMacPibAttributeIdentifier id); + /** * Set the CSMA/CA implementation to be used by the MAC. * @@ -978,6 +1066,15 @@ class LrWpanMac : public Object */ void SetMlmeCommStatusIndicationCallback(MlmeCommStatusIndicationCallback c); + /** + * Set the callback for the indication to the reception of an orphan notification. + * The callback implements MLME-ORPHAN.indication SAP of IEEE 802.15.4-2011, + * section 6.2.7.1. + * + * \param c the callback + */ + void SetMlmeOrphanIndicationCallback(MlmeOrphanIndicationCallback c); + /** * Set the callback for the confirmation of a data transmission request. * The callback implements MCPS-DATA.confirm SAP of IEEE 802.15.4-2006, @@ -1050,6 +1147,15 @@ class LrWpanMac : public Object */ void SetMlmeSetConfirmCallback(MlmeSetConfirmCallback c); + /** + * Set the callback for the confirmation of an attempt to read an attribute. + * The callback implements MLME-GET.confirm SAP of IEEE 802.15.4-2011, + * section 6.2.5.2 + * + *\param c the callback + */ + void SetMlmeGetConfirmCallback(MlmeGetConfirmCallback c); + // interfaces between MAC and PHY /** @@ -1095,7 +1201,7 @@ class LrWpanMac : public Object */ void PlmeGetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttributeIdentifier id, - LrWpanPhyPibAttributes* attribute); + Ptr attribute); /** * IEEE 802.15.4-2006 section 6.2.2.8 @@ -1362,6 +1468,11 @@ class LrWpanMac : public Object */ bool m_panCoor; + /** + * Indicates if the current device is a coordinator type + */ + bool m_coor; + /** * Indication of the Interval used by the coordinator to transmit beacon frames * expressed in symbols. @@ -1563,6 +1674,13 @@ class LrWpanMac : public Object */ void SendBeaconRequestCommand(); + /** + * Called to send a orphan notification command. This is used by an associated device that + * has lost synchronization with its coordinator. + * As described in IEEE 802.15.4-2011 (Section 5.3.6) + */ + void SendOrphanNotificationCommand(); + /** * Called to end a MLME-START.request after changing the page and channel number. */ @@ -1902,6 +2020,13 @@ class LrWpanMac : public Object */ MlmeSetConfirmCallback m_mlmeSetConfirmCallback; + /** + * This callback is used to report the result of an attribute read request + * to the upper layers. + * See IEEE 802.15.4-2011, section 6.2.5.2 + */ + MlmeGetConfirmCallback m_mlmeGetConfirmCallback; + /** * This callback is used to notify incoming beacon packets to the upper layers. * See IEEE 802.15.4-2011, section 6.2.4.1. @@ -1960,6 +2085,12 @@ class LrWpanMac : public Object */ MlmeCommStatusIndicationCallback m_mlmeCommStatusIndicationCallback; + /** + * This callback is used to indicate the reception of a orphan notification command. + * See IEEE 802.15.4-2011, section 6.2.7.1 + */ + MlmeOrphanIndicationCallback m_mlmeOrphanIndicationCallback; + /** * This callback is used to report data transmission request status to the * upper layers. @@ -2042,9 +2173,14 @@ class LrWpanMac : public Object */ std::vector m_energyDetectList; + /** + * The list of unscanned channels during a scan operation. + */ + std::vector m_unscannedChannels; + /** * The parameters used during a MLME-SCAN.request. These parameters are stored here while - * PLME-SET operations (set channel page, set channel number) and multiple ed scans take place. + * PLME-SET (set channel page, set channel number) and other operations take place. */ MlmeScanRequestParams m_scanParams; @@ -2139,10 +2275,15 @@ class LrWpanMac : public Object EventId m_trackingEvent; /** - * Scheduler event for the end of a channel scan. + * Scheduler event for the end of an ACTIVE or PASSIVE channel scan. */ EventId m_scanEvent; + /** + * Scheduler event for the end of an ORPHAN channel scan. + */ + EventId m_scanOrphanEvent; + /** * Scheduler event for the end of a ED channel scan. */ diff --git a/src/lr-wpan/model/lr-wpan-net-device.h b/src/lr-wpan/model/lr-wpan-net-device.h index 7c6758ad5..5d7ff5891 100644 --- a/src/lr-wpan/model/lr-wpan-net-device.h +++ b/src/lr-wpan/model/lr-wpan-net-device.h @@ -250,7 +250,7 @@ class LrWpanNetDevice : public NetDevice * * \param panId The PanID * \param shortAddr The Short MAC address - * \return a Pseudo-Mac48Adress + * \return a Pseudo-Mac48Address */ Mac48Address BuildPseudoMacAddress(uint16_t panId, Mac16Address shortAddr) const; @@ -309,8 +309,8 @@ class LrWpanNetDevice : public NetDevice /** * How the pseudo MAC address is created. * - * According to \RFC{4944} the psudo-MAC is YYYY:0000:XXXX (with U/L bit set to local) - * According to \RFC{6282} the psudo-MAC is 0200:0000:XXXX + * According to \RFC{4944} the pseudo-MAC is YYYY:0000:XXXX (with U/L bit set to local) + * According to \RFC{6282} the pseudo-MAC is 0200:0000:XXXX */ PseudoMacAddressMode_e m_pseudoMacMode; }; diff --git a/src/lr-wpan/model/lr-wpan-phy.cc b/src/lr-wpan/model/lr-wpan-phy.cc index 5a6d81674..f0f9ad606 100644 --- a/src/lr-wpan/model/lr-wpan-phy.cc +++ b/src/lr-wpan/model/lr-wpan-phy.cc @@ -230,7 +230,7 @@ LrWpanPhy::DoDispose() m_plmeGetAttributeConfirmCallback = MakeNullCallback(); + Ptr>(); m_plmeSetTRXStateConfirmCallback = MakeNullCallback(); m_plmeSetAttributeConfirmCallback = MakeNullCallback(); @@ -737,31 +737,31 @@ void LrWpanPhy::PlmeGetAttributeRequest(LrWpanPibAttributeIdentifier id) { NS_LOG_FUNCTION(this << id); - LrWpanPhyEnumeration status; + LrWpanPhyEnumeration status = IEEE_802_15_4_PHY_SUCCESS; + Ptr attributes = Create(); switch (id) { case phyCurrentChannel: - case phyChannelsSupported: - case phyTransmitPower: - case phyCCAMode: - case phyCurrentPage: - case phyMaxFrameDuration: - case phySHRDuration: - case phySymbolsPerOctet: { - status = IEEE_802_15_4_PHY_SUCCESS; + attributes->phyCurrentChannel = m_phyPIBAttributes.phyCurrentChannel; break; - } - default: { + case phyCurrentPage: + attributes->phyCurrentPage = m_phyPIBAttributes.phyCurrentPage; + break; + case phySHRDuration: + attributes->phySHRDuration = GetPhySHRDuration(); + break; + case phySymbolsPerOctet: + attributes->phySymbolsPerOctet = GetPhySymbolsPerOctet(); + break; + default: status = IEEE_802_15_4_PHY_UNSUPPORTED_ATTRIBUTE; break; } - } + if (!m_plmeGetAttributeConfirmCallback.IsNull()) { - LrWpanPhyPibAttributes retValue; - memcpy(&retValue, &m_phyPIBAttributes, sizeof(LrWpanPhyPibAttributes)); - m_plmeGetAttributeConfirmCallback(status, id, &retValue); + m_plmeGetAttributeConfirmCallback(status, id, attributes); } } @@ -996,7 +996,7 @@ LrWpanPhy::PageSupported(uint8_t page) void LrWpanPhy::PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier id, - LrWpanPhyPibAttributes* attribute) + Ptr attribute) { NS_LOG_FUNCTION(this << id << attribute); NS_ASSERT(attribute); @@ -1484,7 +1484,7 @@ LrWpanPhy::EndTx() NS_ABORT_IF((m_trxState != IEEE_802_15_4_PHY_BUSY_TX) && (m_trxState != IEEE_802_15_4_PHY_TRX_OFF)); - if (m_currentTxPacket.second == false) + if (!m_currentTxPacket.second) { NS_LOG_DEBUG("Packet successfully transmitted"); m_phyTxEndTrace(m_currentTxPacket.first); diff --git a/src/lr-wpan/model/lr-wpan-phy.h b/src/lr-wpan/model/lr-wpan-phy.h index 9e53cc392..995c715c3 100644 --- a/src/lr-wpan/model/lr-wpan-phy.h +++ b/src/lr-wpan/model/lr-wpan-phy.h @@ -156,7 +156,7 @@ enum LrWpanPibAttributeIdentifier * * IEEE802.15.4-2006 PHY PIB Attributes Table 23 in section 6.4.2 */ -struct LrWpanPhyPibAttributes +struct LrWpanPhyPibAttributes : public SimpleRefCount { uint8_t phyCurrentChannel; //!< The RF channel to use uint32_t phyChannelsSupported[32]; //!< BitField representing the available channels supported @@ -218,7 +218,10 @@ typedef Callback PlmeEdConfirmCallback; * @param id the identifier of attribute * @param attribute the pointer to attribute struct */ -typedef Callback +typedef Callback> PlmeGetAttributeConfirmCallback; /** @@ -395,7 +398,7 @@ class LrWpanPhy : public SpectrumPhy * \param attribute the attribute value */ void PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier id, - LrWpanPhyPibAttributes* attribute); + Ptr attribute); /** * set the callback for the end of a RX, as part of the diff --git a/src/lr-wpan/test/examples-to-run.py b/src/lr-wpan/test/examples-to-run.py index dfe679888..0704b98dd 100644 --- a/src/lr-wpan/test/examples-to-run.py +++ b/src/lr-wpan/test/examples-to-run.py @@ -1,5 +1,4 @@ #! /usr/bin/env python3 -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains diff --git a/src/lr-wpan/test/lr-wpan-mac-test.cc b/src/lr-wpan/test/lr-wpan-mac-test.cc index 6e78d04fd..9f77df6f8 100644 --- a/src/lr-wpan/test/lr-wpan-mac-test.cc +++ b/src/lr-wpan/test/lr-wpan-mac-test.cc @@ -488,27 +488,216 @@ TestActiveScanPanDescriptors::DoRun() NS_TEST_EXPECT_MSG_EQ(m_panDescriptorList.size(), 2, "Error, Beacons not received or PAN descriptors not found"); - NS_TEST_ASSERT_MSG_LT(m_panDescriptorList[0].m_linkQuality, - 255, - "Error, Coordinator 1 (PAN 5) LQI value should be less than 255."); - NS_TEST_ASSERT_MSG_LT(m_panDescriptorList[1].m_linkQuality, - 255, - "Error, Coordinator 2 (PAN 7) LQI value should be less than 255."); - NS_TEST_ASSERT_MSG_GT(m_panDescriptorList[0].m_linkQuality, - 0, - "Error, Coordinator 1 (PAN 5) LQI value should be greater than 0."); - NS_TEST_ASSERT_MSG_GT(m_panDescriptorList[1].m_linkQuality, - 0, - "Error, Coordinator 2 (PAN 7) LQI value should be greater than 0."); - NS_TEST_ASSERT_MSG_LT( - m_panDescriptorList[1].m_linkQuality, - m_panDescriptorList[0].m_linkQuality, - "Error, Coordinator 2 (PAN 7) LQI value should be less than Coordinator 1 (PAN 5)."); + if (m_panDescriptorList.size() == 2) + { + NS_TEST_ASSERT_MSG_LT(m_panDescriptorList[0].m_linkQuality, + 255, + "Error, Coordinator 1 (PAN 5) LQI value should be less than 255."); + NS_TEST_ASSERT_MSG_LT(m_panDescriptorList[1].m_linkQuality, + 255, + "Error, Coordinator 2 (PAN 7) LQI value should be less than 255."); + NS_TEST_ASSERT_MSG_GT(m_panDescriptorList[0].m_linkQuality, + 0, + "Error, Coordinator 1 (PAN 5) LQI value should be greater than 0."); + NS_TEST_ASSERT_MSG_GT(m_panDescriptorList[1].m_linkQuality, + 0, + "Error, Coordinator 2 (PAN 7) LQI value should be greater than 0."); - NS_TEST_EXPECT_MSG_EQ(g_beaconPayloadSize, - 25, - "Error, Beacon Payload not received or incorrect size (25 bytes)"); + NS_TEST_ASSERT_MSG_LT(m_panDescriptorList[1].m_linkQuality, + m_panDescriptorList[0].m_linkQuality, + "Error, Coordinator 2 (PAN 7) LQI value should" + " be less than Coordinator 1 (PAN 5)."); + + NS_TEST_EXPECT_MSG_EQ(g_beaconPayloadSize, + 25, + "Error, Beacon Payload not received or incorrect size (25 bytes)"); + } + + Simulator::Destroy(); +} + +/** + * \ingroup lr-wpan-test + * \ingroup tests + * + * \brief Test MAC Orphan Scan Coordinator Realignment command reception and its values. + */ +class TestOrphanScan : public TestCase +{ + public: + TestOrphanScan(); + ~TestOrphanScan() override; + + private: + /** + * Function called in response to a MAC scan request. + * + * \param params MLME scan confirm parameters + */ + void ScanConfirm(MlmeScanConfirmParams params); + + /** + * Function called as a result of receiving an orphan notification command + * on the coordinator + * + * \param params MLME orphan indication parameters + */ + void OrphanIndicationCoord(MlmeOrphanIndicationParams params); + + void DoRun() override; + + Ptr coord1NetDevice; //!< The LrWpanNetDevice of coordinator 1 + Ptr endNodeNetDevice; //!< The LrWpanNetDevice of the end device + bool m_orphanScanSuccess; //!< Indicates a successful orphan scan +}; + +TestOrphanScan::TestOrphanScan() + : TestCase("Test an orphan scan and the reception of the commands involved") +{ + m_orphanScanSuccess = false; +} + +TestOrphanScan::~TestOrphanScan() +{ +} + +void +TestOrphanScan::ScanConfirm(MlmeScanConfirmParams params) +{ + if (params.m_status == MLMESCAN_SUCCESS) + { + m_orphanScanSuccess = true; + } +} + +void +TestOrphanScan::OrphanIndicationCoord(MlmeOrphanIndicationParams params) +{ + // The steps taken by the coordinator on the event of an orphan indication + // are meant to be implemented by the next higher layer and are out of the scope of the + // standard. In this test, we assume that coordinator 2 already has + // the endDevice [00:00:00:00:00:00:00:03] registered and therefore reply to this device + // a with a coordidinator realignment command. + + if (params.m_orphanAddr == Mac64Address("00:00:00:00:00:00:00:02")) + { + MlmeOrphanResponseParams respParams; + respParams.m_assocMember = true; + respParams.m_orphanAddr = params.m_orphanAddr; + respParams.m_shortAddr = Mac16Address("00:02"); + + Simulator::ScheduleNow(&LrWpanMac::MlmeOrphanResponse, + coord1NetDevice->GetMac(), + respParams); + } +} + +void +TestOrphanScan::DoRun() +{ + // Create 2 PAN coordinator nodes, and 1 end device + Ptr coord1 = CreateObject(); + Ptr endNode = CreateObject(); + + coord1NetDevice = CreateObject(); + endNodeNetDevice = CreateObject(); + + // PAN Coordinators configurations require to set both, the EUI-64 (extended address) + // and to assign their own short address. + coord1NetDevice->GetMac()->SetExtendedAddress(Mac64Address("00:00:00:00:00:00:00:01")); + coord1NetDevice->GetMac()->SetShortAddress(Mac16Address("00:01")); + + // Other devices must have only its EUI-64 and later on, their short address is + // potentially assigned by the coordinator. + endNodeNetDevice->GetMac()->SetExtendedAddress(Mac64Address("00:00:00:00:00:00:00:02")); + + // Configure Spectrum channel + Ptr channel = CreateObject(); + Ptr propModel = + CreateObject(); + Ptr delayModel = + CreateObject(); + channel->AddPropagationLossModel(propModel); + channel->SetPropagationDelayModel(delayModel); + + coord1NetDevice->SetChannel(channel); + endNodeNetDevice->SetChannel(channel); + + coord1->AddDevice(coord1NetDevice); + endNode->AddDevice(endNodeNetDevice); + + // Mobility + Ptr coord1Mobility = + CreateObject(); + coord1Mobility->SetPosition(Vector(0, 0, 0)); + coord1NetDevice->GetPhy()->SetMobility(coord1Mobility); + + Ptr endNodeMobility = + CreateObject(); + endNodeMobility->SetPosition(Vector(100, 0, 0)); + endNodeNetDevice->GetPhy()->SetMobility(endNodeMobility); + + // MAC layer Callbacks hooks + MlmeScanConfirmCallback cb1; + cb1 = MakeCallback(&TestOrphanScan::ScanConfirm, this); + endNodeNetDevice->GetMac()->SetMlmeScanConfirmCallback(cb1); + + MlmeOrphanIndicationCallback cb2; + cb2 = MakeCallback(&TestOrphanScan::OrphanIndicationCoord, this); + coord1NetDevice->GetMac()->SetMlmeOrphanIndicationCallback(cb2); + ///////////////// + // ORPHAN SCAN // + ///////////////// + + // PAN coordinator N0 (PAN 5) is set to channel 12 in non-beacon mode + // but answer to beacon request and orphan notification commands. + MlmeStartRequestParams params; + params.m_panCoor = true; + params.m_PanId = 5; + params.m_bcnOrd = 15; + params.m_sfrmOrd = 15; + params.m_logCh = 12; + Simulator::ScheduleWithContext(1, + Seconds(2.0), + &LrWpanMac::MlmeStartRequest, + coord1NetDevice->GetMac(), + params); + + // End device N1 is set to scan 4 channels looking for the presence of a coordinator. + // On each channel, a single orphan notification command is sent and a response is + // waited for a maximum time of macResponseWaitTime. If a reply is received from a + // coordinator within this time (coordinator realignment command), the programmed scans on + // other channels is suspended. + // Scan Channels are represented by bits 0-26 (27 LSB) + // ch 14 ch 11 + // | | + // 0x7800 = 0000000000000000111100000000000 + MlmeScanRequestParams scanParams; + scanParams.m_chPage = 0; + scanParams.m_scanChannels = 0x7800; + scanParams.m_scanType = MLMESCAN_ORPHAN; + Simulator::ScheduleWithContext(1, + Seconds(3.0), + &LrWpanMac::MlmeScanRequest, + endNodeNetDevice->GetMac(), + scanParams); + + Simulator::Stop(Seconds(4000)); + NS_LOG_DEBUG("----------- Start of TestOrphanScan -------------------"); + Simulator::Run(); + + NS_TEST_EXPECT_MSG_EQ(m_orphanScanSuccess, + true, + "Error, no coordinator realignment commands" + " received during orphan scan"); + if (m_orphanScanSuccess) + { + NS_TEST_EXPECT_MSG_EQ(endNodeNetDevice->GetMac()->GetShortAddress(), + Mac16Address("00:02"), + "Error, end device did not receive short address" + " during orphan scan"); + } Simulator::Destroy(); } @@ -530,6 +719,7 @@ LrWpanMacTestSuite::LrWpanMacTestSuite() { AddTestCase(new TestRxOffWhenIdleAfterCsmaFailure, TestCase::QUICK); AddTestCase(new TestActiveScanPanDescriptors, TestCase::QUICK); + AddTestCase(new TestOrphanScan, TestCase::QUICK); } static LrWpanMacTestSuite g_lrWpanMacTestSuite; //!< Static variable for test initialization diff --git a/src/lte/doc/source/lte-design.rst b/src/lte/doc/source/lte-design.rst index f363a18f1..f61022b93 100644 --- a/src/lte/doc/source/lte-design.rst +++ b/src/lte/doc/source/lte-design.rst @@ -685,7 +685,7 @@ The model can be disabled for working with a zero-losses channel by setting the Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false)); -.. _sec-control-channles-phy-error-model: +.. _sec-control-channels-phy-error-model: Control Channels PHY Error Model ++++++++++++++++++++++++++++++++ @@ -2266,13 +2266,13 @@ is less than a defined threshold Qout (default: -5dB), the frame cannot be decod (see``LteUePhy::RadioLinkFailureDetection``). The Qout threshold corresponds to 10% block error rate (BLER) of a hypothetical PDCCH transmission taking into account the PCFICH errors [R4-081920]_ (also refer to -:ref:`sec-control-channles-phy-error-model`). Once, the UE is unable to decode +:ref:`sec-control-channels-phy-error-model`). Once, the UE is unable to decode 20 consecutive frames, i.e., the Qout evaluation period (200ms) is reached, an out-of-sync indication is sent to the UE RRC layer (see ``LteUeRrc::DoNotifyOutOfSync``). Else, the counter for the unsuccessfuly decoded frames is reset to zero. At the LteUeRrc, when the number of consecutive out-of-sync indications matches with the value of N310 parameter, the T310 timer is started and LteUePhy is notified to start -measuring for in-sync indications (see ``LteUePhy::DoStartInSnycDetection``). We note +measuring for in-sync indications (see ``LteUePhy::DoStartInSyncDetection``). We note that, the UE RRC state is not changed till the expiration of T310 timer. If the resultant SINR values averaged over a downlink frame is greater than a defined threshold Qin (default: -3.8dB), the frame is considered to be successfully @@ -2468,7 +2468,7 @@ where: - :math:`F_{n-1}` is the old filtered measurement result, where :math:`F_0 = M_1` (i.e. the first measurement is not filtered); and - :math:`a = (\frac{1}{2})^{\frac{k}{4}}`, where :math:`k` is the configurable - `filterCoefficent` provided by the ``QuantityConfig``; + `filterCoefficient` provided by the ``QuantityConfig``; :math:`k = 4` is the default value, but can be configured by setting the `RsrpFilterCoefficient` and `RsrqFilterCoefficient` attributes in diff --git a/src/lte/examples/lena-cqi-threshold.cc b/src/lte/examples/lena-cqi-threshold.cc index 187b864bc..a51c32a7b 100644 --- a/src/lte/examples/lena-cqi-threshold.cc +++ b/src/lte/examples/lena-cqi-threshold.cc @@ -113,7 +113,7 @@ main(int argc, char* argv[]) Simulator::Schedule(Seconds(0.020), &ChangePosition, ueNodes.Get(0)); // Activate a data radio bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/examples/lena-deactivate-bearer.cc b/src/lte/examples/lena-deactivate-bearer.cc index a7c9347bb..01805ed69 100644 --- a/src/lte/examples/lena-deactivate-bearer.cc +++ b/src/lte/examples/lena-deactivate-bearer.cc @@ -153,7 +153,7 @@ main(int argc, char* argv[]) qos.mbrDl = qos.gbrDl; qos.mbrUl = qos.gbrUl; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); bearer.arp.priorityLevel = 15 - (u + 1); bearer.arp.preemptionCapability = true; diff --git a/src/lte/examples/lena-dual-stripe.cc b/src/lte/examples/lena-dual-stripe.cc index 4ca1c4b0b..9df5111ea 100644 --- a/src/lte/examples/lena-dual-stripe.cc +++ b/src/lte/examples/lena-dual-stripe.cc @@ -948,7 +948,7 @@ main(int argc, char* argv[]) Ptr ueDev = ueDevs.Get(u); for (uint32_t b = 0; b < numBearersPerUe; ++b) { - enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; + EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDev, bearer); } diff --git a/src/lte/examples/lena-fading.cc b/src/lte/examples/lena-fading.cc index aec3d1d75..5e755b61c 100644 --- a/src/lte/examples/lena-fading.cc +++ b/src/lte/examples/lena-fading.cc @@ -112,7 +112,7 @@ main(int argc, char* argv[]) lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/examples/lena-frequency-reuse.cc b/src/lte/examples/lena-frequency-reuse.cc index ef8cc7772..926039584 100644 --- a/src/lte/examples/lena-frequency-reuse.cc +++ b/src/lte/examples/lena-frequency-reuse.cc @@ -325,7 +325,7 @@ main(int argc, char* argv[]) lteHelper->AttachToClosestEnb(randomUeDevs, enbDevs); // Activate a data radio bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(edgeUeDevs, bearer); lteHelper->ActivateDataRadioBearer(centerUeDevs, bearer); diff --git a/src/lte/examples/lena-intercell-interference.cc b/src/lte/examples/lena-intercell-interference.cc index b4d08247a..2895198a7 100644 --- a/src/lte/examples/lena-intercell-interference.cc +++ b/src/lte/examples/lena-intercell-interference.cc @@ -126,7 +126,7 @@ main(int argc, char* argv[]) lteHelper->Attach(ueDevs2, enbDevs.Get(1)); // Activate a data radio bearer each UE - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs1, bearer); lteHelper->ActivateDataRadioBearer(ueDevs2, bearer); diff --git a/src/lte/examples/lena-pathloss-traces.cc b/src/lte/examples/lena-pathloss-traces.cc index bdd52ef71..3144f6692 100644 --- a/src/lte/examples/lena-pathloss-traces.cc +++ b/src/lte/examples/lena-pathloss-traces.cc @@ -136,7 +136,7 @@ main(int argc, char* argv[]) lteHelper->Attach(ueDevs2, enbDevs.Get(1)); // Activate an EPS bearer on all UEs - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs1, bearer); lteHelper->ActivateDataRadioBearer(ueDevs2, bearer); diff --git a/src/lte/examples/lena-profiling.cc b/src/lte/examples/lena-profiling.cc index f84f8920b..5014883b0 100644 --- a/src/lte/examples/lena-profiling.cc +++ b/src/lte/examples/lena-profiling.cc @@ -184,7 +184,7 @@ main(int argc, char* argv[]) NetDeviceContainer ueDev = lteHelper->InstallUeDevice(ueNodes.at(i)); ueDevs.push_back(ueDev); lteHelper->Attach(ueDev, enbDevs.Get(i)); - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDev, bearer); } diff --git a/src/lte/examples/lena-radio-link-failure.cc b/src/lte/examples/lena-radio-link-failure.cc index e007da944..5f73b87f9 100644 --- a/src/lte/examples/lena-radio-link-failure.cc +++ b/src/lte/examples/lena-radio-link-failure.cc @@ -318,7 +318,7 @@ Throughput(bool firstWrite, Time binSize, std::string fileName) { std::ofstream output; - if (firstWrite == true) + if (firstWrite) { output.open(fileName, std::ofstream::out); firstWrite = false; diff --git a/src/lte/examples/lena-rem-sector-antenna.cc b/src/lte/examples/lena-rem-sector-antenna.cc index 29de39d91..ce793d70c 100644 --- a/src/lte/examples/lena-rem-sector-antenna.cc +++ b/src/lte/examples/lena-rem-sector-antenna.cc @@ -198,7 +198,7 @@ main(int argc, char* argv[]) NetDeviceContainer ueDev = lteHelper->InstallUeDevice(ueNodes.at(i)); ueDevs.push_back(ueDev); lteHelper->Attach(ueDev, enbDevs.Get(i)); - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDev, bearer); } diff --git a/src/lte/examples/lena-rem.cc b/src/lte/examples/lena-rem.cc index 7a9e95105..37de2bfad 100644 --- a/src/lte/examples/lena-rem.cc +++ b/src/lte/examples/lena-rem.cc @@ -84,7 +84,7 @@ main(int argc, char* argv[]) lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/examples/lena-rlc-traces.cc b/src/lte/examples/lena-rlc-traces.cc index 7695547c0..298d4015f 100644 --- a/src/lte/examples/lena-rlc-traces.cc +++ b/src/lte/examples/lena-rlc-traces.cc @@ -67,7 +67,7 @@ main(int argc, char* argv[]) lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/examples/lena-simple-epc-backhaul.cc b/src/lte/examples/lena-simple-epc-backhaul.cc index 3927f2300..2353098aa 100644 --- a/src/lte/examples/lena-simple-epc-backhaul.cc +++ b/src/lte/examples/lena-simple-epc-backhaul.cc @@ -158,7 +158,7 @@ main(int argc, char* argv[]) for (uint16_t i = 0; i < numNodePairs; ++i) { Ptr enb = enbNodes.Get(i); - std::vector cellIds(1, i); + std::vector cellIds(1, i + 1); // Create a point to point link between the eNB and the SGW with // the corresponding new NetDevices on each side diff --git a/src/lte/examples/lena-simple.cc b/src/lte/examples/lena-simple.cc index d0f9501f5..bf97bd940 100644 --- a/src/lte/examples/lena-simple.cc +++ b/src/lte/examples/lena-simple.cc @@ -95,7 +95,7 @@ main(int argc, char* argv[]) lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate a data radio bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); lteHelper->EnableTraces(); diff --git a/src/lte/examples/lena-uplink-power-control.cc b/src/lte/examples/lena-uplink-power-control.cc index e1933d488..5a1e46d98 100644 --- a/src/lte/examples/lena-uplink-power-control.cc +++ b/src/lte/examples/lena-uplink-power-control.cc @@ -91,7 +91,7 @@ main(int argc, char* argv[]) lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate a data radio bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/helper/emu-epc-helper.cc b/src/lte/helper/emu-epc-helper.cc index dc405a4d5..18c51817d 100644 --- a/src/lte/helper/emu-epc-helper.cc +++ b/src/lte/helper/emu-epc-helper.cc @@ -19,7 +19,7 @@ * Manuel Requena */ -#include "ns3/emu-epc-helper.h" +#include "emu-epc-helper.h" #include "ns3/emu-fd-net-device-helper.h" #include "ns3/epc-x2.h" diff --git a/src/lte/helper/emu-epc-helper.h b/src/lte/helper/emu-epc-helper.h index e288a1de7..5e2dc4daa 100644 --- a/src/lte/helper/emu-epc-helper.h +++ b/src/lte/helper/emu-epc-helper.h @@ -22,7 +22,7 @@ #ifndef EMU_EPC_HELPER_H #define EMU_EPC_HELPER_H -#include "ns3/no-backhaul-epc-helper.h" +#include "no-backhaul-epc-helper.h" namespace ns3 { diff --git a/src/lte/helper/epc-helper.cc b/src/lte/helper/epc-helper.cc index 4b9c8fdd1..7e95db508 100644 --- a/src/lte/helper/epc-helper.cc +++ b/src/lte/helper/epc-helper.cc @@ -19,7 +19,8 @@ * Manuel Requena */ -#include +#include "epc-helper.h" + #include #include #include diff --git a/src/lte/helper/lte-helper.cc b/src/lte/helper/lte-helper.cc index c5397a26a..e2a1cc784 100644 --- a/src/lte/helper/lte-helper.cc +++ b/src/lte/helper/lte-helper.cc @@ -22,11 +22,17 @@ #include "lte-helper.h" +#include "cc-helper.h" +#include "epc-helper.h" +#include "mac-stats-calculator.h" +#include "phy-rx-stats-calculator.h" +#include "phy-stats-calculator.h" +#include "phy-tx-stats-calculator.h" + #include #include #include #include -#include #include #include #include @@ -35,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -54,13 +61,9 @@ #include #include #include -#include #include #include #include -#include -#include -#include #include #include #include @@ -739,7 +742,7 @@ LteHelper::InstallSingleEnbDevice(Ptr n) it->first, DynamicCast(it->second)->GetMac()->GetLteMacSapProvider()); - if (ccmTest == false) + if (!ccmTest) { NS_FATAL_ERROR("Error in SetComponentCarrierMacSapProviders"); } @@ -939,7 +942,7 @@ LteHelper::InstallSingleUeDevice(Ptr n) // number of component carriers in UE RRC ccmUe->SetNumberOfComponentCarriers(m_noOfCcs); - // run intializeSap to create the proper number of MAC and PHY control sap provider/users + // run initializeSap to create the proper number of MAC and PHY control sap provider/users rrc->InitializeSap(); if (m_useIdealRrc) @@ -987,7 +990,7 @@ LteHelper::InstallSingleUeDevice(Ptr n) ccmUe->SetComponentCarrierMacSapProviders(it->first, it->second->GetMac()->GetLteMacSapProvider()); - if (ccmTest == false) + if (!ccmTest) { NS_FATAL_ERROR("Error in SetComponentCarrierMacSapProviders"); } @@ -1572,7 +1575,7 @@ int64_t LteHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; - if (m_fadingModel && (m_fadingStreamsAssigned == false)) + if (m_fadingModel && !m_fadingStreamsAssigned) { Ptr tflm = m_fadingModel->GetObject(); if (tflm) diff --git a/src/lte/helper/lte-helper.h b/src/lte/helper/lte-helper.h index 0bb8b1a6e..560a2d73e 100644 --- a/src/lte/helper/lte-helper.h +++ b/src/lte/helper/lte-helper.h @@ -22,23 +22,23 @@ #ifndef LTE_HELPER_H #define LTE_HELPER_H -#include +#include "mac-stats-calculator.h" +#include "phy-rx-stats-calculator.h" +#include "phy-stats-calculator.h" +#include "phy-tx-stats-calculator.h" +#include "radio-bearer-stats-calculator.h" +#include "radio-bearer-stats-connector.h" + #include #include #include #include -#include #include #include #include #include #include #include -#include -#include -#include -#include -#include #include #include diff --git a/src/lte/helper/lte-hex-grid-enb-topology-helper.cc b/src/lte/helper/lte-hex-grid-enb-topology-helper.cc index a68a96772..3f9eeacab 100644 --- a/src/lte/helper/lte-hex-grid-enb-topology-helper.cc +++ b/src/lte/helper/lte-hex-grid-enb-topology-helper.cc @@ -19,9 +19,10 @@ #include "lte-hex-grid-enb-topology-helper.h" +#include "epc-helper.h" + #include #include -#include #include #include diff --git a/src/lte/helper/lte-hex-grid-enb-topology-helper.h b/src/lte/helper/lte-hex-grid-enb-topology-helper.h index 906f3de7f..a5d06c664 100644 --- a/src/lte/helper/lte-hex-grid-enb-topology-helper.h +++ b/src/lte/helper/lte-hex-grid-enb-topology-helper.h @@ -20,7 +20,7 @@ #ifndef LTE_HEX_GRID_ENB_TOPOLOGY_HELPER_H #define LTE_HEX_GRID_ENB_TOPOLOGY_HELPER_H -#include +#include "lte-helper.h" namespace ns3 { diff --git a/src/lte/helper/lte-stats-calculator.cc b/src/lte/helper/lte-stats-calculator.cc index 456f9d840..d760109ea 100644 --- a/src/lte/helper/lte-stats-calculator.cc +++ b/src/lte/helper/lte-stats-calculator.cc @@ -82,14 +82,7 @@ LteStatsCalculator::GetDlOutputFilename() bool LteStatsCalculator::ExistsImsiPath(std::string path) { - if (m_pathImsiMap.find(path) == m_pathImsiMap.end()) - { - return false; - } - else - { - return true; - } + return m_pathImsiMap.find(path) != m_pathImsiMap.end(); } void @@ -108,14 +101,7 @@ LteStatsCalculator::GetImsiPath(std::string path) bool LteStatsCalculator::ExistsCellIdPath(std::string path) { - if (m_pathCellIdMap.find(path) == m_pathCellIdMap.end()) - { - return false; - } - else - { - return true; - } + return m_pathCellIdMap.find(path) != m_pathCellIdMap.end(); } void diff --git a/src/lte/helper/mac-stats-calculator.cc b/src/lte/helper/mac-stats-calculator.cc index 0339fc16f..297ad71bb 100644 --- a/src/lte/helper/mac-stats-calculator.cc +++ b/src/lte/helper/mac-stats-calculator.cc @@ -110,7 +110,7 @@ MacStatsCalculator::DlScheduling(uint16_t cellId, << (uint32_t)dlSchedulingCallbackInfo.mcsTb2 << dlSchedulingCallbackInfo.sizeTb2); NS_LOG_INFO("Write DL Mac Stats in " << GetDlOutputFilename()); - if (m_dlFirstWrite == true) + if (m_dlFirstWrite) { m_dlOutFile.open(GetDlOutputFilename()); if (!m_dlOutFile.is_open()) @@ -151,7 +151,7 @@ MacStatsCalculator::UlScheduling(uint16_t cellId, << size); NS_LOG_INFO("Write UL Mac Stats in " << GetUlOutputFilename()); - if (m_ulFirstWrite == true) + if (m_ulFirstWrite) { m_ulOutFile.open(GetUlOutputFilename()); if (!m_ulOutFile.is_open()) @@ -185,7 +185,7 @@ MacStatsCalculator::DlSchedulingCallback(Ptr macStats, std::ostringstream pathAndRnti; std::string pathEnb = path.substr(0, path.find("/ComponentCarrierMap")); pathAndRnti << pathEnb << "/LteEnbRrc/UeMap/" << dlSchedulingCallbackInfo.rnti; - if (macStats->ExistsImsiPath(pathAndRnti.str()) == true) + if (macStats->ExistsImsiPath(pathAndRnti.str())) { imsi = macStats->GetImsiPath(pathAndRnti.str()); } @@ -195,7 +195,7 @@ MacStatsCalculator::DlSchedulingCallback(Ptr macStats, macStats->SetImsiPath(pathAndRnti.str(), imsi); } uint16_t cellId = 0; - if (macStats->ExistsCellIdPath(pathAndRnti.str()) == true) + if (macStats->ExistsCellIdPath(pathAndRnti.str())) { cellId = macStats->GetCellIdPath(pathAndRnti.str()); } @@ -224,7 +224,7 @@ MacStatsCalculator::UlSchedulingCallback(Ptr macStats, std::ostringstream pathAndRnti; std::string pathEnb = path.substr(0, path.find("/ComponentCarrierMap")); pathAndRnti << pathEnb << "/LteEnbRrc/UeMap/" << rnti; - if (macStats->ExistsImsiPath(pathAndRnti.str()) == true) + if (macStats->ExistsImsiPath(pathAndRnti.str())) { imsi = macStats->GetImsiPath(pathAndRnti.str()); } @@ -234,7 +234,7 @@ MacStatsCalculator::UlSchedulingCallback(Ptr macStats, macStats->SetImsiPath(pathAndRnti.str(), imsi); } uint16_t cellId = 0; - if (macStats->ExistsCellIdPath(pathAndRnti.str()) == true) + if (macStats->ExistsCellIdPath(pathAndRnti.str())) { cellId = macStats->GetCellIdPath(pathAndRnti.str()); } diff --git a/src/lte/helper/mac-stats-calculator.h b/src/lte/helper/mac-stats-calculator.h index 29ad0fe22..83baca369 100644 --- a/src/lte/helper/mac-stats-calculator.h +++ b/src/lte/helper/mac-stats-calculator.h @@ -22,8 +22,9 @@ #ifndef MAC_STATS_CALCULATOR_H_ #define MAC_STATS_CALCULATOR_H_ +#include "lte-stats-calculator.h" + #include "ns3/lte-enb-mac.h" -#include "ns3/lte-stats-calculator.h" #include "ns3/nstime.h" #include "ns3/uinteger.h" diff --git a/src/lte/helper/no-backhaul-epc-helper.cc b/src/lte/helper/no-backhaul-epc-helper.cc index 98ce23bab..0c7648bef 100644 --- a/src/lte/helper/no-backhaul-epc-helper.cc +++ b/src/lte/helper/no-backhaul-epc-helper.cc @@ -18,7 +18,7 @@ * (based on the original point-to-point-epc-helper.cc) */ -#include "ns3/no-backhaul-epc-helper.h" +#include "no-backhaul-epc-helper.h" #include "ns3/boolean.h" #include "ns3/epc-enb-application.h" diff --git a/src/lte/helper/no-backhaul-epc-helper.h b/src/lte/helper/no-backhaul-epc-helper.h index ae8b08e0b..cc0194fdf 100644 --- a/src/lte/helper/no-backhaul-epc-helper.h +++ b/src/lte/helper/no-backhaul-epc-helper.h @@ -21,7 +21,7 @@ #ifndef NO_BACKHAUL_EPC_HELPER_H #define NO_BACKHAUL_EPC_HELPER_H -#include "ns3/epc-helper.h" +#include "epc-helper.h" namespace ns3 { diff --git a/src/lte/helper/phy-rx-stats-calculator.cc b/src/lte/helper/phy-rx-stats-calculator.cc index 447edb8be..cd108dc69 100644 --- a/src/lte/helper/phy-rx-stats-calculator.cc +++ b/src/lte/helper/phy-rx-stats-calculator.cc @@ -106,7 +106,7 @@ PhyRxStatsCalculator::DlPhyReception(PhyReceptionStatParameters params) << params.m_ndi << params.m_correctness); NS_LOG_INFO("Write DL Rx Phy Stats in " << GetDlRxOutputFilename()); - if (m_dlRxFirstWrite == true) + if (m_dlRxFirstWrite) { m_dlRxOutFile.open(GetDlRxOutputFilename()); if (!m_dlRxOutFile.is_open()) @@ -142,7 +142,7 @@ PhyRxStatsCalculator::UlPhyReception(PhyReceptionStatParameters params) << params.m_ndi << params.m_correctness); NS_LOG_INFO("Write UL Rx Phy Stats in " << GetUlRxOutputFilename()); - if (m_ulRxFirstWrite == true) + if (m_ulRxFirstWrite) { m_ulRxOutFile.open(GetUlRxOutputFilename()); if (!m_ulRxOutFile.is_open()) @@ -178,7 +178,7 @@ PhyRxStatsCalculator::DlPhyReceptionCallback(Ptr phyRxStat std::ostringstream pathAndRnti; pathAndRnti << path << "/" << params.m_rnti; std::string pathUePhy = path.substr(0, path.find("/ComponentCarrierMapUe")); - if (phyRxStats->ExistsImsiPath(pathAndRnti.str()) == true) + if (phyRxStats->ExistsImsiPath(pathAndRnti.str())) { imsi = phyRxStats->GetImsiPath(pathAndRnti.str()); } @@ -202,7 +202,7 @@ PhyRxStatsCalculator::UlPhyReceptionCallback(Ptr phyRxStat std::ostringstream pathAndRnti; std::string pathEnb = path.substr(0, path.find("/ComponentCarrierMap")); pathAndRnti << pathEnb << "/LteEnbRrc/UeMap/" << params.m_rnti; - if (phyRxStats->ExistsImsiPath(pathAndRnti.str()) == true) + if (phyRxStats->ExistsImsiPath(pathAndRnti.str())) { imsi = phyRxStats->GetImsiPath(pathAndRnti.str()); } diff --git a/src/lte/helper/phy-rx-stats-calculator.h b/src/lte/helper/phy-rx-stats-calculator.h index 95129089d..d98f73524 100644 --- a/src/lte/helper/phy-rx-stats-calculator.h +++ b/src/lte/helper/phy-rx-stats-calculator.h @@ -22,7 +22,8 @@ #ifndef PHY_RX_STATS_CALCULATOR_H_ #define PHY_RX_STATS_CALCULATOR_H_ -#include "ns3/lte-stats-calculator.h" +#include "lte-stats-calculator.h" + #include "ns3/nstime.h" #include "ns3/uinteger.h" #include diff --git a/src/lte/helper/phy-stats-calculator.cc b/src/lte/helper/phy-stats-calculator.cc index ffa07a31d..32d516745 100644 --- a/src/lte/helper/phy-stats-calculator.cc +++ b/src/lte/helper/phy-stats-calculator.cc @@ -132,7 +132,7 @@ PhyStatsCalculator::ReportCurrentCellRsrpSinr(uint16_t cellId, NS_LOG_FUNCTION(this << cellId << imsi << rnti << rsrp << sinr); NS_LOG_INFO("Write RSRP/SINR Phy Stats in " << GetCurrentCellRsrpSinrFilename()); - if (m_RsrpSinrFirstWrite == true) + if (m_RsrpSinrFirstWrite) { m_rsrpOutFile.open(GetCurrentCellRsrpSinrFilename()); if (!m_rsrpOutFile.is_open()) @@ -164,7 +164,7 @@ PhyStatsCalculator::ReportUeSinr(uint16_t cellId, NS_LOG_FUNCTION(this << cellId << imsi << rnti << sinrLinear); NS_LOG_INFO("Write SINR Linear Phy Stats in " << GetUeSinrFilename()); - if (m_UeSinrFirstWrite == true) + if (m_UeSinrFirstWrite) { m_ueSinrOutFile.open(GetUeSinrFilename()); if (!m_ueSinrOutFile.is_open()) @@ -190,7 +190,7 @@ PhyStatsCalculator::ReportInterference(uint16_t cellId, Ptr inter NS_LOG_FUNCTION(this << cellId << interference); NS_LOG_INFO("Write Interference Phy Stats in " << GetInterferenceFilename()); - if (m_InterferenceFirstWrite == true) + if (m_InterferenceFirstWrite) { m_interferenceOutFile.open(GetInterferenceFilename()); if (!m_interferenceOutFile.is_open()) @@ -220,7 +220,7 @@ PhyStatsCalculator::ReportCurrentCellRsrpSinrCallback(Ptr ph NS_LOG_FUNCTION(phyStats << path); uint64_t imsi = 0; std::string pathUePhy = path.substr(0, path.find("/ComponentCarrierMapUe")); - if (phyStats->ExistsImsiPath(pathUePhy) == true) + if (phyStats->ExistsImsiPath(pathUePhy)) { imsi = phyStats->GetImsiPath(pathUePhy); } @@ -248,7 +248,7 @@ PhyStatsCalculator::ReportUeSinr(Ptr phyStats, pathAndRnti << path << "/" << rnti; std::string pathEnbMac = path.substr(0, path.find("/ComponentCarrierMap")); pathEnbMac += "/LteEnbMac/DlScheduling"; - if (phyStats->ExistsImsiPath(pathAndRnti.str()) == true) + if (phyStats->ExistsImsiPath(pathAndRnti.str())) { imsi = phyStats->GetImsiPath(pathAndRnti.str()); } diff --git a/src/lte/helper/phy-stats-calculator.h b/src/lte/helper/phy-stats-calculator.h index 86ae42fea..42c8fd978 100644 --- a/src/lte/helper/phy-stats-calculator.h +++ b/src/lte/helper/phy-stats-calculator.h @@ -20,7 +20,8 @@ #ifndef PHY_STATS_CALCULATOR_H_ #define PHY_STATS_CALCULATOR_H_ -#include "ns3/lte-stats-calculator.h" +#include "lte-stats-calculator.h" + #include "ns3/nstime.h" #include "ns3/spectrum-value.h" #include "ns3/uinteger.h" diff --git a/src/lte/helper/phy-tx-stats-calculator.cc b/src/lte/helper/phy-tx-stats-calculator.cc index 3cff748cb..afb7b96d4 100644 --- a/src/lte/helper/phy-tx-stats-calculator.cc +++ b/src/lte/helper/phy-tx-stats-calculator.cc @@ -106,7 +106,7 @@ PhyTxStatsCalculator::DlPhyTransmission(PhyTransmissionStatParameters params) << params.m_ndi); NS_LOG_INFO("Write DL Tx Phy Stats in " << GetDlTxOutputFilename()); - if (m_dlTxFirstWrite == true) + if (m_dlTxFirstWrite) { m_dlTxOutFile.open(GetDlOutputFilename()); if (!m_dlTxOutFile.is_open()) @@ -140,7 +140,7 @@ PhyTxStatsCalculator::UlPhyTransmission(PhyTransmissionStatParameters params) << params.m_ndi); NS_LOG_INFO("Write UL Tx Phy Stats in " << GetUlTxOutputFilename()); - if (m_ulTxFirstWrite == true) + if (m_ulTxFirstWrite) { m_ulTxOutFile.open(GetUlTxOutputFilename()); if (!m_ulTxOutFile.is_open()) @@ -177,7 +177,7 @@ PhyTxStatsCalculator::DlPhyTransmissionCallback(Ptr phyTxS std::ostringstream pathAndRnti; std::string pathEnb = path.substr(0, path.find("/ComponentCarrierMap")); pathAndRnti << pathEnb << "/LteEnbRrc/UeMap/" << params.m_rnti; - if (phyTxStats->ExistsImsiPath(pathAndRnti.str()) == true) + if (phyTxStats->ExistsImsiPath(pathAndRnti.str())) { imsi = phyTxStats->GetImsiPath(pathAndRnti.str()); } @@ -201,7 +201,7 @@ PhyTxStatsCalculator::UlPhyTransmissionCallback(Ptr phyTxS std::ostringstream pathAndRnti; pathAndRnti << path << "/" << params.m_rnti; std::string pathUePhy = path.substr(0, path.find("/ComponentCarrierMapUe")); - if (phyTxStats->ExistsImsiPath(pathAndRnti.str()) == true) + if (phyTxStats->ExistsImsiPath(pathAndRnti.str())) { imsi = phyTxStats->GetImsiPath(pathAndRnti.str()); } diff --git a/src/lte/helper/phy-tx-stats-calculator.h b/src/lte/helper/phy-tx-stats-calculator.h index 35237f6e6..ef2de9dc8 100644 --- a/src/lte/helper/phy-tx-stats-calculator.h +++ b/src/lte/helper/phy-tx-stats-calculator.h @@ -22,7 +22,8 @@ #ifndef PHY_TX_STATS_CALCULATOR_H_ #define PHY_TX_STATS_CALCULATOR_H_ -#include "ns3/lte-stats-calculator.h" +#include "lte-stats-calculator.h" + #include "ns3/nstime.h" #include "ns3/uinteger.h" #include diff --git a/src/lte/helper/point-to-point-epc-helper.cc b/src/lte/helper/point-to-point-epc-helper.cc index f06d170a0..a5ed68ce7 100644 --- a/src/lte/helper/point-to-point-epc-helper.cc +++ b/src/lte/helper/point-to-point-epc-helper.cc @@ -20,7 +20,7 @@ * (most of the code refactored to no-backhaul-epc-helper.cc) */ -#include "ns3/point-to-point-epc-helper.h" +#include "point-to-point-epc-helper.h" #include "ns3/boolean.h" #include "ns3/log.h" diff --git a/src/lte/helper/point-to-point-epc-helper.h b/src/lte/helper/point-to-point-epc-helper.h index 5f1d0f0d9..8c7f041c9 100644 --- a/src/lte/helper/point-to-point-epc-helper.h +++ b/src/lte/helper/point-to-point-epc-helper.h @@ -23,7 +23,7 @@ #ifndef POINT_TO_POINT_EPC_HELPER_H #define POINT_TO_POINT_EPC_HELPER_H -#include "ns3/no-backhaul-epc-helper.h" +#include "no-backhaul-epc-helper.h" namespace ns3 { diff --git a/src/lte/helper/radio-bearer-stats-calculator.cc b/src/lte/helper/radio-bearer-stats-calculator.cc index 9685ac491..55d639cd5 100644 --- a/src/lte/helper/radio-bearer-stats-calculator.cc +++ b/src/lte/helper/radio-bearer-stats-calculator.cc @@ -244,7 +244,7 @@ RadioBearerStatsCalculator::ShowResults() std::ofstream ulOutFile; std::ofstream dlOutFile; - if (m_firstWrite == true) + if (m_firstWrite) { ulOutFile.open(GetUlOutputFilename()); if (!ulOutFile.is_open()) diff --git a/src/lte/helper/radio-bearer-stats-calculator.h b/src/lte/helper/radio-bearer-stats-calculator.h index 7ea405786..babb6e4d2 100644 --- a/src/lte/helper/radio-bearer-stats-calculator.h +++ b/src/lte/helper/radio-bearer-stats-calculator.h @@ -21,9 +21,10 @@ #ifndef RADIO_BEARER_STATS_CALCULATOR_H_ #define RADIO_BEARER_STATS_CALCULATOR_H_ +#include "lte-stats-calculator.h" + #include "ns3/basic-data-calculators.h" #include "ns3/lte-common.h" -#include "ns3/lte-stats-calculator.h" #include "ns3/object.h" #include "ns3/uinteger.h" diff --git a/src/lte/model/a2-a4-rsrq-handover-algorithm.h b/src/lte/model/a2-a4-rsrq-handover-algorithm.h index e226b9712..e45885b7c 100644 --- a/src/lte/model/a2-a4-rsrq-handover-algorithm.h +++ b/src/lte/model/a2-a4-rsrq-handover-algorithm.h @@ -27,9 +27,10 @@ #ifndef A2_A4_RSRQ_HANDOVER_ALGORITHM_H #define A2_A4_RSRQ_HANDOVER_ALGORITHM_H -#include -#include -#include +#include "lte-handover-algorithm.h" +#include "lte-handover-management-sap.h" +#include "lte-rrc-sap.h" + #include #include diff --git a/src/lte/model/a3-rsrp-handover-algorithm.cc b/src/lte/model/a3-rsrp-handover-algorithm.cc index 778e72c5a..32e117b62 100644 --- a/src/lte/model/a3-rsrp-handover-algorithm.cc +++ b/src/lte/model/a3-rsrp-handover-algorithm.cc @@ -20,9 +20,10 @@ #include "a3-rsrp-handover-algorithm.h" +#include "lte-common.h" + #include #include -#include #include #include diff --git a/src/lte/model/a3-rsrp-handover-algorithm.h b/src/lte/model/a3-rsrp-handover-algorithm.h index eaa46f8d1..ba6fda1bd 100644 --- a/src/lte/model/a3-rsrp-handover-algorithm.h +++ b/src/lte/model/a3-rsrp-handover-algorithm.h @@ -21,9 +21,10 @@ #ifndef A3_RSRP_HANDOVER_ALGORITHM_H #define A3_RSRP_HANDOVER_ALGORITHM_H -#include -#include -#include +#include "lte-handover-algorithm.h" +#include "lte-handover-management-sap.h" +#include "lte-rrc-sap.h" + #include namespace ns3 diff --git a/src/lte/model/component-carrier-enb.cc b/src/lte/model/component-carrier-enb.cc index c29019a8c..f2cf4b678 100644 --- a/src/lte/model/component-carrier-enb.cc +++ b/src/lte/model/component-carrier-enb.cc @@ -19,13 +19,14 @@ #include "component-carrier-enb.h" +#include "ff-mac-scheduler.h" +#include "lte-enb-mac.h" +#include "lte-enb-phy.h" +#include "lte-ffr-algorithm.h" + #include #include -#include #include -#include -#include -#include #include #include #include diff --git a/src/lte/model/component-carrier-enb.h b/src/lte/model/component-carrier-enb.h index d0c74cc76..4c422e2ec 100644 --- a/src/lte/model/component-carrier-enb.h +++ b/src/lte/model/component-carrier-enb.h @@ -21,9 +21,8 @@ #define COMPONENT_CARRIER_ENB_H #include "component-carrier.h" +#include "lte-enb-phy.h" -#include "ns3/lte-phy.h" -#include #include #include #include diff --git a/src/lte/model/component-carrier-ue.cc b/src/lte/model/component-carrier-ue.cc index 19902545a..2d7fe75f4 100644 --- a/src/lte/model/component-carrier-ue.cc +++ b/src/lte/model/component-carrier-ue.cc @@ -19,11 +19,12 @@ #include "component-carrier-ue.h" +#include "lte-ue-mac.h" +#include "lte-ue-phy.h" + #include #include #include -#include -#include #include #include #include diff --git a/src/lte/model/component-carrier-ue.h b/src/lte/model/component-carrier-ue.h index 2dcbbedba..8e369cd82 100644 --- a/src/lte/model/component-carrier-ue.h +++ b/src/lte/model/component-carrier-ue.h @@ -20,9 +20,10 @@ #ifndef COMPONENT_CARRIER_UE_H #define COMPONENT_CARRIER_UE_H -#include "ns3/lte-phy.h" -#include -#include +#include "component-carrier.h" +#include "lte-phy.h" +#include "lte-ue-phy.h" + #include #include #include diff --git a/src/lte/model/cqa-ff-mac-scheduler.cc b/src/lte/model/cqa-ff-mac-scheduler.cc index f606595d7..4707e5704 100644 --- a/src/lte/model/cqa-ff-mac-scheduler.cc +++ b/src/lte/model/cqa-ff-mac-scheduler.cc @@ -22,13 +22,15 @@ * Proportional Fair and Round Robin schedulers implementations. */ +#include "cqa-ff-mac-scheduler.h" + +#include "ff-mac-common.h" +#include "lte-amc.h" +#include "lte-vendor-specific-parameters.h" + #include -#include -#include #include #include -#include -#include #include #include #include @@ -229,7 +231,7 @@ CqaFfMacScheduler::GetLteFfrSapUser() void CqaFfMacScheduler::DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params) + const FfMacCschedSapProvider::CschedCellConfigReqParameters& params) { NS_LOG_FUNCTION(this); // Read the subset of parameters used @@ -242,7 +244,7 @@ CqaFfMacScheduler::DoCschedCellConfigReq( void CqaFfMacScheduler::DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params) + const FfMacCschedSapProvider::CschedUeConfigReqParameters& params) { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); @@ -288,7 +290,7 @@ CqaFfMacScheduler::DoCschedUeConfigReq( void CqaFfMacScheduler::DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params) + const FfMacCschedSapProvider::CschedLcConfigReqParameters& params) { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); @@ -298,7 +300,7 @@ CqaFfMacScheduler::DoCschedLcConfigReq( // LTE MAC scheduler specification if (params.m_reconfigureFlag) { - std::vector::const_iterator lcit; + std::vector::const_iterator lcit; for (lcit = params.m_logicalChannelConfigList.begin(); lcit != params.m_logicalChannelConfigList.end(); @@ -320,7 +322,7 @@ CqaFfMacScheduler::DoCschedLcConfigReq( } // else new UE is added else { - std::vector::const_iterator lcit; + std::vector::const_iterator lcit; for (lcit = params.m_logicalChannelConfigList.begin(); lcit != params.m_logicalChannelConfigList.end(); @@ -377,7 +379,7 @@ CqaFfMacScheduler::DoCschedLcConfigReq( void CqaFfMacScheduler::DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); std::vector::const_iterator it; @@ -424,7 +426,7 @@ CqaFfMacScheduler::DoCschedLcReleaseReq( void CqaFfMacScheduler::DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) { NS_LOG_FUNCTION(this); @@ -475,7 +477,7 @@ CqaFfMacScheduler::DoCschedUeReleaseReq( void CqaFfMacScheduler::DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) { 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) @@ -500,7 +502,7 @@ CqaFfMacScheduler::DoSchedDlRlcBufferReq( void CqaFfMacScheduler::DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -508,7 +510,7 @@ CqaFfMacScheduler::DoSchedDlPagingBufferReq( void CqaFfMacScheduler::DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -570,14 +572,8 @@ CqaFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { i = (i + 1) % HARQ_PROC_NUM; } while (((*itStat).second.at(i) != 0) && (i != (*it).second)); - if ((*itStat).second.at(i) == 0) - { - return (true); - } - else - { - return (false); // return a not valid harq proc id - } + + return (*itStat).second.at(i) == 0; } uint8_t @@ -585,7 +581,7 @@ CqaFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - if (m_harqOn == false) + if (!m_harqOn) { return (0); } @@ -656,7 +652,7 @@ CqaFfMacScheduler::RefreshHarqProcesses() void CqaFfMacScheduler::DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); @@ -687,7 +683,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) { - if ((*it) == true) + if (*it) { rbgAllocatedNum++; } @@ -715,7 +711,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) { - if ((*it) == true) + if (*it) { if (tmpMinBandwidth > maxContinuousUlBandwidth) { @@ -744,7 +740,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; + std::vector::iterator itRach; for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > @@ -786,7 +782,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.at(i) = (*itRach).m_rnti; } - if (m_harqOn == true) + if (m_harqOn) { // generate UL-DCI for HARQ retransmissions UlDciListElement_s uldci; @@ -851,12 +847,12 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( m_dlInfoListBuffered = params.m_dlInfoList; } } - if (m_harqOn == false) + if (!m_harqOn) { // Ignore HARQ feedback m_dlInfoListBuffered.clear(); } - std::vector dlInfoListUntxed; + 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); @@ -947,7 +943,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( bool free = true; for (std::size_t j = 0; j < dciRbg.size(); j++) { - if (rbgMap.at(dciRbg.at(j)) == true) + if (rbgMap.at(dciRbg.at(j))) { free = false; break; @@ -975,7 +971,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( std::vector rbgMapCopy = rbgMap; while ((j < dciRbg.size()) && (startRbg != rbgId)) { - if (rbgMapCopy.at(rbgId) == false) + if (!rbgMapCopy.at(rbgId)) { rbgMapCopy.at(rbgId) = true; dciRbg.at(j) = rbgId; @@ -1046,7 +1042,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( } for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++) { - std::vector rlcPduListPerLc; + std::vector rlcPduListPerLc; for (std::size_t j = 0; j < nLayers; j++) { if (retx.at(j)) @@ -1131,7 +1127,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( return; } - std::map::iterator itLogicalChannels; + std::map::iterator itLogicalChannels; for (itLogicalChannels = m_ueLogicalChannelsConfigList.begin(); itLogicalChannels != m_ueLogicalChannelsConfigList.end(); @@ -1182,7 +1178,8 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( UEtoHOL.insert(std::pair(itLogicalChannels->first, delay)); - if (itLogicalChannels->second.m_qosBearerType == itLogicalChannels->second.QBT_NON_GBR) + if (itLogicalChannels->second.m_qosBearerType == + LogicalChannelConfigListElement_s::QBT_NON_GBR) { if (map_nonGBRHOLgroupToUE.count(group) == 0) { @@ -1195,7 +1192,10 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( map_nonGBRHOLgroupToUE.find(group)->second.insert(itRlcBufferReq->first); } } - else if (itLogicalChannels->second.m_qosBearerType == itLogicalChannels->second.QBT_GBR) + else if (itLogicalChannels->second.m_qosBearerType == + LogicalChannelConfigListElement_s::QBT_GBR || + itLogicalChannels->second.m_qosBearerType == + LogicalChannelConfigListElement_s::QBT_DGBR) { if (map_GBRHOLgroupToUE.count(group) == 0) { @@ -1326,7 +1326,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( std::set availableRBGs; for (int i = 0; i < numberOfRBGs; i++) { - if (rbgMap.at(i) == false) + if (!rbgMap.at(i)) { availableRBGs.insert(i); } @@ -1398,7 +1398,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( std::map::iterator itStats; - if ((m_ffrSapProvider->IsDlRbgAvailableForUe(currentRB, flowId.m_rnti)) == false) + if (!m_ffrSapProvider->IsDlRbgAvailableForUe(currentRB, flowId.m_rnti)) { continue; } @@ -1618,7 +1618,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( NS_LOG_INFO("Scheduled RNTI:" << newEl.m_rnti); // create the DlDciListElement_s DlDciListElement_s newDci; - std::vector newRlcPduLe; + std::vector newRlcPduLe; newDci.m_rnti = (*itMap).first; newDci.m_harqProcess = UpdateHarqProcessId((*itMap).first); uint16_t lcActives = LcActivePerFlow(itMap->first); @@ -1673,7 +1673,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) || ((*itBufReq).second.m_rlcStatusPduSize > 0))) { - std::vector newRlcPduLe; + std::vector newRlcPduLe; // for (uint8_t j = 0; j < nLayer; j++) //{ RlcPduListElement_s newRlcEl; @@ -1686,7 +1686,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( UpdateDlRlcBufferInfo(newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size); - if (m_harqOn == true) + if (m_harqOn) { // store RLC PDU list for HARQ std::map::iterator itRlcPdu = @@ -1717,7 +1717,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = newDci; - if (m_harqOn == true) + if (m_harqOn) { // store DCI for HARQ std::map::iterator itDci = @@ -1794,7 +1794,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( void CqaFfMacScheduler::DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1803,7 +1803,7 @@ CqaFfMacScheduler::DoSchedDlRachInfoReq( void CqaFfMacScheduler::DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); m_ffrSapProvider->ReportDlCqiInfo(params); @@ -1898,7 +1898,7 @@ CqaFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) void CqaFfMacScheduler::DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size()); @@ -1924,7 +1924,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) { - if ((*it) == true) + if (*it) { rbAllocatedNum++; } @@ -1943,7 +1943,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( } } - if (m_harqOn == true) + if (m_harqOn) { // Process UL HARQ feedback for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++) @@ -1984,7 +1984,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; NS_LOG_INFO(this << " BUSY " << j); @@ -2125,12 +2125,12 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; break; } - if ((m_ffrSapProvider->IsUlRbgAvailableForUe(j, (*it).first)) == false) + if (!m_ffrSapProvider->IsUlRbgAvailableForUe(j, (*it).first)) { free = false; break; @@ -2247,7 +2247,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( ret.m_dciList.push_back(uldci); // store DCI for HARQ_PERIOD uint8_t harqId = 0; - if (m_harqOn == true) + if (m_harqOn) { std::map::iterator itProcId; itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); @@ -2327,21 +2327,21 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( void CqaFfMacScheduler::DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) { NS_LOG_FUNCTION(this); } void CqaFfMacScheduler::DoSchedUlSrInfoReq( - const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) { NS_LOG_FUNCTION(this); } void CqaFfMacScheduler::DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -2384,7 +2384,7 @@ CqaFfMacScheduler::DoSchedUlMacCtrlInfoReq( void CqaFfMacScheduler::DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); // retrieve the allocation for this subframe diff --git a/src/lte/model/cqa-ff-mac-scheduler.h b/src/lte/model/cqa-ff-mac-scheduler.h index 9b96fbde9..8fc6b0a93 100644 --- a/src/lte/model/cqa-ff-mac-scheduler.h +++ b/src/lte/model/cqa-ff-mac-scheduler.h @@ -23,43 +23,22 @@ #ifndef CQA_FF_MAC_SCHEDULER_H #define CQA_FF_MAC_SCHEDULER_H -#include -#include -#include -#include -#include -#include +#include "ff-mac-csched-sap.h" +#include "ff-mac-sched-sap.h" +#include "ff-mac-scheduler.h" +#include "lte-amc.h" +#include "lte-common.h" +#include "lte-ffr-sap.h" + #include #include #include #include -// value for SINR outside the range defined by FF-API, used to indicate that there -// is no CQI for this element - -#define NO_SINR -5000 -#define HARQ_PROC_NUM 8 -#define HARQ_DL_TIMEOUT 11 - namespace ns3 { -/// DL HARQ process status vector typedef -typedef std::vector DlHarqProcessesStatus_t; -/// DL HARQ process timer vector typedef -typedef std::vector DlHarqProcessesTimer_t; -/// DL HARQ process DCI buffer vector typedef -typedef std::vector DlHarqProcessesDciBuffer_t; -/// vector of the LCs and layers per UE -typedef std::vector> RlcPduList_t; -/// vector of the 8 HARQ processes per UE -typedef std::vector DlHarqRlcPduListBuffer_t; -/// UL HARQ process DCI buffer vector -typedef std::vector UlHarqProcessesDciBuffer_t; -/// UL HARQ process status vector -typedef std::vector UlHarqProcessesStatus_t; - /// CGA Flow Performance structure struct CqasFlowPerf_t { @@ -133,36 +112,31 @@ class CqaFfMacScheduler : public FfMacScheduler * Csched Cell Config Request * \param params CschedCellConfigReqParameters& */ - void DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params); + void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters& params); /** * Csched UE Config Request * \param params CschedUeConfigReqParameters& */ - void DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params); + void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters& params); /** * Csched LC Config Request * \param params CschedLcConfigReqParameters& */ - void DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params); + void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters& params); /** * Csched LC Release Request * \param params CschedLcReleaseReqParameters& */ - void DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); + void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); /** * Csched UE Release Request * \param params CschedUeReleaseReqParameters& */ - void DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); + void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); // // Implementation of the SCHED API primitives @@ -173,77 +147,70 @@ class CqaFfMacScheduler : public FfMacScheduler * Sched DL RLC Buffer Request * \param params SchedDlRlcBufferReqParameters& */ - void DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); + void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); /** * Sched DL Paging Buffer Request * \param params SchedDlPagingBufferReqParameters& */ void DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); /** * Sched DL MAC Buffer Request * \param params SchedDlMacBufferReqParameters& */ - void DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); + void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); /** * Sched DL RLC Buffer Request * \param params SchedDlTriggerReqParameters& */ - void DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); + void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); /** * Sched DL RACH Info Request * \param params SchedDlRachInfoReqParameters& */ - void DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); + void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); /** * Sched DL CGI Info Request * \param params SchedDlCqiInfoReqParameters& */ - void DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); + void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); /** * Sched UL Trigger Request * \param params SchedUlTriggerReqParameters& */ - void DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); + void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); /** * Sched UL Noise InterferenceRequest * \param params SchedUlNoiseInterferenceReqParameters& */ void DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); /** * Sched UL Sr Info Request * \param params SchedUlSrInfoReqParameters& */ - void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); + void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); /** * Sched UL MAC Control Info Request * \param params SchedUlMacCtrlInfoReqParameters& */ void DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); /** * Sched UL CGI Info Request * \param params SchedUlCqiInfoReqParameters& */ - void DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); + void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); /** * Get RGB Size @@ -328,7 +295,7 @@ class CqaFfMacScheduler : public FfMacScheduler /** * Map of UE logical channel config list */ - std::map m_ueLogicalChannelsConfigList; + std::map m_ueLogicalChannelsConfigList; /** * Map of UE's DL CQI P01 received @@ -416,9 +383,9 @@ class CqaFfMacScheduler : public FfMacScheduler m_ulHarqProcessesDciBuffer; ///< UL HARQ process DCI buffer // RACH attributes - std::vector m_rachList; ///< RACH list - std::vector m_rachAllocationMap; ///< RACH allocation map - uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) + std::vector m_rachList; ///< RACH list + std::vector m_rachAllocationMap; ///< RACH allocation map + uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) std::string m_CqaMetric; ///< CQA metric name }; diff --git a/src/lte/model/epc-enb-application.cc b/src/lte/model/epc-enb-application.cc index 224486c74..0b48d5c41 100644 --- a/src/lte/model/epc-enb-application.cc +++ b/src/lte/model/epc-enb-application.cc @@ -227,7 +227,7 @@ EpcEnbApplication::DoInitialContextSetupRequest( ++erabIt) { // request the RRC to setup a radio bearer - struct EpcEnbS1SapUser::DataRadioBearerSetupRequestParameters params; + EpcEnbS1SapUser::DataRadioBearerSetupRequestParameters params; params.rnti = rnti; params.bearer = erabIt->erabLevelQosParameters; params.bearerId = erabIt->erabId; @@ -241,7 +241,7 @@ EpcEnbApplication::DoInitialContextSetupRequest( } // Send Initial Context Setup Request to RRC - struct EpcEnbS1SapUser::InitialContextSetupRequestParameters params; + EpcEnbS1SapUser::InitialContextSetupRequestParameters params; params.rnti = rnti; m_s1SapUser->InitialContextSetupRequest(params); } diff --git a/src/lte/model/epc-enb-application.h b/src/lte/model/epc-enb-application.h index d44c4f1d9..fef63a18b 100644 --- a/src/lte/model/epc-enb-application.h +++ b/src/lte/model/epc-enb-application.h @@ -21,13 +21,12 @@ #ifndef EPC_ENB_APPLICATION_H #define EPC_ENB_APPLICATION_H +#include "epc-enb-s1-sap.h" +#include "epc-s1ap-sap.h" + #include #include #include -#include -#include -#include -#include #include #include #include @@ -150,7 +149,7 @@ class EpcEnbApplication : public Application struct EpsFlowId_t { uint16_t m_rnti; ///< RNTI - uint8_t m_bid; ///< Bid, the EPS Bearer IDentifier + uint8_t m_bid; ///< Bid, the EPS Bearer Identifier public: EpsFlowId_t(); @@ -237,7 +236,7 @@ class EpcEnbApplication : public Application * * \param packet t * \param rnti maps to enbUeS1Id - * \param bid the EPS Bearer IDentifier + * \param bid the EPS Bearer Identifier */ void SendToLteSocket(Ptr packet, uint16_t rnti, uint8_t bid); @@ -245,16 +244,16 @@ class EpcEnbApplication : public Application * Send a packet to the SGW via the S1-U interface * * \param packet packet to be sent - * \param teid the Tunnel Endpoint IDentifier + * \param teid the Tunnel Endpoint Identifier */ void SendToS1uSocket(Ptr packet, uint32_t teid); /** * internal method used for the actual setup of the S1 Bearer * - * \param teid the Tunnel Endpoint IDentifier + * \param teid the Tunnel Endpoint Identifier * \param rnti maps to enbUeS1Id - * \param bid the S1-U Bearer IDentifier + * \param bid the S1-U Bearer Identifier */ void SetupS1Bearer(uint32_t teid, uint16_t rnti, uint8_t bid); diff --git a/src/lte/model/epc-enb-s1-sap.cc b/src/lte/model/epc-enb-s1-sap.cc index 8f794c642..4dc79c5a6 100644 --- a/src/lte/model/epc-enb-s1-sap.cc +++ b/src/lte/model/epc-enb-s1-sap.cc @@ -17,7 +17,7 @@ * Author: Nicola Baldo */ -#include "ns3/epc-enb-s1-sap.h" +#include "epc-enb-s1-sap.h" namespace ns3 { diff --git a/src/lte/model/epc-enb-s1-sap.h b/src/lte/model/epc-enb-s1-sap.h index 431098566..50a0bc5c7 100644 --- a/src/lte/model/epc-enb-s1-sap.h +++ b/src/lte/model/epc-enb-s1-sap.h @@ -20,7 +20,8 @@ #ifndef EPC_ENB_S1_SAP_H #define EPC_ENB_S1_SAP_H -#include +#include "eps-bearer.h" + #include #include diff --git a/src/lte/model/epc-gtpc-header.cc b/src/lte/model/epc-gtpc-header.cc index 1d29a13cd..a3bd7a6cc 100644 --- a/src/lte/model/epc-gtpc-header.cc +++ b/src/lte/model/epc-gtpc-header.cc @@ -17,7 +17,7 @@ * Author: Manuel Requena */ -#include "ns3/epc-gtpc-header.h" +#include "epc-gtpc-header.h" #include "ns3/log.h" diff --git a/src/lte/model/epc-gtpc-header.h b/src/lte/model/epc-gtpc-header.h index 64597ebf1..bad4b313f 100644 --- a/src/lte/model/epc-gtpc-header.h +++ b/src/lte/model/epc-gtpc-header.h @@ -20,8 +20,9 @@ #ifndef EPC_GTPC_HEADER_H #define EPC_GTPC_HEADER_H -#include "ns3/epc-tft.h" -#include "ns3/eps-bearer.h" +#include "epc-tft.h" +#include "eps-bearer.h" + #include "ns3/header.h" namespace ns3 diff --git a/src/lte/model/epc-gtpu-header.cc b/src/lte/model/epc-gtpu-header.cc index 79b69dc1b..f3de6628c 100644 --- a/src/lte/model/epc-gtpu-header.cc +++ b/src/lte/model/epc-gtpu-header.cc @@ -270,16 +270,12 @@ GtpuHeader::SetVersion(uint8_t m_version) bool GtpuHeader::operator==(const GtpuHeader& b) const { - if (m_version == b.m_version && m_protocolType == b.m_protocolType && - m_extensionHeaderFlag == b.m_extensionHeaderFlag && - m_sequenceNumberFlag == b.m_sequenceNumberFlag && m_nPduNumberFlag == b.m_nPduNumberFlag && - m_messageType == b.m_messageType && m_length == b.m_length && m_teid == b.m_teid && - m_sequenceNumber == b.m_sequenceNumber && m_nPduNumber == b.m_nPduNumber && - m_nextExtensionType == b.m_nextExtensionType) - { - return true; - } - return false; + return m_version == b.m_version && m_protocolType == b.m_protocolType && + m_extensionHeaderFlag == b.m_extensionHeaderFlag && + m_sequenceNumberFlag == b.m_sequenceNumberFlag && + m_nPduNumberFlag == b.m_nPduNumberFlag && m_messageType == b.m_messageType && + m_length == b.m_length && m_teid == b.m_teid && m_sequenceNumber == b.m_sequenceNumber && + m_nPduNumber == b.m_nPduNumber && m_nextExtensionType == b.m_nextExtensionType; } } // namespace ns3 diff --git a/src/lte/model/epc-mme-application.cc b/src/lte/model/epc-mme-application.cc index df1f87e21..eb70b4e55 100644 --- a/src/lte/model/epc-mme-application.cc +++ b/src/lte/model/epc-mme-application.cc @@ -17,11 +17,14 @@ * Author: Manuel Requena */ -#include "ns3/epc-mme-application.h" +#include "epc-mme-application.h" + +#include "epc-gtpc-header.h" -#include "ns3/epc-gtpc-header.h" #include "ns3/log.h" +#include + namespace ns3 { diff --git a/src/lte/model/epc-mme-application.h b/src/lte/model/epc-mme-application.h index dc1ebeab1..d10ff1d3a 100644 --- a/src/lte/model/epc-mme-application.h +++ b/src/lte/model/epc-mme-application.h @@ -26,6 +26,8 @@ #include "ns3/application.h" #include "ns3/socket.h" +#include + namespace ns3 { diff --git a/src/lte/model/epc-pgw-application.cc b/src/lte/model/epc-pgw-application.cc index 46ab7eb43..f5805ff84 100644 --- a/src/lte/model/epc-pgw-application.cc +++ b/src/lte/model/epc-pgw-application.cc @@ -18,10 +18,11 @@ * (based on epc-sgw-pgw-application.cc) */ -#include "ns3/epc-pgw-application.h" +#include "epc-pgw-application.h" + +#include "epc-gtpu-header.h" #include "ns3/abort.h" -#include "ns3/epc-gtpu-header.h" #include "ns3/inet-socket-address.h" #include "ns3/ipv4-l3-protocol.h" #include "ns3/ipv4.h" diff --git a/src/lte/model/epc-pgw-application.h b/src/lte/model/epc-pgw-application.h index 1ee2cd51e..aef395772 100644 --- a/src/lte/model/epc-pgw-application.h +++ b/src/lte/model/epc-pgw-application.h @@ -21,9 +21,10 @@ #ifndef EPC_PGW_APPLICATION_H #define EPC_PGW_APPLICATION_H +#include "epc-gtpc-header.h" +#include "epc-tft-classifier.h" + #include "ns3/application.h" -#include "ns3/epc-gtpc-header.h" -#include "ns3/epc-tft-classifier.h" #include "ns3/socket.h" #include "ns3/virtual-net-device.h" @@ -123,7 +124,7 @@ class EpcPgwApplication : public Application * * \param packet packet to be sent * \param sgwS5uAddress the address of the SGW - * \param teid the Tunnel Endpoint IDentifier + * \param teid the Tunnel Endpoint Identifier */ void SendToS5uSocket(Ptr packet, Ipv4Address sgwS5uAddress, uint32_t teid); diff --git a/src/lte/model/epc-s11-sap.h b/src/lte/model/epc-s11-sap.h index 94f3922b6..6ffd58c25 100644 --- a/src/lte/model/epc-s11-sap.h +++ b/src/lte/model/epc-s11-sap.h @@ -20,9 +20,10 @@ #ifndef EPC_S11_SAP_H #define EPC_S11_SAP_H +#include "epc-tft.h" +#include "eps-bearer.h" + #include -#include -#include #include #include diff --git a/src/lte/model/epc-s1ap-sap.h b/src/lte/model/epc-s1ap-sap.h index 46f5bcbea..6d19a0ef0 100644 --- a/src/lte/model/epc-s1ap-sap.h +++ b/src/lte/model/epc-s1ap-sap.h @@ -20,9 +20,10 @@ #ifndef EPC_S1AP_SAP_H #define EPC_S1AP_SAP_H +#include "eps-bearer.h" + #include -#include -#include +#include #include #include diff --git a/src/lte/model/epc-sgw-application.cc b/src/lte/model/epc-sgw-application.cc index a9f11d8a1..c02c2c7db 100644 --- a/src/lte/model/epc-sgw-application.cc +++ b/src/lte/model/epc-sgw-application.cc @@ -17,11 +17,14 @@ * Author: Manuel Requena */ -#include "ns3/epc-sgw-application.h" +#include "epc-sgw-application.h" + +#include "epc-gtpu-header.h" -#include "ns3/epc-gtpu-header.h" #include "ns3/log.h" +#include + namespace ns3 { diff --git a/src/lte/model/epc-sgw-application.h b/src/lte/model/epc-sgw-application.h index a70af2084..99fab403f 100644 --- a/src/lte/model/epc-sgw-application.h +++ b/src/lte/model/epc-sgw-application.h @@ -20,11 +20,14 @@ #ifndef EPC_SGW_APPLICATION_H #define EPC_SGW_APPLICATION_H +#include "epc-gtpc-header.h" + #include "ns3/address.h" #include "ns3/application.h" -#include "ns3/epc-gtpc-header.h" #include "ns3/socket.h" +#include + namespace ns3 { @@ -144,7 +147,7 @@ class EpcSgwApplication : public Application * * \param packet packet to be sent * \param enbS1uAddress the address of the eNB - * \param teid the Tunnel Endpoint IDentifier + * \param teid the Tunnel Endpoint Identifier */ void SendToS1uSocket(Ptr packet, Ipv4Address enbS1uAddress, uint32_t teid); diff --git a/src/lte/model/epc-tft-classifier.h b/src/lte/model/epc-tft-classifier.h index 3770c7ff5..3819aaebd 100644 --- a/src/lte/model/epc-tft-classifier.h +++ b/src/lte/model/epc-tft-classifier.h @@ -20,7 +20,8 @@ #ifndef EPC_TFT_CLASSIFIER_H #define EPC_TFT_CLASSIFIER_H -#include "ns3/epc-tft.h" +#include "epc-tft.h" + #include "ns3/ptr.h" #include "ns3/simple-ref-count.h" diff --git a/src/lte/model/epc-ue-nas.cc b/src/lte/model/epc-ue-nas.cc index 69f6efc34..b00ba3246 100644 --- a/src/lte/model/epc-ue-nas.cc +++ b/src/lte/model/epc-ue-nas.cc @@ -20,11 +20,11 @@ #include "epc-ue-nas.h" #include "lte-as-sap.h" -#include "lte-enb-net-device.h" #include #include #include +#include namespace ns3 { @@ -222,7 +222,6 @@ EpcUeNas::Send(Ptr packet, uint16_t protocolNumber) default: NS_LOG_WARN(this << " NAS OFF, discarding packet"); return false; - break; } } diff --git a/src/lte/model/epc-ue-nas.h b/src/lte/model/epc-ue-nas.h index 6aa09f72b..a2a047163 100644 --- a/src/lte/model/epc-ue-nas.h +++ b/src/lte/model/epc-ue-nas.h @@ -20,10 +20,10 @@ #ifndef EPC_UE_NAS_H #define EPC_UE_NAS_H +#include "epc-tft-classifier.h" #include "eps-bearer.h" +#include "lte-as-sap.h" -#include -#include #include #include diff --git a/src/lte/model/epc-x2-header.cc b/src/lte/model/epc-x2-header.cc index 990d983d5..94e064299 100644 --- a/src/lte/model/epc-x2-header.cc +++ b/src/lte/model/epc-x2-header.cc @@ -17,7 +17,7 @@ * Author: Manuel Requena */ -#include "ns3/epc-x2-header.h" +#include "epc-x2-header.h" #include "ns3/log.h" diff --git a/src/lte/model/epc-x2-header.h b/src/lte/model/epc-x2-header.h index c3ce296a8..296d298cf 100644 --- a/src/lte/model/epc-x2-header.h +++ b/src/lte/model/epc-x2-header.h @@ -20,7 +20,8 @@ #ifndef EPC_X2_HEADER_H #define EPC_X2_HEADER_H -#include "ns3/epc-x2-sap.h" +#include "epc-x2-sap.h" + #include "ns3/header.h" #include diff --git a/src/lte/model/epc-x2-sap.cc b/src/lte/model/epc-x2-sap.cc index 793ea2af1..d440168b3 100644 --- a/src/lte/model/epc-x2-sap.cc +++ b/src/lte/model/epc-x2-sap.cc @@ -17,7 +17,7 @@ * Author: Manuel Requena */ -#include "ns3/epc-x2-sap.h" +#include "epc-x2-sap.h" namespace ns3 { diff --git a/src/lte/model/epc-x2-sap.h b/src/lte/model/epc-x2-sap.h index 8c4fb0c38..6358a9193 100644 --- a/src/lte/model/epc-x2-sap.h +++ b/src/lte/model/epc-x2-sap.h @@ -20,7 +20,8 @@ #ifndef EPC_X2_SAP_H #define EPC_X2_SAP_H -#include "ns3/eps-bearer.h" +#include "eps-bearer.h" + #include "ns3/ipv4-address.h" #include "ns3/packet.h" diff --git a/src/lte/model/epc-x2.cc b/src/lte/model/epc-x2.cc index 72e6feeea..32fd03f8e 100644 --- a/src/lte/model/epc-x2.cc +++ b/src/lte/model/epc-x2.cc @@ -17,10 +17,11 @@ * Author: Manuel Requena */ -#include "ns3/epc-x2.h" +#include "epc-x2.h" + +#include "epc-gtpu-header.h" +#include "epc-x2-header.h" -#include "ns3/epc-gtpu-header.h" -#include "ns3/epc-x2-header.h" #include "ns3/inet-socket-address.h" #include "ns3/log.h" #include "ns3/node.h" diff --git a/src/lte/model/epc-x2.h b/src/lte/model/epc-x2.h index 891c0bbcf..69a4910cb 100644 --- a/src/lte/model/epc-x2.h +++ b/src/lte/model/epc-x2.h @@ -20,8 +20,9 @@ #ifndef EPC_X2_H #define EPC_X2_H +#include "epc-x2-sap.h" + #include "ns3/callback.h" -#include "ns3/epc-x2-sap.h" #include "ns3/object.h" #include "ns3/ptr.h" #include "ns3/socket.h" diff --git a/src/lte/model/eps-bearer.cc b/src/lte/model/eps-bearer.cc index 2c1e7012b..ba055ceb5 100644 --- a/src/lte/model/eps-bearer.cc +++ b/src/lte/model/eps-bearer.cc @@ -52,7 +52,7 @@ EpsBearer::GetTypeId() .AddConstructor() .AddAttribute( "Release", - "Change from 11 to 15 if you need bearer definition as per Release 15." + "Change from 11 to 18 if you need bearer definition as per newer Releases." " Reference document: TS 23.203. The change does not impact other LTE code than " " bearers definition.", UintegerValue(11), @@ -111,38 +111,42 @@ EpsBearer::SetRelease(uint8_t release) case 15: m_requirements = GetRequirementsRel15(); break; + case 18: + m_requirements = GetRequirementsRel18(); + break; default: NS_FATAL_ERROR("Not recognized release " << static_cast(release) - << " please use a value between 8 and 11, or 15"); + << " please choose a value between" + " 8 and 11, or 15 or 18"); } m_release = release; } -bool -EpsBearer::IsGbr() const +uint8_t +EpsBearer::GetResourceType() const { - return IsGbr(*m_requirements, qci); + return GetResourceType(m_requirements, qci); } uint8_t EpsBearer::GetPriority() const { - return GetPriority(*m_requirements, qci); + return GetPriority(m_requirements, qci); } uint16_t EpsBearer::GetPacketDelayBudgetMs() const { - return GetPacketDelayBudgetMs(*m_requirements, qci); + return GetPacketDelayBudgetMs(m_requirements, qci); } double EpsBearer::GetPacketErrorLossRate() const { - return GetPacketErrorLossRate(*m_requirements, qci); + return GetPacketErrorLossRate(m_requirements, qci); } -EpsBearer::BearerRequirementsMap* +const EpsBearer::BearerRequirementsMap& EpsBearer::GetRequirementsRel11() { /* Needed to support GCC 4.9. Otherwise, use list constructors, for example: @@ -151,74 +155,93 @@ EpsBearer::GetRequirementsRel11() * { * return * { - * { GBR_CONV_VOICE , { true, 20, 100, 1.0e-2, 0, 2000} }, + * { GBR_CONV_VOICE , { 1, 20, 100, 1.0e-2, 0, 2000} }, * ... * }; * } */ - static EpsBearer::BearerRequirementsMap ret; - - if (ret.empty()) - { - ret.insert(std::make_pair(GBR_CONV_VOICE, std::make_tuple(true, 2, 100, 1.0e-2, 0, 0))); - ret.insert(std::make_pair(GBR_CONV_VIDEO, std::make_tuple(true, 4, 150, 1.0e-3, 0, 0))); - ret.insert(std::make_pair(GBR_GAMING, std::make_tuple(true, 3, 50, 1.0e-3, 0, 0))); - ret.insert(std::make_pair(GBR_NON_CONV_VIDEO, std::make_tuple(true, 5, 300, 1.0e-6, 0, 0))); - ret.insert(std::make_pair(NGBR_IMS, std::make_tuple(false, 1, 100, 1.0e-6, 0, 0))); - ret.insert( - std::make_pair(NGBR_VIDEO_TCP_OPERATOR, std::make_tuple(false, 6, 300, 1.0e-6, 0, 0))); - ret.insert( - std::make_pair(NGBR_VOICE_VIDEO_GAMING, std::make_tuple(false, 7, 100, 1.0e-3, 0, 0))); - ret.insert( - std::make_pair(NGBR_VIDEO_TCP_PREMIUM, std::make_tuple(false, 8, 300, 1.0e-6, 0, 0))); - ret.insert( - std::make_pair(NGBR_VIDEO_TCP_DEFAULT, std::make_tuple(false, 9, 300, 1.0e-6, 0, 0))); - } - return &ret; + static EpsBearer::BearerRequirementsMap ret{ + {GBR_CONV_VOICE, std::make_tuple(1, 2, 100, 1.0e-2, 0, 0)}, + {GBR_CONV_VIDEO, std::make_tuple(1, 4, 150, 1.0e-3, 0, 0)}, + {GBR_GAMING, std::make_tuple(1, 3, 50, 1.0e-3, 0, 0)}, + {GBR_NON_CONV_VIDEO, std::make_tuple(1, 5, 300, 1.0e-6, 0, 0)}, + {NGBR_IMS, std::make_tuple(0, 1, 100, 1.0e-6, 0, 0)}, + {NGBR_VIDEO_TCP_OPERATOR, std::make_tuple(0, 6, 300, 1.0e-6, 0, 0)}, + {NGBR_VOICE_VIDEO_GAMING, std::make_tuple(0, 7, 100, 1.0e-3, 0, 0)}, + {NGBR_VIDEO_TCP_PREMIUM, std::make_tuple(0, 8, 300, 1.0e-6, 0, 0)}, + {NGBR_VIDEO_TCP_DEFAULT, std::make_tuple(0, 9, 300, 1.0e-6, 0, 0)}, + }; + return ret; } -EpsBearer::BearerRequirementsMap* +const EpsBearer::BearerRequirementsMap& EpsBearer::GetRequirementsRel15() { // Needed to support GCC 4.9. Otherwise, use list constructors (see GetRequirementsRel10) - static EpsBearer::BearerRequirementsMap ret; + static EpsBearer::BearerRequirementsMap ret{ + {GBR_CONV_VOICE, std::make_tuple(1, 20, 100, 1.0e-2, 0, 2000)}, + {GBR_CONV_VIDEO, std::make_tuple(1, 40, 150, 1.0e-3, 0, 2000)}, + {GBR_GAMING, std::make_tuple(1, 30, 50, 1.0e-3, 0, 2000)}, + {GBR_NON_CONV_VIDEO, std::make_tuple(1, 50, 300, 1.0e-6, 0, 2000)}, + {GBR_MC_PUSH_TO_TALK, std::make_tuple(1, 7, 75, 1.0e-2, 0, 2000)}, + {GBR_NMC_PUSH_TO_TALK, std::make_tuple(1, 20, 100, 1.0e-2, 0, 2000)}, + {GBR_MC_VIDEO, std::make_tuple(1, 15, 100, 1.0e-3, 0, 2000)}, + {GBR_V2X, std::make_tuple(1, 25, 50, 1.0e-2, 0, 2000)}, + {NGBR_IMS, std::make_tuple(0, 10, 100, 1.0e-6, 0, 0)}, + {NGBR_VIDEO_TCP_OPERATOR, std::make_tuple(0, 60, 300, 1.0e-6, 0, 0)}, + {NGBR_VOICE_VIDEO_GAMING, std::make_tuple(0, 70, 100, 1.0e-3, 0, 0)}, + {NGBR_VIDEO_TCP_PREMIUM, std::make_tuple(0, 80, 300, 1.0e-6, 0, 0)}, + {NGBR_VIDEO_TCP_DEFAULT, std::make_tuple(0, 90, 300, 1.0e-6, 0, 0)}, + {NGBR_MC_DELAY_SIGNAL, std::make_tuple(0, 5, 60, 1.0e-6, 0, 0)}, + {NGBR_MC_DATA, std::make_tuple(0, 55, 200, 1.0e-6, 0, 0)}, + {NGBR_V2X, std::make_tuple(0, 65, 5, 1.0e-2, 0, 0)}, + {NGBR_LOW_LAT_EMBB, std::make_tuple(0, 68, 10, 1.0e-6, 0, 0)}, + {DGBR_DISCRETE_AUT_SMALL, std::make_tuple(2, 19, 10, 1.0e-4, 255, 2000)}, + {DGBR_DISCRETE_AUT_LARGE, std::make_tuple(2, 22, 10, 1.0e-4, 1358, 2000)}, + {DGBR_ITS, std::make_tuple(2, 24, 30, 1.0e-5, 1354, 2000)}, + {DGBR_ELECTRICITY, std::make_tuple(2, 21, 5, 1.0e-5, 255, 2000)}, + }; + return ret; +} - if (ret.empty()) - { - ret.insert(std::make_pair(GBR_CONV_VOICE, std::make_tuple(true, 20, 100, 1.0e-2, 0, 2000))); - ret.insert(std::make_pair(GBR_CONV_VIDEO, std::make_tuple(true, 40, 150, 1.0e-3, 0, 2000))); - ret.insert(std::make_pair(GBR_GAMING, std::make_tuple(true, 30, 50, 1.0e-3, 0, 2000))); - ret.insert( - std::make_pair(GBR_NON_CONV_VIDEO, std::make_tuple(true, 50, 300, 1.0e-6, 0, 2000))); - ret.insert( - std::make_pair(GBR_MC_PUSH_TO_TALK, std::make_tuple(true, 7, 75, 1.0e-2, 0, 2000))); - ret.insert( - std::make_pair(GBR_NMC_PUSH_TO_TALK, std::make_tuple(true, 20, 100, 1.0e-2, 0, 2000))); - ret.insert(std::make_pair(GBR_MC_VIDEO, std::make_tuple(true, 15, 100, 1.0e-3, 0, 2000))); - ret.insert(std::make_pair(GBR_V2X, std::make_tuple(true, 25, 50, 1.0e-2, 0, 2000))); - ret.insert(std::make_pair(NGBR_IMS, std::make_tuple(false, 10, 100, 1.0e-6, 0, 0))); - ret.insert( - std::make_pair(NGBR_VIDEO_TCP_OPERATOR, std::make_tuple(false, 60, 300, 1.0e-6, 0, 0))); - ret.insert( - std::make_pair(NGBR_VOICE_VIDEO_GAMING, std::make_tuple(false, 70, 100, 1.0e-3, 0, 0))); - ret.insert( - std::make_pair(NGBR_VIDEO_TCP_PREMIUM, std::make_tuple(false, 80, 300, 1.0e-6, 0, 0))); - ret.insert( - std::make_pair(NGBR_VIDEO_TCP_DEFAULT, std::make_tuple(false, 90, 300, 1.0e-6, 0, 0))); - ret.insert( - std::make_pair(NGBR_MC_DELAY_SIGNAL, std::make_tuple(false, 5, 60, 1.0e-6, 0, 0))); - ret.insert(std::make_pair(NGBR_MC_DATA, std::make_tuple(false, 55, 200, 1.0e-6, 0, 0))); - ret.insert(std::make_pair(NGBR_V2X, std::make_tuple(false, 65, 5, 1.0e-2, 0, 0))); - ret.insert(std::make_pair(NGBR_LOW_LAT_EMBB, std::make_tuple(false, 68, 10, 1.0e-6, 0, 0))); - ret.insert(std::make_pair(DGBR_DISCRETE_AUT_SMALL, - std::make_tuple(false, 19, 10, 1.0e-4, 255, 2000))); - ret.insert(std::make_pair(DGBR_DISCRETE_AUT_LARGE, - std::make_tuple(false, 22, 10, 1.0e-4, 1358, 2000))); - ret.insert(std::make_pair(DGBR_ITS, std::make_tuple(false, 24, 30, 1.0e-5, 1354, 2000))); - ret.insert( - std::make_pair(DGBR_ELECTRICITY, std::make_tuple(false, 21, 5, 1.0e-5, 255, 2000))); - } - return &ret; +const EpsBearer::BearerRequirementsMap& +EpsBearer::GetRequirementsRel18() +{ + // Needed to support GCC 4.9. Otherwise, use list constructors (see GetRequirementsRel10) + static EpsBearer::BearerRequirementsMap ret{ + {GBR_CONV_VOICE, std::make_tuple(1, 20, 100, 1.0e-2, 0, 2000)}, + {GBR_CONV_VIDEO, std::make_tuple(1, 40, 150, 1.0e-3, 0, 2000)}, + {GBR_GAMING, std::make_tuple(1, 30, 50, 1.0e-3, 0, 2000)}, + {GBR_NON_CONV_VIDEO, std::make_tuple(1, 50, 300, 1.0e-6, 0, 2000)}, + {GBR_MC_PUSH_TO_TALK, std::make_tuple(1, 7, 75, 1.0e-2, 0, 2000)}, + {GBR_NMC_PUSH_TO_TALK, std::make_tuple(1, 20, 100, 1.0e-2, 0, 2000)}, + {GBR_MC_VIDEO, std::make_tuple(1, 15, 100, 1.0e-3, 0, 2000)}, + {GBR_V2X, std::make_tuple(1, 25, 50, 1.0e-2, 0, 2000)}, + {NGBR_IMS, std::make_tuple(0, 10, 100, 1.0e-6, 0, 0)}, + {NGBR_VIDEO_TCP_OPERATOR, std::make_tuple(0, 60, 300, 1.0e-6, 0, 0)}, + {NGBR_VOICE_VIDEO_GAMING, std::make_tuple(0, 70, 100, 1.0e-3, 0, 0)}, + {NGBR_VIDEO_TCP_PREMIUM, std::make_tuple(0, 80, 300, 1.0e-6, 0, 0)}, + {NGBR_VIDEO_TCP_DEFAULT, std::make_tuple(0, 90, 300, 1.0e-6, 0, 0)}, + {NGBR_MC_DELAY_SIGNAL, std::make_tuple(0, 5, 60, 1.0e-6, 0, 0)}, + {NGBR_MC_DATA, std::make_tuple(0, 55, 200, 1.0e-6, 0, 0)}, + {NGBR_V2X, std::make_tuple(0, 65, 5, 1.0e-2, 0, 0)}, + {NGBR_LOW_LAT_EMBB, std::make_tuple(0, 68, 10, 1.0e-6, 0, 0)}, + {GBR_LIVE_UL_71, std::make_tuple(1, 56, 150, 1.0e-6, 0, 0)}, + {GBR_LIVE_UL_72, std::make_tuple(1, 56, 300, 1.0e-4, 0, 0)}, + {GBR_LIVE_UL_73, std::make_tuple(1, 56, 300, 1.0e-8, 0, 0)}, + {GBR_LIVE_UL_74, std::make_tuple(1, 56, 500, 1.0e-8, 0, 0)}, + {GBR_LIVE_UL_76, std::make_tuple(1, 56, 500, 1.0e-4, 0, 0)}, + {DGBR_DISCRETE_AUT_SMALL, std::make_tuple(2, 19, 10, 1.0e-4, 255, 2000)}, + {DGBR_DISCRETE_AUT_LARGE, std::make_tuple(2, 22, 10, 1.0e-4, 1358, 2000)}, + {DGBR_ITS, std::make_tuple(2, 24, 30, 1.0e-5, 1354, 2000)}, + {DGBR_ELECTRICITY, std::make_tuple(2, 21, 5, 1.0e-5, 255, 2000)}, + {DGBR_V2X, std::make_tuple(2, 18, 5, 1.0e-4, 1354, 2000)}, + {DGBR_INTER_SERV_87, std::make_tuple(2, 25, 5, 1.0e-3, 500, 2000)}, + {DGBR_INTER_SERV_88, std::make_tuple(2, 25, 10, 1.0e-3, 1125, 2000)}, + {DGBR_VISUAL_CONTENT_89, std::make_tuple(2, 25, 15, 1.0e-4, 17000, 2000)}, + {DGBR_VISUAL_CONTENT_90, std::make_tuple(2, 25, 20, 1.0e-4, 63000, 2000)}, + }; + return ret; } } // namespace ns3 diff --git a/src/lte/model/eps-bearer.h b/src/lte/model/eps-bearer.h index 4639042b4..608c3ac5f 100644 --- a/src/lte/model/eps-bearer.h +++ b/src/lte/model/eps-bearer.h @@ -79,10 +79,10 @@ struct AllocationRetentionPriority * * Please note that from Release 8 (the latest when the LENA project finished) * to Release 11, the bearers ID and requirements are the same. From Release 12, - * they started to change, and the latest version is now Release 15. However, - * we do not support intermediate types: in other words, you can select from - * Release 8 to Release 11, or Release 15. Any other value will result in a - * program crash. + * they started to change, and the latest version is now Release 18. However, + * we do not support intermediate types between releases 11 and 15: in other words, + * you can select from Release 8 to Release 11, or Release 15 or 18. + * Any other value will result in a program crash. * * The release version only affect Bearer definitions. Other part of the LTE * module are not affected when changing the Release attribute. @@ -100,7 +100,7 @@ class EpsBearer : public ObjectBase /** * QoS Class Indicator. See 3GPP 23.203 Section 6.1.7.2 for standard values. - * Updated to Release 15. + * Updated to Release 18. */ enum Qci : uint8_t { @@ -112,6 +112,11 @@ class EpsBearer : public ObjectBase GBR_NMC_PUSH_TO_TALK = 66, ///< GBR Non-Mission-Critical User Plane Push To Talk voice GBR_MC_VIDEO = 67, ///< GBR Mission Critical Video User Plane GBR_V2X = 75, ///< GBR V2X Messages + GBR_LIVE_UL_71 = 71, ///< GBR Live UL streaming + GBR_LIVE_UL_72 = 72, ///< GBR Live UL streaming + GBR_LIVE_UL_73 = 73, ///< GBR Live UL streaming + GBR_LIVE_UL_74 = 74, ///< GBR Live UL streaming + GBR_LIVE_UL_76 = 76, ///< GBR Live UL streaming NGBR_IMS = 5, ///< Non-GBR IMS Signalling NGBR_VIDEO_TCP_OPERATOR = 6, ///< Non-GBR TCP-based Video (Buffered Streaming, e.g., www, e-mail...) @@ -131,7 +136,16 @@ class EpsBearer : public ObjectBase 83, ///< Delay-Critical GBR Discrete Automation Large Packets (TS 22.261) DGBR_ITS = 84, ///< Delay-Critical GBR Intelligent Transport Systems (TS 22.261) DGBR_ELECTRICITY = - 85, ///< Delay-Critical GBR Electricity Distribution High Voltage (TS 22.261) + 85, ///< Delay-Critical GBR Electricity Distribution High Voltage (TS 22.261) + DGBR_V2X = 86, ///< Delay-Critical GBR V2X Messages (TS 23.501) + DGBR_INTER_SERV_87 = + 87, ///< Delay-Critical GBR Interactive Service - Motion tracking data (TS 23.501) + DGBR_INTER_SERV_88 = + 88, ///< Delay-Critical GBR Interactive Service - Motion tracking data (TS 23.501) + DGBR_VISUAL_CONTENT_89 = + 89, ///< Delay-Critical GBR Visual Content for cloud/edge/split rendering (TS 23.501) + DGBR_VISUAL_CONTENT_90 = + 90, ///< Delay-Critical GBR Visual Content for cloud/edge/split rendering (TS 23.501) }; Qci qci; ///< Qos class indicator @@ -198,9 +212,9 @@ class EpsBearer : public ObjectBase /** * - * @return true if the EPS Bearer is a Guaranteed Bit Rate bearer, false otherwise + * @return the resource type (NON-GBR, GBR, DC-GBR) of the selected QCI */ - bool IsGbr() const; + uint8_t GetResourceType() const; /** * @@ -250,20 +264,21 @@ class EpsBearer : public ObjectBase /** * \brief Map between QCI and requirements * - * The tuple is formed by: isGbr, priority, packet delay budget, packet error rate, + * The tuple is formed by: resource type, priority, packet delay budget, packet error rate, * default maximum data burst, default averaging window (0 when does not apply) */ - typedef std:: - unordered_map, QciHash> - BearerRequirementsMap; + typedef std::unordered_map, + QciHash> + BearerRequirementsMap; /** - * \brief Is the selected QCI GBR? + * \brief Get the resource type (NON-GBR, GBR, DC-GBR) of the selected QCI * \param map Map between QCI and requirements * \param qci QCI to look for - * \return GBR flag for the selected CQI + * \return the resource type (NON-GBR, GBR, DC-GBR) of the selected QCI */ - static uint32_t IsGbr(const BearerRequirementsMap& map, Qci qci) + static uint8_t GetResourceType(const BearerRequirementsMap& map, Qci qci) { return std::get<0>(map.at(qci)); } @@ -334,7 +349,7 @@ class EpsBearer : public ObjectBase * * To be revisited when GCC 4.9 will not be supported anymore. */ - static BearerRequirementsMap* GetRequirementsRel11(); + static const BearerRequirementsMap& GetRequirementsRel11(); /** * \brief Retrieve requirements for Rel. 15 @@ -347,16 +362,22 @@ class EpsBearer : public ObjectBase * * To be revisited when GCC 4.9 will not be supported anymore. */ - static BearerRequirementsMap* GetRequirementsRel15(); + static const BearerRequirementsMap& GetRequirementsRel15(); + + /** + * \brief Retrieve requirements for Rel. 18 + * \return the BearerRequirementsMap for Release 18 + */ + static const BearerRequirementsMap& GetRequirementsRel18(); /** * \brief Requirements pointer per bearer * * It will point to a static map. */ - BearerRequirementsMap* m_requirements; + BearerRequirementsMap m_requirements; - uint8_t m_release{30}; //!< Release (10 or 15) + uint8_t m_release{30}; //!< Release (10 or 15 or 18) }; } // namespace ns3 diff --git a/src/lte/model/fdbet-ff-mac-scheduler.cc b/src/lte/model/fdbet-ff-mac-scheduler.cc index 3623eb09a..78de191a5 100644 --- a/src/lte/model/fdbet-ff-mac-scheduler.cc +++ b/src/lte/model/fdbet-ff-mac-scheduler.cc @@ -18,11 +18,13 @@ * Modification: Dizhi Zhou // modify codes related to downlink scheduler */ +#include "fdbet-ff-mac-scheduler.h" + +#include "lte-amc.h" +#include "lte-vendor-specific-parameters.h" + #include -#include #include -#include -#include #include #include #include @@ -140,7 +142,7 @@ FdBetFfMacScheduler::GetLteFfrSapUser() void FdBetFfMacScheduler::DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params) + const FfMacCschedSapProvider::CschedCellConfigReqParameters& params) { NS_LOG_FUNCTION(this); // Read the subset of parameters used @@ -153,7 +155,7 @@ FdBetFfMacScheduler::DoCschedCellConfigReq( void FdBetFfMacScheduler::DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params) + const FfMacCschedSapProvider::CschedUeConfigReqParameters& params) { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); @@ -199,7 +201,7 @@ FdBetFfMacScheduler::DoCschedUeConfigReq( void FdBetFfMacScheduler::DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params) + const FfMacCschedSapProvider::CschedLcConfigReqParameters& params) { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); @@ -228,7 +230,7 @@ FdBetFfMacScheduler::DoCschedLcConfigReq( void FdBetFfMacScheduler::DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) @@ -255,7 +257,7 @@ FdBetFfMacScheduler::DoCschedLcReleaseReq( void FdBetFfMacScheduler::DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) { NS_LOG_FUNCTION(this); @@ -295,7 +297,7 @@ FdBetFfMacScheduler::DoCschedUeReleaseReq( void FdBetFfMacScheduler::DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) { 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) @@ -320,7 +322,7 @@ FdBetFfMacScheduler::DoSchedDlRlcBufferReq( void FdBetFfMacScheduler::DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -328,7 +330,7 @@ FdBetFfMacScheduler::DoSchedDlPagingBufferReq( void FdBetFfMacScheduler::DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -390,14 +392,8 @@ FdBetFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { i = (i + 1) % HARQ_PROC_NUM; } while (((*itStat).second.at(i) != 0) && (i != (*it).second)); - if ((*itStat).second.at(i) == 0) - { - return (true); - } - else - { - return (false); // return a not valid harq proc id - } + + return (*itStat).second.at(i) == 0; } uint8_t @@ -405,7 +401,7 @@ FdBetFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - if (m_harqOn == false) + if (!m_harqOn) { return (0); } @@ -476,7 +472,7 @@ FdBetFfMacScheduler::RefreshHarqProcesses() void FdBetFfMacScheduler::DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); @@ -508,7 +504,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; + std::vector::iterator itRach; for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > @@ -550,7 +546,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.at(i) = (*itRach).m_rnti; } - if (m_harqOn == true) + if (m_harqOn) { // generate UL-DCI for HARQ retransmissions UlDciListElement_s uldci; @@ -615,12 +611,12 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( m_dlInfoListBuffered = params.m_dlInfoList; } } - if (m_harqOn == false) + if (!m_harqOn) { // Ignore HARQ feedback m_dlInfoListBuffered.clear(); } - std::vector dlInfoListUntxed; + 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); @@ -711,7 +707,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( bool free = true; for (std::size_t j = 0; j < dciRbg.size(); j++) { - if (rbgMap.at(dciRbg.at(j)) == true) + if (rbgMap.at(dciRbg.at(j))) { free = false; break; @@ -739,7 +735,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( std::vector rbgMapCopy = rbgMap; while ((j < dciRbg.size()) && (startRbg != rbgId)) { - if (rbgMapCopy.at(rbgId) == false) + if (!rbgMapCopy.at(rbgId)) { rbgMapCopy.at(rbgId) = true; dciRbg.at(j) = rbgId; @@ -810,7 +806,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++) { - std::vector rlcPduListPerLc; + std::vector rlcPduListPerLc; for (std::size_t j = 0; j < nLayers; j++) { if (retx.at(j)) @@ -971,7 +967,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( do { NS_LOG_INFO(this << " ALLOCATION for RBG " << i << " of " << rbgNum); - if (rbgMap.at(i) == false) + if (!rbgMap.at(i)) { // allocate one RBG to current UE std::map>::iterator itMap; @@ -1130,7 +1126,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) || ((*itBufReq).second.m_rlcStatusPduSize > 0))) { - std::vector newRlcPduLe; + std::vector newRlcPduLe; for (uint8_t j = 0; j < nLayer; j++) { RlcPduListElement_s newRlcEl; @@ -1142,7 +1138,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( UpdateDlRlcBufferInfo(newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size); - if (m_harqOn == true) + if (m_harqOn) { // store RLC PDU list for HARQ std::map::iterator itRlcPdu = @@ -1172,7 +1168,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = newDci; - if (m_harqOn == true) + if (m_harqOn) { // store DCI for HARQ std::map::iterator itDci = @@ -1233,7 +1229,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( void FdBetFfMacScheduler::DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1242,7 +1238,7 @@ FdBetFfMacScheduler::DoSchedDlRachInfoReq( void FdBetFfMacScheduler::DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1336,7 +1332,7 @@ FdBetFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) void FdBetFfMacScheduler::DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size()); @@ -1365,7 +1361,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( } } - if (m_harqOn == true) + if (m_harqOn) { // Process UL HARQ feedback for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++) @@ -1405,7 +1401,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; NS_LOG_INFO(this << " BUSY " << j); @@ -1541,7 +1537,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; break; @@ -1656,7 +1652,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( ret.m_dciList.push_back(uldci); // store DCI for HARQ_PERIOD uint8_t harqId = 0; - if (m_harqOn == true) + if (m_harqOn) { std::map::iterator itProcId; itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); @@ -1736,21 +1732,21 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( void FdBetFfMacScheduler::DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) { NS_LOG_FUNCTION(this); } void FdBetFfMacScheduler::DoSchedUlSrInfoReq( - const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) { NS_LOG_FUNCTION(this); } void FdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1793,7 +1789,7 @@ FdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq( void FdBetFfMacScheduler::DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); // retrieve the allocation for this subframe diff --git a/src/lte/model/fdbet-ff-mac-scheduler.h b/src/lte/model/fdbet-ff-mac-scheduler.h index 6319bf87c..7e4c02269 100644 --- a/src/lte/model/fdbet-ff-mac-scheduler.h +++ b/src/lte/model/fdbet-ff-mac-scheduler.h @@ -21,37 +21,21 @@ #ifndef FDBET_FF_MAC_SCHEDULER_H #define FDBET_FF_MAC_SCHEDULER_H -#include -#include -#include -#include -#include -#include +#include "ff-mac-csched-sap.h" +#include "ff-mac-sched-sap.h" +#include "ff-mac-scheduler.h" +#include "lte-amc.h" +#include "lte-common.h" +#include "lte-ffr-sap.h" + #include #include #include -// value for SINR outside the range defined by FF-API, used to indicate that there -// is no CQI for this element -#define NO_SINR -5000 - -#define HARQ_PROC_NUM 8 -#define HARQ_DL_TIMEOUT 11 - namespace ns3 { -typedef std::vector DlHarqProcessesStatus_t; -typedef std::vector DlHarqProcessesTimer_t; -typedef std::vector DlHarqProcessesDciBuffer_t; -typedef std::vector> - RlcPduList_t; // vector of the LCs and layers per UE -typedef std::vector DlHarqRlcPduListBuffer_t; // vector of the 8 HARQ processes per UE - -typedef std::vector UlHarqProcessesDciBuffer_t; -typedef std::vector UlHarqProcessesStatus_t; - /// fdbetsFlowPerf_t structure struct fdbetsFlowPerf_t { @@ -124,36 +108,31 @@ class FdBetFfMacScheduler : public FfMacScheduler * CSched cell config request function * \param params the CSched cell config request parameters */ - void DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params); + void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters& params); /** * Csched UE config request function * \param params the CSched UE config request parameters */ - void DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params); + void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters& params); /** * Csched LC config request function * \param params the CSched LC config request parameters */ - void DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params); + void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters& params); /** * CSched LC release request function * \param params the CSched LC release request parameters */ - void DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); + void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); /** * CSched UE release request function * \param params the CSChed UE release request parameters */ - void DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); + void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); // // Implementation of the SCHED API primitives @@ -164,78 +143,71 @@ class FdBetFfMacScheduler : public FfMacScheduler * Sched DL RLC buffer request function * \param params the Sched DL RLC buffer request parameters */ - void DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); + void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); /** * Sched DL paging buffer request function * \param params the Sched DL paging buffer request parameters */ void DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); /** * Sched DL MAC buffer request function * \param params the Sched DL MAC buffer request parameters */ - void DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); + void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); /** * Sched DL trigger request function * - * \param params struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& + * \param params FfMacSchedSapProvider::SchedDlTriggerReqParameters& */ - void DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); + void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); /** * Sched DL RACH info request function * \param params the Sched DL RACH info request parameters */ - void DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); + void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); /** * Sched DL CGI info request function * \param params the Sched DL CGI info request parameters */ - void DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); + void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); /** * Sched UL trigger request function * \param params the Sched UL trigger request parameters */ - void DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); + void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); /** * Sched UL noise interference request function * \param params the Sched UL noise interference request parameters */ void DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); /** * Sched UL SR info request function * \param params the Schedul UL SR info request parameters */ - void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); + void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); /** * Sched UL MAC control info request function * \param params the Sched UL MAC control info request parameters */ void DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); /** * Sched UL CGI info request function * \param params the Sched UL CGI info request parameters */ - void DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); + void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); /** * Get RBG size function @@ -403,9 +375,9 @@ class FdBetFfMacScheduler : public FfMacScheduler m_ulHarqProcessesDciBuffer; ///< UL HARQ process DCI Buffer // RACH attributes - std::vector m_rachList; ///< rach list - std::vector m_rachAllocationMap; ///< rach allocation map - uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) + std::vector m_rachList; ///< rach list + std::vector m_rachAllocationMap; ///< rach allocation map + uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) }; } // namespace ns3 diff --git a/src/lte/model/fdmt-ff-mac-scheduler.cc b/src/lte/model/fdmt-ff-mac-scheduler.cc index a2896e773..32bebcab0 100644 --- a/src/lte/model/fdmt-ff-mac-scheduler.cc +++ b/src/lte/model/fdmt-ff-mac-scheduler.cc @@ -18,11 +18,13 @@ * Modification: Dizhi Zhou // modify codes related to downlink scheduler */ +#include "fdmt-ff-mac-scheduler.h" + +#include "lte-amc.h" +#include "lte-vendor-specific-parameters.h" + #include -#include #include -#include -#include #include #include #include @@ -139,7 +141,7 @@ FdMtFfMacScheduler::GetLteFfrSapUser() void FdMtFfMacScheduler::DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params) + const FfMacCschedSapProvider::CschedCellConfigReqParameters& params) { NS_LOG_FUNCTION(this); // Read the subset of parameters used @@ -152,7 +154,7 @@ FdMtFfMacScheduler::DoCschedCellConfigReq( void FdMtFfMacScheduler::DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params) + const FfMacCschedSapProvider::CschedUeConfigReqParameters& params) { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); @@ -198,7 +200,7 @@ FdMtFfMacScheduler::DoCschedUeConfigReq( void FdMtFfMacScheduler::DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params) + const FfMacCschedSapProvider::CschedLcConfigReqParameters& params) { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); @@ -217,7 +219,7 @@ FdMtFfMacScheduler::DoCschedLcConfigReq( void FdMtFfMacScheduler::DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) @@ -244,7 +246,7 @@ FdMtFfMacScheduler::DoCschedLcReleaseReq( void FdMtFfMacScheduler::DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) { NS_LOG_FUNCTION(this); @@ -284,7 +286,7 @@ FdMtFfMacScheduler::DoCschedUeReleaseReq( void FdMtFfMacScheduler::DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) { 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) @@ -309,7 +311,7 @@ FdMtFfMacScheduler::DoSchedDlRlcBufferReq( void FdMtFfMacScheduler::DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -317,7 +319,7 @@ FdMtFfMacScheduler::DoSchedDlPagingBufferReq( void FdMtFfMacScheduler::DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -379,14 +381,8 @@ FdMtFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { i = (i + 1) % HARQ_PROC_NUM; } while (((*itStat).second.at(i) != 0) && (i != (*it).second)); - if ((*itStat).second.at(i) == 0) - { - return (true); - } - else - { - return (false); // return a not valid harq proc id - } + + return (*itStat).second.at(i) == 0; } uint8_t @@ -394,7 +390,7 @@ FdMtFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - if (m_harqOn == false) + if (!m_harqOn) { return (0); } @@ -465,7 +461,7 @@ FdMtFfMacScheduler::RefreshHarqProcesses() void FdMtFfMacScheduler::DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); @@ -497,7 +493,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; + std::vector::iterator itRach; for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > @@ -539,7 +535,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.at(i) = (*itRach).m_rnti; } - if (m_harqOn == true) + if (m_harqOn) { // generate UL-DCI for HARQ retransmissions UlDciListElement_s uldci; @@ -604,12 +600,12 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( m_dlInfoListBuffered = params.m_dlInfoList; } } - if (m_harqOn == false) + if (!m_harqOn) { // Ignore HARQ feedback m_dlInfoListBuffered.clear(); } - std::vector dlInfoListUntxed; + 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); @@ -700,7 +696,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( bool free = true; for (std::size_t j = 0; j < dciRbg.size(); j++) { - if (rbgMap.at(dciRbg.at(j)) == true) + if (rbgMap.at(dciRbg.at(j))) { free = false; break; @@ -728,7 +724,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( std::vector rbgMapCopy = rbgMap; while ((j < dciRbg.size()) && (startRbg != rbgId)) { - if (rbgMapCopy.at(rbgId) == false) + if (!rbgMapCopy.at(rbgId)) { rbgMapCopy.at(rbgId) = true; dciRbg.at(j) = rbgId; @@ -799,7 +795,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( } for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++) { - std::vector rlcPduListPerLc; + std::vector rlcPduListPerLc; for (std::size_t j = 0; j < nLayers; j++) { if (retx.at(j)) @@ -887,7 +883,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( for (int i = 0; i < rbgNum; i++) { NS_LOG_INFO(this << " ALLOCATION for RBG " << i << " of " << rbgNum); - if (rbgMap.at(i) == false) + if (!rbgMap.at(i)) { std::set::iterator it; std::set::iterator itMax = m_flowStatsDl.end(); @@ -1117,7 +1113,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) || ((*itBufReq).second.m_rlcStatusPduSize > 0))) { - std::vector newRlcPduLe; + std::vector newRlcPduLe; for (uint8_t j = 0; j < nLayer; j++) { RlcPduListElement_s newRlcEl; @@ -1129,7 +1125,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( UpdateDlRlcBufferInfo(newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size); - if (m_harqOn == true) + if (m_harqOn) { // store RLC PDU list for HARQ std::map::iterator itRlcPdu = @@ -1159,7 +1155,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = newDci; - if (m_harqOn == true) + if (m_harqOn) { // store DCI for HARQ std::map::iterator itDci = @@ -1193,7 +1189,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( void FdMtFfMacScheduler::DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1202,7 +1198,7 @@ FdMtFfMacScheduler::DoSchedDlRachInfoReq( void FdMtFfMacScheduler::DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1296,7 +1292,7 @@ FdMtFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) void FdMtFfMacScheduler::DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size()); @@ -1325,7 +1321,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( } } - if (m_harqOn == true) + if (m_harqOn) { // Process UL HARQ feedback for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++) @@ -1365,7 +1361,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; NS_LOG_INFO(this << " BUSY " << j); @@ -1500,7 +1496,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; break; @@ -1615,7 +1611,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( ret.m_dciList.push_back(uldci); // store DCI for HARQ_PERIOD uint8_t harqId = 0; - if (m_harqOn == true) + if (m_harqOn) { std::map::iterator itProcId; itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); @@ -1670,21 +1666,21 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( void FdMtFfMacScheduler::DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) { NS_LOG_FUNCTION(this); } void FdMtFfMacScheduler::DoSchedUlSrInfoReq( - const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) { NS_LOG_FUNCTION(this); } void FdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1727,7 +1723,7 @@ FdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq( void FdMtFfMacScheduler::DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); // retrieve the allocation for this subframe diff --git a/src/lte/model/fdmt-ff-mac-scheduler.h b/src/lte/model/fdmt-ff-mac-scheduler.h index db4ec4fad..92994cd5f 100644 --- a/src/lte/model/fdmt-ff-mac-scheduler.h +++ b/src/lte/model/fdmt-ff-mac-scheduler.h @@ -21,43 +21,22 @@ #ifndef FDMT_FF_MAC_SCHEDULER_H #define FDMT_FF_MAC_SCHEDULER_H -#include -#include -#include -#include -#include -#include +#include "ff-mac-csched-sap.h" +#include "ff-mac-sched-sap.h" +#include "ff-mac-scheduler.h" +#include "lte-amc.h" +#include "lte-common.h" +#include "lte-ffr-sap.h" + #include #include #include #include -/** - * value for SINR outside the range defined by FF-API, used to indicate that there - * is no CQI for this element - */ -#define NO_SINR -5000 - -/// number of HARQ processes -#define HARQ_PROC_NUM 8 -/// HARQ DL timeout -#define HARQ_DL_TIMEOUT 11 - namespace ns3 { -typedef std::vector DlHarqProcessesStatus_t; -typedef std::vector DlHarqProcessesTimer_t; -typedef std::vector DlHarqProcessesDciBuffer_t; -typedef std::vector> - RlcPduList_t; ///< vector of the LCs and layers per UE -typedef std::vector - DlHarqRlcPduListBuffer_t; ///< vector of the 8 HARQ processes per UE - -typedef std::vector UlHarqProcessesDciBuffer_t; -typedef std::vector UlHarqProcessesStatus_t; - /** * \ingroup ff-api * \brief Implements the SCHED SAP and CSCHED SAP for a Frequency Domain Maximize Throughput @@ -121,36 +100,31 @@ class FdMtFfMacScheduler : public FfMacScheduler * Csched cell config request function * \param params the CSched cell config request parameters */ - void DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params); + void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters& params); /** * CSched UE config request function * \param params the CSChed UE config request parameters */ - void DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params); + void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters& params); /** * CSched LC config request function * \param params the CSChed LC config request parameters */ - void DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params); + void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters& params); /** * CSched LC release request function * \param params the CSched LC release request parameters */ - void DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); + void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); /** * CSched UE release request function * \param params th CSched UE release request parameters */ - void DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); + void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); // // Implementation of the SCHED API primitives @@ -161,78 +135,71 @@ class FdMtFfMacScheduler : public FfMacScheduler * Sched DL RLC buffer request function * \param params the Sched DL RLC buffer request parameters */ - void DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); + void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); /** * Sched DL paging buffer request function - * \param params the Sched DL paging buffer request paarameters + * \param params the Sched DL paging buffer request parameters */ void DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); /** * Sched DL MAC buffer request function * \param params the Sched DL MAC buffer request parameters */ - void DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); + void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); /** * Sched DL trigger request function * - * \param params struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& + * \param params FfMacSchedSapProvider::SchedDlTriggerReqParameters& */ - void DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); + void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); /** * Sched DL RACH info request function * \param params the Sched DL RACH info request parameters */ - void DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); + void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); /** * Sched DL CQI info request function * \param params the Sched DL CQI info request parameters */ - void DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); + void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); /** * Sched UL trigger request function * \param params the Sched UL trigger request parameters */ - void DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); + void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); /** * Sched UL noise interference request function * \param params the Sched UL noise interference request parameters */ void DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); /** * Sched UL SR info request function * \param params the Sched UL SR info request parameters */ - void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); + void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); /** * Sched UL MAC control info request function * \param params the Sched UL MAC control info request parameters */ void DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); /** * Sched UL CQI info request function * \param params the Sched UL CQI info request parameters */ - void DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); + void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); /** * Get RBG size function @@ -397,9 +364,9 @@ class FdMtFfMacScheduler : public FfMacScheduler m_ulHarqProcessesDciBuffer; ///< UL HARQ process DCI buffer // RACH attributes - std::vector m_rachList; ///< RACH list - std::vector m_rachAllocationMap; ///< RACH allocation map - uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) + std::vector m_rachList; ///< RACH list + std::vector m_rachAllocationMap; ///< RACH allocation map + uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) }; } // namespace ns3 diff --git a/src/lte/model/fdtbfq-ff-mac-scheduler.cc b/src/lte/model/fdtbfq-ff-mac-scheduler.cc index 7a47b03ca..96e94698c 100644 --- a/src/lte/model/fdtbfq-ff-mac-scheduler.cc +++ b/src/lte/model/fdtbfq-ff-mac-scheduler.cc @@ -18,12 +18,14 @@ * Modification: Dizhi Zhou // modify codes related to downlink scheduler */ +#include "fdtbfq-ff-mac-scheduler.h" + +#include "lte-amc.h" +#include "lte-vendor-specific-parameters.h" + #include -#include #include #include -#include -#include #include #include #include @@ -165,7 +167,7 @@ FdTbfqFfMacScheduler::GetLteFfrSapUser() void FdTbfqFfMacScheduler::DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params) + const FfMacCschedSapProvider::CschedCellConfigReqParameters& params) { NS_LOG_FUNCTION(this); // Read the subset of parameters used @@ -178,7 +180,7 @@ FdTbfqFfMacScheduler::DoCschedCellConfigReq( void FdTbfqFfMacScheduler::DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params) + const FfMacCschedSapProvider::CschedUeConfigReqParameters& params) { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); @@ -224,7 +226,7 @@ FdTbfqFfMacScheduler::DoCschedUeConfigReq( void FdTbfqFfMacScheduler::DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params) + const FfMacCschedSapProvider::CschedLcConfigReqParameters& params) { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); @@ -282,7 +284,7 @@ FdTbfqFfMacScheduler::DoCschedLcConfigReq( void FdTbfqFfMacScheduler::DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) @@ -309,7 +311,7 @@ FdTbfqFfMacScheduler::DoCschedLcReleaseReq( void FdTbfqFfMacScheduler::DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) { NS_LOG_FUNCTION(this); @@ -349,7 +351,7 @@ FdTbfqFfMacScheduler::DoCschedUeReleaseReq( void FdTbfqFfMacScheduler::DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) { 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) @@ -374,7 +376,7 @@ FdTbfqFfMacScheduler::DoSchedDlRlcBufferReq( void FdTbfqFfMacScheduler::DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -382,7 +384,7 @@ FdTbfqFfMacScheduler::DoSchedDlPagingBufferReq( void FdTbfqFfMacScheduler::DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -444,14 +446,8 @@ FdTbfqFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { i = (i + 1) % HARQ_PROC_NUM; } while (((*itStat).second.at(i) != 0) && (i != (*it).second)); - if ((*itStat).second.at(i) == 0) - { - return (true); - } - else - { - return (false); // return a not valid harq proc id - } + + return (*itStat).second.at(i) == 0; } uint8_t @@ -459,7 +455,7 @@ FdTbfqFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - if (m_harqOn == false) + if (!m_harqOn) { return (0); } @@ -530,7 +526,7 @@ FdTbfqFfMacScheduler::RefreshHarqProcesses() void FdTbfqFfMacScheduler::DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); @@ -553,7 +549,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) { - if ((*it) == true) + if (*it) { rbgAllocatedNum++; } @@ -581,7 +577,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) { - if ((*it) == true) + if (*it) { if (tmpMinBandwidth > maxContinuousUlBandwidth) { @@ -610,7 +606,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; + std::vector::iterator itRach; for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > @@ -652,7 +648,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.at(i) = (*itRach).m_rnti; } - if (m_harqOn == true) + if (m_harqOn) { // generate UL-DCI for HARQ retransmissions UlDciListElement_s uldci; @@ -717,12 +713,12 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( m_dlInfoListBuffered = params.m_dlInfoList; } } - if (m_harqOn == false) + if (!m_harqOn) { // Ignore HARQ feedback m_dlInfoListBuffered.clear(); } - std::vector dlInfoListUntxed; + 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); @@ -813,7 +809,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( bool free = true; for (std::size_t j = 0; j < dciRbg.size(); j++) { - if (rbgMap.at(dciRbg.at(j)) == true) + if (rbgMap.at(dciRbg.at(j))) { free = false; break; @@ -841,7 +837,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( std::vector rbgMapCopy = rbgMap; while ((j < dciRbg.size()) && (startRbg != rbgId)) { - if (rbgMapCopy.at(rbgId) == false) + if (!rbgMapCopy.at(rbgId)) { rbgMapCopy.at(rbgId) = true; dciRbg.at(j) = rbgId; @@ -912,7 +908,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( } for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++) { - std::vector rlcPduListPerLc; + std::vector rlcPduListPerLc; for (std::size_t j = 0; j < nLayers; j++) { if (retx.at(j)) @@ -1092,7 +1088,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( double metric = (((double)(*it).second.counter) / ((double)(*it).second.tokenGenerationRate)); - if (firstRnti == true) + if (firstRnti) { metricMax = metric; itMax = it; @@ -1198,12 +1194,12 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( continue; } - if (rbgMap.at(k) == true) // this RBG is allocated in RACH procedure + if (rbgMap.at(k)) // this RBG is allocated in RACH procedure { continue; } - if ((m_ffrSapProvider->IsDlRbgAvailableForUe(k, (*itMax).first)) == false) + if (!m_ffrSapProvider->IsDlRbgAvailableForUe(k, (*itMax).first)) { continue; } @@ -1516,7 +1512,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) || ((*itBufReq).second.m_rlcStatusPduSize > 0))) { - std::vector newRlcPduLe; + std::vector newRlcPduLe; for (uint8_t j = 0; j < nLayer; j++) { RlcPduListElement_s newRlcEl; @@ -1528,7 +1524,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( UpdateDlRlcBufferInfo(newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size); - if (m_harqOn == true) + if (m_harqOn) { // store RLC PDU list for HARQ std::map::iterator itRlcPdu = @@ -1558,7 +1554,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = newDci; - if (m_harqOn == true) + if (m_harqOn) { // store DCI for HARQ std::map::iterator itDci = @@ -1592,7 +1588,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( void FdTbfqFfMacScheduler::DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1601,7 +1597,7 @@ FdTbfqFfMacScheduler::DoSchedDlRachInfoReq( void FdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); m_ffrSapProvider->ReportDlCqiInfo(params); @@ -1696,7 +1692,7 @@ FdTbfqFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) void FdTbfqFfMacScheduler::DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size()); @@ -1722,7 +1718,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) { - if ((*it) == true) + if (*it) { rbAllocatedNum++; } @@ -1741,7 +1737,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( } } - if (m_harqOn == true) + if (m_harqOn) { // Process UL HARQ feedback for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++) @@ -1781,7 +1777,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; NS_LOG_INFO(this << " BUSY " << j); @@ -1922,12 +1918,12 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; break; } - if ((m_ffrSapProvider->IsUlRbgAvailableForUe(j, (*it).first)) == false) + if (!m_ffrSapProvider->IsUlRbgAvailableForUe(j, (*it).first)) { free = false; break; @@ -2044,7 +2040,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( ret.m_dciList.push_back(uldci); // store DCI for HARQ_PERIOD uint8_t harqId = 0; - if (m_harqOn == true) + if (m_harqOn) { std::map::iterator itProcId; itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); @@ -2099,21 +2095,21 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( void FdTbfqFfMacScheduler::DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) { NS_LOG_FUNCTION(this); } void FdTbfqFfMacScheduler::DoSchedUlSrInfoReq( - const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) { NS_LOG_FUNCTION(this); } void FdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -2156,7 +2152,7 @@ FdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq( void FdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); // retrieve the allocation for this subframe diff --git a/src/lte/model/fdtbfq-ff-mac-scheduler.h b/src/lte/model/fdtbfq-ff-mac-scheduler.h index 8b6f91756..b956aa7a6 100644 --- a/src/lte/model/fdtbfq-ff-mac-scheduler.h +++ b/src/lte/model/fdtbfq-ff-mac-scheduler.h @@ -21,42 +21,21 @@ #ifndef FDTBFQ_FF_MAC_SCHEDULER_H #define FDTBFQ_FF_MAC_SCHEDULER_H -#include -#include -#include -#include -#include -#include +#include "ff-mac-csched-sap.h" +#include "ff-mac-sched-sap.h" +#include "ff-mac-scheduler.h" +#include "lte-amc.h" +#include "lte-common.h" +#include "lte-ffr-sap.h" + #include #include #include -/** - * value for SINR outside the range defined by FF-API, used to indicate that there - * is no CQI for this element - */ -#define NO_SINR -5000 - -/// HARQ number of processes -#define HARQ_PROC_NUM 8 -/// HARQ DL timeout -#define HARQ_DL_TIMEOUT 11 - namespace ns3 { -typedef std::vector DlHarqProcessesStatus_t; -typedef std::vector DlHarqProcessesTimer_t; -typedef std::vector DlHarqProcessesDciBuffer_t; -typedef std::vector> - RlcPduList_t; ///< vector of the LCs and layers per UE -typedef std::vector - DlHarqRlcPduListBuffer_t; ///< vector of the 8 HARQ processes per UE - -typedef std::vector UlHarqProcessesDciBuffer_t; -typedef std::vector UlHarqProcessesStatus_t; - /** * Flow information */ @@ -162,36 +141,31 @@ class FdTbfqFfMacScheduler : public FfMacScheduler * Csched cell config request function * \param params the CSched cell config request parameters */ - void DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params); + void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters& params); /** * CSched UE config request function * \param params CSChed UE config request parameters */ - void DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params); + void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters& params); /** * CSched LC config request function * \param params the CSched LC config request parameters */ - void DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params); + void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters& params); /** * CSched LC release request function - * \param params the CSChed LC releease request parameters + * \param params the CSChed LC release request parameters */ - void DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); + void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); /** * CSched UE release request function * \param params the CSched UE release request parameters */ - void DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); + void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); // // Implementation of the SCHED API primitives @@ -202,78 +176,71 @@ class FdTbfqFfMacScheduler : public FfMacScheduler * Sched DL RLC buffer request function * \param params the Sched DL RLC buffer request parameters */ - void DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); + void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); /** * Sched DL paging buffer request function * \param params the Sched DL paging buffer request parameters */ void DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); /** * Sched DL MAC buffer request function * \param params Sched DL MAC buffer request parameters */ - void DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); + void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); /** * Sched DL trigger request function * - * \param params struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& + * \param params FfMacSchedSapProvider::SchedDlTriggerReqParameters& */ - void DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); + void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); /** * Sched DL RACH info request function * \param params the Sched DL RACH info request parameters */ - void DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); + void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); /** * Sched DL CQI info request function * \param params the Sched DL CQI info request parameters */ - void DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); + void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); /** * Sched UL trigger request function * \param params the Sched UL trigger request parameters */ - void DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); + void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); /** * Sched UL noise interference request function * \param params the Sched UL noise interference request parameters */ void DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); /** * Sched UL SR info request function * \param params the Sched UL SR info request parameters */ - void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); + void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); /** * Sched UL MAC control info request function * \param params the Sched UL MAC control info request parameters */ void DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); /** * Sched UL CQI info request function * \param params the Sched UL CQI info request parameters */ - void DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); + void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); /** * Get RBG size function @@ -449,9 +416,9 @@ class FdTbfqFfMacScheduler : public FfMacScheduler m_ulHarqProcessesDciBuffer; ///< UL HARQ process DCI buffer // RACH attributes - std::vector m_rachList; ///< RACH list - std::vector m_rachAllocationMap; ///< RACH allocation map - uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) + std::vector m_rachList; ///< RACH list + std::vector m_rachAllocationMap; ///< RACH allocation map + uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) }; } // namespace ns3 diff --git a/src/lte/model/ff-mac-common.cc b/src/lte/model/ff-mac-common.cc index d2586c9dc..0cd3c5711 100644 --- a/src/lte/model/ff-mac-common.cc +++ b/src/lte/model/ff-mac-common.cc @@ -17,7 +17,7 @@ * Author: Marco Miozzo */ -#include +#include "ff-mac-common.h" namespace ns3 { diff --git a/src/lte/model/ff-mac-common.h b/src/lte/model/ff-mac-common.h index e333bf60e..66c54e33e 100644 --- a/src/lte/model/ff-mac-common.h +++ b/src/lte/model/ff-mac-common.h @@ -215,6 +215,7 @@ struct LogicalChannelConfigListElement_s { QBT_NON_GBR, QBT_GBR, + QBT_DGBR, NotValid_QosBearerType } m_qosBearerType{NotValid_QosBearerType}; ///< the QOS bearer type @@ -262,14 +263,14 @@ struct RlcPduListElement_s }; /** - * \brief See section 4.3.8 builDataListElement + * \brief See section 4.3.8 buildDataListElement * \struct BuildDataListElement_s */ struct BuildDataListElement_s { uint16_t m_rnti{UINT16_MAX}; ///< RNTI struct DlDciListElement_s m_dci; ///< DCI - std::vector m_ceBitmap; ///< CE bitmap + std::vector m_ceBitmap; ///< CE bitmap std::vector> m_rlcPduList; ///< RLC PDU list }; @@ -474,7 +475,8 @@ struct DlInfoListElement_s NACK, DTX }; - std::vector m_harqStatus; ///< HARQ status + + std::vector m_harqStatus; ///< HARQ status }; /** diff --git a/src/lte/model/ff-mac-csched-sap.h b/src/lte/model/ff-mac-csched-sap.h index 44e393126..6a7b7f9e9 100644 --- a/src/lte/model/ff-mac-csched-sap.h +++ b/src/lte/model/ff-mac-csched-sap.h @@ -77,17 +77,17 @@ class FfMacCschedSapProvider PHICH_R_TWO } m_phichResource; ///< PHICH resource - enum NormalExtended_e m_phichDuration; ///< PHICH duration + NormalExtended_e m_phichDuration; ///< PHICH duration uint8_t m_initialNrOfPdcchOfdmSymbols; ///< initial number of PDCCH OFDM symbols - struct SiConfiguration_s m_siConfiguration; ///< SI configuration + SiConfiguration_s m_siConfiguration; ///< SI configuration uint16_t m_ulBandwidth; ///< UL bandwidth uint16_t m_dlBandwidth; ///< DL bandwidth - enum NormalExtended_e m_ulCyclicPrefixLength; ///< UL cyclic prefix length - enum NormalExtended_e m_dlCyclicPrefixLength; ///< DL cyclic prefix length + NormalExtended_e m_ulCyclicPrefixLength; ///< UL cyclic prefix length + NormalExtended_e m_dlCyclicPrefixLength; ///< DL cyclic prefix length uint8_t m_antennaPortsCount; ///< antenna port count @@ -125,8 +125,7 @@ class FfMacCschedSapProvider MOD_64QAM } m_enable64Qam; ///< enable64Qam - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -136,11 +135,11 @@ class FfMacCschedSapProvider /// CschedUeConfigReqParameters structure struct CschedUeConfigReqParameters { - uint16_t m_rnti; ///< RNTI - bool m_reconfigureFlag; ///< reconfigure flag - bool m_drxConfigPresent; ///< drx config present - struct DrxConfig_s m_drxConfig; ///< drx config - uint16_t m_timeAlignmentTimer; ///< time alignment timer + uint16_t m_rnti; ///< RNTI + bool m_reconfigureFlag; ///< reconfigure flag + bool m_drxConfigPresent; ///< drx config present + DrxConfig_s m_drxConfig; ///< drx config + uint16_t m_timeAlignmentTimer; ///< time alignment timer /// MeasGapConfigPattern_e enumeration enum MeasGapConfigPattern_e @@ -150,17 +149,17 @@ class FfMacCschedSapProvider OFF } m_measGapConfigPattern; ///< measGapConfigPattern - uint8_t m_measGapConfigSubframeOffset; ///< measure gap config subframe offset - bool m_spsConfigPresent; ///< SPS config present - struct SpsConfig_s m_spsConfig; ///< SPS config - bool m_srConfigPresent; ///< SR config present - struct SrConfig_s m_srConfig; ///< SR config - bool m_cqiConfigPresent; ///< CQI config present - struct CqiConfig_s m_cqiConfig; ///< CQI config - uint8_t m_transmissionMode; ///< transmission mode - uint64_t m_ueAggregatedMaximumBitrateUl; ///< UE aggregate maximum bit rate UL - uint64_t m_ueAggregatedMaximumBitrateDl; ///< UE aggregate maximum bit rate DL - struct UeCapabilities_s m_ueCapabilities; ///< UE capabilities + uint8_t m_measGapConfigSubframeOffset; ///< measure gap config subframe offset + bool m_spsConfigPresent; ///< SPS config present + SpsConfig_s m_spsConfig; ///< SPS config + bool m_srConfigPresent; ///< SR config present + SrConfig_s m_srConfig; ///< SR config + bool m_cqiConfigPresent; ///< CQI config present + CqiConfig_s m_cqiConfig; ///< CQI config + uint8_t m_transmissionMode; ///< transmission mode + uint64_t m_ueAggregatedMaximumBitrateUl; ///< UE aggregate maximum bit rate UL + uint64_t m_ueAggregatedMaximumBitrateDl; ///< UE aggregate maximum bit rate DL + UeCapabilities_s m_ueCapabilities; ///< UE capabilities /// OpenClosedLoop_e enum OpenClosedLoop_e @@ -198,8 +197,7 @@ class FfMacCschedSapProvider uint8_t m_ackNackRepetitionFactor; ///< ackNackRepetitionFactor - std::vector - m_vendorSpecificList; ///< vendorSpecificList + std::vector m_vendorSpecificList; ///< vendorSpecificList }; /** @@ -211,11 +209,10 @@ class FfMacCschedSapProvider uint16_t m_rnti; ///< RNTI bool m_reconfigureFlag; ///< reconfigure flag - std::vector + std::vector m_logicalChannelConfigList; ///< logicalChannelConfigList - std::vector - m_vendorSpecificList; ///< vendorSpecificList + std::vector m_vendorSpecificList; ///< vendorSpecificList }; /** @@ -228,8 +225,7 @@ class FfMacCschedSapProvider std::vector m_logicalChannelIdentity; ///< logical channel identity - std::vector - m_vendorSpecificList; ///< vendorSpecificList + std::vector m_vendorSpecificList; ///< vendorSpecificList }; /** @@ -240,8 +236,7 @@ class FfMacCschedSapProvider { uint16_t m_rnti; ///< RNTI - std::vector - m_vendorSpecificList; ///< vendorSpecificList + std::vector m_vendorSpecificList; ///< vendorSpecificList }; // @@ -254,35 +249,35 @@ class FfMacCschedSapProvider * * \param params CschedCellConfigReqParameters */ - virtual void CschedCellConfigReq(const struct CschedCellConfigReqParameters& params) = 0; + virtual void CschedCellConfigReq(const CschedCellConfigReqParameters& params) = 0; /** * \brief CSCHED_UE_CONFIG_REQ * * \param params CschedUeConfigReqParameters */ - virtual void CschedUeConfigReq(const struct CschedUeConfigReqParameters& params) = 0; + virtual void CschedUeConfigReq(const CschedUeConfigReqParameters& params) = 0; /** * \brief CSCHED_LC_CONFIG_REQ * * \param params CschedLcConfigReqParameters */ - virtual void CschedLcConfigReq(const struct CschedLcConfigReqParameters& params) = 0; + virtual void CschedLcConfigReq(const CschedLcConfigReqParameters& params) = 0; /** * \brief CSCHED_LC_RELEASE_REQ * * \param params CschedLcReleaseReqParameters */ - virtual void CschedLcReleaseReq(const struct CschedLcReleaseReqParameters& params) = 0; + virtual void CschedLcReleaseReq(const CschedLcReleaseReqParameters& params) = 0; /** * \brief CSCHED_UE_RELEASE_REQ * * \param params CschedUeReleaseReqParameters */ - virtual void CschedUeReleaseReq(const struct CschedUeReleaseReqParameters& params) = 0; + virtual void CschedUeReleaseReq(const CschedUeReleaseReqParameters& params) = 0; private: }; @@ -305,10 +300,9 @@ class FfMacCschedSapUser */ struct CschedCellConfigCnfParameters { - enum Result_e m_result; ///< result + Result_e m_result; ///< result - std::vector - m_vendorSpecificList; ///< vendorSpecificList + std::vector m_vendorSpecificList; ///< vendorSpecificList }; /** @@ -317,11 +311,10 @@ class FfMacCschedSapUser */ struct CschedUeConfigCnfParameters { - uint16_t m_rnti; ///< RNTI - enum Result_e m_result; ///< result + uint16_t m_rnti; ///< RNTI + Result_e m_result; ///< result - std::vector - m_vendorSpecificList; ///< vendorSpecificList + std::vector m_vendorSpecificList; ///< vendorSpecificList }; /** @@ -330,13 +323,12 @@ class FfMacCschedSapUser */ struct CschedLcConfigCnfParameters { - uint16_t m_rnti; ///< RNTI - enum Result_e m_result; ///< result + uint16_t m_rnti; ///< RNTI + Result_e m_result; ///< result std::vector m_logicalChannelIdentity; ///< logical channel identity - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -345,13 +337,12 @@ class FfMacCschedSapUser */ struct CschedLcReleaseCnfParameters { - uint16_t m_rnti; ///< RNTI - enum Result_e m_result; ///< result + uint16_t m_rnti; ///< RNTI + Result_e m_result; ///< result std::vector m_logicalChannelIdentity; ///< logical channel identity - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -360,11 +351,10 @@ class FfMacCschedSapUser */ struct CschedUeReleaseCnfParameters { - uint16_t m_rnti; ///< RNTI - enum Result_e m_result; ///< result + uint16_t m_rnti; ///< RNTI + Result_e m_result; ///< result - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -373,17 +363,16 @@ class FfMacCschedSapUser */ struct CschedUeConfigUpdateIndParameters { - uint16_t m_rnti; ///< RNTI - uint8_t m_transmissionMode; ///< transmission mode - bool m_spsConfigPresent; ///< SPS config present - struct SpsConfig_s m_spsConfig; ///< SPS config - bool m_srConfigPresent; ///< SR config present - struct SrConfig_s m_srConfig; ///< SR config - bool m_cqiConfigPresent; ///< CQI config present - struct CqiConfig_s m_cqiConfig; ///< CQI config + uint16_t m_rnti; ///< RNTI + uint8_t m_transmissionMode; ///< transmission mode + bool m_spsConfigPresent; ///< SPS config present + SpsConfig_s m_spsConfig; ///< SPS config + bool m_srConfigPresent; ///< SR config present + SrConfig_s m_srConfig; ///< SR config + bool m_cqiConfigPresent; ///< CQI config present + CqiConfig_s m_cqiConfig; ///< CQI config - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -395,8 +384,7 @@ class FfMacCschedSapUser uint8_t m_prbUtilizationDl; ///< DL utilization uint8_t m_prbUtilizationUl; ///< UL utilization - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; // @@ -409,51 +397,49 @@ class FfMacCschedSapUser * * \param params CschedCellConfigCnfParameters */ - virtual void CschedCellConfigCnf(const struct CschedCellConfigCnfParameters& params) = 0; + virtual void CschedCellConfigCnf(const CschedCellConfigCnfParameters& params) = 0; /** * \brief CSCHED_UE_CONFIG_CNF * * \param params CschedUeConfigCnfParameters */ - virtual void CschedUeConfigCnf(const struct CschedUeConfigCnfParameters& params) = 0; + virtual void CschedUeConfigCnf(const CschedUeConfigCnfParameters& params) = 0; /** * \brief CSCHED_LC_CONFIG_CNF * * \param params CschedLcConfigCnfParameters */ - virtual void CschedLcConfigCnf(const struct CschedLcConfigCnfParameters& params) = 0; + virtual void CschedLcConfigCnf(const CschedLcConfigCnfParameters& params) = 0; /** * \brief CSCHED_LC_RELEASE_CNF * * \param params CschedLcReleaseCnfParameters */ - virtual void CschedLcReleaseCnf(const struct CschedLcReleaseCnfParameters& params) = 0; + virtual void CschedLcReleaseCnf(const CschedLcReleaseCnfParameters& params) = 0; /** * \brief CSCHED_UE_RELEASE_CNF * * \param params CschedUeReleaseCnfParameters */ - virtual void CschedUeReleaseCnf(const struct CschedUeReleaseCnfParameters& params) = 0; + virtual void CschedUeReleaseCnf(const CschedUeReleaseCnfParameters& params) = 0; /** * \brief CSCHED_UE_UPDATE_IND * * \param params CschedUeConfigUpdateIndParameters */ - virtual void CschedUeConfigUpdateInd( - const struct CschedUeConfigUpdateIndParameters& params) = 0; + virtual void CschedUeConfigUpdateInd(const CschedUeConfigUpdateIndParameters& params) = 0; /** * \brief CSCHED_UE_CONFIG_IND * * \param params CschedCellConfigUpdateIndParameters */ - virtual void CschedCellConfigUpdateInd( - const struct CschedCellConfigUpdateIndParameters& params) = 0; + virtual void CschedCellConfigUpdateInd(const CschedCellConfigUpdateIndParameters& params) = 0; private: }; @@ -474,11 +460,11 @@ class MemberCschedSapProvider : public FfMacCschedSapProvider MemberCschedSapProvider() = delete; // inherited from FfMacCschedSapProvider - void CschedCellConfigReq(const struct CschedCellConfigReqParameters& params) override; - void CschedUeConfigReq(const struct CschedUeConfigReqParameters& params) override; - void CschedLcConfigReq(const struct CschedLcConfigReqParameters& params) override; - void CschedLcReleaseReq(const struct CschedLcReleaseReqParameters& params) override; - void CschedUeReleaseReq(const struct CschedUeReleaseReqParameters& params) override; + void CschedCellConfigReq(const CschedCellConfigReqParameters& params) override; + void CschedUeConfigReq(const CschedUeConfigReqParameters& params) override; + void CschedLcConfigReq(const CschedLcConfigReqParameters& params) override; + void CschedLcReleaseReq(const CschedLcReleaseReqParameters& params) override; + void CschedUeReleaseReq(const CschedUeReleaseReqParameters& params) override; private: C* m_scheduler; ///< scheduler class @@ -492,35 +478,35 @@ MemberCschedSapProvider::MemberCschedSapProvider(C* scheduler) template void -MemberCschedSapProvider::CschedCellConfigReq(const struct CschedCellConfigReqParameters& params) +MemberCschedSapProvider::CschedCellConfigReq(const CschedCellConfigReqParameters& params) { m_scheduler->DoCschedCellConfigReq(params); } template void -MemberCschedSapProvider::CschedUeConfigReq(const struct CschedUeConfigReqParameters& params) +MemberCschedSapProvider::CschedUeConfigReq(const CschedUeConfigReqParameters& params) { m_scheduler->DoCschedUeConfigReq(params); } template void -MemberCschedSapProvider::CschedLcConfigReq(const struct CschedLcConfigReqParameters& params) +MemberCschedSapProvider::CschedLcConfigReq(const CschedLcConfigReqParameters& params) { m_scheduler->DoCschedLcConfigReq(params); } template void -MemberCschedSapProvider::CschedLcReleaseReq(const struct CschedLcReleaseReqParameters& params) +MemberCschedSapProvider::CschedLcReleaseReq(const CschedLcReleaseReqParameters& params) { m_scheduler->DoCschedLcReleaseReq(params); } template void -MemberCschedSapProvider::CschedUeReleaseReq(const struct CschedUeReleaseReqParameters& params) +MemberCschedSapProvider::CschedUeReleaseReq(const CschedUeReleaseReqParameters& params) { m_scheduler->DoCschedUeReleaseReq(params); } diff --git a/src/lte/model/ff-mac-sched-sap.h b/src/lte/model/ff-mac-sched-sap.h index 9e6f6a87a..18fa724ac 100644 --- a/src/lte/model/ff-mac-sched-sap.h +++ b/src/lte/model/ff-mac-sched-sap.h @@ -65,8 +65,7 @@ class FfMacSchedSapProvider uint16_t m_rlcRetransmissionHolDelay; ///< RLC retransmission HOL delay uint16_t m_rlcStatusPduSize; ///< RLC status PDU size - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -75,11 +74,10 @@ class FfMacSchedSapProvider */ struct SchedDlPagingBufferReqParameters { - uint16_t m_rnti; ///< RNTI - std::vector m_pagingInfoList; ///< paging info list + uint16_t m_rnti; ///< RNTI + std::vector m_pagingInfoList; ///< paging info list - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -88,11 +86,10 @@ class FfMacSchedSapProvider */ struct SchedDlMacBufferReqParameters { - uint16_t m_rnti; ///< RNTI - enum CeBitmap_e m_ceBitmap; ///< CE bitmap + uint16_t m_rnti; ///< RNTI + CeBitmap_e m_ceBitmap; ///< CE bitmap - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -101,11 +98,10 @@ class FfMacSchedSapProvider */ struct SchedDlTriggerReqParameters { - uint16_t m_sfnSf; ///< sfn SF - std::vector m_dlInfoList; ///< DL info list + uint16_t m_sfnSf; ///< sfn SF + std::vector m_dlInfoList; ///< DL info list - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -114,11 +110,10 @@ class FfMacSchedSapProvider */ struct SchedDlRachInfoReqParameters { - uint16_t m_sfnSf; ///< sfn SF - std::vector m_rachList; ///< RACH list + uint16_t m_sfnSf; ///< sfn SF + std::vector m_rachList; ///< RACH list - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -127,11 +122,10 @@ class FfMacSchedSapProvider */ struct SchedDlCqiInfoReqParameters { - uint16_t m_sfnSf; ///< sfn SF - std::vector m_cqiList; ///< CQI list + uint16_t m_sfnSf; ///< sfn SF + std::vector m_cqiList; ///< CQI list - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -140,11 +134,10 @@ class FfMacSchedSapProvider */ struct SchedUlTriggerReqParameters { - uint16_t m_sfnSf; ///< sfn SF - std::vector m_ulInfoList; ///< UL info list + uint16_t m_sfnSf; ///< sfn SF + std::vector m_ulInfoList; ///< UL info list - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -157,8 +150,7 @@ class FfMacSchedSapProvider uint16_t m_rip; ///< RIP uint16_t m_tnp; ///< TNP - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -167,11 +159,10 @@ class FfMacSchedSapProvider */ struct SchedUlSrInfoReqParameters { - uint16_t m_sfnSf; ///< sfn SF - std::vector m_srList; ///< SR list + uint16_t m_sfnSf; ///< sfn SF + std::vector m_srList; ///< SR list - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -180,11 +171,10 @@ class FfMacSchedSapProvider */ struct SchedUlMacCtrlInfoReqParameters { - uint16_t m_sfnSf; ///< sfn SF - std::vector m_macCeList; ///< MAC CE list + uint16_t m_sfnSf; ///< sfn SF + std::vector m_macCeList; ///< MAC CE list - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -193,11 +183,10 @@ class FfMacSchedSapProvider */ struct SchedUlCqiInfoReqParameters { - uint16_t m_sfnSf; ///< sfn SF - struct UlCqi_s m_ulCqi; ///< UL CQI + uint16_t m_sfnSf; ///< sfn SF + UlCqi_s m_ulCqi; ///< UL CQI - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; // @@ -210,49 +199,49 @@ class FfMacSchedSapProvider * * \param params SchedDlRlcBufferReqParameters */ - virtual void SchedDlRlcBufferReq(const struct SchedDlRlcBufferReqParameters& params) = 0; + virtual void SchedDlRlcBufferReq(const SchedDlRlcBufferReqParameters& params) = 0; /** * \brief SCHED_DL_PAGING_BUFFER_REQ * * \param params SchedDlPagingBufferReqParameters */ - virtual void SchedDlPagingBufferReq(const struct SchedDlPagingBufferReqParameters& params) = 0; + virtual void SchedDlPagingBufferReq(const SchedDlPagingBufferReqParameters& params) = 0; /** * \brief SCHED_DL_MAC_BUFFER_REQ * * \param params SchedDlMacBufferReqParameters */ - virtual void SchedDlMacBufferReq(const struct SchedDlMacBufferReqParameters& params) = 0; + virtual void SchedDlMacBufferReq(const SchedDlMacBufferReqParameters& params) = 0; /** * \brief SCHED_DL_TRIGGER_REQ * * \param params SchedDlTriggerReqParameters */ - virtual void SchedDlTriggerReq(const struct SchedDlTriggerReqParameters& params) = 0; + virtual void SchedDlTriggerReq(const SchedDlTriggerReqParameters& params) = 0; /** * \brief SCHED_DL_RACH_INFO_REQ * * \param params SchedDlRachInfoReqParameters */ - virtual void SchedDlRachInfoReq(const struct SchedDlRachInfoReqParameters& params) = 0; + virtual void SchedDlRachInfoReq(const SchedDlRachInfoReqParameters& params) = 0; /** * \brief SCHED_DL_CQI_INFO_REQ * * \param params SchedDlCqiInfoReqParameters */ - virtual void SchedDlCqiInfoReq(const struct SchedDlCqiInfoReqParameters& params) = 0; + virtual void SchedDlCqiInfoReq(const SchedDlCqiInfoReqParameters& params) = 0; /** * \brief SCHED_UL_TRIGGER_REQ * * \param params SchedUlTriggerReqParameters */ - virtual void SchedUlTriggerReq(const struct SchedUlTriggerReqParameters& params) = 0; + virtual void SchedUlTriggerReq(const SchedUlTriggerReqParameters& params) = 0; /** * \brief SCHED_UL_NOISE_INTERFERENCE_REQ @@ -260,28 +249,28 @@ class FfMacSchedSapProvider * \param params SchedUlNoiseInterferenceReqParameters */ virtual void SchedUlNoiseInterferenceReq( - const struct SchedUlNoiseInterferenceReqParameters& params) = 0; + const SchedUlNoiseInterferenceReqParameters& params) = 0; /** * \brief SCHED_UL_SR_INFO_REQ * * \param params SchedUlSrInfoReqParameters */ - virtual void SchedUlSrInfoReq(const struct SchedUlSrInfoReqParameters& params) = 0; + virtual void SchedUlSrInfoReq(const SchedUlSrInfoReqParameters& params) = 0; /** * \brief SCHED_UL_MAC_CTRL_INFO_REQ * * \param params SchedUlMacCtrlInfoReqParameters */ - virtual void SchedUlMacCtrlInfoReq(const struct SchedUlMacCtrlInfoReqParameters& params) = 0; + virtual void SchedUlMacCtrlInfoReq(const SchedUlMacCtrlInfoReqParameters& params) = 0; /** * \brief SCHED_UL_CQI_INFO_REQ * * \param params SchedUlCqiInfoReqParameters */ - virtual void SchedUlCqiInfoReq(const struct SchedUlCqiInfoReqParameters& params) = 0; + virtual void SchedUlCqiInfoReq(const SchedUlCqiInfoReqParameters& params) = 0; private: }; @@ -302,15 +291,13 @@ class FfMacSchedSapUser */ struct SchedDlConfigIndParameters { - std::vector m_buildDataList; ///< build data list - std::vector m_buildRarList; ///< build rar list - std::vector - m_buildBroadcastList; ///< build broadcast list + std::vector m_buildDataList; ///< build data list + std::vector m_buildRarList; ///< build rar list + std::vector m_buildBroadcastList; ///< build broadcast list uint8_t m_nrOfPdcchOfdmSymbols; ///< number of PDCCH OFDM symbols - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; /** @@ -319,11 +306,10 @@ class FfMacSchedSapUser */ struct SchedUlConfigIndParameters { - std::vector m_dciList; ///< DCI list - std::vector m_phichList; ///< PHICH list + std::vector m_dciList; ///< DCI list + std::vector m_phichList; ///< PHICH list - std::vector - m_vendorSpecificList; ///< vendor specific list + std::vector m_vendorSpecificList; ///< vendor specific list }; // @@ -336,14 +322,14 @@ class FfMacSchedSapUser * * \param params SchedDlConfigIndParameters */ - virtual void SchedDlConfigInd(const struct SchedDlConfigIndParameters& params) = 0; + virtual void SchedDlConfigInd(const SchedDlConfigIndParameters& params) = 0; /** * \brief SCHED_UL_CONFIG_IND * * \param params SchedUlConfigIndParameters */ - virtual void SchedUlConfigInd(const struct SchedUlConfigIndParameters& params) = 0; + virtual void SchedUlConfigInd(const SchedUlConfigIndParameters& params) = 0; private: }; @@ -364,18 +350,17 @@ class MemberSchedSapProvider : public FfMacSchedSapProvider MemberSchedSapProvider() = delete; // inherited from FfMacSchedSapProvider - void SchedDlRlcBufferReq(const struct SchedDlRlcBufferReqParameters& params) override; - void SchedDlPagingBufferReq(const struct SchedDlPagingBufferReqParameters& params) override; - void SchedDlMacBufferReq(const struct SchedDlMacBufferReqParameters& params) override; - void SchedDlTriggerReq(const struct SchedDlTriggerReqParameters& params) override; - void SchedDlRachInfoReq(const struct SchedDlRachInfoReqParameters& params) override; - void SchedDlCqiInfoReq(const struct SchedDlCqiInfoReqParameters& params) override; - void SchedUlTriggerReq(const struct SchedUlTriggerReqParameters& params) override; - void SchedUlNoiseInterferenceReq( - const struct SchedUlNoiseInterferenceReqParameters& params) override; - void SchedUlSrInfoReq(const struct SchedUlSrInfoReqParameters& params) override; - void SchedUlMacCtrlInfoReq(const struct SchedUlMacCtrlInfoReqParameters& params) override; - void SchedUlCqiInfoReq(const struct SchedUlCqiInfoReqParameters& params) override; + void SchedDlRlcBufferReq(const SchedDlRlcBufferReqParameters& params) override; + void SchedDlPagingBufferReq(const SchedDlPagingBufferReqParameters& params) override; + void SchedDlMacBufferReq(const SchedDlMacBufferReqParameters& params) override; + void SchedDlTriggerReq(const SchedDlTriggerReqParameters& params) override; + void SchedDlRachInfoReq(const SchedDlRachInfoReqParameters& params) override; + void SchedDlCqiInfoReq(const SchedDlCqiInfoReqParameters& params) override; + void SchedUlTriggerReq(const SchedUlTriggerReqParameters& params) override; + void SchedUlNoiseInterferenceReq(const SchedUlNoiseInterferenceReqParameters& params) override; + void SchedUlSrInfoReq(const SchedUlSrInfoReqParameters& params) override; + void SchedUlMacCtrlInfoReq(const SchedUlMacCtrlInfoReqParameters& params) override; + void SchedUlCqiInfoReq(const SchedUlCqiInfoReqParameters& params) override; private: C* m_scheduler; ///< the scheduler class @@ -389,50 +374,49 @@ MemberSchedSapProvider::MemberSchedSapProvider(C* scheduler) template void -MemberSchedSapProvider::SchedDlRlcBufferReq(const struct SchedDlRlcBufferReqParameters& params) +MemberSchedSapProvider::SchedDlRlcBufferReq(const SchedDlRlcBufferReqParameters& params) { m_scheduler->DoSchedDlRlcBufferReq(params); } template void -MemberSchedSapProvider::SchedDlPagingBufferReq( - const struct SchedDlPagingBufferReqParameters& params) +MemberSchedSapProvider::SchedDlPagingBufferReq(const SchedDlPagingBufferReqParameters& params) { m_scheduler->DoSchedDlPagingBufferReq(params); } template void -MemberSchedSapProvider::SchedDlMacBufferReq(const struct SchedDlMacBufferReqParameters& params) +MemberSchedSapProvider::SchedDlMacBufferReq(const SchedDlMacBufferReqParameters& params) { m_scheduler->DoSchedDlMacBufferReq(params); } template void -MemberSchedSapProvider::SchedDlTriggerReq(const struct SchedDlTriggerReqParameters& params) +MemberSchedSapProvider::SchedDlTriggerReq(const SchedDlTriggerReqParameters& params) { m_scheduler->DoSchedDlTriggerReq(params); } template void -MemberSchedSapProvider::SchedDlRachInfoReq(const struct SchedDlRachInfoReqParameters& params) +MemberSchedSapProvider::SchedDlRachInfoReq(const SchedDlRachInfoReqParameters& params) { m_scheduler->DoSchedDlRachInfoReq(params); } template void -MemberSchedSapProvider::SchedDlCqiInfoReq(const struct SchedDlCqiInfoReqParameters& params) +MemberSchedSapProvider::SchedDlCqiInfoReq(const SchedDlCqiInfoReqParameters& params) { m_scheduler->DoSchedDlCqiInfoReq(params); } template void -MemberSchedSapProvider::SchedUlTriggerReq(const struct SchedUlTriggerReqParameters& params) +MemberSchedSapProvider::SchedUlTriggerReq(const SchedUlTriggerReqParameters& params) { m_scheduler->DoSchedUlTriggerReq(params); } @@ -440,29 +424,28 @@ MemberSchedSapProvider::SchedUlTriggerReq(const struct SchedUlTriggerReqParam template void MemberSchedSapProvider::SchedUlNoiseInterferenceReq( - const struct SchedUlNoiseInterferenceReqParameters& params) + const SchedUlNoiseInterferenceReqParameters& params) { m_scheduler->DoSchedUlNoiseInterferenceReq(params); } template void -MemberSchedSapProvider::SchedUlSrInfoReq(const struct SchedUlSrInfoReqParameters& params) +MemberSchedSapProvider::SchedUlSrInfoReq(const SchedUlSrInfoReqParameters& params) { m_scheduler->DoSchedUlSrInfoReq(params); } template void -MemberSchedSapProvider::SchedUlMacCtrlInfoReq( - const struct SchedUlMacCtrlInfoReqParameters& params) +MemberSchedSapProvider::SchedUlMacCtrlInfoReq(const SchedUlMacCtrlInfoReqParameters& params) { m_scheduler->DoSchedUlMacCtrlInfoReq(params); } template void -MemberSchedSapProvider::SchedUlCqiInfoReq(const struct SchedUlCqiInfoReqParameters& params) +MemberSchedSapProvider::SchedUlCqiInfoReq(const SchedUlCqiInfoReqParameters& params) { m_scheduler->DoSchedUlCqiInfoReq(params); } diff --git a/src/lte/model/ff-mac-scheduler.h b/src/lte/model/ff-mac-scheduler.h index 2d9dea43d..635b3ef49 100644 --- a/src/lte/model/ff-mac-scheduler.h +++ b/src/lte/model/ff-mac-scheduler.h @@ -21,6 +21,8 @@ #ifndef FF_MAC_SCHEDULER_H #define FF_MAC_SCHEDULER_H +#include "ff-mac-common.h" + #include namespace ns3 @@ -38,6 +40,37 @@ class LteFfrSapUser; * \defgroup ff-api FF MAC Schedulers */ +/// DL HARQ process status vector +using DlHarqProcessesStatus_t = std::vector; + +/// DL HARQ process timer vector +using DlHarqProcessesTimer_t = std::vector; + +/// DL HARQ process DCI buffer vector +using DlHarqProcessesDciBuffer_t = std::vector; + +/// Vector of the LCs and layers per UE +using RlcPduList_t = std::vector>; + +/// Vector of the 8 HARQ processes per UE +using DlHarqRlcPduListBuffer_t = std::vector; + +/// UL HARQ process DCI buffer vector +using UlHarqProcessesDciBuffer_t = std::vector; + +/// UL HARQ process status vector +using UlHarqProcessesStatus_t = std::vector; + +/// Value for SINR outside the range defined by FF-API, used to indicate that there is +/// no CQI for this element +constexpr double NO_SINR = -5000; + +/// Number of HARQ processes +constexpr uint32_t HARQ_PROC_NUM = 8; + +/// HARQ DL timeout +constexpr uint32_t HARQ_DL_TIMEOUT = 11; + /** * \ingroup ff-api * diff --git a/src/lte/model/lte-amc.cc b/src/lte/model/lte-amc.cc index 4973e9497..eb161a7c3 100644 --- a/src/lte/model/lte-amc.cc +++ b/src/lte/model/lte-amc.cc @@ -19,12 +19,14 @@ * Nicola Baldo */ +#include "lte-amc.h" + +#include "lte-mi-error-model.h" + #include "ns3/enum.h" #include #include #include -#include -#include #include #include diff --git a/src/lte/model/lte-anr-sap.h b/src/lte/model/lte-anr-sap.h index ee556b66f..4445d5b0b 100644 --- a/src/lte/model/lte-anr-sap.h +++ b/src/lte/model/lte-anr-sap.h @@ -21,7 +21,7 @@ #ifndef LTE_ANR_SAP_H #define LTE_ANR_SAP_H -#include +#include "lte-rrc-sap.h" namespace ns3 { diff --git a/src/lte/model/lte-anr.cc b/src/lte/model/lte-anr.cc index 73adb7c48..7424386c6 100644 --- a/src/lte/model/lte-anr.cc +++ b/src/lte/model/lte-anr.cc @@ -174,7 +174,7 @@ LteAnr::DoReportUeMeas(LteRrcSap::MeasResults measResults) // Update neighbour relation entry NS_LOG_LOGIC(this << " updating NRT of cell " << m_servingCellId << " with entry of cell " << it->physCellId); - if (itNrt->second.noX2 == false) + if (!itNrt->second.noX2) { NS_LOG_LOGIC(this << " enabling handover" << " from cell " << m_servingCellId << " to cell " diff --git a/src/lte/model/lte-anr.h b/src/lte/model/lte-anr.h index 3c5ae5ca1..b93064784 100644 --- a/src/lte/model/lte-anr.h +++ b/src/lte/model/lte-anr.h @@ -27,8 +27,9 @@ #ifndef LTE_ANR_H #define LTE_ANR_H -#include -#include +#include "lte-anr-sap.h" +#include "lte-rrc-sap.h" + #include #include diff --git a/src/lte/model/lte-as-sap.cc b/src/lte/model/lte-as-sap.cc index a4d7e8dae..c1dbe8ff0 100644 --- a/src/lte/model/lte-as-sap.cc +++ b/src/lte/model/lte-as-sap.cc @@ -17,7 +17,7 @@ * Author: Nicola Baldo */ -#include "ns3/lte-as-sap.h" +#include "lte-as-sap.h" namespace ns3 { diff --git a/src/lte/model/lte-asn1-header.cc b/src/lte/model/lte-asn1-header.cc index ec55a0275..18cf50c7f 100644 --- a/src/lte/model/lte-asn1-header.cc +++ b/src/lte/model/lte-asn1-header.cc @@ -17,7 +17,7 @@ * Author: Lluis Parcerisa */ -#include "ns3/lte-asn1-header.h" +#include "lte-asn1-header.h" #include "ns3/log.h" diff --git a/src/lte/model/lte-ccm-mac-sap.h b/src/lte/model/lte-ccm-mac-sap.h index ce77576e0..01a486dbb 100644 --- a/src/lte/model/lte-ccm-mac-sap.h +++ b/src/lte/model/lte-ccm-mac-sap.h @@ -21,11 +21,8 @@ #ifndef LTE_CCM_MAC_SAP_H #define LTE_CCM_MAC_SAP_H -#include -#include -#include -#include -#include +#include "ff-mac-common.h" +#include "lte-mac-sap.h" namespace ns3 { diff --git a/src/lte/model/lte-ccm-rrc-sap.h b/src/lte/model/lte-ccm-rrc-sap.h index 006f814c9..85f6fc834 100644 --- a/src/lte/model/lte-ccm-rrc-sap.h +++ b/src/lte/model/lte-ccm-rrc-sap.h @@ -21,10 +21,10 @@ #ifndef LTE_CCM_RRC_SAP_H #define LTE_CCM_RRC_SAP_H -#include -#include -#include -#include +#include "eps-bearer.h" +#include "lte-enb-cmac-sap.h" +#include "lte-mac-sap.h" +#include "lte-rrc-sap.h" #include diff --git a/src/lte/model/lte-common.h b/src/lte/model/lte-common.h index d802fe66a..8861bcd9b 100644 --- a/src/lte/model/lte-common.h +++ b/src/lte/model/lte-common.h @@ -32,6 +32,12 @@ namespace ns3 { +/// Minimum number of carrier components allowed by 3GPP up to R13 +constexpr uint32_t MIN_NO_CC = 1; + +/// Maximum number of carrier components allowed by 3GPP up to R13 +constexpr uint32_t MAX_NO_CC = 5; + /// LteFlowId structure struct LteFlowId_t { diff --git a/src/lte/model/lte-control-messages.cc b/src/lte/model/lte-control-messages.cc index 3ba810617..2c86fed0a 100644 --- a/src/lte/model/lte-control-messages.cc +++ b/src/lte/model/lte-control-messages.cc @@ -20,9 +20,6 @@ #include "lte-control-messages.h" -#include "lte-net-device.h" -#include "lte-ue-net-device.h" - #include "ns3/address-utils.h" #include "ns3/log.h" #include "ns3/uinteger.h" diff --git a/src/lte/model/lte-control-messages.h b/src/lte/model/lte-control-messages.h index f09470ac9..6ab3631eb 100644 --- a/src/lte/model/lte-control-messages.h +++ b/src/lte/model/lte-control-messages.h @@ -21,8 +21,9 @@ #ifndef LTE_CONTROL_MESSAGES_H #define LTE_CONTROL_MESSAGES_H -#include -#include +#include "ff-mac-common.h" +#include "lte-rrc-sap.h" + #include #include diff --git a/src/lte/model/lte-enb-cmac-sap.h b/src/lte/model/lte-enb-cmac-sap.h index 50d9c05ac..2ceea2ef8 100644 --- a/src/lte/model/lte-enb-cmac-sap.h +++ b/src/lte/model/lte-enb-cmac-sap.h @@ -21,9 +21,6 @@ #ifndef LTE_ENB_CMAC_SAP_H #define LTE_ENB_CMAC_SAP_H -#include -#include -#include #include namespace ns3 @@ -70,15 +67,16 @@ class LteEnbCmacSapProvider */ struct LcInfo { - uint16_t rnti; /**< C-RNTI identifying the UE */ - uint8_t lcId; /**< logical channel identifier */ - uint8_t lcGroup; /**< logical channel group */ - uint8_t qci; /**< QoS Class Identifier */ - bool isGbr; /**< true if the bearer is GBR, false if the bearer is NON-GBR */ - uint64_t mbrUl; /**< maximum bitrate in uplink */ - uint64_t mbrDl; /**< maximum bitrate in downlink */ - uint64_t gbrUl; /**< guaranteed bitrate in uplink */ - uint64_t gbrDl; /**< guaranteed bitrate in downlink */ + uint16_t rnti; /**< C-RNTI identifying the UE */ + uint8_t lcId; /**< logical channel identifier */ + uint8_t lcGroup; /**< logical channel group */ + uint8_t qci; /**< QoS Class Identifier */ + uint8_t resourceType; /**< 0 if the bearer is NON-GBR, 1 if the bearer + is GBR, 2 if the bearer in DC-GBR */ + uint64_t mbrUl; /**< maximum bitrate in uplink */ + uint64_t mbrDl; /**< maximum bitrate in downlink */ + uint64_t gbrUl; /**< guaranteed bitrate in uplink */ + uint64_t gbrDl; /**< guaranteed bitrate in downlink */ }; /** diff --git a/src/lte/model/lte-enb-component-carrier-manager.cc b/src/lte/model/lte-enb-component-carrier-manager.cc index f41bbaa22..51b05deb2 100644 --- a/src/lte/model/lte-enb-component-carrier-manager.cc +++ b/src/lte/model/lte-enb-component-carrier-manager.cc @@ -20,6 +20,8 @@ #include "lte-enb-component-carrier-manager.h" +#include "lte-common.h" + #include namespace ns3 diff --git a/src/lte/model/lte-enb-component-carrier-manager.h b/src/lte/model/lte-enb-component-carrier-manager.h index a92760714..ced66c8b4 100644 --- a/src/lte/model/lte-enb-component-carrier-manager.h +++ b/src/lte/model/lte-enb-component-carrier-manager.h @@ -21,12 +21,13 @@ #ifndef LTE_ENB_COMPONENT_CARRIER_MANAGER_H #define LTE_ENB_COMPONENT_CARRIER_MANAGER_H -#include -#include -#include -#include -#include -#include +#include "lte-ccm-mac-sap.h" +#include "lte-ccm-rrc-sap.h" +#include "lte-enb-cmac-sap.h" +#include "lte-enb-rrc.h" +#include "lte-mac-sap.h" +#include "lte-rrc-sap.h" + #include #include diff --git a/src/lte/model/lte-enb-cphy-sap.cc b/src/lte/model/lte-enb-cphy-sap.cc index bdab5be75..ac312fa76 100644 --- a/src/lte/model/lte-enb-cphy-sap.cc +++ b/src/lte/model/lte-enb-cphy-sap.cc @@ -17,7 +17,7 @@ * Author: Nicola Baldo */ -#include "ns3/lte-enb-cphy-sap.h" +#include "lte-enb-cphy-sap.h" namespace ns3 { diff --git a/src/lte/model/lte-enb-cphy-sap.h b/src/lte/model/lte-enb-cphy-sap.h index 2f09ebab9..3301d1e48 100644 --- a/src/lte/model/lte-enb-cphy-sap.h +++ b/src/lte/model/lte-enb-cphy-sap.h @@ -21,7 +21,8 @@ #ifndef LTE_ENB_CPHY_SAP_H #define LTE_ENB_CPHY_SAP_H -#include +#include "lte-rrc-sap.h" + #include #include diff --git a/src/lte/model/lte-enb-mac.cc b/src/lte/model/lte-enb-mac.cc index 977493912..63f9bf32b 100644 --- a/src/lte/model/lte-enb-mac.cc +++ b/src/lte/model/lte-enb-mac.cc @@ -21,18 +21,15 @@ * Biljana Bojovic (Carrier Aggregation) */ -#include "lte-amc.h" -#include "lte-control-messages.h" -#include "lte-enb-net-device.h" -#include "lte-ue-net-device.h" +#include "lte-enb-mac.h" + +#include "lte-common.h" +#include "lte-control-messages.h" +#include "lte-enb-cmac-sap.h" +#include "lte-mac-sap.h" +#include "lte-radio-bearer-tag.h" -#include "ns3/lte-enb-cmac-sap.h" -#include "ns3/lte-mac-sap.h" #include -#include -#include -#include -#include #include #include #include @@ -144,8 +141,8 @@ class EnbMacMemberFfMacSchedSapUser : public FfMacSchedSapUser */ EnbMacMemberFfMacSchedSapUser(LteEnbMac* mac); - void SchedDlConfigInd(const struct SchedDlConfigIndParameters& params) override; - void SchedUlConfigInd(const struct SchedUlConfigIndParameters& params) override; + void SchedDlConfigInd(const SchedDlConfigIndParameters& params) override; + void SchedUlConfigInd(const SchedUlConfigIndParameters& params) override; private: LteEnbMac* m_mac; ///< the MAC @@ -157,13 +154,13 @@ EnbMacMemberFfMacSchedSapUser::EnbMacMemberFfMacSchedSapUser(LteEnbMac* mac) } void -EnbMacMemberFfMacSchedSapUser::SchedDlConfigInd(const struct SchedDlConfigIndParameters& params) +EnbMacMemberFfMacSchedSapUser::SchedDlConfigInd(const SchedDlConfigIndParameters& params) { m_mac->DoSchedDlConfigInd(params); } void -EnbMacMemberFfMacSchedSapUser::SchedUlConfigInd(const struct SchedUlConfigIndParameters& params) +EnbMacMemberFfMacSchedSapUser::SchedUlConfigInd(const SchedUlConfigIndParameters& params) { m_mac->DoSchedUlConfigInd(params); } @@ -179,14 +176,13 @@ class EnbMacMemberFfMacCschedSapUser : public FfMacCschedSapUser */ EnbMacMemberFfMacCschedSapUser(LteEnbMac* mac); - void CschedCellConfigCnf(const struct CschedCellConfigCnfParameters& params) override; - void CschedUeConfigCnf(const struct CschedUeConfigCnfParameters& params) override; - void CschedLcConfigCnf(const struct CschedLcConfigCnfParameters& params) override; - void CschedLcReleaseCnf(const struct CschedLcReleaseCnfParameters& params) override; - void CschedUeReleaseCnf(const struct CschedUeReleaseCnfParameters& params) override; - void CschedUeConfigUpdateInd(const struct CschedUeConfigUpdateIndParameters& params) override; - void CschedCellConfigUpdateInd( - const struct CschedCellConfigUpdateIndParameters& params) override; + void CschedCellConfigCnf(const CschedCellConfigCnfParameters& params) override; + void CschedUeConfigCnf(const CschedUeConfigCnfParameters& params) override; + void CschedLcConfigCnf(const CschedLcConfigCnfParameters& params) override; + void CschedLcReleaseCnf(const CschedLcReleaseCnfParameters& params) override; + void CschedUeReleaseCnf(const CschedUeReleaseCnfParameters& params) override; + void CschedUeConfigUpdateInd(const CschedUeConfigUpdateIndParameters& params) override; + void CschedCellConfigUpdateInd(const CschedCellConfigUpdateIndParameters& params) override; private: LteEnbMac* m_mac; ///< the MAC @@ -198,48 +194,45 @@ EnbMacMemberFfMacCschedSapUser::EnbMacMemberFfMacCschedSapUser(LteEnbMac* mac) } void -EnbMacMemberFfMacCschedSapUser::CschedCellConfigCnf( - const struct CschedCellConfigCnfParameters& params) +EnbMacMemberFfMacCschedSapUser::CschedCellConfigCnf(const CschedCellConfigCnfParameters& params) { m_mac->DoCschedCellConfigCnf(params); } void -EnbMacMemberFfMacCschedSapUser::CschedUeConfigCnf(const struct CschedUeConfigCnfParameters& params) +EnbMacMemberFfMacCschedSapUser::CschedUeConfigCnf(const CschedUeConfigCnfParameters& params) { m_mac->DoCschedUeConfigCnf(params); } void -EnbMacMemberFfMacCschedSapUser::CschedLcConfigCnf(const struct CschedLcConfigCnfParameters& params) +EnbMacMemberFfMacCschedSapUser::CschedLcConfigCnf(const CschedLcConfigCnfParameters& params) { m_mac->DoCschedLcConfigCnf(params); } void -EnbMacMemberFfMacCschedSapUser::CschedLcReleaseCnf( - const struct CschedLcReleaseCnfParameters& params) +EnbMacMemberFfMacCschedSapUser::CschedLcReleaseCnf(const CschedLcReleaseCnfParameters& params) { m_mac->DoCschedLcReleaseCnf(params); } void -EnbMacMemberFfMacCschedSapUser::CschedUeReleaseCnf( - const struct CschedUeReleaseCnfParameters& params) +EnbMacMemberFfMacCschedSapUser::CschedUeReleaseCnf(const CschedUeReleaseCnfParameters& params) { m_mac->DoCschedUeReleaseCnf(params); } void EnbMacMemberFfMacCschedSapUser::CschedUeConfigUpdateInd( - const struct CschedUeConfigUpdateIndParameters& params) + const CschedUeConfigUpdateIndParameters& params) { m_mac->DoCschedUeConfigUpdateInd(params); } void EnbMacMemberFfMacCschedSapUser::CschedCellConfigUpdateInd( - const struct CschedCellConfigUpdateIndParameters& params) + const CschedCellConfigUpdateIndParameters& params) { m_mac->DoCschedCellConfigUpdateInd(params); } @@ -261,8 +254,8 @@ class EnbMacMemberLteEnbPhySapUser : public LteEnbPhySapUser void ReceiveLteControlMessage(Ptr msg) override; void ReceiveRachPreamble(uint32_t prachId) override; void UlCqiReport(FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqi) override; - void UlInfoListElementHarqFeeback(UlInfoListElement_s params) override; - void DlInfoListElementHarqFeeback(DlInfoListElement_s params) override; + void UlInfoListElementHarqFeedback(UlInfoListElement_s params) override; + void DlInfoListElementHarqFeedback(DlInfoListElement_s params) override; private: LteEnbMac* m_mac; ///< the MAC @@ -304,15 +297,15 @@ EnbMacMemberLteEnbPhySapUser::UlCqiReport(FfMacSchedSapProvider::SchedUlCqiInfoR } void -EnbMacMemberLteEnbPhySapUser::UlInfoListElementHarqFeeback(UlInfoListElement_s params) +EnbMacMemberLteEnbPhySapUser::UlInfoListElementHarqFeedback(UlInfoListElement_s params) { - m_mac->DoUlInfoListElementHarqFeeback(params); + m_mac->DoUlInfoListElementHarqFeedback(params); } void -EnbMacMemberLteEnbPhySapUser::DlInfoListElementHarqFeeback(DlInfoListElement_s params) +EnbMacMemberLteEnbPhySapUser::DlInfoListElementHarqFeedback(DlInfoListElement_s params) { - m_mac->DoDlInfoListElementHarqFeeback(params); + m_mac->DoDlInfoListElementHarqFeedback(params); } // ////////////////////////////////////// @@ -533,6 +526,14 @@ LteEnbMac::DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo) else { rnti = m_cmacSapUser->AllocateTemporaryCellRnti(); + + if (rnti == 0) + { + // If rnti = 0, UE context was not created (not enough SRS) + // Therefore don't send RAR for this preamble + NS_LOG_INFO("UE context not created, no RAR to send"); + continue; + } NS_LOG_INFO("preambleId " << (uint32_t)it->first << ": allocated T-C-RNTI " << (uint32_t)rnti << ", sending RAR"); } @@ -563,7 +564,7 @@ LteEnbMac::DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo) FfMacSchedSapProvider::SchedDlTriggerReqParameters dlparams; dlparams.m_sfnSf = ((0x3FF & dlSchedFrameNo) << 4) | (0xF & dlSchedSubframeNo); - // Forward DL HARQ feebacks collected during last TTI + // Forward DL HARQ Feedbacks collected during last TTI if (!m_dlInfoListReceived.empty()) { dlparams.m_dlInfoList = m_dlInfoListReceived; @@ -617,7 +618,7 @@ LteEnbMac::DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo) FfMacSchedSapProvider::SchedUlTriggerReqParameters ulparams; ulparams.m_sfnSf = ((0x3FF & ulSchedFrameNo) << 4) | (0xF & ulSchedSubframeNo); - // Forward DL HARQ feebacks collected during last TTI + // Forward DL HARQ Feedbacks collected during last TTI if (!m_ulInfoListReceived.empty()) { ulparams.m_ulInfoList = m_ulInfoListReceived; @@ -646,7 +647,7 @@ LteEnbMac::DoReceiveLteControlMessage(Ptr msg) { Ptr dlharq = DynamicCast(msg); - DoDlInfoListElementHarqFeeback(dlharq->GetDlHarqFeedback()); + DoDlInfoListElementHarqFeedback(dlharq->GetDlHarqFeedback()); } else { @@ -893,21 +894,22 @@ LteEnbMac::DoAddLc(LteEnbCmacSapProvider::LcInfo lcinfo, LteMacSapUser* msu) // 4.3.4 logicalChannelConfigListElement if (lcinfo.lcId != 0) { - struct FfMacCschedSapProvider::CschedLcConfigReqParameters params; + FfMacCschedSapProvider::CschedLcConfigReqParameters params; params.m_rnti = lcinfo.rnti; params.m_reconfigureFlag = false; - struct LogicalChannelConfigListElement_s lccle; + LogicalChannelConfigListElement_s lccle; lccle.m_logicalChannelIdentity = lcinfo.lcId; lccle.m_logicalChannelGroup = lcinfo.lcGroup; lccle.m_direction = LogicalChannelConfigListElement_s::DIR_BOTH; - lccle.m_qosBearerType = lcinfo.isGbr ? LogicalChannelConfigListElement_s::QBT_GBR - : LogicalChannelConfigListElement_s::QBT_NON_GBR; lccle.m_qci = lcinfo.qci; lccle.m_eRabMaximulBitrateUl = lcinfo.mbrUl; lccle.m_eRabMaximulBitrateDl = lcinfo.mbrDl; lccle.m_eRabGuaranteedBitrateUl = lcinfo.gbrUl; lccle.m_eRabGuaranteedBitrateDl = lcinfo.gbrDl; + lccle.m_qosBearerType = + static_cast(lcinfo.resourceType); + params.m_logicalChannelConfigList.push_back(lccle); m_cschedSapProvider->CschedLcConfigReq(params); @@ -930,7 +932,7 @@ LteEnbMac::DoReleaseLc(uint16_t rnti, uint8_t lcid) m_rlcAttached.find(rnti); rntiIt->second.erase(lcid); - struct FfMacCschedSapProvider::CschedLcReleaseReqParameters params; + FfMacCschedSapProvider::CschedLcReleaseReqParameters params; params.m_rnti = rnti; params.m_logicalChannelIdentity.push_back(lcid); m_cschedSapProvider->CschedLcReleaseReq(params); @@ -952,7 +954,7 @@ LteEnbMac::DoUeUpdateConfigurationReq(LteEnbCmacSapProvider::UeConfig params) LteEnbCmacSapProvider::RachConfig LteEnbMac::DoGetRachConfig() const { - struct LteEnbCmacSapProvider::RachConfig rc; + LteEnbCmacSapProvider::RachConfig rc; rc.numberOfRaPreambles = m_numberOfRaPreambles; rc.preambleTransMax = m_preambleTransMax; rc.raResponseWindowSize = m_raResponseWindowSize; @@ -1296,14 +1298,14 @@ LteEnbMac::DoCschedCellConfigUpdateInd( } void -LteEnbMac::DoUlInfoListElementHarqFeeback(UlInfoListElement_s params) +LteEnbMac::DoUlInfoListElementHarqFeedback(UlInfoListElement_s params) { NS_LOG_FUNCTION(this); m_ulInfoListReceived.push_back(params); } void -LteEnbMac::DoDlInfoListElementHarqFeeback(DlInfoListElement_s params) +LteEnbMac::DoDlInfoListElementHarqFeedback(DlInfoListElement_s params) { NS_LOG_FUNCTION(this); // Update HARQ buffer diff --git a/src/lte/model/lte-enb-mac.h b/src/lte/model/lte-enb-mac.h index ba4d2d542..a607f4744 100644 --- a/src/lte/model/lte-enb-mac.h +++ b/src/lte/model/lte-enb-mac.h @@ -24,17 +24,19 @@ #ifndef LTE_ENB_MAC_H #define LTE_ENB_MAC_H -#include "ns3/trace-source-accessor.h" -#include "ns3/traced-value.h" -#include -#include -#include -#include -#include -#include -#include +#include "ff-mac-csched-sap.h" +#include "ff-mac-sched-sap.h" +#include "lte-ccm-mac-sap.h" +#include "lte-common.h" +#include "lte-enb-cmac-sap.h" +#include "lte-enb-phy-sap.h" +#include "lte-mac-sap.h" + +#include #include #include +#include +#include #include #include @@ -365,12 +367,12 @@ class LteEnbMac : public Object * \brief UL Info List ELements HARQ Feedback function * \param params UlInfoListElement_s */ - void DoUlInfoListElementHarqFeeback(UlInfoListElement_s params); + void DoUlInfoListElementHarqFeedback(UlInfoListElement_s params); /** * \brief DL Info List ELements HARQ Feedback function * \param params DlInfoListElement_s */ - void DoDlInfoListElementHarqFeeback(DlInfoListElement_s params); + void DoDlInfoListElementHarqFeedback(DlInfoListElement_s params); /// RNTI, LC ID, SAP of the RLC instance std::map> m_rlcAttached; diff --git a/src/lte/model/lte-enb-net-device.cc b/src/lte/model/lte-enb-net-device.cc index e901294dd..7ed86b412 100644 --- a/src/lte/model/lte-enb-net-device.cc +++ b/src/lte/model/lte-enb-net-device.cc @@ -21,25 +21,25 @@ * 2015 - Carrier Aggregation */ +#include "lte-enb-net-device.h" + +#include "component-carrier-enb.h" +#include "lte-anr.h" +#include "lte-enb-component-carrier-manager.h" +#include "lte-enb-mac.h" +#include "lte-enb-phy.h" +#include "lte-enb-rrc.h" +#include "lte-ffr-algorithm.h" +#include "lte-handover-algorithm.h" +#include "lte-net-device.h" + #include #include #include -#include #include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include diff --git a/src/lte/model/lte-enb-net-device.h b/src/lte/model/lte-enb-net-device.h index 4ab32535b..6c85dd50c 100644 --- a/src/lte/model/lte-enb-net-device.h +++ b/src/lte/model/lte-enb-net-device.h @@ -23,10 +23,10 @@ #ifndef LTE_ENB_NET_DEVICE_H #define LTE_ENB_NET_DEVICE_H -#include "ns3/component-carrier-enb.h" +#include "component-carrier.h" +#include "lte-net-device.h" + #include "ns3/event-id.h" -#include "ns3/lte-net-device.h" -#include "ns3/lte-phy.h" #include "ns3/mac48-address.h" #include "ns3/nstime.h" #include "ns3/traced-callback.h" diff --git a/src/lte/model/lte-enb-phy-sap.h b/src/lte/model/lte-enb-phy-sap.h index 57f9de632..7a5aae213 100644 --- a/src/lte/model/lte-enb-phy-sap.h +++ b/src/lte/model/lte-enb-phy-sap.h @@ -20,8 +20,9 @@ #ifndef LTE_ENB_PHY_SAP_H #define LTE_ENB_PHY_SAP_H -#include -#include +#include "ff-mac-common.h" +#include "ff-mac-sched-sap.h" + #include namespace ns3 @@ -109,14 +110,14 @@ class LteEnbPhySapUser * * \param params */ - virtual void UlInfoListElementHarqFeeback(UlInfoListElement_s params) = 0; + virtual void UlInfoListElementHarqFeedback(UlInfoListElement_s params) = 0; /** * Notify the HARQ on the DL transmission status * * \param params */ - virtual void DlInfoListElementHarqFeeback(DlInfoListElement_s params) = 0; + virtual void DlInfoListElementHarqFeedback(DlInfoListElement_s params) = 0; }; } // namespace ns3 diff --git a/src/lte/model/lte-enb-phy.cc b/src/lte/model/lte-enb-phy.cc index f25134526..bb07f2b7a 100644 --- a/src/lte/model/lte-enb-phy.cc +++ b/src/lte/model/lte-enb-phy.cc @@ -20,27 +20,22 @@ #include "lte-enb-phy.h" +#include "lte-common.h" #include "lte-control-messages.h" -#include "lte-enb-mac.h" -#include "lte-enb-net-device.h" #include "lte-net-device.h" #include "lte-spectrum-value-helper.h" -#include "lte-ue-phy.h" -#include "lte-ue-rrc.h" +#include "lte-vendor-specific-parameters.h" #include #include #include -#include -#include #include #include #include #include -// WILD HACK for the inizialization of direct eNB-UE ctrl messaging -#include +// WILD HACK for the initialization of direct eNB-UE ctrl messaging #include #include #include @@ -736,7 +731,7 @@ LteEnbPhy::StartSubFrame() it != rarMsg->RarListEnd(); ++it) { - if (it->rarPayload.m_grant.m_ulDelay == true) + if (it->rarPayload.m_grant.m_ulDelay) { NS_FATAL_ERROR(" RAR delay is not yet implemented"); } @@ -1161,7 +1156,7 @@ LteEnbPhy::ReportUlHarqFeedback(UlInfoListElement_s mes) { NS_LOG_FUNCTION(this); // forward to scheduler - m_enbPhySapUser->UlInfoListElementHarqFeeback(mes); + m_enbPhySapUser->UlInfoListElementHarqFeedback(mes); } } // namespace ns3 diff --git a/src/lte/model/lte-enb-phy.h b/src/lte/model/lte-enb-phy.h index 388aa6c72..958138f3a 100644 --- a/src/lte/model/lte-enb-phy.h +++ b/src/lte/model/lte-enb-phy.h @@ -21,11 +21,11 @@ #ifndef ENB_LTE_PHY_H #define ENB_LTE_PHY_H -#include -#include -#include -#include -#include +#include "lte-control-messages.h" +#include "lte-enb-cphy-sap.h" +#include "lte-enb-phy-sap.h" +#include "lte-harq-phy.h" +#include "lte-phy.h" #include #include diff --git a/src/lte/model/lte-enb-rrc.cc b/src/lte/model/lte-enb-rrc.cc index d893bd84c..e11c1cff3 100644 --- a/src/lte/model/lte-enb-rrc.cc +++ b/src/lte/model/lte-enb-rrc.cc @@ -25,16 +25,18 @@ #include "lte-enb-rrc.h" +#include "component-carrier-enb.h" +#include "eps-bearer-tag.h" +#include "lte-pdcp.h" +#include "lte-radio-bearer-info.h" +#include "lte-rlc-am.h" +#include "lte-rlc-tm.h" +#include "lte-rlc-um.h" +#include "lte-rlc.h" + #include -#include #include #include -#include -#include -#include -#include -#include -#include #include #include #include @@ -204,7 +206,7 @@ UeManager::DoInitialize() // Iinterface Specification v1.11, 4.3.4 logicalChannelConfigListElement lcinfo.lcGroup = 0; lcinfo.qci = 0; - lcinfo.isGbr = false; + lcinfo.resourceType = 0; lcinfo.mbrUl = 0; lcinfo.mbrDl = 0; lcinfo.gbrUl = 0; @@ -249,7 +251,7 @@ UeManager::DoInitialize() lcinfo.lcGroup = 0; // all SRBs always mapped to LCG 0 lcinfo.qci = EpsBearer::GBR_CONV_VOICE; // not sure why the FF API requires a CQI even for SRBs... - lcinfo.isGbr = true; + lcinfo.resourceType = 1; // GBR resource type lcinfo.mbrUl = 1e6; lcinfo.mbrDl = 1e6; lcinfo.gbrUl = 1e4; @@ -436,6 +438,7 @@ UeManager::SetupDataRadioBearer(EpsBearer bearer, Ptr rlc = rlcObjectFactory.Create()->GetObject(); rlc->SetLteMacSapProvider(m_rrc->m_macSapProvider); rlc->SetRnti(m_rnti); + rlc->SetPacketDelayBudgetMs(bearer.GetPacketDelayBudgetMs()); drbInfo->m_rlc = rlc; @@ -468,7 +471,7 @@ UeManager::SetupDataRadioBearer(EpsBearer bearer, // lcinfo.lcId = lcid; // lcinfo.lcGroup = m_rrc->GetLogicalChannelGroup (bearer); // lcinfo.qci = bearer.qci; - // lcinfo.isGbr = bearer.IsGbr (); + // lcinfo.resourceType = bearer.GetResourceType(); // lcinfo.mbrUl = bearer.gbrQosInfo.mbrUl; // lcinfo.mbrDl = bearer.gbrQosInfo.mbrDl; // lcinfo.gbrUl = bearer.gbrQosInfo.gbrUl; @@ -503,7 +506,7 @@ UeManager::SetupDataRadioBearer(EpsBearer bearer, drbInfo->m_logicalChannelIdentity = lcid; drbInfo->m_logicalChannelConfig.priority = m_rrc->GetLogicalChannelPriority(bearer); drbInfo->m_logicalChannelConfig.logicalChannelGroup = m_rrc->GetLogicalChannelGroup(bearer); - if (bearer.IsGbr()) + if (bearer.GetResourceType() > 0) // 1, 2 for GBR and DC-GBR { drbInfo->m_logicalChannelConfig.prioritizedBitRateKbps = bearer.gbrQosInfo.gbrUl; } @@ -679,7 +682,7 @@ UeManager::PrepareHandover(uint16_t cellId) uint16_t rnti = m_rrc->AddUe(UeManager::HANDOVER_JOINING, componentCarrierId); LteEnbCmacSapProvider::AllocateNcRaPreambleReturnValue anrcrv = m_rrc->m_cmacSapProvider.at(componentCarrierId)->AllocateNcRaPreamble(rnti); - if (anrcrv.valid == false) + if (!anrcrv.valid) { NS_LOG_INFO(this << " failed to allocate a preamble for non-contention based RA => " "cannot perform HO"); @@ -958,7 +961,6 @@ UeManager::SendData(uint8_t bid, Ptr p) case CONNECTION_SETUP: NS_LOG_WARN("not connected, discarding packet"); return; - break; case CONNECTED_NORMALLY: case CONNECTION_RECONFIGURATION: @@ -1145,7 +1147,7 @@ UeManager::RecvRrcConnectionRequest(LteRrcSap::RrcConnectionRequest msg) case INITIAL_RANDOM_ACCESS: { m_connectionRequestTimeout.Cancel(); - if (m_rrc->m_admitRrcConnectionRequest == true) + if (m_rrc->m_admitRrcConnectionRequest) { m_imsi = msg.ueIdentity; @@ -1195,7 +1197,7 @@ UeManager::RecvRrcConnectionSetupCompleted(LteRrcSap::RrcConnectionSetupComplete { case CONNECTION_SETUP: m_connectionSetupTimeout.Cancel(); - if (m_caSupportConfigured == false && m_rrc->m_numberOfComponentCarriers > 1) + if (!m_caSupportConfigured && m_rrc->m_numberOfComponentCarriers > 1) { m_pendingRrcConnectionReconfiguration = true; // Force Reconfiguration m_pendingStartDataRadioBearers = true; @@ -1610,7 +1612,7 @@ UeManager::BuildRrcConnectionReconfiguration() msg.haveMobilityControlInfo = false; msg.haveMeasConfig = true; msg.measConfig = m_rrc->m_ueMeasConfig; - if (m_caSupportConfigured == false && m_rrc->m_numberOfComponentCarriers > 1) + if (!m_caSupportConfigured && m_rrc->m_numberOfComponentCarriers > 1) { m_caSupportConfigured = true; NS_LOG_FUNCTION(this << "CA not configured. Configure now!"); @@ -1733,11 +1735,11 @@ UeManager::SwitchToState(State newState) break; case CONNECTED_NORMALLY: { - if (m_pendingRrcConnectionReconfiguration == true) + if (m_pendingRrcConnectionReconfiguration) { ScheduleRrcConnectionReconfiguration(); } - if (m_pendingStartDataRadioBearers == true && m_caSupportConfigured == true) + if (m_pendingStartDataRadioBearers && m_caSupportConfigured) { StartDataRadioBearers(); } @@ -2867,7 +2869,7 @@ LteEnbRrc::DoRecvHandoverRequest(EpcX2SapUser::HandoverRequestParams req) NS_LOG_LOGIC("mmeUeS1apId = " << req.mmeUeS1apId); // if no SRS index is available, then do not accept the handover - if (m_admitHandoverRequest == false || IsMaxSrsReached()) + if (!m_admitHandoverRequest || IsMaxSrsReached()) { NS_LOG_INFO("rejecting handover request from cellId " << req.sourceCellId); EpcX2Sap::HandoverPreparationFailureParams res; @@ -2887,7 +2889,7 @@ LteEnbRrc::DoRecvHandoverRequest(EpcX2SapUser::HandoverRequestParams req) ueManager->SetImsi(req.mmeUeS1apId); LteEnbCmacSapProvider::AllocateNcRaPreambleReturnValue anrcrv = m_cmacSapProvider.at(componentCarrierId)->AllocateNcRaPreamble(rnti); - if (anrcrv.valid == false) + if (!anrcrv.valid) { NS_LOG_INFO( this @@ -3121,6 +3123,7 @@ LteEnbRrc::DoAllocateTemporaryCellRnti(uint8_t componentCarrierId) // if no SRS index is available, then do not create a new UE context. if (IsMaxSrsReached()) { + NS_LOG_WARN("Not enough SRS configuration indices, UE context not created"); return 0; // return 0 since new RNTI was not assigned for the received preamble } return AddUe(UeManager::INITIAL_RANDOM_ACCESS, componentCarrierId); @@ -3310,15 +3313,12 @@ LteEnbRrc::GetRlcType(EpsBearer bearer) { case RLC_SM_ALWAYS: return LteRlcSm::GetTypeId(); - break; case RLC_UM_ALWAYS: return LteRlcUm::GetTypeId(); - break; case RLC_AM_ALWAYS: return LteRlcAm::GetTypeId(); - break; case PER_BASED: if (bearer.GetPacketErrorLossRate() > 1.0e-5) @@ -3329,11 +3329,9 @@ LteEnbRrc::GetRlcType(EpsBearer bearer) { return LteRlcAm::GetTypeId(); } - break; default: return LteRlcSm::GetTypeId(); - break; } } @@ -3487,20 +3485,13 @@ LteEnbRrc::IsMaxSrsReached() NS_ASSERT(m_srsCurrentPeriodicityId < SRS_ENTRIES); NS_LOG_DEBUG(this << " SRS p " << g_srsPeriodicity[m_srsCurrentPeriodicityId] << " set " << m_ueSrsConfigurationIndexSet.size()); - if (m_ueSrsConfigurationIndexSet.size() >= g_srsPeriodicity[m_srsCurrentPeriodicityId]) - { - return true; - } - else - { - return false; - } + return m_ueSrsConfigurationIndexSet.size() >= g_srsPeriodicity[m_srsCurrentPeriodicityId]; } uint8_t LteEnbRrc::GetLogicalChannelGroup(EpsBearer bearer) { - if (bearer.IsGbr()) + if (bearer.GetResourceType() > 0) // 1, 2 for GBR and DC-GBR { return 1; } @@ -3561,10 +3552,8 @@ LteEnbRrc::IsRandomAccessCompleted(uint16_t rnti) case UeManager::CONNECTED_NORMALLY: case UeManager::CONNECTION_RECONFIGURATION: return true; - break; default: return false; - break; } } diff --git a/src/lte/model/lte-enb-rrc.h b/src/lte/model/lte-enb-rrc.h index 3b09ff913..63b0fafaf 100644 --- a/src/lte/model/lte-enb-rrc.h +++ b/src/lte/model/lte-enb-rrc.h @@ -27,22 +27,20 @@ #ifndef LTE_ENB_RRC_H #define LTE_ENB_RRC_H -#include -#include -#include +#include "component-carrier.h" +#include "epc-enb-s1-sap.h" +#include "epc-x2-sap.h" +#include "lte-anr-sap.h" +#include "lte-ccm-rrc-sap.h" +#include "lte-enb-cmac-sap.h" +#include "lte-enb-cphy-sap.h" +#include "lte-ffr-rrc-sap.h" +#include "lte-handover-management-sap.h" +#include "lte-mac-sap.h" +#include "lte-pdcp-sap.h" +#include "lte-rrc-sap.h" + #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include @@ -51,9 +49,6 @@ #include #include -#define MIN_NO_CC 1 -#define MAX_NO_CC 5 // this is the maximum number of carrier components allowed by 3GPP up to R13 - namespace ns3 { @@ -1637,7 +1632,7 @@ class LteEnbRrc : public Object * The `EpsBearerToRlcMapping` attribute. Specify which type of RLC will be * used for each type of EPS bearer. */ - enum LteEpsBearerToRlcMapping_t m_epsBearerToRlcMapping; + LteEpsBearerToRlcMapping_t m_epsBearerToRlcMapping; /** * The `SystemInformationPeriodicity` attribute. The interval for sending * system information. diff --git a/src/lte/model/lte-ffr-algorithm.h b/src/lte/model/lte-ffr-algorithm.h index 801de5fe5..b2b9d56de 100644 --- a/src/lte/model/lte-ffr-algorithm.h +++ b/src/lte/model/lte-ffr-algorithm.h @@ -21,9 +21,10 @@ #ifndef LTE_FFR_ALGORITHM_H #define LTE_FFR_ALGORITHM_H -#include -#include -#include +#include "epc-x2-sap.h" +#include "ff-mac-sched-sap.h" +#include "lte-rrc-sap.h" + #include #include @@ -176,7 +177,7 @@ class LteFfrAlgorithm : public Object * */ virtual void DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) = 0; + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) = 0; /** * \brief DoReportUlCqiInfo @@ -184,7 +185,7 @@ class LteFfrAlgorithm : public Object * */ virtual void DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) = 0; + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) = 0; /** * \brief DoReportUlCqiInfo diff --git a/src/lte/model/lte-ffr-distributed-algorithm.cc b/src/lte/model/lte-ffr-distributed-algorithm.cc index 352103171..fc2b39b2f 100644 --- a/src/lte/model/lte-ffr-distributed-algorithm.cc +++ b/src/lte/model/lte-ffr-distributed-algorithm.cc @@ -306,7 +306,7 @@ LteFfrDistributedAlgorithm::DoIsUlRbgAvailableForUe(int rbId, uint16_t rnti) void LteFfrDistributedAlgorithm::DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); NS_LOG_WARN("Method should not be called, because it is empty"); @@ -314,7 +314,7 @@ LteFfrDistributedAlgorithm::DoReportDlCqiInfo( void LteFfrDistributedAlgorithm::DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); NS_LOG_WARN("Method should not be called, because it is empty"); @@ -465,7 +465,7 @@ LteFfrDistributedAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults found = true; } } - if (found == false) + if (!found) { m_neighborCell.push_back(it->physCellId); } @@ -587,7 +587,10 @@ LteFfrDistributedAlgorithm::Calculate() for (uint16_t i = 0; i < rbgNum; i++) { - metricA[i] += cellIt->second * rntpIt->second[i]; + if (rntpIt->second[i]) + { + metricA[i] += cellIt->second; + } } } @@ -706,21 +709,19 @@ LteFfrDistributedAlgorithm::UpdateNeighbourMeasurements(uint16_t rnti, } NS_ASSERT(it1 != m_ueMeasures.end()); - Ptr cellMeasures; std::map>::iterator it2; it2 = it1->second.find(cellId); if (it2 != it1->second.end()) { - cellMeasures = it2->second; - cellMeasures->m_cellId = cellId; - cellMeasures->m_rsrp = rsrp; - cellMeasures->m_rsrq = rsrq; + it2->second->m_cellId = cellId; + it2->second->m_rsrp = rsrp; + it2->second->m_rsrq = rsrq; } else { // insert a new cell entry - cellMeasures = Create(); + Ptr cellMeasures = Create(); cellMeasures->m_cellId = cellId; cellMeasures->m_rsrp = rsrp; cellMeasures->m_rsrq = rsrq; diff --git a/src/lte/model/lte-ffr-distributed-algorithm.h b/src/lte/model/lte-ffr-distributed-algorithm.h index ca53422ca..ce43217d1 100644 --- a/src/lte/model/lte-ffr-distributed-algorithm.h +++ b/src/lte/model/lte-ffr-distributed-algorithm.h @@ -21,10 +21,10 @@ #ifndef LTE_FFR_DISTRIBUTED_ALGORITHM_H #define LTE_FFR_DISTRIBUTED_ALGORITHM_H -#include -#include -#include -#include +#include "lte-ffr-algorithm.h" +#include "lte-ffr-rrc-sap.h" +#include "lte-ffr-sap.h" +#include "lte-rrc-sap.h" namespace ns3 { @@ -69,9 +69,9 @@ class LteFfrDistributedAlgorithm : public LteFfrAlgorithm std::vector DoGetAvailableUlRbg() override; bool DoIsUlRbgAvailableForUe(int i, uint16_t rnti) override; void DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo(std::map> ulCqiMap) override; uint8_t DoGetTpc(uint16_t rnti) override; uint16_t DoGetMinContinuousUlBandwidth() override; diff --git a/src/lte/model/lte-ffr-enhanced-algorithm.cc b/src/lte/model/lte-ffr-enhanced-algorithm.cc index d56578015..90afde1b6 100644 --- a/src/lte/model/lte-ffr-enhanced-algorithm.cc +++ b/src/lte/model/lte-ffr-enhanced-algorithm.cc @@ -20,10 +20,10 @@ #include "lte-ffr-enhanced-algorithm.h" +#include "ff-mac-common.h" +#include "lte-common.h" + #include "ns3/boolean.h" -#include "ns3/ff-mac-common.h" -#include "ns3/lte-common.h" -#include "ns3/lte-vendor-specific-parameters.h" #include #include @@ -486,7 +486,7 @@ LteFfrEnhancedAlgorithm::DoGetAvailableDlRbg() for (uint32_t i = 0; i < rbgMap.size(); i++) { NS_LOG_INFO("\t rbgId: " << i << " available " << (int)rbgAvailableMap.at(i)); - if (rbgAvailableMap.at(i) == true) + if (rbgAvailableMap.at(i)) { rbgMap.at(i) = false; } @@ -546,7 +546,7 @@ LteFfrEnhancedAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) { NS_LOG_INFO("RNTI: " << rnti << " rbgId: " << rbgId << " available: " << it->second.at(rbgId)); - if (it->second.at(rbgId) == true) + if (it->second.at(rbgId)) { return true; } @@ -582,7 +582,7 @@ LteFfrEnhancedAlgorithm::DoGetAvailableUlRbg() for (uint32_t i = 0; i < rbgMap.size(); i++) { NS_LOG_INFO("\t rbgId: " << i << " available " << (int)rbAvailableMap.at(i)); - if (rbAvailableMap.at(i) == true) + if (rbAvailableMap.at(i)) { rbgMap.at(i) = false; } @@ -646,7 +646,7 @@ LteFfrEnhancedAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) { NS_LOG_INFO("RNTI: " << rnti << " rbgId: " << rbgId << " available: " << it->second.at(rbgId)); - if (it->second.at(rbgId) == true) + if (it->second.at(rbgId)) { return true; } @@ -659,7 +659,7 @@ LteFfrEnhancedAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) void LteFfrEnhancedAlgorithm::DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -732,7 +732,7 @@ LteFfrEnhancedAlgorithm::DoReportDlCqiInfo( isSecondarySegmentRbg = m_dlSecondarySegmentRbgMap[i]; } - rbgAvailable = (isSecondarySegmentRbg == true) ? rbgAvailable : false; + rbgAvailable = (isSecondarySegmentRbg ? rbgAvailable : false); rbgAvailableMap.push_back(rbgAvailable); } @@ -766,7 +766,7 @@ LteFfrEnhancedAlgorithm::DoReportDlCqiInfo( void LteFfrEnhancedAlgorithm::DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); if (params.m_ulCqi.m_type == UlCqi_s::SRS) diff --git a/src/lte/model/lte-ffr-enhanced-algorithm.h b/src/lte/model/lte-ffr-enhanced-algorithm.h index d6a0f2c26..ef2fdb419 100644 --- a/src/lte/model/lte-ffr-enhanced-algorithm.h +++ b/src/lte/model/lte-ffr-enhanced-algorithm.h @@ -21,10 +21,10 @@ #ifndef LTE_FFR_ENHANCED_ALGORITHM_H #define LTE_FFR_ENHANCED_ALGORITHM_H -#include -#include -#include -#include +#include "lte-ffr-algorithm.h" +#include "lte-ffr-rrc-sap.h" +#include "lte-ffr-sap.h" +#include "lte-rrc-sap.h" #include @@ -78,9 +78,9 @@ class LteFfrEnhancedAlgorithm : public LteFfrAlgorithm std::vector DoGetAvailableUlRbg() override; bool DoIsUlRbgAvailableForUe(int i, uint16_t rnti) override; void DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo(std::map> ulCqiMap) override; uint8_t DoGetTpc(uint16_t rnti) override; uint16_t DoGetMinContinuousUlBandwidth() override; diff --git a/src/lte/model/lte-ffr-rrc-sap.h b/src/lte/model/lte-ffr-rrc-sap.h index 662b9588b..e883361e9 100644 --- a/src/lte/model/lte-ffr-rrc-sap.h +++ b/src/lte/model/lte-ffr-rrc-sap.h @@ -21,8 +21,8 @@ #ifndef LTE_FFR_RRC_SAP_H #define LTE_FFR_RRC_SAP_H -#include -#include +#include "epc-x2-sap.h" +#include "lte-rrc-sap.h" namespace ns3 { diff --git a/src/lte/model/lte-ffr-sap.h b/src/lte/model/lte-ffr-sap.h index 6a002f335..a88f541f7 100644 --- a/src/lte/model/lte-ffr-sap.h +++ b/src/lte/model/lte-ffr-sap.h @@ -21,8 +21,7 @@ #ifndef LTE_FFR_SAP_H #define LTE_FFR_SAP_H -#include -#include +#include "ff-mac-sched-sap.h" #include @@ -101,14 +100,14 @@ class LteFfrSapProvider * \param params the struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters */ virtual void ReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) = 0; + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) = 0; /** * \brief ReportUlCqiInfo * \param params the struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters */ virtual void ReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) = 0; + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) = 0; /** * \brief ReportUlCqiInfo @@ -168,10 +167,8 @@ class MemberLteFfrSapProvider : public LteFfrSapProvider bool IsDlRbgAvailableForUe(int i, uint16_t rnti) override; std::vector GetAvailableUlRbg() override; bool IsUlRbgAvailableForUe(int i, uint16_t rnti) override; - void ReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; - void ReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; + void ReportDlCqiInfo(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; + void ReportUlCqiInfo(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; void ReportUlCqiInfo(std::map> ulCqiMap) override; uint8_t GetTpc(uint16_t rnti) override; uint16_t GetMinContinuousUlBandwidth() override; @@ -218,7 +215,7 @@ MemberLteFfrSapProvider::IsUlRbgAvailableForUe(int i, uint16_t rnti) template void MemberLteFfrSapProvider::ReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { m_owner->DoReportDlCqiInfo(params); } @@ -226,7 +223,7 @@ MemberLteFfrSapProvider::ReportDlCqiInfo( template void MemberLteFfrSapProvider::ReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { m_owner->DoReportUlCqiInfo(params); } diff --git a/src/lte/model/lte-ffr-soft-algorithm.cc b/src/lte/model/lte-ffr-soft-algorithm.cc index 157ce1fce..a38ae488c 100644 --- a/src/lte/model/lte-ffr-soft-algorithm.cc +++ b/src/lte/model/lte-ffr-soft-algorithm.cc @@ -521,7 +521,7 @@ LteFfrSoftAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) void LteFfrSoftAlgorithm::DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); NS_LOG_WARN("Method should not be called, because it is empty"); @@ -529,7 +529,7 @@ LteFfrSoftAlgorithm::DoReportDlCqiInfo( void LteFfrSoftAlgorithm::DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); NS_LOG_WARN("Method should not be called, because it is empty"); @@ -601,7 +601,7 @@ LteFfrSoftAlgorithm::DoGetMinContinuousUlBandwidth() for (std::size_t i = 0; i < m_ulCenterRbgMap.size(); i++) { - if (m_ulCenterRbgMap[i] == true) + if (m_ulCenterRbgMap[i]) { centerSubBandwidth++; } @@ -609,7 +609,7 @@ LteFfrSoftAlgorithm::DoGetMinContinuousUlBandwidth() for (std::size_t i = 0; i < m_ulMediumRbgMap.size(); i++) { - if (m_ulMediumRbgMap[i] == true) + if (m_ulMediumRbgMap[i]) { mediumSubBandwidth++; } @@ -617,7 +617,7 @@ LteFfrSoftAlgorithm::DoGetMinContinuousUlBandwidth() for (std::size_t i = 0; i < m_ulEdgeRbgMap.size(); i++) { - if (m_ulEdgeRbgMap[i] == true) + if (m_ulEdgeRbgMap[i]) { edgeSubBandwidth++; } diff --git a/src/lte/model/lte-ffr-soft-algorithm.h b/src/lte/model/lte-ffr-soft-algorithm.h index 663aa2da8..9cc796104 100644 --- a/src/lte/model/lte-ffr-soft-algorithm.h +++ b/src/lte/model/lte-ffr-soft-algorithm.h @@ -21,10 +21,10 @@ #ifndef LTE_FFR_SOFT_ALGORITHM_H #define LTE_FFR_SOFT_ALGORITHM_H -#include -#include -#include -#include +#include "lte-ffr-algorithm.h" +#include "lte-ffr-rrc-sap.h" +#include "lte-ffr-sap.h" +#include "lte-rrc-sap.h" #include @@ -75,9 +75,9 @@ class LteFfrSoftAlgorithm : public LteFfrAlgorithm std::vector DoGetAvailableUlRbg() override; bool DoIsUlRbgAvailableForUe(int i, uint16_t rnti) override; void DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo(std::map> ulCqiMap) override; uint8_t DoGetTpc(uint16_t rnti) override; uint16_t DoGetMinContinuousUlBandwidth() override; diff --git a/src/lte/model/lte-fr-hard-algorithm.cc b/src/lte/model/lte-fr-hard-algorithm.cc index f2525ca1a..e23557f56 100644 --- a/src/lte/model/lte-fr-hard-algorithm.cc +++ b/src/lte/model/lte-fr-hard-algorithm.cc @@ -335,7 +335,7 @@ LteFrHardAlgorithm::DoIsUlRbgAvailableForUe(int rbId, uint16_t rnti) void LteFrHardAlgorithm::DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); NS_LOG_WARN("Method should not be called, because it is empty"); @@ -343,7 +343,7 @@ LteFrHardAlgorithm::DoReportDlCqiInfo( void LteFrHardAlgorithm::DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); NS_LOG_WARN("Method should not be called, because it is empty"); diff --git a/src/lte/model/lte-fr-hard-algorithm.h b/src/lte/model/lte-fr-hard-algorithm.h index d42acf313..b39ae8173 100644 --- a/src/lte/model/lte-fr-hard-algorithm.h +++ b/src/lte/model/lte-fr-hard-algorithm.h @@ -21,10 +21,10 @@ #ifndef LTE_FR_HARD_ALGORITHM_H #define LTE_FR_HARD_ALGORITHM_H -#include -#include -#include -#include +#include "lte-ffr-algorithm.h" +#include "lte-ffr-rrc-sap.h" +#include "lte-ffr-sap.h" +#include "lte-rrc-sap.h" namespace ns3 { @@ -73,9 +73,9 @@ class LteFrHardAlgorithm : public LteFfrAlgorithm std::vector DoGetAvailableUlRbg() override; bool DoIsUlRbgAvailableForUe(int i, uint16_t rnti) override; void DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo(std::map> ulCqiMap) override; uint8_t DoGetTpc(uint16_t rnti) override; uint16_t DoGetMinContinuousUlBandwidth() override; diff --git a/src/lte/model/lte-fr-no-op-algorithm.cc b/src/lte/model/lte-fr-no-op-algorithm.cc index 7cd39e3ae..91c2d6591 100644 --- a/src/lte/model/lte-fr-no-op-algorithm.cc +++ b/src/lte/model/lte-fr-no-op-algorithm.cc @@ -137,7 +137,7 @@ LteFrNoOpAlgorithm::DoIsUlRbgAvailableForUe(int i, uint16_t rnti) void LteFrNoOpAlgorithm::DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); NS_LOG_WARN("Method should not be called, because it is empty"); @@ -145,7 +145,7 @@ LteFrNoOpAlgorithm::DoReportDlCqiInfo( void LteFrNoOpAlgorithm::DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); NS_LOG_WARN("Method should not be called, because it is empty"); diff --git a/src/lte/model/lte-fr-no-op-algorithm.h b/src/lte/model/lte-fr-no-op-algorithm.h index bdf4b3517..e13f1e30d 100644 --- a/src/lte/model/lte-fr-no-op-algorithm.h +++ b/src/lte/model/lte-fr-no-op-algorithm.h @@ -21,10 +21,10 @@ #ifndef LTE_FR_NO_OP_ALGORITHM_H #define LTE_FR_NO_OP_ALGORITHM_H -#include -#include -#include -#include +#include "lte-ffr-algorithm.h" +#include "lte-ffr-rrc-sap.h" +#include "lte-ffr-sap.h" +#include "lte-rrc-sap.h" namespace ns3 { @@ -79,9 +79,9 @@ class LteFrNoOpAlgorithm : public LteFfrAlgorithm std::vector DoGetAvailableUlRbg() override; bool DoIsUlRbgAvailableForUe(int i, uint16_t rnti) override; void DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo(std::map> ulCqiMap) override; uint8_t DoGetTpc(uint16_t rnti) override; uint16_t DoGetMinContinuousUlBandwidth() override; diff --git a/src/lte/model/lte-fr-soft-algorithm.cc b/src/lte/model/lte-fr-soft-algorithm.cc index 9f5d3dcdf..c38e1e886 100644 --- a/src/lte/model/lte-fr-soft-algorithm.cc +++ b/src/lte/model/lte-fr-soft-algorithm.cc @@ -428,7 +428,7 @@ LteFrSoftAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) void LteFrSoftAlgorithm::DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); NS_LOG_WARN("Method should not be called, because it is empty"); @@ -436,7 +436,7 @@ LteFrSoftAlgorithm::DoReportDlCqiInfo( void LteFrSoftAlgorithm::DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); NS_LOG_WARN("Method should not be called, because it is empty"); diff --git a/src/lte/model/lte-fr-soft-algorithm.h b/src/lte/model/lte-fr-soft-algorithm.h index d42da04e1..6524f756b 100644 --- a/src/lte/model/lte-fr-soft-algorithm.h +++ b/src/lte/model/lte-fr-soft-algorithm.h @@ -21,10 +21,10 @@ #ifndef LTE_FR_SOFT_ALGORITHM_H #define LTE_FR_SOFT_ALGORITHM_H -#include -#include -#include -#include +#include "lte-ffr-algorithm.h" +#include "lte-ffr-rrc-sap.h" +#include "lte-ffr-sap.h" +#include "lte-rrc-sap.h" #include @@ -75,9 +75,9 @@ class LteFrSoftAlgorithm : public LteFfrAlgorithm std::vector DoGetAvailableUlRbg() override; bool DoIsUlRbgAvailableForUe(int i, uint16_t rnti) override; void DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo(std::map> ulCqiMap) override; uint8_t DoGetTpc(uint16_t rnti) override; uint16_t DoGetMinContinuousUlBandwidth() override; diff --git a/src/lte/model/lte-fr-strict-algorithm.cc b/src/lte/model/lte-fr-strict-algorithm.cc index cc4dee814..d09a12c07 100644 --- a/src/lte/model/lte-fr-strict-algorithm.cc +++ b/src/lte/model/lte-fr-strict-algorithm.cc @@ -456,7 +456,7 @@ LteFrStrictAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) void LteFrStrictAlgorithm::DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); NS_LOG_WARN("Method should not be called, because it is empty"); @@ -464,7 +464,7 @@ LteFrStrictAlgorithm::DoReportDlCqiInfo( void LteFrStrictAlgorithm::DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); NS_LOG_WARN("Method should not be called, because it is empty"); diff --git a/src/lte/model/lte-fr-strict-algorithm.h b/src/lte/model/lte-fr-strict-algorithm.h index 2b7bc91ee..3f2dbacdb 100644 --- a/src/lte/model/lte-fr-strict-algorithm.h +++ b/src/lte/model/lte-fr-strict-algorithm.h @@ -21,10 +21,10 @@ #ifndef LTE_FR_STRICT_ALGORITHM_H #define LTE_FR_STRICT_ALGORITHM_H -#include -#include -#include -#include +#include "lte-ffr-algorithm.h" +#include "lte-ffr-rrc-sap.h" +#include "lte-ffr-sap.h" +#include "lte-rrc-sap.h" #include @@ -75,9 +75,9 @@ class LteFrStrictAlgorithm : public LteFfrAlgorithm std::vector DoGetAvailableUlRbg() override; bool DoIsUlRbgAvailableForUe(int i, uint16_t rnti) override; void DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo(std::map> ulCqiMap) override; uint8_t DoGetTpc(uint16_t rnti) override; uint16_t DoGetMinContinuousUlBandwidth() override; @@ -141,7 +141,7 @@ class LteFrStrictAlgorithm : public LteFfrAlgorithm }; std::map m_ues; ///< UEs - std::vector m_egdeUes; ///< Edge UEs + std::vector m_edgeUes; ///< Edge UEs uint8_t m_edgeSubBandThreshold; ///< Edge subband threshold diff --git a/src/lte/model/lte-handover-algorithm.h b/src/lte/model/lte-handover-algorithm.h index 29a90caee..714dc508e 100644 --- a/src/lte/model/lte-handover-algorithm.h +++ b/src/lte/model/lte-handover-algorithm.h @@ -21,7 +21,8 @@ #ifndef LTE_HANDOVER_ALGORITHM_H #define LTE_HANDOVER_ALGORITHM_H -#include +#include "lte-rrc-sap.h" + #include namespace ns3 diff --git a/src/lte/model/lte-handover-management-sap.h b/src/lte/model/lte-handover-management-sap.h index 6487fafe5..fe093e758 100644 --- a/src/lte/model/lte-handover-management-sap.h +++ b/src/lte/model/lte-handover-management-sap.h @@ -21,7 +21,7 @@ #ifndef LTE_HANDOVER_MANAGEMENT_SAP_H #define LTE_HANDOVER_MANAGEMENT_SAP_H -#include +#include "lte-rrc-sap.h" namespace ns3 { diff --git a/src/lte/model/lte-harq-phy.cc b/src/lte/model/lte-harq-phy.cc index dc5ae883f..921a75bd1 100644 --- a/src/lte/model/lte-harq-phy.cc +++ b/src/lte/model/lte-harq-phy.cc @@ -17,9 +17,10 @@ * Author: Marco Miozzo */ +#include "lte-harq-phy.h" + #include #include -#include namespace ns3 { diff --git a/src/lte/model/lte-interference.cc b/src/lte/model/lte-interference.cc index 35c6efd44..8e332ebe8 100644 --- a/src/lte/model/lte-interference.cc +++ b/src/lte/model/lte-interference.cc @@ -66,7 +66,7 @@ void LteInterference::StartRx(Ptr rxPsd) { NS_LOG_FUNCTION(this << *rxPsd); - if (m_receiving == false) + if (!m_receiving) { NS_LOG_LOGIC("first signal"); m_rxSignal = rxPsd->Copy(); @@ -109,7 +109,7 @@ void LteInterference::EndRx() { NS_LOG_FUNCTION(this); - if (m_receiving != true) + if (!m_receiving) { NS_LOG_INFO("EndRx was already evaluated or RX was aborted"); } @@ -235,7 +235,7 @@ LteInterference::SetNoisePowerSpectralDensity(Ptr noisePsd) // reset m_allSignals (will reset if already set previously) // this is needed since this method can potentially change the SpectrumModel m_allSignals = Create(noisePsd->GetSpectrumModel()); - if (m_receiving == true) + if (m_receiving) { // abort rx m_receiving = false; diff --git a/src/lte/model/lte-mac-sap.cc b/src/lte/model/lte-mac-sap.cc index 80a1df5b3..c5a5192d5 100644 --- a/src/lte/model/lte-mac-sap.cc +++ b/src/lte/model/lte-mac-sap.cc @@ -17,7 +17,7 @@ * Author: Nicola Baldo */ -#include "ns3/lte-mac-sap.h" +#include "lte-mac-sap.h" namespace ns3 { diff --git a/src/lte/model/lte-mi-error-model.cc b/src/lte/model/lte-mi-error-model.cc index 125970245..946042da0 100644 --- a/src/lte/model/lte-mi-error-model.cc +++ b/src/lte/model/lte-mi-error-model.cc @@ -28,15 +28,15 @@ * Marco Miozzo */ -#include "stdlib.h" +#include "lte-mi-error-model.h" #include -#include #include #include #include #include +#include #include namespace ns3 diff --git a/src/lte/model/lte-mi-error-model.h b/src/lte/model/lte-mi-error-model.h index 18dabe690..5c7cbcf98 100644 --- a/src/lte/model/lte-mi-error-model.h +++ b/src/lte/model/lte-mi-error-model.h @@ -31,7 +31,8 @@ #ifndef LTE_MI_ERROR_MODEL_H #define LTE_MI_ERROR_MODEL_H -#include +#include "lte-harq-phy.h" + #include #include diff --git a/src/lte/model/lte-net-device.cc b/src/lte/model/lte-net-device.cc index e59891114..c159eadbc 100644 --- a/src/lte/model/lte-net-device.cc +++ b/src/lte/model/lte-net-device.cc @@ -20,9 +20,8 @@ #include "lte-net-device.h" -#include "lte-amc.h" - #include "ns3/callback.h" +#include "ns3/channel.h" #include "ns3/enum.h" #include "ns3/ipv4-header.h" #include "ns3/ipv6-header.h" @@ -37,7 +36,6 @@ #include #include #include -#include namespace ns3 { diff --git a/src/lte/model/lte-net-device.h b/src/lte/model/lte-net-device.h index f4a319692..eddaaa2e5 100644 --- a/src/lte/model/lte-net-device.h +++ b/src/lte/model/lte-net-device.h @@ -22,8 +22,6 @@ #define LTE_NET_DEVICE_H #include -#include -#include #include #include #include diff --git a/src/lte/model/lte-pdcp-header.cc b/src/lte/model/lte-pdcp-header.cc index ee996520a..09f29b6eb 100644 --- a/src/lte/model/lte-pdcp-header.cc +++ b/src/lte/model/lte-pdcp-header.cc @@ -17,7 +17,7 @@ * Author: Manuel Requena */ -#include "ns3/lte-pdcp-header.h" +#include "lte-pdcp-header.h" #include "ns3/log.h" diff --git a/src/lte/model/lte-pdcp-sap.cc b/src/lte/model/lte-pdcp-sap.cc index f67b61590..7d75bd95f 100644 --- a/src/lte/model/lte-pdcp-sap.cc +++ b/src/lte/model/lte-pdcp-sap.cc @@ -17,7 +17,7 @@ * Author: Manuel Requena */ -#include "ns3/lte-pdcp-sap.h" +#include "lte-pdcp-sap.h" namespace ns3 { diff --git a/src/lte/model/lte-pdcp.cc b/src/lte/model/lte-pdcp.cc index e77bf4e58..e970535f1 100644 --- a/src/lte/model/lte-pdcp.cc +++ b/src/lte/model/lte-pdcp.cc @@ -17,12 +17,13 @@ * Author: Manuel Requena */ -#include "ns3/lte-pdcp.h" +#include "lte-pdcp.h" + +#include "lte-pdcp-header.h" +#include "lte-pdcp-sap.h" +#include "lte-pdcp-tag.h" #include "ns3/log.h" -#include "ns3/lte-pdcp-header.h" -#include "ns3/lte-pdcp-sap.h" -#include "ns3/lte-pdcp-tag.h" #include "ns3/simulator.h" namespace ns3 diff --git a/src/lte/model/lte-pdcp.h b/src/lte/model/lte-pdcp.h index 41717fe3d..282591162 100644 --- a/src/lte/model/lte-pdcp.h +++ b/src/lte/model/lte-pdcp.h @@ -20,8 +20,9 @@ #ifndef LTE_PDCP_H #define LTE_PDCP_H -#include "ns3/lte-pdcp-sap.h" -#include "ns3/lte-rlc-sap.h" +#include "lte-pdcp-sap.h" +#include "lte-rlc-sap.h" + #include "ns3/object.h" #include "ns3/trace-source-accessor.h" #include "ns3/traced-value.h" diff --git a/src/lte/model/lte-phy.cc b/src/lte/model/lte-phy.cc index d7c3b8c52..e259250cb 100644 --- a/src/lte/model/lte-phy.cc +++ b/src/lte/model/lte-phy.cc @@ -20,6 +20,7 @@ #include "lte-phy.h" +#include "lte-control-messages.h" #include "lte-net-device.h" #include "ns3/spectrum-error-model.h" diff --git a/src/lte/model/lte-phy.h b/src/lte/model/lte-phy.h index 24b1874f1..736388c82 100644 --- a/src/lte/model/lte-phy.h +++ b/src/lte/model/lte-phy.h @@ -22,8 +22,9 @@ #ifndef LTE_PHY_H #define LTE_PHY_H +#include "lte-spectrum-phy.h" + #include -#include #include #include #include diff --git a/src/lte/model/lte-radio-bearer-info.cc b/src/lte/model/lte-radio-bearer-info.cc index 2d86a4a4c..f7fbded2e 100644 --- a/src/lte/model/lte-radio-bearer-info.cc +++ b/src/lte/model/lte-radio-bearer-info.cc @@ -21,7 +21,6 @@ #include "lte-pdcp.h" #include "lte-rlc.h" -#include "lte-ue-rrc.h" #include diff --git a/src/lte/model/lte-radio-bearer-info.h b/src/lte/model/lte-radio-bearer-info.h index f7c881aec..e7fa25862 100644 --- a/src/lte/model/lte-radio-bearer-info.h +++ b/src/lte/model/lte-radio-bearer-info.h @@ -20,9 +20,10 @@ #ifndef LTE_RADIO_BEARER_INFO_H #define LTE_RADIO_BEARER_INFO_H -#include +#include "eps-bearer.h" +#include "lte-rrc-sap.h" + #include -#include #include #include diff --git a/src/lte/model/lte-rlc-am-header.cc b/src/lte/model/lte-rlc-am-header.cc index 4fa417275..56a476ee6 100644 --- a/src/lte/model/lte-rlc-am-header.cc +++ b/src/lte/model/lte-rlc-am-header.cc @@ -17,7 +17,7 @@ * Author: Manuel Requena */ -#include "ns3/lte-rlc-am-header.h" +#include "lte-rlc-am-header.h" #include "ns3/log.h" diff --git a/src/lte/model/lte-rlc-am-header.h b/src/lte/model/lte-rlc-am-header.h index 22fbb674d..4ddc99802 100644 --- a/src/lte/model/lte-rlc-am-header.h +++ b/src/lte/model/lte-rlc-am-header.h @@ -20,8 +20,9 @@ #ifndef LTE_RLC_AM_HEADER_H #define LTE_RLC_AM_HEADER_H +#include "lte-rlc-sequence-number.h" + #include "ns3/header.h" -#include "ns3/lte-rlc-sequence-number.h" #include @@ -73,11 +74,8 @@ class LteRlcAmHeader : public Header DATA_PDU = 1 }; - /// ControlPduType_t enumeration - enum ControPduType_t - { - STATUS_PDU = 000, - }; + /// Control PDU type status + static constexpr uint8_t STATUS_PDU{0}; // // DATA PDU diff --git a/src/lte/model/lte-rlc-am.cc b/src/lte/model/lte-rlc-am.cc index 922a82e4c..d4e8ffc14 100644 --- a/src/lte/model/lte-rlc-am.cc +++ b/src/lte/model/lte-rlc-am.cc @@ -18,12 +18,13 @@ * Nicola Baldo */ -#include "ns3/lte-rlc-am.h" +#include "lte-rlc-am.h" + +#include "lte-rlc-am-header.h" +#include "lte-rlc-sdu-status-tag.h" +#include "lte-rlc-tag.h" #include "ns3/log.h" -#include "ns3/lte-rlc-am-header.h" -#include "ns3/lte-rlc-sdu-status-tag.h" -#include "ns3/lte-rlc-tag.h" #include "ns3/simulator.h" namespace ns3 diff --git a/src/lte/model/lte-rlc-am.h b/src/lte/model/lte-rlc-am.h index 5db362f78..0e9d533ba 100644 --- a/src/lte/model/lte-rlc-am.h +++ b/src/lte/model/lte-rlc-am.h @@ -20,9 +20,10 @@ #ifndef LTE_RLC_AM_H #define LTE_RLC_AM_H +#include "lte-rlc-sequence-number.h" +#include "lte-rlc.h" + #include -#include -#include #include #include diff --git a/src/lte/model/lte-rlc-header.cc b/src/lte/model/lte-rlc-header.cc index adeea5e68..5ed1b6f65 100644 --- a/src/lte/model/lte-rlc-header.cc +++ b/src/lte/model/lte-rlc-header.cc @@ -17,7 +17,7 @@ * Author: Manuel Requena */ -#include "ns3/lte-rlc-header.h" +#include "lte-rlc-header.h" #include "ns3/log.h" diff --git a/src/lte/model/lte-rlc-header.h b/src/lte/model/lte-rlc-header.h index 16704bb2c..a107f4ed2 100644 --- a/src/lte/model/lte-rlc-header.h +++ b/src/lte/model/lte-rlc-header.h @@ -20,8 +20,9 @@ #ifndef LTE_RLC_HEADER_H #define LTE_RLC_HEADER_H +#include "lte-rlc-sequence-number.h" + #include "ns3/header.h" -#include "ns3/lte-rlc-sequence-number.h" #include diff --git a/src/lte/model/lte-rlc-sap.cc b/src/lte/model/lte-rlc-sap.cc index 9ff4cf8cf..902b4d3d6 100644 --- a/src/lte/model/lte-rlc-sap.cc +++ b/src/lte/model/lte-rlc-sap.cc @@ -17,7 +17,7 @@ * Author: Manuel Requena */ -#include "ns3/lte-rlc-sap.h" +#include "lte-rlc-sap.h" namespace ns3 { diff --git a/src/lte/model/lte-rlc-sdu-status-tag.cc b/src/lte/model/lte-rlc-sdu-status-tag.cc index 89a4dca73..10532adce 100644 --- a/src/lte/model/lte-rlc-sdu-status-tag.cc +++ b/src/lte/model/lte-rlc-sdu-status-tag.cc @@ -17,7 +17,7 @@ * Author: Manuel Requena */ -#include "ns3/lte-rlc-sdu-status-tag.h" +#include "lte-rlc-sdu-status-tag.h" namespace ns3 { diff --git a/src/lte/model/lte-rlc-sequence-number.h b/src/lte/model/lte-rlc-sequence-number.h index 6d8733836..b2b049535 100644 --- a/src/lte/model/lte-rlc-sequence-number.h +++ b/src/lte/model/lte-rlc-sequence-number.h @@ -26,8 +26,6 @@ #include #include -// #include "ns3/lte-rlc.h" - namespace ns3 { diff --git a/src/lte/model/lte-rlc-tm.cc b/src/lte/model/lte-rlc-tm.cc index f794e8072..6cc137870 100644 --- a/src/lte/model/lte-rlc-tm.cc +++ b/src/lte/model/lte-rlc-tm.cc @@ -18,7 +18,7 @@ * Nicola Baldo */ -#include "ns3/lte-rlc-tm.h" +#include "lte-rlc-tm.h" #include "ns3/log.h" #include "ns3/simulator.h" diff --git a/src/lte/model/lte-rlc-tm.h b/src/lte/model/lte-rlc-tm.h index 4683d2d49..f48819ca2 100644 --- a/src/lte/model/lte-rlc-tm.h +++ b/src/lte/model/lte-rlc-tm.h @@ -21,7 +21,8 @@ #ifndef LTE_RLC_TM_H #define LTE_RLC_TM_H -#include "ns3/lte-rlc.h" +#include "lte-rlc.h" + #include #include diff --git a/src/lte/model/lte-rlc-um.cc b/src/lte/model/lte-rlc-um.cc index 79eb09878..e25debe22 100644 --- a/src/lte/model/lte-rlc-um.cc +++ b/src/lte/model/lte-rlc-um.cc @@ -17,12 +17,13 @@ * Author: Manuel Requena */ -#include "ns3/lte-rlc-um.h" +#include "lte-rlc-um.h" + +#include "lte-rlc-header.h" +#include "lte-rlc-sdu-status-tag.h" +#include "lte-rlc-tag.h" #include "ns3/log.h" -#include "ns3/lte-rlc-header.h" -#include "ns3/lte-rlc-sdu-status-tag.h" -#include "ns3/lte-rlc-tag.h" #include "ns3/simulator.h" namespace ns3 @@ -68,7 +69,21 @@ LteRlcUm::GetTypeId() "Value of the t-Reordering timer (See section 7.3 of 3GPP TS 36.322)", TimeValue(MilliSeconds(100)), MakeTimeAccessor(&LteRlcUm::m_reorderingTimerValue), - MakeTimeChecker()); + MakeTimeChecker()) + .AddAttribute( + "EnablePdcpDiscarding", + "Whether to use the PDCP discarding, i.e., perform discarding at the moment " + "of passing the PDCP SDU to RLC)", + BooleanValue(true), + MakeBooleanAccessor(&LteRlcUm::m_enablePdcpDiscarding), + MakeBooleanChecker()) + .AddAttribute("DiscardTimerMs", + "Discard timer in milliseconds to be used to discard packets. " + "If set to 0 then packet delay budget will be used as the discard " + "timer value, otherwise it will be used this value.", + UintegerValue(0), + MakeUintegerAccessor(&LteRlcUm::m_discardTimerMs), + MakeUintegerChecker()); return tid; } @@ -93,6 +108,29 @@ LteRlcUm::DoTransmitPdcpPdu(Ptr p) if (m_txBufferSize + p->GetSize() <= m_maxTxBufferSize) { + if (m_enablePdcpDiscarding) + { + // discart the packet + uint32_t headOfLineDelayInMs = 0; + uint32_t discardTimerMs = + (m_discardTimerMs > 0) ? m_discardTimerMs : m_packetDelayBudgetMs; + + if (!m_txBuffer.empty()) + { + headOfLineDelayInMs = + (Simulator::Now() - m_txBuffer.begin()->m_waitingSince).GetMilliSeconds(); + } + 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_DEBUG("headOfLineDelayInMs = " << headOfLineDelayInMs); + NS_LOG_DEBUG("m_packetDelayBudgetMs = " << m_packetDelayBudgetMs); + NS_LOG_DEBUG("packet size = " << p->GetSize()); + m_txDropTrace(p); + } + } + /** Store PDCP PDU */ LteRlcSduStatusTag tag; tag.SetStatus(LteRlcSduStatusTag::FULL_SDU); diff --git a/src/lte/model/lte-rlc-um.h b/src/lte/model/lte-rlc-um.h index cd3566f0e..8c544cba8 100644 --- a/src/lte/model/lte-rlc-um.h +++ b/src/lte/model/lte-rlc-um.h @@ -20,8 +20,9 @@ #ifndef LTE_RLC_UM_H #define LTE_RLC_UM_H -#include "ns3/lte-rlc-sequence-number.h" -#include "ns3/lte-rlc.h" +#include "lte-rlc-sequence-number.h" +#include "lte-rlc.h" + #include #include @@ -143,9 +144,12 @@ class LteRlcUm : public LteRlc /** * Timers. See section 7.3 in TS 36.322 */ - Time m_reorderingTimerValue; ///< reordering timer value - EventId m_reorderingTimer; ///< reordering timer - EventId m_rbsTimer; ///< RBS timer + Time m_reorderingTimerValue; ///< reordering timer value + EventId m_reorderingTimer; ///< reordering timer + EventId m_rbsTimer; ///< RBS timer + bool m_enablePdcpDiscarding{false}; //!< whether to use the PDCP discarding (perform discarding + //!< at the moment of passing the PDCP SDU to RLC) + uint32_t m_discardTimerMs{0}; //!< the discard timer value in milliseconds /** * Reassembling state diff --git a/src/lte/model/lte-rlc.cc b/src/lte/model/lte-rlc.cc index b5e9cf5b5..653c89e2a 100644 --- a/src/lte/model/lte-rlc.cc +++ b/src/lte/model/lte-rlc.cc @@ -17,15 +17,15 @@ * Author: Nicola Baldo */ -#include "ns3/lte-rlc.h" +#include "lte-rlc.h" + +#include "lte-rlc-sap.h" +#include "lte-rlc-tag.h" +// #include "lte-mac-sap.h" +// #include "ff-mac-sched-sap.h" #include "ns3/log.h" -#include "ns3/lte-rlc-tag.h" #include "ns3/simulator.h" -// #include "lte-mac-sap.h" -#include "ns3/lte-rlc-sap.h" - -// #include "ff-mac-sched-sap.h" namespace ns3 { @@ -144,6 +144,13 @@ LteRlc::SetLcId(uint8_t lcId) m_lcid = lcId; } +void +LteRlc::SetPacketDelayBudgetMs(uint16_t packetDelayBudget) +{ + NS_LOG_FUNCTION(this << +packetDelayBudget); + m_packetDelayBudgetMs = packetDelayBudget; +} + void LteRlc::SetLteRlcSapUser(LteRlcSapUser* s) { diff --git a/src/lte/model/lte-rlc.h b/src/lte/model/lte-rlc.h index ee45fee8a..0283992df 100644 --- a/src/lte/model/lte-rlc.h +++ b/src/lte/model/lte-rlc.h @@ -20,8 +20,9 @@ #ifndef LTE_RLC_H #define LTE_RLC_H -#include "ns3/lte-mac-sap.h" -#include "ns3/lte-rlc-sap.h" +#include "lte-mac-sap.h" +#include "lte-rlc-sap.h" + #include "ns3/nstime.h" #include "ns3/object.h" #include "ns3/trace-source-accessor.h" @@ -75,6 +76,11 @@ class LteRlc : public Object // SimpleRefCount */ void SetLcId(uint8_t lcId); + /** + * \param packetDelayBudget + */ + void SetPacketDelayBudgetMs(uint16_t packetDelayBudget); + /** * * @@ -165,6 +171,8 @@ class LteRlc : public Object // SimpleRefCount uint16_t m_rnti; ///< RNTI uint8_t m_lcid; ///< LCID + uint16_t m_packetDelayBudgetMs{ + UINT16_MAX}; //!< the packet delay budget in ms of the corresponding logical channel /** * Used to inform of a PDU delivery to the MAC SAP provider diff --git a/src/lte/model/lte-rrc-header.cc b/src/lte/model/lte-rrc-header.cc index 5319bb473..81add7473 100644 --- a/src/lte/model/lte-rrc-header.cc +++ b/src/lte/model/lte-rrc-header.cc @@ -20,7 +20,7 @@ * Biljana Bojovic (Carrier Aggregation) */ -#include "ns3/lte-rrc-header.h" +#include "lte-rrc-header.h" #include "ns3/log.h" @@ -1934,7 +1934,7 @@ RrcAsn1Header::SerializeRadioResourceConfigCommonSCell( SerializeInteger(rrccsc.ulConfiguration.ulFreqInfo.ulCarrierFreq, 0, MAX_EARFCN); SerializeInteger(rrccsc.ulConfiguration.ulFreqInfo.ulBandwidth, 6, 100); - // Serialize UlPowerControllCommonSCell + // Serialize UlPowerControlCommonSCell std::bitset<2> UlPowerControlCommonSCell_r10; UlPowerControlCommonSCell_r10.set(1, 0); // p0-NominalPUSCH-r10 Not Implemented UlPowerControlCommonSCell_r10.set(0, 1); // alpha @@ -5384,7 +5384,7 @@ RrcConnectionReconfigurationHeader::PreSerialize() const // Serialize t304 SerializeEnum(8, 0); - // Serialize newUE-Identitiy + // Serialize newUE-Identity SerializeBitstring(std::bitset<16>(m_mobilityControlInfo.newUeIdentity)); // Serialize radioResourceConfigCommon @@ -6258,7 +6258,7 @@ RrcConnectionReestablishmentRequestHeader::PreSerialize() const SerializeUlCcchMessage(0); - // Serialize RrcConnectionReestablishmentReques sequence: + // Serialize RrcConnectionReestablishmentRequest sequence: // no default or optional fields. Extension marker not present. SerializeSequence(std::bitset<0>(), false); diff --git a/src/lte/model/lte-rrc-header.h b/src/lte/model/lte-rrc-header.h index 342f219fc..48c99acfd 100644 --- a/src/lte/model/lte-rrc-header.h +++ b/src/lte/model/lte-rrc-header.h @@ -23,9 +23,10 @@ #ifndef RRC_HEADER_H #define RRC_HEADER_H +#include "lte-asn1-header.h" +#include "lte-rrc-sap.h" + #include "ns3/header.h" -#include "ns3/lte-asn1-header.h" -#include "ns3/lte-rrc-sap.h" #include #include diff --git a/src/lte/model/lte-rrc-protocol-ideal.h b/src/lte/model/lte-rrc-protocol-ideal.h index 979fc4462..ca37f75e1 100644 --- a/src/lte/model/lte-rrc-protocol-ideal.h +++ b/src/lte/model/lte-rrc-protocol-ideal.h @@ -20,7 +20,8 @@ #ifndef LTE_RRC_PROTOCOL_IDEAL_H #define LTE_RRC_PROTOCOL_IDEAL_H -#include +#include "lte-rrc-sap.h" + #include #include diff --git a/src/lte/model/lte-rrc-protocol-real.cc b/src/lte/model/lte-rrc-protocol-real.cc index 61564eded..13d67cd2c 100644 --- a/src/lte/model/lte-rrc-protocol-real.cc +++ b/src/lte/model/lte-rrc-protocol-real.cc @@ -22,6 +22,7 @@ #include "lte-enb-net-device.h" #include "lte-enb-rrc.h" +#include "lte-rrc-header.h" #include "lte-ue-net-device.h" #include "lte-ue-rrc.h" diff --git a/src/lte/model/lte-rrc-protocol-real.h b/src/lte/model/lte-rrc-protocol-real.h index 098fb755c..55ec197d0 100644 --- a/src/lte/model/lte-rrc-protocol-real.h +++ b/src/lte/model/lte-rrc-protocol-real.h @@ -21,10 +21,10 @@ #ifndef LTE_RRC_PROTOCOL_REAL_H #define LTE_RRC_PROTOCOL_REAL_H -#include -#include -#include -#include +#include "lte-pdcp-sap.h" +#include "lte-rlc-sap.h" +#include "lte-rrc-sap.h" + #include #include diff --git a/src/lte/model/lte-spectrum-phy.cc b/src/lte/model/lte-spectrum-phy.cc index 2c0840601..680969b6b 100644 --- a/src/lte/model/lte-spectrum-phy.cc +++ b/src/lte/model/lte-spectrum-phy.cc @@ -22,8 +22,8 @@ #include "lte-spectrum-phy.h" #include "lte-chunk-processor.h" -#include "lte-net-device.h" -#include "lte-phy-tag.h" +#include "lte-control-messages.h" +#include "lte-mi-error-model.h" #include "lte-radio-bearer-tag.h" #include "lte-spectrum-signal-parameters.h" @@ -32,8 +32,6 @@ #include #include #include -#include -#include #include #include #include @@ -458,12 +456,10 @@ LteSpectrumPhy::StartTxDataFrame(Ptr pb, m_endTxEvent = Simulator::Schedule(duration, &LteSpectrumPhy::EndTxData, this); } return false; - break; default: NS_FATAL_ERROR("unknown state"); return true; - break; } } @@ -516,12 +512,10 @@ LteSpectrumPhy::StartTxDlCtrlFrame(std::list> ctrlMsgList m_endTxEvent = Simulator::Schedule(DL_CTRL_DURATION, &LteSpectrumPhy::EndTxDlCtrl, this); } return false; - break; default: NS_FATAL_ERROR("unknown state"); return true; - break; } } @@ -572,12 +566,10 @@ LteSpectrumPhy::StartTxUlSrsFrame() m_endTxEvent = Simulator::Schedule(UL_SRS_DURATION, &LteSpectrumPhy::EndTxUlSrs, this); } return false; - break; default: NS_FATAL_ERROR("unknown state"); return true; - break; } } @@ -764,7 +756,7 @@ LteSpectrumPhy::StartRxDlCtrl(Ptr lteDlC // common code for the two states // check presence of PSS for UE measuerements - if (lteDlCtrlRxParams->pss == true) + if (lteDlCtrlRxParams->pss) { if (!m_ltePhyRxPssCallback.IsNull()) { diff --git a/src/lte/model/lte-spectrum-phy.h b/src/lte/model/lte-spectrum-phy.h index 16ec2c090..45411e54a 100644 --- a/src/lte/model/lte-spectrum-phy.h +++ b/src/lte/model/lte-spectrum-phy.h @@ -22,19 +22,20 @@ #ifndef LTE_SPECTRUM_PHY_H #define LTE_SPECTRUM_PHY_H -#include "ns3/random-variable-stream.h" +#include "ff-mac-common.h" +#include "lte-common.h" +#include "lte-harq-phy.h" +#include "lte-interference.h" + #include #include -#include #include -#include -#include -#include #include #include #include #include #include +#include #include #include #include diff --git a/src/lte/model/lte-spectrum-signal-parameters.cc b/src/lte/model/lte-spectrum-signal-parameters.cc index 99a891669..1d9218f9f 100644 --- a/src/lte/model/lte-spectrum-signal-parameters.cc +++ b/src/lte/model/lte-spectrum-signal-parameters.cc @@ -18,9 +18,11 @@ * Modified by Marco Miozzo (add data and ctrl diversity) */ +#include "lte-spectrum-signal-parameters.h" + +#include "lte-control-messages.h" + #include -#include -#include #include #include diff --git a/src/lte/model/lte-spectrum-signal-parameters.h b/src/lte/model/lte-spectrum-signal-parameters.h index 35f5c5fb2..2159614d9 100644 --- a/src/lte/model/lte-spectrum-signal-parameters.h +++ b/src/lte/model/lte-spectrum-signal-parameters.h @@ -23,6 +23,8 @@ #include +#include + namespace ns3 { diff --git a/src/lte/model/lte-ue-ccm-rrc-sap.h b/src/lte/model/lte-ue-ccm-rrc-sap.h index f67b40fc8..550bf438b 100644 --- a/src/lte/model/lte-ue-ccm-rrc-sap.h +++ b/src/lte/model/lte-ue-ccm-rrc-sap.h @@ -21,10 +21,8 @@ #ifndef LTE_UE_CCM_RRC_SAP_H #define LTE_UE_CCM_RRC_SAP_H -#include -#include -#include -#include +#include "lte-mac-sap.h" +#include "lte-ue-cmac-sap.h" #include diff --git a/src/lte/model/lte-ue-cmac-sap.h b/src/lte/model/lte-ue-cmac-sap.h index 20bdbc660..dc47aeaf3 100644 --- a/src/lte/model/lte-ue-cmac-sap.h +++ b/src/lte/model/lte-ue-cmac-sap.h @@ -20,9 +20,6 @@ #ifndef LTE_UE_CMAC_SAP_H #define LTE_UE_CMAC_SAP_H -#include -#include -#include #include namespace ns3 diff --git a/src/lte/model/lte-ue-component-carrier-manager.cc b/src/lte/model/lte-ue-component-carrier-manager.cc index 03ba88af9..7cfc28b95 100644 --- a/src/lte/model/lte-ue-component-carrier-manager.cc +++ b/src/lte/model/lte-ue-component-carrier-manager.cc @@ -20,6 +20,8 @@ #include "lte-ue-component-carrier-manager.h" +#include "lte-common.h" + #include namespace ns3 diff --git a/src/lte/model/lte-ue-component-carrier-manager.h b/src/lte/model/lte-ue-component-carrier-manager.h index 52c116ee4..d4ff3bbea 100644 --- a/src/lte/model/lte-ue-component-carrier-manager.h +++ b/src/lte/model/lte-ue-component-carrier-manager.h @@ -21,17 +21,14 @@ #ifndef LTE_UE_COMPONENT_CARRIER_MANAGER_H #define LTE_UE_COMPONENT_CARRIER_MANAGER_H -#include -#include -#include +#include "lte-mac-sap.h" +#include "lte-ue-ccm-rrc-sap.h" + #include #include #include -#define MIN_NO_CC 1 -#define MAX_NO_CC 5 // this is the maximum number of carrier components allowed by 3GPP up to R13 - namespace ns3 { diff --git a/src/lte/model/lte-ue-cphy-sap.cc b/src/lte/model/lte-ue-cphy-sap.cc index 627c66056..6a01b343f 100644 --- a/src/lte/model/lte-ue-cphy-sap.cc +++ b/src/lte/model/lte-ue-cphy-sap.cc @@ -17,7 +17,7 @@ * Author: Nicola Baldo */ -#include "ns3/lte-ue-cphy-sap.h" +#include "lte-ue-cphy-sap.h" namespace ns3 { diff --git a/src/lte/model/lte-ue-cphy-sap.h b/src/lte/model/lte-ue-cphy-sap.h index c8af203ce..f59814e3a 100644 --- a/src/lte/model/lte-ue-cphy-sap.h +++ b/src/lte/model/lte-ue-cphy-sap.h @@ -21,7 +21,8 @@ #ifndef LTE_UE_CPHY_SAP_H #define LTE_UE_CPHY_SAP_H -#include +#include "lte-rrc-sap.h" + #include #include @@ -194,7 +195,7 @@ class LteUeCphySapProvider * started by checking if the radio frames are in-sync for N311 * consecutive times. */ - virtual void StartInSnycDetection() = 0; + virtual void StartInSyncDetection() = 0; /** * \brief A method call by UE RRC to communicate the IMSI to the UE PHY @@ -231,8 +232,8 @@ class LteUeCphySapUser /// UeMeasurementsParameters structure struct UeMeasurementsParameters { - std::vector m_ueMeasurementsList; ///< UE measurement list - uint8_t m_componentCarrierId; ///< component carrier ID + std::vector m_ueMeasurementsList; ///< UE measurement list + uint8_t m_componentCarrierId; ///< component carrier ID }; /** @@ -327,7 +328,7 @@ class MemberLteUeCphySapProvider : public LteUeCphySapProvider void SetRsrpFilterCoefficient(uint8_t rsrpFilterCoefficient) override; void ResetPhyAfterRlf() override; void ResetRlfParams() override; - void StartInSnycDetection() override; + void StartInSyncDetection() override; void SetImsi(uint64_t imsi) override; private: @@ -454,9 +455,9 @@ MemberLteUeCphySapProvider::ResetRlfParams() template void -MemberLteUeCphySapProvider::StartInSnycDetection() +MemberLteUeCphySapProvider::StartInSyncDetection() { - m_owner->DoStartInSnycDetection(); + m_owner->DoStartInSyncDetection(); } template diff --git a/src/lte/model/lte-ue-mac.cc b/src/lte/model/lte-ue-mac.cc index 9ef09f5c6..5518f3dec 100644 --- a/src/lte/model/lte-ue-mac.cc +++ b/src/lte/model/lte-ue-mac.cc @@ -20,13 +20,12 @@ #include "lte-ue-mac.h" +#include "ff-mac-common.h" +#include "lte-common.h" +#include "lte-control-messages.h" #include "lte-radio-bearer-tag.h" -#include "lte-ue-net-device.h" -#include #include -#include -#include #include #include #include @@ -921,7 +920,7 @@ LteUeMac::DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo) m_frameNo = frameNo; m_subframeNo = subframeNo; RefreshHarqProcessesPacketBuffer(); - if ((Simulator::Now() >= m_bsrLast + m_bsrPeriodicity) && (m_freshUlBsr == true)) + if ((Simulator::Now() >= m_bsrLast + m_bsrPeriodicity) && m_freshUlBsr) { if (m_componentCarrierId == 0) { diff --git a/src/lte/model/lte-ue-mac.h b/src/lte/model/lte-ue-mac.h index 4cd3eda1e..c9608880f 100644 --- a/src/lte/model/lte-ue-mac.h +++ b/src/lte/model/lte-ue-mac.h @@ -21,10 +21,12 @@ #ifndef LTE_UE_MAC_ENTITY_H #define LTE_UE_MAC_ENTITY_H +#include "ff-mac-common.h" +#include "lte-mac-sap.h" +#include "lte-ue-cmac-sap.h" +#include "lte-ue-phy-sap.h" + #include -#include -#include -#include #include #include #include diff --git a/src/lte/model/lte-ue-net-device.cc b/src/lte/model/lte-ue-net-device.cc index f02206d1e..eb21cf1d2 100644 --- a/src/lte/model/lte-ue-net-device.cc +++ b/src/lte/model/lte-ue-net-device.cc @@ -24,10 +24,10 @@ #include "lte-ue-net-device.h" -#include "epc-tft.h" #include "epc-ue-nas.h" -#include "lte-amc.h" +#include "lte-enb-net-device.h" #include "lte-net-device.h" +#include "lte-ue-component-carrier-manager.h" #include "lte-ue-mac.h" #include "lte-ue-phy.h" #include "lte-ue-rrc.h" @@ -39,7 +39,6 @@ #include "ns3/ipv6-header.h" #include "ns3/ipv6.h" #include "ns3/llc-snap-header.h" -#include "ns3/lte-enb-net-device.h" #include "ns3/node.h" #include "ns3/packet-burst.h" #include "ns3/packet.h" @@ -50,7 +49,6 @@ #include #include #include -#include #include #include diff --git a/src/lte/model/lte-ue-net-device.h b/src/lte/model/lte-ue-net-device.h index 9c938ddd3..143cff654 100644 --- a/src/lte/model/lte-ue-net-device.h +++ b/src/lte/model/lte-ue-net-device.h @@ -24,11 +24,10 @@ #ifndef LTE_UE_NET_DEVICE_H #define LTE_UE_NET_DEVICE_H -#include "ns3/component-carrier-ue.h" -#include "ns3/eps-bearer.h" +#include "component-carrier-ue.h" +#include "lte-net-device.h" + #include "ns3/event-id.h" -#include "ns3/lte-net-device.h" -#include "ns3/lte-phy.h" #include "ns3/nstime.h" #include "ns3/traced-callback.h" diff --git a/src/lte/model/lte-ue-phy.cc b/src/lte/model/lte-ue-phy.cc index f7cf3591e..f7ef206e7 100644 --- a/src/lte/model/lte-ue-phy.cc +++ b/src/lte/model/lte-ue-phy.cc @@ -26,19 +26,15 @@ #include "ff-mac-common.h" #include "lte-amc.h" -#include "lte-chunk-processor.h" -#include "lte-enb-net-device.h" -#include "lte-enb-phy.h" +#include "lte-common.h" #include "lte-net-device.h" #include "lte-spectrum-value-helper.h" -#include "lte-ue-mac.h" #include "lte-ue-net-device.h" +#include "lte-ue-power-control.h" #include #include #include -#include -#include #include #include #include @@ -1585,7 +1581,7 @@ LteUePhy::DoResetRlfParams() } void -LteUePhy::DoStartInSnycDetection() +LteUePhy::DoStartInSyncDetection() { NS_LOG_FUNCTION(this); // indicates that the downlink radio link quality has to be monitored for in-sync indications @@ -1617,7 +1613,7 @@ LteUePhy::RlfDetection(double sinrDb) m_numOfSubframes++; NS_LOG_LOGIC("No of Subframes: " << m_numOfSubframes << " UE synchronized: " << m_downlinkInSync); - // check for out_of_snyc indications first when UE is both DL and UL synchronized + // check for out_of_sync indications first when UE is both DL and UL synchronized // m_downlinkInSync=true indicates that the evaluation is for out-of-sync indications if (m_downlinkInSync && m_numOfSubframes == 10) { @@ -1657,7 +1653,7 @@ LteUePhy::RlfDetection(double sinrDb) m_ueCphySapUser->NotifyOutOfSync(); m_numOfFrames = 0; } - // check for in_snyc indications when T310 timer is started + // check for in_sync indications when T310 timer is started // m_downlinkInSync=false indicates that the evaluation is for in-sync indications if (!m_downlinkInSync && m_numOfSubframes == 10) { diff --git a/src/lte/model/lte-ue-phy.h b/src/lte/model/lte-ue-phy.h index 38d25c552..81b5e7eda 100644 --- a/src/lte/model/lte-ue-phy.h +++ b/src/lte/model/lte-ue-phy.h @@ -24,13 +24,14 @@ #ifndef LTE_UE_PHY_H #define LTE_UE_PHY_H -#include -#include -#include -#include -#include -#include -#include +#include "ff-mac-common.h" +#include "lte-amc.h" +#include "lte-control-messages.h" +#include "lte-phy.h" +#include "lte-ue-cphy-sap.h" +#include "lte-ue-phy-sap.h" +#include "lte-ue-power-control.h" + #include #include @@ -580,7 +581,7 @@ class LteUePhy : public LtePhy * consecutive times. * */ - void DoStartInSnycDetection(); + void DoStartInSyncDetection(); /** * \brief Radio link failure detection function diff --git a/src/lte/model/lte-ue-rrc.cc b/src/lte/model/lte-ue-rrc.cc index 821d0d5ea..4e600a86a 100644 --- a/src/lte/model/lte-ue-rrc.cc +++ b/src/lte/model/lte-ue-rrc.cc @@ -25,14 +25,16 @@ #include "lte-ue-rrc.h" +#include "lte-common.h" +#include "lte-pdcp.h" +#include "lte-radio-bearer-info.h" +#include "lte-rlc-am.h" +#include "lte-rlc-tm.h" +#include "lte-rlc-um.h" +#include "lte-rlc.h" + #include #include -#include -#include -#include -#include -#include -#include #include #include #include @@ -1307,7 +1309,7 @@ LteUeRrc::EvaluateCellForSelection() uint32_t cellCsgId = m_lastSib1.cellAccessRelatedInfo.csgIdentity; bool cellCsgIndication = m_lastSib1.cellAccessRelatedInfo.csgIndication; - isSuitableCell = (cellCsgIndication == false) || (cellCsgId == m_csgWhiteList); + isSuitableCell = (!cellCsgIndication || cellCsgId == m_csgWhiteList); NS_LOG_LOGIC(this << " csg(ue/cell/indication)=" << m_csgWhiteList << "/" << cellCsgId << "/" << cellCsgIndication); @@ -1415,7 +1417,7 @@ void LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedicated rrcd) { NS_LOG_FUNCTION(this); - const struct LteRrcSap::PhysicalConfigDedicated& pcd = rrcd.physicalConfigDedicated; + const LteRrcSap::PhysicalConfigDedicated& pcd = rrcd.physicalConfigDedicated; if (pcd.haveAntennaInfoDedicated) { @@ -1473,7 +1475,7 @@ LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedica m_srb1->m_logicalChannelConfig.logicalChannelGroup = stamIt->logicalChannelConfig.logicalChannelGroup; - struct LteUeCmacSapProvider::LogicalChannelConfig lcConfig; + LteUeCmacSapProvider::LogicalChannelConfig lcConfig; lcConfig.priority = stamIt->logicalChannelConfig.priority; lcConfig.prioritizedBitRateKbps = stamIt->logicalChannelConfig.prioritizedBitRateKbps; lcConfig.bucketSizeDurationMs = stamIt->logicalChannelConfig.bucketSizeDurationMs; @@ -1567,7 +1569,7 @@ LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedica m_drbCreatedTrace(m_imsi, m_cellId, m_rnti, dtamIt->drbIdentity); - struct LteUeCmacSapProvider::LogicalChannelConfig lcConfig; + LteUeCmacSapProvider::LogicalChannelConfig lcConfig; lcConfig.priority = dtamIt->logicalChannelConfig.priority; lcConfig.prioritizedBitRateKbps = dtamIt->logicalChannelConfig.prioritizedBitRateKbps; lcConfig.bucketSizeDurationMs = dtamIt->logicalChannelConfig.bucketSizeDurationMs; @@ -3374,7 +3376,7 @@ LteUeRrc::DoNotifyOutOfSync() { NS_LOG_INFO("t310 started"); } - m_cphySapProvider.at(0)->StartInSnycDetection(); + m_cphySapProvider.at(0)->StartInSyncDetection(); m_noOfSyncIndications = 0; } } diff --git a/src/lte/model/lte-ue-rrc.h b/src/lte/model/lte-ue-rrc.h index daf4ef1f3..d89dd9909 100644 --- a/src/lte/model/lte-ue-rrc.h +++ b/src/lte/model/lte-ue-rrc.h @@ -26,13 +26,13 @@ #ifndef LTE_UE_RRC_H #define LTE_UE_RRC_H -#include "ns3/component-carrier-ue.h" -#include -#include -#include -#include -#include -#include +#include "lte-as-sap.h" +#include "lte-pdcp-sap.h" +#include "lte-rrc-sap.h" +#include "lte-ue-ccm-rrc-sap.h" +#include "lte-ue-cmac-sap.h" +#include "lte-ue-cphy-sap.h" + #include #include #include @@ -41,9 +41,6 @@ #include #include -#define MIN_NO_CC 1 -#define MAX_NO_CC 5 // this is the maximum number of carrier components allowed by 3GPP up to R13 - namespace ns3 { @@ -347,7 +344,7 @@ class LteUeRrc : public Object typedef void (*ImsiCidRntiTracedCallback)(uint64_t imsi, uint16_t cellId, uint16_t rnti); /** - * TracedCallback signature for MIBRecieved, Sib1Received and + * TracedCallback signature for MIBReceived, Sib1Received and * HandoverStart events. * * \param [in] imsi diff --git a/src/lte/model/lte-vendor-specific-parameters.cc b/src/lte/model/lte-vendor-specific-parameters.cc index b1ee8683c..bc0b15ec5 100644 --- a/src/lte/model/lte-vendor-specific-parameters.cc +++ b/src/lte/model/lte-vendor-specific-parameters.cc @@ -17,8 +17,9 @@ * Author: Marco Miozzo */ +#include "lte-vendor-specific-parameters.h" + #include -#include namespace ns3 { diff --git a/src/lte/model/lte-vendor-specific-parameters.h b/src/lte/model/lte-vendor-specific-parameters.h index 53a52d849..01d3f25e8 100644 --- a/src/lte/model/lte-vendor-specific-parameters.h +++ b/src/lte/model/lte-vendor-specific-parameters.h @@ -20,7 +20,7 @@ #ifndef LTE_VENDOR_SPECIFIC_PARAMETERS #define LTE_VENDOR_SPECIFIC_PARAMETERS -#include +#include "ff-mac-common.h" #define SRS_CQI_RNTI_VSP 1 diff --git a/src/lte/model/no-op-component-carrier-manager.cc b/src/lte/model/no-op-component-carrier-manager.cc index 5bf125e08..14d8a0226 100644 --- a/src/lte/model/no-op-component-carrier-manager.cc +++ b/src/lte/model/no-op-component-carrier-manager.cc @@ -22,6 +22,8 @@ #include "no-op-component-carrier-manager.h" +#include "lte-common.h" + #include #include @@ -205,7 +207,7 @@ NoOpComponentCarrierManager::DoSetupDataRadioBearer(EpsBearer bearer, lci.qci = bearer.qci; if (ncc == 0) { - lci.isGbr = bearer.IsGbr(); + lci.resourceType = bearer.GetResourceType(); lci.mbrUl = bearer.gbrQosInfo.mbrUl; lci.mbrDl = bearer.gbrQosInfo.mbrDl; lci.gbrUl = bearer.gbrQosInfo.gbrUl; @@ -213,7 +215,7 @@ NoOpComponentCarrierManager::DoSetupDataRadioBearer(EpsBearer bearer, } else { - lci.isGbr = 0; + lci.resourceType = 0; lci.mbrUl = 0; lci.mbrDl = 0; lci.gbrUl = 0; @@ -234,7 +236,7 @@ NoOpComponentCarrierManager::DoSetupDataRadioBearer(EpsBearer bearer, lcinfo.lcId = lcid; lcinfo.lcGroup = lcGroup; lcinfo.qci = bearer.qci; - lcinfo.isGbr = bearer.IsGbr(); + lcinfo.resourceType = bearer.GetResourceType(); lcinfo.mbrUl = bearer.gbrQosInfo.mbrUl; lcinfo.mbrDl = bearer.gbrQosInfo.mbrDl; lcinfo.gbrUl = bearer.gbrQosInfo.gbrUl; diff --git a/src/lte/model/no-op-component-carrier-manager.h b/src/lte/model/no-op-component-carrier-manager.h index 4847009ea..df4b5a8b1 100644 --- a/src/lte/model/no-op-component-carrier-manager.h +++ b/src/lte/model/no-op-component-carrier-manager.h @@ -22,9 +22,9 @@ #ifndef NO_OP_COMPONENT_CARRIER_MANAGER_H #define NO_OP_COMPONENT_CARRIER_MANAGER_H -#include -#include -#include +#include "lte-ccm-rrc-sap.h" +#include "lte-enb-component-carrier-manager.h" +#include "lte-rrc-sap.h" #include diff --git a/src/lte/model/no-op-handover-algorithm.h b/src/lte/model/no-op-handover-algorithm.h index 4f5172366..3ef5ad514 100644 --- a/src/lte/model/no-op-handover-algorithm.h +++ b/src/lte/model/no-op-handover-algorithm.h @@ -21,9 +21,9 @@ #ifndef NO_OP_HANDOVER_ALGORITHM_H #define NO_OP_HANDOVER_ALGORITHM_H -#include -#include -#include +#include "lte-handover-algorithm.h" +#include "lte-handover-management-sap.h" +#include "lte-rrc-sap.h" namespace ns3 { diff --git a/src/lte/model/pf-ff-mac-scheduler.cc b/src/lte/model/pf-ff-mac-scheduler.cc index 474b4f753..3a0918c8a 100644 --- a/src/lte/model/pf-ff-mac-scheduler.cc +++ b/src/lte/model/pf-ff-mac-scheduler.cc @@ -17,12 +17,14 @@ * Author: Marco Miozzo */ +#include "pf-ff-mac-scheduler.h" + +#include "lte-amc.h" +#include "lte-vendor-specific-parameters.h" + #include #include -#include -#include #include -#include #include #include @@ -142,7 +144,7 @@ PfFfMacScheduler::GetLteFfrSapUser() void PfFfMacScheduler::DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params) + const FfMacCschedSapProvider::CschedCellConfigReqParameters& params) { NS_LOG_FUNCTION(this); // Read the subset of parameters used @@ -155,7 +157,7 @@ PfFfMacScheduler::DoCschedCellConfigReq( void PfFfMacScheduler::DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params) + const FfMacCschedSapProvider::CschedUeConfigReqParameters& params) { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); @@ -201,7 +203,7 @@ PfFfMacScheduler::DoCschedUeConfigReq( void PfFfMacScheduler::DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params) + const FfMacCschedSapProvider::CschedLcConfigReqParameters& params) { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); @@ -230,7 +232,7 @@ PfFfMacScheduler::DoCschedLcConfigReq( void PfFfMacScheduler::DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) @@ -257,7 +259,7 @@ PfFfMacScheduler::DoCschedLcReleaseReq( void PfFfMacScheduler::DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) { NS_LOG_FUNCTION(this); @@ -297,7 +299,7 @@ PfFfMacScheduler::DoCschedUeReleaseReq( void PfFfMacScheduler::DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) { 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) @@ -322,7 +324,7 @@ PfFfMacScheduler::DoSchedDlRlcBufferReq( void PfFfMacScheduler::DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -330,7 +332,7 @@ PfFfMacScheduler::DoSchedDlPagingBufferReq( void PfFfMacScheduler::DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -392,14 +394,8 @@ PfFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { i = (i + 1) % HARQ_PROC_NUM; } while (((*itStat).second.at(i) != 0) && (i != (*it).second)); - if ((*itStat).second.at(i) == 0) - { - return (true); - } - else - { - return (false); // return a not valid harq proc id - } + + return (*itStat).second.at(i) == 0; } uint8_t @@ -407,7 +403,7 @@ PfFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - if (m_harqOn == false) + if (!m_harqOn) { return (0); } @@ -478,7 +474,7 @@ PfFfMacScheduler::RefreshHarqProcesses() void PfFfMacScheduler::DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); @@ -501,7 +497,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) { - if ((*it) == true) + if (*it) { rbgAllocatedNum++; } @@ -529,7 +525,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) { - if ((*it) == true) + if (*it) { if (tmpMinBandwidth > maxContinuousUlBandwidth) { @@ -558,7 +554,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; + std::vector::iterator itRach; for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > @@ -600,7 +596,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.at(i) = (*itRach).m_rnti; } - if (m_harqOn == true) + if (m_harqOn) { // generate UL-DCI for HARQ retransmissions UlDciListElement_s uldci; @@ -665,12 +661,12 @@ PfFfMacScheduler::DoSchedDlTriggerReq( m_dlInfoListBuffered = params.m_dlInfoList; } } - if (m_harqOn == false) + if (!m_harqOn) { // Ignore HARQ feedback m_dlInfoListBuffered.clear(); } - std::vector dlInfoListUntxed; + 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); @@ -761,7 +757,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( bool free = true; for (std::size_t j = 0; j < dciRbg.size(); j++) { - if (rbgMap.at(dciRbg.at(j)) == true) + if (rbgMap.at(dciRbg.at(j))) { free = false; break; @@ -789,7 +785,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( std::vector rbgMapCopy = rbgMap; while ((j < dciRbg.size()) && (startRbg != rbgId)) { - if (rbgMapCopy.at(rbgId) == false) + if (!rbgMapCopy.at(rbgId)) { rbgMapCopy.at(rbgId) = true; dciRbg.at(j) = rbgId; @@ -860,7 +856,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( } for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++) { - std::vector rlcPduListPerLc; + std::vector rlcPduListPerLc; for (std::size_t j = 0; j < nLayers; j++) { if (retx.at(j)) @@ -948,20 +944,20 @@ PfFfMacScheduler::DoSchedDlTriggerReq( for (int i = 0; i < rbgNum; i++) { NS_LOG_INFO(this << " ALLOCATION for RBG " << i << " of " << rbgNum); - if (rbgMap.at(i) == false) + if (!rbgMap.at(i)) { std::map::iterator it; std::map::iterator itMax = m_flowStatsDl.end(); double rcqiMax = 0.0; for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { - if ((m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*it).first)) == false) + if (!m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*it).first)) { continue; } std::set::iterator itRnti = rntiAllocated.find((*it).first); - if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it).first))) + if (itRnti != rntiAllocated.end() || !HarqProcessAvailability((*it).first)) { // UE already allocated for HARQ or without HARQ process available -> drop it if (itRnti != rntiAllocated.end()) @@ -1194,7 +1190,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) || ((*itBufReq).second.m_rlcStatusPduSize > 0))) { - std::vector newRlcPduLe; + std::vector newRlcPduLe; for (uint8_t j = 0; j < nLayer; j++) { RlcPduListElement_s newRlcEl; @@ -1206,7 +1202,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( UpdateDlRlcBufferInfo(newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size); - if (m_harqOn == true) + if (m_harqOn) { // store RLC PDU list for HARQ std::map::iterator itRlcPdu = @@ -1236,7 +1232,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = newDci; - if (m_harqOn == true) + if (m_harqOn) { // store DCI for HARQ std::map::iterator itDci = @@ -1297,7 +1293,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( void PfFfMacScheduler::DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1306,7 +1302,7 @@ PfFfMacScheduler::DoSchedDlRachInfoReq( void PfFfMacScheduler::DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); m_ffrSapProvider->ReportDlCqiInfo(params); @@ -1401,7 +1397,7 @@ PfFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) void PfFfMacScheduler::DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size()); @@ -1426,7 +1422,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) { - if ((*it) == true) + if (*it) { rbAllocatedNum++; } @@ -1445,7 +1441,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( } } - if (m_harqOn == true) + if (m_harqOn) { // Process UL HARQ feedback @@ -1486,7 +1482,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; NS_LOG_INFO(this << " BUSY " << j); @@ -1627,12 +1623,12 @@ PfFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; break; } - if ((m_ffrSapProvider->IsUlRbgAvailableForUe(j, (*it).first)) == false) + if (!m_ffrSapProvider->IsUlRbgAvailableForUe(j, (*it).first)) { free = false; break; @@ -1749,7 +1745,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( ret.m_dciList.push_back(uldci); // store DCI for HARQ_PERIOD uint8_t harqId = 0; - if (m_harqOn == true) + if (m_harqOn) { std::map::iterator itProcId; itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); @@ -1829,21 +1825,21 @@ PfFfMacScheduler::DoSchedUlTriggerReq( void PfFfMacScheduler::DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) { NS_LOG_FUNCTION(this); } void PfFfMacScheduler::DoSchedUlSrInfoReq( - const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) { NS_LOG_FUNCTION(this); } void PfFfMacScheduler::DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1886,7 +1882,7 @@ PfFfMacScheduler::DoSchedUlMacCtrlInfoReq( void PfFfMacScheduler::DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); m_ffrSapProvider->ReportUlCqiInfo(params); diff --git a/src/lte/model/pf-ff-mac-scheduler.h b/src/lte/model/pf-ff-mac-scheduler.h index dba0725ab..738380abc 100644 --- a/src/lte/model/pf-ff-mac-scheduler.h +++ b/src/lte/model/pf-ff-mac-scheduler.h @@ -20,37 +20,21 @@ #ifndef PF_FF_MAC_SCHEDULER_H #define PF_FF_MAC_SCHEDULER_H -#include -#include -#include -#include -#include -#include +#include "ff-mac-csched-sap.h" +#include "ff-mac-sched-sap.h" +#include "ff-mac-scheduler.h" +#include "lte-amc.h" +#include "lte-common.h" +#include "lte-ffr-sap.h" + #include #include #include -// value for SINR outside the range defined by FF-API, used to indicate that there -// is no CQI for this element -#define NO_SINR -5000 - -#define HARQ_PROC_NUM 8 -#define HARQ_DL_TIMEOUT 11 - namespace ns3 { -typedef std::vector DlHarqProcessesStatus_t; -typedef std::vector DlHarqProcessesTimer_t; -typedef std::vector DlHarqProcessesDciBuffer_t; -typedef std::vector> - RlcPduList_t; // vector of the LCs and layers per UE -typedef std::vector DlHarqRlcPduListBuffer_t; // vector of the 8 HARQ processes per UE - -typedef std::vector UlHarqProcessesDciBuffer_t; -typedef std::vector UlHarqProcessesStatus_t; - /// pfsFlowPerf_t structure struct pfsFlowPerf_t { @@ -124,40 +108,35 @@ class PfFfMacScheduler : public FfMacScheduler * * \param params FfMacCschedSapProvider::CschedCellConfigReqParameters */ - void DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params); + void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters& params); /** * \brief CSched UE config request * * \param params FfMacCschedSapProvider::CschedUeConfigReqParameters */ - void DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params); + void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters& params); /** * \brief CSched LC config request * * \param params FfMacCschedSapProvider::CschedLcConfigReqParameters */ - void DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params); + void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters& params); /** * \brief CSched LC release request * * \param params FfMacCschedSapProvider::CschedLcReleaseReqParameters */ - void DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); + void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); /** * \brief CSched UE release request * * \param params FfMacCschedSapProvider::CschedLcReleaseReqParameters */ - void DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); + void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); // // Implementation of the SCHED API primitives @@ -169,8 +148,7 @@ class PfFfMacScheduler : public FfMacScheduler * * \param params FfMacSchedSapProvider::SchedDlRlcBufferReqParameters */ - void DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); + void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); /** * \brief Sched DL paging buffer request @@ -178,47 +156,42 @@ class PfFfMacScheduler : public FfMacScheduler * \param params FfMacSchedSapProvider::SchedDlPagingBufferReqParameters */ void DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); /** * \brief Sched DL MAC buffer request * * \param params FfMacSchedSapProvider::SchedDlMacBufferReqParameters */ - void DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); + void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); /** * \brief Sched DL trigger request * * \param params FfMacSchedSapProvider::SchedDlTriggerReqParameters */ - void DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); + void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); /** * \brief Sched DL RACH info request * * \param params FfMacSchedSapProvider::SchedDlRachInfoReqParameters */ - void DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); + void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); /** * \brief Sched DL CQI info request * * \param params FfMacSchedSapProvider::SchedDlCqiInfoReqParameters */ - void DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); + void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); /** * \brief Sched UL trigger request * * \param params FfMacSchedSapProvider::SchedUlTriggerReqParameters */ - void DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); + void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); /** * \brief Sched UL noise interference request @@ -226,14 +199,14 @@ class PfFfMacScheduler : public FfMacScheduler * \param params FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters */ void DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); /** * \brief Sched UL SR info request * * \param params FfMacSchedSapProvider::SchedUlSrInfoReqParameters */ - void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); + void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); /** * \brief Sched UL MAC control info request @@ -241,15 +214,14 @@ class PfFfMacScheduler : public FfMacScheduler * \param params FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters */ void DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); /** * \brief Sched UL CQI info request * * \param params FfMacSchedSapProvider::SchedUlCqiInfoReqParameters */ - void DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); + void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); /** * \brief Get RBG size @@ -422,9 +394,9 @@ class PfFfMacScheduler : public FfMacScheduler m_ulHarqProcessesDciBuffer; ///< UL HARQ process DCI buffer // RACH attributes - std::vector m_rachList; ///< RACH list - std::vector m_rachAllocationMap; ///< RACH allocation map - uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) + std::vector m_rachList; ///< RACH list + std::vector m_rachAllocationMap; ///< RACH allocation map + uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) }; } // namespace ns3 diff --git a/src/lte/model/pss-ff-mac-scheduler.cc b/src/lte/model/pss-ff-mac-scheduler.cc index 18acc2225..4884a52b1 100644 --- a/src/lte/model/pss-ff-mac-scheduler.cc +++ b/src/lte/model/pss-ff-mac-scheduler.cc @@ -18,13 +18,15 @@ * Modification: Dizhi Zhou // modify codes related to downlink scheduler */ +#include "pss-ff-mac-scheduler.h" + +#include "lte-amc.h" +#include "lte-vendor-specific-parameters.h" + #include #include -#include -#include #include #include -#include #include #include @@ -155,7 +157,7 @@ PssFfMacScheduler::GetLteFfrSapUser() void PssFfMacScheduler::DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params) + const FfMacCschedSapProvider::CschedCellConfigReqParameters& params) { NS_LOG_FUNCTION(this); // Read the subset of parameters used @@ -168,7 +170,7 @@ PssFfMacScheduler::DoCschedCellConfigReq( void PssFfMacScheduler::DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params) + const FfMacCschedSapProvider::CschedUeConfigReqParameters& params) { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); @@ -214,7 +216,7 @@ PssFfMacScheduler::DoCschedUeConfigReq( void PssFfMacScheduler::DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params) + const FfMacCschedSapProvider::CschedLcConfigReqParameters& params) { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); @@ -262,7 +264,7 @@ PssFfMacScheduler::DoCschedLcConfigReq( void PssFfMacScheduler::DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) @@ -289,7 +291,7 @@ PssFfMacScheduler::DoCschedLcReleaseReq( void PssFfMacScheduler::DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) { NS_LOG_FUNCTION(this); @@ -329,7 +331,7 @@ PssFfMacScheduler::DoCschedUeReleaseReq( void PssFfMacScheduler::DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) { 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) @@ -354,7 +356,7 @@ PssFfMacScheduler::DoSchedDlRlcBufferReq( void PssFfMacScheduler::DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -362,7 +364,7 @@ PssFfMacScheduler::DoSchedDlPagingBufferReq( void PssFfMacScheduler::DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -424,14 +426,8 @@ PssFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { i = (i + 1) % HARQ_PROC_NUM; } while (((*itStat).second.at(i) != 0) && (i != (*it).second)); - if ((*itStat).second.at(i) == 0) - { - return (true); - } - else - { - return (false); // return a not valid harq proc id - } + + return (*itStat).second.at(i) == 0; } uint8_t @@ -439,7 +435,7 @@ PssFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - if (m_harqOn == false) + if (!m_harqOn) { return (0); } @@ -510,7 +506,7 @@ PssFfMacScheduler::RefreshHarqProcesses() void PssFfMacScheduler::DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); @@ -533,7 +529,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) { - if ((*it) == true) + if (*it) { rbgAllocatedNum++; } @@ -561,7 +557,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) { - if ((*it) == true) + if (*it) { if (tmpMinBandwidth > maxContinuousUlBandwidth) { @@ -590,7 +586,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; + std::vector::iterator itRach; for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > @@ -632,7 +628,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.at(i) = (*itRach).m_rnti; } - if (m_harqOn == true) + if (m_harqOn) { // generate UL-DCI for HARQ retransmissions UlDciListElement_s uldci; @@ -697,12 +693,12 @@ PssFfMacScheduler::DoSchedDlTriggerReq( m_dlInfoListBuffered = params.m_dlInfoList; } } - if (m_harqOn == false) + if (!m_harqOn) { // Ignore HARQ feedback m_dlInfoListBuffered.clear(); } - std::vector dlInfoListUntxed; + 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); @@ -793,7 +789,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( bool free = true; for (std::size_t j = 0; j < dciRbg.size(); j++) { - if (rbgMap.at(dciRbg.at(j)) == true) + if (rbgMap.at(dciRbg.at(j))) { free = false; break; @@ -821,7 +817,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( std::vector rbgMapCopy = rbgMap; while ((j < dciRbg.size()) && (startRbg != rbgId)) { - if (rbgMapCopy.at(rbgId) == false) + if (!rbgMapCopy.at(rbgId)) { rbgMapCopy.at(rbgId) = true; dciRbg.at(j) = rbgId; @@ -892,7 +888,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( } for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++) { - std::vector rlcPduListPerLc; + std::vector rlcPduListPerLc; for (std::size_t j = 0; j < nLayers; j++) { if (retx.at(j)) @@ -1115,38 +1111,23 @@ PssFfMacScheduler::DoSchedDlTriggerReq( nMux = (int)((ueSet1.size() + ueSet2.size()) / 2); } } - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it--) + + std::vector>::iterator itSet; + for (itSet = ueSet1.begin(); itSet != ueSet1.end() && nMux != 0; itSet++) { - std::vector>::iterator itSet; - for (itSet = ueSet1.begin(); itSet != ueSet1.end() && nMux != 0; itSet++) - { - std::map::iterator itUe; - itUe = m_flowStatsDl.find((*itSet).second); - tdUeSet.insert( - std::pair((*itUe).first, (*itUe).second)); - nMux--; - } + std::map::iterator itUe; + itUe = m_flowStatsDl.find((*itSet).second); + tdUeSet.insert(std::pair((*itUe).first, (*itUe).second)); + nMux--; + } - if (nMux == 0) - { - break; - } - - for (itSet = ueSet2.begin(); itSet != ueSet2.end() && nMux != 0; itSet++) - { - std::map::iterator itUe; - itUe = m_flowStatsDl.find((*itSet).second); - tdUeSet.insert( - std::pair((*itUe).first, (*itUe).second)); - nMux--; - } - - if (nMux == 0) - { - break; - } - - } // end of m_flowStatsDl + for (itSet = ueSet2.begin(); itSet != ueSet2.end() && nMux != 0; itSet++) + { + std::map::iterator itUe; + itUe = m_flowStatsDl.find((*itSet).second); + tdUeSet.insert(std::pair((*itUe).first, (*itUe).second)); + nMux--; + } if (m_fdSchedulerType == "CoItA") { @@ -1212,7 +1193,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( for (int i = 0; i < rbgNum; i++) { - if (rbgMap.at(i) == true) + if (rbgMap.at(i)) { continue; } @@ -1221,7 +1202,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( double metricMax = 0.0; for (it = tdUeSet.begin(); it != tdUeSet.end(); it++) { - if ((m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*it).first)) == false) + if (!m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*it).first)) { continue; } @@ -1322,7 +1303,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( // FD scheduler: Proportional Fair scheduled (PFsch) for (int i = 0; i < rbgNum; i++) { - if (rbgMap.at(i) == true) + if (rbgMap.at(i)) { continue; } @@ -1331,7 +1312,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( double metricMax = 0.0; for (it = tdUeSet.begin(); it != tdUeSet.end(); it++) { - if ((m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*it).first)) == false) + if (!m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*it).first)) { continue; } @@ -1549,7 +1530,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) || ((*itBufReq).second.m_rlcStatusPduSize > 0))) { - std::vector newRlcPduLe; + std::vector newRlcPduLe; for (uint8_t j = 0; j < nLayer; j++) { RlcPduListElement_s newRlcEl; @@ -1561,7 +1542,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( UpdateDlRlcBufferInfo(newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size); - if (m_harqOn == true) + if (m_harqOn) { // store RLC PDU list for HARQ std::map::iterator itRlcPdu = @@ -1591,7 +1572,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = newDci; - if (m_harqOn == true) + if (m_harqOn) { // store DCI for HARQ std::map::iterator itDci = @@ -1659,7 +1640,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( void PssFfMacScheduler::DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1668,7 +1649,7 @@ PssFfMacScheduler::DoSchedDlRachInfoReq( void PssFfMacScheduler::DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); m_ffrSapProvider->ReportDlCqiInfo(params); @@ -1763,7 +1744,7 @@ PssFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) void PssFfMacScheduler::DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size()); @@ -1789,7 +1770,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) { - if ((*it) == true) + if (*it) { rbAllocatedNum++; } @@ -1808,7 +1789,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( } } - if (m_harqOn == true) + if (m_harqOn) { // Process UL HARQ feedback for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++) @@ -1848,7 +1829,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; NS_LOG_INFO(this << " BUSY " << j); @@ -1989,12 +1970,12 @@ PssFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; break; } - if ((m_ffrSapProvider->IsUlRbgAvailableForUe(j, (*it).first)) == false) + if (!m_ffrSapProvider->IsUlRbgAvailableForUe(j, (*it).first)) { free = false; break; @@ -2111,7 +2092,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( ret.m_dciList.push_back(uldci); // store DCI for HARQ_PERIOD uint8_t harqId = 0; - if (m_harqOn == true) + if (m_harqOn) { std::map::iterator itProcId; itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); @@ -2166,21 +2147,21 @@ PssFfMacScheduler::DoSchedUlTriggerReq( void PssFfMacScheduler::DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) { NS_LOG_FUNCTION(this); } void PssFfMacScheduler::DoSchedUlSrInfoReq( - const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) { NS_LOG_FUNCTION(this); } void PssFfMacScheduler::DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -2223,7 +2204,7 @@ PssFfMacScheduler::DoSchedUlMacCtrlInfoReq( void PssFfMacScheduler::DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); // retrieve the allocation for this subframe diff --git a/src/lte/model/pss-ff-mac-scheduler.h b/src/lte/model/pss-ff-mac-scheduler.h index 8c64a5fed..6030ce326 100644 --- a/src/lte/model/pss-ff-mac-scheduler.h +++ b/src/lte/model/pss-ff-mac-scheduler.h @@ -21,37 +21,21 @@ #ifndef PSS_FF_MAC_SCHEDULER_H #define PSS_FF_MAC_SCHEDULER_H -#include -#include -#include -#include -#include -#include +#include "ff-mac-csched-sap.h" +#include "ff-mac-sched-sap.h" +#include "ff-mac-scheduler.h" +#include "lte-amc.h" +#include "lte-common.h" +#include "lte-ffr-sap.h" + #include #include #include -// value for SINR outside the range defined by FF-API, used to indicate that there -// is no CQI for this element -#define NO_SINR -5000 - -#define HARQ_PROC_NUM 8 -#define HARQ_DL_TIMEOUT 11 - namespace ns3 { -typedef std::vector DlHarqProcessesStatus_t; -typedef std::vector DlHarqProcessesTimer_t; -typedef std::vector DlHarqProcessesDciBuffer_t; -typedef std::vector> - RlcPduList_t; // vector of the LCs and layers per UE -typedef std::vector DlHarqRlcPduListBuffer_t; // vector of the 8 HARQ processes per UE - -typedef std::vector UlHarqProcessesDciBuffer_t; -typedef std::vector UlHarqProcessesStatus_t; - /** * Flow information */ @@ -129,40 +113,35 @@ class PssFfMacScheduler : public FfMacScheduler * * \param params FfMacCschedSapProvider::CschedCellConfigReqParameters */ - void DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params); + void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters& params); /** * \brief CSched UE config request function * * \param params FfMacCschedSapProvider::CschedUeConfigReqParameters */ - void DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params); + void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters& params); /** * \brief CSched LC config request function * * \param params FfMacCschedSapProvider::CschedLcConfigReqParameters */ - void DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params); + void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters& params); /** * \brief CSched LC release request function * * \param params FfMacCschedSapProvider::CschedLcReleaseReqParameters */ - void DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); + void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); /** * \brief CSched UE release request function * * \param params FfMacCschedSapProvider::CschedUeReleaseReqParameters */ - void DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); + void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); // // Implementation of the SCHED API primitives @@ -174,8 +153,7 @@ class PssFfMacScheduler : public FfMacScheduler * * \param params FfMacSchedSapProvider::SchedDlRlcBufferReqParameters */ - void DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); + void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); /** * \brief Sched DL paging buffer request function @@ -183,47 +161,42 @@ class PssFfMacScheduler : public FfMacScheduler * \param params FfMacSchedSapProvider::SchedDlPagingBufferReqParameters */ void DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); /** * \brief Sched DL MAC buffer request function * * \param params FfMacSchedSapProvider::SchedDlMacBufferReqParameters */ - void DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); + void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); /** * \brief Sched DL trigger request function * * \param params FfMacSchedSapProvider::SchedDlTriggerReqParameters */ - void DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); + void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); /** * \brief Sched DL RACH info request function * * \param params FfMacSchedSapProvider::SchedDlRachInfoReqParameters */ - void DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); + void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); /** * \brief Sched DL CQI info request function * * \param params FfMacSchedSapProvider::SchedDlCqiInfoReqParameters */ - void DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); + void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); /** * \brief Sched UL trigger request function * * \param params FfMacSchedSapProvider::SchedUlTriggerReqParameters */ - void DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); + void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); /** * \brief Sched UL noise interference request function @@ -231,14 +204,14 @@ class PssFfMacScheduler : public FfMacScheduler * \param params FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters */ void DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); /** * \brief Sched UL SR info request function * * \param params FfMacSchedSapProvider::SchedUlSrInfoReqParameters */ - void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); + void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); /** * \brief Sched UL MAC control info request function @@ -246,15 +219,14 @@ class PssFfMacScheduler : public FfMacScheduler * \param params FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters */ void DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); /** * \brief Sched UL CQI info request function * * \param params FfMacSchedSapProvider::SchedUlCqiInfoReqParameters */ - void DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); + void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); /** * \brief Get RBG size function @@ -431,9 +403,9 @@ class PssFfMacScheduler : public FfMacScheduler m_ulHarqProcessesDciBuffer; ///< UL HARQ process DCI buffer // RACH attributes - std::vector m_rachList; ///< RACH list - std::vector m_rachAllocationMap; ///< RACH allocation map - uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) + std::vector m_rachList; ///< RACH list + std::vector m_rachAllocationMap; ///< RACH allocation map + uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) }; } // namespace ns3 diff --git a/src/lte/model/rem-spectrum-phy.cc b/src/lte/model/rem-spectrum-phy.cc index eda9c4600..378140f1e 100644 --- a/src/lte/model/rem-spectrum-phy.cc +++ b/src/lte/model/rem-spectrum-phy.cc @@ -21,10 +21,11 @@ #include "rem-spectrum-phy.h" +#include "lte-spectrum-signal-parameters.h" + #include #include #include -#include #include #include #include diff --git a/src/lte/model/rr-ff-mac-scheduler.cc b/src/lte/model/rr-ff-mac-scheduler.cc index 5bf71eb6a..636d98d24 100644 --- a/src/lte/model/rr-ff-mac-scheduler.cc +++ b/src/lte/model/rr-ff-mac-scheduler.cc @@ -17,14 +17,16 @@ * Author: Marco Miozzo */ +#include "rr-ff-mac-scheduler.h" + +#include "lte-amc.h" +#include "lte-common.h" +#include "lte-vendor-specific-parameters.h" + #include #include -#include -#include -#include #include #include -#include #include #include @@ -141,7 +143,7 @@ RrFfMacScheduler::GetLteFfrSapUser() void RrFfMacScheduler::DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params) + const FfMacCschedSapProvider::CschedCellConfigReqParameters& params) { NS_LOG_FUNCTION(this); // Read the subset of parameters used @@ -154,7 +156,7 @@ RrFfMacScheduler::DoCschedCellConfigReq( void RrFfMacScheduler::DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params) + const FfMacCschedSapProvider::CschedUeConfigReqParameters& params) { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); @@ -200,7 +202,7 @@ RrFfMacScheduler::DoCschedUeConfigReq( void RrFfMacScheduler::DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params) + const FfMacCschedSapProvider::CschedLcConfigReqParameters& params) { NS_LOG_FUNCTION(this); // Not used at this stage (LCs updated by DoSchedDlRlcBufferReq) @@ -208,7 +210,7 @@ RrFfMacScheduler::DoCschedLcConfigReq( void RrFfMacScheduler::DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) @@ -232,7 +234,7 @@ RrFfMacScheduler::DoCschedLcReleaseReq( void RrFfMacScheduler::DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) { NS_LOG_FUNCTION(this << " Release RNTI " << params.m_rnti); @@ -274,7 +276,7 @@ RrFfMacScheduler::DoCschedUeReleaseReq( void RrFfMacScheduler::DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) { 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) @@ -303,7 +305,7 @@ RrFfMacScheduler::DoSchedDlRlcBufferReq( << params.m_rlcRetransmissionQueueSize << " RLC stat size " << params.m_rlcStatusPduSize); // initialize statistics of the flow in case of new flows - if (newLc == true) + if (newLc) { m_p10CqiRxed.insert( std::pair(params.m_rnti, 1)); // only codeword 0 at this stage (SISO) @@ -314,7 +316,7 @@ RrFfMacScheduler::DoSchedDlRlcBufferReq( void RrFfMacScheduler::DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -322,7 +324,7 @@ RrFfMacScheduler::DoSchedDlPagingBufferReq( void RrFfMacScheduler::DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -370,14 +372,8 @@ RrFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { i = (i + 1) % HARQ_PROC_NUM; } while (((*itStat).second.at(i) != 0) && (i != (*it).second)); - if ((*itStat).second.at(i) == 0) - { - return (true); - } - else - { - return (false); // return a not valid harq proc id - } + + return (*itStat).second.at(i) == 0; } uint8_t @@ -385,7 +381,7 @@ RrFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - if (m_harqOn == false) + if (!m_harqOn) { return (0); } @@ -455,7 +451,7 @@ RrFfMacScheduler::RefreshHarqProcesses() void RrFfMacScheduler::DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " DL Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); @@ -483,7 +479,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; + std::vector::iterator itRach; for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > @@ -525,7 +521,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.at(i) = (*itRach).m_rnti; } - if (m_harqOn == true) + if (m_harqOn) { // generate UL-DCI for HARQ retransmissions UlDciListElement_s uldci; @@ -590,12 +586,12 @@ RrFfMacScheduler::DoSchedDlTriggerReq( m_dlInfoListBuffered = params.m_dlInfoList; } } - if (m_harqOn == false) + if (!m_harqOn) { // Ignore HARQ feedback m_dlInfoListBuffered.clear(); } - std::vector dlInfoListUntxed; + 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); @@ -686,7 +682,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( bool free = true; for (std::size_t j = 0; j < dciRbg.size(); j++) { - if (rbgMap.at(dciRbg.at(j)) == true) + if (rbgMap.at(dciRbg.at(j))) { free = false; break; @@ -714,7 +710,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( std::vector rbgMapCopy = rbgMap; while ((j < dciRbg.size()) && (startRbg != rbgId)) { - if (rbgMapCopy.at(rbgId) == false) + if (!rbgMapCopy.at(rbgId)) { rbgMapCopy.at(rbgId) = true; dciRbg.at(j) = rbgId; @@ -786,7 +782,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++) { - std::vector rlcPduListPerLc; + std::vector rlcPduListPerLc; for (std::size_t j = 0; j < nLayers; j++) { if (retx.at(j)) @@ -978,10 +974,10 @@ RrFfMacScheduler::DoSchedDlTriggerReq( if ((itLcRnti == lcActivesPerRnti.end()) || (itRnti != rntiAllocated.end())) { // skip this RNTI (no active queue or yet allocated for HARQ) - uint16_t rntiDiscared = (*it).m_rnti; + uint16_t rntiDiscarded = (*it).m_rnti; while (it != m_rlcBufferReq.end()) { - if ((*it).m_rnti != rntiDiscared) + if ((*it).m_rnti != rntiDiscarded) { break; } @@ -1029,7 +1025,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( if (((*it).m_rlcTransmissionQueueSize > 0) || ((*it).m_rlcRetransmissionQueueSize > 0) || ((*it).m_rlcStatusPduSize > 0)) { - std::vector newRlcPduLe; + std::vector newRlcPduLe; for (uint8_t j = 0; j < nLayer; j++) { RlcPduListElement_s newRlcEl; @@ -1043,7 +1039,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( rlcPduSize); newRlcPduLe.push_back(newRlcEl); - if (m_harqOn == true) + if (m_harqOn) { // store RLC PDU list for HARQ std::map::iterator itRlcPdu = @@ -1076,7 +1072,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( NS_LOG_INFO("RBG:"); while (i < rbgPerTb) { - if (rbgMap.at(rbgAllocated) == false) + if (!rbgMap.at(rbgAllocated)) { rbgMask = rbgMask + (0x1 << rbgAllocated); NS_LOG_INFO("\t " << rbgAllocated); @@ -1098,7 +1094,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( newDci.m_tpc = 1; // 1 is mapped to 0 in Accumulated Mode and to -1 in Absolute Mode newEl.m_dci = newDci; - if (m_harqOn == true) + if (m_harqOn) { // store DCI for HARQ std::map::iterator itDci = @@ -1135,7 +1131,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( void RrFfMacScheduler::DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1144,7 +1140,7 @@ RrFfMacScheduler::DoSchedDlRachInfoReq( void RrFfMacScheduler::DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1191,7 +1187,7 @@ RrFfMacScheduler::DoSchedDlCqiInfoReq( void RrFfMacScheduler::DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size()); @@ -1220,7 +1216,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( } } - if (m_harqOn == true) + if (m_harqOn) { // Process UL HARQ feedback for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++) @@ -1260,7 +1256,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; NS_LOG_INFO(this << " BUSY " << j); @@ -1389,7 +1385,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; break; @@ -1497,7 +1493,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( ret.m_dciList.push_back(uldci); // store DCI for HARQ_PERIOD uint8_t harqId = 0; - if (m_harqOn == true) + if (m_harqOn) { std::map::iterator itProcId; itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); @@ -1552,21 +1548,21 @@ RrFfMacScheduler::DoSchedUlTriggerReq( void RrFfMacScheduler::DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) { NS_LOG_FUNCTION(this); } void RrFfMacScheduler::DoSchedUlSrInfoReq( - const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) { NS_LOG_FUNCTION(this); } void RrFfMacScheduler::DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1610,7 +1606,7 @@ RrFfMacScheduler::DoSchedUlMacCtrlInfoReq( void RrFfMacScheduler::DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); diff --git a/src/lte/model/rr-ff-mac-scheduler.h b/src/lte/model/rr-ff-mac-scheduler.h index b9c0b4102..04ea25045 100644 --- a/src/lte/model/rr-ff-mac-scheduler.h +++ b/src/lte/model/rr-ff-mac-scheduler.h @@ -21,32 +21,18 @@ #ifndef RR_FF_MAC_SCHEDULER_H #define RR_FF_MAC_SCHEDULER_H -#include -#include -#include -#include -#include -#include +#include "ff-mac-csched-sap.h" +#include "ff-mac-sched-sap.h" +#include "ff-mac-scheduler.h" +#include "lte-amc.h" +#include "lte-ffr-sap.h" #include #include -#define HARQ_PROC_NUM 8 -#define HARQ_DL_TIMEOUT 11 - namespace ns3 { -typedef std::vector DlHarqProcessesStatus_t; -typedef std::vector DlHarqProcessesTimer_t; -typedef std::vector DlHarqProcessesDciBuffer_t; -typedef std::vector> - RlcPduList_t; // vector of the LCs and layers per UE -typedef std::vector DlHarqRlcPduListBuffer_t; // vector of the 8 HARQ processes per UE - -typedef std::vector UlHarqProcessesDciBuffer_t; -typedef std::vector UlHarqProcessesStatus_t; - /** * \ingroup ff-api * \brief Implements the SCHED SAP and CSCHED SAP for a Round Robin scheduler @@ -109,36 +95,31 @@ class RrFfMacScheduler : public FfMacScheduler * \brief CSched cell config request * \param params FfMacCschedSapProvider::CschedCellConfigReqParameters */ - void DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params); + void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters& params); /** * \brief CSched UE config request * \param params FfMacCschedSapProvider::CschedUeConfigReqParameters */ - void DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params); + void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters& params); /** * \brief CSched LC config request * \param params FfMacCschedSapProvider::CschedLcConfigReqParameters */ - void DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params); + void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters& params); /** * \brief CSched LC release request * \param params FfMacCschedSapProvider::CschedLcReleaseReqParameters */ - void DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); + void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); /** * \brief CSched UE release request * \param params FfMacCschedSapProvider::CschedUeReleaseReqParameters */ - void DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); + void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); // // Implementation of the SCHED API primitives @@ -149,77 +130,70 @@ class RrFfMacScheduler : public FfMacScheduler * \brief Sched DL RLC buffer request * \param params FfMacSchedSapProvider::SchedDlRlcBufferReqParameters */ - void DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); + void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); /** * \brief Sched DL paging buffer request * \param params FfMacSchedSapProvider::SchedDlPagingBufferReqParameters */ void DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); /** * \brief Sched DL MAC buffer request * \param params FfMacSchedSapProvider::SchedDlMacBufferReqParameters */ - void DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); + void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); /** * \brief Sched DL trigger request * \param params FfMacSchedSapProvider::SchedDlTriggerReqParameters */ - void DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); + void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); /** * \brief Sched DL RACH info request * \param params FfMacSchedSapProvider::SchedDlRachInfoReqParameters */ - void DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); + void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); /** * \brief Sched DL CQI info request * \param params FfMacSchedSapProvider::SchedDlCqiInfoReqParameters */ - void DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); + void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); /** * \brief Sched UL trigger request * \param params FfMacSchedSapProvider::SchedUlTriggerReqParameters */ - void DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); + void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); /** * \brief Sched UL noise interference request * \param params FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters */ void DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); /** * \brief Sched UL SRS info request * \param params FfMacSchedSapProvider::SchedUlSrInfoReqParameters */ - void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); + void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); /** * \brief Sched UL MAC control info request * \param params FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters */ void DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); /** * \brief Sched UL CQI info request * \param params FfMacSchedSapProvider::SchedUlCqiInfoReqParameters */ - void DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); + void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); /** * \brief Get RBG size function @@ -361,9 +335,9 @@ class RrFfMacScheduler : public FfMacScheduler m_ulHarqProcessesDciBuffer; ///< UL HARQ process DCI buffer // RACH attributes - std::vector m_rachList; ///< RACH list - std::vector m_rachAllocationMap; ///< RACH allocation map - uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) + std::vector m_rachList; ///< RACH list + std::vector m_rachAllocationMap; ///< RACH allocation map + uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) }; } // namespace ns3 diff --git a/src/lte/model/simple-ue-component-carrier-manager.cc b/src/lte/model/simple-ue-component-carrier-manager.cc index 21a6ffb0e..724f371f5 100644 --- a/src/lte/model/simple-ue-component-carrier-manager.cc +++ b/src/lte/model/simple-ue-component-carrier-manager.cc @@ -21,7 +21,6 @@ #include "simple-ue-component-carrier-manager.h" #include -#include namespace ns3 { diff --git a/src/lte/model/simple-ue-component-carrier-manager.h b/src/lte/model/simple-ue-component-carrier-manager.h index 6f783bb0e..f301ee973 100644 --- a/src/lte/model/simple-ue-component-carrier-manager.h +++ b/src/lte/model/simple-ue-component-carrier-manager.h @@ -21,9 +21,9 @@ #ifndef SIMPLE_UE_COMPONENT_CARRIER_MANAGER_H #define SIMPLE_UE_COMPONENT_CARRIER_MANAGER_H -#include -#include -#include +#include "lte-rrc-sap.h" +#include "lte-ue-ccm-rrc-sap.h" +#include "lte-ue-component-carrier-manager.h" #include diff --git a/src/lte/model/tdbet-ff-mac-scheduler.cc b/src/lte/model/tdbet-ff-mac-scheduler.cc index 1e28b7e47..f7a61bf6a 100644 --- a/src/lte/model/tdbet-ff-mac-scheduler.cc +++ b/src/lte/model/tdbet-ff-mac-scheduler.cc @@ -18,14 +18,16 @@ * Modification: Dizhi Zhou // modify codes related to downlink scheduler */ +#include "tdbet-ff-mac-scheduler.h" + +#include "lte-amc.h" +#include "lte-vendor-specific-parameters.h" + #include #include -#include -#include #include #include #include -#include #include #include @@ -140,7 +142,7 @@ TdBetFfMacScheduler::GetLteFfrSapUser() void TdBetFfMacScheduler::DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params) + const FfMacCschedSapProvider::CschedCellConfigReqParameters& params) { NS_LOG_FUNCTION(this); // Read the subset of parameters used @@ -153,7 +155,7 @@ TdBetFfMacScheduler::DoCschedCellConfigReq( void TdBetFfMacScheduler::DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params) + const FfMacCschedSapProvider::CschedUeConfigReqParameters& params) { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); @@ -199,7 +201,7 @@ TdBetFfMacScheduler::DoCschedUeConfigReq( void TdBetFfMacScheduler::DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params) + const FfMacCschedSapProvider::CschedLcConfigReqParameters& params) { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); @@ -228,7 +230,7 @@ TdBetFfMacScheduler::DoCschedLcConfigReq( void TdBetFfMacScheduler::DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) @@ -255,7 +257,7 @@ TdBetFfMacScheduler::DoCschedLcReleaseReq( void TdBetFfMacScheduler::DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) { NS_LOG_FUNCTION(this); @@ -295,7 +297,7 @@ TdBetFfMacScheduler::DoCschedUeReleaseReq( void TdBetFfMacScheduler::DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) { 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) @@ -320,7 +322,7 @@ TdBetFfMacScheduler::DoSchedDlRlcBufferReq( void TdBetFfMacScheduler::DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -328,7 +330,7 @@ TdBetFfMacScheduler::DoSchedDlPagingBufferReq( void TdBetFfMacScheduler::DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -390,14 +392,8 @@ TdBetFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { i = (i + 1) % HARQ_PROC_NUM; } while (((*itStat).second.at(i) != 0) && (i != (*it).second)); - if ((*itStat).second.at(i) == 0) - { - return (true); - } - else - { - return (false); // return a not valid harq proc id - } + + return (*itStat).second.at(i) == 0; } uint8_t @@ -405,7 +401,7 @@ TdBetFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - if (m_harqOn == false) + if (!m_harqOn) { return (0); } @@ -476,7 +472,7 @@ TdBetFfMacScheduler::RefreshHarqProcesses() void TdBetFfMacScheduler::DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); @@ -508,7 +504,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; + std::vector::iterator itRach; for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > @@ -550,7 +546,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.at(i) = (*itRach).m_rnti; } - if (m_harqOn == true) + if (m_harqOn) { // generate UL-DCI for HARQ retransmissions UlDciListElement_s uldci; @@ -615,12 +611,12 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( m_dlInfoListBuffered = params.m_dlInfoList; } } - if (m_harqOn == false) + if (!m_harqOn) { // Ignore HARQ feedback m_dlInfoListBuffered.clear(); } - std::vector dlInfoListUntxed; + 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); @@ -711,7 +707,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( bool free = true; for (std::size_t j = 0; j < dciRbg.size(); j++) { - if (rbgMap.at(dciRbg.at(j)) == true) + if (rbgMap.at(dciRbg.at(j))) { free = false; break; @@ -739,7 +735,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( std::vector rbgMapCopy = rbgMap; while ((j < dciRbg.size()) && (startRbg != rbgId)) { - if (rbgMapCopy.at(rbgId) == false) + if (!rbgMapCopy.at(rbgId)) { rbgMapCopy.at(rbgId) = true; dciRbg.at(j) = rbgId; @@ -810,7 +806,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( } for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++) { - std::vector rlcPduListPerLc; + std::vector rlcPduListPerLc; for (std::size_t j = 0; j < nLayers; j++) { if (retx.at(j)) @@ -1046,7 +1042,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) || ((*itBufReq).second.m_rlcStatusPduSize > 0))) { - std::vector newRlcPduLe; + std::vector newRlcPduLe; for (uint8_t j = 0; j < nLayer; j++) { RlcPduListElement_s newRlcEl; @@ -1058,7 +1054,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( UpdateDlRlcBufferInfo(newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size); - if (m_harqOn == true) + if (m_harqOn) { // store RLC PDU list for HARQ std::map::iterator itRlcPdu = @@ -1088,7 +1084,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = newDci; - if (m_harqOn == true) + if (m_harqOn) { // store DCI for HARQ std::map::iterator itDci = @@ -1149,7 +1145,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( void TdBetFfMacScheduler::DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1158,7 +1154,7 @@ TdBetFfMacScheduler::DoSchedDlRachInfoReq( void TdBetFfMacScheduler::DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1252,7 +1248,7 @@ TdBetFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) void TdBetFfMacScheduler::DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size()); @@ -1281,7 +1277,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( } } - if (m_harqOn == true) + if (m_harqOn) { // Process UL HARQ feedback for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++) @@ -1321,7 +1317,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; NS_LOG_INFO(this << " BUSY " << j); @@ -1457,7 +1453,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; break; @@ -1572,7 +1568,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( ret.m_dciList.push_back(uldci); // store DCI for HARQ_PERIOD uint8_t harqId = 0; - if (m_harqOn == true) + if (m_harqOn) { std::map::iterator itProcId; itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); @@ -1652,21 +1648,21 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( void TdBetFfMacScheduler::DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) { NS_LOG_FUNCTION(this); } void TdBetFfMacScheduler::DoSchedUlSrInfoReq( - const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) { NS_LOG_FUNCTION(this); } void TdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1709,7 +1705,7 @@ TdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq( void TdBetFfMacScheduler::DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); // retrieve the allocation for this subframe diff --git a/src/lte/model/tdbet-ff-mac-scheduler.h b/src/lte/model/tdbet-ff-mac-scheduler.h index 01e34ae28..a9b056f1e 100644 --- a/src/lte/model/tdbet-ff-mac-scheduler.h +++ b/src/lte/model/tdbet-ff-mac-scheduler.h @@ -21,37 +21,21 @@ #ifndef TDBET_FF_MAC_SCHEDULER_H #define TDBET_FF_MAC_SCHEDULER_H -#include -#include -#include -#include -#include -#include +#include "ff-mac-csched-sap.h" +#include "ff-mac-sched-sap.h" +#include "ff-mac-scheduler.h" +#include "lte-amc.h" +#include "lte-common.h" +#include "lte-ffr-sap.h" + #include #include #include -// value for SINR outside the range defined by FF-API, used to indicate that there -// is no CQI for this element -#define NO_SINR -5000 - -#define HARQ_PROC_NUM 8 -#define HARQ_DL_TIMEOUT 11 - namespace ns3 { -typedef std::vector DlHarqProcessesStatus_t; -typedef std::vector DlHarqProcessesTimer_t; -typedef std::vector DlHarqProcessesDciBuffer_t; -typedef std::vector> - RlcPduList_t; // vector of the LCs and layers per UE -typedef std::vector DlHarqRlcPduListBuffer_t; // vector of the 8 HARQ processes per UE - -typedef std::vector UlHarqProcessesDciBuffer_t; -typedef std::vector UlHarqProcessesStatus_t; - /// tdbetsFlowPerf_t structure struct tdbetsFlowPerf_t { @@ -123,36 +107,31 @@ class TdBetFfMacScheduler : public FfMacScheduler * \brief CSched cell config request * \param params FfMacCschedSapProvider::CschedCellConfigReqParameters */ - void DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params); + void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters& params); /** * \brief CSched UE config request * \param params FfMacCschedSapProvider::CschedUeConfigReqParameters */ - void DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params); + void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters& params); /** * \brief CSched LC config request * \param params FfMacCschedSapProvider::CschedLcConfigReqParameters */ - void DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params); + void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters& params); /** * \brief CSched LC release request * \param params FfMacCschedSapProvider::CschedLcReleaseReqParameters */ - void DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); + void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); /** * \brief CSched UE release request * \param params FfMacCschedSapProvider::CschedUeReleaseReqParameters */ - void DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); + void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); // // Implementation of the SCHED API primitives @@ -163,77 +142,70 @@ class TdBetFfMacScheduler : public FfMacScheduler * \brief Sched DL RLC buffer request * \param params FfMacSchedSapProvider::SchedDlRlcBufferReqParameters */ - void DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); + void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); /** * \brief Sched DL paging buffer request * \param params FfMacSchedSapProvider::SchedDlPagingBufferReqParameters */ void DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); /** * \brief Sched DL MAC buffer request * \param params FfMacSchedSapProvider::SchedDlMacBufferReqParameters */ - void DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); + void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); /** * \brief Sched DL trigger request * \param params FfMacSchedSapProvider::SchedDlTriggerReqParameters */ - void DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); + void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); /** * \brief Sched DL RACH info request * \param params FfMacSchedSapProvider::SchedDlRachInfoReqParameters */ - void DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); + void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); /** * \brief Sched DL CQI info request * \param params FfMacSchedSapProvider::SchedDlCqiInfoReqParameters */ - void DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); + void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); /** * \brief Sched UL trigger request * \param params FfMacSchedSapProvider::SchedUlTriggerReqParameters */ - void DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); + void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); /** * \brief Sched UL noise interference request * \param params FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters */ void DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); /** * \brief Sched UL SR info request * \param params FfMacSchedSapProvider::SchedUlSrInfoReqParameters */ - void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); + void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); /** * \brief Sched UL MAC control info request * \param params FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters */ void DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); /** * \brief Sched UL CQI info request * \param params FfMacSchedSapProvider::SchedUlCqiInfoReqParameters */ - void DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); + void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); /** * \brief Get RBG size function @@ -401,9 +373,9 @@ class TdBetFfMacScheduler : public FfMacScheduler m_ulHarqProcessesDciBuffer; ///< UL HARQ process DCI buffer // RACH attributes - std::vector m_rachList; ///< RACH list - std::vector m_rachAllocationMap; ///< RACH allocation map - uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) + std::vector m_rachList; ///< RACH list + std::vector m_rachAllocationMap; ///< RACH allocation map + uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) }; } // namespace ns3 diff --git a/src/lte/model/tdmt-ff-mac-scheduler.cc b/src/lte/model/tdmt-ff-mac-scheduler.cc index 7c1a0ce9f..42fc8865f 100644 --- a/src/lte/model/tdmt-ff-mac-scheduler.cc +++ b/src/lte/model/tdmt-ff-mac-scheduler.cc @@ -18,14 +18,16 @@ * Modification: Dizhi Zhou // modify codes related to downlink scheduler */ +#include "tdmt-ff-mac-scheduler.h" + +#include "lte-amc.h" +#include "lte-vendor-specific-parameters.h" + #include #include -#include -#include #include #include #include -#include #include #include @@ -139,7 +141,7 @@ TdMtFfMacScheduler::GetLteFfrSapUser() void TdMtFfMacScheduler::DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params) + const FfMacCschedSapProvider::CschedCellConfigReqParameters& params) { NS_LOG_FUNCTION(this); // Read the subset of parameters used @@ -152,7 +154,7 @@ TdMtFfMacScheduler::DoCschedCellConfigReq( void TdMtFfMacScheduler::DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params) + const FfMacCschedSapProvider::CschedUeConfigReqParameters& params) { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); @@ -198,7 +200,7 @@ TdMtFfMacScheduler::DoCschedUeConfigReq( void TdMtFfMacScheduler::DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params) + const FfMacCschedSapProvider::CschedLcConfigReqParameters& params) { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); @@ -217,7 +219,7 @@ TdMtFfMacScheduler::DoCschedLcConfigReq( void TdMtFfMacScheduler::DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) @@ -244,7 +246,7 @@ TdMtFfMacScheduler::DoCschedLcReleaseReq( void TdMtFfMacScheduler::DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) { NS_LOG_FUNCTION(this); @@ -284,7 +286,7 @@ TdMtFfMacScheduler::DoCschedUeReleaseReq( void TdMtFfMacScheduler::DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) { 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) @@ -309,7 +311,7 @@ TdMtFfMacScheduler::DoSchedDlRlcBufferReq( void TdMtFfMacScheduler::DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -317,7 +319,7 @@ TdMtFfMacScheduler::DoSchedDlPagingBufferReq( void TdMtFfMacScheduler::DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -379,14 +381,8 @@ TdMtFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { i = (i + 1) % HARQ_PROC_NUM; } while (((*itStat).second.at(i) != 0) && (i != (*it).second)); - if ((*itStat).second.at(i) == 0) - { - return (true); - } - else - { - return (false); // return a not valid harq proc id - } + + return (*itStat).second.at(i) == 0; } uint8_t @@ -394,7 +390,7 @@ TdMtFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - if (m_harqOn == false) + if (!m_harqOn) { return (0); } @@ -465,7 +461,7 @@ TdMtFfMacScheduler::RefreshHarqProcesses() void TdMtFfMacScheduler::DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); @@ -497,7 +493,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; + std::vector::iterator itRach; for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > @@ -539,7 +535,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.at(i) = (*itRach).m_rnti; } - if (m_harqOn == true) + if (m_harqOn) { // generate UL-DCI for HARQ retransmissions UlDciListElement_s uldci; @@ -604,12 +600,12 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( m_dlInfoListBuffered = params.m_dlInfoList; } } - if (m_harqOn == false) + if (!m_harqOn) { // Ignore HARQ feedback m_dlInfoListBuffered.clear(); } - std::vector dlInfoListUntxed; + 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); @@ -700,7 +696,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( bool free = true; for (std::size_t j = 0; j < dciRbg.size(); j++) { - if (rbgMap.at(dciRbg.at(j)) == true) + if (rbgMap.at(dciRbg.at(j))) { free = false; break; @@ -728,7 +724,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( std::vector rbgMapCopy = rbgMap; while ((j < dciRbg.size()) && (startRbg != rbgId)) { - if (rbgMapCopy.at(rbgId) == false) + if (!rbgMapCopy.at(rbgId)) { rbgMapCopy.at(rbgId) = true; dciRbg.at(j) = rbgId; @@ -799,7 +795,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( } for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++) { - std::vector rlcPduListPerLc; + std::vector rlcPduListPerLc; for (std::size_t j = 0; j < nLayers; j++) { if (retx.at(j)) @@ -967,7 +963,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( { NS_LOG_INFO(this << " ALLOCATION for RBG " << i << " of " << rbgNum); NS_LOG_DEBUG(this << " ALLOCATION for RBG " << i << " of " << rbgNum); - if (rbgMap.at(i) == false) + if (!rbgMap.at(i)) { rbgMap.at(i) = true; tempMap.push_back(i); @@ -1046,7 +1042,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) || ((*itBufReq).second.m_rlcStatusPduSize > 0))) { - std::vector newRlcPduLe; + std::vector newRlcPduLe; for (uint8_t j = 0; j < nLayer; j++) { RlcPduListElement_s newRlcEl; @@ -1058,7 +1054,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( UpdateDlRlcBufferInfo(newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size); - if (m_harqOn == true) + if (m_harqOn) { // store RLC PDU list for HARQ std::map::iterator itRlcPdu = @@ -1088,7 +1084,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = newDci; - if (m_harqOn == true) + if (m_harqOn) { // store DCI for HARQ std::map::iterator itDci = @@ -1122,7 +1118,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( void TdMtFfMacScheduler::DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1131,7 +1127,7 @@ TdMtFfMacScheduler::DoSchedDlRachInfoReq( void TdMtFfMacScheduler::DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1225,7 +1221,7 @@ TdMtFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) void TdMtFfMacScheduler::DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size()); @@ -1254,7 +1250,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( } } - if (m_harqOn == true) + if (m_harqOn) { // Process UL HARQ feedback for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++) @@ -1294,7 +1290,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; NS_LOG_INFO(this << " BUSY " << j); @@ -1429,7 +1425,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; break; @@ -1544,7 +1540,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( ret.m_dciList.push_back(uldci); // store DCI for HARQ_PERIOD uint8_t harqId = 0; - if (m_harqOn == true) + if (m_harqOn) { std::map::iterator itProcId; itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); @@ -1599,21 +1595,21 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( void TdMtFfMacScheduler::DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) { NS_LOG_FUNCTION(this); } void TdMtFfMacScheduler::DoSchedUlSrInfoReq( - const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) { NS_LOG_FUNCTION(this); } void TdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1656,7 +1652,7 @@ TdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq( void TdMtFfMacScheduler::DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); // retrieve the allocation for this subframe diff --git a/src/lte/model/tdmt-ff-mac-scheduler.h b/src/lte/model/tdmt-ff-mac-scheduler.h index 927288894..e889b1846 100644 --- a/src/lte/model/tdmt-ff-mac-scheduler.h +++ b/src/lte/model/tdmt-ff-mac-scheduler.h @@ -21,38 +21,22 @@ #ifndef TDMT_FF_MAC_SCHEDULER_H #define TDMT_FF_MAC_SCHEDULER_H -#include -#include -#include -#include -#include -#include +#include "ff-mac-csched-sap.h" +#include "ff-mac-sched-sap.h" +#include "ff-mac-scheduler.h" +#include "lte-amc.h" +#include "lte-common.h" +#include "lte-ffr-sap.h" + #include #include #include #include -// value for SINR outside the range defined by FF-API, used to indicate that there -// is no CQI for this element -#define NO_SINR -5000 - -#define HARQ_PROC_NUM 8 -#define HARQ_DL_TIMEOUT 11 - namespace ns3 { -typedef std::vector DlHarqProcessesStatus_t; -typedef std::vector DlHarqProcessesTimer_t; -typedef std::vector DlHarqProcessesDciBuffer_t; -typedef std::vector> - RlcPduList_t; // vector of the LCs and layers per UE -typedef std::vector DlHarqRlcPduListBuffer_t; // vector of the 8 HARQ processes per UE - -typedef std::vector UlHarqProcessesDciBuffer_t; -typedef std::vector UlHarqProcessesStatus_t; - /** * \ingroup ff-api * \brief Implements the SCHED SAP and CSCHED SAP for a Time Domain Maximize Throughput scheduler @@ -115,36 +99,31 @@ class TdMtFfMacScheduler : public FfMacScheduler * \brief CSched cell config request * \param params FfMacCschedSapProvider::CschedCellConfigReqParameters */ - void DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params); + void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters& params); /** * \brief CSched UE config request * \param params FfMacCschedSapProvider::CschedUeConfigReqParameters */ - void DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params); + void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters& params); /** * \brief CSched LC config request * \param params FfMacCschedSapProvider::CschedLcConfigReqParameters */ - void DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params); + void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters& params); /** * \brief CSched LC release request * \param params FfMacCschedSapProvider::CschedLcReleaseReqParameters */ - void DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); + void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); /** * \brief CSched UE release request * \param params FfMacCschedSapProvider::CschedUeReleaseReqParameters */ - void DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); + void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); // // Implementation of the SCHED API primitives @@ -155,77 +134,70 @@ class TdMtFfMacScheduler : public FfMacScheduler * \brief Sched DL RLC buffer request * \param params FfMacSchedSapProvider::SchedDlRlcBufferReqParameters */ - void DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); + void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); /** * \brief Sched DL paging buffer request * \param params FfMacSchedSapProvider::SchedDlPagingBufferReqParameters */ void DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); /** * \brief Sched DL MAC buffer request * \param params FfMacSchedSapProvider::SchedDlMacBufferReqParameters */ - void DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); + void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); /** * \brief Sched DL trigger request * \param params FfMacSchedSapProvider::SchedDlTriggerReqParameters */ - void DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); + void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); /** * \brief Sched DL RACH info request * \param params FfMacSchedSapProvider::SchedDlRachInfoReqParameters */ - void DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); + void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); /** * \brief Sched DL CQI info request * \param params FfMacSchedSapProvider::SchedDlCqiInfoReqParameters */ - void DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); + void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); /** * \brief Sched UL trigger request * \param params FfMacSchedSapProvider::SchedUlTriggerReqParameters */ - void DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); + void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); /** * \brief Sched UL noise interference request * \param params FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters */ void DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); /** * \brief Sched UL SR info request * \param params FfMacSchedSapProvider::SchedUlSrInfoReqParameters */ - void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); + void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); /** * \brief Sched UL MAC control info request * \param params FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters */ void DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); /** * \brief Sched UL CQI info request * \param params FfMacSchedSapProvider::SchedUlCqiInfoReqParameters */ - void DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); + void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); /** * \brief Get RBG size function @@ -391,9 +363,9 @@ class TdMtFfMacScheduler : public FfMacScheduler m_ulHarqProcessesDciBuffer; ///< UL HARQ process DCI buffer // RACH attributes - std::vector m_rachList; ///< RACH list - std::vector m_rachAllocationMap; ///< RACH allocation map - uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) + std::vector m_rachList; ///< RACH list + std::vector m_rachAllocationMap; ///< RACH allocation map + uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) }; } // namespace ns3 diff --git a/src/lte/model/tdtbfq-ff-mac-scheduler.cc b/src/lte/model/tdtbfq-ff-mac-scheduler.cc index 92eb85d0f..9d2300390 100644 --- a/src/lte/model/tdtbfq-ff-mac-scheduler.cc +++ b/src/lte/model/tdtbfq-ff-mac-scheduler.cc @@ -18,15 +18,17 @@ * Modification: Dizhi Zhou // modify codes related to downlink scheduler */ +#include "tdtbfq-ff-mac-scheduler.h" + +#include "lte-amc.h" +#include "lte-vendor-specific-parameters.h" + #include #include #include -#include -#include #include #include #include -#include #include #include @@ -165,7 +167,7 @@ TdTbfqFfMacScheduler::GetLteFfrSapUser() void TdTbfqFfMacScheduler::DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params) + const FfMacCschedSapProvider::CschedCellConfigReqParameters& params) { NS_LOG_FUNCTION(this); // Read the subset of parameters used @@ -178,7 +180,7 @@ TdTbfqFfMacScheduler::DoCschedCellConfigReq( void TdTbfqFfMacScheduler::DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params) + const FfMacCschedSapProvider::CschedUeConfigReqParameters& params) { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); @@ -224,7 +226,7 @@ TdTbfqFfMacScheduler::DoCschedUeConfigReq( void TdTbfqFfMacScheduler::DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params) + const FfMacCschedSapProvider::CschedLcConfigReqParameters& params) { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); @@ -280,7 +282,7 @@ TdTbfqFfMacScheduler::DoCschedLcConfigReq( void TdTbfqFfMacScheduler::DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) @@ -307,7 +309,7 @@ TdTbfqFfMacScheduler::DoCschedLcReleaseReq( void TdTbfqFfMacScheduler::DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) { NS_LOG_FUNCTION(this); @@ -347,7 +349,7 @@ TdTbfqFfMacScheduler::DoCschedUeReleaseReq( void TdTbfqFfMacScheduler::DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) { 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) @@ -372,7 +374,7 @@ TdTbfqFfMacScheduler::DoSchedDlRlcBufferReq( void TdTbfqFfMacScheduler::DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -380,7 +382,7 @@ TdTbfqFfMacScheduler::DoSchedDlPagingBufferReq( void TdTbfqFfMacScheduler::DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -442,14 +444,8 @@ TdTbfqFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { i = (i + 1) % HARQ_PROC_NUM; } while (((*itStat).second.at(i) != 0) && (i != (*it).second)); - if ((*itStat).second.at(i) == 0) - { - return (true); - } - else - { - return (false); // return a not valid harq proc id - } + + return (*itStat).second.at(i) == 0; } uint8_t @@ -457,7 +453,7 @@ TdTbfqFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - if (m_harqOn == false) + if (!m_harqOn) { return (0); } @@ -528,7 +524,7 @@ TdTbfqFfMacScheduler::RefreshHarqProcesses() void TdTbfqFfMacScheduler::DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); @@ -551,7 +547,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) { - if ((*it) == true) + if (*it) { rbgAllocatedNum++; } @@ -579,7 +575,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) { - if ((*it) == true) + if (*it) { if (tmpMinBandwidth > maxContinuousUlBandwidth) { @@ -608,7 +604,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; + std::vector::iterator itRach; for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > @@ -650,7 +646,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.at(i) = (*itRach).m_rnti; } - if (m_harqOn == true) + if (m_harqOn) { // generate UL-DCI for HARQ retransmissions UlDciListElement_s uldci; @@ -715,12 +711,12 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( m_dlInfoListBuffered = params.m_dlInfoList; } } - if (m_harqOn == false) + if (!m_harqOn) { // Ignore HARQ feedback m_dlInfoListBuffered.clear(); } - std::vector dlInfoListUntxed; + 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); @@ -811,7 +807,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( bool free = true; for (std::size_t j = 0; j < dciRbg.size(); j++) { - if (rbgMap.at(dciRbg.at(j)) == true) + if (rbgMap.at(dciRbg.at(j))) { free = false; break; @@ -839,7 +835,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( std::vector rbgMapCopy = rbgMap; while ((j < dciRbg.size()) && (startRbg != rbgId)) { - if (rbgMapCopy.at(rbgId) == false) + if (!rbgMapCopy.at(rbgId)) { rbgMapCopy.at(rbgId) = true; dciRbg.at(j) = rbgId; @@ -910,7 +906,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( } for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++) { - std::vector rlcPduListPerLc; + std::vector rlcPduListPerLc; for (std::size_t j = 0; j < nLayers; j++) { if (retx.at(j)) @@ -1080,7 +1076,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( double metric = (((double)(*it).second.counter) / ((double)(*it).second.tokenGenerationRate)); - if (firstRnti == true) + if (firstRnti) { metricMax = metric; itMax = it; @@ -1106,12 +1102,12 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( std::vector tempMap; for (int i = 0; i < rbgNum; i++) { - if (rbgMap.at(i) == true) + if (rbgMap.at(i)) { // this RBG is allocated in RACH procedure continue; } - if ((m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*itMax).first)) == false) + if (!m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*itMax).first)) { continue; } @@ -1232,7 +1228,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) || ((*itBufReq).second.m_rlcStatusPduSize > 0))) { - std::vector newRlcPduLe; + std::vector newRlcPduLe; for (uint8_t j = 0; j < nLayer; j++) { RlcPduListElement_s newRlcEl; @@ -1244,7 +1240,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( UpdateDlRlcBufferInfo(newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size); - if (m_harqOn == true) + if (m_harqOn) { // store RLC PDU list for HARQ std::map::iterator itRlcPdu = @@ -1274,7 +1270,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = newDci; - if (m_harqOn == true) + if (m_harqOn) { // store DCI for HARQ std::map::iterator itDci = @@ -1328,7 +1324,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( void TdTbfqFfMacScheduler::DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1337,7 +1333,7 @@ TdTbfqFfMacScheduler::DoSchedDlRachInfoReq( void TdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); m_ffrSapProvider->ReportDlCqiInfo(params); @@ -1432,7 +1428,7 @@ TdTbfqFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) void TdTbfqFfMacScheduler::DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size()); @@ -1458,7 +1454,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) { - if ((*it) == true) + if (*it) { rbAllocatedNum++; } @@ -1477,7 +1473,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( } } - if (m_harqOn == true) + if (m_harqOn) { // Process UL HARQ feedback for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++) @@ -1517,7 +1513,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; NS_LOG_INFO(this << " BUSY " << j); @@ -1658,12 +1654,12 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; break; } - if ((m_ffrSapProvider->IsUlRbgAvailableForUe(j, (*it).first)) == false) + if (!m_ffrSapProvider->IsUlRbgAvailableForUe(j, (*it).first)) { free = false; break; @@ -1780,7 +1776,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( ret.m_dciList.push_back(uldci); // store DCI for HARQ_PERIOD uint8_t harqId = 0; - if (m_harqOn == true) + if (m_harqOn) { std::map::iterator itProcId; itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); @@ -1835,21 +1831,21 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( void TdTbfqFfMacScheduler::DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) { NS_LOG_FUNCTION(this); } void TdTbfqFfMacScheduler::DoSchedUlSrInfoReq( - const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) { NS_LOG_FUNCTION(this); } void TdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1892,7 +1888,7 @@ TdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq( void TdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); // retrieve the allocation for this subframe diff --git a/src/lte/model/tdtbfq-ff-mac-scheduler.h b/src/lte/model/tdtbfq-ff-mac-scheduler.h index ee16385f9..8dc2c03d6 100644 --- a/src/lte/model/tdtbfq-ff-mac-scheduler.h +++ b/src/lte/model/tdtbfq-ff-mac-scheduler.h @@ -21,37 +21,21 @@ #ifndef TDTBFQ_FF_MAC_SCHEDULER_H #define TDTBFQ_FF_MAC_SCHEDULER_H -#include -#include -#include -#include -#include -#include +#include "ff-mac-csched-sap.h" +#include "ff-mac-sched-sap.h" +#include "ff-mac-scheduler.h" +#include "lte-amc.h" +#include "lte-common.h" +#include "lte-ffr-sap.h" + #include #include #include -// value for SINR outside the range defined by FF-API, used to indicate that there -// is no CQI for this element -#define NO_SINR -5000 - -#define HARQ_PROC_NUM 8 -#define HARQ_DL_TIMEOUT 11 - namespace ns3 { -typedef std::vector DlHarqProcessesStatus_t; -typedef std::vector DlHarqProcessesTimer_t; -typedef std::vector DlHarqProcessesDciBuffer_t; -typedef std::vector> - RlcPduList_t; // vector of the LCs and layers per UE -typedef std::vector DlHarqRlcPduListBuffer_t; // vector of the 8 HARQ processes per UE - -typedef std::vector UlHarqProcessesDciBuffer_t; -typedef std::vector UlHarqProcessesStatus_t; - /** * Flow information */ @@ -132,36 +116,31 @@ class TdTbfqFfMacScheduler : public FfMacScheduler * \brief CSched cell config request * \param params FfMacCschedSapProvider::CschedCellConfigReqParameters */ - void DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params); + void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters& params); /** * \brief CSched UE config request * \param params FfMacCschedSapProvider::CschedUeConfigReqParameters */ - void DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params); + void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters& params); /** * \brief CSched LC config request * \param params FfMacCschedSapProvider::CschedLcConfigReqParameters */ - void DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params); + void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters& params); /** * \brief CSched LC release request * \param params FfMacCschedSapProvider::CschedLcReleaseReqParameters */ - void DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); + void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); /** * \brief CSched UE release request * \param params FfMacCschedSapProvider::CschedUeReleaseReqParameters */ - void DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); + void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); // // Implementation of the SCHED API primitives @@ -172,77 +151,70 @@ class TdTbfqFfMacScheduler : public FfMacScheduler * \brief Sched DL RLC buffer request * \param params FfMacSchedSapProvider::SchedDlRlcBufferReqParameters */ - void DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); + void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); /** * \brief Sched DL paging buffer request * \param params FfMacSchedSapProvider::SchedDlPagingBufferReqParameters */ void DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); /** * \brief Sched DL MAC buffer request * \param params FfMacSchedSapProvider::SchedDlMacBufferReqParameters */ - void DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); + void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); /** * \brief Sched DL trigger request * \param params FfMacSchedSapProvider::SchedDlTriggerReqParameters */ - void DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); + void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); /** * \brief Sched DL RACH info request * \param params FfMacSchedSapProvider::SchedDlRachInfoReqParameters */ - void DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); + void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); /** * \brief Sched DL CQI info request * \param params FfMacSchedSapProvider::SchedDlCqiInfoReqParameters */ - void DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); + void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); /** * \brief Sched UL trigger request * \param params FfMacSchedSapProvider::SchedUlTriggerReqParameters */ - void DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); + void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); /** * \brief Sched UL noise interference request * \param params FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters */ void DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); /** * \brief Sched UL SR info request * \param params FfMacSchedSapProvider::SchedUlSrInfoReqParameters */ - void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); + void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); /** * \brief Sched UL MAC control info request * \param params FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters */ void DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); /** * \brief Sched UL CQI info request * \param params FfMacSchedSapProvider::SchedUlCqiInfoReqParameters */ - void DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); + void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); /** * \brief Get RBG size @@ -418,9 +390,9 @@ class TdTbfqFfMacScheduler : public FfMacScheduler m_ulHarqProcessesDciBuffer; ///< UL HARQ process DCI buffer // RACH attributes - std::vector m_rachList; ///< RACH list - std::vector m_rachAllocationMap; ///< RACH allocation map - uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) + std::vector m_rachList; ///< RACH list + std::vector m_rachAllocationMap; ///< RACH allocation map + uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) }; } // namespace ns3 diff --git a/src/lte/model/tta-ff-mac-scheduler.cc b/src/lte/model/tta-ff-mac-scheduler.cc index 6d151ab17..0b6b58d8e 100644 --- a/src/lte/model/tta-ff-mac-scheduler.cc +++ b/src/lte/model/tta-ff-mac-scheduler.cc @@ -18,14 +18,16 @@ * Modification: Dizhi Zhou // modify codes related to downlink scheduler */ +#include "tta-ff-mac-scheduler.h" + +#include "lte-amc.h" +#include "lte-vendor-specific-parameters.h" + #include #include -#include -#include #include #include #include -#include #include #include @@ -139,7 +141,7 @@ TtaFfMacScheduler::GetLteFfrSapUser() void TtaFfMacScheduler::DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params) + const FfMacCschedSapProvider::CschedCellConfigReqParameters& params) { NS_LOG_FUNCTION(this); // Read the subset of parameters used @@ -152,7 +154,7 @@ TtaFfMacScheduler::DoCschedCellConfigReq( void TtaFfMacScheduler::DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params) + const FfMacCschedSapProvider::CschedUeConfigReqParameters& params) { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); @@ -198,7 +200,7 @@ TtaFfMacScheduler::DoCschedUeConfigReq( void TtaFfMacScheduler::DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params) + const FfMacCschedSapProvider::CschedLcConfigReqParameters& params) { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); @@ -217,7 +219,7 @@ TtaFfMacScheduler::DoCschedLcConfigReq( void TtaFfMacScheduler::DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) @@ -244,7 +246,7 @@ TtaFfMacScheduler::DoCschedLcReleaseReq( void TtaFfMacScheduler::DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) + const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params) { NS_LOG_FUNCTION(this); @@ -284,7 +286,7 @@ TtaFfMacScheduler::DoCschedUeReleaseReq( void TtaFfMacScheduler::DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params) { 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) @@ -309,7 +311,7 @@ TtaFfMacScheduler::DoSchedDlRlcBufferReq( void TtaFfMacScheduler::DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -317,7 +319,7 @@ TtaFfMacScheduler::DoSchedDlPagingBufferReq( void TtaFfMacScheduler::DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) + const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params) { NS_LOG_FUNCTION(this); NS_FATAL_ERROR("method not implemented"); @@ -379,14 +381,8 @@ TtaFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { i = (i + 1) % HARQ_PROC_NUM; } while (((*itStat).second.at(i) != 0) && (i != (*it).second)); - if ((*itStat).second.at(i) == 0) - { - return (true); - } - else - { - return (false); // return a not valid harq proc id - } + + return (*itStat).second.at(i) == 0; } uint8_t @@ -394,7 +390,7 @@ TtaFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - if (m_harqOn == false) + if (!m_harqOn) { return (0); } @@ -465,7 +461,7 @@ TtaFfMacScheduler::RefreshHarqProcesses() void TtaFfMacScheduler::DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); @@ -497,7 +493,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; + std::vector::iterator itRach; for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > @@ -539,7 +535,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.at(i) = (*itRach).m_rnti; } - if (m_harqOn == true) + if (m_harqOn) { // generate UL-DCI for HARQ retransmissions UlDciListElement_s uldci; @@ -604,12 +600,12 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( m_dlInfoListBuffered = params.m_dlInfoList; } } - if (m_harqOn == false) + if (!m_harqOn) { // Ignore HARQ feedback m_dlInfoListBuffered.clear(); } - std::vector dlInfoListUntxed; + 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); @@ -700,7 +696,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( bool free = true; for (std::size_t j = 0; j < dciRbg.size(); j++) { - if (rbgMap.at(dciRbg.at(j)) == true) + if (rbgMap.at(dciRbg.at(j))) { free = false; break; @@ -728,7 +724,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( std::vector rbgMapCopy = rbgMap; while ((j < dciRbg.size()) && (startRbg != rbgId)) { - if (rbgMapCopy.at(rbgId) == false) + if (!rbgMapCopy.at(rbgId)) { rbgMapCopy.at(rbgId) = true; dciRbg.at(j) = rbgId; @@ -799,7 +795,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( } for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++) { - std::vector rlcPduListPerLc; + std::vector rlcPduListPerLc; for (std::size_t j = 0; j < nLayers; j++) { if (retx.at(j)) @@ -887,7 +883,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( for (int i = 0; i < rbgNum; i++) { NS_LOG_INFO(this << " ALLOCATION for RBG " << i << " of " << rbgNum); - if (rbgMap.at(i) == false) + if (!rbgMap.at(i)) { std::set::iterator it; std::set::iterator itMax = m_flowStatsDl.end(); @@ -1134,7 +1130,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) || ((*itBufReq).second.m_rlcStatusPduSize > 0))) { - std::vector newRlcPduLe; + std::vector newRlcPduLe; for (uint8_t j = 0; j < nLayer; j++) { RlcPduListElement_s newRlcEl; @@ -1146,7 +1142,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( UpdateDlRlcBufferInfo(newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size); - if (m_harqOn == true) + if (m_harqOn) { // store RLC PDU list for HARQ std::map::iterator itRlcPdu = @@ -1176,7 +1172,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = newDci; - if (m_harqOn == true) + if (m_harqOn) { // store DCI for HARQ std::map::iterator itDci = @@ -1210,7 +1206,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( void TtaFfMacScheduler::DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1219,7 +1215,7 @@ TtaFfMacScheduler::DoSchedDlRachInfoReq( void TtaFfMacScheduler::DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1313,7 +1309,7 @@ TtaFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) void TtaFfMacScheduler::DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) + const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params) { NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size()); @@ -1342,7 +1338,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( } } - if (m_harqOn == true) + if (m_harqOn) { // Process UL HARQ feedback for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++) @@ -1382,7 +1378,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; NS_LOG_INFO(this << " BUSY " << j); @@ -1517,7 +1513,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( bool free = true; for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - if (rbMap.at(j) == true) + if (rbMap.at(j)) { free = false; break; @@ -1632,7 +1628,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( ret.m_dciList.push_back(uldci); // store DCI for HARQ_PERIOD uint8_t harqId = 0; - if (m_harqOn == true) + if (m_harqOn) { std::map::iterator itProcId; itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); @@ -1687,21 +1683,21 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( void TtaFfMacScheduler::DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params) { NS_LOG_FUNCTION(this); } void TtaFfMacScheduler::DoSchedUlSrInfoReq( - const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params) { NS_LOG_FUNCTION(this); } void TtaFfMacScheduler::DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params) { NS_LOG_FUNCTION(this); @@ -1744,7 +1740,7 @@ TtaFfMacScheduler::DoSchedUlMacCtrlInfoReq( void TtaFfMacScheduler::DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); // retrieve the allocation for this subframe diff --git a/src/lte/model/tta-ff-mac-scheduler.h b/src/lte/model/tta-ff-mac-scheduler.h index 8566bffaa..d39f98a11 100644 --- a/src/lte/model/tta-ff-mac-scheduler.h +++ b/src/lte/model/tta-ff-mac-scheduler.h @@ -21,38 +21,22 @@ #ifndef TTA_FF_MAC_SCHEDULER_H #define TTA_FF_MAC_SCHEDULER_H -#include -#include -#include -#include -#include -#include +#include "ff-mac-csched-sap.h" +#include "ff-mac-sched-sap.h" +#include "ff-mac-scheduler.h" +#include "lte-amc.h" +#include "lte-common.h" +#include "lte-ffr-sap.h" + #include #include #include #include -// value for SINR outside the range defined by FF-API, used to indicate that there -// is no CQI for this element -#define NO_SINR -5000 - -#define HARQ_PROC_NUM 8 -#define HARQ_DL_TIMEOUT 11 - namespace ns3 { -typedef std::vector DlHarqProcessesStatus_t; -typedef std::vector DlHarqProcessesTimer_t; -typedef std::vector DlHarqProcessesDciBuffer_t; -typedef std::vector> - RlcPduList_t; // vector of the LCs and layers per UE -typedef std::vector DlHarqRlcPduListBuffer_t; // vector of the 8 HARQ processes per UE - -typedef std::vector UlHarqProcessesDciBuffer_t; -typedef std::vector UlHarqProcessesStatus_t; - /** * \ingroup ff-api * \brief Implements the SCHED SAP and CSCHED SAP for a Throughput to Average scheduler @@ -115,36 +99,31 @@ class TtaFfMacScheduler : public FfMacScheduler * \brief CSched cell config request function * \param params FfMacCschedSapProvider::CschedCellConfigReqParameters */ - void DoCschedCellConfigReq( - const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params); + void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters& params); /** * \brief CSched UE config request function * \param params FfMacCschedSapProvider::CschedUeConfigReqParameters */ - void DoCschedUeConfigReq( - const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params); + void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters& params); /** * \brief CSched LC config request function * \param params FfMacCschedSapProvider::CschedLcConfigReqParameters */ - void DoCschedLcConfigReq( - const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params); + void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters& params); /** * \brief CSched LC release request function * \param params FfMacCschedSapProvider::CschedLcReleaseReqParameters */ - void DoCschedLcReleaseReq( - const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); + void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params); /** * \brief CSched UE release request function * \param params FfMacCschedSapProvider::CschedUeReleaseReqParameters */ - void DoCschedUeReleaseReq( - const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); + void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters& params); // // Implementation of the SCHED API primitives @@ -155,77 +134,70 @@ class TtaFfMacScheduler : public FfMacScheduler * \brief Sched DL RLC buffer request function * \param params FfMacSchedSapProvider::SchedDlRlcBufferReqParameters */ - void DoSchedDlRlcBufferReq( - const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); + void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params); /** * \brief Sched DL paging buffer request function * \param params FfMacCschedSapProvider::SchedDlPagingBufferReqParameters */ void DoSchedDlPagingBufferReq( - const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); + const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params); /** * \brief Sched DL MAC buffer request function * \param params FfMacCschedSapProvider::SchedDlMacBufferReqParameters */ - void DoSchedDlMacBufferReq( - const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); + void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params); /** * \brief Sched DL trigger request function * \param params FfMacCschedSapProvider::SchedDlTriggerReqParameters */ - void DoSchedDlTriggerReq( - const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); + void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters& params); /** * \brief Sched DL RACH info request function * \param params FfMacCschedSapProvider::SchedDlRachInfoReqParameters */ - void DoSchedDlRachInfoReq( - const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); + void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params); /** * \brief Sched DL CQI info request function * \param params FfMacCschedSapProvider::SchedDlCqiInfoReqParameters */ - void DoSchedDlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); + void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params); /** * \brief Sched UL trigger request function * \param params FfMacCschedSapProvider::SchedUlTriggerReqParameters */ - void DoSchedUlTriggerReq( - const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); + void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters& params); /** * \brief Sched UL noise interference request function * \param params FfMacCschedSapProvider::SchedUlNoiseInterferenceReqParameters */ void DoSchedUlNoiseInterferenceReq( - const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); + const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params); /** * \brief Sched UL SR info request function * \param params FfMacCschedSapProvider::SchedUlSrInfoReqParameters */ - void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); + void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params); /** * \brief Sched UL MAC control info request function * \param params FfMacCschedSapProvider::SchedUlMacCtrlInfoReqParameters */ void DoSchedUlMacCtrlInfoReq( - const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); + const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params); /** * \brief Sched UL CQI info request function * \param params FfMacCschedSapProvider::SchedUlCqiInfoReqParameters */ - void DoSchedUlCqiInfoReq( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); + void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params); /** * \brief Get RBG size function @@ -391,9 +363,9 @@ class TtaFfMacScheduler : public FfMacScheduler m_ulHarqProcessesDciBuffer; ///< UL HARQ process DCI buffer // RACH attributes - std::vector m_rachList; ///< RACH list - std::vector m_rachAllocationMap; ///< RACH allocation map - uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) + std::vector m_rachList; ///< RACH list + std::vector m_rachAllocationMap; ///< RACH allocation map + uint8_t m_ulGrantMcs; ///< MCS for UL grant (default 0) }; } // namespace ns3 diff --git a/src/lte/test/examples-to-run.py b/src/lte/test/examples-to-run.py index bec96595a..413403833 100644 --- a/src/lte/test/examples-to-run.py +++ b/src/lte/test/examples-to-run.py @@ -1,6 +1,4 @@ #! /usr/bin/env python3 -# -*- coding: utf-8 -*- -## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- # A list of C++ examples to run in order to ensure that they remain # buildable and runnable over time. Each tuple in the list contains @@ -32,16 +30,16 @@ cpp_examples = [ ("lena-simple", "True", "True"), ("lena-simple-epc", "True", "True"), ("lena-x2-handover", "True", "True"), - ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::TtaFfMacScheduler", "options.valgrind", "True"), - ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::TdTbfqFfMacScheduler", "options.valgrind", "True"), - ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::TdMtFfMacScheduler", "options.valgrind", "True"), - ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::TdBetFfMacScheduler", "options.valgrind", "True"), - ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::RrFfMacScheduler", "options.valgrind", "True"), - ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::PssFfMacScheduler", "options.valgrind", "True"), - ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::PfFfMacScheduler", "options.valgrind", "True"), - ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::FdTbfqFfMacScheduler", "options.valgrind", "True"), - ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::FdMtFfMacScheduler", "options.valgrind", "True"), - ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::FdBetFfMacScheduler", "options.valgrind", "True"), + ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::TtaFfMacScheduler", "args.valgrind", "True"), + ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::TdTbfqFfMacScheduler", "args.valgrind", "True"), + ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::TdMtFfMacScheduler", "args.valgrind", "True"), + ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::TdBetFfMacScheduler", "args.valgrind", "True"), + ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::RrFfMacScheduler", "args.valgrind", "True"), + ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::PssFfMacScheduler", "args.valgrind", "True"), + ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::PfFfMacScheduler", "args.valgrind", "True"), + ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::FdTbfqFfMacScheduler", "args.valgrind", "True"), + ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::FdMtFfMacScheduler", "args.valgrind", "True"), + ("lena-simple-epc --simTime=1.1 --ns3::LteHelper::Scheduler=ns3::FdBetFfMacScheduler", "args.valgrind", "True"), ("lena-ipv6-addr-conf", "True", "True"), ("lena-ipv6-ue-rh", "True", "True"), ("lena-ipv6-ue-ue", "True", "True"), diff --git a/src/lte/test/lte-ffr-simple.cc b/src/lte/test/lte-ffr-simple.cc index faf08bf74..2ebf0e2c6 100644 --- a/src/lte/test/lte-ffr-simple.cc +++ b/src/lte/test/lte-ffr-simple.cc @@ -224,15 +224,13 @@ LteFfrSimple::DoIsUlRbgAvailableForUe(int i, uint16_t rnti) } void -LteFfrSimple::DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) +LteFfrSimple::DoReportDlCqiInfo(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); } void -LteFfrSimple::DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) +LteFfrSimple::DoReportUlCqiInfo(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION(this); } diff --git a/src/lte/test/lte-ffr-simple.h b/src/lte/test/lte-ffr-simple.h index 57220757f..492e5e40d 100644 --- a/src/lte/test/lte-ffr-simple.h +++ b/src/lte/test/lte-ffr-simple.h @@ -108,9 +108,9 @@ class LteFfrSimple : public LteFfrAlgorithm std::vector DoGetAvailableUlRbg() override; bool DoIsUlRbgAvailableForUe(int i, uint16_t rnti) override; void DoReportDlCqiInfo( - const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo( - const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; + const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) override; void DoReportUlCqiInfo(std::map> ulCqiMap) override; uint8_t DoGetTpc(uint16_t rnti) override; uint16_t DoGetMinContinuousUlBandwidth() override; diff --git a/src/lte/test/lte-test-carrier-aggregation-configuration.cc b/src/lte/test/lte-test-carrier-aggregation-configuration.cc index 958896a3d..8431c0b59 100644 --- a/src/lte/test/lte-test-carrier-aggregation-configuration.cc +++ b/src/lte/test/lte-test-carrier-aggregation-configuration.cc @@ -370,7 +370,7 @@ CarrierAggregationConfigTestCase::DoRun() } // Activate a data radio bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/test/lte-test-carrier-aggregation.cc b/src/lte/test/lte-test-carrier-aggregation.cc index 3276144e5..e80b3eeb8 100644 --- a/src/lte/test/lte-test-carrier-aggregation.cc +++ b/src/lte/test/lte-test-carrier-aggregation.cc @@ -49,6 +49,7 @@ #include #include +#include using namespace ns3; @@ -376,7 +377,7 @@ CarrierAggregationTestCase::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/test/lte-test-carrier-aggregation.h b/src/lte/test/lte-test-carrier-aggregation.h index 1af31ba43..080da0522 100644 --- a/src/lte/test/lte-test-carrier-aggregation.h +++ b/src/lte/test/lte-test-carrier-aggregation.h @@ -27,6 +27,8 @@ #include "ns3/simulator.h" #include "ns3/test.h" +#include + using namespace ns3; /** 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 2c9f257d0..00c31222e 100644 --- a/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc @@ -431,7 +431,7 @@ LenaCqaFfMacSchedulerTestCase1::DoRun() qos.mbrDl = 0; qos.mbrUl = 0; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDedicatedEpsBearer(ueDevice, bearer, EpcTft::Default()); } @@ -690,7 +690,7 @@ LenaCqaFfMacSchedulerTestCase2::DoRun() qos.mbrDl = qos.gbrDl; qos.mbrUl = qos.gbrUl; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDedicatedEpsBearer(ueDevice, bearer, EpcTft::Default()); } diff --git a/src/lte/test/lte-test-cqi-generation.cc b/src/lte/test/lte-test-cqi-generation.cc index e3946eb3a..d522b5054 100644 --- a/src/lte/test/lte-test-cqi-generation.cc +++ b/src/lte/test/lte-test-cqi-generation.cc @@ -267,7 +267,7 @@ LteCqiGenerationTestCase::DoRun() lteHelper->Attach(ueDevs2, enbDevs.Get(1)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs1, bearer); lteHelper->ActivateDataRadioBearer(ueDevs2, bearer); @@ -417,7 +417,7 @@ LteCqiGenerationDlPowerControlTestCase::DoRun() lteHelper->Attach(ueDevs2, enbDevs.Get(1)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs1, bearer); lteHelper->ActivateDataRadioBearer(ueDevs2, bearer); diff --git a/src/lte/test/lte-test-deactivate-bearer.cc b/src/lte/test/lte-test-deactivate-bearer.cc index b9e849808..bee2d6bd5 100644 --- a/src/lte/test/lte-test-deactivate-bearer.cc +++ b/src/lte/test/lte-test-deactivate-bearer.cc @@ -271,7 +271,7 @@ LenaDeactivateBearerTestCase::DoRun() qos.mbrDl = qos.gbrDl; qos.mbrUl = qos.gbrUl; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); bearer.arp.priorityLevel = 15 - (u + 1); bearer.arp.preemptionCapability = true; diff --git a/src/lte/test/lte-test-downlink-power-control.cc b/src/lte/test/lte-test-downlink-power-control.cc index 46832ac3d..188e22c83 100644 --- a/src/lte/test/lte-test-downlink-power-control.cc +++ b/src/lte/test/lte-test-downlink-power-control.cc @@ -489,7 +489,7 @@ LteDownlinkPowerControlTestCase::DoRun() simpleFfrAlgorithm->SetPdschConfigDedicated(m_pdschConfigDedicated); // Activate the default EPS bearer - enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; + EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); @@ -659,7 +659,7 @@ LteDownlinkPowerControlRrcConnectionReconfigurationTestCase::DoRun() simpleFfrAlgorithm->SetPdschConfigDedicated(pdschConfigDedicated); // Activate the default EPS bearer - enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; + EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); 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 5421812aa..42b273052 100644 --- a/src/lte/test/lte-test-fdbet-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-fdbet-ff-mac-scheduler.cc @@ -280,7 +280,7 @@ LenaFdBetFfMacSchedulerTestCase1::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); @@ -462,7 +462,7 @@ LenaFdBetFfMacSchedulerTestCase2::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/test/lte-test-fdmt-ff-mac-scheduler.cc b/src/lte/test/lte-test-fdmt-ff-mac-scheduler.cc index 2b9131839..805f2d046 100644 --- a/src/lte/test/lte-test-fdmt-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-fdmt-ff-mac-scheduler.cc @@ -257,7 +257,7 @@ LenaFdMtFfMacSchedulerTestCase::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); 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 2eb1a6f68..94ed69e5f 100644 --- a/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc @@ -432,7 +432,7 @@ LenaFdTbfqFfMacSchedulerTestCase1::DoRun() qos.mbrDl = qos.gbrDl; qos.mbrUl = 0; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDedicatedEpsBearer(ueDevice, bearer, EpcTft::Default()); } @@ -704,7 +704,7 @@ LenaFdTbfqFfMacSchedulerTestCase2::DoRun() qos.mbrDl = qos.gbrDl; qos.mbrUl = 0; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDedicatedEpsBearer(ueDevice, bearer, EpcTft::Default()); } diff --git a/src/lte/test/lte-test-frequency-reuse.cc b/src/lte/test/lte-test-frequency-reuse.cc index cc96b9cfa..00424214e 100644 --- a/src/lte/test/lte-test-frequency-reuse.cc +++ b/src/lte/test/lte-test-frequency-reuse.cc @@ -487,7 +487,7 @@ LteFrTestCase::DlDataRxStart(Ptr spectrumValue) NS_LOG_DEBUG("RB " << i << " POWER: " << " " << power << " isAvailable: " << m_availableDlRb[i]); - if (m_availableDlRb[i] == false && power > 0) + if (!m_availableDlRb[i] && power > 0) { m_usedMutedDlRbg = true; } @@ -507,7 +507,7 @@ LteFrTestCase::UlDataRxStart(Ptr spectrumValue) NS_LOG_DEBUG("RB " << i << " POWER: " << " " << power << " isAvailable: " << m_availableUlRb[i]); - if (m_availableUlRb[i] == false && power > 0) + if (!m_availableUlRb[i] && power > 0) { m_usedMutedUlRbg = true; } @@ -598,7 +598,7 @@ LteHardFrTestCase::DoRun() qos.gbrUl = 1e4; qos.gbrDl = 1e4; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); @@ -736,7 +736,7 @@ LteStrictFrTestCase::DoRun() qos.gbrUl = 1e4; qos.gbrDl = 1e4; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); @@ -832,11 +832,11 @@ LteFrAreaTestCase::DlDataRxStart(Ptr spectrumValue) << " " << power << " Available: " << m_expectedDlRb[i] << " Expected Power: " << m_expectedDlPower); - if (m_expectedDlRb[i] == false && power > 0) + if (!m_expectedDlRb[i] && power > 0) { m_usedWrongDlRbg = true; } - else if (m_expectedDlRb[i] == true && power > 0) + else if (m_expectedDlRb[i] && power > 0) { NS_TEST_ASSERT_MSG_EQ_TOL(power, m_expectedDlPower, @@ -869,7 +869,7 @@ LteFrAreaTestCase::UlDataRxStart(Ptr spectrumValue) { // Count the RB as active if it is part of // the expected UL RBs and has Power Spectral Density (PSD) > 0 - if (m_expectedUlRb[numActiveRbs] == true && (*it) > 0) + if (m_expectedUlRb[numActiveRbs] && (*it) > 0) { numActiveRbs++; } @@ -883,11 +883,11 @@ LteFrAreaTestCase::UlDataRxStart(Ptr spectrumValue) double power = (*it) * (numActiveRbs * 180000); NS_LOG_DEBUG("RB " << i << " POWER: " << power << " expectedUlPower: " << m_expectedUlPower); - if (m_expectedUlRb[i] == false && power > 0) + if (!m_expectedUlRb[i] && power > 0) { m_usedWrongUlRbg = true; } - else if (m_expectedUlRb[i] == true && power > 0) + else if (m_expectedUlRb[i] && power > 0) { NS_TEST_ASSERT_MSG_EQ_TOL(power, m_expectedUlPower, @@ -1066,7 +1066,7 @@ LteStrictFrAreaTestCase::DoRun() qos.gbrUl = 1e4; qos.gbrDl = 1e4; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDataRadioBearer(ueDevs1, bearer); @@ -1283,7 +1283,7 @@ LteSoftFrAreaTestCase::DoRun() qos.gbrUl = 1e4; qos.gbrDl = 1e4; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDataRadioBearer(ueDevs1, bearer); lteHelper->ActivateDataRadioBearer(ueDevs2, bearer); @@ -1512,7 +1512,7 @@ LteSoftFfrAreaTestCase::DoRun() qos.gbrUl = 1e4; qos.gbrDl = 1e4; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDataRadioBearer(ueDevs1, bearer); lteHelper->ActivateDataRadioBearer(ueDevs2, bearer); @@ -1783,7 +1783,7 @@ LteEnhancedFfrAreaTestCase::DoRun() qos.gbrUl = 1e4; qos.gbrDl = 1e4; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDataRadioBearer(ueDevs1, bearer); lteHelper->ActivateDataRadioBearer(ueDevs2, bearer); @@ -2159,7 +2159,7 @@ LteDistributedFfrAreaTestCase::DoRun() qos.gbrUl = 1e4; qos.gbrDl = 1e4; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDedicatedEpsBearer(ueLteDevs.Get(u), bearer, tft); diff --git a/src/lte/test/lte-test-harq.cc b/src/lte/test/lte-test-harq.cc index b6d7b0ead..ca8184d8a 100644 --- a/src/lte/test/lte-test-harq.cc +++ b/src/lte/test/lte-test-harq.cc @@ -209,7 +209,7 @@ LenaHarqTestCase::DoRun() lena->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lena->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/test/lte-test-interference-fr.cc b/src/lte/test/lte-test-interference-fr.cc index aecb9779b..e6c231a3d 100644 --- a/src/lte/test/lte-test-interference-fr.cc +++ b/src/lte/test/lte-test-interference-fr.cc @@ -217,7 +217,7 @@ LteInterferenceHardFrTestCase::DoRun() lteHelper->Attach(ueDevs2, enbDevs.Get(1)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs1, bearer); lteHelper->ActivateDataRadioBearer(ueDevs2, bearer); @@ -404,7 +404,7 @@ LteInterferenceStrictFrTestCase::DoRun() lteHelper->Attach(ueDevs2, enbDevs.Get(1)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs1, bearer); lteHelper->ActivateDataRadioBearer(ueDevs2, bearer); diff --git a/src/lte/test/lte-test-interference.cc b/src/lte/test/lte-test-interference.cc index 33162e416..33e919394 100644 --- a/src/lte/test/lte-test-interference.cc +++ b/src/lte/test/lte-test-interference.cc @@ -278,7 +278,7 @@ LteInterferenceTestCase::DoRun() lteHelper->Attach(ueDevs2, enbDevs.Get(1)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs1, bearer); lteHelper->ActivateDataRadioBearer(ueDevs2, bearer); diff --git a/src/lte/test/lte-test-ipv6-routing.cc b/src/lte/test/lte-test-ipv6-routing.cc index f6ab82189..c09559566 100644 --- a/src/lte/test/lte-test-ipv6-routing.cc +++ b/src/lte/test/lte-test-ipv6-routing.cc @@ -181,7 +181,7 @@ LteIpv6RoutingTestCase::Checker() Ptr p2 = (*it2)->Copy(); Ipv6Header ipv6header2; p2->RemoveHeader(ipv6header2); - Ipv6Address sorceAddress = ipv6header2.GetSource(); + Ipv6Address sourceAddress = ipv6header2.GetSource(); Ipv6Address destinationAddress = ipv6header2.GetDestination(); UdpHeader udpHeader2; p2->RemoveHeader(udpHeader2); @@ -190,7 +190,7 @@ LteIpv6RoutingTestCase::Checker() sourcePort = udpHeader2.GetSourcePort(); destinationPort = udpHeader2.GetDestinationPort(); // Check whether the uids, addresses and ports match - if ((p2->GetUid() == p1->GetUid()) && sorceAddress == ipv6header1.GetDestination() && + if ((p2->GetUid() == p1->GetUid()) && sourceAddress == ipv6header1.GetDestination() && destinationAddress == ipv6header1.GetSource() && sourcePort == udpHeader1.GetDestinationPort() && destinationPort == udpHeader1.GetSourcePort()) diff --git a/src/lte/test/lte-test-link-adaptation.cc b/src/lte/test/lte-test-link-adaptation.cc index 75fa7d2d3..0c72f614a 100644 --- a/src/lte/test/lte-test-link-adaptation.cc +++ b/src/lte/test/lte-test-link-adaptation.cc @@ -189,7 +189,7 @@ LteLinkAdaptationTestCase::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate the default EPS bearer - enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; + EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/test/lte-test-mimo.cc b/src/lte/test/lte-test-mimo.cc index 1e3934461..e1768a47d 100644 --- a/src/lte/test/lte-test-mimo.cc +++ b/src/lte/test/lte-test-mimo.cc @@ -183,7 +183,7 @@ LenaMimoTestCase::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/test/lte-test-pathloss-model.cc b/src/lte/test/lte-test-pathloss-model.cc index 425e32f7c..95e35299e 100644 --- a/src/lte/test/lte-test-pathloss-model.cc +++ b/src/lte/test/lte-test-pathloss-model.cc @@ -238,7 +238,7 @@ LtePathlossModelSystemTestCase::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); 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 bc02ce263..86db09f4a 100644 --- a/src/lte/test/lte-test-pf-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-pf-ff-mac-scheduler.cc @@ -297,7 +297,7 @@ LenaPfFfMacSchedulerTestCase1::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); @@ -476,7 +476,7 @@ LenaPfFfMacSchedulerTestCase2::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/test/lte-test-phy-error-model.cc b/src/lte/test/lte-test-phy-error-model.cc index 2c4b96f3e..689375394 100644 --- a/src/lte/test/lte-test-phy-error-model.cc +++ b/src/lte/test/lte-test-phy-error-model.cc @@ -205,7 +205,7 @@ LenaDataPhyErrorModelTestCase::DoRun() lena->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lena->ActivateDataRadioBearer(ueDevs, bearer); @@ -366,7 +366,7 @@ LenaDlCtrlPhyErrorModelTestCase::DoRun() lena->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lena->ActivateDataRadioBearer(ueDevs, bearer); 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 ddc785508..e1a876c94 100644 --- a/src/lte/test/lte-test-pss-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-pss-ff-mac-scheduler.cc @@ -429,7 +429,7 @@ LenaPssFfMacSchedulerTestCase1::DoRun() qos.mbrDl = 0; qos.mbrUl = 0; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDedicatedEpsBearer(ueDevice, bearer, EpcTft::Default()); } @@ -692,7 +692,7 @@ LenaPssFfMacSchedulerTestCase2::DoRun() qos.mbrDl = qos.gbrDl; qos.mbrUl = qos.gbrUl; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDedicatedEpsBearer(ueDevice, bearer, EpcTft::Default()); } diff --git a/src/lte/test/lte-test-radio-link-failure.h b/src/lte/test/lte-test-radio-link-failure.h index 36419fc5b..7d58eebbc 100644 --- a/src/lte/test/lte-test-radio-link-failure.h +++ b/src/lte/test/lte-test-radio-link-failure.h @@ -21,6 +21,7 @@ #define LTE_TEST_RADIO_LINK_FAILURE_H #include +#include #include #include #include diff --git a/src/lte/test/lte-test-rr-ff-mac-scheduler.cc b/src/lte/test/lte-test-rr-ff-mac-scheduler.cc index cdb7e11b3..531e2a248 100644 --- a/src/lte/test/lte-test-rr-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-rr-ff-mac-scheduler.cc @@ -266,7 +266,7 @@ LenaRrFfMacSchedulerTestCase::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); 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 c73c5115c..0c20b0a58 100644 --- a/src/lte/test/lte-test-tdbet-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-tdbet-ff-mac-scheduler.cc @@ -283,7 +283,7 @@ LenaTdBetFfMacSchedulerTestCase1::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); @@ -467,7 +467,7 @@ LenaTdBetFfMacSchedulerTestCase2::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/test/lte-test-tdmt-ff-mac-scheduler.cc b/src/lte/test/lte-test-tdmt-ff-mac-scheduler.cc index 1b4d3e993..a8caaa131 100644 --- a/src/lte/test/lte-test-tdmt-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-tdmt-ff-mac-scheduler.cc @@ -259,7 +259,7 @@ LenaTdMtFfMacSchedulerTestCase::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); 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 055a8f7f9..40cbcda8e 100644 --- a/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc @@ -432,7 +432,7 @@ LenaTdTbfqFfMacSchedulerTestCase1::DoRun() qos.mbrDl = qos.gbrDl; qos.mbrUl = 0; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDedicatedEpsBearer(ueDevice, bearer, EpcTft::Default()); } @@ -702,7 +702,7 @@ LenaTdTbfqFfMacSchedulerTestCase2::DoRun() qos.mbrDl = qos.gbrDl; qos.mbrUl = 0; - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q, qos); lteHelper->ActivateDedicatedEpsBearer(ueDevice, bearer, EpcTft::Default()); } diff --git a/src/lte/test/lte-test-tta-ff-mac-scheduler.cc b/src/lte/test/lte-test-tta-ff-mac-scheduler.cc index 12c4d2a30..905539129 100644 --- a/src/lte/test/lte-test-tta-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-tta-ff-mac-scheduler.cc @@ -259,7 +259,7 @@ LenaTtaFfMacSchedulerTestCase::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/test/lte-test-ue-measurements.cc b/src/lte/test/lte-test-ue-measurements.cc index cec4d97b2..2ade5de4b 100644 --- a/src/lte/test/lte-test-ue-measurements.cc +++ b/src/lte/test/lte-test-ue-measurements.cc @@ -324,7 +324,7 @@ LteUeMeasurementsTestCase::DoRun() lteHelper->Attach(ueDevs2, enbDevs.Get(1)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs1, bearer); lteHelper->ActivateDataRadioBearer(ueDevs2, bearer); @@ -794,7 +794,7 @@ LteUeMeasurementsPiecewiseTestCase1::DoRun() lteHelper->Attach(ueDevs.Get(0), enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); @@ -1502,7 +1502,7 @@ LteUeMeasurementsPiecewiseTestCase2::DoRun() lteHelper->Attach(ueDevs.Get(0), enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); @@ -1826,7 +1826,7 @@ LteUeMeasurementsPiecewiseTestCase3::DoRun() lteHelper->Attach(ueDevs.Get(0), enbDevs.Get(0)); // Activate an EPS bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/test/lte-test-uplink-power-control.cc b/src/lte/test/lte-test-uplink-power-control.cc index 6b16d2092..9e37e8599 100644 --- a/src/lte/test/lte-test-uplink-power-control.cc +++ b/src/lte/test/lte-test-uplink-power-control.cc @@ -279,7 +279,7 @@ LteUplinkOpenLoopPowerControlTestCase::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate a data radio bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); @@ -462,7 +462,7 @@ LteUplinkClosedLoopPowerControlAbsoluteModeTestCase::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate a data radio bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); @@ -626,7 +626,7 @@ LteUplinkClosedLoopPowerControlAccumulatedModeTestCase::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate a data radio bearer - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/test/test-lte-antenna.cc b/src/lte/test/test-lte-antenna.cc index 9d5a8c7c8..ce630d405 100644 --- a/src/lte/test/test-lte-antenna.cc +++ b/src/lte/test/test-lte-antenna.cc @@ -174,7 +174,7 @@ LteEnbAntennaTestCase::DoRun() lteHelper->Attach(ueDevs, enbDevs.Get(0)); // Activate the default EPS bearer - enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; + EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; EpsBearer bearer(q); lteHelper->ActivateDataRadioBearer(ueDevs, bearer); diff --git a/src/lte/test/test-lte-handover-delay.cc b/src/lte/test/test-lte-handover-delay.cc index 7cf84a4e0..783831d19 100644 --- a/src/lte/test/test-lte-handover-delay.cc +++ b/src/lte/test/test-lte-handover-delay.cc @@ -20,6 +20,7 @@ #include #include +#include #include #include #include diff --git a/src/lte/test/test-lte-handover-failure.cc b/src/lte/test/test-lte-handover-failure.cc index 96255ce9b..5181a121b 100644 --- a/src/lte/test/test-lte-handover-failure.cc +++ b/src/lte/test/test-lte-handover-failure.cc @@ -110,7 +110,7 @@ class LteHandoverFailureTestCase : public TestCase m_handoverJoiningTimeout(handoverJoiningTimeout), m_handoverLeavingTimeout(handoverLeavingTimeout), m_targeteNodeBPosition(targeteNodeBPosition), - m_hasHandoverFailureOccured(false) + m_hasHandoverFailureOccurred(false) { } @@ -198,8 +198,8 @@ class LteHandoverFailureTestCase : public TestCase uint8_t m_raResponseWindowSize; ///< window length for reception of RAR Time m_handoverJoiningTimeout; ///< handover joining timeout duration at target eNodeB Time m_handoverLeavingTimeout; ///< handover leaving timeout duration at source eNodeB - uint16_t m_targeteNodeBPosition; ///< position of the target eNodeB - bool m_hasHandoverFailureOccured; ///< has handover failure occurred in simulation + uint16_t m_targeteNodeBPosition; ///< position of the target eNodeB + bool m_hasHandoverFailureOccurred; ///< has handover failure occurred in simulation }; // end of class LteHandoverFailureTestCase @@ -321,7 +321,7 @@ LteHandoverFailureTestCase::HandoverFailureMaxRach(std::string context, uint16_t targetCellId) { NS_LOG_FUNCTION(this << context << imsi << rnti << targetCellId); - m_hasHandoverFailureOccured = true; + m_hasHandoverFailureOccurred = true; } void @@ -331,7 +331,7 @@ LteHandoverFailureTestCase::HandoverFailureNoPreamble(std::string context, uint16_t targetCellId) { NS_LOG_FUNCTION(this << context << imsi << rnti << targetCellId); - m_hasHandoverFailureOccured = true; + m_hasHandoverFailureOccurred = true; } void @@ -341,7 +341,7 @@ LteHandoverFailureTestCase::HandoverFailureJoining(std::string context, uint16_t targetCellId) { NS_LOG_FUNCTION(this << context << imsi << rnti << targetCellId); - m_hasHandoverFailureOccured = true; + m_hasHandoverFailureOccurred = true; } void @@ -351,14 +351,14 @@ LteHandoverFailureTestCase::HandoverFailureLeaving(std::string context, uint16_t targetCellId) { NS_LOG_FUNCTION(this << context << imsi << rnti << targetCellId); - m_hasHandoverFailureOccured = true; + m_hasHandoverFailureOccurred = true; } void LteHandoverFailureTestCase::DoTeardown() { NS_LOG_FUNCTION(this); - NS_TEST_ASSERT_MSG_EQ(m_hasHandoverFailureOccured, true, "Handover failure did not occur"); + NS_TEST_ASSERT_MSG_EQ(m_hasHandoverFailureOccurred, true, "Handover failure did not occur"); } /** diff --git a/src/lte/test/test-lte-rrc.cc b/src/lte/test/test-lte-rrc.cc index c7a1865ce..6210d4375 100644 --- a/src/lte/test/test-lte-rrc.cc +++ b/src/lte/test/test-lte-rrc.cc @@ -389,7 +389,7 @@ LteRrcConnectionEstablishmentTestCase::Connect(Ptr ueDevice, PtrActivateDataRadioBearer(ueDevice, bearer); } @@ -784,13 +784,10 @@ LteRrcTestSuite::LteRrcTestSuite() for (uint32_t useIdealRrc = 0; useIdealRrc <= 1; ++useIdealRrc) { - // <----- all times in ms -----------------> + // <----- all times in ms -----------------> - // nUes tConnBase delayDiscStart - // useIdealRrc - // nBearers tConnIncrPerUe - // errorExpected - // admitRrcConnectionRequest + // nUes tConnBase delayDiscStart useIdealRrc nBearers tConnIncrPerUe errorExpected + // admitRrcConnectionRequest AddTestCase( new LteRrcConnectionEstablishmentTestCase(1, 0, 0, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE); diff --git a/src/lte/test/test-lte-x2-handover-measures.cc b/src/lte/test/test-lte-x2-handover-measures.cc index c452d85bb..cf32f7a95 100644 --- a/src/lte/test/test-lte-x2-handover-measures.cc +++ b/src/lte/test/test-lte-x2-handover-measures.cc @@ -527,7 +527,7 @@ LteX2HandoverMeasuresTestCase::DoRun() Ptr ueDev = ueDevices.Get(u); for (uint32_t b = 0; b < m_nDedicatedBearers; ++b) { - enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; + EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; EpsBearer bearer(q); m_lteHelper->ActivateDataRadioBearer(ueDev, bearer); } @@ -565,13 +565,12 @@ LteX2HandoverMeasuresTestCase::DoRun() ueDevices.Get(checkPointEventIt->ueDeviceIndex), enbDevices.Get(checkPointEventIt->enbDeviceIndex)); - Time saveStatsTime = checkPointTime; - Simulator::Schedule(saveStatsTime, + Simulator::Schedule(checkPointTime, &LteX2HandoverMeasuresTestCase::SaveStats, this, checkPointEventIt->ueDeviceIndex); - Time checkStats = saveStatsTime + m_statsDuration; + Time checkStats = checkPointTime + m_statsDuration; Simulator::Schedule(checkStats, &LteX2HandoverMeasuresTestCase::CheckStats, this, diff --git a/src/lte/test/test-lte-x2-handover.cc b/src/lte/test/test-lte-x2-handover.cc index 8358d3082..7185b48c3 100644 --- a/src/lte/test/test-lte-x2-handover.cc +++ b/src/lte/test/test-lte-x2-handover.cc @@ -427,7 +427,7 @@ LteX2HandoverTestCase::DoRun() Ptr ueDev = ueDevices.Get(u); for (uint32_t b = 0; b < m_nDedicatedBearers; ++b) { - enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; + EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT; EpsBearer bearer(q); m_lteHelper->ActivateDataRadioBearer(ueDev, bearer); } @@ -708,48 +708,48 @@ LteX2HandoverTestSuite::LteX2HandoverTestSuite() ue2bwd.sourceEnbDeviceIndex = 1; ue2bwd.targetEnbDeviceIndex = 0; - std::string hel0name("none"); - std::list hel0; + std::string handoverEventList0name("none"); + std::list handoverEventList0; - std::string hel1name("1 fwd"); - const std::list hel1{ + std::string handoverEventList1name("1 fwd"); + const std::list handoverEventList1{ ue1fwd, }; - std::string hel2name("1 fwd & bwd"); - const std::list hel2{ + std::string handoverEventList2name("1 fwd & bwd"); + const std::list handoverEventList2{ ue1fwd, ue1bwd, }; - std::string hel3name("1 fwd & bwd & fwd"); - const std::list hel3{ + std::string handoverEventList3name("1 fwd & bwd & fwd"); + const std::list handoverEventList3{ ue1fwd, ue1bwd, ue1fwdagain, }; - std::string hel4name("1+2 fwd"); - const std::list hel4{ + std::string handoverEventList4name("1+2 fwd"); + const std::list handoverEventList4{ ue1fwd, ue2fwd, }; - std::string hel5name("1+2 fwd & bwd"); - const std::list hel5{ + std::string handoverEventList5name("1+2 fwd & bwd"); + const std::list handoverEventList5{ ue1fwd, ue1bwd, ue2fwd, ue2bwd, }; - // std::string hel6name("2 fwd"); - // const std::list hel6{ + // std::string handoverEventList6name("2 fwd"); + // const std::list handoverEventList6{ // ue2fwd, // }; - // std::string hel7name("2 fwd & bwd"); - // const std::list hel7{ + // std::string handoverEventList7name("2 fwd & bwd"); + // const std::list handoverEventList7{ // ue2fwd, // ue2bwd, // }; @@ -766,126 +766,326 @@ LteX2HandoverTestSuite::LteX2HandoverTestSuite() for (int32_t useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc) { // nUes, nDBearers, helist, name, sched, admitHo, idealRrc - AddTestCase( - new LteX2HandoverTestCase(1, 0, hel0, hel0name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 0, hel0, hel0name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 5, hel0, hel0name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 5, hel0, hel0name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 0, hel1, hel1name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 1, hel1, hel1name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 2, hel1, hel1name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 0, hel1, hel1name, *schedIt, false, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 1, hel1, hel1name, *schedIt, false, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 2, hel1, hel1name, *schedIt, false, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 0, hel1, hel1name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 1, hel1, hel1name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 2, hel1, hel1name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 0, hel1, hel1name, *schedIt, false, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 1, hel1, hel1name, *schedIt, false, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 2, hel1, hel1name, *schedIt, false, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 0, hel2, hel2name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 1, hel2, hel2name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 2, hel2, hel2name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 0, hel3, hel3name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 1, hel3, hel3name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(1, 2, hel3, hel3name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 0, hel3, hel3name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 1, hel3, hel3name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 2, hel3, hel3name, *schedIt, true, useIdealRrc), - TestCase::QUICK); - AddTestCase( - new LteX2HandoverTestCase(2, 0, hel4, hel4name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 1, hel4, hel4name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 2, hel4, hel4name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 0, hel5, hel5name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 1, hel5, hel5name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(2, 2, hel5, hel5name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(3, 0, hel3, hel3name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(3, 1, hel3, hel3name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(3, 2, hel3, hel3name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(3, 0, hel4, hel4name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(3, 1, hel4, hel4name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(3, 2, hel4, hel4name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(3, 0, hel5, hel5name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(3, 1, hel5, hel5name, *schedIt, true, useIdealRrc), - TestCase::EXTENSIVE); - AddTestCase( - new LteX2HandoverTestCase(3, 2, hel5, hel5name, *schedIt, true, useIdealRrc), - TestCase::QUICK); + AddTestCase(new LteX2HandoverTestCase(1, + 0, + handoverEventList0, + handoverEventList0name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 0, + handoverEventList0, + handoverEventList0name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 5, + handoverEventList0, + handoverEventList0name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 5, + handoverEventList0, + handoverEventList0name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 0, + handoverEventList1, + handoverEventList1name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 1, + handoverEventList1, + handoverEventList1name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 2, + handoverEventList1, + handoverEventList1name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 0, + handoverEventList1, + handoverEventList1name, + *schedIt, + false, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 1, + handoverEventList1, + handoverEventList1name, + *schedIt, + false, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 2, + handoverEventList1, + handoverEventList1name, + *schedIt, + false, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 0, + handoverEventList1, + handoverEventList1name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 1, + handoverEventList1, + handoverEventList1name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 2, + handoverEventList1, + handoverEventList1name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 0, + handoverEventList1, + handoverEventList1name, + *schedIt, + false, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 1, + handoverEventList1, + handoverEventList1name, + *schedIt, + false, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 2, + handoverEventList1, + handoverEventList1name, + *schedIt, + false, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 0, + handoverEventList2, + handoverEventList2name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 1, + handoverEventList2, + handoverEventList2name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 2, + handoverEventList2, + handoverEventList2name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 0, + handoverEventList3, + handoverEventList3name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 1, + handoverEventList3, + handoverEventList3name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(1, + 2, + handoverEventList3, + handoverEventList3name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 0, + handoverEventList3, + handoverEventList3name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 1, + handoverEventList3, + handoverEventList3name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 2, + handoverEventList3, + handoverEventList3name, + *schedIt, + true, + useIdealRrc), + TestCase::QUICK); + AddTestCase(new LteX2HandoverTestCase(2, + 0, + handoverEventList4, + handoverEventList4name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 1, + handoverEventList4, + handoverEventList4name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 2, + handoverEventList4, + handoverEventList4name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 0, + handoverEventList5, + handoverEventList5name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 1, + handoverEventList5, + handoverEventList5name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(2, + 2, + handoverEventList5, + handoverEventList5name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(3, + 0, + handoverEventList3, + handoverEventList3name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(3, + 1, + handoverEventList3, + handoverEventList3name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(3, + 2, + handoverEventList3, + handoverEventList3name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(3, + 0, + handoverEventList4, + handoverEventList4name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(3, + 1, + handoverEventList4, + handoverEventList4name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(3, + 2, + handoverEventList4, + handoverEventList4name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(3, + 0, + handoverEventList5, + handoverEventList5name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(3, + 1, + handoverEventList5, + handoverEventList5name, + *schedIt, + true, + useIdealRrc), + TestCase::EXTENSIVE); + AddTestCase(new LteX2HandoverTestCase(3, + 2, + handoverEventList5, + handoverEventList5name, + *schedIt, + true, + useIdealRrc), + TestCase::QUICK); } } } diff --git a/src/mesh/model/dot11s/hwmp-protocol.h b/src/mesh/model/dot11s/hwmp-protocol.h index 3b53c51cf..4c317f94f 100644 --- a/src/mesh/model/dot11s/hwmp-protocol.h +++ b/src/mesh/model/dot11s/hwmp-protocol.h @@ -136,12 +136,12 @@ class HwmpProtocol : public MeshL2RoutingProtocol bool Install(Ptr mp); /** * Peer link status function - * \param meshPontAddress The MAC address of the mesh point + * \param meshPointAddress The MAC address of the mesh point * \param peerAddress The MAC address of the peer * \param interface The interface number * \param status The status of the peer link */ - void PeerLinkStatus(Mac48Address meshPontAddress, + void PeerLinkStatus(Mac48Address meshPointAddress, Mac48Address peerAddress, uint32_t interface, bool status); @@ -355,9 +355,9 @@ class HwmpProtocol : public MeshL2RoutingProtocol /// Route discovery time: TracedCallback